SystemProperty SystemState'in hangi özelliği takip edeceği bilgisini barındıran enumeration'dır. Eğer değişikliklerde SystemState'in changed event'ının fırlatılması isteniyorsa bu özellik SystemState class'ının constructor'unda verilmelidir. Bu özelliğin sadece değerinin okunması isteniyorsa SystemState class'ının her bir SystemProperty için static bir property'si bulunmaktadır. Bu property'den ilgili özelliğe ait anlık değerler okunabilir. Öncelikle SystemProperty enum'unun bize ne gibi özellikleri takip etme fırsatı sunduğuna bakalım sonra ise SystemState ve SystemProperty'nin kullanımını inceleyelim.
SystemProperty enum'u değerleri:
MessageBox.Show("PowerBatteryState:" + Microsoft.WindowsMobile.Status.SystemState.PowerBatteryState.ToString()); MessageBox.Show("PowerBatteryStrength:" + Microsoft.WindowsMobile.Status.SystemState.PowerBatteryStrength.ToString()); MessageBox.Show("DisplayRotation:" + Microsoft.WindowsMobile.Status.SystemState.DisplayRotation.ToString()); MessageBox.Show("HeadsetPresent:" + Microsoft.WindowsMobile.Status.SystemState.HeadsetPresent.ToString());
Microsoft.WindowsMobile.Status.SystemState insSystemState = new Microsoft.WindowsMobile.Status.SystemState(SystemProperty.PowerBatteryStrength); MessageBox.Show(insSystemState.CurrentValue.ToString())
private void Form1_Load(object sender, EventArgs e) { Microsoft.WindowsMobile.Status.SystemState insSystemState = new Microsoft.WindowsMobile.Status.SystemState(SystemProperty.PhoneIncomingCallerNumber); insSystemState.Changed += new ChangeEventHandler(insSystemState_Changed); } void insSystemState_Changed(object sender, ChangeEventArgs args) { MessageBox.Show("Arayan numara : " + args.NewValue.ToString()); }
Microsoft.WindowsMobile.Status.SystemState insSystemState = new Microsoft.WindowsMobile.Status.SystemState(SystemProperty.PhoneIncomingCallerNumber); insSystemState.Changed += delegate(object s, ChangeEventArgs args) { MessageBox.Show("Arayan numara : " + args.NewValue.ToString()); };
List<SystemState> list = new List<SystemState>(); private void Form1_Load(object sender, EventArgs e) { for (int i = 0; i <= 140; i++) { SystemState s = new SystemState((SystemProperty)i); s.Changed += delegate(object obj, ChangeEventArgs args) { txtStatus.Text+= String.Format("{0} tarihinde {1} değeri {2} olarak değişti." + Environment.NewLine, DateTime.Now.ToString(), ((SystemState)obj).Property.ToString(), args.NewValue.ToString()) ; }; list.Add(s); } }