Commit 471dbe78 几米阳光

增加程序导入导出功能

1 个父辈 68fc4aca
...@@ -64,72 +64,34 @@ namespace URSoldering.DeviceLibrary ...@@ -64,72 +64,34 @@ namespace URSoldering.DeviceLibrary
boardList = new List<BoardInfo>(); boardList = new List<BoardInfo>();
List<int> idList = new List<int>(); List<int> idList = new List<int>();
List<string> nameList = new List<string>(); List<string> nameList = new List<string>();
foreach (string str in lines) foreach (string str in lines)
{ {
try bool IsNeedUpdate = false;
{ BoardInfo board = StringToBoard(str, out IsNeedUpdate);
string newStr = str; if (board != null)
string errMsg="\"System.Drawing.Bitmap\""; {
if (str.Contains(errMsg)) if (idList.Contains(board.boardId))
{ {
newStr = str.Replace(errMsg, "null"); LogUtil.error("加载产品配置出错:id=" + board.boardId + "的数据重复!");
} }
BoardInfo board = JsonHelper.DeserializeJsonToObject<BoardInfo>(newStr); if (nameList.Contains(board.boardName))
bool isUpdate = false; {
if (board != null) LogUtil.error("加载产品配置出错:name=" + board.boardName + "的数据重复!");
{ }
if (board.boardId > MaxId) idList.Add(board.boardId);
{ nameList.Add(board.boardName);
MaxId = board.boardId; if (board.boardId.Equals(CurrBoardId))
} {
if (idList.Contains(board.boardId)) LogUtil.info("加载产品配置:name=" + board.boardName + "为启动时的默认板子!");
{ CurrBoard = board;
LogUtil.error("加载产品配置出错:id=" + board.boardId + "的数据重复!"); }
} boardList.Add(board);
if (nameList.Contains(board.boardName)) if (IsNeedUpdate)
{ {
LogUtil.error("加载产品配置出错:name=" + board.boardName + "的数据重复!"); SaveListToFile(boardList);
} }
//如果料号是空,用产品名称作为料号 }
if(board.PartNumber==null){ }
board.PartNumber = board.boardName;
isUpdate = true;
}
if (board.WareCode == null)
{
board.WareCode = "";
}
if (board.APointValue == null)
{
board.APointValue = new URPointValue();
board.BPointValue = new URPointValue();
board.CPointValue = new URPointValue();
board.DPointValue = new URPointValue();
isUpdate = true;
}
idList.Add(board.boardId);
nameList.Add(board.boardName);
if (board.boardId.Equals(CurrBoardId))
{
LogUtil.info("加载产品配置:name=" + board.boardName + "为启动时的默认板子!");
CurrBoard = board;
}
//if (board.orgType == 0)
//{
// board.orgType = 1;
//}
boardList.Add(board);
}
if (isUpdate)
{
SaveListToFile(boardList);
}
}
catch (Exception ex)
{
LogUtil.error("出错:" + ex.ToString());
}
}
string path = ConfigAppSettings.GetValue(Setting_Init.BOARD_IMAGE_PATH); string path = ConfigAppSettings.GetValue(Setting_Init.BOARD_IMAGE_PATH);
string imagePath = Application.StartupPath + "/" + path + "/" + ConfigAppSettings.GetValue(Setting_Init.BOARD_IMAGE_DEFAULT); string imagePath = Application.StartupPath + "/" + path + "/" + ConfigAppSettings.GetValue(Setting_Init.BOARD_IMAGE_DEFAULT);
...@@ -160,6 +122,53 @@ namespace URSoldering.DeviceLibrary ...@@ -160,6 +122,53 @@ namespace URSoldering.DeviceLibrary
} }
} }
public static BoardInfo StringToBoard(string str, out bool IsNeedUpdate)
{
IsNeedUpdate = false;
BoardInfo board = null;
try
{
string newStr = str;
string errMsg = "\"System.Drawing.Bitmap\"";
if (str.Contains(errMsg))
{
newStr = str.Replace(errMsg, "null");
}
board = JsonHelper.DeserializeJsonToObject<BoardInfo>(newStr);
// bool isUpdate = false;
if (board != null)
{
if (board.boardId > MaxId)
{
MaxId = board.boardId;
}
//如果料号是空,用产品名称作为料号
if (board.PartNumber == null)
{
board.PartNumber = board.boardName;
IsNeedUpdate = true;
}
if (board.WareCode == null)
{
board.WareCode = "";
}
if (board.APointValue == null)
{
board.APointValue = new URPointValue();
board.BPointValue = new URPointValue();
board.CPointValue = new URPointValue();
board.DPointValue = new URPointValue();
IsNeedUpdate = true;
}
}
}
catch (Exception ex)
{
LogUtil.error("出错:" + ex.ToString());
}
return board;
}
public static void Update(BoardInfo board) public static void Update(BoardInfo board)
{ {
int index = 0; int index = 0;
......
...@@ -50,6 +50,8 @@ ...@@ -50,6 +50,8 @@
this.txtBoardName = new System.Windows.Forms.TextBox(); this.txtBoardName = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label();
this.groupBox1 = new System.Windows.Forms.GroupBox(); this.groupBox1 = new System.Windows.Forms.GroupBox();
this.btnExport = new System.Windows.Forms.Button();
this.btnImport = new System.Windows.Forms.Button();
this.btnCopy = new System.Windows.Forms.Button(); this.btnCopy = new System.Windows.Forms.Button();
this.btnBack = new System.Windows.Forms.Button(); this.btnBack = new System.Windows.Forms.Button();
this.btnDel = new System.Windows.Forms.Button(); this.btnDel = new System.Windows.Forms.Button();
...@@ -57,6 +59,7 @@ ...@@ -57,6 +59,7 @@
this.btnNew = new System.Windows.Forms.Button(); this.btnNew = new System.Windows.Forms.Button();
this.cmbBoardList = new System.Windows.Forms.ComboBox(); this.cmbBoardList = new System.Windows.Forms.ComboBox();
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
this.panel1.SuspendLayout(); this.panel1.SuspendLayout();
this.groupBox2.SuspendLayout(); this.groupBox2.SuspendLayout();
this.panBoard.SuspendLayout(); this.panBoard.SuspendLayout();
...@@ -72,7 +75,7 @@ ...@@ -72,7 +75,7 @@
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel1.Location = new System.Drawing.Point(0, 0); this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1"; this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(1012, 626); this.panel1.Size = new System.Drawing.Size(1220, 626);
this.panel1.TabIndex = 2; this.panel1.TabIndex = 2;
// //
// groupBox2 // groupBox2
...@@ -101,7 +104,7 @@ ...@@ -101,7 +104,7 @@
this.groupBox2.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.groupBox2.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupBox2.Location = new System.Drawing.Point(12, 71); this.groupBox2.Location = new System.Drawing.Point(12, 71);
this.groupBox2.Name = "groupBox2"; this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(997, 541); this.groupBox2.Size = new System.Drawing.Size(1205, 541);
this.groupBox2.TabIndex = 1; this.groupBox2.TabIndex = 1;
this.groupBox2.TabStop = false; this.groupBox2.TabStop = false;
this.groupBox2.Text = "程序信息"; this.groupBox2.Text = "程序信息";
...@@ -184,7 +187,7 @@ ...@@ -184,7 +187,7 @@
this.label6.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) this.label6.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.label6.AutoSize = true; this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(-1269, 23); this.label6.Location = new System.Drawing.Point(-1061, 23);
this.label6.Name = "label6"; this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(68, 17); this.label6.Size = new System.Drawing.Size(68, 17);
this.label6.TabIndex = 33; this.label6.TabIndex = 33;
...@@ -199,7 +202,7 @@ ...@@ -199,7 +202,7 @@
this.panBoard.Controls.Add(this.picBoard); this.panBoard.Controls.Add(this.picBoard);
this.panBoard.Location = new System.Drawing.Point(601, 21); this.panBoard.Location = new System.Drawing.Point(601, 21);
this.panBoard.Name = "panBoard"; this.panBoard.Name = "panBoard";
this.panBoard.Size = new System.Drawing.Size(389, 502); this.panBoard.Size = new System.Drawing.Size(597, 502);
this.panBoard.TabIndex = 10; this.panBoard.TabIndex = 10;
// //
// picBoard // picBoard
...@@ -210,7 +213,7 @@ ...@@ -210,7 +213,7 @@
this.picBoard.BackColor = System.Drawing.Color.Green; this.picBoard.BackColor = System.Drawing.Color.Green;
this.picBoard.Location = new System.Drawing.Point(3, 3); this.picBoard.Location = new System.Drawing.Point(3, 3);
this.picBoard.Name = "picBoard"; this.picBoard.Name = "picBoard";
this.picBoard.Size = new System.Drawing.Size(316, 225); this.picBoard.Size = new System.Drawing.Size(524, 225);
this.picBoard.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; this.picBoard.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.picBoard.TabIndex = 10; this.picBoard.TabIndex = 10;
this.picBoard.TabStop = false; this.picBoard.TabStop = false;
...@@ -287,6 +290,8 @@ ...@@ -287,6 +290,8 @@
// //
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.groupBox1.Controls.Add(this.btnExport);
this.groupBox1.Controls.Add(this.btnImport);
this.groupBox1.Controls.Add(this.btnCopy); this.groupBox1.Controls.Add(this.btnCopy);
this.groupBox1.Controls.Add(this.btnBack); this.groupBox1.Controls.Add(this.btnBack);
this.groupBox1.Controls.Add(this.btnDel); this.groupBox1.Controls.Add(this.btnDel);
...@@ -297,14 +302,34 @@ ...@@ -297,14 +302,34 @@
this.groupBox1.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.groupBox1.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupBox1.Location = new System.Drawing.Point(12, 5); this.groupBox1.Location = new System.Drawing.Point(12, 5);
this.groupBox1.Name = "groupBox1"; this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(998, 60); this.groupBox1.Size = new System.Drawing.Size(1206, 60);
this.groupBox1.TabIndex = 0; this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false; this.groupBox1.TabStop = false;
this.groupBox1.Text = "程序管理"; this.groupBox1.Text = "程序管理";
// //
// btnExport
//
this.btnExport.Location = new System.Drawing.Point(926, 16);
this.btnExport.Name = "btnExport";
this.btnExport.Size = new System.Drawing.Size(117, 35);
this.btnExport.TabIndex = 9;
this.btnExport.Text = "导出";
this.btnExport.UseVisualStyleBackColor = true;
this.btnExport.Click += new System.EventHandler(this.btnExport_Click);
//
// btnImport
//
this.btnImport.Location = new System.Drawing.Point(803, 16);
this.btnImport.Name = "btnImport";
this.btnImport.Size = new System.Drawing.Size(117, 35);
this.btnImport.TabIndex = 8;
this.btnImport.Text = "导入";
this.btnImport.UseVisualStyleBackColor = true;
this.btnImport.Click += new System.EventHandler(this.btnImport_Click);
//
// btnCopy // btnCopy
// //
this.btnCopy.Location = new System.Drawing.Point(694, 16); this.btnCopy.Location = new System.Drawing.Point(680, 16);
this.btnCopy.Name = "btnCopy"; this.btnCopy.Name = "btnCopy";
this.btnCopy.Size = new System.Drawing.Size(117, 35); this.btnCopy.Size = new System.Drawing.Size(117, 35);
this.btnCopy.TabIndex = 7; this.btnCopy.TabIndex = 7;
...@@ -315,7 +340,7 @@ ...@@ -315,7 +340,7 @@
// btnBack // btnBack
// //
this.btnBack.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.btnBack.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnBack.Location = new System.Drawing.Point(865, 15); this.btnBack.Location = new System.Drawing.Point(1073, 16);
this.btnBack.Name = "btnBack"; this.btnBack.Name = "btnBack";
this.btnBack.Size = new System.Drawing.Size(117, 35); this.btnBack.Size = new System.Drawing.Size(117, 35);
this.btnBack.TabIndex = 6; this.btnBack.TabIndex = 6;
...@@ -325,7 +350,7 @@ ...@@ -325,7 +350,7 @@
// //
// btnDel // btnDel
// //
this.btnDel.Location = new System.Drawing.Point(570, 16); this.btnDel.Location = new System.Drawing.Point(557, 16);
this.btnDel.Name = "btnDel"; this.btnDel.Name = "btnDel";
this.btnDel.Size = new System.Drawing.Size(117, 35); this.btnDel.Size = new System.Drawing.Size(117, 35);
this.btnDel.TabIndex = 5; this.btnDel.TabIndex = 5;
...@@ -335,7 +360,7 @@ ...@@ -335,7 +360,7 @@
// //
// btnSave // btnSave
// //
this.btnSave.Location = new System.Drawing.Point(446, 16); this.btnSave.Location = new System.Drawing.Point(434, 16);
this.btnSave.Name = "btnSave"; this.btnSave.Name = "btnSave";
this.btnSave.Size = new System.Drawing.Size(117, 35); this.btnSave.Size = new System.Drawing.Size(117, 35);
this.btnSave.TabIndex = 4; this.btnSave.TabIndex = 4;
...@@ -345,7 +370,7 @@ ...@@ -345,7 +370,7 @@
// //
// btnNew // btnNew
// //
this.btnNew.Location = new System.Drawing.Point(322, 16); this.btnNew.Location = new System.Drawing.Point(311, 16);
this.btnNew.Name = "btnNew"; this.btnNew.Name = "btnNew";
this.btnNew.Size = new System.Drawing.Size(117, 35); this.btnNew.Size = new System.Drawing.Size(117, 35);
this.btnNew.TabIndex = 3; this.btnNew.TabIndex = 3;
...@@ -357,7 +382,7 @@ ...@@ -357,7 +382,7 @@
// //
this.cmbBoardList.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cmbBoardList.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbBoardList.FormattingEnabled = true; this.cmbBoardList.FormattingEnabled = true;
this.cmbBoardList.Location = new System.Drawing.Point(85, 22); this.cmbBoardList.Location = new System.Drawing.Point(77, 22);
this.cmbBoardList.Name = "cmbBoardList"; this.cmbBoardList.Name = "cmbBoardList";
this.cmbBoardList.Size = new System.Drawing.Size(207, 25); this.cmbBoardList.Size = new System.Drawing.Size(207, 25);
this.cmbBoardList.TabIndex = 1; this.cmbBoardList.TabIndex = 1;
...@@ -377,7 +402,7 @@ ...@@ -377,7 +402,7 @@
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.AutoSize = true; this.AutoSize = true;
this.ClientSize = new System.Drawing.Size(1012, 626); this.ClientSize = new System.Drawing.Size(1220, 626);
this.Controls.Add(this.panel1); this.Controls.Add(this.panel1);
this.Name = "FrmBoardList"; this.Name = "FrmBoardList";
this.Text = "程序配置"; this.Text = "程序配置";
...@@ -426,5 +451,8 @@ ...@@ -426,5 +451,8 @@
private System.Windows.Forms.Button btnCopy; private System.Windows.Forms.Button btnCopy;
private System.Windows.Forms.TextBox txtAOIName; private System.Windows.Forms.TextBox txtAOIName;
private System.Windows.Forms.Label label10; private System.Windows.Forms.Label label10;
private System.Windows.Forms.Button btnExport;
private System.Windows.Forms.Button btnImport;
private System.Windows.Forms.OpenFileDialog openFileDialog1;
} }
} }
\ No newline at end of file \ No newline at end of file
...@@ -9,6 +9,8 @@ using System.Reflection; ...@@ -9,6 +9,8 @@ using System.Reflection;
using System.Windows.Forms; using System.Windows.Forms;
using URSoldering.Common; using URSoldering.Common;
using System.Drawing.Drawing2D; using System.Drawing.Drawing2D;
using System.IO;
using System.Text;
namespace URSoldering.Client namespace URSoldering.Client
{ {
...@@ -21,13 +23,13 @@ namespace URSoldering.Client ...@@ -21,13 +23,13 @@ namespace URSoldering.Client
} }
private void FrmBoard_Load(object sender, EventArgs e) private void FrmBoard_Load(object sender, EventArgs e)
{ {
LoadCom(); LoadCom();
} }
private void AddColumn(string text,int width) private void AddColumn(string text, int width)
{ {
ColumnHeader chName = new ColumnHeader(); ColumnHeader chName = new ColumnHeader();
chName.Text =text ; //设置列标题 chName.Text = text; //设置列标题
chName.Width = width; //设置列宽度 chName.Width = width; //设置列宽度
chName.TextAlign = HorizontalAlignment.Left; //设置列的对齐方式 chName.TextAlign = HorizontalAlignment.Left; //设置列的对齐方式
this.listPoint.Columns.Add(chName); //将列头添加到ListView控件。 this.listPoint.Columns.Add(chName); //将列头添加到ListView控件。
...@@ -49,7 +51,7 @@ namespace URSoldering.Client ...@@ -49,7 +51,7 @@ namespace URSoldering.Client
AddColumn("预热温度", 90); AddColumn("预热温度", 90);
AddColumn("焊接温度", 90); AddColumn("焊接温度", 90);
AddColumn("初始送丝", 90); AddColumn("初始送丝", 90);
AddColumn("送丝量", 80); AddColumn("送丝量", 80);
} }
private void btnSave_Click(object sender, EventArgs e) private void btnSave_Click(object sender, EventArgs e)
{ {
...@@ -98,6 +100,9 @@ namespace URSoldering.Client ...@@ -98,6 +100,9 @@ namespace URSoldering.Client
} }
} }
int preId = -1; int preId = -1;
public object ResourceCulture { get; private set; }
private void LoadPoint(BoardInfo board) private void LoadPoint(BoardInfo board)
{ {
if (preId >= 0 && preId.Equals(board.boardId)) if (preId >= 0 && preId.Equals(board.boardId))
...@@ -114,10 +119,10 @@ namespace URSoldering.Client ...@@ -114,10 +119,10 @@ namespace URSoldering.Client
lvi.Text = point.pointName; lvi.Text = point.pointName;
lvi.SubItems.Add(point.TypeValue); lvi.SubItems.Add(point.TypeValue);
lvi.SubItems.Add(point.preheatTemperature.ToString()+ "°C"); lvi.SubItems.Add(point.preheatTemperature.ToString() + "°C");
lvi.SubItems.Add(point.weldTemperature.ToString() + "°C"); lvi.SubItems.Add(point.weldTemperature.ToString() + "°C");
lvi.SubItems.Add((point.startSendWireSpeed * point.startSendWireTime).ToString()+"mm"); lvi.SubItems.Add((point.startSendWireSpeed * point.startSendWireTime).ToString() + "mm");
lvi.SubItems.Add((point.sendWireTime * point.sendWireSpeed).ToString()+"mm"); lvi.SubItems.Add((point.sendWireTime * point.sendWireSpeed).ToString() + "mm");
this.listPoint.Items.Add(lvi); this.listPoint.Items.Add(lvi);
i++; i++;
} }
...@@ -145,7 +150,7 @@ namespace URSoldering.Client ...@@ -145,7 +150,7 @@ namespace URSoldering.Client
if (cmbBoardList.Text != "" && cmbBoardList.SelectedIndex >= 0) if (cmbBoardList.Text != "" && cmbBoardList.SelectedIndex >= 0)
{ {
BoardInfo board = (BoardInfo)cmbBoardList.SelectedItem; BoardInfo board = (BoardInfo)cmbBoardList.SelectedItem;
if (MessageBox.Show("确认要删除程序【" + board.boardName + "】吗?", "删除确认", if (MessageBox.Show("确认要删除程序【" + board.boardName + "】吗?", "删除确认",
MessageBoxButtons.OKCancel, MessageBoxButtons.OKCancel,
MessageBoxIcon.Question).Equals(DialogResult.OK)) MessageBoxIcon.Question).Equals(DialogResult.OK))
...@@ -162,7 +167,7 @@ namespace URSoldering.Client ...@@ -162,7 +167,7 @@ namespace URSoldering.Client
MessageBox.Show("请选择程序!"); MessageBox.Show("请选择程序!");
} }
} }
private void GetPicPointByUrPoint(BoardInfo boardInfo ,URPointValue point, out float x, out float y) private void GetPicPointByUrPoint(BoardInfo boardInfo, URPointValue point, out float x, out float y)
{ {
int width = picBoard.Width; int width = picBoard.Width;
int height = picBoard.Height; int height = picBoard.Height;
...@@ -174,13 +179,13 @@ namespace URSoldering.Client ...@@ -174,13 +179,13 @@ namespace URSoldering.Client
//判断AD点是否有效 //判断AD点是否有效
if (APointValue.IsValid() && DPointValue.IsValid()) if (APointValue.IsValid() && DPointValue.IsValid())
{ {
x = (float)((point.X-APointValue.X) * width / (DPointValue.X - APointValue.X)); x = (float)((point.X - APointValue.X) * width / (DPointValue.X - APointValue.X));
y = (float)((point.Y-APointValue.Y) * height / (DPointValue.Y - APointValue.Y)); y = (float)((point.Y - APointValue.Y) * height / (DPointValue.Y - APointValue.Y));
} }
else if (BPointValue.IsValid() && CPointValue.IsValid()) else if (BPointValue.IsValid() && CPointValue.IsValid())
{ {
x = (float)((point.X-BPointValue.X) * width / (CPointValue.X - BPointValue.X)); x = (float)((point.X - BPointValue.X) * width / (CPointValue.X - BPointValue.X));
y = (float)((point.Y-CPointValue.Y) * height / (BPointValue.Y - CPointValue.Y)); y = (float)((point.Y - CPointValue.Y) * height / (BPointValue.Y - CPointValue.Y));
} }
else else
{ {
...@@ -221,7 +226,7 @@ namespace URSoldering.Client ...@@ -221,7 +226,7 @@ namespace URSoldering.Client
picBoard.Image = board.GetImage(); picBoard.Image = board.GetImage();
picBoard.Refresh(); picBoard.Refresh();
Graphics grfx = picBoard.CreateGraphics(); Graphics grfx = picBoard.CreateGraphics();
float preX = 0; float preX = 0;
float preY = 0; float preY = 0;
...@@ -230,7 +235,7 @@ namespace URSoldering.Client ...@@ -230,7 +235,7 @@ namespace URSoldering.Client
{ {
int pointHight = 16; int pointHight = 16;
float x, y; float x, y;
GetPicPointByUrPoint(board,weld.GetURPoint(), out x, out y); GetPicPointByUrPoint(board, weld.GetURPoint(), out x, out y);
LogUtil.debug("显示焊点:X【" + x + "】Y【" + y + "】,坐标X【" + weld.RobotX + "】坐标Y【" + weld.RobotY + "】"); LogUtil.debug("显示焊点:X【" + x + "】Y【" + y + "】,坐标X【" + weld.RobotX + "】坐标Y【" + weld.RobotY + "】");
g.FillEllipse(Brushes.Red, x - pointHight / 2, y - pointHight / 2, pointHight, pointHight); g.FillEllipse(Brushes.Red, x - pointHight / 2, y - pointHight / 2, pointHight, pointHight);
...@@ -247,7 +252,7 @@ namespace URSoldering.Client ...@@ -247,7 +252,7 @@ namespace URSoldering.Client
grfx.DrawLine(RedPen, preX, preY, xCenter, yCenter); grfx.DrawLine(RedPen, preX, preY, xCenter, yCenter);
grfx.DrawLine(p, preX, preY, x, y); grfx.DrawLine(p, preX, preY, x, y);
} }
//写字 //写字
g.DrawString(weld.pointName, new Font("Arial ", 10, FontStyle.Bold), Brushes.Red, x - pointHight / 2, y + pointHight / 2 + 2); g.DrawString(weld.pointName, new Font("Arial ", 10, FontStyle.Bold), Brushes.Red, x - pointHight / 2, y + pointHight / 2 + 2);
preX = x; preX = x;
...@@ -296,5 +301,78 @@ namespace URSoldering.Client ...@@ -296,5 +301,78 @@ namespace URSoldering.Client
} }
} }
private void btnExport_Click(object sender, EventArgs e)
{
if (cmbBoardList.Text != "" && cmbBoardList.SelectedIndex >= 0)
{
BoardInfo board = (BoardInfo)cmbBoardList.SelectedItem;
SaveFileDialog sfd = new SaveFileDialog();
sfd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
sfd.FileName = "程序-" + board.boardName + "-"+DateTime.Now.ToString("yyyy:MM:dd:HH:mm").Replace(":","");
sfd.Filter = @"data|*.data";
DialogResult result = sfd.ShowDialog();
if (result.Equals(DialogResult.OK))
{
string filePath = sfd.FileName;
{
if (File.Exists(filePath))
{
File.Delete(filePath);
}
File.WriteAllText(filePath, JsonHelper.SerializeObject(board), Encoding.GetEncoding("gbk"));
MessageBox.Show("成功导出程序【" + board.boardName + "】到文件:\r\n" + filePath, "提示");
}
}
}
}
private void btnImport_Click(object sender, EventArgs e)
{
openFileDialog1.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
openFileDialog1.Filter = @"data|*.data";
DialogResult result = this.openFileDialog1.ShowDialog();
if (result.Equals(DialogResult.OK))
{
string fileName = this.openFileDialog1.FileName;
string[] lines = File.ReadAllLines(fileName, Encoding.GetEncoding("gbk"));
if (lines.Length <= 0)
{
MessageBox.Show("解析程序失败,请选择正确文件", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
bool isNeedUpdate = false;
BoardInfo board = BoardManager.StringToBoard(lines[0],out isNeedUpdate);
if (board == null)
{
MessageBox.Show("解析程序失败,请选择正确文件", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (BoardManager.getBoardByName(board.boardName) != null)
{
MessageBox.Show("导入失败:程序名【" + board.boardName+"】已存在","提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
return;
}
string oldName = ConfigAppSettings.GetValue(Setting_Init.BOARD_IMAGE_DEFAULT);
string newName = board.boardName + Path.GetExtension(oldName);
string configPath = ConfigAppSettings.GetValue(Setting_Init.BOARD_IMAGE_PATH);
string oldPath = Application.StartupPath + "/" + configPath + "/" + oldName;
string newPath = Application.StartupPath + "/" + configPath + "/" + newName;
if (File.Exists(oldPath))
{
File.Copy(oldPath, newPath, true);
}
board.imgName = newName;
board.boardId = BoardManager.GetNextId();
BoardManager.Add(board);
MessageBox.Show("程序【" + board.boardName + "】导入成功","提示");
LoadCom();
preId = -1;
}
}
} }
} }
...@@ -117,7 +117,7 @@ ...@@ -117,7 +117,7 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="openFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>True</value> <value>17, 17</value>
</metadata> </metadata>
</root> </root>
\ No newline at end of file \ No newline at end of file
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!