GetHostName 및 GetHostByName

C#/Network 2012. 6. 13. 15:10 Posted by 퓨어레드
// 호스팅 이름을 리턴한다.
string hostName = Dns.GetHostName ();

string result = string.Format ("Local hostname : {0}\r\n", hostName);

// IP 엔트리를 리턴한다.
IPHostEntry myself = Dns.GetHostByName (hostName);

foreach (IPAddress ip in myself.AddressList)

	 result += string.Format ("IP Address : {0}\r\n", ip.ToString ());


txtIpInfo.Text = result;

 

============== 결과 ================
Local hostname : red
 
IP Address : 192.168.219.12

'C# > Network' 카테고리의 다른 글

IPAddress  (0) 2012.06.13
C# POSTDATA 파일 업로드  (0) 2012.06.04
C# HttpWebRequest 클래스를 이용한 POST 전송하기  (0) 2012.06.04
Socket Server 연결 Sample  (0) 2012.04.18
Socket Client 연결 Sample  (0) 2012.04.18

XAML 하위 속성 풀어서 지정하기

C#/WPF 2012. 6. 13. 15:07 Posted by 퓨어레드

속성값에 값을 주는것 풀어서 할수 있다.

태그를 엘리먼트명.속성명이다.

 

Content 가 없는 속성들은 태그를 바로 닫아준다.

 

<Polygon xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         Points="144 48, 200 222, 53 114, 235 114, 88 222"
         Stroke="Blue"
         StrokeThickness="5">
    <Polygon.Fill>
        <RadialGradientBrush>
            <GradientStop Offset="0" Color="Blue" />
            <GradientStop Offset="1" Color="Red" />
        </RadialGradientBrush>
    </Polygon.Fill>
</Polygon>

ItemSource 로 데이터를 넣은 뒤.. ItemSource 안에 있는 내용을 수정하여 Control 에 적용하려면

ItemSource 로 들어가는 데이터에

INotifyPropertyChanged 를 구현해주면 된다.

 

샘플소스

public class UploadFileInfo : INotifyPropertyChanged
{
	long recvFileSize = 0;
	public long RecvFileSize
	{
		get { return recvFileSize; }
		set 
		{
			recvFileSize = value;
			NotifyPropertyChanged ("RecvFileSize");
		}
	}

	#region INotifyPropertyChanged Members

	private void NotifyPropertyChanged (string prop)
	{
		PropertyChangedEventHandler handler = PropertyChanged;

		if (handler != null)
			handler (this, new PropertyChangedEventArgs (prop));
	}

	public event PropertyChangedEventHandler PropertyChanged;

	#endregion