motorTest/ViewModel/HandModel.cs
2026-10-17 11:39:30 +08:00

142 lines
4.1 KiB
C#

using Community;
using Model;
using Model.MotionControl;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
namespace ViewModel
{
/// <summary>
/// 吸嘴模型
/// </summary>
public class HandModel : NotificationObject
{
public string Barcode { get; set; }
/// <summary>
/// 序号
/// </summary>
public int Number { get; set; }
public Label Labels { 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 MotionPointModel TakePoint { get; set; }
public RobotPoint PutPoint { get; set; }
/// <summary>
/// 贴合点
/// </summary>
public MotionPointModel FitPoint { get; set; }
/// <summary>
/// 补偿值
/// </summary>
public OffsetValueModel OffsetValue { get; set; }
/// <summary>
/// 视觉补偿值
/// </summary>
public OffsetValueModel VisionOffsetValue { get; set; }
/// <summary>
/// 气缸
/// </summary>
public OutputSignal QiGang { get; set; }
/// <summary>
/// 气缸原位
/// </summary>
public InputSignal QiGangUp { get; set; }
/// <summary>
/// 气缸到位
/// </summary>
public InputSignal QiGangDown { get; set; }
/// <summary>
/// 真空开关
/// </summary>
public OutputSignal VacuumSwitch { get; set; }
public OutputSignal VacuumOffSwitch { get; set; }
/// <summary>
/// 真空捡知
/// </summary>
public InputSignal VacuumCheck { get; set; }
public MotionPointModel VisionPoint { get; internal set; }
public MotionPointModel TempPoint { get; internal set; }
public List<double> LogList { get; internal set; }
/// <summary>
/// Label显示控件对象
/// </summary>
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();
}
/// <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.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;
}
}
}
}