|
@@ -1,4 +1,5 @@
|
|
|
using OTS.WinFormsUI.Docking;
|
|
|
+using OTSPartA_STDEditor.BaseClass;
|
|
|
using SourceGrid;
|
|
|
using System;
|
|
|
using System.Collections;
|
|
@@ -17,32 +18,17 @@ namespace OTSPartA_STDEditor
|
|
|
public STDRuleslist m_STDRuleslist = null;
|
|
|
public Attributes m_Attributes = null;
|
|
|
public SubMidWindow m_SubMidWindow = null;
|
|
|
- /// <summary>
|
|
|
- /// 实际存储的字典
|
|
|
- /// </summary>
|
|
|
- public Dictionary<int, STDdata> STDDictionary = new Dictionary<int, STDdata>();
|
|
|
- /// <summary>
|
|
|
- /// 原始数据字典用于在关闭时比较是否弹出保存提示
|
|
|
- /// </summary>
|
|
|
- private Dictionary<int, STDdata> STDDictionaryInitial = new Dictionary<int, STDdata>();
|
|
|
- public Dictionary<int, string> GroupIdDictionaryFromId = new Dictionary<int, string>();
|
|
|
- public Dictionary<string, int> GroupIdDictionaryFromName = new Dictionary<string, int>();
|
|
|
- string STDDBAddress_backupDirectory = Application.StartupPath + "\\Config\\SysData\\LibBackup\\";
|
|
|
public string STDDBAddress = "";
|
|
|
+ public STDInfo _sTDEditor=null;
|
|
|
/// <summary>
|
|
|
/// 0:正在打开的标准库路径;1:所增加标准的颗粒所在结果库位置;2:所增加标准的颗粒FieldId;3:所增加标准的颗粒ParticleId;4:所增加标准的颗粒XRayId
|
|
|
/// </summary>
|
|
|
List<string> ImportArgs = new List<string>();
|
|
|
-
|
|
|
//国际化
|
|
|
public Language lan;
|
|
|
Hashtable table;
|
|
|
-
|
|
|
//是否做出过更改
|
|
|
public bool IsModified { set; get; }
|
|
|
- public bool Isoldversion { set; get; }
|
|
|
-
|
|
|
-
|
|
|
public static readonly string[] ColorGroup = { "#FFB6C1", "#FFC0CB", "#DC143C", "#FFF0F5", "#DB7093", "#FF69B4", "#FF1493", "#C71585", "#DA70D6", "#D8BFD8", "#DDA0DD", "#EE82EE", "#FF00FF", "#8B008B", "#800080", "#BA55D3", "#9400D3", "#9932CC", "#4B0082", "#8A2BE2", "#9370DB","#7B68EE", "#6A5ACD", "#483D8B", "#E6E6FA", "#F8F8FF", "#0000FF", "#0000CD", "#191970", "#00008B", "#000080", "#4169E1" , "#6495ED", "#B0C4DE", "#778899", "#708090", "#1E90FF", "#F0F8FF", "#00FFFF" };
|
|
|
public Form_Main()
|
|
|
{
|
|
@@ -63,7 +49,6 @@ namespace OTSPartA_STDEditor
|
|
|
ImportArgs.Add(it);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
private void Form_ConstantsEditor2_Load(object sender, EventArgs e)
|
|
|
{
|
|
|
lan = new Language(this);
|
|
@@ -80,116 +65,18 @@ namespace OTSPartA_STDEditor
|
|
|
var result = m_importStandardLibraryTypeSelection.ShowDialog();
|
|
|
if (m_importStandardLibraryTypeSelection.SelectEvent == "expression")
|
|
|
{
|
|
|
- int STDId = AddSTDDictionaryItem();
|
|
|
- m_STDRuleslist.AddNewRow(STDId, "NewClassify", Attributes.colorHx16toRGB(STDDictionary[STDId].Color));
|
|
|
+ int STDId = _sTDEditor.AddSTDDictionaryItem();
|
|
|
+ m_STDRuleslist.AddNewRow(STDId, "NewClassify", Attributes.colorHx16toRGB(_sTDEditor.STDDictionary[STDId].Color));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- void LoadConstants(string STDDBAddress)
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
- System.Data.SQLite.SQLiteConnection m_dbConnection = new System.Data.SQLite.SQLiteConnection("data source='" + STDDBAddress + "'");
|
|
|
- m_dbConnection.Open();
|
|
|
- System.Data.SQLite.SQLiteDataAdapter m_dataAdapter = new System.Data.SQLite.SQLiteDataAdapter("select * from Constants", m_dbConnection);
|
|
|
- DataSet ds = new DataSet();
|
|
|
- m_dataAdapter.Fill(ds);
|
|
|
- DataTable dt = ds.Tables[0];
|
|
|
- if (dt.Rows.Count > 0)
|
|
|
- {
|
|
|
- string ConstantsStr = dt.Rows[0][0].ToString();
|
|
|
- ConstantsStr = ConstantsStr.Replace(" ", "");
|
|
|
- string[] ConstantsStr2 = ConstantsStr.Split(',');
|
|
|
- m_SubMidWindow.m_STDEditor.comboBox_Constants.Items.Clear();
|
|
|
- m_SubMidWindow.m_STDEditor.comboBox_Constants.Items.AddRange(ConstantsStr2);
|
|
|
- }
|
|
|
- m_dbConnection.Close();
|
|
|
- }
|
|
|
- catch (Exception ee)
|
|
|
- {
|
|
|
- MessageBox.Show(ee.ToString());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- bool LoadClassifyToDictionary(string DBAddress, ref Dictionary<int, STDdata> STDDictionary)
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
- //STDDictionaryInitial.Clear();
|
|
|
-
|
|
|
- System.Data.SQLite.SQLiteConnection m_dbConnection = new System.Data.SQLite.SQLiteConnection("data source='" + DBAddress + "'");
|
|
|
- m_dbConnection.Open();
|
|
|
- System.Data.SQLite.SQLiteDataAdapter m_dataAdapter = new System.Data.SQLite.SQLiteDataAdapter("select * from ClassifySTD order by ListNum", m_dbConnection);
|
|
|
- DataSet ds = new DataSet();
|
|
|
- m_dataAdapter.Fill(ds);
|
|
|
- DataTable dt = ds.Tables[0];
|
|
|
-
|
|
|
- if (dt != null)
|
|
|
- {
|
|
|
-
|
|
|
- if ((dt.Columns.Contains("IfElementAnalysis")))
|
|
|
- {
|
|
|
- rbSave.Enabled = true;
|
|
|
- Isoldversion = false;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- MessageBox.Show("该标准库为旧版本,只能进行另存操作!", "注意");
|
|
|
- rbSave.Enabled = false;
|
|
|
- Isoldversion = true;
|
|
|
- }
|
|
|
- if (dt.Rows.Count > 0)
|
|
|
- {
|
|
|
- foreach (DataRow item in dt.Rows)
|
|
|
- {
|
|
|
- STDdata new_STDdata = new STDdata();
|
|
|
-
|
|
|
- new_STDdata.Hardness = item["Hardness"].ToString();
|
|
|
- new_STDdata.Density = item["Density"].ToString();
|
|
|
- new_STDdata.Electrical_conductivity = item["Electrical_conductivity"].ToString();
|
|
|
- new_STDdata.BSE = item["BSE"].ToString();
|
|
|
- new_STDdata.Formula = item["Formula"].ToString();
|
|
|
- new_STDdata.Element = item["Element"].ToString();
|
|
|
- new_STDdata.StrName = item["StrName"].ToString();
|
|
|
- new_STDdata.Expression = item["Expression"].ToString();
|
|
|
- new_STDdata.Color = item["Color"].ToString();
|
|
|
- new_STDdata.KeyElementList = item["KeyElementList"].ToString();
|
|
|
- new_STDdata.SubElementList = item["SubElementList"].ToString();
|
|
|
- new_STDdata.GroupId = item["GroupId"].ToString();
|
|
|
- new_STDdata.ListNum = item["ListNum"].ToString();
|
|
|
- new_STDdata.GroupId = item["GroupId"].ToString();
|
|
|
- if (dt.Columns.Contains("IfElementAnalysis"))
|
|
|
- {
|
|
|
- if (Convert.ToBoolean(item["IfElementAnalysis"]))
|
|
|
- {
|
|
|
- new_STDdata.IfElementAnalysis = true;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- new_STDdata.IfElementAnalysis = false;
|
|
|
- }
|
|
|
- }
|
|
|
- STDDictionary.Add(int.Parse(item["STDId"].ToString()), new_STDdata);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return true;
|
|
|
- }
|
|
|
- catch /*(Exception ee)*/
|
|
|
- {
|
|
|
- MessageBox.Show("The selected standard library is formatted incorrectly, please open the correct standard library!", "Tip");
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
public void ChangeSTDEditorAndGrid_Attributes(int STDId)
|
|
|
{
|
|
|
m_SubMidWindow.ChangeText_textbox_STDEditor(STDId);
|
|
|
m_Attributes.SetDatatoGrid_Attributes(STDId);
|
|
|
}
|
|
|
-
|
|
|
private void rbBackup_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
if (m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row >= 0)
|
|
@@ -207,17 +94,16 @@ namespace OTSPartA_STDEditor
|
|
|
{
|
|
|
if (STDDBAddress == saveFile.FileName)
|
|
|
{
|
|
|
- MessageBox.Show("不能另存为同名文件!", "Tip");
|
|
|
+ MessageBox.Show("Cannot save as same name!", "Tip");
|
|
|
return;
|
|
|
}
|
|
|
FormForWaiting forWaiting = new FormForWaiting();
|
|
|
forWaiting.Show();
|
|
|
System.IO.File.Copy(STDDBAddress, saveFile.FileName, true);
|
|
|
- bool result = SaveAsDictionaryToClassify(saveFile.FileName);
|
|
|
+ bool result = _sTDEditor.SaveAsDictionaryToClassify(saveFile.FileName);
|
|
|
if (result)
|
|
|
{
|
|
|
- STDDictionaryInitial.Clear();
|
|
|
- STDDictionaryInitial = Clone(STDDictionary) as Dictionary<int, STDdata>;
|
|
|
+ _sTDEditor.UpdateSTDDictionaryInitial();
|
|
|
STDDBAddress = saveFile.FileName;
|
|
|
this.Text = this.Text.Split(' ')[0] + " " + saveFile.FileName;
|
|
|
IsModified = false;
|
|
@@ -240,38 +126,7 @@ namespace OTSPartA_STDEditor
|
|
|
MessageBox.Show(ex.Message);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- public bool ClearDb(string DBAddress, string DBTableName)
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
- System.Data.SQLite.SQLiteConnection m_dbConnection = new System.Data.SQLite.SQLiteConnection("data source='" + DBAddress + "'");
|
|
|
- m_dbConnection.Open();
|
|
|
-
|
|
|
- System.Data.SQLite.SQLiteCommand cmm = m_dbConnection.CreateCommand();
|
|
|
- cmm.CommandText = "delete from " + DBTableName;
|
|
|
- cmm.ExecuteNonQuery();
|
|
|
- m_dbConnection.Close();
|
|
|
- return true;
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
- {
|
|
|
- MessageBox.Show(ex.ToString());
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- object Clone(Dictionary<int, STDdata> STDDictionary)
|
|
|
- {
|
|
|
- Dictionary<int, STDdata> STDDictionaryInitial = new Dictionary<int, STDdata>();
|
|
|
- foreach (var key in STDDictionary.Keys)
|
|
|
- {
|
|
|
- STDdata tDdata = new STDdata();
|
|
|
- tDdata = tDdata.Clone(STDDictionary[key]) as STDdata;
|
|
|
- STDDictionaryInitial.Add(key, tDdata);
|
|
|
- }
|
|
|
- return STDDictionaryInitial;
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
private void rbSave_Click(object sender, EventArgs e)
|
|
|
{
|
|
@@ -279,15 +134,14 @@ namespace OTSPartA_STDEditor
|
|
|
{
|
|
|
SaveDataOfSelRule(m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row, 0);
|
|
|
}
|
|
|
- if (RuleformatcheckAndSave())
|
|
|
+ if (Ruleformatcheck())
|
|
|
{
|
|
|
FormForWaiting forWaiting = new FormForWaiting();
|
|
|
forWaiting.Show();
|
|
|
- bool result = SaveDictionaryToClassify(STDDBAddress);
|
|
|
+ bool result = _sTDEditor.SaveDictionaryToClassify();
|
|
|
if (result)
|
|
|
{
|
|
|
- STDDictionaryInitial.Clear();
|
|
|
- STDDictionaryInitial = Clone(STDDictionary) as Dictionary<int, STDdata>;
|
|
|
+ _sTDEditor.UpdateSTDDictionaryInitial();
|
|
|
forWaiting.Close();
|
|
|
IsModified = false;
|
|
|
MessageBox.Show("Save successful!", "Tip");
|
|
@@ -305,9 +159,9 @@ namespace OTSPartA_STDEditor
|
|
|
}
|
|
|
|
|
|
|
|
|
- bool RuleformatcheckAndSave()
|
|
|
+ bool Ruleformatcheck()
|
|
|
{
|
|
|
- foreach (var ite in STDDictionary)
|
|
|
+ foreach (var ite in _sTDEditor.STDDictionary)
|
|
|
{
|
|
|
if (CheckExpression(ite.Value.Expression))
|
|
|
{
|
|
@@ -338,6 +192,9 @@ namespace OTSPartA_STDEditor
|
|
|
{
|
|
|
return System.Drawing.ColorTranslator.ToHtml(System.Drawing.Color.FromArgb(R, G, B));
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
//表达式规则检查
|
|
|
public bool CheckExpression(string Expression)
|
|
|
{
|
|
@@ -541,44 +398,45 @@ namespace OTSPartA_STDEditor
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
public void SaveDataOfSelRule(int PreRow, int PreColumn)
|
|
|
{
|
|
|
- STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].StrName = Convert.ToString(m_Attributes.Grid_Attributes[2, 1].Value);
|
|
|
- STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Color = colorRGBtoHx16(m_Attributes.Grid_Attributes[3, 1].View.BackColor.R, m_Attributes.Grid_Attributes[3, 1].View.BackColor.G, m_Attributes.Grid_Attributes[3, 1].View.BackColor.B);
|
|
|
- STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].IfElementAnalysis = Convert.ToBoolean(m_Attributes.Grid_Attributes[4, 1].Value);
|
|
|
- STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Hardness = Convert.ToString(m_Attributes.Grid_Attributes[5, 1].Value);
|
|
|
- STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Density = Convert.ToString(m_Attributes.Grid_Attributes[6, 1].Value);
|
|
|
- STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Electrical_conductivity = Convert.ToString(m_Attributes.Grid_Attributes[7, 1].Value);
|
|
|
- STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].BSE = Convert.ToString(m_Attributes.Grid_Attributes[8, 1].Value);
|
|
|
+ _sTDEditor.STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].StrName = Convert.ToString(m_Attributes.Grid_Attributes[2, 1].Value);
|
|
|
+ _sTDEditor.STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Color = colorRGBtoHx16(m_Attributes.Grid_Attributes[3, 1].View.BackColor.R, m_Attributes.Grid_Attributes[3, 1].View.BackColor.G, m_Attributes.Grid_Attributes[3, 1].View.BackColor.B);
|
|
|
+ _sTDEditor.STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].IfElementAnalysis = Convert.ToBoolean(m_Attributes.Grid_Attributes[4, 1].Value);
|
|
|
+ _sTDEditor.STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Hardness = Convert.ToString(m_Attributes.Grid_Attributes[5, 1].Value);
|
|
|
+ _sTDEditor.STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Density = Convert.ToString(m_Attributes.Grid_Attributes[6, 1].Value);
|
|
|
+ _sTDEditor.STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Electrical_conductivity = Convert.ToString(m_Attributes.Grid_Attributes[7, 1].Value);
|
|
|
+ _sTDEditor.STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].BSE = Convert.ToString(m_Attributes.Grid_Attributes[8, 1].Value);
|
|
|
|
|
|
|
|
|
if (m_Attributes.Grid_Attributes[9, 1].Value != null)
|
|
|
{
|
|
|
- STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Formula = Convert.ToString(m_Attributes.Grid_Attributes[9, 1].Value);
|
|
|
+ _sTDEditor.STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Formula = Convert.ToString(m_Attributes.Grid_Attributes[9, 1].Value);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Formula = "";
|
|
|
+ _sTDEditor.STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Formula = "";
|
|
|
}
|
|
|
if (m_Attributes.Grid_Attributes[10, 1].Value != null)
|
|
|
{
|
|
|
- STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Element = Convert.ToString(m_Attributes.Grid_Attributes[10, 1].Value);
|
|
|
+ _sTDEditor.STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Element = Convert.ToString(m_Attributes.Grid_Attributes[10, 1].Value);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Element = "";
|
|
|
+ _sTDEditor.STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Element = "";
|
|
|
}
|
|
|
|
|
|
if (m_Attributes.Grid_Attributes[11, 1].Value != null)
|
|
|
{
|
|
|
- STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].GroupId = GroupIdDictionaryFromName[Convert.ToString(m_Attributes.Grid_Attributes[11, 1].Value)].ToString();
|
|
|
+ _sTDEditor.STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].GroupId = _sTDEditor.GroupIdDictionaryFromName[Convert.ToString(m_Attributes.Grid_Attributes[11, 1].Value)].ToString();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].GroupId = "0";
|
|
|
+ _sTDEditor.STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].GroupId = "0";
|
|
|
}
|
|
|
|
|
|
- STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Expression = m_SubMidWindow.m_STDEditor.textbox_STDEditor.Text.ToString();
|
|
|
+ _sTDEditor.STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Expression = m_SubMidWindow.m_STDEditor.textbox_STDEditor.Text.ToString();
|
|
|
|
|
|
string sKeyElements = "";
|
|
|
for (int i = 0; i < m_SubMidWindow.m_STDEditor.dataGridView_KeyElements.Columns.Count; i++)
|
|
@@ -600,368 +458,20 @@ namespace OTSPartA_STDEditor
|
|
|
sSubElements = sSubElements.Substring(0, sSubElements.Length - 1);
|
|
|
}
|
|
|
|
|
|
- STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].KeyElementList = sKeyElements;
|
|
|
- STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].SubElementList = sSubElements;
|
|
|
-
|
|
|
- STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].ListNum = PreRow.ToString();
|
|
|
- }
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 保存ClassifySTD库和MineralElements库
|
|
|
- /// </summary>
|
|
|
- /// <param name="DBAddress"></param>
|
|
|
- /// <returns></returns>
|
|
|
- bool SaveDictionaryToClassify(string DBAddress)
|
|
|
- {
|
|
|
- //保存列表顺序
|
|
|
- for (int i = 1; i < m_STDRuleslist.Grid_Minerals.RowsCount; i++)
|
|
|
- {
|
|
|
- STDDictionary[(int)m_STDRuleslist.Grid_Minerals[i, 0].Tag].ListNum = i.ToString();
|
|
|
- }
|
|
|
- try
|
|
|
- {
|
|
|
- System.Data.SQLite.SQLiteConnection m_dbConnection = new System.Data.SQLite.SQLiteConnection("data source='" + DBAddress + "'");
|
|
|
- m_dbConnection.Open();
|
|
|
-
|
|
|
- System.Data.SQLite.SQLiteCommand cmm = m_dbConnection.CreateCommand();
|
|
|
- cmm.CommandText = "delete from ClassifySTD";
|
|
|
- //cmm.CommandText = "delete from ClassifySTD_Backup";
|
|
|
- try
|
|
|
- {
|
|
|
- cmm.ExecuteNonQuery();
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
- {
|
|
|
- MessageBox.Show(ex.ToString());
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- System.Data.SQLite.SQLiteDataAdapter m_dataAdapter = new System.Data.SQLite.SQLiteDataAdapter("select * from ClassifySTD", m_dbConnection);
|
|
|
- //System.Data.SQLite.SQLiteDataAdapter m_dataAdapter = new System.Data.SQLite.SQLiteDataAdapter("select * from ClassifySTD_Backup", m_dbConnection);
|
|
|
- System.Data.SQLite.SQLiteCommandBuilder qLiteCommandBuilder = new System.Data.SQLite.SQLiteCommandBuilder(m_dataAdapter);
|
|
|
-
|
|
|
- DataSet ds = new DataSet();
|
|
|
- m_dataAdapter.Fill(ds, "ClassifySTD");
|
|
|
- DataTable dt = ds.Tables["ClassifySTD"];
|
|
|
-
|
|
|
- //m_dataAdapter.Fill(ds, "ClassifySTD_Backup");
|
|
|
- //DataTable dt = ds.Tables["ClassifySTD_Backup"];
|
|
|
-
|
|
|
- dt.Clear();
|
|
|
- foreach (KeyValuePair<int, STDdata> kv in STDDictionary)
|
|
|
- {
|
|
|
- string UsingElementList = "";
|
|
|
- string UsingImgPropertyList = "";
|
|
|
- string UsingOtherPropertyList = "";
|
|
|
- List<string> UsingElementL = new List<string>();
|
|
|
- List<string> UsingImgPropertyL = new List<string>();
|
|
|
- List<string> UsingOtherPropertyL = new List<string>();
|
|
|
-
|
|
|
- string str_RemoveBlank = kv.Value.Expression;
|
|
|
- ////forth_elem干扰or分隔符,故先行去掉
|
|
|
- //if (str_RemoveBlank.Contains("fourth_elem"))
|
|
|
- //{
|
|
|
- // str_RemoveBlank = str_RemoveBlank.Replace("fourth_elem", "");
|
|
|
- // UsingOtherPropertyList = "fourth_elem";
|
|
|
- //}
|
|
|
-
|
|
|
- str_RemoveBlank = str_RemoveBlank.Replace(" ", "");
|
|
|
- string[] str_Removeand = System.Text.RegularExpressions.Regex.Split(str_RemoveBlank, "and", System.Text.RegularExpressions.RegexOptions.None);
|
|
|
- List<string> str_Removeandor = new List<string>();
|
|
|
- for (int i = 0; i < str_Removeand.Length; i++)
|
|
|
- {
|
|
|
- str_Removeandor.AddRange(System.Text.RegularExpressions.Regex.Split(str_Removeand[i], "or", System.Text.RegularExpressions.RegexOptions.None));
|
|
|
- }
|
|
|
- List<string> list_all = new List<string>();
|
|
|
- for (int i = 0; i < str_Removeandor.Count; i++)
|
|
|
- {
|
|
|
- list_all.AddRange(str_Removeandor[i].Split(new char[] { '+', '-', '*', '/', '=', '>', '<', '(', ')' }));
|
|
|
- }
|
|
|
- for (int i = 0; i < list_all.Count; i++)
|
|
|
- {
|
|
|
- //周期元素?
|
|
|
- if (m_SubMidWindow.m_STDEditor.comboBox_PeriodicTable.Items.Contains(list_all[i]))
|
|
|
- {
|
|
|
- if (!UsingElementL.Contains(list_all[i]))
|
|
|
- {
|
|
|
- UsingElementL.Add(list_all[i]);
|
|
|
- }
|
|
|
- }
|
|
|
- //first_elem?
|
|
|
- if (m_SubMidWindow.m_STDEditor.comboBox_Elem1.Items.Contains(list_all[i]))
|
|
|
- {
|
|
|
- if (!UsingOtherPropertyL.Contains(list_all[i]))
|
|
|
- {
|
|
|
- UsingOtherPropertyL.Add(list_all[i]);
|
|
|
- }
|
|
|
- }
|
|
|
- //Element1?
|
|
|
- if (m_SubMidWindow.m_STDEditor.comboBox_Elem.Items.Contains(list_all[i]))
|
|
|
- {
|
|
|
- if (!UsingOtherPropertyL.Contains(list_all[i]))
|
|
|
- {
|
|
|
- UsingOtherPropertyL.Add(list_all[i]);
|
|
|
- }
|
|
|
- }
|
|
|
- //其它元素?
|
|
|
- if (m_SubMidWindow.m_STDEditor.comboBox_ImgProperty.Items.Contains(list_all[i]))
|
|
|
- {
|
|
|
- if (!UsingImgPropertyL.Contains(list_all[i]))
|
|
|
- {
|
|
|
- UsingImgPropertyL.Add(list_all[i]);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (UsingElementL.Count > 0)
|
|
|
- {
|
|
|
- for (int i = 0; i < UsingElementL.Count - 1; i++)
|
|
|
- {
|
|
|
- UsingElementList += UsingElementL[i] + ",";
|
|
|
- }
|
|
|
- UsingElementList += UsingElementL[UsingElementL.Count - 1];
|
|
|
- }
|
|
|
-
|
|
|
- if (UsingImgPropertyL.Count > 0)
|
|
|
- {
|
|
|
- for (int i = 0; i < UsingImgPropertyL.Count - 1; i++)
|
|
|
- {
|
|
|
- UsingImgPropertyList += UsingImgPropertyL[i] + ",";
|
|
|
- }
|
|
|
- UsingImgPropertyList += UsingImgPropertyL[UsingImgPropertyL.Count - 1];
|
|
|
- }
|
|
|
-
|
|
|
- if (UsingOtherPropertyL.Count > 0)
|
|
|
- {
|
|
|
- for (int i = 0; i < UsingOtherPropertyL.Count - 1; i++)
|
|
|
- {
|
|
|
- UsingOtherPropertyList += UsingOtherPropertyL[i] + ",";
|
|
|
- }
|
|
|
- UsingOtherPropertyList += UsingOtherPropertyL[UsingOtherPropertyL.Count - 1];
|
|
|
- }
|
|
|
-
|
|
|
- DataRow newRow = dt.NewRow();
|
|
|
- newRow["STDId"] = kv.Key;
|
|
|
- newRow["StrName"] = kv.Value.StrName;
|
|
|
- newRow["Color"] = kv.Value.Color;
|
|
|
- newRow["KeyElementList"] = kv.Value.KeyElementList;
|
|
|
- newRow["SubElementList"] = kv.Value.SubElementList;
|
|
|
- newRow["UsingImgPropertyList"] = UsingImgPropertyList;
|
|
|
- newRow["UsingOtherPropertyList"] = UsingOtherPropertyList;
|
|
|
- newRow["Expression"] = kv.Value.Expression;
|
|
|
- newRow["Hardness"] = kv.Value.Hardness;
|
|
|
- newRow["Density"] = kv.Value.Density;
|
|
|
- newRow["Electrical_conductivity"] = kv.Value.Electrical_conductivity;
|
|
|
- newRow["BSE"] = int.Parse(kv.Value.BSE);
|
|
|
- newRow["Formula"] = kv.Value.Formula;
|
|
|
- newRow["Element"] = kv.Value.Element;
|
|
|
- newRow["IfElementAnalysis"] = kv.Value.IfElementAnalysis;
|
|
|
- newRow["GroupId"] = int.Parse(kv.Value.GroupId);
|
|
|
- newRow["ListNum"] = kv.Value.ListNum;
|
|
|
- dt.Rows.Add(newRow);
|
|
|
- }
|
|
|
- m_dataAdapter.Update(ds, "ClassifySTD");
|
|
|
- m_dbConnection.Close();
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
- {
|
|
|
- MessageBox.Show(ex.ToString());
|
|
|
- return false;
|
|
|
- }
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- bool SaveAsDictionaryToClassify(string DBAddress)
|
|
|
- {
|
|
|
- ////保存列表顺序
|
|
|
- //for (int i = 1; i < m_STDRuleslist.Grid_Minerals.RowsCount; i++)
|
|
|
- //{
|
|
|
- // STDDictionary[(int)m_STDRuleslist.Grid_Minerals[i, 0].Tag].ListNum = i.ToString();
|
|
|
- //}
|
|
|
- try
|
|
|
- {
|
|
|
- System.Data.SQLite.SQLiteConnection m_dbConnection = new System.Data.SQLite.SQLiteConnection("data source='" + DBAddress + "'");
|
|
|
- m_dbConnection.Open();
|
|
|
-
|
|
|
- System.Data.SQLite.SQLiteCommand cmm = m_dbConnection.CreateCommand();
|
|
|
- cmm.CommandText = "drop table ClassifySTD";
|
|
|
- cmm.ExecuteNonQuery();
|
|
|
-
|
|
|
- cmm.CommandText = "CREATE TABLE ClassifySTD (STDId INTEGER,StrName TEXT, Color TEXT,KeyElementList TEXT,SubElementList TEXT,UsingImgPropertyList TEXT,UsingOtherPropertyList TEXT,Expression TEXT,Hardness TEXT,Density TEXT,Electrical_conductivity TEXT,BSE INTEGER,Formula TEXT,Element TEXT,IfElementAnalysis BOOLEAN,ListNum INT,GroupId INT)";
|
|
|
- cmm.ExecuteNonQuery();
|
|
|
-
|
|
|
- System.Data.Common.DbTransaction trans = m_dbConnection.BeginTransaction();
|
|
|
- trans.Commit();
|
|
|
-
|
|
|
- System.Data.SQLite.SQLiteDataAdapter m_dataAdapter = new System.Data.SQLite.SQLiteDataAdapter("select * from ClassifySTD", m_dbConnection);
|
|
|
- System.Data.SQLite.SQLiteCommandBuilder qLiteCommandBuilder = new System.Data.SQLite.SQLiteCommandBuilder(m_dataAdapter);
|
|
|
-
|
|
|
- DataSet ds = new DataSet();
|
|
|
- m_dataAdapter.Fill(ds, "ClassifySTD");
|
|
|
- DataTable dt = ds.Tables["ClassifySTD"];
|
|
|
-
|
|
|
- foreach (KeyValuePair<int, STDdata> kv in STDDictionary)
|
|
|
- {
|
|
|
- string UsingElementList = "";
|
|
|
- string UsingImgPropertyList = "";
|
|
|
- string UsingOtherPropertyList = "";
|
|
|
- List<string> UsingElementL = new List<string>();
|
|
|
- List<string> UsingImgPropertyL = new List<string>();
|
|
|
- List<string> UsingOtherPropertyL = new List<string>();
|
|
|
-
|
|
|
- string str_RemoveBlank = kv.Value.Expression;
|
|
|
- ////forth_elem干扰or分隔符,故先行去掉
|
|
|
- //if (str_RemoveBlank.Contains("fourth_elem"))
|
|
|
- //{
|
|
|
- // str_RemoveBlank = str_RemoveBlank.Replace("fourth_elem", "");
|
|
|
- // UsingOtherPropertyList = "fourth_elem,";
|
|
|
- //}
|
|
|
-
|
|
|
- str_RemoveBlank = str_RemoveBlank.Replace(" ", "");
|
|
|
- string[] str_Removeand = System.Text.RegularExpressions.Regex.Split(str_RemoveBlank, "and", System.Text.RegularExpressions.RegexOptions.None);
|
|
|
- List<string> str_Removeandor = new List<string>();
|
|
|
- for (int i = 0; i < str_Removeand.Length; i++)
|
|
|
- {
|
|
|
- str_Removeandor.AddRange(System.Text.RegularExpressions.Regex.Split(str_Removeand[i], "or", System.Text.RegularExpressions.RegexOptions.None));
|
|
|
- }
|
|
|
- List<string> list_all = new List<string>();
|
|
|
- for (int i = 0; i < str_Removeandor.Count; i++)
|
|
|
- {
|
|
|
- list_all.AddRange(str_Removeandor[i].Split(new char[] { '+', '-', '*', '/', '=', '>', '<', '(', ')' }));
|
|
|
- }
|
|
|
- for (int i = 0; i < list_all.Count; i++)
|
|
|
- {
|
|
|
- //周期元素?
|
|
|
- if (m_SubMidWindow.m_STDEditor.comboBox_PeriodicTable.Items.Contains(list_all[i]))
|
|
|
- {
|
|
|
- if (!UsingElementL.Contains(list_all[i]))
|
|
|
- {
|
|
|
- UsingElementL.Add(list_all[i]);
|
|
|
- }
|
|
|
- }
|
|
|
- //first_elem?
|
|
|
- if (m_SubMidWindow.m_STDEditor.comboBox_Elem1.Items.Contains(list_all[i]))
|
|
|
- {
|
|
|
- if (!UsingOtherPropertyL.Contains(list_all[i]))
|
|
|
- {
|
|
|
- UsingOtherPropertyL.Add(list_all[i]);
|
|
|
- }
|
|
|
- }
|
|
|
- //Element1?
|
|
|
- if (m_SubMidWindow.m_STDEditor.comboBox_Elem.Items.Contains(list_all[i]))
|
|
|
- {
|
|
|
- if (!UsingOtherPropertyL.Contains(list_all[i]))
|
|
|
- {
|
|
|
- UsingOtherPropertyL.Add(list_all[i]);
|
|
|
- }
|
|
|
- }
|
|
|
- //其它元素?
|
|
|
- if (m_SubMidWindow.m_STDEditor.comboBox_ImgProperty.Items.Contains(list_all[i]))
|
|
|
- {
|
|
|
- if (!UsingImgPropertyL.Contains(list_all[i]))
|
|
|
- {
|
|
|
- UsingImgPropertyL.Add(list_all[i]);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (UsingElementL.Count > 0)
|
|
|
- {
|
|
|
- for (int i = 0; i < UsingElementL.Count - 1; i++)
|
|
|
- {
|
|
|
- UsingElementList += UsingElementL[i] + ",";
|
|
|
- }
|
|
|
- UsingElementList += UsingElementL[UsingElementL.Count - 1];
|
|
|
- }
|
|
|
-
|
|
|
- if (UsingImgPropertyL.Count > 0)
|
|
|
- {
|
|
|
- for (int i = 0; i < UsingImgPropertyL.Count - 1; i++)
|
|
|
- {
|
|
|
- UsingImgPropertyList += UsingImgPropertyL[i] + ",";
|
|
|
- }
|
|
|
- UsingImgPropertyList += UsingImgPropertyL[UsingImgPropertyL.Count - 1];
|
|
|
- }
|
|
|
-
|
|
|
- if (UsingOtherPropertyL.Count > 0)
|
|
|
- {
|
|
|
- for (int i = 0; i < UsingOtherPropertyL.Count - 1; i++)
|
|
|
- {
|
|
|
- UsingOtherPropertyList += UsingOtherPropertyL[i] + ",";
|
|
|
- }
|
|
|
- UsingOtherPropertyList += UsingOtherPropertyL[UsingOtherPropertyL.Count - 1];
|
|
|
- }
|
|
|
-
|
|
|
- DataRow newRow = dt.NewRow();
|
|
|
- newRow["STDId"] = kv.Key;
|
|
|
- newRow["StrName"] = kv.Value.StrName;
|
|
|
- newRow["Color"] = kv.Value.Color;
|
|
|
- newRow["KeyElementList"] = kv.Value.KeyElementList;
|
|
|
- newRow["SubElementList"] = kv.Value.SubElementList;
|
|
|
- newRow["UsingImgPropertyList"] = UsingImgPropertyList;
|
|
|
- newRow["UsingOtherPropertyList"] = UsingOtherPropertyList;
|
|
|
- newRow["Expression"] = kv.Value.Expression;
|
|
|
- newRow["Hardness"] = kv.Value.Hardness;
|
|
|
- newRow["Density"] = kv.Value.Density;
|
|
|
- newRow["Electrical_conductivity"] = kv.Value.Electrical_conductivity;
|
|
|
- newRow["BSE"] = int.Parse(kv.Value.BSE);
|
|
|
- newRow["Formula"] = kv.Value.Formula;
|
|
|
- newRow["Element"] = kv.Value.Element;
|
|
|
- newRow["IfElementAnalysis"] = kv.Value.IfElementAnalysis;
|
|
|
- newRow["GroupId"] = int.Parse(kv.Value.GroupId);
|
|
|
- newRow["ListNum"] = kv.Value.ListNum;
|
|
|
- dt.Rows.Add(newRow);
|
|
|
- }
|
|
|
- m_dataAdapter.Update(ds, "ClassifySTD");
|
|
|
- m_dbConnection.Close();
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
- {
|
|
|
- MessageBox.Show(ex.ToString());
|
|
|
- return false;
|
|
|
- }
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- public int AddSTDDictionaryItem()
|
|
|
- {
|
|
|
- STDdata new_STDdata = new STDdata();//定义一个TreeNode节点对象
|
|
|
- new_STDdata.Hardness = "1";
|
|
|
- new_STDdata.Density = "1";
|
|
|
- new_STDdata.Electrical_conductivity = "1";
|
|
|
- new_STDdata.BSE = "1";
|
|
|
- new_STDdata.Formula = "1";
|
|
|
- new_STDdata.Element = "1";
|
|
|
- new_STDdata.StrName = "NewRuleName";
|
|
|
- //new_STDdata.Expression = "NewRules";
|
|
|
- new_STDdata.Expression = "false";
|
|
|
- new_STDdata.KeyElementList = "";
|
|
|
- new_STDdata.SubElementList = "";
|
|
|
- Random random = new Random();
|
|
|
- new_STDdata.Color = ColorGroup[random.Next(ColorGroup.Length)];
|
|
|
-
|
|
|
- int STDId = 40000;
|
|
|
-
|
|
|
- foreach (KeyValuePair<int, STDdata> kv in STDDictionary)
|
|
|
- {
|
|
|
- if (STDId < kv.Key)
|
|
|
- {
|
|
|
- STDId = kv.Key;
|
|
|
- }
|
|
|
- }
|
|
|
+ _sTDEditor.STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].KeyElementList = sKeyElements;
|
|
|
+ _sTDEditor.STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].SubElementList = sSubElements;
|
|
|
|
|
|
- STDDictionary.Add(STDId + 1, new_STDdata);
|
|
|
-
|
|
|
- return STDId + 1;
|
|
|
+ _sTDEditor.STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].ListNum = PreRow.ToString();
|
|
|
}
|
|
|
|
|
|
public void RemoveSTDDictionaryItem(int STDId)
|
|
|
{
|
|
|
- STDDictionary.Remove(STDId);
|
|
|
+ _sTDEditor.STDDictionary.Remove(STDId);
|
|
|
}
|
|
|
|
|
|
public void ChangeStrName(int RowNum, string NewStrName)
|
|
|
{
|
|
|
- STDDictionary[(int)m_STDRuleslist.Grid_Minerals[RowNum, 0].Tag].StrName = NewStrName;
|
|
|
+ _sTDEditor.STDDictionary[(int)m_STDRuleslist.Grid_Minerals[RowNum, 0].Tag].StrName = NewStrName;
|
|
|
m_Attributes.Grid_Attributes[2, 1].Value = NewStrName;
|
|
|
}
|
|
|
|
|
@@ -974,6 +484,8 @@ namespace OTSPartA_STDEditor
|
|
|
m_STDRuleslist.Grid_Minerals[m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row, 0].Value = RuleName;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
public void SetNull()
|
|
|
{
|
|
|
m_SubMidWindow.m_STDEditor.textbox_STDEditor.Text = "";
|
|
@@ -1022,18 +534,10 @@ namespace OTSPartA_STDEditor
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- System.Data.SQLite.SQLiteConnection m_dbConnection = new System.Data.SQLite.SQLiteConnection("data source='" + STDDBAddress + "'");
|
|
|
- m_dbConnection.Open();
|
|
|
- System.Data.SQLite.SQLiteDataAdapter m_dataAdapter = new System.Data.SQLite.SQLiteDataAdapter("select value from Constants", m_dbConnection);
|
|
|
- DataSet ds = new DataSet();
|
|
|
- m_dataAdapter.Fill(ds);
|
|
|
- DataTable dt = ds.Tables[0];
|
|
|
- string ConstantsStr = dt.Rows[0][0].ToString();
|
|
|
- ConstantsStr = ConstantsStr.Replace(" ", "");
|
|
|
- string[] ConstantsStr2 = ConstantsStr.Split(',');
|
|
|
+ _sTDEditor.LoadConstants();
|
|
|
+ string[] ConstantsStr2 = _sTDEditor.ConstantsStr;
|
|
|
m_SubMidWindow.m_STDEditor.comboBox_Constants.Items.Clear();
|
|
|
m_SubMidWindow.m_STDEditor.comboBox_Constants.Items.AddRange(ConstantsStr2);
|
|
|
- m_dbConnection.Close();
|
|
|
}
|
|
|
catch (Exception ee)
|
|
|
{
|
|
@@ -1045,72 +549,36 @@ namespace OTSPartA_STDEditor
|
|
|
|
|
|
public void AddSTDGroupsToAttribute()
|
|
|
{
|
|
|
- try
|
|
|
- {
|
|
|
- System.Data.SQLite.SQLiteConnection m_dbConnection = new System.Data.SQLite.SQLiteConnection("data source='" + STDDBAddress + "'");
|
|
|
- m_dbConnection.Open();
|
|
|
- System.Data.SQLite.SQLiteDataAdapter m_dataAdapter = new System.Data.SQLite.SQLiteDataAdapter("select name,id from STDGroups order by iorder", m_dbConnection);
|
|
|
- DataSet ds = new DataSet();
|
|
|
- m_dataAdapter.Fill(ds);
|
|
|
- DataTable dt = ds.Tables[0];
|
|
|
- if (dt != null)
|
|
|
- {
|
|
|
- if (dt.Rows.Count >= 0)
|
|
|
- {
|
|
|
- GroupIdDictionaryFromId.Clear();
|
|
|
- GroupIdDictionaryFromName.Clear();
|
|
|
-
|
|
|
- List<string> ss = new List<string>();
|
|
|
- if (dt.Select("id='0'").Length == 0)
|
|
|
- {
|
|
|
- GroupIdDictionaryFromId.Add(0, "Default");
|
|
|
- GroupIdDictionaryFromName.Add("Default", 0);
|
|
|
- ss.Add("Default");
|
|
|
- }
|
|
|
- foreach (DataRow item in dt.Rows)
|
|
|
- {
|
|
|
- ss.Add(item["name"].ToString());
|
|
|
- GroupIdDictionaryFromName.Add(item["name"].ToString(), int.Parse(item["id"].ToString()));
|
|
|
- GroupIdDictionaryFromId.Add(int.Parse(item["id"].ToString()), item["name"].ToString());
|
|
|
- }
|
|
|
- SourceGrid.Cells.Editors.ComboBox GroupIdCBBox = new SourceGrid.Cells.Editors.ComboBox(typeof(string));
|
|
|
- GroupIdCBBox.StandardValues = ss;
|
|
|
- GroupIdCBBox.EditableMode = SourceGrid.EditableMode.SingleClick | SourceGrid.EditableMode.Focus;
|
|
|
- m_Attributes.Grid_Attributes[11, 1] = new SourceGrid.Cells.Cell("Default", GroupIdCBBox);
|
|
|
- GroupIdCBBox.Control.DropDownStyle = ComboBoxStyle.DropDownList; //设置下拉框为不可以编辑的状态
|
|
|
- }
|
|
|
- }
|
|
|
- //string ConstantsStr = dt.Rows[0][0].ToString();
|
|
|
- m_dbConnection.Close();
|
|
|
- }
|
|
|
- catch (Exception ee)
|
|
|
+ List<string> ss = new List<string>();
|
|
|
+ ss.Add("Default");
|
|
|
+ foreach (var item in _sTDEditor.GroupDictionary)
|
|
|
{
|
|
|
- MessageBox.Show(ee.ToString());
|
|
|
+ ss.Add(item.Value.name.ToString());
|
|
|
}
|
|
|
+ SourceGrid.Cells.Editors.ComboBox GroupIdCBBox = new SourceGrid.Cells.Editors.ComboBox(typeof(string));
|
|
|
+ GroupIdCBBox.StandardValues = ss;
|
|
|
+ GroupIdCBBox.EditableMode = SourceGrid.EditableMode.SingleClick | SourceGrid.EditableMode.Focus;
|
|
|
+ m_Attributes.Grid_Attributes[11, 1] = new SourceGrid.Cells.Cell("Default", GroupIdCBBox);
|
|
|
+ GroupIdCBBox.Control.DropDownStyle = ComboBoxStyle.DropDownList; //设置下拉框为不可以编辑的状态
|
|
|
}
|
|
|
|
|
|
void SetNonexistentGroupsToDefault()
|
|
|
{
|
|
|
- foreach (KeyValuePair<int, STDdata> kv in STDDictionary)
|
|
|
- {
|
|
|
- if (!GroupIdDictionaryFromId.Keys.Contains(int.Parse(kv.Value.GroupId)))
|
|
|
- {
|
|
|
- kv.Value.GroupId = "0";
|
|
|
- }
|
|
|
- }
|
|
|
+ _sTDEditor.SetNonexistentGroupsToDefault(); ;
|
|
|
m_Attributes.Grid_Attributes.Refresh();
|
|
|
}
|
|
|
+
|
|
|
private void ribbon_GroupNameMaintenance_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
//STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row, 0].Tag.ToString())].GroupId = GroupIdDictionaryFromName[m_Attributes.Grid_Attributes[10, 1].Value.ToString()].ToString();
|
|
|
- int selGroupId = GroupIdDictionaryFromName[m_Attributes.Grid_Attributes[11, 1].Value.ToString()];
|
|
|
+ int selGroupId = _sTDEditor.GroupIdDictionaryFromName[m_Attributes.Grid_Attributes[11, 1].Value.ToString()];
|
|
|
Form_GroupId form_GroupId = new Form_GroupId(STDDBAddress, this);
|
|
|
DialogResult dialogResult = form_GroupId.ShowDialog();
|
|
|
if (dialogResult == DialogResult.Yes)
|
|
|
{
|
|
|
AddSTDGroupsToAttribute();
|
|
|
//SetNonexistentGroupsToDefault();
|
|
|
- m_Attributes.Grid_Attributes[11, 1].Value = GroupIdDictionaryFromId[selGroupId];
|
|
|
+ m_Attributes.Grid_Attributes[11, 1].Value = _sTDEditor.GroupIdDictionaryFromId[selGroupId];
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1121,9 +589,9 @@ namespace OTSPartA_STDEditor
|
|
|
|
|
|
private void rbClose_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
- if (!Isoldversion)
|
|
|
+ if (!_sTDEditor.Isoldversion)
|
|
|
{
|
|
|
- if (!EqualsBetweenDictionary(STDDictionaryInitial, STDDictionary) || IsModified)
|
|
|
+ if (!EqualsBetweenDictionary() || IsModified)
|
|
|
{
|
|
|
DialogResult dr = MessageBox.Show("Whether to save the current modification?", "Tip", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
|
|
if (dr == DialogResult.Yes)
|
|
@@ -1140,13 +608,13 @@ namespace OTSPartA_STDEditor
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- STDDictionaryInitial.Clear();
|
|
|
- }
|
|
|
+ //else
|
|
|
+ //{
|
|
|
+ // STDDictionaryInitial.Clear();
|
|
|
+ //}
|
|
|
FormForWaiting forWaiting = new FormForWaiting();
|
|
|
forWaiting.Show();
|
|
|
- bool result = SaveDictionaryToClassify(STDDBAddress);
|
|
|
+ bool result = _sTDEditor.SaveDictionaryToClassify();
|
|
|
if (result)
|
|
|
{
|
|
|
forWaiting.Close();
|
|
@@ -1226,11 +694,10 @@ namespace OTSPartA_STDEditor
|
|
|
|
|
|
void InitForms(string DBAddress)
|
|
|
{
|
|
|
- STDDictionary.Clear();
|
|
|
ButtonStatusOpen();
|
|
|
- bool ret = LoadClassifyToDictionary(DBAddress, ref STDDictionary);
|
|
|
- STDDictionaryInitial = Clone(STDDictionary) as Dictionary<int, STDdata>;
|
|
|
- if (!ret)
|
|
|
+
|
|
|
+ _sTDEditor = new STDInfo(DBAddress);
|
|
|
+ if (_sTDEditor.STDDictionary == null|| _sTDEditor.GroupDictionary==null)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
@@ -1244,18 +711,13 @@ namespace OTSPartA_STDEditor
|
|
|
m_SubMidWindow.Show(dockPanel1, DockState.Document);
|
|
|
dockPanel1.DockLeftPortion = 360;
|
|
|
dockPanel1.DockRightPortion = 381;
|
|
|
-
|
|
|
- if (m_SubMidWindow.m_STDEditor.m_sc != null)
|
|
|
- {
|
|
|
- m_SubMidWindow.m_STDEditor.m_sc.CloseDB();
|
|
|
- }
|
|
|
-
|
|
|
- m_SubMidWindow.m_STDEditor.m_sc = new SqlLiteClass(DBAddress);
|
|
|
-
|
|
|
- LoadConstants(DBAddress);
|
|
|
AddSTDGroupsToAttribute();
|
|
|
+ m_SubMidWindow.m_STDEditor.comboBox_Constants.Items.Clear();
|
|
|
+ if(_sTDEditor.ConstantsStr != null)
|
|
|
+ {
|
|
|
+ m_SubMidWindow.m_STDEditor.comboBox_Constants.Items.AddRange(_sTDEditor.ConstantsStr);
|
|
|
+ }
|
|
|
m_SubMidWindow.m_STDEditor.textbox_STDEditor.Text = "";
|
|
|
-
|
|
|
if (m_STDRuleslist.Grid_Minerals.RowsCount > 1)
|
|
|
{
|
|
|
m_STDRuleslist.button_UpOrder.Enabled = false;
|
|
@@ -1270,40 +732,21 @@ namespace OTSPartA_STDEditor
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- bool EqualsBetweenDictionary(Dictionary<int, STDdata> STDDictionaryInitial, Dictionary<int, STDdata> STDDictionary)
|
|
|
- {
|
|
|
- if (STDDictionaryInitial.Count != STDDictionary.Count)
|
|
|
- {
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- foreach (var key in STDDictionaryInitial.Keys)
|
|
|
- {
|
|
|
- if (STDDictionary.Keys.Contains(key))
|
|
|
- {
|
|
|
- if (!STDDictionaryInitial[key].Equals(STDDictionary[key]))
|
|
|
- {
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return true;
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
private void Form_ConstantsEditor2_FormClosing(object sender, FormClosingEventArgs e)
|
|
|
{
|
|
|
- if (Isoldversion)
|
|
|
+ if(_sTDEditor==null)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (_sTDEditor.Isoldversion)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
if (m_STDRuleslist.Text != "")
|
|
|
{
|
|
|
- if (!EqualsBetweenDictionary(STDDictionaryInitial, STDDictionary) || IsModified)
|
|
|
+ if (!EqualsBetweenDictionary() || IsModified)
|
|
|
{
|
|
|
DialogResult dr = MessageBox.Show("Whether to save the current modification", "Tip", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
|
|
if (dr == DialogResult.Yes)
|
|
@@ -1321,13 +764,13 @@ namespace OTSPartA_STDEditor
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- STDDictionaryInitial.Clear();
|
|
|
- }
|
|
|
+ //else
|
|
|
+ //{
|
|
|
+ // STDDictionaryInitial.Clear();
|
|
|
+ //}
|
|
|
FormForWaiting forWaiting = new FormForWaiting();
|
|
|
forWaiting.Show();
|
|
|
- bool result = SaveDictionaryToClassify(STDDBAddress);
|
|
|
+ bool result = _sTDEditor.SaveDictionaryToClassify();
|
|
|
if (result)
|
|
|
{
|
|
|
forWaiting.Close();
|
|
@@ -1340,9 +783,9 @@ namespace OTSPartA_STDEditor
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- foreach (KeyValuePair<int, STDdata> kv in STDDictionary)
|
|
|
+ foreach (KeyValuePair<int, STDdata> kv in _sTDEditor.STDDictionary)
|
|
|
{
|
|
|
- if (!GroupIdDictionaryFromId.Keys.Contains(int.Parse(kv.Value.GroupId)))
|
|
|
+ if (!_sTDEditor.GroupIdDictionaryFromId.Keys.Contains(int.Parse(kv.Value.GroupId)))
|
|
|
{
|
|
|
MessageBox.Show("There is non-existent grouping informations in the classification, please adjust!");
|
|
|
e.Cancel = true;
|
|
@@ -1353,7 +796,10 @@ namespace OTSPartA_STDEditor
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ bool EqualsBetweenDictionary()
|
|
|
+ {
|
|
|
+ return _sTDEditor.EqualsBetweenDictionary();
|
|
|
+ }
|
|
|
private void rbNew_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
SaveFileDialog saveFile = new SaveFileDialog();
|