본문 바로가기

IT개발/c#19

[wpf] 클립보드에 string data를 저장하자 WPF로 Clipboard 를 사용하여 복사/붙여넣기를 하는 것은 생각보다 매우 간단하다. System.Windows.Clipboard 클래스 를 사용한다. 1) 복사하기 :Clipboard.SetText (string text) , Clipboard.SetImage (BitmapSource image) 함수 사용( 이외에도 SetAudio, SetData, SetDataObject 함수도 존재함) BitmapImage img = new BitmapImage();Clipboard.SetImage(img); 2) 붙여넣기 :Clipboard.GetText(), Clipboard.GetImage(), Clipboard.GetData(), Clipboard.GetDataObject() 등의 함수 사용 Bitm.. 2014. 5. 2.
[c#] c#에서 내 컴퓨터 IP주소를 받아오는 함수 만들기 private static string getIP(){ Regex regex = new Regex(@"^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$"); foreach (System.Net.IPAddress ip in System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName()).AddressList) { if (regex.IsMatch(ip.ToString())) { return ip.ToString(); } } return null;} 2014. 4. 28.
[c#] c# 에서 Brushes.[] 클래스에서 제공하는 color table 정리 .AliceBlue240,248,255.LightSalmon255,160,122.AntiqueWhite250,235,215.LightSeaGreen32,178,170.Aqua0,255,255.LightSkyBlue135,206,250.Aquamarine127,255,212.LightSlateGray119,136,153.Azure240,255,255.LightSteelBlue176,196,222.Beige245,245,220.LightYellow255,255,224.Bisque255,228,196.Lime0,255,0.Black0,0,0.LimeGreen50,205,50.BlanchedAlmond255,255,205.Linen250,240,230.Blue0,0,255.Magenta255,0,255.Blue.. 2014. 4. 25.
[c#] string 데이터를 utf-8 로 인코딩 하여 담아보자 (string to utf-8, encoding) As you know the string is coming in as Encoding.Default you could simply use: byte[] bytes = Encoding.Default.GetBytes(myString); myString = Encoding.UTF8.GetString(bytes); 2014. 4. 25.
[c#] c# 형변환에 대해서 알아보자 프로그래밍을 하다보면 형변환을 해야 하는 경우가 많은데, 각각의 자료형 형변환에 대해서 정리했습니다. 일단 가장 기본적으로 수치 자료형들을 str형으로 바꿀때는 ""+자료형 을 해주면 str형으로 바뀝니다. 또는 각각의 ToString() 메소드를 통해서 형을 변환 시킬 수 도 있습니다. 그리고 나머지 수치 자료들은 모두 Parse() 메소드를 가지고 있습니다. 예를 들면 String str = "1234"; 라는 변수는 int a = int.Parse(str) 을 통해서 int 형으로 변환이 됩니다. double 같은 경우는 double.Parse() 가 있습니다. float, long 형 모두 같습니다. 그 외에 double를 int로 바꿀때는 앞에 (int)를 붙여주면 됩니다 예를들면 double .. 2014. 4. 23.
[WPF] ListBox 안에 Button 넣기 In this tutorial I will demonstrate how to create a listbox in WPF which is databound to a collection, we then would like to add a button to each item in the listbox. Clicking this button will button will delete that item from the collection. Making an ObservableCollection We create a small class which represents a User with a Name and Age: public class User {public string Name { get; set; } pub.. 2014. 4. 23.