using Community; using Model; using Model.MotionControl; using System.Collections.Generic; using System.Windows; using System.Windows.Controls; using System.Windows.Data; namespace ViewModel { /// /// 吸嘴模型 /// public class HandModel : NotificationObject { public string Barcode { get; set; } /// /// 序号 /// public int Number { get; set; } public Label Labels { get; set; } private ShowInfo state; /// /// 标签状态 /// public ShowInfo State { get { return state; } set { state = value == null ? new ShowInfo() : value; RaisePropertyChanged("State"); } } /// /// 取料点 /// public MotionPointModel TakePoint { get; set; } public RobotPoint PutPoint { get; set; } /// /// 贴合点 /// public MotionPointModel FitPoint { get; set; } /// /// 补偿值 /// public OffsetValueModel OffsetValue { get; set; } /// /// 视觉补偿值 /// public OffsetValueModel VisionOffsetValue { get; set; } /// /// 气缸 /// public OutputSignal QiGang { get; set; } /// /// 气缸原位 /// public InputSignal QiGangUp { get; set; } /// /// 气缸到位 /// public InputSignal QiGangDown { get; set; } /// /// 真空开关 /// public OutputSignal VacuumSwitch { get; set; } public OutputSignal VacuumOffSwitch { get; set; } /// /// 真空捡知 /// public InputSignal VacuumCheck { get; set; } public MotionPointModel VisionPoint { get; internal set; } public MotionPointModel TempPoint { get; internal set; } public List LogList { get; internal set; } /// /// Label显示控件对象 /// public HandModel() { State = new ShowInfo(); Labels = new Label(); //数据样式 Labels.Style = (Style)MyMessageBox.MetroWin.FindResource("Mylabel1");//LabelStyle 这个样式是引用的资源文件中的样式名称 //绑定背景颜色 Labels.SetBinding(Label.BackgroundProperty, new Binding() { Source = this, Path = new PropertyPath("State.StatusBackground"), Mode = BindingMode.TwoWay }); //绑定内容 Labels.SetBinding(Label.ContentProperty, new Binding() { Source = this, Path = new PropertyPath("State.StatuInfo"), Mode = BindingMode.TwoWay }); Labels.MouseDoubleClick += Labels_MouseDoubleClick; //增加鼠标双击事件 Labels.Margin = new Thickness(1); //设置边距 OffsetValue = new OffsetValueModel(); VisionOffsetValue = new OffsetValueModel(); } /// /// Label的双击事件 /// /// /// private void Labels_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e) { //如果为绿色 则不允许改其他颜色 if (State.StatusBackground == ColorStr.White) { State.StatusBackground = ColorStr.Blue; } else if (State.StatusBackground == ColorStr.Blue) { State.StatusBackground = ColorStr.Yellow; } else if (State.StatusBackground == ColorStr.Yellow) { State.StatusBackground = ColorStr.Green; } else { State.StatusBackground = ColorStr.White; } } } }