private void OnSDModelUnview(object sender, SimulateDataModelEventArgs e) { if (sender is SimulateDataViewModel) { e.SDVModel = (SimulateDataViewModel)(sender); if (SDModelUnview != null) { SDModelUnview(this, e); } } if (sender is SimuViewChartModel) { if (e.SDVModel == null) { foreach (SimulateDataViewModel sdvmodel in SDVModels) { if (sdvmodel.SDModel == e.SDModel_old) { e.SDVModel = sdvmodel; } } } if (e.SDVModel == null) { throw new KeyNotFoundException(); } //e.SDVModel.HideViewFlag(); e.SDVModel.ViewFlag.Visibility = Visibility.Hidden; e.SDVModel.MI_ViewButton.Header = "监视"; } }
//public event SimulateDataModelEventHandler SDModelSetup; private void OnSDModelSetup(object sender, SimulateDataModelEventArgs e) { if (sender is SimuViewChartModel) { if (e.SDCModel == null) { foreach (SimulateDataChartModel sdcmodel in SDCModels) { if (sdcmodel.SDModel == e.SDModel_old) { e.SDCModel = sdcmodel; break; } } } if (e.SDCModel == null) { Add(e.SDModel_new, e.ID); } else { e.SDCModel.Setup(e.SDModel_new); } } }
private void OnXYModelCreate(object sender, SimulateDataModelEventArgs e) { if (XYModelCreate != null) { XYModelCreate(this, e); } }
private void OnSDModelDraw(object sender, SimulateDataModelEventArgs e) { if (SDModelDraw != null) { SDModelDraw(this, e); } }
private void OnSDModelLock(object sender, SimulateDataModelEventArgs e) { if (sender is SimulateDataViewModel) { e.SDVModel = (SimulateDataViewModel)(sender); if (SDModelLock != null) { SDModelLock(this, e); } } if (sender is SimuViewChartModel) { if (e.SDVModel == null) { foreach (SimulateDataViewModel sdvmodel in SDVModels) { if (sdvmodel.SDModel == e.SDModel_old) { e.SDVModel = sdvmodel; } } } if (e.SDVModel == null) { throw new KeyNotFoundException(); } //e.SDVModel.ShowLockFlag(); e.SDVModel.LockFlag.Visibility = Visibility.Visible; e.SDVModel.MI_LockButton.Header = "取消锁定"; } }
private void OnSDModelDelete(object sender, SimulateDataModelEventArgs e) { foreach (SimulateDataChartModel sdcmodel in VChart.CursorCollection()) { VChart.CursorRemoveValue(sdcmodel.SDModel); } }
private void OnSDModelUnview(object sender, SimulateDataModelEventArgs e) { e.SDModel_new.IsView = false; if (SDModelUnview != null) { SDModelUnview(this, e); } }
private void OnSDModelUnlock(object sender, SimulateDataModelEventArgs e) { e.SDModel_new.IsLock = false; if (SDModelUnlock != null) { SDModelUnlock(this, e); } }
private void MI_Select_Click(object sender, RoutedEventArgs e) { SimulateDataModelEventArgs _e = new SimulateDataModelEventArgs(); if (SDModelSelect != null) { SDModelSelect(this, _e); } }
private void OnSDModelPaste(object sender, SimulateDataModelEventArgs e) { int id = e.ID; foreach (SimulateDataModel sdmodel in copysdmodels) { SimulateDataChartModel sdcmodel = VChart.SDCModels.ElementAt(id); VChart.SetValue(sdmodel, sdcmodel.SDModel, (int)(copystart), (int)(copyend), (int)(e.TimeStart), (int)(e.TimeEnd)); } }
private void MI_LoadAll_Click(object sender, RoutedEventArgs e) { SimulateDataModelEventArgs _e = new SimulateDataModelEventArgs(); _e.TimeStart = CursorTimeStart(); _e.TimeEnd = CursorTimeEnd(); if (SDModelLoadAll != null) { SDModelLoadAll(this, _e); } }
private void OnSDModelCopy(object sender, SimulateDataModelEventArgs e) { copysdmodels.Clear(); copystart = e.TimeStart; copyend = e.TimeEnd; foreach (SimulateDataChartModel sdcmodel in VChart.CursorCollection()) { SimulateDataModel sdmodel = sdcmodel.SDModel.Clone(); copysdmodels.Add(sdmodel); } }
private void OnRunDataFinished(object sender, SimulateDataModelEventArgs e) { foreach (SimulateDataChartModel sdcmodel in SDCModels) { SimulateDataModel sdmodel = sdcmodel.SDModel; if (sdmodel.IsView) { sdcmodel.Update(); } } }
private void MI_Delete_Click(object sender, RoutedEventArgs e) { SimulateDataModelEventArgs _e = new SimulateDataModelEventArgs(); _e.TimeStart = CursorTimeStart(); _e.TimeEnd = CursorTimeEnd(); if (SDModelDelete != null) { SDModelDelete(this, _e); } UpdateChart(); }
private void MI_Paste_Click(object sender, RoutedEventArgs e) { SimulateDataModelEventArgs _e = new SimulateDataModelEventArgs(); _e.TimeStart = CursorTimeStart(); _e.TimeEnd = CursorTimeEnd(); _e.ID = (int)(Math.Min(cssy, csey) / 40); if (SDModelPaste != null) { SDModelPaste(this, _e); } UpdateChart(); }
private void OnSDModelView(object sender, SimulateDataModelEventArgs e) { if (e.SDModel_old.IsLock) { e.SDModel_new.IsLock = false; if (SDModelUnlock != null) { SDModelUnlock(this, e); } } e.SDModel_new.IsView = true; if (SDModelView != null) { SDModelView(this, e); } }
private void LoadXml(string filename) { XDocument xdoc = XDocument.Load(filename); XElement node_Root = xdoc.Element("SimuDatas"); IEnumerable <XElement> node_SDModels = node_Root.Elements("SimuDataNode"); SimulateDataModelEventArgs e; foreach (SimulateDataChartModel sdcmodel in VChart.SDCModels) { SimulateDataModel sdmodel = sdcmodel.SDModel; e = new SimulateDataModelEventArgs(); e.SDModel_old = sdmodel; e.SDModel_new = null; OnSDModelClose(this, e); } //VList.Clear(); //VChart.Clear(); int id = 0; foreach (XElement node_SDModel in node_SDModels) { SimulateDataModel sdmodel = new SimulateDataModel(); sdmodel.LoadXml(node_SDModel); e = new SimulateDataModelEventArgs(); e.SDModel_new = sdmodel; e.ID = id++; if (SDModelSetup != null) { SDModelSetup(this, e); } } foreach (SimulateDataChartModel sdcmodel in VChart.SDCModels) { SimulateDataModel sdmodel = sdcmodel.SDModel; e = new SimulateDataModelEventArgs(); e.SDModel_new = sdmodel; if (sdmodel.IsLock && SDModelLock != null) { SDModelLock(this, e); } if (sdmodel.IsView && SDModelView != null) { SDModelView(this, e); } } }
private void OnSDModelClose(object sender, RoutedEventArgs e) { if (sender is SimulateDataViewModel) { SimulateDataViewModel sdvmodel = (SimulateDataViewModel)(sender); if (!SDVModels.Contains(sdvmodel)) { return; } if (SDModelClose != null) { SimulateDataModelEventArgs _e = new SimulateDataModelEventArgs(); _e.SDModel_old = sdvmodel.SDModel; _e.SDVModel = sdvmodel; SDModelClose(sender, _e); } } }
private void OnRunDrawFinished(object sender, SimulateDataModelEventArgs e) { List <SimulateDataModel> views = new List <SimulateDataModel>(); foreach (SimulateDataChartModel sdcmodel in SDCModels) { SimulateDataModel sdmodel = sdcmodel.SDModel; if (sdmodel.IsView) { views.Add(sdmodel); } } e.SDModels = views; if (XYModelCreate != null) { XYModelCreate(this, e); } }
private void OnSDModelSetup(object sender, SimulateDataModelEventArgs e) { if (sender is SimulateDataViewModel) { SimulateDataViewModel sdvmodel = (SimulateDataViewModel)(sender); e.SDVModel = sdvmodel; e.ID = 0; foreach (SimulateDataViewModel _sdvmodel in SDVModels) { if (sdvmodel == _sdvmodel) { break; } e.ID++; } if (SDModelSetup != null) { SDModelSetup(sender, e); } } if (sender is SimuViewChartModel) { if (e.SDVModel == null) { foreach (SimulateDataViewModel sdvmodel in SDVModels) { if (sdvmodel.SDModel == e.SDModel_old) { sdvmodel.SDModel = e.SDModel_new; e.SDVModel = sdvmodel; break; } } } if (e.SDVModel == null) { Add(e.SDModel_new, e.ID); } else { e.SDVModel.SDModel = e.SDModel_new; } } }
private void OnSDModelLoadAll(object sender, SimulateDataModelEventArgs e) { OpenFileDialog ofdialog = new OpenFileDialog(); ofdialog.Filter = "SimuWave文件|*.siw"; ofdialog.Title = "读取仿真波形文件"; if (ofdialog.ShowDialog() == true) { try { string filename = ofdialog.FileName; LoadXml(filename); } catch (Exception) { LocalizedMessageBox.Show("读取波形文件失败!", LocalizedMessageIcon.Error); } } }
private void OnSDModelSaveAll(object sender, SimulateDataModelEventArgs e) { SaveFileDialog sfdialog = new SaveFileDialog(); sfdialog.Filter = "SimuWave文件|*.siw"; sfdialog.Title = "保存仿真波形文件"; if (sfdialog.ShowDialog() == true) { try { string filename = sfdialog.FileName; SaveXml(filename); } catch (Exception) { LocalizedMessageBox.Show("保存波形文件失败!", LocalizedMessageIcon.Error); } } }
private void MI_ViewButton_Click(object sender, RoutedEventArgs e) { SimulateDataModelEventArgs _e = new SimulateDataModelEventArgs(); _e.SDModel_old = _e.SDModel_new = SDModel; if (!SDModel.IsView) { if (SDModelView != null) { SDModelView(this, _e); } } else { if (SDModelUnview != null) { SDModelUnview(this, _e); } } }
private void MI_LockButton_Click(object sender, RoutedEventArgs e) { SimulateDataModelEventArgs _e = new SimulateDataModelEventArgs(); _e.SDModel_old = _e.SDModel_new = SDModel; if (!SDModel.IsLock) { if (SDModelLock != null) { SDModelLock(this, _e); } } else { if (SDModelUnlock != null) { SDModelUnlock(this, _e); } } }
private void OnSDModelClose(object sender, SimulateDataModelEventArgs e) { SimulateDataModelEventArgs _e = new SimulateDataModelEventArgs(); _e.SDCModel = e.SDCModel; _e.SDVModel = e.SDVModel; if (SDModelUnlock != null && e.SDModel_old.IsLock) { _e.SDModel_old = _e.SDModel_new = e.SDModel_old; SDModelUnlock(this, _e); } if (SDModelUnview != null && e.SDModel_old.IsView) { _e.SDModel_old = _e.SDModel_new = e.SDModel_old; SDModelUnview(this, _e); } if (SDModelClose != null) { SDModelClose(this, e); } }
private void OnSDModelClose(object sender, SimulateDataModelEventArgs e) { if (sender is SimuViewChartModel) { if (e.SDVModel == null) { foreach (SimulateDataViewModel sdvmodel in SDVModels) { if (sdvmodel.SDModel == e.SDModel_old) { e.SDVModel = sdvmodel; break; } } } if (e.SDVModel == null) { throw new ArgumentException(); } Remove(e.SDVModel); } }
private void OnSDModelUnview(object sender, SimulateDataModelEventArgs e) { if (sender is SimuViewChartModel) { if (e.SDCModel == null) { foreach (SimulateDataChartModel sdcmodel in SDCModels) { if (sdcmodel.SDModel == e.SDModel_old) { e.SDCModel = sdcmodel; break; } } } if (e.SDCModel == null) { throw new KeyNotFoundException(); } e.SDCModel.Update(); } }
private void OnInputKeyUp(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { string name = NameTextInput.Text; Match m1 = Regex.Match(name, @"^\w+\d+$"); //Match m2 = Regex.Match(name, @"^\w+\[\d+\.\.\d+\]$"); //Match m3 = Regex.Match(name, @"^\w+\b\w+\d+$"); //Match m4 = Regex.Match(name, @"^\w+\b\w+\[\d+\.\.\d+\]$"); if (m1.Success) { SimulateDataModel _sdmodel = SimulateDataModel.Create(name); if (_sdmodel != null && SDModelSetup != null) { SimulateDataModelEventArgs _e = new SimulateDataModelEventArgs(); _e.SDModel_new = _sdmodel; //_e.SDVModel = this; Setup(_sdmodel); SDModelSetup(this, _e); } } } }
private void OnSDModelSelect(object sender, SimulateDataModelEventArgs e) { }