using Community; using Model; using Model.MotionControl; using System.Windows; using System.Windows.Controls; using System.Windows.Data; namespace ViewModel { #region 自定义Label控件类 /// /// 自定义Label控件类 /// public class MyLabel : NotificationObject { /// /// 序号 /// public int Number { get; set; } private string myColor; /// /// 表示颜色 /// public string MyColor { get { return myColor; } set { myColor = value; this.RaisePropertyChanged("MyColor"); } } /// /// 对于的Tray名称 /// public string TrayName { get; set; } public RobotPoint TakePutPoint { get; set; } public RobotPoint VisonPoint { get; set; } public Label Labels { get; set; } private string labelConten; /// /// label内容 /// public string LabelConten { get { return labelConten; } set { labelConten = value; this.RaisePropertyChanged("LabelConten"); } } /// /// 吸嘴编号(点位归属的那个吸嘴) /// public int XizuiNumber { get; set; } /// /// 吸嘴1取放料点位 /// public RobotPoint TakePutPoint1 { get; set; } /// /// 吸嘴2取放料点位 /// public RobotPoint TakePutPoint2 { get; set; } /// /// 取料点 /// public RobotPoint TakePoint { get; set; } /// /// 放料点 /// public RobotPoint PutPoint { get; set; } /// /// 第一个吸嘴贴标点 /// public MotionPointModel Point_M1 { get; set; } /// /// 第二个吸嘴贴标点 /// public MotionPointModel Point_M2 { get; set; } /// /// 第三个吸嘴贴标点 /// public MotionPointModel Point_M3 { get; set; } /// /// 第四个吸嘴贴标点 /// public MotionPointModel Point_M4 { get; set; } /// /// 第五个吸嘴贴标点 /// public MotionPointModel Point_M5 { get; set; } /// /// 第六个吸嘴贴标点 /// public MotionPointModel Point_M6 { get; set; } private ProductModel product; /// /// Mylabel对应的产品对象 /// public ProductModel Product { get { return product; } set { product = value; RaisePropertyChanged("Product"); } } /// /// Label显示控件对象 /// public MyLabel() { Product = new ProductModel(); Labels = new Label(); MyColor = ColorStr.White; //LabelConten ="11"; //绑定背景颜色 Labels.SetBinding(Label.BackgroundProperty, new Binding() { Source = this, Path = new PropertyPath("Product.StateColour"), Mode = BindingMode.TwoWay }); //绑定内容 // Labels.SetBinding(Label.ContentProperty, new Binding() { Source = this, Path = new PropertyPath("Product.SnCode"), Mode = BindingMode.TwoWay }); Labels.SetBinding(Label.ContentProperty, new Binding() { Source = this, Path = new PropertyPath("LabelConten"), Mode = BindingMode.TwoWay }); Labels.MouseDoubleClick += Labels_MouseDoubleClick; //增加鼠标双击事件 Labels.Margin = new Thickness(1); //设置边距 Labels.HorizontalContentAlignment = HorizontalAlignment.Center; Labels.VerticalContentAlignment = VerticalAlignment.Center; } /// /// Label的双击事件 /// /// /// private void Labels_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e) { if (Product.StateColour == ColorStr.Green) { Product.StateColour = ColorStr.White; } else if (Product.StateColour == ColorStr.White) { Product.StateColour = ColorStr.Blue; } else { Product.StateColour = ColorStr.Green; } } } #endregion #region Tray盘类 #endregion }