using Community; using Model; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Data; using System.Windows; using System.Windows.Controls; namespace ViewModel { public class HandModel : NotificationObject { /// /// 序号 /// 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 OutputSignal QiGang { get; set; } /// /// 气缸原位 /// public InputSignal QiGangUp { get; set; } /// /// 气缸到位 /// public InputSignal QiGangDown { get; set; } /// /// 顶升气缸原位 /// public OutputSignal YDingShengQiGangYW { get; set; } /// /// 顶升气缸动位 /// public OutputSignal YDingShengQiGangDW { get; set; } /// /// 顶升气缸原位检知 /// public InputSignal XDingShengQigangYW { get; set; } /// /// 顶升气缸到位检知 /// public InputSignal XDingShengQigangDW { get; set; } /// /// 伸缩气缸 /// public OutputSignal YShenSuoQiGangYW { get; set; } /// /// 伸缩气缸 /// public OutputSignal YShenSuoQiGangDW { get; set; } /// /// 伸缩气缸原位 /// public InputSignal XShenSuoQigangYW { get; set; } /// /// 伸缩气缸到位 /// public InputSignal XShenSuoQigangDW { get; set; } /// /// 真空开关 /// public OutputSignal VacuumSwitch { get; set; } /// /// 真空破开关 /// public OutputSignal VacuumPoSwitch { get; set; } /// /// 真空捡知 /// public InputSignal VacuumCheck { get; set; } /// /// 吸嘴放料点位1 /// public RobotPoint PutProPoint1 { get; set; } /// /// 吸嘴放料点位2 /// public RobotPoint PutProPoint2 { get; set; } /// /// 吸嘴取料点位1 /// public RobotPoint TakeProPoint1 { get; set; } /// /// 吸嘴取料点位2 /// public RobotPoint TakeProPoint2 { get; set; } public DateTime CheckVacuumTime { get; set; } public double OfficeX { get; set; } public double OfficeY { get; set; } public double OfficeU { get; 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); //设置边距 } /// /// 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.Green; } else { State.StatusBackground = ColorStr.White; } } } }