본문 바로가기

전체 글361

RelativeSource Binding RelativeSource를 이용하면 c# 코드 없이 순수 xaml로만 바인딩을 할 수 있다. 실행 결과는 아래와 같다. 보다시피 Window의 ActualWidth가 Label의 Content에 바인딩이 됐다. 2023. 3. 1.
DataContext Binding 별도의 타겟을 지정하지 않고 Path만 써 놓으면 DataContext를 읽게 된다. DataContext는 기본적으로 null이기 때문에, 개발자가 직접 지정해주어야 한다. 위는 xaml, 아래는 cs using System.Windows; namespace IamNamespace { /// /// Interaction logic for MainWindow.xaml /// public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); DataContext = this; } } } 이렇게 하면 MainWindow의 Title에 ActualWidth를 바인딩할 수 있다. 2023. 3. 1.
메모장의 숨겨진 기능 (2) I자 모양의 텍스트 커서를 z 뒤에다 놓자. 상태바에 Ln 26, Col 2라고 표시된 것을 알 수 있다. 이 상태에서 스크롤을 맨 위로 올린 다음, 윗 방향키를 눌러보자. 정말 놀랍게도, Ln 11, Col 2로 커서가 옮겨진 것을 확인할 수 있다. 당연한 거 아닌가 생각이 들면, notepad가 아니라 wordpad를 실행시켜서 실험해 보자. 이렇게 단순한 프로그램에 이렇게 복잡한 알고리즘이 들어가있는 게 놀랍다. 2023. 2. 25.
[C#] 오류를 파일에 기록해보자! using System; using System.IO; namespace TEST { public class Program { public static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; } private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { File.WriteAllText("exception.txt", e.ExceptionObject.ToString()); } } } 한 줄이면 딱 끝나. 이게 AppDomain.Curren.. 2023. 2. 21.
예약어에 바인딩이 된다? What’s New In Python 3.10 — Python 3.10.10 documentation What’s New In Python 3.10 — Python 3.10.10 documentation Parenthesized context managers Using enclosing parentheses for continuation across multiple lines in context managers is now supported. This allows formatting a long collection of context managers in multiple lines in a similar way as it was previously pos docs.python.org python 3.10.. 2023. 2. 19.
곰녹음기를 죽이는 방법 저장하기에 aux 넣고 저장 누르면 죽는다. 2023. 2. 19.
메모장의 숨겨진 기능! 텍스트 커서를 두고 5초간 아무것도 안 하면 커서가 더이상 깜빡이지 않는다. 2023. 2. 19.
[C# WPF] Binding Binding이란? WPF에서 쓸 수 있는 기술이다. 쓰는 방법은 무척 간단하다. 큰 따옴표 안에 {Binding}을 써 주기만 하면 끝이다. Binding을 사용할 수 있는 가장 단순하고 쉬운 방법은 ElementName을 지정한 후 그 Element의 속성을 Path로 지정해주는 것이다. 실제로 저 프로그램을 실행해보면... 프로그램 창의 Title이 ActualWidth와 실시간으로 동기화되는 것을 볼 수 있다. 2023. 2. 18.
mciSendString 음질 개선 https://stackoverflow.com/a/3694293 How do I record audio with C#/WPF? I have an application to which I want to add the ability to import small audio snippets directly from a microphone device of some sort. I already allow importing of pictures and this works okay with stackoverflow.com C#으로 목소리 녹음을 하는 방법 중 하나는 mciSendString이다. 답변에도 나와있듯이 엄청 간단하다. open, record, save 이 세 가지가 끝이다. 근데 결과물을 들으면 음질이 .. 2023. 2. 3.
[C# WPF] super mario 63의 cheat를 구현해 보자. super mario 63에는 "cheat"를 입력하면 모든 것을 잠금 해제할 수 있는 창이 나온다. wpf에서도 창에 cheat를 입력하면 이벤트가 발생하도록 할 수 있을까? using System.Windows; using System.Windows.Input; namespace cheat { public partial class MainWindow : Window { private int cheatIndex = 0; private Key[] cheatKeys = {Key.C, Key.H,Key.E,Key.A,Key.T}; public MainWindow() { InitializeComponent(); } protected override void OnKeyDown(KeyEventArgs e) { b.. 2023. 2. 3.