int IComparable.CompareTo(object obj) { Detection d = (Detection)obj; if (String.Compare(this.Feature1, d.Feature1) == 0) { if (String.Compare(this.Feature2, d.Feature2) == 0) { if (String.Compare(this.Time, d.Time) == 0) { return(0); } } } return(1); }
public void NotifyPropertyChanged(string propName) { if (WindowisOpen == false) { return; } if (String.Compare(propName, "VM_Alarm") == 0) { this.Dispatcher.Invoke(() => { //List<Detection> detections = new List<Detection>(); //Detection d = new Detection() { Feature1 = vm.Feature1.ToString(), Feature2 = vm.Feature2.ToString(), Time = vm.AnomalyTime }; //Console.WriteLine(vm.Feature1 + "," + vm.Feature2 + "," + vm.AnomalyTime); /* * dlist.Add(new Detection() * { * Feature1 = vm.Feature1.ToString(), * Feature2 = vm.Feature2.ToString(), * Time = vm.AnomalyTime * }); */ int time = vm.AnomalyTime; string minutes = ((time / 10) / 60).ToString(); minutes = minutes.PadLeft(2, '0'); string seconds = ((time / 10) % 60).ToString(); seconds = seconds.PadLeft(2, '0'); //string milisec = ((time % 10) % 60).ToString(); // milisec = milisec.PadLeft(2, '0'); string deisplayTime = minutes + ":" + seconds; Detection d = (new Detection() { Feature1 = vm.Feature1.ToString(), Feature2 = vm.Feature2.ToString(), Time = deisplayTime }); if (detectionList.Items.Contains(d) == false) { if (detectionList.Items.Count == 10) { detectionList.Items.RemoveAt(0); } detectionList.Items.Add(d); } //detectionList.Items.Clear(); //detectionList.ItemsSource = detections; //detectionList.Items.Add(new Detection { Feature1 = vm.Feature1.ToString(), Feature2 = vm.Feature2.ToString(), Time = vm.AnomalyTime }); }); } if (String.Compare(propName, "VM_Time") == 0) { this.Dispatcher.Invoke(() => { detectionList.Items.Clear(); }); } if (String.Compare(propName, "VM_Done") == 0) { this.Dispatcher.Invoke(() => { WindowisOpen = false; this.Close(); }); } }