110 lines
3.1 KiB
C#
110 lines
3.1 KiB
C#
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
|
|
{
|
|
/// <summary>
|
|
/// 序号
|
|
/// </summary>
|
|
public int Number { get; set; }
|
|
|
|
private string shortCode;
|
|
/// <summary>
|
|
/// 简码
|
|
/// </summary>
|
|
public string ShortCode
|
|
{
|
|
get { return shortCode; }
|
|
set { shortCode = value; RaisePropertyChanged("ShortCode"); }
|
|
}
|
|
/// <summary>
|
|
/// 产品对象
|
|
/// </summary>
|
|
public TestBox Box { get; set; }
|
|
|
|
private ShowInfo state;
|
|
/// <summary>
|
|
/// 标签状态
|
|
/// </summary>
|
|
public ShowInfo State
|
|
{
|
|
get { return state; }
|
|
set
|
|
{
|
|
state = value == null ? new ShowInfo() : value;
|
|
RaisePropertyChanged("State");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 测试数据
|
|
/// </summary>
|
|
public string TestData { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
/// Label显示控件对象
|
|
/// </summary>
|
|
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); //设置边距
|
|
|
|
}
|
|
/// <summary>
|
|
/// 原来的颜色
|
|
/// </summary>
|
|
string yuanse = "";
|
|
/// <summary>
|
|
/// Label的双击事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
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;
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|