|
@@ -14,7 +14,9 @@ namespace SpectrumSTDEditor
|
|
|
public Dictionary<int, STDdata> ReferenceDictionary = new Dictionary<int, STDdata>();
|
|
|
System.Collections.Hashtable table_ReferenceLibrary;
|
|
|
Dictionary<int, string> ReferenceGroup = new Dictionary<int, string>();
|
|
|
+ List<STDEditor.STDXray> ReferenceXrayList = null;
|
|
|
|
|
|
+ byte[] ReferencexrayByteData = null;
|
|
|
public ReferenceLibrary(SubMidWindow SubMidWindow)
|
|
|
{
|
|
|
InitializeComponent();
|
|
@@ -119,10 +121,30 @@ namespace SpectrumSTDEditor
|
|
|
new_STDdata.StrName = item["name"].ToString();
|
|
|
new_STDdata.Color = item["color"].ToString();
|
|
|
new_STDdata.ChineseName = item["chinesename"].ToString();
|
|
|
+ new_STDdata.XrayData = (byte[])item["SPEC"];
|
|
|
STDDictionary.Add(int.Parse(item["id"].ToString()), new_STDdata);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ //加载Xray信息
|
|
|
+ System.Data.SQLite.SQLiteDataAdapter m_dataAdapterXray = new System.Data.SQLite.SQLiteDataAdapter("select Id,SPEC from STDMinerals", m_dbConnection);
|
|
|
+ DataSet dsXray = new DataSet();
|
|
|
+ m_dataAdapterXray.Fill(dsXray);
|
|
|
+ DataTable dtXray = dsXray.Tables[0];
|
|
|
+ ReferenceXrayList = new List<STDEditor.STDXray>();
|
|
|
+ if (dtXray != null)
|
|
|
+ {
|
|
|
+ if (dtXray.Rows.Count > 0)
|
|
|
+ {
|
|
|
+ foreach (DataRow item in dtXray.Rows)
|
|
|
+ {
|
|
|
+ STDEditor.STDXray sXray = new STDEditor.STDXray();
|
|
|
+ sXray.StdID = item["Id"].ToString();
|
|
|
+ sXray.XrayData = (byte[])item["SPEC"];
|
|
|
+ ReferenceXrayList.Add(sXray);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
return true;
|
|
|
}
|
|
|
catch (Exception)
|
|
@@ -229,10 +251,14 @@ namespace SpectrumSTDEditor
|
|
|
if ((bool)PropGrid[PropGrid.Selection.ActivePosition.Row, 0].Value == true)
|
|
|
{
|
|
|
PropGrid[PropGrid.Selection.ActivePosition.Row, 0].Value = false;
|
|
|
+ m_SubMidWindow.m_STDEditor.ShowXrayAtlas();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
int r = PropGrid.Selection.ActivePosition.Row;
|
|
|
+ SelReferenceXray((int)PropGrid.Rows[r].Tag, ReferenceDictionary[(int)PropGrid.Rows[r].Tag]);
|
|
|
+ ShowReferenceContent(PropGrid.Rows[r].Tag.ToString());
|
|
|
+ //m_SubMidWindow.m_MainForm.m_Attributes.SetDatatoGrid_Attributes(ReferenceDictionary[(int)PropGrid.Rows[r].Tag]);
|
|
|
|
|
|
MakeCheckboxUnchecked();
|
|
|
PropGrid[PropGrid.Selection.ActivePosition.Row, 0].Value = true;
|
|
@@ -257,7 +283,44 @@ namespace SpectrumSTDEditor
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+ /// <summary>
|
|
|
+ /// 根据选择节点显示对应的Xray信息
|
|
|
+ /// </summary>
|
|
|
+ public void SelReferenceXray(int Key, STDdata sT)
|
|
|
+ {
|
|
|
+ if (sT == null)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (ReferenceXrayList != null)
|
|
|
+ {
|
|
|
+ //if (m_STDXrayList.Count > 0)
|
|
|
+ //{
|
|
|
+ bool isExists = false;
|
|
|
+ foreach (STDEditor.STDXray item in ReferenceXrayList)
|
|
|
+ {
|
|
|
+ //修改XrayData信息
|
|
|
+ if (item.StdID == Key.ToString())
|
|
|
+ {
|
|
|
+ string selColor = sT.Color;
|
|
|
+ int colorValue = Convert.ToInt32(selColor);
|
|
|
+ //显示Xray信息
|
|
|
+ if (item.XrayData != null)
|
|
|
+ {
|
|
|
+ isExists = true;
|
|
|
+ m_SubMidWindow.m_STDEditor.ShowXrayAtlas(colorValue, item.XrayData);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!isExists)
|
|
|
+ {
|
|
|
+ m_SubMidWindow.m_STDEditor.ShowXrayAtlas();
|
|
|
+ }
|
|
|
+ //}
|
|
|
+ }
|
|
|
|
|
|
+ }
|
|
|
private void TSClose_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
if (PropGrid.RowsCount > 1)
|
|
@@ -279,7 +342,6 @@ namespace SpectrumSTDEditor
|
|
|
{
|
|
|
SourceGrid.Grid oSender = (SourceGrid.Grid)sender;
|
|
|
oSender.Focus();
|
|
|
-
|
|
|
// 表示右击的是无效区域, 则退出(第0行是标题)
|
|
|
if (oSender.MouseCellPosition.Row < 1 || oSender.MouseCellPosition.Column < 0)
|
|
|
{
|
|
@@ -287,7 +349,6 @@ namespace SpectrumSTDEditor
|
|
|
}
|
|
|
// 右击的区域获取焦点
|
|
|
PropGrid.Selection.Focus(new SourceGrid.Position(oSender.MouseCellPosition.Row, oSender.MouseCellPosition.Column), true);
|
|
|
-
|
|
|
try
|
|
|
{
|
|
|
if (MouseButtons.Right == e.Button && e.Clicks == 1)
|
|
@@ -306,48 +367,50 @@ namespace SpectrumSTDEditor
|
|
|
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
private void insertToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
m_SubMidWindow.m_MainForm.m_STDRuleslist.Grid_Minerals.Focus(true);
|
|
|
int i = m_SubMidWindow.m_MainForm.m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row;
|
|
|
int j = m_SubMidWindow.m_MainForm.m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Column;
|
|
|
- /// 保证鼠标点击的GRID行和列是有效的
|
|
|
if (i >= 0 && j >= 0)
|
|
|
{
|
|
|
- //规则名称不为空
|
|
|
if (m_SubMidWindow.m_MainForm.m_STDRuleslist.Grid_Minerals[i, 0].Value.ToString().Replace(" ", "").Trim() != "")
|
|
|
{
|
|
|
-
|
|
|
- m_SubMidWindow.m_MainForm.SaveDataOfSelRule(i, j);
|
|
|
-
|
|
|
- PropGrid.Focus(true);
|
|
|
- int selrow = PropGrid.Selection.ActivePosition.Row;
|
|
|
- int STDnum = (int)PropGrid[selrow, 1].Tag;
|
|
|
- int STDId = 1;
|
|
|
- foreach (KeyValuePair<int, STDdata> kv in m_SubMidWindow.m_MainForm.STDDictionary)
|
|
|
- {
|
|
|
- if (STDId < kv.Key)
|
|
|
- {
|
|
|
- STDId = kv.Key;
|
|
|
- }
|
|
|
- }
|
|
|
- STDdata sT = new STDdata();
|
|
|
- sT.BSE = ReferenceDictionary[STDnum].BSE;
|
|
|
- sT.StrName = ReferenceDictionary[STDnum].StrName;
|
|
|
- sT.Color = ReferenceDictionary[STDnum].Color;
|
|
|
- sT.Density = ReferenceDictionary[STDnum].Density;
|
|
|
- sT.Formula = ReferenceDictionary[STDnum].Formula;
|
|
|
- sT.Hardness = ReferenceDictionary[STDnum].Hardness;
|
|
|
- sT.Element = ReferenceDictionary[STDnum].Element;
|
|
|
- m_SubMidWindow.m_MainForm.STDDictionary.Add(STDId + 1, sT);
|
|
|
-
|
|
|
- m_SubMidWindow.m_MainForm.m_STDRuleslist.InsertNewRow(STDId + 1, sT.StrName, shareFunction.string10ToColor(sT.Color));
|
|
|
- m_SubMidWindow.m_MainForm.m_STDRuleslist.Refresh();
|
|
|
-
|
|
|
- m_SubMidWindow.m_MainForm.m_STDRuleslist.PreRow = i;
|
|
|
-
|
|
|
-
|
|
|
+ m_SubMidWindow.m_MainForm.SaveDataOfSelRule(i, j);
|
|
|
+ PropGrid.Focus(true);
|
|
|
+ int selrow = PropGrid.Selection.ActivePosition.Row;
|
|
|
+ int STDnum = (int)PropGrid[selrow, 1].Tag;
|
|
|
+ int STDId = 1;
|
|
|
+ foreach (KeyValuePair<int, STDdata> kv in m_SubMidWindow.m_MainForm.STDDictionary)
|
|
|
+ {
|
|
|
+ if (STDId < kv.Key)
|
|
|
+ {
|
|
|
+ STDId = kv.Key;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ STDdata sT = new STDdata();
|
|
|
+ sT.BSE = ReferenceDictionary[STDnum].BSE;
|
|
|
+ sT.StrName = ReferenceDictionary[STDnum].StrName;
|
|
|
+ sT.Color = ReferenceDictionary[STDnum].Color;
|
|
|
+ sT.Density = ReferenceDictionary[STDnum].Density;
|
|
|
+ sT.Formula = ReferenceDictionary[STDnum].Formula;
|
|
|
+ sT.Hardness = ReferenceDictionary[STDnum].Hardness;
|
|
|
+ sT.Element = ReferenceDictionary[STDnum].Element;
|
|
|
+ m_SubMidWindow.m_MainForm.STDDictionary.Add(STDId + 1, sT);
|
|
|
+ m_SubMidWindow.m_MainForm.m_STDRuleslist.InsertNewRow(STDId + 1, sT.StrName, shareFunction.string10ToColor(sT.Color));
|
|
|
+ m_SubMidWindow.m_MainForm.m_STDRuleslist.Refresh();
|
|
|
+ m_SubMidWindow.m_MainForm.m_STDRuleslist.PreRow = i;
|
|
|
+ for (int k = 0; k < ReferenceXrayList.Count; k++)
|
|
|
+ {
|
|
|
+ if (int.Parse(ReferenceXrayList[k].StdID) == STDnum)
|
|
|
+ {
|
|
|
+ STDEditor.STDXray tDXray = new STDEditor.STDXray();
|
|
|
+ tDXray.StdID = (STDId + 1).ToString();
|
|
|
+ tDXray.XrayData = ReferenceXrayList[k].XrayData;
|
|
|
+ tDXray.InfoState = (int)STDEditor.STDXrayInfoState.Add;
|
|
|
+ m_SubMidWindow.m_STDEditor.m_STDXrayList.Add(tDXray);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -356,7 +419,20 @@ namespace SpectrumSTDEditor
|
|
|
AddIntoMainLab();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ private void ShowReferenceContent(string stdID)
|
|
|
+ {
|
|
|
+ if (ReferenceXrayList != null)
|
|
|
+ {
|
|
|
+ for (int i = 0; i < ReferenceXrayList.Count; i++)
|
|
|
+ {
|
|
|
+ if (ReferenceXrayList[i].StdID == stdID)
|
|
|
+ {
|
|
|
+ //获取修改行的信息
|
|
|
+ ReferencexrayByteData = (byte[])ReferenceXrayList[i].XrayData;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
#region 因为复制容易引起用户误操作,故取消
|
|
|
private void copyDataToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
{
|
|
@@ -383,9 +459,7 @@ namespace SpectrumSTDEditor
|
|
|
//规则名称不为空
|
|
|
if (m_SubMidWindow.m_MainForm.m_STDRuleslist.Grid_Minerals[i, j].Value.ToString().Replace(" ", "").Trim() != "")
|
|
|
{
|
|
|
-
|
|
|
m_SubMidWindow.m_MainForm.SaveDataOfSelRule(i, j);
|
|
|
-
|
|
|
AddIntoMainLab();
|
|
|
}
|
|
|
}
|
|
@@ -416,11 +490,24 @@ namespace SpectrumSTDEditor
|
|
|
sT.Density = ReferenceDictionary[STDnum].Density;
|
|
|
sT.Formula = ReferenceDictionary[STDnum].Formula;
|
|
|
sT.Hardness = ReferenceDictionary[STDnum].Hardness;
|
|
|
-
|
|
|
+ sT.ChineseName = ReferenceDictionary[STDnum].ChineseName;
|
|
|
+ sT.Element = ReferenceDictionary[STDnum].Element;
|
|
|
+ sT.XrayData = ReferenceDictionary[STDnum].XrayData;
|
|
|
m_SubMidWindow.m_MainForm.STDDictionary.Add(STDId + 1, sT);
|
|
|
m_SubMidWindow.m_MainForm.m_STDRuleslist.AddNewRow(STDId + 1, sT.StrName, shareFunction.string10ToColor(sT.Color));
|
|
|
m_SubMidWindow.m_MainForm.m_STDRuleslist.Refresh();
|
|
|
m_SubMidWindow.m_MainForm.m_STDRuleslist.PreRow = m_SubMidWindow.m_MainForm.m_STDRuleslist.Grid_Minerals.RowsCount - 1;
|
|
|
+ for (int k = 0; k < ReferenceXrayList.Count; k++)
|
|
|
+ {
|
|
|
+ if (int.Parse(ReferenceXrayList[k].StdID) == STDnum)
|
|
|
+ {
|
|
|
+ STDEditor.STDXray tDXray = new STDEditor.STDXray();
|
|
|
+ tDXray.StdID = (STDId + 1).ToString();
|
|
|
+ tDXray.XrayData = ReferenceXrayList[k].XrayData;
|
|
|
+ tDXray.InfoState = (int)STDEditor.STDXrayInfoState.Add;
|
|
|
+ m_SubMidWindow.m_STDEditor.m_STDXrayList.Add(tDXray);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|