Commit ca74e6c5 LN

新离线编程

1 个父辈 7df8a2a9
......@@ -149,6 +149,9 @@ namespace TSA_V.Common
[MyConfigComment("点位切换音效文件")]
public static MyConfig<string> Set_PointChangeSound = @"\sound\pointC.wav";
[MyConfigComment("最后一次校准信息,保存后作为新板子的基准")]
public static MyConfig<string> Data_LastCalibrateInfo ="";
public static void ChangeConfig()
{
try
......@@ -280,5 +283,6 @@ namespace TSA_V.Common
}
}
}
}
......@@ -35,6 +35,19 @@ namespace TSA_V.Common
}
return value;
}
public static double GetDoubleValue(NumericUpDown num)
{
double value = 0;
try
{
value =(double)num.Value;
}
catch (Exception ex)
{
value = 0;
}
return value;
}
public static int GetIntValue(TextBox txt)
{
int value = 0;
......
......@@ -87,10 +87,10 @@ namespace TSA_V.DeviceLibrary
/// </summary>
public int LineWidth { get; set; }
public double BaseX = 0;
public double BaseY = 0;
public double BaseImageX = 0;
public double BaseImageY = 0;
//public double BaseX = 0;
//public double BaseY = 0;
//public double BaseImageX = 0;
//public double BaseImageY = 0;
public string AOIProName = "";
......@@ -196,6 +196,25 @@ namespace TSA_V.DeviceLibrary
return true;
}
public List<SMTPointInfo> getCalPoint()
{
SMTPointInfo lefup = new SMTPointInfo();
lefup.PositionX = 0;
lefup.PositionY = 0;
lefup.NodePositionX = calInfo.leftUpPoint.X;
lefup.NodePositionY = calInfo.leftUpPoint.Y;
SMTPointInfo right = new SMTPointInfo();
right.PositionX = boardWidth;
right.PositionY = boardLength;
right.NodePositionX = calInfo.rightBottomPoint.X;
right.NodePositionY = calInfo.rightBottomPoint.Y;
List<SMTPointInfo> checkOKList = new List<SMTPointInfo>() { lefup, right };
return checkOKList;
}
public CalibrateBean calInfo = null;
}
......@@ -246,6 +265,7 @@ namespace TSA_V.DeviceLibrary
this.PenWidth = penWidth;
this.ShowText = showText;
this.PolaritiesType = PolaritiesType;
this.imgP=new DrawPointInfo(pointSizex, pointSizeY,penWidth);
//if (String.IsNullOrEmpty(this.ShowText))
//{
// this.ShowText = name;
......@@ -339,6 +359,7 @@ namespace TSA_V.DeviceLibrary
/// </summary>
public bool CheckOK = false;
public long pUTime = 0;
public string ToCSVStr()
{
string spilt = ",";
......@@ -355,18 +376,39 @@ namespace TSA_V.DeviceLibrary
return text;
}
/// <summary>
/// 点类型,1=点,2=+,3=|,3=-,4=方形,5=圆圈
/// </summary>
public int PointType = 1;
public void UpdateImgP(ProjectorPInfo p)
{
PositionX = p.PX;
PositionY = p.PY;
PointType = p.PType;
PointSizeX = p.SizeX;
PointSizeY=p.SizeY;
PenWidth = p.PenWidth;
this.ShowText = p.ShowText;
this.PolaritiesType = p.PolaritiesType;
}
public ProjectorPInfo GetShowPInfo(float imageXiShu=1)
{
ProjectorPInfo p = new ProjectorPInfo(PositionX*imageXiShu, PositionY * imageXiShu, PointType, PolaritiesType, (int)(PointSizeX * imageXiShu), (int)(PointSizeY * imageXiShu), (int)(PenWidth * imageXiShu), ShowText);
return p;
}
/// <summary>
/// 点大小
/// </summary>
public int PointSizeX = 1;
public int PointSizeY = 1;
public int PenWidth = 2;
/// <summary>
/// 图片上的点的信息
/// </summary>
public DrawPointInfo imgP = null;
/// <summary>
/// 点类型,1=点,2=+,3=|,3=-,4=方形,5=圆圈
/// </summary>
public int PointType = 1;
public string ShowText = "";
/// <summary>
/// 是否禁用,默认0
......@@ -389,4 +431,26 @@ namespace TSA_V.DeviceLibrary
public ComponetInfo componet;
}
public class DrawPointInfo
{
public DrawPointInfo()
{
}
public DrawPointInfo(int sizeX, int sizeY, int pWidth )
{
SizeX = sizeX;
SizeY = sizeY;
PWidth = pWidth;
this.uTime = DateTime.Now.Ticks;
}
public int SizeX = 5;
public int SizeY = 5;
public int PWidth = 1;
/// <summary>
/// 最后一次更新时间
/// </summary>
public long uTime;
}
}
......@@ -8,7 +8,7 @@ namespace TSA_V.DeviceLibrary
{
public class ProjectorPInfo
{
public ProjectorPInfo(int x, int y, int type=1,int polaritiesType=0, int sizeX=4, int sizeY=4,int lineWidth=2,string showText="",int color=-1)
public ProjectorPInfo(double x, double y, int type=1,int polaritiesType=0, int sizeX=4, int sizeY=4,int lineWidth=2,string showText="",int color=-1)
{
this.PX = x;
this.PY = y;
......@@ -20,8 +20,8 @@ namespace TSA_V.DeviceLibrary
this.showColor = color;
this.PolaritiesType= polaritiesType;
}
public int PX = 2;
public int PY = 2;
public double PX = 2;
public double PY = 2;
public int PType = 1;
public int SizeX = 4;
......
......@@ -95,6 +95,12 @@ namespace TSA_V.DeviceLibrary
sm.PointType =5;
}
if (sm.imgP == null)
{
sm.imgP=new DrawPointInfo(sm.PointSizeX, sm.PointSizeY,sm.PenWidth);
needSave = true;
}
}
if (board.boardId > MaxId)
{
......@@ -547,5 +553,6 @@ namespace TSA_V.DeviceLibrary
}
}
}
using System;
using System.CodeDom;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TSA_V.Common;
namespace TSA_V.DeviceLibrary
{
public class XYConvertManager
{
private static List<ConBaseInfo> conList = null;
public static List<ConBaseInfo> ConList
{
get
{
if (conList == null)
{
try
{
conList = JsonHelper.DeserializeJsonToObject<List<ConBaseInfo>>(Setting_NInit.Data_LastCalibrateInfo);
}
catch (Exception ex)
{
LogUtil.error("转换lastCalibrateBean出错:" + ex.ToString());
}
}
return conList;
}
set
{
conList = value;
Setting_NInit.Data_LastCalibrateInfo = JsonHelper.SerializeObject(conList);
}
}
public static void SaveData(BoardInfo board)
{
List<ConBaseInfo> data = new List<ConBaseInfo>() {
new ConBaseInfo(new Point(0,0),board.calInfo.leftUpPoint),
new ConBaseInfo(new Point(board.boardWidth,board.boardLength),board.calInfo.rightBottomPoint),
};
}
private SMTPointInfo CalPointNodePosition(SMTPointInfo smtPoint, List<SMTPointInfo> checkOKList)
{
try
{
if (smtPoint.CheckOK)
{
//校准点不再自动计算
return smtPoint;
}
double oldX = smtPoint.NodePositionX;
double oldY = smtPoint.NodePositionY;
//SMTPointInfo APoint = GetPoint(smtPoint, checkOKList);
//SMTPointInfo BPoint = GetPoint(APoint, checkOKList);
SMTPointInfo APoint = checkOKList[0];
SMTPointInfo BPoint = checkOKList[1];
//计算坐标
if (Math.Abs(smtPoint.PositionX - APoint.PositionX) < 0.01)
{
smtPoint.NodePositionX = APoint.NodePositionX;
}
else
{
smtPoint.NodePositionX = APoint.NodePositionX + (BPoint.NodePositionX - APoint.NodePositionX) * (smtPoint.PositionX - APoint.PositionX) / (BPoint.PositionX - APoint.PositionX);
if (double.IsNaN(smtPoint.NodePositionX) || double.IsInfinity(smtPoint.NodePositionX))
{
smtPoint.NodePositionX = APoint.NodePositionX;
}
}
if (Math.Abs(smtPoint.PositionY - APoint.PositionY) < 0.01)
{
smtPoint.NodePositionY = APoint.NodePositionY;
}
else
{
smtPoint.NodePositionY = APoint.NodePositionY + (BPoint.NodePositionY - APoint.NodePositionY) * (smtPoint.PositionY - APoint.PositionY) / (BPoint.PositionY - APoint.PositionY);
if (double.IsNaN(smtPoint.NodePositionY) || double.IsInfinity(smtPoint.NodePositionY))
{
smtPoint.NodePositionY = APoint.NodePositionY;
}
}
if (smtPoint.NodePositionX <= 0)
{
smtPoint.NodePositionX = 1;
}
else if (smtPoint.NodePositionX > FrmProjectorScreen.instance.BoundsWidth)
{
smtPoint.NodePositionX = FrmProjectorScreen.instance.BoundsWidth;
}
if (smtPoint.NodePositionY <= 0)
{
smtPoint.NodePositionY = 1;
}
else if (smtPoint.NodePositionY > FrmProjectorScreen.instance.BoundsHeight)
{
smtPoint.NodePositionY = FrmProjectorScreen.instance.BoundsHeight;
}
if (smtPoint.PointSizeX < 1 || smtPoint.PointSizeX > 255)
{
smtPoint.PointSizeX = Setting_NInit.Device_DefaultPointSize;
}
if (smtPoint.PointSizeY < 1 || smtPoint.PointSizeY > 255)
{
smtPoint.PointSizeY = Setting_NInit.Device_DefaultPointSize;
}
double xXishu = (BPoint.NodePositionX - APoint.NodePositionX) / (BPoint.PositionX - APoint.PositionX);
double yXishu = (BPoint.NodePositionY - APoint.NodePositionY) / (BPoint.PositionY - APoint.PositionY);
//计算点大小
if (smtPoint.imgP.uTime > smtPoint.pUTime)
{
smtPoint.PointSizeX = (int)((BPoint.NodePositionX - APoint.NodePositionX) * smtPoint.imgP.SizeX / (BPoint.PositionX - APoint.PositionX));
smtPoint.PointSizeY = (int)((BPoint.NodePositionY - APoint.NodePositionY) * smtPoint.imgP.SizeY / (BPoint.PositionY - APoint.PositionY));
smtPoint.PenWidth = (int)((BPoint.NodePositionX - APoint.NodePositionX) * smtPoint.imgP.PWidth / (BPoint.PositionX - APoint.PositionX));
}
//smtPoint.PointSize = 4;
//smtPoint.NodePositionX = BPoint.NodePositionX - (BPoint.NodePositionX - APoint.NodePositionX) * (BPoint.PositionX - smtPoint.PositionX) / (BPoint.PositionX - APoint.PositionX);
//smtPoint.NodePositionY = BPoint.NodePositionY - (BPoint.NodePositionY - APoint.NodePositionY) * (BPoint.PositionY - smtPoint.PositionY) / (BPoint.PositionY - APoint.PositionY);
LogUtil.info($" 【{smtPoint.PN}】图片坐标【{smtPoint.PositionX},{smtPoint.PositionY}】旧坐标【{oldX},{oldY}】新坐标【{smtPoint.NodePositionX},{smtPoint.NodePositionY}】" +
$"点尺寸({smtPoint.PointSizeX},{smtPoint.PointSizeY}),画笔宽{smtPoint.PenWidth}");
return smtPoint;
}
catch (Exception ex)
{
LogUtil.error(" 【" + smtPoint.PN + "】图片坐标【" + smtPoint.PositionX + "," + smtPoint.PositionY + "】校准坐标出错:" + ex.ToString());
}
return smtPoint;
}
private SMTPointInfo GetPoint(SMTPointInfo smtPoint, List<SMTPointInfo> checkOKList)
{
SMTPointInfo p = null;
double maxPingFang = 0;
foreach (SMTPointInfo sm in checkOKList)
{
if (sm.pointNum.Equals(smtPoint.pointNum))
{
continue;
}
double xjuli = sm.PositionX - smtPoint.PositionX;
double yjuli = sm.PositionY - smtPoint.PositionY;
double cping = xjuli * xjuli + yjuli * yjuli;
if (cping > maxPingFang)
{
p = sm;
maxPingFang = cping;
continue;
}
}
if (p != null)
{
return p;
}
return null;
}
}
public class ConBaseInfo
{
public ConBaseInfo()
{
}
public ConBaseInfo(Point point1,Point point2)
{
this.IPoint = point1;
this.Point = point2;
}
/// <summary>
/// 板子实际坐标
/// </summary>
public Point IPoint = new Point();
/// <summary>
/// 投影对应坐标
/// </summary>
public Point Point = new Point();
}
}
......@@ -761,19 +761,23 @@ namespace TSA_V
string bomName = cmbList.Text;
List<ComponetInfo> list = CSVBomManager.GetComList(bomName);
foreach (ComponetInfo obj in comList)
{
{
foreach (ComponetInfo currObj in list)
{
if (currObj.IsSameCom(obj.PN,obj.PositionNum,obj.TagNo))
if (currObj.PN.Equals(obj.PN)&&currObj.TagNo.Equals(obj.TagNo)&&currObj.PositionNum.Equals(obj.PositionNum))
{
ComponetUploadInfo upload = new ComponetUploadInfo();
upload.Id = currObj.Id;
upload.PN = currObj.PN;
upload.TagNo=currObj.TagNo;
upload.ComCount = currObj.ComCount;
upload.NewCount = obj.ComCount;
upload.PositionNum = currObj.PositionNum;
uploadList.Add(upload);
//如果数量不同才修改
//if (currObj.ComCount != obj.ComCount)
{
ComponetUploadInfo upload = new ComponetUploadInfo();
upload.Id = currObj.Id;
upload.PN = currObj.PN;
upload.TagNo = currObj.TagNo;
upload.ComCount = currObj.ComCount;
upload.NewCount = obj.ComCount;
upload.PositionNum = currObj.PositionNum;
uploadList.Add(upload);
}
break;
}
}
......@@ -784,7 +788,7 @@ namespace TSA_V
}
FrmListViewer<ComponetUploadInfo> frmListViewer = new FrmListViewer<ComponetUploadInfo>(uploadList, 1);
FrmComCountView frmListViewer = new FrmComCountView (uploadList );
List<ComponetInfo> newList = new List<ComponetInfo>();
DialogResult showRes = frmListViewer.ShowDialog();
if (showRes.Equals(DialogResult.OK))
......@@ -795,7 +799,7 @@ namespace TSA_V
{
foreach (ComponetUploadInfo upload in uploadList)
{
if (currObj.IsSameCom(upload.PN, upload.PositionNum, upload.TagNo))
if (currObj.PN.Equals(upload.PN) && currObj.TagNo.Equals(upload.TagNo) && currObj.PositionNum.Equals(upload.PositionNum))
{
LogUtil.info($"修改元器件库{bomName} PN:{currObj.ComCount} TagNo:{currObj.TagNo} 的数量:{currObj.ComCount}->{upload.NewCount}");
currObj.ComCount = upload.NewCount;
......
......@@ -2699,4 +2699,18 @@
<data name = "FrmDeviceConfig_chbWorkT_Text" xml:space = "preserve"> <value> Turn on the work sound </value> </data>
<data name = "FrmDeviceConfig_chbAlarmT_Text" xml:space = "preserve"> <value> Turn on the alarm sound </value> </data>
<data name = "FrmDeviceConfig_chbDisBottomCylinder_Text" xml:space = "preserve"> <value> Disable bottom cylinder </value> </data>
<data name = "FrmAddBoard_chbShowText_Text" xml:space = "preserve"> <value> Set bit number to projected text </value> </data>
<data name = "FrmAddBoard_groupBox4_Text" xml:space = "preserve"> <value> Point Default Settings </value> </data>
<data name = "FrmAddBoard_label10_Text" xml:space = "preserve"> <value> Landscape size→: </value> </data>
<data name = "FrmAddBoard_rdbData_Text" xml:space = "preserve"> <value> Data Sheet Upload </value> </data>
<data name = "FrmBoardInfo_linkDis_Text" xml:space = "preserve"> <value> Batch Disable </value> </data>
<data name = "FrmBoardInfo_linkEnable_Text" xml:space = "preserve"> <value> Batch Enable </value> </data>
<data name = "EnableOk" xml:space = "preserve"> <value> Enable Success </value> </data>
<data name = "DisableOk" xml:space = "preserve"> <value> Disabled Success </value> </data>
<data name = "FrmPointInfo_btnColorChange_Text" xml:space = "preserve"> <value> Color </value> </data>
<data name = "FrmPointInfo_rdbPro_Text" xml:space = "preserve"> <value> projected coordinate/pixels </value> </data>
<data name = "FrmPointInfo_rdbImg_Text" xml:space = "preserve"> <value> actual coordinates/mm </value> </data>
<data name = "SureDeleteSel" xml:space = "preserve"> <value> OK to delete the selected data? </value> </data>
<data name = "FrmBomViewer_linkDelete_Text" xml:space = "preserve"> <value> Batch Delete </value> </data>
<data name = "Column_ISUpdate" xml:space = "preserve"> <value> modified </value> </data>
</root>
\ No newline at end of file
......@@ -2683,4 +2683,18 @@
<data name = "FrmDeviceConfig_chbWorkT_Text" xml:space = "preserve"> <value> 开启工作音效 </value> </data>
<data name = "FrmDeviceConfig_chbAlarmT_Text" xml:space = "preserve"> <value> 开启报警音效 </value> </data>
<data name = "FrmDeviceConfig_chbDisBottomCylinder_Text" xml:space = "preserve"> <value> 禁用底部气缸 </value> </data>
<data name = "FrmAddBoard_chbShowText_Text" xml:space = "preserve"> <value> 默认设置位号为投影文字 </value> </data>
<data name = "FrmAddBoard_groupBox4_Text" xml:space = "preserve"> <value> 点位默认设置 </value> </data>
<data name = "FrmAddBoard_label10_Text" xml:space = "preserve"> <value> 横向大小→: </value> </data>
<data name = "FrmAddBoard_rdbData_Text" xml:space = "preserve"> <value> 数据表上传 </value> </data>
<data name = "FrmBoardInfo_linkDis_Text" xml:space = "preserve"> <value> 批量禁用 </value> </data>
<data name = "FrmBoardInfo_linkEnable_Text" xml:space = "preserve"> <value> 批量启用 </value> </data>
<data name = "EnableOk" xml:space = "preserve"> <value> 启用成功 </value> </data>
<data name = "DisableOk" xml:space = "preserve"> <value> 禁用成功 </value> </data>
<data name = "FrmPointInfo_btnColorChange_Text" xml:space = "preserve"> <value> 颜色 </value> </data>
<data name = "FrmPointInfo_rdbPro_Text" xml:space = "preserve"> <value> 投影坐标/pixels </value> </data>
<data name = "FrmPointInfo_rdbImg_Text" xml:space = "preserve"> <value> 实际坐标/mm </value> </data>
<data name = "SureDeleteSel" xml:space = "preserve"> <value> 确定删除选中的数据? </value> </data>
<data name = "FrmBomViewer_linkDelete_Text" xml:space = "preserve"> <value> 批量删除 </value> </data>
<data name = "Column_ISUpdate" xml:space = "preserve"> <value> 是否修改 </value> </data>
</root>
\ No newline at end of file
......@@ -2698,4 +2698,19 @@
<data name = "FrmDeviceConfig_chbWorkT_Text" xml:space = "preserve"> <value> 开启工作音效 </value> </data>
<data name = "FrmDeviceConfig_chbAlarmT_Text" xml:space = "preserve"> <value> 开启报警音效 </value> </data>
<data name = "FrmDeviceConfig_chbDisBottomCylinder_Text" xml:space = "preserve"> <value> 禁用底部气缸 </value> </data>
<data name = "FrmAddBoard_chbShowText_Text" xml:space = "preserve"> <value> 默认设置位号为投影文字 </value> </data>
<data name = "FrmAddBoard_groupBox4_Text" xml:space = "preserve"> <value> 点位默认设置 </value> </data>
<data name = "FrmAddBoard_label10_Text" xml:space = "preserve"> <value> 横向大小→: </value> </data>
<data name = "FrmAddBoard_rdbData_Text" xml:space = "preserve"> <value> 数据表上传 </value> </data>
<data name = "FrmBoardInfo_linkDis_Text" xml:space = "preserve"> <value> 批量禁用 </value> </data>
<data name = "FrmBoardInfo_linkEnable_Text" xml:space = "preserve"> <value> 批量启用 </value> </data>
<data name = "EnableOk" xml:space = "preserve"> <value> 启用成功 </value> </data>
<data name = "DisableOk" xml:space = "preserve"> <value> 禁用成功 </value> </data>
<data name = "FrmPointInfo_btnColorChange_Text" xml:space = "preserve"> <value> 颜色 </value> </data>
<data name = "FrmPointInfo_rdbPro_Text" xml:space = "preserve"> <value> 投影坐标/pixels </value> </data>
<data name = "FrmPointInfo_rdbImg_Text" xml:space = "preserve"> <value> 实际坐标/mm </value> </data>
<data name = "SureDeleteSel" xml:space = "preserve"> <value> 确定删除选中的数据? </value> </data>
<data name = "FrmBomViewer_linkDelete_Text" xml:space = "preserve"> <value> 批量删除 </value> </data>
<data name = "Column_ISUpdate" xml:space = "preserve"> <value> 是否修改 </value> </data>
</root>
\ No newline at end of file
......@@ -188,6 +188,12 @@
<Compile Include="frmBoard\FrmBomUpload.Designer.cs">
<DependentUpon>FrmBomUpload.cs</DependentUpon>
</Compile>
<Compile Include="frmBoard\FrmComCountView.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="frmBoard\FrmComCountView.Designer.cs">
<DependentUpon>FrmComCountView.cs</DependentUpon>
</Compile>
<Compile Include="frmBoard\FrmCalibrate.cs">
<SubType>Form</SubType>
</Compile>
......@@ -216,6 +222,7 @@
<Compile Include="deviceDebug\FrmUpdatePwd.Designer.cs">
<DependentUpon>FrmUpdatePwd.cs</DependentUpon>
</Compile>
<Compile Include="manager\DrawPointManager.cs" />
<Compile Include="manager\FormManager.cs" />
<Compile Include="frmBoard\FrmAddBoard.cs">
<SubType>Form</SubType>
......@@ -290,6 +297,7 @@
<DependentUpon>FrmBoardPutCom.cs</DependentUpon>
</Compile>
<Compile Include="manager\MouseManager.cs" />
<Compile Include="manager\XYConvertManager.cs" />
<Compile Include="messageBox\MessageBoxMidle.cs" />
<Compile Include="projector\FrmViewScreen.cs">
<SubType>Form</SubType>
......@@ -445,6 +453,9 @@
<EmbeddedResource Include="frmBoard\FrmBomUpload.resx">
<DependentUpon>FrmBomUpload.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="frmBoard\FrmComCountView.resx">
<DependentUpon>FrmComCountView.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="frmBoard\FrmCalibrate.resx">
<DependentUpon>FrmCalibrate.cs</DependentUpon>
</EmbeddedResource>
......@@ -783,7 +794,9 @@
</Content>
<Content Include="记录.txt" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Folder Include="frmBoard\back\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
......
......@@ -172,11 +172,19 @@ namespace TSA_V
int xFangxiang = 1;
int yFangxiang = -1;
int pointSizeX = xyMoveControl1.PointSizeX;
int pointSizeY = xyMoveControl1.PointSizeY;
int pointType = xyMoveControl1.PointType;
int penWidth = xyMoveControl1.PenWidth;
int PolaritiesType = xyMoveControl1.PolaritiesType;
//int pointSizeX = xyMoveControl1.PointSizeX;
//int pointSizeY = xyMoveControl1.PointSizeY;
//int pointType = xyMoveControl1.PointType;
//int penWidth = xyMoveControl1.PenWidth;
//int PolaritiesType = xyMoveControl1.PolaritiesType;
int pointSizeX =(int) numSizeX.Value;
int pointSizeY = (int)numSizeY.Value;
int pointType = cmbType.SelectedIndex;
int penWidth =(int) numPenWidth.Value;
int PolaritiesType = 0;
bool hasTest = chbShowText.Checked;
foreach (ComponetInfo com in comList)
{
double x =com.PositionX+ pianYiX;
......@@ -197,7 +205,12 @@ namespace TSA_V
y = board.boardLength - y;
x = board.boardWidth - x;
}
SMTPointInfo point = new SMTPointInfo(i, com.TagNo, com.PN, x, y, com.PositionNum,com.Text, pointType,pointSizeX,pointSizeY,penWidth, PolaritiesType);
string showText = com.Text;
if (hasTest && showText == "")
{
showText = com.TagNo;
}
SMTPointInfo point = new SMTPointInfo(i, com.TagNo, com.PN, x, y, com.PositionNum, showText, pointType,pointSizeX,pointSizeY,penWidth, PolaritiesType);
y = board.boardLength - y;
......@@ -290,11 +303,16 @@ namespace TSA_V
}
private void FrmAddBoard_Load(object sender, EventArgs e)
{
{
label7.Text = ResourceCulture.GetString("FrmPointInfo_lblSizeWidth_Text", "纵向大小↓: ");
label10.Text = ResourceCulture.GetString("FrmPointInfo_lblSizeLength_Text", "横向大小→:");
lbltype.Text = ResourceCulture.GetString("FrmPointInfo_lbltype_Text", "坐标点形状:");
lblLineWidth.Text = ResourceCulture.GetString("FrmPointInfo_lblLineWidth_Text", "画笔宽度:");
this.timer1.Enabled = true;
LoadComList();
LanguageProcess();
LanguageProcess();
xyMoveControl1.Visible = false;
//xyMoveControl1.XValue = ConfigAppSettings.GetDoubleValue(Setting_Init.BOARD_ORIGIN_X);
//xyMoveControl1.YValue = ConfigAppSettings.GetDoubleValue(Setting_Init.BOARD_ORIGIN_Y);
this.cmbOrgType.Items.Clear();
......@@ -319,10 +337,10 @@ namespace TSA_V
xyMoveControl1.ShowPointEvent += XyMoveControl1_ShowPointEvent;
xyMoveControl1.XValue = TSAVBean.X_Max/2;
xyMoveControl1.YValue = TSAVBean.Y_Max/2;
ProjectorControl.MaxX =(int) TSAVBean.X_Max;
ProjectorControl.MaxY = (int)TSAVBean.Y_Max;
xyMoveControl1.MaxX =(int) TSAVBean.X_Max;
xyMoveControl1.MaxY = (int)TSAVBean.Y_Max;
xyMoveControl1.ShowText = "";
cmbType.SelectedIndex= 0;
rdbUpload.Checked = true;
ComChange( );
......@@ -359,37 +377,14 @@ namespace TSA_V
}
private void ComChange( )
{
if (rdbUpload.Checked)
{
txtCsvFileName.Visible = true;
likDownFile.Visible = true;
likSelCsvFile.Visible = true;
cmbBomList.Visible = false;
linkBomUpload.Visible = true;
linkDataViewer.Visible = uploadPointList.Count > 0;
}
else if (rdbSelCom.Checked)
{
txtCsvFileName.Visible = false;
likDownFile.Visible = false;
likSelCsvFile.Visible = false;
cmbBomList.Visible = true;
linkBomUpload.Visible = false;
}
//else if (rbBom.Checked)
//{
// FrmBomUpload frm = new FrmBomUpload();
// DialogResult resut = frm.ShowDialog();
// if (resut.Equals(DialogResult.OK))
// {
// List<ComponetInfo> dataList = frm.componetInfos;
// if (ProcessComData(dataList))
// {
// uploadPointList = dataList;
// }
// }
//}
{
txtCsvFileName.Visible = rdbUpload.Checked;
likDownFile.Visible = rdbUpload.Checked;
likSelCsvFile.Visible = rdbUpload.Checked;
cmbBomList.Visible = rdbSelCom.Checked;
linkBomUpload.Visible = rdbData.Checked;
linkDataViewer.Visible = uploadPointList.Count > 0;
}
private void rdbUpload_CheckedChanged(object sender, EventArgs e)
{
......@@ -480,7 +475,8 @@ namespace TSA_V
linkDataViewer.Visible = false;
}
else
{
{
this.uploadPointList = frmViewer.dataList;
this.txtCsvFileName.Text = fileName;
linkDataViewer.Visible = true;
}
......@@ -641,17 +637,6 @@ namespace TSA_V
List<ComponetInfo> dataList = frm.componetInfos;
if (ProcessComData(dataList))
{
//FrmListViewer frmViewer = new FrmListViewer(dataList);
//DialogResult sureresult = frmViewer.ShowDialog();
//if (sureresult.Equals(DialogResult.Cancel))
//{
// uploadPointList = new List<ComponetInfo>();
// txtCsvFileName.Text = "";
// linkDataViewer.Visible = false;
//}
//else
//{
string bomName = "bomUpdate_" + DateTime.Now.ToString("yyyyMMddHHmm");
string path= Path.GetPathRoot(Application.StartupPath)+@"bomFile\"+bomName+".csv";
......@@ -662,7 +647,6 @@ namespace TSA_V
txtCsvFileName.Text = path;
linkDataViewer.Visible = true;
}
//}
}
}
}
......@@ -679,7 +663,16 @@ namespace TSA_V
txtCsvFileName.Text = "";
linkDataViewer.Visible = false;
}
else
{
this.uploadPointList = frmViewer.dataList;
}
}
}
private void rdbData_CheckedChanged(object sender, EventArgs e)
{
ComChange();
}
}
}
......@@ -52,6 +52,8 @@
this.dataGridViewImageColumn1 = new System.Windows.Forms.DataGridViewImageColumn();
this.dataGridViewImageColumn2 = new System.Windows.Forms.DataGridViewImageColumn();
this.panel1 = new System.Windows.Forms.Panel();
this.linkDis = new System.Windows.Forms.LinkLabel();
this.linkEnable = new System.Windows.Forms.LinkLabel();
this.btnCalibrate = new System.Windows.Forms.Button();
this.btnColorChange = new System.Windows.Forms.Button();
this.btnOpenFile = new System.Windows.Forms.Button();
......@@ -273,7 +275,12 @@
//
// panel1
//
this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.panel1.AutoScroll = true;
this.panel1.Controls.Add(this.linkDis);
this.panel1.Controls.Add(this.linkEnable);
this.panel1.Controls.Add(this.btnCalibrate);
this.panel1.Controls.Add(this.btnColorChange);
this.panel1.Controls.Add(this.btnOpenFile);
......@@ -289,18 +296,41 @@
this.panel1.Controls.Add(this.button1);
this.panel1.Controls.Add(this.btnSave);
this.panel1.Controls.Add(this.panel2);
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(1344, 701);
this.panel1.TabIndex = 0;
//
// linkDis
//
this.linkDis.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.linkDis.AutoSize = true;
this.linkDis.Location = new System.Drawing.Point(118, 644);
this.linkDis.Name = "linkDis";
this.linkDis.Size = new System.Drawing.Size(53, 12);
this.linkDis.TabIndex = 296;
this.linkDis.TabStop = true;
this.linkDis.Text = "批量禁用";
this.linkDis.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkDis_LinkClicked);
//
// linkEnable
//
this.linkEnable.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.linkEnable.AutoSize = true;
this.linkEnable.Location = new System.Drawing.Point(6, 644);
this.linkEnable.Name = "linkEnable";
this.linkEnable.Size = new System.Drawing.Size(53, 12);
this.linkEnable.TabIndex = 295;
this.linkEnable.TabStop = true;
this.linkEnable.Text = "批量启用";
this.linkEnable.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkEnable_LinkClicked);
//
// btnCalibrate
//
this.btnCalibrate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnCalibrate.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnCalibrate.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnCalibrate.Location = new System.Drawing.Point(6, 639);
this.btnCalibrate.Location = new System.Drawing.Point(230, 639);
this.btnCalibrate.Name = "btnCalibrate";
this.btnCalibrate.Size = new System.Drawing.Size(120, 45);
this.btnCalibrate.TabIndex = 294;
......@@ -340,7 +370,7 @@
this.btnCheck.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnCheck.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnCheck.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnCheck.Location = new System.Drawing.Point(6, 639);
this.btnCheck.Location = new System.Drawing.Point(230, 639);
this.btnCheck.Name = "btnCheck";
this.btnCheck.Size = new System.Drawing.Size(120, 45);
this.btnCheck.TabIndex = 291;
......@@ -605,7 +635,6 @@
this.Column_Down});
this.dgvList.ContextMenuStrip = this.contextMenuStrip2;
this.dgvList.Location = new System.Drawing.Point(2, 20);
this.dgvList.MultiSelect = false;
this.dgvList.Name = "dgvList";
this.dgvList.RowHeadersWidth = 30;
this.dgvList.RowTemplate.Height = 23;
......@@ -1180,5 +1209,7 @@
private System.Windows.Forms.DataGridViewLinkColumn Column_Del;
private System.Windows.Forms.DataGridViewLinkColumn Column_Up;
private System.Windows.Forms.DataGridViewLinkColumn Column_Down;
private System.Windows.Forms.LinkLabel linkDis;
private System.Windows.Forms.LinkLabel linkEnable;
}
}
\ No newline at end of file

