123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Data;
- using System.Windows.Forms;
- using System.Drawing;
- namespace IControls_FireManager
- {
-
-
- public static class _Tree
- {
-
- public static TreeView Create(string TreeViewName)
- {
- TreeView treeview = new TreeView();
- treeview.Dock = System.Windows.Forms.DockStyle.Fill;
- treeview.Location = new System.Drawing.Point(0, 0);
- treeview.Name = TreeViewName;
- return treeview;
- }
-
- public static bool DelNodeName_By_Name(TreeView pTreeView, string Name)
- {
- TreeNode[] Ctrls = pTreeView.Nodes.Find(Name, true);
- if (Ctrls.Length > 0)
- {
- try
- {
- Ctrls[0].Remove();
- return true;
- }
- catch { return false; }
- }
- return false;
- }
-
- public static bool DelNodeName_By_Name_Check_ReceiverID(TreeView pTreeView, string Name, string RECEIVER_ID)
- {
- TreeNode[] Ctrls = pTreeView.Nodes.Find(Name, true);
- if (Ctrls.Length > 0)
- {
- try
- {
-
- if(Ctrls[0].Parent.Parent.Name==RECEIVER_ID)
- Ctrls[0].Remove();
- return true;
- }
- catch { return false; }
- }
- return false;
- }
-
- public static bool SetNodeText_By_Name(TreeView pTreeView, string Name, string Text)
- {
- TreeNode[] Ctrls = pTreeView.Nodes.Find(Name, true);
- if (Ctrls.Length > 0)
- {
- try
- {
- Ctrls[0].Text = Text;
- return true;
- }
- catch { return false; }
- }
- return false;
- }
-
- public static bool SetNodeSelectedImageIndex_By_Name(TreeView pTreeView, string Name, int ImageIndex)
- {
- TreeNode[] Ctrls = pTreeView.Nodes.Find(Name, true);
- if (Ctrls.Length > 0)
- {
- try
- {
- Ctrls[0].SelectedImageIndex = ImageIndex;
- return true;
- }
- catch { return false; }
- }
- return false;
- }
-
- public static bool SetNodeColor_By_Name(TreeView pTreeView, string Name, Color pColor)
- {
- TreeNode[] Ctrls = pTreeView.Nodes.Find(Name, true);
- if (Ctrls.Length > 0)
- {
- try
- {
- Ctrls[0].ForeColor = pColor;
- return true;
- }
- catch { return false; }
- }
- return false;
- }
-
- public static TreeNode GetNode_By_Name(TreeView pTreeView, string Name)
- {
- TreeNode[] Ctrls = pTreeView.Nodes.Find(Name, true);
- if (Ctrls.Length > 0)
- {
- try
- {
- return Ctrls[0];
- }
- catch { return null; }
- }
- return null;
- }
-
-
- public static bool SetChildNodeText_By_Name(TreeView pTreeView, TreeNode pNode, string Name, string Text)
- {
- TreeNode[] Ctrls = pTreeView.Nodes[0].Nodes[pNode.Index].Nodes.Find(Name, true);
- if (Ctrls.Length > 0)
- {
- try
- {
- Ctrls[0].Text = Text;
- return true;
- }
- catch { return false; }
- }
- return false;
- }
-
-
-
- public static void NodeAdd(TreeView pTreeView, TreeNode pNode, string key, string text, Object_Type ImageType)
- {
- if (pNode.Nodes.ContainsKey(key) == true)
- {
- _Popup.MessageBoxPopup(0, _Text.OverLapSame, _Text.OK);
- return;
- }
- else
- {
-
- switch(pNode.Level)
- {
- case 0:
- pTreeView.Nodes.Add(key, text, (int)ImageType, (int)ImageType);
- break;
- case 1:
- pTreeView.Nodes[0].Nodes.Add(key, text, (int)ImageType, (int)ImageType);
- break;
- case 2:
- pTreeView.Nodes[0].Nodes[pNode.Index].Nodes.Add(key, text, (int)ImageType, (int)ImageType);
- break;
- case 3:
- pTreeView.Nodes[0].Nodes[pNode.Parent.Index].Nodes[pNode.Index].Nodes.Add(key, text, (int)ImageType, (int)ImageType);
- break;
- case 4:
- pTreeView.Nodes[0].Nodes[pNode.Parent.Parent.Index].Nodes[pNode.Parent.Index].Nodes[pNode.Index].Nodes.Add(key, text, (int)ImageType, (int)ImageType);
- break;
- }
-
-
- }
- }
-
-
-
-
- public static void NodeAdd_Root(TreeView pTreeView, string key, string text, Object_Type ImageType)
- {
- if (pTreeView.Nodes.ContainsKey(key) == true)
- {
- _Popup.MessageBoxPopup(0, _Text.OverLapSame, _Text.OK);
- return;
- }
- else
- {
-
- pTreeView.Nodes.Add(key, text, (int)ImageType, (int)ImageType);
-
-
-
- }
- }
-
- public static void NodeAdd_Root_Node(TreeView pTreeView, int root_index, string key, string text, Object_Type ImageType)
- {
- if (pTreeView.Nodes.ContainsKey(key) == true)
- {
- _Popup.MessageBoxPopup(0, _Text.OverLapSame, _Text.OK);
- return;
- }
- else
- {
-
- pTreeView.Nodes[root_index].Nodes.Add(key, text, (int)ImageType, (int)ImageType);
-
-
-
- }
- }
-
- public static void NodeAdd_Root_Node_Node(TreeView pTreeView, int root_index, int depth1_index, string key, string text, Object_Type ImageType)
- {
- if (pTreeView.Nodes.ContainsKey(key) == true)
- {
- _Popup.MessageBoxPopup(0, _Text.OverLapSame, _Text.OK);
- return;
- }
- else
- {
-
- pTreeView.Nodes[root_index].Nodes[depth1_index].Nodes.Add(key, text, (int)ImageType, (int)ImageType);
-
-
-
- }
- }
-
- public static void NodeAdd_Root_Node_Node_Node(TreeView pTreeView, int root_index, int depth1_index, int depth2_index, string key, string text, Object_Type ImageType)
- {
- if (pTreeView.Nodes.ContainsKey(key) == true)
- {
- _Popup.MessageBoxPopup(0, _Text.OverLapSame, _Text.OK);
- return;
- }
- else
- {
-
- pTreeView.Nodes[root_index].Nodes[depth1_index].Nodes[depth2_index].Nodes.Add(key, text, (int)ImageType, (int)ImageType);
-
-
-
- }
- }
-
- public static void NodeAdd_Root_Node_Node_Node_Node(TreeView pTreeView, int root_index, int depth1_index, int depth2_index, int depth3_index, string key, string text, Object_Type ImageType)
- {
- if (pTreeView.Nodes.ContainsKey(key) == true)
- {
- _Popup.MessageBoxPopup(0, _Text.OverLapSame, _Text.OK);
- return;
- }
- else
- {
-
- pTreeView.Nodes[root_index].Nodes[depth1_index].Nodes[depth2_index].Nodes[depth3_index].Nodes.Add(key, text, (int)ImageType, (int)ImageType);
-
-
- }
- }
-
-
-
- public static void TreeViewNodeTextChanged(TreeView pTreeView, string Text, ToolStripItemClickedEventArgs e)
- {
- if (e.ClickedItem.Text == Text)
- {
- pTreeView.LabelEdit = true;
- if (!pTreeView.SelectedNode.IsEditing)
- {
- pTreeView.SelectedNode.BeginEdit();
- }
- }
- }
-
-
-
- public static void ChangeColor_By_Data(TreeView pTreeView, string Name, string Data)
- {
-
- Color Apply_Color = Color.Blue;
- Color Basic_Color = Color.Black;
-
- TreeNode EditNode = GetNode_By_Name(pTreeView, Name);
-
- if (Data == null || Data.Trim().Length == 0 || Data == _Text.None)
- {
- EditNode.ForeColor = Basic_Color;
- }
- else
- {
- EditNode.ForeColor = Apply_Color;
- }
- }
-
-
-
-
-
- public static void Load_SystemTreeInfo(TreeView treeview)
- {
-
-
-
- treeview.Nodes.Clear();
-
-
- if (_Data.Project_Name == null)
- _Tree.NodeAdd_Root(treeview, _Text.UI_TREE_ROOT_KEY, _Text.DEFAULT_PROJECT_NAME, Object_Type.PROJECT);
- else
- _Tree.NodeAdd_Root(treeview, _Text.UI_TREE_ROOT_KEY, _Data.Project_Name, Object_Type.PROJECT);
-
- int TreeNodeInfo_Level_1th_MaxIndex = 0;
-
-
-
-
- foreach (string RECEIVER_ID in _Data.LIST_RECEIVER_ID)
- if (TreeNodeInfo_Level_1th_MaxIndex <= ((_RECEIVER)_Data.HASH_RECEIVER[RECEIVER_ID]).NODE.T_INDEX)
- TreeNodeInfo_Level_1th_MaxIndex = ((_RECEIVER)_Data.HASH_RECEIVER[RECEIVER_ID]).NODE.T_INDEX;
-
-
-
- for (int h = 0; h <= TreeNodeInfo_Level_1th_MaxIndex; h++)
- {
- foreach (string RECEIVER_ID in _Data.LIST_RECEIVER_ID)
- {
- if (((_RECEIVER)_Data.HASH_RECEIVER[RECEIVER_ID]).NODE.T_INDEX == h)
- {
- _RECEIVER RECEIVER = (_RECEIVER)_Data.HASH_RECEIVER[RECEIVER_ID];
-
-
-
- NodeAdd_Root_Node(treeview, 0, RECEIVER.ID, RECEIVER.KEY_NAME, Object_Type.RECEIVER);
-
-
-
- string temp_key = null;
- string temp_name = null;
-
- TreeNode Added_RECEIVER = _Tree.GetNode_By_Name(treeview, RECEIVER.ID);
-
-
-
-
- temp_key = ((_RECEIVER)_Data.HASH_RECEIVER[RECEIVER_ID]).Set_SubKey(RECEIVER, _Text.UI_TREE_INOUTPUT);
- temp_name = _Text.UI_TREE_INOUTPUT;
- _Tree.NodeAdd_Root_Node_Node(treeview, 0, Added_RECEIVER.Index, temp_key, temp_name, Object_Type.INOUT);
-
- TreeNode Added_INOUTPUT = _Tree.GetNode_By_Name(treeview, temp_key);
-
- temp_key = RECEIVER.Set_SubKey(RECEIVER, _Text.UI_TREE_COM_BOARD);
- temp_name = _Text.UI_TREE_COM_BOARD;
- _Tree.NodeAdd_Root_Node_Node_Node(treeview, 0, Added_RECEIVER.Index, Added_INOUTPUT.Index, temp_key, temp_name, Object_Type.COM_BOARD);
-
- TreeNode Added_COM_BOARD = _Tree.GetNode_By_Name(treeview, temp_key);
- for (int i = 1; i <= RECEIVER.COM_BOARD_MAX_NUM; i++)
- {
- temp_key = RECEIVER.Set_SubKey(RECEIVER, string.Format(_Text.UI_TREE_COM_BOARD_KEY, i));
- temp_name = ((_COM_BOARD)RECEIVER.Hash_COM_BOARD[temp_key]).Get_KEY_NAME();
- _Tree.NodeAdd_Root_Node_Node_Node_Node(treeview, 0, Added_RECEIVER.Index, Added_INOUTPUT.Index, Added_COM_BOARD.Index, temp_key, temp_name, Object_Type.COM_BOARDS);
- }
-
- temp_key = RECEIVER.Set_SubKey(RECEIVER, _Text.UI_TREE_IO_BOARD);
- _Tree.NodeAdd_Root_Node_Node_Node(treeview, 0, Added_RECEIVER.Index, Added_INOUTPUT.Index, temp_key, _Text.UI_TREE_IO_BOARD, Object_Type.IO_BOARD);
-
- TreeNode Added_IO_BOARD = _Tree.GetNode_By_Name(treeview, temp_key);
- for (int i = 1; i <= RECEIVER.IO_BOARD_MAX_NUM; i++)
- {
- temp_key = RECEIVER.Set_SubKey(RECEIVER, string.Format(_Text.UI_TREE_IO_BOARD_KEY, i));
- temp_name = ((_IO_BOARD)RECEIVER.Hash_IO_BOARD[temp_key]).Get_KEY_NAME();
- _Tree.NodeAdd_Root_Node_Node_Node_Node(treeview, 0, Added_RECEIVER.Index, Added_INOUTPUT.Index, Added_IO_BOARD.Index, temp_key, temp_name, Object_Type.IO_BOARD);
- }
-
- temp_key = RECEIVER.Set_SubKey(RECEIVER, _Text.UI_TREE_KEYPAD);
- _Tree.NodeAdd_Root_Node_Node_Node(treeview, 0, Added_RECEIVER.Index, Added_INOUTPUT.Index, temp_key, _Text.UI_TREE_KEYPAD, Object_Type.KEYPAD);
-
- temp_key = RECEIVER.Set_SubKey(RECEIVER, _Text.UI_TREE_EMERGENCY_BROADCAST);
- _Tree.NodeAdd_Root_Node_Node_Node(treeview, 0, Added_RECEIVER.Index, Added_INOUTPUT.Index, temp_key, _Text.UI_TREE_EMERGENCY_BROADCAST, Object_Type.EMERGENCY_BROADCAST);
-
-
-
-
- temp_key = RECEIVER.Set_SubKey(RECEIVER, _Text.UI_TREE_POINT);
- _Tree.NodeAdd_Root_Node_Node(treeview, 0, Added_RECEIVER.Index, temp_key, _Text.UI_TREE_POINT, Object_Type.POINT);
-
- TreeNode Added_POINT = _Tree.GetNode_By_Name(treeview, temp_key);
-
- temp_key = RECEIVER.Set_SubKey(RECEIVER, _Text.UI_TREE_POINT_INPUT);
- _Tree.NodeAdd_Root_Node_Node_Node(treeview, 0, Added_RECEIVER.Index, Added_POINT.Index, temp_key, _Text.UI_TREE_POINT_INPUT, Object_Type.INPUT);
-
- temp_key = RECEIVER.Set_SubKey(RECEIVER, _Text.UI_TREE_POINT_OUTPUT);
- _Tree.NodeAdd_Root_Node_Node_Node(treeview, 0, Added_RECEIVER.Index, Added_POINT.Index, temp_key, _Text.UI_TREE_POINT_OUTPUT, Object_Type.OUTPUT);
-
-
-
-
- temp_key = RECEIVER.Set_SubKey(RECEIVER, _Text.UI_TREE_OPER);
- _Tree.NodeAdd_Root_Node_Node(treeview, 0, Added_RECEIVER.Index, temp_key, _Text.UI_TREE_OPER, Object_Type.OPER);
-
- TreeNode Added_OPER = _Tree.GetNode_By_Name(treeview, temp_key);
-
- temp_key = RECEIVER.Set_SubKey(RECEIVER, _Text.UI_TREE_OPER_GROUP);
- _Tree.NodeAdd_Root_Node_Node_Node(treeview, 0, Added_RECEIVER.Index, Added_OPER.Index, temp_key, _Text.UI_TREE_OPER_GROUP, Object_Type.OPER_GROUP);
-
- temp_key = RECEIVER.Set_SubKey(RECEIVER, _Text.UI_TREE_OPER_SET);
- _Tree.NodeAdd_Root_Node_Node_Node(treeview, 0, Added_RECEIVER.Index, Added_OPER.Index, temp_key, _Text.UI_TREE_OPER_SET, Object_Type.OPER_SET);
-
-
-
-
- temp_key = RECEIVER.Set_SubKey(RECEIVER, _Text.UI_TREE_IMAGE);
- _Tree.NodeAdd_Root_Node_Node(treeview, 0, Added_RECEIVER.Index, temp_key, _Text.UI_TREE_IMAGE, Object_Type.IMAGE);
-
- }
- }
- }
-
- TreeNodeInfo_Level_1th_MaxIndex = 0;
-
-
-
-
-
-
-
-
-
-
- }
-
- public static void Save_SystemTreeInfo(TreeView treeview)
- {
- TreeNode result = null;
-
-
-
-
- foreach (string RECEIVER_ID in _Data.LIST_RECEIVER_ID)
- {
- result = GetNode_By_Name(treeview, RECEIVER_ID);
- if (result != null)
- {
-
-
-
- ((_RECEIVER)_Data.HASH_RECEIVER[RECEIVER_ID]).NODE.T_DEPTH = result.Level;
- ((_RECEIVER)_Data.HASH_RECEIVER[RECEIVER_ID]).NODE.T_INDEX = result.Index;
- ((_RECEIVER)_Data.HASH_RECEIVER[RECEIVER_ID]).NODE.T_PARENT = result.Parent.Name;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
- }
- }
- }
- }
|