public AnalogModelControl(BackData back, AnalogConfigModel model) { this._model = model; this._backData = back; InitializeComponent(); _backData.Timer.Add(GetValue); text_id.Text = model.Name; text_port.Text = model.Port.ToString(); }
public AddAnalog(AnalogConfigModel model) { _data = model; InitializeComponent(); //加载显示的资源,资源有对应的枚举,在AppDate类注册 foreach (var i in AppData._HelperModeContext) { comboBox_HelperMode.Items.Add(i.Key); } foreach (var i in AppData._DecisionModeContext) { comboBox_Decision.Items.Add(i.Key); } }
/// <summary> /// 添加一个模拟量监听模块的点击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_AddAnalogControl(object sender, RoutedEventArgs e) { if (_adam != null) { var model = new AnalogConfigModel(); //启动添加用户控件的窗口 AddAnalog win = new AddAnalog(model); win.ShowDialog(); model = win.GetMode; //将用户控件添加到串口中 if (model != null) { var control = new AnalogModelControl(_data, model); //用户控件初始化 control.DestroyEvent += DestroyAnalogControl; //注册销毁控件事件 view_AnalogContent.Children.Add(control); //添加控件 _data.AnalogConfigModels.Add(model.ID, control); //控件注册 } } else { MessageBox.Show("请先打开串口"); } }
private void btn_Close(object sender, RoutedEventArgs e) { _data = null; this.DialogResult = false; Close(); }