AxisPointControl.cs
2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
using OnlineStore.Common;
using OnlineStore.DeviceLibrary;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace OnlineStore.XLRStore.useControl
{
public partial class AxisPointControl : UserControl
{
public AxisPointControl()
{
InitializeComponent();
}
public string PointText
{
get { return btnMove.Text; }
set { btnMove.Text = value; }
}
public int PointValue
{
get { return FormUtil.GetIntValue(txtPoint.Text); }
set { txtPoint.Text = value.ToString(); }
}
public Color PointBackColor
{
get { return btnMove.BackColor; }
set { this.btnMove.BackColor = value; }
}
public Color PointForeColor
{
get { return btnMove.ForeColor; }
set { this.btnMove.ForeColor = value; }
}
private int MoveSpeed;
private AxisBean MoveAxis = null;
private bool isRelMovePoint=false;
public void SetMoveData(AxisBean axisBean, int speed, int pointV, bool isRelMovePoint=false)
{
this.MoveAxis = axisBean;
this.MoveSpeed = speed;
this.PointValue = pointV;
this.isRelMovePoint = isRelMovePoint;
}
private void btnMove_Click(object sender, EventArgs e)
{
if (MoveAxis == null) return;
int v = FormUtil.GetIntValue(txtPoint);
if (isRelMovePoint)
{
if (v<=0)
{
MessageBox.Show(PointText + "为相对运动,请正确设置点位", "操作失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
int currPosition = MoveAxis.GetAclPosition();
int targetPosition = currPosition + v;
LogUtil.info(this.Name + " " + MoveAxis.AxisName + " 点击:" + btnMove.Text + ",增量运动【" + v + "】,目标位置【"+ targetPosition + "】");
MoveAxis.AbsMove(null, targetPosition, MoveSpeed);
}
else
{
LogUtil.info(this.Name + " " + MoveAxis.AxisName + " 点击:" + btnMove.Text + ",绝对运动【" + v + "】");
MoveAxis.AbsMove(null, v, MoveSpeed);
}
}
}
}