전체 글

· Csharp
1 2 3 4 5 6 7 Colored by Color Scripter cs WindowStyle: 윈도우의 외각선 설정, "None" AllowsTransparency: 윈도우의 배경의 투명성 허용 여부, "True" Background: 윈도의 뒷배경 색깔 설정, "{x:Null}"
· Csharp
C# 의 데이터 저장방식인 직렬화(Serialize), 역직렬화(Deserialize) 도중 다음과 같은 예외가 뜰수도 있음. System.MemberAccessException: '추상 클래스를 만들 수 없습니다' 'System.MemberAccessException' 형식의 예외가 mscorlib.dll에서 발생했지만 사용자 코드에서 처리되지 않았습니다. 추상클래스를 만들 수 없습니다. 우선 문제가 발생했던 코드는 아래와 같음 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 enum icon { Null, File, Link } [Serializable] public class ValueObject { public Enum[]..
· Csharp
Usage 윈도우의 기본 파일 탐색기를 WPF에서 활용하는 코드임. 필자는 선택한 파일의 경로를 불러오는 용도로만 사용하였으므로 거기까지만 설명함 OpenFileDialog 안에 있는 변수들로 여러 활용이 가능 할 것임. 1 2 3 4 5 6 7 8 9 private string FileExplorer() { OpenFileDialog dig = new OpenFileDialog(); bool? result = dig.ShowDialog(); if (result == true) return dig.FileName; else return string.Empty; } Colored by Color Scripter cs OpenFileDialog: 파일 탐색기 dig.ShowDialog( ): 파일 선택을 성..
· Csharp
자꾸 까먹어서 정리하는 자잘한 문법들 계속 추가할 예정 -String String.Empty: 빈 문자열을 나타냄 (읽기 전용) 1 if (name == String.Empty) cs String.IsNullOrWhiteSpace(string string): 문자열이 Null 이거나 빈 문자열이거나 공백만 있을 경우, true 반환 -Enum Enumerable.Repeat(Enum enum, int count).ToArray: 열거형을 한번에 초기화 후 배열로 초기화 1 public Enum[] state = Enumerable.Repeat(icon.Null, 16).ToArray(); cs
· Csharp
가끔 같은 유형의 객체가 여러 개를 만들어서 한번에 관리하고 싶을 때가 있는데, 예를 들어 Icon00 / Icon01 / Icon02 가 있는데, 유동적으로 변수가 00 / 01 / 02로 변하여 이 변수를 이용하여 객체에 접근하고 싶을 때가 있다. 직관적으로 생각하면 "Icon" + number 라고 해서 객체 이름을 조합할 수 있지 않을까? 라는 생각을 하게 되지만 이는 불가능하며, 우회해서 구현은 가능하지만 여러 이유로 나쁜 코드임. 하지만 관점을 바꾸면 의외로 간단한데 List 를 사용하면 됨. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 private List Images = new List(); private void InitLabels() { Images.Add(icon..
· Csharp
자료형별로 별도의 초기화하지 않으면 기본적으로 적용되는 값들이 있음 - Type bool - false double - 0.0D float - 0.0F int - 0 string - null - Array 해당 배열의 타입인 자료형 기본값을 따라감. From section 7.6.10.4 of the C# 5 specification: All elements of the new array instance are initialized to their default values (§5.2). And from section 5.2: The default value of a variable depends on the type of the variable and is determined as follows: Fo..
· Csharp
Setup Using System.Diagnostics Usage - 외부 프로그램 실행과 링크 실행 1 2 3 4 5 string path = Application.StartupPath + "\\test.exe"; Process.Start(path); string url = "www.google.com"; Process.Start(url); Colored by Color Scripter cs 프로그램의 폴더속 "test.exe" 실행 www.google.com 을 기본브라우저로 접속 - 외부 프로그램 종료 1 2 3 4 5 6 7 8 foreach (Process process in Process.GetProcesses()) { if(process.ProcessName.StartWith("test") ..
· Csharp
Setup Using System.Windows Usage MainWindow에서 다른 Window를 열땐 그 객체를 가지고 있으므로 쉽게 접근 가능하지만, 다른 Window에서 MainWindow 접근하기는 힘듬 또한 MainWindow 외의 코드들끼리도 접근하기는 힘드므로 다음 코드를 이용해야 함 1 2 3 (MainWindow)System.Windows.Application.Current.MainWindow (EditWindow)System.Windows.Application.Current.EditWindow cs - 해당 윈도우의 변수나 함수 호출할 때 1 (MainWindow)System.Windows.Application.Current.MainWindow.CallMethod cs 다음과 같이 ..
· Csharp
Setup 트레이 아이콘을 추가하기 위해서는, 프로젝트에 참조 추가를 해야함 솔루션 탐색기에서 참조를 추가할수 있으며, "System.Windows.Forms" 을 추가하면 됨 - 만약 "System.Windows.Forms" 참조를 추가한 후 MessageBox를 사용할려면, "System.Windows.MessageBox"와 "System.Windows.Forms.MessageBox" 사이 참조가 애매하다는 에러가 뜸. MessageBox를 사용할려면, 이 코드를 추가해야 함 1 using MessageBox = System.Windows.Forms.MessageBox; cs Usage 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 2..
· Csharp
WPF의 Image 컴포넌트의 기본 설정은 저품질임 따라서 Image 컴포너트를 사용할때, 종종 이렇게 이상한 이미지를 볼 수 있음 이러한 인코딩 문제를 해결하기 위해서는, XAML에서 RenderOptions을 바꾸어야 함 - RenderOptions.BitmapScallingMode="HighQuality" 그러면 이런 이미지를 볼 수 있음
sckwon770
sckwon770