private DashboardControlEdit(UserControl parent, DashboardControlDataModel dm) { this.callingUserControl = parent; this.DataModel = dm; InitializeComponent(); this.SetFieldValue(this.txtId, this.DataModel.Id, BinaryMsgDataType.typeUInt8); this.txtName.Text = this.DataModel.IOName; this.cbDataType.ItemsSource = this.typeList; this.cbDataType.SelectedItem = this.typeList.Find(x => x.DataType == this.DataModel.DataType); this.currentDataType = this.DataModel.DataType; this.SetFieldValue(this.txtMin, this.DataModel.Minimum, this.DataModel.DataType); this.SetFieldValue(this.txtMax, this.DataModel.Maximum, this.DataModel.DataType); this.SetFieldValue(this.txtStep, this.DataModel.SendAtStep, this.DataModel.DataType); // User display show visual value row and colum this.lblRow.Content = this.DataModel.Row + 1; this.lblColum.Content = this.DataModel.Column - 1; if (this.DataModel.DataType == BinaryMsgDataType.typeBool) { this.rowMin.Height = new GridLength(0); this.rowMax.Height = new GridLength(0); this.rowStep.Height = new GridLength(0); this.cbDataType.SelectedIndex = 0; this.cbDataType.IsEnabled = false; } else { this.cbDataType.SelectionChanged += this.dataTypeChanged; } }
/// <summary>Used to create a data model for the appropriate type</summary> /// <param name="dataType"></param> public DashboardConfigData(BinaryMsgDataType dataType) { this.DataModel = new DashboardControlDataModel() { DataType = dataType, }; }
/// <summary>Add managed control config data to the general config</summary> /// <param name="config">The general config object</param> public void BuildConfig(DashboardConfiguration config) { foreach (var control in Controls) { // Note. All the columns are over by 1 since 0 is occupied by event dummy DashboardControlDataModel dm = control.StorageInfo; switch (this.controlType) { case ControlType.Undefined: break; case ControlType.OutBool: config.OutputsBool.Add(dm); break; case ControlType.OutHorizontal: config.OutputsNumericHorizontal.Add(dm); break; case ControlType.InBool: config.InputsBool.Add(dm); break; case ControlType.InHorizontal: config.InputsNumericHorizontal.Add(dm); break; } } }
public static DashboardControlDataModel ShowBox(UserControl parent, DashboardControlDataModel dm) { DashboardControlEdit win = new DashboardControlEdit(parent, dm); win.ShowDialog(); return(win.DataModel); }
private void InitOutput <T>(DashboardControlDataModel dm, List <DashboardControlBuilder <T> > ctrls) where T : UC_OutputBase, new() { foreach (var ctrl in ctrls) { if (ctrl.GetRow() == dm.Row) { ctrl.AddExisting(dm); } } }
public void AddExisting(DashboardControlDataModel dm) { if (this.nextColumn <= this.max) { T control = new T(); control.Update(dm); control.SetEditState(true); this.InsertControl(control); } }
public void Update(DashboardControlDataModel dataModel) { if (dataModel != null) { this.Id = dataModel.Id; this.IOName = dataModel.IOName; this.DataType = dataModel.DataType; this.SendAtStep = dataModel.SendAtStep; this.Minimum = dataModel.Minimum; this.Maximum = dataModel.Maximum; this.Row = dataModel.Row; this.Column = dataModel.Column; this.DoInit(); } }
// Adding new control. Need to initialize the storage model used in edit dialog private bool AddNew(int row) { if (this.nextColumn <= this.max) { T control = new T(); control.InitNew(row, this.nextColumn, this.DefaultDataType()); control.SetEditState(true); DashboardControlDataModel dm = DashboardControlEdit.ShowBox(null, control.StorageInfo); if (dm != null) { control.Update(dm); this.InsertControl(control); return(true); } } return(false); }
public DashboardControlView(UserControl parent, DashboardControlDataModel dm) { this.callingUserControl = parent; InitializeComponent(); this.SetFieldValue(this.txtId, dm.Id); this.SetFieldValue(this.txtName, dm.IOName); this.txtDataType.Text = dm.DataType.ToStr(); this.SetFieldValue(this.txtMin, dm.Minimum); this.SetFieldValue(this.txtMax, dm.Maximum); this.SetFieldValue(this.txtStep, dm.SendAtStep); this.SetFieldValue(this.txtRow, dm.Row); this.SetFieldValue(this.txtColum, dm.Column); if (dm.DataType == BinaryMsgDataType.typeBool) { this.rowMin.Height = new GridLength(0); this.rowMax.Height = new GridLength(0); this.rowStep.Height = new GridLength(0); } }
public UC_OutputBase(DashboardControlDataModel data) { this.Update(data); }
/// <summary>Constructor</summary> /// <param name="dataModel">Data model passed in with existing values</param> public DashboardConfigData(DashboardControlDataModel dataModel) { this.DataModel = dataModel; }
public static void ShowBox(UserControl parent, DashboardControlDataModel dm) { DashboardControlView win = new DashboardControlView(parent, dm); win.ShowDialog(); }
public UC_BoolProgress(DashboardControlDataModel data) : base(data) { // The base initializes variables and calls the DoInit. Initialize() there }
public UC_HorizontalProgressBar(DashboardControlDataModel data) : base(data) { // The base initializes variables and calls the DoInit. Initialize there }
public UC_VerticalSlider(DashboardControlDataModel data) : base(data) { // The base initializes variables and calls the DoInit. Initialize there }
private void btnCancel_Click(object sender, RoutedEventArgs e) { this.DataModel = null; this.Close(); }