public void UpdateByModelChange(IFineTuneModelable model) { this.BeginInvoke(new Action(() => { //将所有的轨迹命令显示在列表中 this.listView1.Clear(); for (int i = 0; i < model.CmdLineList.Count; i++) { this.listView1.Items.Add(string.Format("{0}:{1}", i + 1, model.CmdLineList[i].ToString())); } this.dataGridView1.Rows.Clear(); for (int i = 0; i < model.CurrCmdPointsList.Count; i++) { //只有勾选的轨迹类型才会添加 if (model.CurrCmdPointsList[i].CmdLineEnable) { DataGridViewRow drRow = new DataGridViewRow(); //添加编号 DataGridViewTextBoxCell cell0 = new DataGridViewTextBoxCell(); string s = string.Format("{0}-{1}", model.CurrCmdPointsList[i].CmdLineNo + 1, model.CurrCmdPointsList[i].PointNo + 1); cell0.Value = s; //添加轨迹名称 DataGridViewTextBoxCell cell1 = new DataGridViewTextBoxCell(); cell1.Value = model.CurrCmdPointsList[i].CmdLineType; //添加点名称 DataGridViewTextBoxCell cell2 = new DataGridViewTextBoxCell(); cell2.Value = model.CurrCmdPointsList[i].PointDescribe; //添加是否跳过该点 DataGridViewCheckBoxCell cell3 = new DataGridViewCheckBoxCell(); cell3.Value = model.CurrCmdPointsList[i].Skip; //添加点的X坐标和Y坐标 DataGridViewTextBoxCell cell4 = new DataGridViewTextBoxCell(); cell4.Value = model.CurrCmdPointsList[i].Point.X.ToString(); DataGridViewTextBoxCell cell5 = new DataGridViewTextBoxCell(); cell5.Value = model.CurrCmdPointsList[i].Point.Y.ToString(); //将所有行信息添加 drRow.Cells.Add(cell0); drRow.Cells.Add(cell1); drRow.Cells.Add(cell2); drRow.Cells.Add(cell3); drRow.Cells.Add(cell4); drRow.Cells.Add(cell5); this.dataGridView1.Rows.Add(drRow); } } })); }
public CmdLineFineTuneForm(Pattern pattern) : this() { this.pattern = pattern; //初始化控制器 this.Controller = new FineTuneController(); //初始化模型 this.model = new FineTuneModel(pattern); //为控制器设置要控制的模型 this.Controller.SetModel(this.model); //将此窗口作为观察者添加到模型中 this.model.AddObserver(this); //listView1.Columns.Add("command", this.listView1.Width, HorizontalAlignment.Left); }
public void UpdateBySelectedChange(IFineTuneModelable model) { this.BeginInvoke(new Action(() => { //跳转到选中轨迹 this.listView1.EnsureVisible(model.SelectedCmdLineNo); for (int i = 0; i < this.listView1.Items.Count; i++) { this.listView1.Items[i].BackColor = Color.White; } this.listView1.Items[model.SelectedCmdLineNo].BackColor = Color.Red; //跳转到选中点 for (int i = 0; i < this.dataGridView1.Rows.Count; i++) { this.dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.White; } int index = model.GetSelectedInCurrList(); if (index != -1) { this.dataGridView1.FirstDisplayedScrollingRowIndex = index; this.dataGridView1.Rows[index].DefaultCellStyle.BackColor = Color.Red; } //显示选中的点的坐标和点在列表中的编号 CmdLinePoint selcetedPoint = model.GetSelectedPoint(); if (selcetedPoint == null) { this.txtPointX.Text = "0"; this.txtPointY.Text = "0"; } else { this.txtPointX.Text = selcetedPoint.Point.X.ToString(); this.txtPointY.Text = selcetedPoint.Point.Y.ToString(); } })); }
public void SetModel(IFineTuneModelable model) { this.model = model; }