using AccAOI;
using log4net;
using NPOI.Util;
using OpenCvSharp.Flann;
using Org.BouncyCastle.Asn1.Tsp;
using System;
using System.Collections.Generic;
using System.Drawing;
......@@ -294,6 +296,7 @@ namespace TSA_V
view = new DataGridViewRow();
view.CreateCells(dgvList);
}
view.Tag = point;
view.Cells[0].Value = point.pointNum.ToString();
view.Cells[1].Value = point.TagNo.ToString();
view.Cells[2].Value = point.PN;
......@@ -702,6 +705,13 @@ namespace TSA_V
{
return null;
}
try
{
point = (SMTPointInfo)row.Tag;
}catch(Exception ex)
{
LogUtil.error("获取行数据出错:" + ex.ToString());
}
point.PN = row.Cells[Column_Name.Name].Value.ToString();
point.pointNum = Convert.ToInt32(row.Cells[this.Column_pointNum.Name].Value.ToString());
point.TagNo = row.Cells[this.Column_PartNum.Name].Value.ToString();
......@@ -847,7 +857,7 @@ namespace TSA_V
{
setPointInfo(dgvList.Rows[currIndex - 1], smt);
}
dgvList.Rows[currIndex].Selected = true;
// dgvList.Rows[currIndex].Selected = true;
}
}
catch (Exception ex)
......@@ -875,6 +885,9 @@ namespace TSA_V
List<SMTPointInfo> allPoint = allPointInfo();
FrmPointInfo fwpi = new FrmPointInfo(updateBoardInfo, allPoint, rowIndex, NextProcess);
fwpi.StartPosition = FormStartPosition.Manual;
fwpi.Location= new Point(this.Location.X,this.Location.Y);
fwpi.ShowPointEvent += Fwpi_ShowPointEvent;
fwpi.AoiProgramName = cmbAOIFile.Text;
fwpi.PicImage = picBoard.Image;
DialogResult result = fwpi.ShowDialog();
......@@ -899,17 +912,16 @@ namespace TSA_V
loadPictureBoxSize();
}
SetListCurrCell(index);
}
}
}
private void AddNewPoint(double x, double y, double nodeX, double nodeY)
{
SMTPointInfo smtInfo = new SMTPointInfo();
string name = "P" + (dgvList.Rows.Count + 1);
FrmPointInfo fwpi = new FrmPointInfo(updateBoardInfo, name, x, y, nodeX, nodeY);
fwpi.ShowPointEvent += Fwpi_ShowPointEvent;
fwpi.AoiProgramName = cmbAOIFile.Text;
fwpi.PicImage = picBoard.Image;
DialogResult result = fwpi.ShowDialog();
......@@ -1209,7 +1221,7 @@ namespace TSA_V
{
if (isFinishLoad)
{
if (dgvList.SelectedRows != null && dgvList.SelectedRows.Count > 0)
if (dgvList.SelectedRows != null && dgvList.SelectedRows.Count ==1)
{
int rowIndex = dgvList.SelectedRows[0].Index;
string partNum = dgvList.Rows[rowIndex].Cells[this.Column_PartNum.Name].Value.ToString();
......@@ -1580,5 +1592,109 @@ namespace TSA_V
dgvList.Rows[i].Cells[this.Column_disable.Name].Value = true;
}
}
private void linkEnable_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
if (dgvList.SelectedRows != null && dgvList.SelectedRows.Count > 0)
{
int count = 0; isFinishLoad = false;
try
{
foreach (DataGridViewRow row in dgvList.SelectedRows)
{
SMTPointInfo point = getRowPointInfo(row);
point.Disable = false;
setPointInfo(row, point);
row.Selected = false;
count++;
}
}
catch (Exception ex)
{
LogUtil.error(ex.ToString());
}
finally
{
isFinishLoad = true;
}
if (count > 0)
{
MessageBox.Show(ResourceCulture.GetString("EnableOk", "启用成功"));
}
}
}
private void linkDis_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
if (dgvList.SelectedRows != null && dgvList.SelectedRows.Count > 0)
{
int count = 0;
isFinishLoad = false;
try
{
foreach (DataGridViewRow row in dgvList.SelectedRows)
{
SMTPointInfo point = getRowPointInfo(row);
point.Disable = true;
setPointInfo(row, point);
row.Selected = false;
count++;
}
}
catch (Exception ex)
{
LogUtil.error(ex.ToString());
}
finally
{
isFinishLoad = true;
}
if (count > 0)
{
MessageBox.Show(ResourceCulture.GetString("DisableOk", "禁用成功"));
}
}
}
private bool Fwpi_ShowPointEvent(SMTPointInfo smtInfo, Color color)
{
try
{
if (chbNormal.Checked)
{
chbNormal.Checked = false;
}
panBoard.AutoScrollPosition = new Point((int)(smtInfo.PositionX * display.imageXiShu - panBoard.Width / 2), (int)(smtInfo.PositionY * display.imageXiShu - panBoard.Height / 2));
// panBoard.AutoScrollPosition = new Point((int)picBoard.Width, (int)picBoard.Height);
if (isFinishLoad && this.txtBoardW.Text.Trim() != "" && this.txtBoardL.Text.Trim() != "")
{
//loadPictureBoxSize();
int width = 200;
int height = 200;
if (this.txtBoardL.Text.Trim() != "" && (this.txtBoardW.Text.Trim() != ""))
{
width = Convert.ToInt32(this.txtBoardL.Text.Trim());
height = Convert.ToInt32(this.txtBoardW.Text.Trim());
}
display.selectIndex = selectIndex;
display.SetImage(picBoard.Image);
display.ShowName = chbShowName.Checked;
display.ImageNormal = chbNormal.Checked;
display.DrawEditPoint(width, height, smtInfo, color);
imageXiShu = display.imageXiShu;
}
}
catch (Exception ex)
{
LogUtil.error("出错:" + ex.ToString());
}
return true;
}
}
}
......@@ -190,7 +190,11 @@ namespace TSA_V
{
this.Visible = true;
LoadCom();
cmbBoardList_SelectedIndexChanged(null, null);
if (cmbBoardList.Items.Count > 0)
{
cmbBoardList.SelectedIndex=cmbBoardList.Items.Count-1;
}
//cmbBoardList_SelectedIndexChanged(null, null);
preId = -1;
}
}
......@@ -204,6 +208,7 @@ namespace TSA_V
{
if (cmbBoardList.Text != "" && cmbBoardList.SelectedIndex >= 0)
{
int selectIndex=cmbBoardList.SelectedIndex;
BoardInfo board = (BoardInfo)cmbBoardList.SelectedItem;
////如果是当前默认程序,不能删除
//if (BoardManager.CurrBoard != null && board.boardId.Equals(BoardManager.CurrBoardId))
......@@ -228,8 +233,17 @@ namespace TSA_V
this.txtWidth.Text = "";
this.picBoard.Image = null;
LoadCom();
cmbBoardList_SelectedIndexChanged(null, null);
LoadCom();
int nexcount = selectIndex - 1;
if (nexcount < 0 &&cmbBoardList.Items.Count>0)
{
cmbBoardList.SelectedIndex = 0;
}
else
{
cmbBoardList.SelectedIndex = nexcount;
}
//cmbBoardList_SelectedIndexChanged(null, null);
preId = -1;
}
}
......
......@@ -356,6 +356,7 @@ namespace TSA_V.frmBoard
}
else
{
this.componetInfos = frmViewer.dataList;
this.DialogResult = DialogResult.OK;
}
}
......
......@@ -28,6 +28,9 @@
/// </summary>
private void InitializeComponent()
{
this.linkDelete = new System.Windows.Forms.LinkLabel();
this.btnCancel = new System.Windows.Forms.Button();
this.btnOK = new System.Windows.Forms.Button();
this.panel1 = new System.Windows.Forms.Panel();
this.dgvData = new System.Windows.Forms.DataGridView();
this.Column_ID = new System.Windows.Forms.DataGridViewTextBoxColumn();
......@@ -40,12 +43,48 @@
this.Column_Notes = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column_CompontentDes = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column_del = new System.Windows.Forms.DataGridViewLinkColumn();
this.btnOK = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dgvData)).BeginInit();
this.SuspendLayout();
//
// linkDelete
//
this.linkDelete.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.linkDelete.AutoSize = true;
this.linkDelete.Location = new System.Drawing.Point(13, 577);
this.linkDelete.Name = "linkDelete";
this.linkDelete.Size = new System.Drawing.Size(53, 12);
this.linkDelete.TabIndex = 286;
this.linkDelete.TabStop = true;
this.linkDelete.Text = "批量删除";
this.linkDelete.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkDelete_LinkClicked);
//
// btnCancel
//
this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnCancel.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnCancel.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnCancel.Location = new System.Drawing.Point(875, 577);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(120, 45);
this.btnCancel.TabIndex = 285;
this.btnCancel.Text = "取消";
this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// btnOK
//
this.btnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnOK.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnOK.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnOK.Location = new System.Drawing.Point(749, 577);
this.btnOK.Name = "btnOK";
this.btnOK.Size = new System.Drawing.Size(120, 45);
this.btnOK.TabIndex = 284;
this.btnOK.Text = "确认";
this.btnOK.UseVisualStyleBackColor = true;
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
//
// panel1
//
this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
......@@ -76,13 +115,13 @@
this.Column_del});
this.dgvData.Dock = System.Windows.Forms.DockStyle.Fill;
this.dgvData.Location = new System.Drawing.Point(0, 0);
this.dgvData.MultiSelect = false;
this.dgvData.Name = "dgvData";
this.dgvData.RowTemplate.Height = 23;
this.dgvData.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.dgvData.Size = new System.Drawing.Size(995, 562);
this.dgvData.TabIndex = 0;
this.dgvData.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvData_CellContentClick);
this.dgvData.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(this.dgvData_RowPostPaint);
//
// Column_ID
//
......@@ -137,37 +176,12 @@
this.Column_del.Name = "Column_del";
this.Column_del.Text = "删除";
//
// btnOK
//
this.btnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnOK.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnOK.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnOK.Location = new System.Drawing.Point(749, 577);
this.btnOK.Name = "btnOK";
this.btnOK.Size = new System.Drawing.Size(120, 45);
this.btnOK.TabIndex = 284;
this.btnOK.Text = "确认";
this.btnOK.UseVisualStyleBackColor = true;
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
//
// btnCancel
//
this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnCancel.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnCancel.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnCancel.Location = new System.Drawing.Point(875, 577);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(120, 45);
this.btnCancel.TabIndex = 285;
this.btnCancel.Text = "取消";
this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// FrmBomViewer
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1007, 634);
this.Controls.Add(this.linkDelete);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnOK);
this.Controls.Add(this.panel1);
......@@ -180,6 +194,7 @@
this.panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dgvData)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
......@@ -199,5 +214,6 @@
private System.Windows.Forms.DataGridViewTextBoxColumn Column_Notes;
private System.Windows.Forms.DataGridViewTextBoxColumn Column_CompontentDes;
private System.Windows.Forms.DataGridViewLinkColumn Column_del;
private System.Windows.Forms.LinkLabel linkDelete;
}
}
\ No newline at end of file
......@@ -192,5 +192,55 @@ namespace TSA_V
}
}
}
private void linkDelete_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
if (dgvData.SelectedRows != null && dgvData.SelectedRows.Count > 0)
{
try
{
if (MessageBox.Show(ResourceCulture.GetString("SureDeleteSel", "确定删除选中的数据?"),
ResourceCulture.GetString(ResourceCulture.MsgTitle, "提示?"),
MessageBoxButtons.OKCancel,
MessageBoxIcon.Question) != DialogResult.OK)
{
return;
}
List<DataGridViewRow> rows = new List<DataGridViewRow>();
foreach (DataGridViewRow row in dgvData.SelectedRows)
{
rows.Add(row);
}
foreach(DataGridViewRow row in rows)
{
this.dgvData.Rows.Remove(row);
}
}
catch (Exception ex)
{
LogUtil.error(ex.ToString());
}
}
}
private void dgvData_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
// 表头宽度
SizeF strSizeF = e.Graphics.MeasureString((e.RowIndex + 1).ToString(), this.dgvData.RowHeadersDefaultCellStyle.Font);
if (strSizeF.Width + 20 > this.dgvData.RowHeadersWidth)
this.dgvData.RowHeadersWidth = 20 + (int)strSizeF.Width;
// 序号显示
SolidBrush b = new SolidBrush(dgvData.RowHeadersDefaultCellStyle.ForeColor);
e.Graphics.DrawString(
(e.RowIndex + 1).ToString(System.Globalization.CultureInfo.CurrentUICulture),
this.dgvData.DefaultCellStyle.Font,
b,
e.RowBounds.Location.X + 10,
e.RowBounds.Location.Y + 4);
}
}
}
......@@ -260,23 +260,15 @@ namespace TSA_V.frmBoard
{
List<SMTPointInfo> pointList = new List<SMTPointInfo>(currBoard.smtList);
SMTPointInfo lefup = new SMTPointInfo();
lefup.PositionX = 0;
lefup.PositionY = 0;
lefup.NodePositionX = currBoard.calInfo.leftUpPoint.X;
lefup.NodePositionY = currBoard.calInfo.leftUpPoint.Y;
List<SMTPointInfo> checkOKList = currBoard.getCalPoint();
SMTPointInfo right = new SMTPointInfo();
right.PositionX = currBoard.boardWidth;
right.PositionY = currBoard.boardLength;
right.NodePositionX = currBoard.calInfo.rightBottomPoint.X;
right.NodePositionY = currBoard.calInfo.rightBottomPoint.Y;
LogUtil.info($" 【{ currBoard.boardName}】左上角(0,0)坐标【{lefup.NodePositionX},{ lefup.NodePositionY}】右下角({right.PositionX},{right.PositionY})【{right.NodePositionX},{right.NodePositionY}】");
List<SMTPointInfo> checkOKList = new List<SMTPointInfo>() { lefup, right };
LogUtil.info($" 【{currBoard.boardName}】左上角(0,0)坐标【{checkOKList[0].NodePositionX},{checkOKList[0].NodePositionY}】右下角" +
$"({checkOKList[1].PositionX},{checkOKList[1].PositionY})【{checkOKList[1].NodePositionX},{checkOKList[1].NodePositionY}】");
for (int i = 0; i < pointList.Count; i++)
{
pointList[i] = CalPointNodePosition(pointList[i], checkOKList);
pointList[i] =XYConvertManager.CalPointNodePosition(pointList[i], checkOKList);
}
currBoard.smtList = pointList;
BoardManager.Update(currBoard);
......@@ -285,6 +277,10 @@ namespace TSA_V.frmBoard
this.Cursor = Cursors.Default;
//重新加载
MessageBox.Show(ResourceCulture.GetString(ResourceCulture.TrainOK, "坐标校准完成!"));
//记录校准信息
XYConvertManager.SaveData(currBoard);
DialogResult = DialogResult.OK;
this.Close();
}
......@@ -294,116 +290,6 @@ namespace TSA_V.frmBoard
}
}
private SMTPointInfo CalPointNodePosition(SMTPointInfo smtPoint, List<SMTPointInfo> checkOKList)
{
try
{
if (smtPoint.CheckOK)
{
//校准点不再自动计算
return smtPoint;
}
double oldX = smtPoint.NodePositionX;
double oldY = smtPoint.NodePositionY;
//SMTPointInfo APoint = GetPoint(smtPoint, checkOKList);
//SMTPointInfo BPoint = GetPoint(APoint, checkOKList);
SMTPointInfo APoint = checkOKList[0];
SMTPointInfo BPoint = checkOKList[1];
//计算坐标
if (Math.Abs(smtPoint.PositionX - APoint.PositionX) < 0.01)
{
smtPoint.NodePositionX = APoint.NodePositionX;
}
else
{
smtPoint.NodePositionX = APoint.NodePositionX + (BPoint.NodePositionX - APoint.NodePositionX) * (smtPoint.PositionX - APoint.PositionX) / (BPoint.PositionX - APoint.PositionX);
if (double.IsNaN(smtPoint.NodePositionX) || double.IsInfinity(smtPoint.NodePositionX))
{
smtPoint.NodePositionX = APoint.NodePositionX;
}
}
if (Math.Abs(smtPoint.PositionY - APoint.PositionY) < 0.01)
{
smtPoint.NodePositionY = APoint.NodePositionY;
}
else
{
smtPoint.NodePositionY = APoint.NodePositionY + (BPoint.NodePositionY - APoint.NodePositionY) * (smtPoint.PositionY - APoint.PositionY) / (BPoint.PositionY - APoint.PositionY);
if (double.IsNaN(smtPoint.NodePositionY) || double.IsInfinity(smtPoint.NodePositionY))
{
smtPoint.NodePositionY = APoint.NodePositionY;
}
}
if (smtPoint.NodePositionX <= 0)
{
smtPoint.NodePositionX = 1;
}
else if (smtPoint.NodePositionX > FrmProjectorScreen.instance.BoundsWidth)
{
smtPoint.NodePositionX = FrmProjectorScreen.instance.BoundsWidth;
}
if (smtPoint.NodePositionY <= 0)
{
smtPoint.NodePositionY = 1;
}
else if (smtPoint.NodePositionY > FrmProjectorScreen.instance.BoundsHeight)
{
smtPoint.NodePositionY = FrmProjectorScreen.instance.BoundsHeight;
}
if (smtPoint.PointSizeX < 1 || smtPoint.PointSizeX > 255)
{
smtPoint.PointSizeX = Setting_NInit.Device_DefaultPointSize;
}
if (smtPoint.PointSizeY < 1 || smtPoint.PointSizeY > 255)
{
smtPoint.PointSizeY = Setting_NInit.Device_DefaultPointSize;
}
//smtPoint.PointSize = 4;
//smtPoint.NodePositionX = BPoint.NodePositionX - (BPoint.NodePositionX - APoint.NodePositionX) * (BPoint.PositionX - smtPoint.PositionX) / (BPoint.PositionX - APoint.PositionX);
//smtPoint.NodePositionY = BPoint.NodePositionY - (BPoint.NodePositionY - APoint.NodePositionY) * (BPoint.PositionY - smtPoint.PositionY) / (BPoint.PositionY - APoint.PositionY);
LogUtil.info(" 【" + smtPoint.PN + "】图片坐标【" + smtPoint.PositionX + "," + smtPoint.PositionY + "】旧坐标【" + oldX + "," + oldY + "】新坐标【" + smtPoint.NodePositionX + "," + smtPoint.NodePositionY + "】");
return smtPoint;
}
catch (Exception ex)
{
LogUtil.error(" 【" + smtPoint.PN + "】图片坐标【" + smtPoint.PositionX + "," + smtPoint.PositionY + "】校准坐标出错:" + ex.ToString());
}
return smtPoint;
}
private SMTPointInfo GetPoint(SMTPointInfo smtPoint, List<SMTPointInfo> checkOKList)
{
SMTPointInfo p = null;
double maxPingFang = 0;
foreach (SMTPointInfo sm in checkOKList)
{
if (sm.pointNum.Equals(smtPoint.pointNum))
{
continue;
}
double xjuli = sm.PositionX - smtPoint.PositionX;
double yjuli = sm.PositionY - smtPoint.PositionY;
double cping = xjuli * xjuli + yjuli * yjuli;
if (cping > maxPingFang)
{
p = sm;
maxPingFang = cping;
continue;
}
}
if (p != null)
{
return p;
}
return null;
}
private void btnExit_Click(object sender, EventArgs e)
{
......
namespace TSA_V
{
partial class FrmComCountView
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btnCancel = new System.Windows.Forms.Button();
this.btnOK = new System.Windows.Forms.Button();
this.panel1 = new System.Windows.Forms.Panel();
this.dgvData = new System.Windows.Forms.DataGridView();
this.Column_ID = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column_TagNo = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column_PN = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column_PositionNum = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column_ComCount = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column_nCount = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column_ISUpdate = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dgvData)).BeginInit();
this.SuspendLayout();
//
// btnCancel
//
this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnCancel.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnCancel.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnCancel.Location = new System.Drawing.Point(875, 577);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(120, 45);
this.btnCancel.TabIndex = 285;
this.btnCancel.Text = "取消";
this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// btnOK
//
this.btnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnOK.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnOK.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnOK.Location = new System.Drawing.Point(749, 577);
this.btnOK.Name = "btnOK";
this.btnOK.Size = new System.Drawing.Size(120, 45);
this.btnOK.TabIndex = 284;
this.btnOK.Text = "确认";
this.btnOK.UseVisualStyleBackColor = true;
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
//
// panel1
//
this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.panel1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.panel1.Controls.Add(this.dgvData);
this.panel1.Location = new System.Drawing.Point(5, 5);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(995, 562);
this.panel1.TabIndex = 0;
//
// dgvData
//
this.dgvData.AllowUserToAddRows = false;
this.dgvData.AllowUserToDeleteRows = false;
this.dgvData.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgvData.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.Column_ID,
this.Column_TagNo,
this.Column_PN,
this.Column_PositionNum,
this.Column_ComCount,
this.Column_nCount,
this.Column_ISUpdate});
this.dgvData.Dock = System.Windows.Forms.DockStyle.Fill;
this.dgvData.Location = new System.Drawing.Point(0, 0);
this.dgvData.Name = "dgvData";
this.dgvData.RowTemplate.Height = 23;
this.dgvData.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.dgvData.Size = new System.Drawing.Size(995, 562);
this.dgvData.TabIndex = 0;
this.dgvData.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvData_CellEndEdit);
this.dgvData.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(this.dgvData_RowPostPaint);
//
// Column_ID
//
this.Column_ID.DataPropertyName = "Id";
this.Column_ID.HeaderText = "ID";
this.Column_ID.Name = "Column_ID";
this.Column_ID.ReadOnly = true;
this.Column_ID.Visible = false;
//
// Column_TagNo
//
this.Column_TagNo.HeaderText = "位号";
this.Column_TagNo.Name = "Column_TagNo";
this.Column_TagNo.ReadOnly = true;
this.Column_TagNo.Width = 200;
//
// Column_PN
//
this.Column_PN.HeaderText = "物料编码";
this.Column_PN.Name = "Column_PN";
this.Column_PN.ReadOnly = true;
this.Column_PN.Width = 200;
//
// Column_PositionNum
//
this.Column_PositionNum.HeaderText = "料盘位置";
this.Column_PositionNum.Name = "Column_PositionNum";
this.Column_PositionNum.ReadOnly = true;
this.Column_PositionNum.Width = 120;
//
// Column_ComCount
//
this.Column_ComCount.HeaderText = "原始数量";
this.Column_ComCount.Name = "Column_ComCount";
this.Column_ComCount.ReadOnly = true;
//
// Column_nCount
//
this.Column_nCount.HeaderText = "新数量";
this.Column_nCount.Name = "Column_nCount";
//
// Column_ISUpdate
//
this.Column_ISUpdate.HeaderText = "是否修改";
this.Column_ISUpdate.Name = "Column_ISUpdate";
this.Column_ISUpdate.ReadOnly = true;
//
// FrmComCountView
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1007, 634);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnOK);
this.Controls.Add(this.panel1);
this.MaximizeBox = true;
this.MinimizeBox = true;
this.Name = "FrmComCountView";
this.Text = "数据预览";
this.TopMost = true;
this.Load += new System.EventHandler(this.FrmImageViewer_Load);
this.panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dgvData)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Button btnOK;
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.DataGridView dgvData;
private System.Windows.Forms.DataGridViewTextBoxColumn Column_ID;
private System.Windows.Forms.DataGridViewTextBoxColumn Column_TagNo;
private System.Windows.Forms.DataGridViewTextBoxColumn Column_PN;
private System.Windows.Forms.DataGridViewTextBoxColumn Column_PositionNum;
private System.Windows.Forms.DataGridViewTextBoxColumn Column_ComCount;
private System.Windows.Forms.DataGridViewTextBoxColumn Column_nCount;
private System.Windows.Forms.DataGridViewTextBoxColumn Column_ISUpdate;
}
}
\ No newline at end of file
using log4net.Repository.Hierarchy;
using NPOI.SS.Formula.Functions;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using TSA_V.Common;
using TSA_V.DeviceLibrary;
using TSA_V.LoadCSVLibrary;
namespace TSA_V
{
public partial class FrmComCountView : FrmBase
{
public List<ComponetUploadInfo> dataList = new List<ComponetUploadInfo>();
public FrmComCountView(List<ComponetUploadInfo> dataList )
{
InitializeComponent();
this.dataList = dataList;
}
private void FrmImageViewer_Load(object sender, EventArgs e)
{
LoadData();
this.WindowState = FormWindowState.Maximized;
}
private void addData (ComponetUploadInfo obj)
{
DataGridViewRow row = new DataGridViewRow();
row.CreateCells(dgvData);
row.Cells[0].Value = obj.Id;
row.Cells[Column_TagNo.Index].Value = obj.TagNo;
row.Cells[Column_PN.Index].Value = obj.PN;
row.Cells[Column_PositionNum.Index].Value = obj.PositionNum;
row.Cells[Column_ComCount.Index].Value = obj.ComCount;
row.Cells[Column_nCount.Index].Value = obj.NewCount;
if (obj.NewCount != obj.ComCount)
{
row.DefaultCellStyle.BackColor = Color.LightBlue;
row.Cells[Column_ISUpdate.Index].Value = "√";
}
else
{
row.DefaultCellStyle.BackColor = Color.White;
row.Cells[Column_ISUpdate.Index].Value = "";
}
dgvData.Rows.Add(row);
}
private void LoadData()
{
//dgvData.DataSource = dataList;
dgvData.Columns[0].Visible = false;
dgvData.Columns[Column_TagNo.Index].HeaderText = ResourceCulture.GetString(ResourceCulture.Col_Num, "位号");
dgvData.Columns[Column_PN.Index].HeaderText = ResourceCulture.GetString(ResourceCulture.Col_Name, "物料编码");
dgvData.Columns[Column_PositionNum.Index].HeaderText = ResourceCulture.GetString(ResourceCulture.Col_Position, "料盘位置");
dgvData.Columns[Column_ComCount.Index].HeaderText = ResourceCulture.GetString(ResourceCulture.Col_Count, "数量");
dgvData.Columns[Column_nCount.Index].HeaderText = ResourceCulture.GetString("Col_Count_N", "修改后数量");
dgvData.Columns[Column_ISUpdate.Index].HeaderText = ResourceCulture.GetString("Column_ISUpdate", "是否修改");
dgvData.AllowUserToDeleteRows = false;
dgvData.AllowUserToOrderColumns = false;
Column_TagNo.ReadOnly = true;
Column_PN.ReadOnly = true;
Column_PositionNum.ReadOnly = true;
Column_ComCount.ReadOnly = true;
Column_nCount.ReadOnly = false;
foreach (ComponetUploadInfo obj in dataList)
{
addData(obj);
}
this.Text = ResourceCulture.GetString("FrmListViewer_Text", "数据预览");
btnCancel.Text = ResourceCulture.GetString("FrmListViewer_btnCancel_Text", "取消");
btnOK.Text = ResourceCulture.GetString("FrmListViewer_btnOK_Text", "确定");
}
private void GetList()
{
List<ComponetUploadInfo> pointList = new List<ComponetUploadInfo>();
foreach (DataGridViewRow row in dgvData.Rows)
{
if (row != null)
{
ComponetUploadInfo point = getRowPointInfo(row);
if (point != null)
{
pointList.Add(point);
}
}
}
this.dataList = new List<ComponetUploadInfo>(pointList);
}
private ComponetUploadInfo getRowPointInfo(DataGridViewRow row)
{
ComponetUploadInfo point = new ComponetUploadInfo();
try
{
if (row.Cells[Column_TagNo.Name].Value == null)
{
return null;
}
point.Id = Convert.ToInt32( row.Cells[Column_ID.Name].Value.ToString());
point.PN = row.Cells[this.Column_PN.Name].Value.ToString();
point.TagNo = row.Cells[this.Column_TagNo.Name].Value.ToString();
point.PositionNum = row.Cells[this.Column_PositionNum.Name].Value.ToString();
point.ComCount = row.Cells[this.Column_ComCount.Name].Value.ToString();
point.NewCount = row.Cells[this.Column_nCount.Name].Value.ToString();
}
catch (Exception ex)
{
LogUtil.error( "保存数据出错:" + ex.ToString());
return null;
}
return point;
}
private void btnOK_Click(object sender, EventArgs e)
{
GetList();
this.DialogResult = DialogResult.OK;
this.Close();
}
private void btnCancel_Click(object sender, EventArgs e)
{
if(dataList.Count <= 0)
{
this.DialogResult = DialogResult.Cancel;
this.Close();
}
DialogResult resul = MessageBox.Show(ResourceCulture.GetString("SureCancelData","确认取消数据上传?"), "", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (resul == DialogResult.Yes)
{
this.DialogResult = DialogResult.Cancel;
this.Close();
}
}
private void dgvData_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex >= 0)
{
ComponetUploadInfo com = getRowPointInfo(dgvData.Rows[e.RowIndex]);
if(com.NewCount.Equals(com.ComCount))
{
dgvData.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.White;
dgvData.Rows[e.RowIndex].Cells[Column_ISUpdate.Index].Value = "";
}
else
{
dgvData.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.LightBlue;
dgvData.Rows[e.RowIndex].Cells[Column_ISUpdate.Index].Value = "√";
}
}
}
private void dgvData_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
// 表头宽度
SizeF strSizeF = e.Graphics.MeasureString((e.RowIndex + 1).ToString(), this.dgvData.RowHeadersDefaultCellStyle.Font);
if (strSizeF.Width + 20 > this.dgvData.RowHeadersWidth)
this.dgvData.RowHeadersWidth = 20 + (int)strSizeF.Width;
// 序号显示
SolidBrush b = new SolidBrush(dgvData.RowHeadersDefaultCellStyle.ForeColor);
e.Graphics.DrawString(
(e.RowIndex + 1).ToString(System.Globalization.CultureInfo.CurrentUICulture),
this.dgvData.DefaultCellStyle.Font,
b,
e.RowBounds.Location.X + 10,
e.RowBounds.Location.Y + 4);
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="Column_ID.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column_TagNo.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column_PN.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column_PositionNum.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column_ComCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column_nCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column_ISUpdate.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TSA_V.DeviceLibrary;
namespace TSA_V
{
public class DrawPointManager
{
public static void DrawPoint(Graphics g, ProjectorPInfo p,Color color)
{
if (p.SizeX < 2)
{
p.SizeX = 2;
}
if (p.SizeY < 2)
{
p.SizeY = 2;
}
int lineLength = 2;
int x =(int) p.PX;
int y =(int)p.PY;
Pen pen = new Pen(color, p.PenWidth);
System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(color);
//点类型,1 = 点,2 = +,3 =|,4 = -,5 = 方形,6 = 圆圈
if (p.PType.Equals(2))
{
g.DrawLine(pen, new Point(x - p.SizeX, y), new Point(x + p.SizeX, y));
g.DrawLine(pen, new Point(x, y - p.SizeY), new Point(x, y + p.SizeY));
}
else if (p.PType.Equals(3))
{
g.DrawLine(pen, new Point(x, y - p.SizeY), new Point(x, y + p.SizeY));
}
else if (p.PType.Equals(4))
{
g.DrawLine(pen, new Point(x - p.SizeX, y), new Point(x + p.SizeX, y));
}
else if (p.PType.Equals(5))
{
g.DrawRectangle(pen, x - p.SizeX / 2, y - p.SizeY / 2, p.SizeX, p.SizeY);
}
else if (p.PType.Equals(6))
{
g.DrawEllipse(pen, x - p.SizeX / 2, y - p.SizeY / 2, p.SizeX, p.SizeY);
}
else if (p.PType > 6)
{
g.DrawEllipse(pen, x - p.SizeX / 2, y - p.SizeY / 2, p.SizeX, p.SizeY);
}
else
{
g.FillEllipse(myBrush, new Rectangle(x - p.SizeX / 2, y - p.SizeY / 2, p.SizeX, p.SizeY));//画实心椭圆
}
if (p.PolaritiesType.Equals(0))
{
}
else if (p.PolaritiesType.Equals(1))
{
//p.SizeX = 12;
//p.SizeY = 36;
int plusSize = p.SizeX / 2;
int pX = x;
int pY = y - p.SizeY / 2 - lineLength - plusSize;
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));
}
else if (p.PolaritiesType.Equals(2))
{
//p.SizeX = 12;
//p.SizeY = 36;
int plusSize = p.SizeX / 2;
int pX = x;
int pY = y + p.SizeY / 2 + lineLength + plusSize;
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));
}
else if (p.PolaritiesType.Equals(3))
{
//p.SizeX = 12;
//p.SizeY = 36;
int plusSize = p.SizeY / 2;
int pX = x - p.SizeX / 2 - lineLength - plusSize;
int pY = y;
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));
}
else if (p.PolaritiesType.Equals(4))
{
//p.SizeX = 12;
//p.SizeY = 36;
int plusSize = p.SizeY / 2;
int pX = x + p.SizeX / 2 + lineLength + plusSize;
int pY = y;
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));
}
else if (p.PolaritiesType.Equals(5))
{
//p.SizeX = 12;
//p.SizeY = 36;
int plusSize = p.SizeX / 2;
int pX = x - 6;
int pY = y - p.SizeY / 2 - lineLength - plusSize;
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));
}
else if (p.PolaritiesType.Equals(6))
{
//p.SizeX = 12;
//p.SizeY = 36;
int plusSize = p.SizeX / 2;
int pX = x + 6;
int pY = y - p.SizeY / 2 - lineLength - plusSize;
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));
}
else if (p.PolaritiesType.Equals(6))
{
//p.SizeX = 12;
//p.SizeY = 36;
int plusSize = p.SizeX / 2;
int pX = x + 6;
int pY = y - p.SizeY / 2 - lineLength - plusSize;
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));
}
else if (p.PolaritiesType.Equals(7))
{
//p.SizeX = 12;
//p.SizeY = 36;
int plusSize = p.SizeX / 2;
int pX = x - 6;
int pY = y + p.SizeY / 2 + lineLength + plusSize;
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));
}
else if (p.PolaritiesType.Equals(8))
{
//p.SizeX = 12;
//p.SizeY = 36;
int plusSize = p.SizeX / 2;
int pX = x + 6;
int pY = y + p.SizeY / 2 + lineLength + plusSize;
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));
}
}
}
}
using System;
using System.CodeDom;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TSA_V.Common;
using TSA_V.DeviceLibrary;
namespace TSA_V
{
public class XYConvertManager
{
private static List<ConBaseInfo> conList = null;
public static List<ConBaseInfo> ConList
{
get
{
if (conList == null)
{
try
{
conList = JsonHelper.DeserializeJsonToObject<List<ConBaseInfo>>(Setting_NInit.Data_LastCalibrateInfo);
}
catch (Exception ex)
{
LogUtil.error("转换lastCalibrateBean出错:" + ex.ToString());
}
}
return conList;
}
set
{
conList = value;
Setting_NInit.Data_LastCalibrateInfo = JsonHelper.SerializeObject(conList);
}
}
public static void SaveData(BoardInfo board)
{
List<ConBaseInfo> data = new List<ConBaseInfo>() {
new ConBaseInfo(new Point(0,0),board.calInfo.leftUpPoint),
new ConBaseInfo(new Point(board.boardWidth,board.boardLength),board.calInfo.rightBottomPoint),
};
}
public static SMTPointInfo CalPointNodePosition(SMTPointInfo smtPoint, List<SMTPointInfo> checkOKList)
{
try
{
if (smtPoint.CheckOK)
{
//校准点不再自动计算
return smtPoint;
}
double oldX = smtPoint.NodePositionX;
double oldY = smtPoint.NodePositionY;
//SMTPointInfo APoint = GetPoint(smtPoint, checkOKList);
//SMTPointInfo BPoint = GetPoint(APoint, checkOKList);
SMTPointInfo APoint = checkOKList[0];
SMTPointInfo BPoint = checkOKList[1];
//计算坐标
if (Math.Abs(smtPoint.PositionX - APoint.PositionX) < 0.01)
{
smtPoint.NodePositionX = APoint.NodePositionX;
}
else
{
smtPoint.NodePositionX = APoint.NodePositionX + (BPoint.NodePositionX - APoint.NodePositionX) * (smtPoint.PositionX - APoint.PositionX) / (BPoint.PositionX - APoint.PositionX);
if (double.IsNaN(smtPoint.NodePositionX) || double.IsInfinity(smtPoint.NodePositionX))
{
smtPoint.NodePositionX = APoint.NodePositionX;
}
}
if (Math.Abs(smtPoint.PositionY - APoint.PositionY) < 0.01)
{
smtPoint.NodePositionY = APoint.NodePositionY;
}
else
{
smtPoint.NodePositionY = APoint.NodePositionY + (BPoint.NodePositionY - APoint.NodePositionY) * (smtPoint.PositionY - APoint.PositionY) / (BPoint.PositionY - APoint.PositionY);
if (double.IsNaN(smtPoint.NodePositionY) || double.IsInfinity(smtPoint.NodePositionY))
{
smtPoint.NodePositionY = APoint.NodePositionY;
}
}
if (smtPoint.NodePositionX <= 0)
{
smtPoint.NodePositionX = 1;
}
else if (smtPoint.NodePositionX > FrmProjectorScreen.instance.BoundsWidth)
{
smtPoint.NodePositionX = FrmProjectorScreen.instance.BoundsWidth;
}
if (smtPoint.NodePositionY <= 0)
{
smtPoint.NodePositionY = 1;
}
else if (smtPoint.NodePositionY > FrmProjectorScreen.instance.BoundsHeight)
{
smtPoint.NodePositionY = FrmProjectorScreen.instance.BoundsHeight;
}
if (smtPoint.PointSizeX < 1 || smtPoint.PointSizeX > 255)
{
smtPoint.PointSizeX = Setting_NInit.Device_DefaultPointSize;
}
if (smtPoint.PointSizeY < 1 || smtPoint.PointSizeY > 255)
{
smtPoint.PointSizeY = Setting_NInit.Device_DefaultPointSize;
}
double xXishu = (BPoint.NodePositionX - APoint.NodePositionX) / (BPoint.PositionX - APoint.PositionX);
double yXishu = (BPoint.NodePositionY - APoint.NodePositionY) / (BPoint.PositionY - APoint.PositionY);
//计算点大小
if (smtPoint.imgP.uTime > smtPoint.pUTime)
{
smtPoint.PointSizeX = (int)((BPoint.NodePositionX - APoint.NodePositionX) * smtPoint.imgP.SizeX / (BPoint.PositionX - APoint.PositionX));
smtPoint.PointSizeY = (int)((BPoint.NodePositionY - APoint.NodePositionY) * smtPoint.imgP.SizeY / (BPoint.PositionY - APoint.PositionY));
smtPoint.PenWidth = (int)((BPoint.NodePositionX - APoint.NodePositionX) * smtPoint.imgP.PWidth / (BPoint.PositionX - APoint.PositionX));
}
//smtPoint.PointSize = 4;
//smtPoint.NodePositionX = BPoint.NodePositionX - (BPoint.NodePositionX - APoint.NodePositionX) * (BPoint.PositionX - smtPoint.PositionX) / (BPoint.PositionX - APoint.PositionX);
//smtPoint.NodePositionY = BPoint.NodePositionY - (BPoint.NodePositionY - APoint.NodePositionY) * (BPoint.PositionY - smtPoint.PositionY) / (BPoint.PositionY - APoint.PositionY);
LogUtil.info($" 【{smtPoint.PN}】图片坐标【{smtPoint.PositionX},{smtPoint.PositionY}】旧坐标【{oldX},{oldY}】新坐标【{smtPoint.NodePositionX},{smtPoint.NodePositionY}】" +
$"点尺寸({smtPoint.PointSizeX},{smtPoint.PointSizeY}),画笔宽{smtPoint.PenWidth}");
return smtPoint;
}
catch (Exception ex)
{
LogUtil.error(" 【" + smtPoint.PN + "】图片坐标【" + smtPoint.PositionX + "," + smtPoint.PositionY + "】校准坐标出错:" + ex.ToString());
}
return smtPoint;
}
private SMTPointInfo GetPoint(SMTPointInfo smtPoint, List<SMTPointInfo> checkOKList)
{
SMTPointInfo p = null;
double maxPingFang = 0;
foreach (SMTPointInfo sm in checkOKList)
{
if (sm.pointNum.Equals(smtPoint.pointNum))
{
continue;
}
double xjuli = sm.PositionX - smtPoint.PositionX;
double yjuli = sm.PositionY - smtPoint.PositionY;
double cping = xjuli * xjuli + yjuli * yjuli;
if (cping > maxPingFang)
{
p = sm;
maxPingFang = cping;
continue;
}
}
if (p != null)
{
return p;
}
return null;
}
}
public class ConBaseInfo
{
public ConBaseInfo()
{
}
public ConBaseInfo(Point point1,Point point2)
{
this.IPoint = point1;
this.Point = point2;
}
/// <summary>
/// 板子实际坐标
/// </summary>
public Point IPoint = new Point();
/// <summary>
/// 投影对应坐标
/// </summary>
public Point Point = new Point();
}
}
......@@ -78,8 +78,8 @@ namespace TSA_V
TSAVBean.Y_Max = BoundsHeight;
TSAVBean.X_Min = 1;
TSAVBean.Y_Min = 1;
ProjectorControl.MaxX = (int)TSAVBean.X_Max;
ProjectorControl.MaxY = (int)TSAVBean.Y_Max;
//ProjectorControl.MaxX = (int)TSAVBean.X_Max;
//ProjectorControl.MaxY = (int)TSAVBean.Y_Max;
ISShow = true;
this.Location = new Point(screen.Bounds.Left, screen.Bounds.Top);
......@@ -489,7 +489,7 @@ namespace TSA_V
}
Graphics g = panel1.CreateGraphics();
Color pColor = Color.FromArgb(p.showColor);
DrawPoint(pColor, g, p.PX, p.PY, p.PType,p.PolaritiesType, p.SizeX, p.SizeY, p.PenWidth, p.ShowText);
DrawPoint(pColor, g, (int)p.PX, (int)p.PY, p.PType,p.PolaritiesType, p.SizeX, p.SizeY, p.PenWidth, p.ShowText);
g.Dispose();
}
public void ShowPoint(bool showName,int rgbColor, params SMTPointInfo[] points)
......
......@@ -77,23 +77,7 @@ namespace TSA_V
picBoard.Height = picBoard.Image.Height;
}
else
{
//int xishu = 100;
//picBoard.Width = width * xishu;
//picBoard.Height = height * xishu;
//if (picBoard.Width > panBoard.Width)
//{
// picBoard.Height = height * xishu * panBoard.Width / (width * xishu);
// picBoard.Width = panBoard.Width;
//}
//if (picBoard.Height > (panBoard.Height - 10))
//{
// picBoard.Width = width * xishu * (panBoard.Height - 10) / (height * xishu);
// picBoard.Height = (panBoard.Height - 10);
//}
//picBoard.Width = (int)(picBoard.Width * CurrBeiLu);
//picBoard.Height = (int)(picBoard.Height * CurrBeiLu);
{
SetPicSize();
}
......@@ -225,6 +209,55 @@ namespace TSA_V
{
LogUtil.error("画图出错:" + ex.ToString());
}
}
public void DrawEditPoint(int width, int height, SMTPointInfo point,Color color)
{
//this.PointList = pointList;
Width = width;
Height = height;
CurrBeiLu = 1;
//picBoard.SizeMode = PictureBoxSizeMode.AutoSize;
//if (pointList == null)
//{
// return;
//}
if (!ImageNormal)
{
picBoard.Width = picBoard.Image.Width;
picBoard.Height = picBoard.Image.Height;
}
else
{
SetPicSize();
}
//显示点
picBoard.Refresh();
//panBoard.Refresh();
imageXiShu = (float)picBoard.Width / (float)width;
Graphics grfx = picBoard.CreateGraphics();
//float preX = 0;
//float preY = 0;
int index = 0;
Brush brushes = Brushes.HotPink;
ProjectorPInfo p = point.GetShowPInfo(imageXiShu);
DrawPointManager.DrawPoint(grfx, p, color);
//写字
if (index.Equals(selectIndex) || ShowName)
{
grfx.DrawString(point.GetDisplayStr(), new Font("Arial ", 9, FontStyle.Bold), brushes, p.SizeX - p.PenWidth / 2 + 2, p.SizeY + p.PenWidth / 2 + 2);
}
index++;
grfx.SmoothingMode = SmoothingMode.HighQuality;
grfx.Dispose();
}
}
}
......
20240304 增加
20240401
新分支,修改离线编程。
20240304 增加
<add key ="Device_AutoGuoBan" value ="1 "/>
默认进入过板模式。
......
......@@ -14,14 +14,25 @@ namespace UserFromControl
{
public partial class ProjectorControl : UserControl
{
public static int MaxX = 1920;
public static int MaxY = 1280;
public static Dictionary<int,int> LastStepIndexMap=null;
public int ConType = 0;//坐标类型,0=投影,1=mm/离线编程
public int MaxX = 1920;
public int MaxY = 1280;
public double X_ChangeValue = 1;
public double Y_ChangeValue = 1;
public delegate bool ShowPointDelegate(ProjectorPInfo p);
public event ShowPointDelegate ShowPointEvent;
public ProjectorControl()
{
{
InitializeComponent();
cmbStep.SelectedIndex = TSAVBean.LastStepIndex;
if (LastStepIndexMap == null)
{
LastStepIndexMap = new Dictionary<int, int>();
LastStepIndexMap.Add(0, 1);
LastStepIndexMap.Add(1, 0);
}
cmbStep.SelectedIndex = LastStepIndexMap[ConType];
if (cmbType.SelectedIndex < 0)
{
cmbType.SelectedIndex = 0;
......@@ -88,8 +99,8 @@ namespace UserFromControl
}
public ProjectorPInfo GetPInfo()
{
int px = FormUtil.GetIntValue(numX);
int py = FormUtil.GetIntValue(numY);
double px = (double)(numX.Value);
double py = (double)(numY.Value);
int pointType = cmbType.SelectedIndex + 1;
int sizeX = FormUtil.GetIntValue(numSizeX);
int sizeY = FormUtil.GetIntValue(numSizeY);
......@@ -99,12 +110,12 @@ namespace UserFromControl
////如果亮度和大小超过范围,直接用默认值
//if (sizeX < 1 || sizeX > 255)
//{
// sizeX = TSAVBean.DefaultPSize;
// sizeX = DefaultPSize;
// numSizeX.Text = sizeX.ToString();
//}
//if (sizeY < 1 || sizeY > 255)
//{
// sizeY = TSAVBean.DefaultPSize;
// sizeY = DefaultPSize;
// numSizeY.Text = sizeY.ToString();
//}
ProjectorPInfo p = new ProjectorPInfo(px, py, pointType,ptype, sizeX, sizeY, penWidth,name, ShowColor);
......@@ -112,20 +123,18 @@ namespace UserFromControl
}
public void ShowCurrPoint()
{
this.Cursor = Cursors.WaitCursor;
this.Cursor = Cursors.WaitCursor;
ShowPointEvent?.Invoke(GetPInfo());
this.Cursor = Cursors.Default;
}
private void btnUp_Click(object sender, EventArgs e)
{
int stepValue = (int)(GetStepValue() * TSAVBean.Y_ChangeValue);
int targetValue = FormUtil.GetIntValue(numY) - stepValue;
if (targetValue >= 0 )
double stepValue = (double)(GetStepValue() * Y_ChangeValue);
double targetValue = (double)(numY.Value) - stepValue;
if (targetValue >=(double) numY.Minimum )
{
numY.Text = targetValue.ToString();
numY.Value =(decimal) targetValue ;
ShowCurrPoint();
}
else
......@@ -137,11 +146,11 @@ namespace UserFromControl
private void btnLeft_Click(object sender, EventArgs e)
{
int stepValue = (int)(GetStepValue() * TSAVBean.X_ChangeValue);
int targetValue = FormUtil.GetIntValue(numX) - stepValue;
if (targetValue >= 0 )
double stepValue = (double)(GetStepValue() * X_ChangeValue);
double targetValue = (double)(numX.Value) - stepValue;
if (targetValue >=(double) numX.Minimum )
{
numX.Text = targetValue.ToString();
numX.Value = (decimal)targetValue;
ShowCurrPoint();
}
else
......@@ -153,12 +162,12 @@ namespace UserFromControl
private void btnRight_Click(object sender, EventArgs e)
{
int stepValue = (int)(GetStepValue() * TSAVBean.X_ChangeValue);
double stepValue = (double)(GetStepValue() * X_ChangeValue);
int targetValue = FormUtil.GetIntValue(numX) + stepValue;
if ( targetValue <= MaxX)
double targetValue =(double)numX.Value+ stepValue;
if ( targetValue <=(double)numX.Maximum)
{
numX.Text = targetValue .ToString();
numX.Value = (decimal)targetValue;
ShowCurrPoint();
}
else
......@@ -169,12 +178,12 @@ namespace UserFromControl
}
private void btnDown_Click(object sender, EventArgs e)
{
int stepValue = (int)(GetStepValue() * TSAVBean.Y_ChangeValue);
int targetValue = FormUtil.GetIntValue(numY) + stepValue;
if ( targetValue <= MaxY)
{
double stepValue = (double)(GetStepValue() * Y_ChangeValue);
double targetValue = (double)(numY.Value) + stepValue;
if ( targetValue <= (double)numY.Maximum)
{
numY.Text = targetValue .ToString();
numY.Value = (decimal)targetValue;
ShowCurrPoint();
}
else
......@@ -193,45 +202,7 @@ namespace UserFromControl
}
if (!(cmbType.SelectedIndex + 1).Equals(lastType))
{
lastType = cmbType.SelectedIndex + 1;
//if (lastType >= 9 && lastType <= 10)
//{
// if (numSizeX.Value <= 6)
// {
// numSizeX.Value = 6;
// }
// if (numSizeX.Value == numSizeY.Value * 2)
// {
// }
// else if (numSizeY.Value * 2 > numSizeX.Value && numSizeX.Value < 15)
// {
// numSizeX.Value = numSizeY.Value * 2;
// }
// else
// {
// numSizeY.Value = numSizeX.Value / 2;
// }
//}
//else if( (lastType >= 7 && lastType <= 8)|| (lastType >= 11 && lastType <= 14))
//{
// if (numSizeX.Value <= 3)
// {
// numSizeX.Value = 3;
// }
// if(numSizeY.Value== numSizeX.Value * 2)
// {
// }
// else if (numSizeX.Value * 2 > numSizeY.Value &&numSizeY.Value<15)
// {
// numSizeY.Value = numSizeX.Value * 2;
// }
// else
// {
// numSizeX.Value = numSizeY.Value / 2;
// }
//}
lastType = cmbType.SelectedIndex + 1;
DrawPoint(lastType,lastPolaritiesType);
ShowCurrPoint();
......@@ -243,11 +214,11 @@ namespace UserFromControl
{
set
{
numX.Text = ((int)value).ToString();
numX.Text = (value).ToString();
}
get
{
return FormUtil.GetIntValue(numX);
return (double)numX.Value;
}
}
......@@ -255,11 +226,11 @@ namespace UserFromControl
{
set
{
numY.Text = ((int)value).ToString();
numY.Text = (value).ToString();
}
get
{
return FormUtil.GetIntValue(numY);
return (double)numY.Value;
}
}
public int PointType
......@@ -361,8 +332,8 @@ namespace UserFromControl
private double GetStepValue()
{
int index = cmbStep.SelectedIndex;
TSAVBean.LastStepIndex = index;
int index = cmbStep.SelectedIndex;
LastStepIndexMap[ConType]= index;
if (vallue.Count > index)
{
return vallue[index];
......@@ -370,12 +341,41 @@ namespace UserFromControl
return 10;
}
private List<string> typeList = new List<string>();
private void GalvanometerControl_Load(object sender, EventArgs e)
{
private void ProjectorControl_Load(object sender, EventArgs e)
{
if (cmbType.SelectedIndex < 0)
{
cmbType.SelectedIndex = 0;
}
numSizeX.Maximum = MaxX / 2;
numSizeY.Maximum = MaxY / 2;
cmbStep.SelectedIndex = LastStepIndexMap[ConType];
//重新设置步进值
if (ConType == 1)
{
this.cmbStep.Items.Clear();
this.cmbStep.Items.AddRange(new object[] {
"0.1",
"0.2",
"0.5",
"1",
"2",
"5",
"10",
"20",
"50",
"100"});
numX.DecimalPlaces = 3;
numY.DecimalPlaces = 3;
vallue = new List<double>() { 0.1, 0.2, 0.51, 2, 5, 10, 20, 50, 100 };
}
else
{
numX.DecimalPlaces = 0;
numY.DecimalPlaces = 0;
}
cmbStep.SelectedIndex = LastStepIndexMap[ConType];
}
private void DrawPoint(int type,int polaritiesType , int x=0, int y=0, int sizeX = 2, int sizeY = 2 ,int lineLength=2 )
{
......@@ -633,7 +633,8 @@ namespace UserFromControl
}
private void group_Paint(object sender, PaintEventArgs e)
{
{
return;
DrawPoint(lastType, lastPolaritiesType);
ShowCurrPoint();
}
......@@ -648,5 +649,14 @@ namespace UserFromControl
ShowCurrPoint();
}
}
public void SetPointType(int pointType, int pointSizeX, int pointSizeY, int penWidth, int polaritiesType)
{
this.PointType = pointType;
this.PointSizeX = pointSizeX;
this.PointSizeY = pointSizeY;
this.PenWidth = penWidth;
this.PolaritiesType = polaritiesType;
}
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!