using Community; using Model; using Model.MotionControl; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using ViewModel.Robots; using ViewModel.Vision; using Views; namespace ViewModel { public class HandModel : NotificationObject { /// /// 序号 /// public int Number { get; set; } private string shortCode; /// /// 简码 /// public string ShortCode { get { return shortCode; } set { shortCode = value; RaisePropertyChanged("ShortCode"); } } /// /// 产品对象 /// public TestBox Box { get; set; } private ShowInfo state; /// /// 标签状态 /// public ShowInfo State { get { return state; } set { state = value == null ? new ShowInfo() : value; RaisePropertyChanged("State"); } } /// /// 测试数据 /// public string TestData { get; set; } /// /// Label显示控件对象 /// public HandModel() { State = new ShowInfo(); Box = new TestBox(); Box.DataContext = this; ////数据样式 //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; //增加鼠标双击事件 Box.MouseDoubleClick += Labels_MouseDoubleClick; Box.Margin = new Thickness(1); //设置边距 } /// /// 原来的颜色 /// string yuanse = ""; /// /// Label的双击事件 /// /// /// private void Labels_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e) { //禁用 if (State.StatusBackground != ColorStr.Gray) { yuanse = State.StatusBackground; State.StatusBackground = ColorStr.Gray; } else if (!string.IsNullOrEmpty(yuanse)) { State.StatusBackground = yuanse; yuanse = ""; } else { State.StatusBackground = ColorStr.White; } } } }