Commit 9a3dfd31 刘韬

1

1 个父辈 ff9fa881
......@@ -4,6 +4,7 @@ using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
using TSA_V.Common;
......@@ -148,6 +149,12 @@ namespace TSA_V.LoadCSVLibrary
{
value = "0";
}
if (proName == "PositionX" || proName == "PositionY") {
value = Regex.Match(value, @"\d+\.\d+|\d+").Value;
if (value == "")
value = "0";
}
//如果属性存在
prop.SetValue(bllIns, Convert.ChangeType(value, prop.PropertyType), null);//赋值****在这里需要考虑类型问题
}
......@@ -156,12 +163,7 @@ namespace TSA_V.LoadCSVLibrary
}
ComponetInfo com = (ComponetInfo)bllIns;
com.Id = index + 1;
com.PositionNum = GetPositionNum(com.PositionNum);
if (String.IsNullOrEmpty(com.PositionNum) || String.IsNullOrEmpty(com.PN))
{
LOGGER.Error("读取csv,index=" + index + ",数据不完整,跳过数据,line=" + line);
continue;
}
comList.Add(com);
}
else
......@@ -177,6 +179,46 @@ namespace TSA_V.LoadCSVLibrary
index++;
}
Dictionary<string, string> pnposlist = new Dictionary<string, string>();
HashSet<string> usedposlist = new HashSet<string>();
foreach (var com in comList) {
if (string.IsNullOrWhiteSpace(com.PositionNum))
continue;
com.PositionNum = GetPositionNum(com.PositionNum);
if (!string.IsNullOrEmpty(com.PositionNum))
{
usedposlist.Add(com.PositionNum);
pnposlist[com.PN] = com.PositionNum;
}
}
foreach (var com in comList) {
if (string.IsNullOrWhiteSpace(com.PositionNum) && !string.IsNullOrWhiteSpace(com.PN))
{
if (pnposlist.ContainsKey(com.PN))
com.PositionNum = pnposlist[com.PN];
else
{
foreach (var p in CSVPositionReader<TSAVPosition>.allPositionMap)
{
if (usedposlist.Contains(p.Value.PositionNum))
continue;
com.PositionNum = p.Value.PositionNum;
pnposlist[com.PN] = com.PositionNum;
usedposlist.Add(com.PositionNum);
break;
}
}
}
//if (String.IsNullOrEmpty(com.PositionNum) || String.IsNullOrEmpty(com.PN))
//{
// LOGGER.Error("读取csv,数据不完整,跳过数据,line=" + com.TagNo);
// continue;
//}
}
return comList;
}
public static string GetPositionNum(string configPosition )
......@@ -188,6 +230,8 @@ namespace TSA_V.LoadCSVLibrary
}
return "";
}
public static bool UpdateComponet(string bomName, ComponetInfo com)
{
if (!allComMap.ContainsKey(bomName))
......
......@@ -104,7 +104,7 @@ namespace TSA_V
return false ;
}
board.LineWidth = FormUtil.GetIntValue(txtLineWidth);
if (board.LineWidth <= 0)
if (board.LineWidth <= 0 && !IOBase.NoLine)
{
MessageBox.Show(ResourceCulture.GetString(ResourceCulture.WriteLineWidth, "请输入线体宽度!"));
this.txtLineWidth.Focus();
......@@ -369,8 +369,9 @@ namespace TSA_V
private void btnOpenFile_Click(object sender, LinkLabelLinkClickedEventArgs e)
{
openFileDialogImg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
openFileDialogImg.DefaultExt = "jpg|gif|bmp|png|jpeg";
openFileDialogImg.Filter = "jpg|*.jpg|gif|*.gif|bmp|*.bmp|png|*.png|jpeg|*.jpeg";
//openFileDialogImg.DefaultExt = "jpg|gif|bmp|png|jpeg";
//openFileDialogImg.Filter = "jpg|*.jpg|gif|*.gif|bmp|*.bmp|png|*.png|jpeg|*.jpeg";
openFileDialogImg.Filter = "Image Files|*.bmp;*.jpg;*.gif;*.png;*jpeg";
string directory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);//桌面路径
openFileDialogImg.InitialDirectory = directory;
if (openFileDialogImg.ShowDialog() == DialogResult.OK)
......
......@@ -603,12 +603,15 @@ namespace TSA_V
txtBoardL.Focus();
return;
}
if (board.LineWidth <= 0)
if (!IOBase.NoLine && board.LineWidth <= 0)
{
MessageBox.Show(ResourceCulture.GetString(ResourceCulture.WriteLineWidth, "请输入线体宽度"));
txtLineWidth.Focus();
return;
}
else
board.LineWidth = 1;
if (picBoard.Image == null)
{
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!