/// <summary> /// 菜单点击确定 生成缺陷和样本 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Button_Click(object sender, RoutedEventArgs e) { SampleVieModel sample = new SampleVieModel(); sample.Name = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); sample.Code = this.cb_code.Text; // Do:根据选择的样本类型来生成缺陷/样本 if (this.r_defect.IsChecked.HasValue && this.r_defect.IsChecked.Value) { DefectShape resultStroke = new DefectShape(this._dynamic); sample.Flag = "\xe688"; sample.Type = "0"; resultStroke.Name = sample.Name; resultStroke.Code = sample.Code; resultStroke.Draw(this.canvas); sample.Add(resultStroke); } else { SampleShape resultStroke = new SampleShape(this._dynamic); sample.Flag = "\xeaf3"; sample.Type = "1"; resultStroke.Name = sample.Name; resultStroke.Code = sample.Code; resultStroke.Draw(this.canvas); sample.Add(resultStroke); } this.ViewModel.Add(sample); this.popup.IsOpen = false; }
internal void AddMark(ImgMarkEntity imgMarkEntity) { SampleVieModel sample = new SampleVieModel(); //sample.Name = imgMarkEntity.Name; //sample.Code = imgMarkEntity.PHMCodes; sample.Model = imgMarkEntity; // Do:根据选择的样本类型来生成缺陷/样本 if (this.ImageOprateCtrEntity.MarkType == MarkType.Defect) { DefectShape resultStroke = new DefectShape(this._dynamic); sample.Flag = "\xe688"; sample.Type = "0"; sample.Code = imgMarkEntity.PHMCodes; resultStroke.Name = sample.Name; resultStroke.Code = sample.Code; resultStroke.Draw(this.canvas); sample.Add(resultStroke); } else if (this.ImageOprateCtrEntity.MarkType == MarkType.Sample) { SampleShape resultStroke = new SampleShape(this._dynamic); sample.Flag = "\xeaf3"; sample.Type = "1"; sample.Code = imgMarkEntity.PHMCodes; resultStroke.Name = sample.Name; resultStroke.Code = sample.Code; resultStroke.Draw(this.canvas); sample.Add(resultStroke); } this.ViewModel.Add(sample); // Do:触发新增事件 this.ImageOprateCtrEntity.OnImgMarkOperateEvent(sample.Model); // Do:清除动态框 _dynamic.BegionMatch(false); }
/// <summary> /// 命令触发参数方法 /// </summary> /// <param name="obj"></param> public void RelayMethod(object obj) { string command = obj.ToString(); // Do:测试 if (command == "text") { this.SampleCollection.Clear(); for (int i = 0; i < 10; i++) { SampleVieModel sample = new SampleVieModel(); sample.Name = "Name" + i; sample.Flag = i % 3 == 0 ? "\xe688" : "\xeaf3"; sample.Code = "Code" + i; this.SampleCollection.Add(sample); } } // Do:删除标定 else if (command == "delete") { if (this.SelectSample == null) { return; } this.SelectSample.Flag = "\xe743"; this.SelectSample.Model.markOperateType = ImgMarkOperateType.Delete; this.SelectSample.Visible = false; } // Do:更新标定 else if (command == "update") { if (this.SelectSample == null) { return; } this.SelectSample.Flag = "\xe6b5"; this.SelectSample.Model.markOperateType = ImgMarkOperateType.Update; } }
/// <summary> /// 添加标定 /// </summary> /// <param name="entity"></param> public void Add(SampleVieModel entity) { this.SampleCollection.Add(entity); }
/// <summary> /// 命令触发参数方法 /// </summary> /// <param name="obj"></param> public void RelayMethod(object obj) { string command = obj.ToString(); // Do:测试 if (command == "text") { this.SampleCollection.Clear(); for (int i = 0; i < 10; i++) { SampleVieModel sample = new SampleVieModel(); sample.Name = "Name" + i; sample.Flag = i % 3 == 0 ? "\xe688" : "\xeaf3"; sample.Code = "Code" + i; this.SampleCollection.Add(sample); } } // Do:删除标定 else if (command == "delete") { if (this.SelectSample == null) { return; } this.SelectSample.Flag = "\xe743"; this.SelectSample.Model.markOperateType = ImgMarkOperateType.Delete; this.SelectSample.Visible = false; } // Do:更新标定 else if (command == "update") { if (this.SelectSample == null) { return; } this.SelectSample.Flag = "\xe6b5"; this.SelectSample.Model.markOperateType = ImgMarkOperateType.Update; } // Do:删除标定 else if (command == "menu_delete") { this.SelectSample = this.SampleCollection.ToList().Find(l => l.RectangleLayer.First().IsSelected); if (this.SelectSample == null) { return; } this.SelectSample.Model.markOperateType = ImgMarkOperateType.Delete; // Do:触发删除事件 this._iImgOperate.OnImgMarkOperateEvent(this.SelectSample.Model); this.SelectSample.RectangleLayer.First().Clear(); this.SampleCollection.Remove(this.SelectSample); //this.SelectSample.Flag = "\xe6b5"; //this.SelectSample.Model.markOperateType = ImgMarkOperateType.Update; } }