Commit 30aca5c0 LN

调试修改

1 个父辈 b4cfc899
...@@ -105,28 +105,35 @@ class NanjingSDotIO : IOBase ...@@ -105,28 +105,35 @@ class NanjingSDotIO : IOBase
/// </summary> /// </summary>
void iomonitor() void iomonitor()
{ {
iomonitorrun = true; try
while (iomonitorrun && systemrun)
{ {
Thread.Sleep(2); iomonitorrun = true;
try while (iomonitorrun && systemrun)
{ {
ReadDO(); Thread.Sleep(2);
try
{
ReadDO();
}
catch (SocketException)
{
if (tcpClient != null && tcpClient.Connected)
tcpClient.Close();
ConnectionState_Event?.Invoke(this, false);
iomonitorrun = false;
}
} }
catch (SocketException) if (systemrun)
{ {
if (tcpClient!=null && tcpClient.Connected) do
tcpClient.Close(); {
ConnectionState_Event?.Invoke(this, false); Thread.Sleep(1000);
iomonitorrun = false; } while (systemrun && !Open());
} }
} }
if (systemrun) catch (Exception ex)
{ {
do TSA_V.Common.LogUtil.error($"IO模块{IP}出错:" + ex.ToString());
{
Thread.Sleep(1000);
} while (systemrun && !Open());
} }
} }
......
using System.Collections.Generic; using System;
using System.Collections.Generic;
using System.Net.Http; using System.Net.Http;
using TSA_V.Common; using TSA_V.Common;
using TSA_V.LoadCSVLibrary; using TSA_V.LoadCSVLibrary;
...@@ -36,7 +37,7 @@ namespace TSA_V.DeviceLibrary ...@@ -36,7 +37,7 @@ namespace TSA_V.DeviceLibrary
{ {
string url = $"http://{ip}/wms/associate/lightTagsLed"; string url = $"http://{ip}/wms/associate/lightTagsLed";
string json = JsonHelper.SerializeObject(getLedMaps(macs, ledvs)); string json = JsonHelper.SerializeObject(getLedMaps(macs, ledvs));
Post(url, json); Post(url, json,(open ? "打开所有":"关闭所有"));
} }
} }
public static LabelInfo GetLabel(TSAVPosition position, ComponetInfo com, bool opendLed = false) public static LabelInfo GetLabel(TSAVPosition position, ComponetInfo com, bool opendLed = false)
...@@ -107,7 +108,7 @@ namespace TSA_V.DeviceLibrary ...@@ -107,7 +108,7 @@ namespace TSA_V.DeviceLibrary
Dictionary<string, object> keyValuePairss = getLedMap(mac, ledrgb); Dictionary<string, object> keyValuePairss = getLedMap(mac, ledrgb);
string json = JsonHelper.SerializeObject(keyValuePairss); string json = JsonHelper.SerializeObject(keyValuePairss);
string value = $"[{json}]"; string value = $"[{json}]";
Post(url, value); Post(url, value, mac + (openLed ?"开灯":"关灯"));
} }
public static void UpdateScreen(LabelInfo label) public static void UpdateScreen(LabelInfo label)
{ {
...@@ -141,35 +142,39 @@ namespace TSA_V.DeviceLibrary ...@@ -141,35 +142,39 @@ namespace TSA_V.DeviceLibrary
} }
string json = JsonHelper.SerializeObject(dic); string json = JsonHelper.SerializeObject(dic);
string value = $"[{json}]"; string value = $"[{json}]";
Post(url, value); Post(url, value,"更新屏幕");
} }
public static async void Post(string url, string json) public static async void Post(string url, string json, string opName = "")
{ {
using (var client = new HttpClient()) try
{ {
using (var request = new HttpRequestMessage(HttpMethod.Post, url)) using (var client = new HttpClient())
{ {
var contents = new StringContent($"{json}", null, "application/json"); using (var request = new HttpRequestMessage(HttpMethod.Post, url))
request.Content = contents;
using (HttpResponseMessage response = await client.SendAsync(request) )
{ {
var contents = new StringContent($"{json}", null, "application/json");
if (response.IsSuccessStatusCode) request.Content = contents;
{ using (HttpResponseMessage response = await client.SendAsync(request))
string jsonResponse = response.Content.ReadAsStringAsync().Result;
LogUtil.info($"电子屏 发送{json} 结果 {response.IsSuccessStatusCode}: " + jsonResponse);
}
else
{ {
string jsonResponse = response.Content.ReadAsStringAsync().Result; if (response.IsSuccessStatusCode)
LogUtil.info($"电子屏 发送{json} 结果 {response.IsSuccessStatusCode}: " + jsonResponse); {
string jsonResponse = response.Content.ReadAsStringAsync().Result;
LogUtil.info($"电子屏 {opName} 发送{json} 结果 {response.IsSuccessStatusCode}: " + jsonResponse);
}
else
{
string jsonResponse = response.Content.ReadAsStringAsync().Result;
LogUtil.info($"电子屏 {opName} 发送{json} 结果 {response.IsSuccessStatusCode}: " + jsonResponse);
}
} }
} }
} }
} }
catch (Exception ex)
{
LogUtil.info($"电子屏 {opName} 发送{json} 出错 {ex.ToString()}");
}
} }
// { // {
// "mac":"99.96.19.64", // "mac":"99.96.19.64",
......
...@@ -55,6 +55,11 @@ namespace TSA_V.DeviceLibrary ...@@ -55,6 +55,11 @@ namespace TSA_V.DeviceLibrary
currIndex = ConfigAppSettings.GetIntValue(Setting_Init.TagNumber); currIndex = ConfigAppSettings.GetIntValue(Setting_Init.TagNumber);
isContinue = false; isContinue = false;
} }
else
{
LogUtil.info("开始程序【" + boardInfo.boardName + "】的插件,关闭所有灯");
LedLabelController.CloseAll();
}
IsShowAOI = false; IsShowAOI = false;
currPoint = null; currPoint = null;
IsWorking = true; IsWorking = true;
...@@ -191,6 +196,11 @@ namespace TSA_V.DeviceLibrary ...@@ -191,6 +196,11 @@ namespace TSA_V.DeviceLibrary
//上一个节点返回原点 //上一个节点返回原点
PUSICANControl.AbsMove(PreNodeId, TSAVBean.RotateNode_DefaultPosition); PUSICANControl.AbsMove(PreNodeId, TSAVBean.RotateNode_DefaultPosition);
} }
if (PreLabel != null)
{
LedLabelController.CloseLed(PreLabel.ip, PreLabel.mac);
Thread.Sleep(300);
}
//if (TSAVBean.IsNeedSoldering) //if (TSAVBean.IsNeedSoldering)
//{ //{
// LogUtil.info(" 程序【" + currBoard.boardName + "】需要焊接,打开烙铁灯 "); // LogUtil.info(" 程序【" + currBoard.boardName + "】需要焊接,打开烙铁灯 ");
...@@ -302,6 +312,7 @@ namespace TSA_V.DeviceLibrary ...@@ -302,6 +312,7 @@ namespace TSA_V.DeviceLibrary
if (PreLabel != null) if (PreLabel != null)
{ {
LedLabelController.CloseLed(PreLabel.ip, PreLabel.mac); LedLabelController.CloseLed(PreLabel.ip, PreLabel.mac);
Thread.Sleep(300);
} }
//LedManager.LedOFFALL(); //LedManager.LedOFFALL();
if (position.PositionType.Equals(1)) if (position.PositionType.Equals(1))
......
...@@ -12,6 +12,7 @@ using System.Windows.Forms; ...@@ -12,6 +12,7 @@ using System.Windows.Forms;
using TSA_V.Common; using TSA_V.Common;
using TSA_V.DeviceLibrary; using TSA_V.DeviceLibrary;
using TSA_V.LoadCSVLibrary; using TSA_V.LoadCSVLibrary;
using UserFromControl;
namespace TSA_V namespace TSA_V
{ {
...@@ -316,8 +317,8 @@ namespace TSA_V ...@@ -316,8 +317,8 @@ namespace TSA_V
xyMoveControl1.ShowPointEvent += XyMoveControl1_ShowPointEvent; xyMoveControl1.ShowPointEvent += XyMoveControl1_ShowPointEvent;
xyMoveControl1.XValue = TSAVBean.X_Max/2; xyMoveControl1.XValue = TSAVBean.X_Max/2;
xyMoveControl1.YValue = TSAVBean.Y_Max/2; xyMoveControl1.YValue = TSAVBean.Y_Max/2;
xyMoveControl1.MaxX =(int) TSAVBean.X_Max; ProjectorControl.MaxX =(int) TSAVBean.X_Max;
xyMoveControl1.MaxY = (int)TSAVBean.Y_Max; ProjectorControl.MaxY = (int)TSAVBean.Y_Max;
xyMoveControl1.ShowText = ""; xyMoveControl1.ShowText = "";
rdbUpload.Checked = true; rdbUpload.Checked = true;
......
...@@ -13,6 +13,7 @@ using TSA_V.Common; ...@@ -13,6 +13,7 @@ using TSA_V.Common;
using PUSICANLibrary; using PUSICANLibrary;
using TSA_V.LoadCSVLibrary; using TSA_V.LoadCSVLibrary;
using AccAOI; using AccAOI;
using UserFromControl;
namespace TSA_V namespace TSA_V
{ {
...@@ -41,8 +42,8 @@ namespace TSA_V ...@@ -41,8 +42,8 @@ namespace TSA_V
xyMoveControl1.XValue = nodex; xyMoveControl1.XValue = nodex;
xyMoveControl1.YValue = nodey; xyMoveControl1.YValue = nodey;
xyMoveControl1.MaxX = (int)TSAVBean.X_Max; ProjectorControl.MaxX = (int)TSAVBean.X_Max;
xyMoveControl1.MaxY = (int)TSAVBean.Y_Max; ProjectorControl.MaxY = (int)TSAVBean.Y_Max;
this.txtX.Text = x.ToString(); this.txtX.Text = x.ToString();
this.txtY.Text = y.ToString(); this.txtY.Text = y.ToString();
...@@ -122,8 +123,8 @@ namespace TSA_V ...@@ -122,8 +123,8 @@ namespace TSA_V
return; return;
} }
xyMoveControl1.ShowPointEvent += XyMoveControl1_ShowPointEvent; xyMoveControl1.ShowPointEvent += XyMoveControl1_ShowPointEvent;
xyMoveControl1.MaxX = (int)TSAVBean.X_Max; ProjectorControl.MaxX = (int)TSAVBean.X_Max;
xyMoveControl1.MaxY = (int)TSAVBean.Y_Max; ProjectorControl.MaxY = (int)TSAVBean.Y_Max;
this.PointList = list; this.PointList = list;
this.CurrIndex = currIndex; this.CurrIndex = currIndex;
ShowPoint(); ShowPoint();
......
...@@ -10,6 +10,7 @@ using System.Threading.Tasks; ...@@ -10,6 +10,7 @@ using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using TSA_V.Common; using TSA_V.Common;
using TSA_V.DeviceLibrary; using TSA_V.DeviceLibrary;
using UserFromControl;
namespace TSA_V namespace TSA_V
{ {
...@@ -33,7 +34,7 @@ namespace TSA_V ...@@ -33,7 +34,7 @@ namespace TSA_V
// private bool hasShow = false; // private bool hasShow = false;
private void FrmScreenTest_Load(object sender, EventArgs e) private void FrmScreenTest_Load(object sender, EventArgs e)
{ {
this.Text = "显示测试_" + ScreenIndex; this.Text = "投影_" + ScreenIndex;
this.StartPosition = FormStartPosition.Manual; this.StartPosition = FormStartPosition.Manual;
timer1.Start(); timer1.Start();
if (panel1.BackgroundImage != null) if (panel1.BackgroundImage != null)
...@@ -76,12 +77,13 @@ namespace TSA_V ...@@ -76,12 +77,13 @@ namespace TSA_V
TSAVBean.Y_Max = ScreenHeight; TSAVBean.Y_Max = ScreenHeight;
TSAVBean.X_Min = 1; TSAVBean.X_Min = 1;
TSAVBean.Y_Min = 1; TSAVBean.Y_Min = 1;
ProjectorControl.MaxX = (int)TSAVBean.X_Max;
ProjectorControl.MaxY = (int)TSAVBean.Y_Max;
ISShow = true; ISShow = true;
this.Location = new Point(screen.Bounds.Left, screen.Bounds.Top); this.Location = new Point(screen.Bounds.Left, screen.Bounds.Top);
this.Show(); this.Show();
LogUtil.info($"投影显示成功,屏幕索引={ ScreenIndex} , 位置X:{screen.Bounds.Left} ,Y:{screen.Bounds.Top} "); LogUtil.info($"投影显示成功,屏幕索引={ ScreenIndex} , 位置X:{screen.Bounds.Left} ,Y:{screen.Bounds.Top} ,范围 X:{ScreenWidth},Y:{ScreenHeight}");
return true; return true;
} }
else else
...@@ -118,22 +120,29 @@ namespace TSA_V ...@@ -118,22 +120,29 @@ namespace TSA_V
//循环画线 //循环画线
for (int i = 0; i <= Point_X_Length; i++) for (int i = 0; i <= Point_X_Length; i++)
{ {
float line = 0.2F; float line = 2F;
float picLocationX = startX + lineWidth * i; float picLocationX = startX + lineWidth * i;
if (picLocationX >= ScreenWidth) if (picLocationX >= ScreenWidth)
{ {
picLocationX = ScreenWidth - 2; picLocationX = ScreenWidth - 2;
} }
else if (picLocationX == 0)
{
picLocationX = 2;
}
grfx.DrawLine(new Pen(color, line), picLocationX, startY, picLocationX, ScreenHeight); grfx.DrawLine(new Pen(color, line), picLocationX, startY, picLocationX, ScreenHeight);
} }
for (int i = 0; i <= Point_Y_Length; i++) for (int i = 0; i <= Point_Y_Length; i++)
{ {
float line = 0.2F; float line = 2F;
float picLocationY = startY + lineHeight * i; float picLocationY = startY + lineHeight * i;
if (picLocationY >= ScreenHeight) if (picLocationY >= ScreenHeight)
{ {
picLocationY = ScreenHeight - 1; picLocationY = ScreenHeight - 1;
}else if(picLocationY== 0)
{
picLocationY = 2;
} }
grfx.DrawLine(new Pen(color, line), startX, picLocationY, ScreenWidth, picLocationY); grfx.DrawLine(new Pen(color, line), startX, picLocationY, ScreenWidth, picLocationY);
} }
......
...@@ -32,7 +32,7 @@ namespace TSA_V ...@@ -32,7 +32,7 @@ namespace TSA_V
// private bool hasShow = false; // private bool hasShow = false;
private void FrmScreenTest_Load(object sender, EventArgs e) private void FrmScreenTest_Load(object sender, EventArgs e)
{ {
this.Text = "显示测试_" + ScreenIndex; this.Text = "View_" + ScreenIndex;
this.StartPosition = FormStartPosition.Manual; this.StartPosition = FormStartPosition.Manual;
timer1.Start(); timer1.Start();
if (panel1.BackgroundImage != null) if (panel1.BackgroundImage != null)
...@@ -72,16 +72,16 @@ namespace TSA_V ...@@ -72,16 +72,16 @@ namespace TSA_V
ScreenWidth = screen.Bounds.Width; ScreenWidth = screen.Bounds.Width;
ScreenHeight = screen.Bounds.Height; ScreenHeight = screen.Bounds.Height;
TSAVBean.X_Max = ScreenWidth; //TSAVBean.X_Max = ScreenWidth;
TSAVBean.Y_Max = ScreenHeight; //TSAVBean.Y_Max = ScreenHeight;
TSAVBean.X_Min = 1; //TSAVBean.X_Min = 1;
TSAVBean.Y_Min = 1; //TSAVBean.Y_Min = 1;
ISShow = true; ISShow = true;
this.Location = new Point(screen.Bounds.Left, screen.Bounds.Top); this.Location = new Point(screen.Bounds.Left, screen.Bounds.Top);
this.Show(); this.Show();
LogUtil.info($"第二屏幕显示成功,屏幕索引={ ScreenIndex}, X: {screen.Bounds.Left} ,Y:{screen.Bounds.Top} "); LogUtil.info($"第二屏幕显示成功,屏幕索引={ ScreenIndex}, X: {screen.Bounds.Left} ,Y:{screen.Bounds.Top}, 屏幕尺寸:X:{ScreenWidth} ,Y:{ScreenHeight} ");
return true; return true;
} }
else else
...@@ -94,264 +94,264 @@ namespace TSA_V ...@@ -94,264 +94,264 @@ namespace TSA_V
private void FrmScreenTest_Shown(object sender, EventArgs e) private void FrmScreenTest_Shown(object sender, EventArgs e)
{ {
ShowPoint(new ProjectorPInfo(ScreenWidth / 2, ScreenHeight / 2)); //ShowPoint(new ProjectorPInfo(ScreenWidth / 2, ScreenHeight / 2));
DrawArea(); //DrawArea();
panAoi.BackColor = Color.Black; panAoi.BackColor = Color.Black;
panAoi.Visible = false; panAoi.Visible = false;
} }
public void DrawArea() //public void DrawArea()
{ //{
if (!ISShow) // if (!ISShow)
{ // {
return; // return;
} // }
int startX = 0; // int startX = 0;
int startY = 0; // int startY = 0;
int Point_X_Length = 3; // int Point_X_Length = 3;
int Point_Y_Length = 3; // int Point_Y_Length = 3;
int lineWidth = (ScreenWidth) / (Point_X_Length - 1); // int lineWidth = (ScreenWidth) / (Point_X_Length - 1);
int lineHeight = (ScreenHeight) / (Point_Y_Length - 1); // int lineHeight = (ScreenHeight) / (Point_Y_Length - 1);
Graphics grfx = panel1.CreateGraphics(); // Graphics grfx = panel1.CreateGraphics();
Color color = Color.White; // Color color = Color.White;
grfx.SmoothingMode = SmoothingMode.HighQuality; // grfx.SmoothingMode = SmoothingMode.HighQuality;
//循环画线 // //循环画线
for (int i = 0; i <= Point_X_Length; i++) // for (int i = 0; i <= Point_X_Length; i++)
{ // {
float line = 0.2F; // float line = 0.2F;
float picLocationX = startX + lineWidth * i; // float picLocationX = startX + lineWidth * i;
if (picLocationX >= ScreenWidth) // if (picLocationX >= ScreenWidth)
{ // {
picLocationX = ScreenWidth - 2; // picLocationX = ScreenWidth - 2;
} // }
grfx.DrawLine(new Pen(color, line), picLocationX, startY, picLocationX, ScreenHeight); // grfx.DrawLine(new Pen(color, line), picLocationX, startY, picLocationX, ScreenHeight);
} // }
for (int i = 0; i <= Point_Y_Length; i++) // for (int i = 0; i <= Point_Y_Length; i++)
{ // {
float line = 0.2F; // float line = 0.2F;
float picLocationY = startY + lineHeight * i; // float picLocationY = startY + lineHeight * i;
if (picLocationY >= ScreenHeight) // if (picLocationY >= ScreenHeight)
{ // {
picLocationY = ScreenHeight - 1; // picLocationY = ScreenHeight - 1;
} // }
grfx.DrawLine(new Pen(color, line), startX, picLocationY, ScreenWidth, picLocationY); // grfx.DrawLine(new Pen(color, line), startX, picLocationY, ScreenWidth, picLocationY);
} // }
grfx.Dispose(); // grfx.Dispose();
} //}
public void DrawLine() //public void DrawLine()
{ //{
if (!ISShow) // if (!ISShow)
{ // {
return; // return;
} // }
int startX = 0; // int startX = 0;
int startY = 0; // int startY = 0;
int Point_X_Length = 21; // int Point_X_Length = 21;
int Point_Y_Length = 21; // int Point_Y_Length = 21;
int lineWidth = (ScreenWidth - startX * 2) / (Point_X_Length - 1); // int lineWidth = (ScreenWidth - startX * 2) / (Point_X_Length - 1);
int lineHeight = (ScreenHeight - startY * 2) / (Point_Y_Length - 1); // int lineHeight = (ScreenHeight - startY * 2) / (Point_Y_Length - 1);
Graphics grfx = panel1.CreateGraphics(); // Graphics grfx = panel1.CreateGraphics();
Color color = Color.White; // Color color = Color.LightGray;
grfx.SmoothingMode = SmoothingMode.HighQuality; // grfx.SmoothingMode = SmoothingMode.HighQuality;
//循环画线 // //循环画线
for (int i = 0; i <= Point_X_Length; i++) // for (int i = 0; i <= Point_X_Length; i++)
{ // {
float line = 0.2F; // float line = 0.2F;
float picLocationX = startX + lineWidth * i; // float picLocationX = startX + lineWidth * i;
if (i.Equals(Point_X_Length / 2)) // if (i.Equals(Point_X_Length / 2))
{ // {
line = 1; // line = 1;
} // }
else if (((i % 5).Equals(0)) && (i > 0) && (i < Point_X_Length)) // else if (((i % 5).Equals(0)) && (i > 0) && (i < Point_X_Length))
{ // {
line = 0.5F; // line = 0.5F;
} // }
grfx.DrawLine(new Pen(color, line), picLocationX, startY, picLocationX, ScreenHeight); // grfx.DrawLine(new Pen(color, line), picLocationX, startY, picLocationX, ScreenHeight);
} // }
for (int i = 0; i <= Point_Y_Length; i++) // for (int i = 0; i <= Point_Y_Length; i++)
{ // {
float line = 0.2F; // float line = 0.2F;
float picLocationY = startY + lineHeight * i; // float picLocationY = startY + lineHeight * i;
if (i.Equals(Point_Y_Length / 2)) // if (i.Equals(Point_Y_Length / 2))
{ // {
line = 1; // line = 1;
} // }
else if (((i % 5).Equals(0)) && (i > 0) && (i < Point_Y_Length)) // else if (((i % 5).Equals(0)) && (i > 0) && (i < Point_Y_Length))
{ // {
line = 0.5F; // line = 0.5F;
} // }
grfx.DrawLine(new Pen(color, line), startX, picLocationY, ScreenWidth, picLocationY); // grfx.DrawLine(new Pen(color, line), startX, picLocationY, ScreenWidth, picLocationY);
} // }
grfx.Dispose(); // grfx.Dispose();
} //}
private Color CurrColor = Color.White; //private Color CurrColor = Color.White;
public void ClearPoint() //public void ClearPoint()
{ //{
try // try
{ // {
if (!ISShow) // if (!ISShow)
{ // {
return; // return;
} // }
Graphics g = this.panel1.CreateGraphics(); // Graphics g = this.panel1.CreateGraphics();
g.Clear(Color.Black); // g.Clear(Color.Black);
g.Dispose();//释放资源 // g.Dispose();//释放资源
} // }
catch (Exception ex) // catch (Exception ex)
{ // {
LogUtil.error("ClearPoint 出错:" + ex.ToString()); // LogUtil.error("ClearPoint 出错:" + ex.ToString());
} // }
} //}
private void DrawPoint(Graphics g, int x, int y, int type = 0, int sizeX = 2, int sizeY = 2, int lineLength = 2, string name = "") //private void DrawPoint(Graphics g, int x, int y, int type = 0, int sizeX = 2, int sizeY = 2, int lineLength = 2, string name = "")
{ //{
if (sizeX < 2) // if (sizeX < 2)
{ // {
sizeX = 2; // sizeX = 2;
} // }
if (sizeY < 2) // if (sizeY < 2)
{ // {
sizeY = 2; // sizeY = 2;
} // }
LastX = x; // LastX = x;
LastY = y; // LastY = y;
LastSizeX = sizeX; // LastSizeX = sizeX;
LastSizeY = sizeY; // LastSizeY = sizeY;
LastType = type; // LastType = type;
Pen pen = new Pen(CurrColor, lineLength); // Pen pen = new Pen(CurrColor, lineLength);
System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(CurrColor); // System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(CurrColor);
//点类型,1 = 点,2 = +,3 =|,4 = -,5 = 方形,6 = 圆圈 // //点类型,1 = 点,2 = +,3 =|,4 = -,5 = 方形,6 = 圆圈
if (type.Equals(PointType_Define.PlusSign_2)) // if (type.Equals(PointType_Define.PlusSign_2))
{ // {
g.DrawLine(pen, new Point(x - sizeX, y), new Point(x + sizeX, y)); // g.DrawLine(pen, new Point(x - sizeX, y), new Point(x + sizeX, y));
g.DrawLine(pen, new Point(x, y - sizeY), new Point(x, y + sizeY)); // g.DrawLine(pen, new Point(x, y - sizeY), new Point(x, y + sizeY));
} // }
else if (type.Equals(PointType_Define.VerticalLine_3)) // else if (type.Equals(PointType_Define.VerticalLine_3))
{ // {
g.DrawLine(pen, new Point(x, y - sizeY), new Point(x, y + sizeY)); // g.DrawLine(pen, new Point(x, y - sizeY), new Point(x, y + sizeY));
} // }
else if (type.Equals(PointType_Define.Line_4)) // else if (type.Equals(PointType_Define.Line_4))
{ // {
g.DrawLine(pen, new Point(x - sizeX, y), new Point(x + sizeX, y)); // g.DrawLine(pen, new Point(x - sizeX, y), new Point(x + sizeX, y));
} // }
else if (type.Equals(PointType_Define.Rectangle_5)) // else if (type.Equals(PointType_Define.Rectangle_5))
{ // {
g.DrawRectangle(pen, x - sizeX / 2, y - sizeY / 2, sizeX, sizeY); // g.DrawRectangle(pen, x - sizeX / 2, y - sizeY / 2, sizeX, sizeY);
} // }
else if (type.Equals(PointType_Define.Cycle_6)) // else if (type.Equals(PointType_Define.Cycle_6))
{ // {
g.DrawEllipse(pen, x - sizeX / 2, y - sizeY / 2, sizeX, sizeY); // g.DrawEllipse(pen, x - sizeX / 2, y - sizeY / 2, sizeX, sizeY);
} // }
else if (type.Equals(PointType_Define.Plus_Up_7)) // else if (type.Equals(PointType_Define.Plus_Up_7))
{ // {
int plusSize = sizeX / 2; // int plusSize = sizeX / 2;
int pX = x; // int pX = x;
int pY = y - sizeY / 2 - lineLength - plusSize; // int pY = y - sizeY / 2 - lineLength - plusSize;
g.DrawLine(pen, new Point(pX - plusSize, pY), new Point(pX + plusSize, pY)); // g.DrawLine(pen, new Point(pX - plusSize, pY), new Point(pX + plusSize, pY));
g.DrawLine(pen, new Point(pX, pY - plusSize), new Point(pX, pY + plusSize)); // g.DrawLine(pen, new Point(pX, pY - plusSize), new Point(pX, pY + plusSize));
g.DrawRectangle(pen, x - sizeX / 2, y - sizeY / 2, sizeX, sizeY); // g.DrawRectangle(pen, x - sizeX / 2, y - sizeY / 2, sizeX, sizeY);
} // }
else if (type.Equals(PointType_Define.Plus_Down_8)) // else if (type.Equals(PointType_Define.Plus_Down_8))
{ // {
g.DrawRectangle(pen, x - sizeX / 2, y - sizeY / 2, sizeX, sizeY); // g.DrawRectangle(pen, x - sizeX / 2, y - sizeY / 2, sizeX, sizeY);
int plusSize = sizeX / 2; // int plusSize = sizeX / 2;
int pX = x; // int pX = x;
int pY = y + sizeY / 2 + lineLength + plusSize; // int pY = y + sizeY / 2 + lineLength + plusSize;
g.DrawLine(pen, new Point(pX - plusSize, pY), new Point(pX + plusSize, pY)); // g.DrawLine(pen, new Point(pX - plusSize, pY), new Point(pX + plusSize, pY));
g.DrawLine(pen, new Point(pX, pY - plusSize), new Point(pX, pY + plusSize)); // g.DrawLine(pen, new Point(pX, pY - plusSize), new Point(pX, pY + plusSize));
} // }
else if (type.Equals(PointType_Define.Plus_Left_9)) // else if (type.Equals(PointType_Define.Plus_Left_9))
{ // {
g.DrawRectangle(pen, x - sizeX / 2, y - sizeY / 2, sizeX, sizeY); // g.DrawRectangle(pen, x - sizeX / 2, y - sizeY / 2, sizeX, sizeY);
int plusSize = sizeY / 2; // int plusSize = sizeY / 2;
int pX = x - sizeX / 2 - lineLength - plusSize; // int pX = x - sizeX / 2 - lineLength - plusSize;
int pY = y; // int pY = y;
g.DrawLine(pen, new Point(pX - plusSize, pY), new Point(pX + plusSize, pY)); // g.DrawLine(pen, new Point(pX - plusSize, pY), new Point(pX + plusSize, pY));
g.DrawLine(pen, new Point(pX, pY - plusSize), new Point(pX, pY + plusSize)); // g.DrawLine(pen, new Point(pX, pY - plusSize), new Point(pX, pY + plusSize));
} // }
else if (type.Equals(PointType_Define.Plus_Right_10)) // else if (type.Equals(PointType_Define.Plus_Right_10))
{ // {
g.DrawRectangle(pen, x - sizeX / 2, y - sizeY / 2, sizeX, sizeY); // g.DrawRectangle(pen, x - sizeX / 2, y - sizeY / 2, sizeX, sizeY);
int plusSize = sizeY / 2; // int plusSize = sizeY / 2;
int pX = x + sizeX / 2 + lineLength + plusSize; // int pX = x + sizeX / 2 + lineLength + plusSize;
int pY = y; // int pY = y;
g.DrawLine(pen, new Point(pX - plusSize, pY), new Point(pX + plusSize, pY)); // g.DrawLine(pen, new Point(pX - plusSize, pY), new Point(pX + plusSize, pY));
g.DrawLine(pen, new Point(pX, pY - plusSize), new Point(pX, pY + plusSize)); // g.DrawLine(pen, new Point(pX, pY - plusSize), new Point(pX, pY + plusSize));
} // }
else // else
{ // {
g.FillEllipse(myBrush, new Rectangle(x - sizeX / 2, y - sizeY / 2, sizeX, sizeY));//画实心椭圆 // g.FillEllipse(myBrush, new Rectangle(x - sizeX / 2, y - sizeY / 2, sizeX, sizeY));//画实心椭圆
} // }
if (!name.Equals("")) // if (!name.Equals(""))
{ // {
int size = (sizeX + sizeY) / 2; // int size = (sizeX + sizeY) / 2;
size = 30; // size = 30;
if (!CloseShowName) // if (!CloseShowName)
{ // {
g.DrawString(name, new Font("Arial ", size, FontStyle.Regular), Brushes.White, x - size + 5, y + size + 2); // g.DrawString(name, new Font("Arial ", size, FontStyle.Regular), Brushes.White, x - size + 5, y + size + 2);
} // }
} // }
} //}
public void ShowPoint(DeviceLibrary.ProjectorPInfo p) //public void ShowPoint(DeviceLibrary.ProjectorPInfo p)
{ //{
if (!ISShow) // if (!ISShow)
{ // {
return; // return;
} // }
Graphics g = panel1.CreateGraphics(); // Graphics g = panel1.CreateGraphics();
DrawPoint(g, p.PX, p.PY, p.PType, p.SizeX, p.SizeY, p.PenWidth, p.ShowText); // DrawPoint(g, p.PX, p.PY, p.PType, p.SizeX, p.SizeY, p.PenWidth, p.ShowText);
g.Dispose(); // g.Dispose();
} //}
public void ShowPoint(bool showName, params SMTPointInfo[] points) //public void ShowPoint(bool showName, params SMTPointInfo[] points)
{ //{
if (!ISShow) // if (!ISShow)
{ // {
return; // return;
} // }
ClearPoint(); // ClearPoint();
Graphics g = panel1.CreateGraphics(); // Graphics g = panel1.CreateGraphics();
foreach (SMTPointInfo point in points) // foreach (SMTPointInfo point in points)
{ // {
int type = point.PointType; // int type = point.PointType;
int x = (int)point.NodePositionX; // int x = (int)point.NodePositionX;
int y = (int)point.NodePositionY; // int y = (int)point.NodePositionY;
int sizex = point.PointSizeX; // int sizex = point.PointSizeX;
int sizey = point.PointSizeY; // int sizey = point.PointSizeY;
DrawPoint(g, x, y, type, sizex, sizey, point.PenWidth, ""); // DrawPoint(g, x, y, type, sizex, sizey, point.PenWidth, "");
if (showName) // if (showName)
{ // {
int size = (sizex + sizey) / 2; // int size = (sizex + sizey) / 2;
if (!CloseShowName) // if (!CloseShowName)
{ // {
if (point.CheckOK && (points.Length > 1)) // if (point.CheckOK && (points.Length > 1))
{ // {
g.DrawString(point.ShowText, new Font("Arial ", size, FontStyle.Regular), Brushes.Red, x - size / 2 + 5, y + size / 2 + 2); // g.DrawString(point.ShowText, new Font("Arial ", size, FontStyle.Regular), Brushes.Red, x - size / 2 + 5, y + size / 2 + 2);
} // }
else // else
{ // {
g.DrawString(point.ShowText, new Font("Arial ", size, FontStyle.Regular), Brushes.White, x - size / 2 + 5, y + size / 2 + 2); // g.DrawString(point.ShowText, new Font("Arial ", size, FontStyle.Regular), Brushes.White, x - size / 2 + 5, y + size / 2 + 2);
} // }
} // }
} // }
} // }
g.Dispose(); // g.Dispose();
} //}
private void timer1_Tick(object sender, EventArgs e) private void timer1_Tick(object sender, EventArgs e)
{ {
......
...@@ -14,8 +14,8 @@ namespace UserFromControl ...@@ -14,8 +14,8 @@ namespace UserFromControl
{ {
public partial class ProjectorControl : UserControl public partial class ProjectorControl : UserControl
{ {
public int MaxX = 1920; public static int MaxX = 1920;
public int MaxY = 1280; public static int MaxY = 1280;
public delegate bool ShowPointDelegate(ProjectorPInfo p); public delegate bool ShowPointDelegate(ProjectorPInfo p);
public event ShowPointDelegate ShowPointEvent; public event ShowPointDelegate ShowPointEvent;
public ProjectorControl() public ProjectorControl()
...@@ -31,7 +31,7 @@ namespace UserFromControl ...@@ -31,7 +31,7 @@ namespace UserFromControl
PointType = TSAVBean.DefaultPType; PointType = TSAVBean.DefaultPType;
numSizeX.Maximum = MaxX / 2; numSizeX.Maximum = MaxX / 2;
numSizeY.Maximum=MaxY/ 2; numSizeY.Maximum=MaxY/ 2;
//LogUtil.info($"投影点位范围:X:{MaxX},Y:{MaxY}");
typeList = new List<string>(); typeList = new List<string>();
this.cmbType.Items.Clear(); this.cmbType.Items.Clear();
typeList.AddRange(new string[] { typeList.AddRange(new string[] {
...@@ -130,6 +130,11 @@ namespace UserFromControl ...@@ -130,6 +130,11 @@ namespace UserFromControl
numY.Text = targetValue.ToString(); numY.Text = targetValue.ToString();
ShowCurrPoint(); ShowCurrPoint();
} }
else
{
numY.Text = 1.ToString();
ShowCurrPoint();
}
} }
private void btnLeft_Click(object sender, EventArgs e) private void btnLeft_Click(object sender, EventArgs e)
...@@ -141,6 +146,11 @@ namespace UserFromControl ...@@ -141,6 +146,11 @@ namespace UserFromControl
numX.Text = targetValue.ToString(); numX.Text = targetValue.ToString();
ShowCurrPoint(); ShowCurrPoint();
} }
else
{
numX.Text = 1.ToString();
ShowCurrPoint();
}
} }
private void btnRight_Click(object sender, EventArgs e) private void btnRight_Click(object sender, EventArgs e)
...@@ -153,6 +163,11 @@ namespace UserFromControl ...@@ -153,6 +163,11 @@ namespace UserFromControl
numX.Text = targetValue .ToString(); numX.Text = targetValue .ToString();
ShowCurrPoint(); ShowCurrPoint();
} }
else
{
numX.Text = MaxX.ToString();
ShowCurrPoint();
}
} }
private void btnDown_Click(object sender, EventArgs e) private void btnDown_Click(object sender, EventArgs e)
...@@ -164,6 +179,11 @@ namespace UserFromControl ...@@ -164,6 +179,11 @@ namespace UserFromControl
numY.Text = targetValue .ToString(); numY.Text = targetValue .ToString();
ShowCurrPoint(); ShowCurrPoint();
} }
else
{
numY.Text = MaxY.ToString();
ShowCurrPoint();
}
} }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!