void doubleClick(object sender, RoutedEventArgs e) { //先查看是否已经打开document,如果打开,则激活就可以 foreach (TabItem item in MainWindow.Instance.documentContainer.Items) { var doc = item.Content as Documents.BaseDocument; if (doc.DataContext is DevicePoint && ((DevicePoint)doc.DataContext).id == _point.id) { //active MainWindow.Instance.documentContainer.SelectedItem = item; return; } } if (_point.Type == DevicePoint_TypeEnum.Analog) { var doc = new Documents.AnalogPointDocument(this.GetDevice(), this.Parent, _point, _point.FolderId.Value); MainWindow.Instance.SetActiveDocument(doc); } else { var doc = new Documents.DigitalPointDocument(this.GetDevice(), this.Parent, _point, _point.FolderId.Value); MainWindow.Instance.SetActiveDocument(doc); } }
void addPointClick(object sender, RoutedEventArgs e) { //获取device对象 Device device = this.GetDevice(); if (device.DriverID == null) { MessageBox.Show(MainWindow.Instance, "请先配置控制器"); return; } if (this.FolderType == DevicePointFolder_TypeEnum.Analog) { var doc = new Documents.AnalogPointDocument(device, this, null, FolderModel.id.Value); MainWindow.Instance.SetActiveDocument(doc); } else if (this.FolderType == DevicePointFolder_TypeEnum.Digital) { var doc = new Documents.DigitalPointDocument(device, this, null, FolderModel.id.Value); MainWindow.Instance.SetActiveDocument(doc); } }