/// <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; }
/// <summary> /// 构造函数 /// </summary> /// <param name="imgMarkEntity"> 标定实体 </param> public SampleVieModel(ImgMarkEntity imgMarkEntity) { // Do:注册明林 RelayCommand = new RelayCommand(RelayMethod); // Do:初始化标定信息 Model = imgMarkEntity; this.Flag = "\xe76c"; this.Name = imgMarkEntity.Name; this.Code = imgMarkEntity.Code; this.Type = "0"; DefectShape defect = new DefectShape(imgMarkEntity.X, imgMarkEntity.Y, imgMarkEntity.Width, imgMarkEntity.Height); // Do:添加到图层列表 this.RectangleLayer.Add(defect); }
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); }