private void ButtonNewSubItem_Click(object sender, EventArgs e) { TreeNode treeNodeSelected = this.TreeView.SelectedNode; if (treeNodeSelected == null) { return; } TreeNode treeNodeParent = treeNodeSelected.Parent == null ? treeNodeSelected : treeNodeSelected.Parent; TreeNodePlateName outPlateName = null; if (m_PlateName.TryGetValue(treeNodeParent, out outPlateName) == false) { return; } string strVarietyName = string.Empty; do { strVarietyName = string.Format("新建的分类{0}", m_VarietyCount++); bool isOK = true; foreach (var item in outPlateName.VarietyName) { if (item.Value == strVarietyName) { isOK = false; break; } } if (isOK == true) { break; } } while (true); TreeNode newTreeNodeVariety = new TreeNode(strVarietyName); ConfigAControl configAControl = new ConfigAControl(); configAControl.Dock = DockStyle.Fill; configAControl.ButtonSaveChanged += new EventHandler(ConfigAControl_ButtonSaveChanged); this.m_AllConfigControlInfo.Add(newTreeNodeVariety, configAControl); treeNodeParent.Nodes.Add(newTreeNodeVariety); // outPlateName.VarietyName.Add(newTreeNodeVariety, strVarietyName); this.Panel.Controls.Add(configAControl); this.TreeView.SelectedNode = newTreeNodeVariety; this.ButtonSave.Enabled = true; }
private void LoadConfigFormInfo() { if (m_IsInitializing == false) { ConfigForm_Load(this, EventArgs.Empty); } this.TreeView.Nodes.Clear(); this.Panel.Controls.Clear(); PlateInfo[] plateInfos = GlobalSetting.PlateInfos; for (int iIndex = 0; iIndex < plateInfos.Length; iIndex++) { PlateInfo plateInfo = plateInfos[iIndex]; TreeNode newTreeNodeParent = new TreeNode(plateInfo.Name); // TreeNodePlateName treeNodePlateName = new TreeNodePlateName(); treeNodePlateName.PlateName = plateInfo.Name; TreeNode newTreeNodeAll = new TreeNode("所有的股票"); newTreeNodeParent.Nodes.Add(newTreeNodeAll); ConfigBControl configBControlAll = new ConfigBControl(); configBControlAll.Visible = false; configBControlAll.Dock = DockStyle.Fill; this.m_AllConfigControlInfo.Add(newTreeNodeParent, configBControlAll); this.m_AllConfigControlInfo.Add(newTreeNodeAll, configBControlAll); for (int iIndex2 = 0; iIndex2 < plateInfo.VarietyInfos.Length; iIndex2++) { VarietyInfo varietyInfo = plateInfo.VarietyInfos[iIndex2]; TreeNode newTreeNodeSub = new TreeNode(varietyInfo.Name); newTreeNodeParent.Nodes.Add(newTreeNodeSub); // treeNodePlateName.VarietyName.Add(newTreeNodeSub, varietyInfo.Name); ConfigAControl configAControlSub = new ConfigAControl(); configAControlSub.Visible = false; configAControlSub.Dock = DockStyle.Fill; configAControlSub.ButtonSaveChanged += new EventHandler(ConfigAControl_ButtonSaveChanged); this.m_AllConfigControlInfo.Add(newTreeNodeSub, configAControlSub); for (int iIndex3 = 0; iIndex3 < varietyInfo.FileInfos.Length; iIndex3++) { FileInfo fileInfo = varietyInfo.FileInfos[iIndex3]; ListViewItem listViewItemSub = new ListViewItem(fileInfo.StockName); ListViewItem.ListViewSubItem listViewSubItemSub1 = new ListViewItem.ListViewSubItem(listViewItemSub, fileInfo.StockSymbol); ListViewItem.ListViewSubItem listViewSubItemSub2 = new ListViewItem.ListViewSubItem(listViewItemSub, fileInfo.FilePath); listViewItemSub.SubItems.Add(listViewSubItemSub1); listViewItemSub.SubItems.Add(listViewSubItemSub2); configAControlSub.ListView.Items.Add(listViewItemSub); ListViewItem listViewItemAll = new ListViewItem(fileInfo.StockName); ListViewItem.ListViewSubItem listViewSubItemAll1 = new ListViewItem.ListViewSubItem(listViewItemAll, fileInfo.StockSymbol); ListViewItem.ListViewSubItem listViewSubItemAll2 = new ListViewItem.ListViewSubItem(listViewItemAll, fileInfo.FilePath); listViewItemAll.SubItems.Add(listViewSubItemAll1); listViewItemAll.SubItems.Add(listViewSubItemAll2); configBControlAll.ListView.Items.Add(listViewItemAll); } this.Panel.Controls.Add(configAControlSub); } this.TreeView.Nodes.Add(newTreeNodeParent); this.Panel.Controls.Add(configBControlAll); m_PlateName.Add(newTreeNodeParent, treeNodePlateName); } }
private void SaveConfigFormInfo() { List <PlateInfo> plateInfoList = new List <PlateInfo>(); for (int iIndex = 0; iIndex < this.TreeView.Nodes.Count; iIndex++) { TreeNode treeNodeParent = this.TreeView.Nodes[iIndex]; if (treeNodeParent == null) { continue; } PlateInfo plateInfo = new PlateInfo(); plateInfo.Name = treeNodeParent.Text; plateInfo.VarietyInfos = new VarietyInfo[0]; plateInfoList.Add(plateInfo); List <VarietyInfo> varietyInfoList = new List <VarietyInfo>(); for (int iIndex2 = 1; iIndex2 < treeNodeParent.Nodes.Count; iIndex2++) { TreeNode treeNodeParentSub = treeNodeParent.Nodes[iIndex2]; if (treeNodeParentSub == null) { continue; } VarietyInfo varietyInfo = new VarietyInfo(); varietyInfo.Name = treeNodeParentSub.Text; varietyInfo.FileInfos = new FileInfo[0]; varietyInfoList.Add(varietyInfo); UserControl outUserControl = null; if (m_AllConfigControlInfo.TryGetValue(treeNodeParentSub, out outUserControl) == true) { ConfigAControl outConfigAControl = outUserControl as ConfigAControl; if (outConfigAControl != null) { List <FileInfo> fileInfoList = new List <FileInfo>(); for (int iIndex3 = 0; iIndex3 < outConfigAControl.ListView.Items.Count; iIndex3++) { ListViewItem listViewItem = outConfigAControl.ListView.Items[iIndex3]; FileInfo fileInfo = new FileInfo(); fileInfo.StockName = listViewItem.Text; fileInfo.StockSymbol = listViewItem.SubItems[1].Text; fileInfo.FilePath = listViewItem.SubItems[2].Text; fileInfoList.Add(fileInfo); } varietyInfo.FileInfos = fileInfoList.ToArray(); } } } plateInfo.VarietyInfos = varietyInfoList.ToArray(); } GlobalSetting.SaveConfigSetting(GlobalSetting.ConfigFilePath, plateInfoList.ToArray()); }
private void LoadConfigFormInfo() { if ( m_IsInitializing == false ) ConfigForm_Load( this, EventArgs.Empty ); this.TreeView.Nodes.Clear(); this.Panel.Controls.Clear(); PlateInfo[] plateInfos = GlobalSetting.PlateInfos; for ( int iIndex = 0; iIndex < plateInfos.Length; iIndex++ ) { PlateInfo plateInfo = plateInfos[iIndex]; TreeNode newTreeNodeParent = new TreeNode( plateInfo.Name ); // TreeNodePlateName treeNodePlateName = new TreeNodePlateName(); treeNodePlateName.PlateName = plateInfo.Name; TreeNode newTreeNodeAll = new TreeNode( "所有的股票" ); newTreeNodeParent.Nodes.Add( newTreeNodeAll ); ConfigBControl configBControlAll = new ConfigBControl(); configBControlAll.Visible = false; configBControlAll.Dock = DockStyle.Fill; this.m_AllConfigControlInfo.Add( newTreeNodeParent, configBControlAll ); this.m_AllConfigControlInfo.Add( newTreeNodeAll, configBControlAll ); for ( int iIndex2 = 0; iIndex2 < plateInfo.VarietyInfos.Length; iIndex2++ ) { VarietyInfo varietyInfo = plateInfo.VarietyInfos[iIndex2]; TreeNode newTreeNodeSub = new TreeNode( varietyInfo.Name ); newTreeNodeParent.Nodes.Add( newTreeNodeSub ); // treeNodePlateName.VarietyName.Add( newTreeNodeSub, varietyInfo.Name ); ConfigAControl configAControlSub = new ConfigAControl(); configAControlSub.Visible = false; configAControlSub.Dock = DockStyle.Fill; configAControlSub.ButtonSaveChanged += new EventHandler( ConfigAControl_ButtonSaveChanged ); this.m_AllConfigControlInfo.Add( newTreeNodeSub, configAControlSub ); for ( int iIndex3 = 0; iIndex3 < varietyInfo.FileInfos.Length; iIndex3++ ) { FileInfo fileInfo = varietyInfo.FileInfos[iIndex3]; ListViewItem listViewItemSub = new ListViewItem( fileInfo.StockName ); ListViewItem.ListViewSubItem listViewSubItemSub1 = new ListViewItem.ListViewSubItem( listViewItemSub, fileInfo.StockSymbol ); ListViewItem.ListViewSubItem listViewSubItemSub2 = new ListViewItem.ListViewSubItem( listViewItemSub, fileInfo.FilePath ); listViewItemSub.SubItems.Add( listViewSubItemSub1 ); listViewItemSub.SubItems.Add( listViewSubItemSub2 ); configAControlSub.ListView.Items.Add( listViewItemSub ); ListViewItem listViewItemAll = new ListViewItem( fileInfo.StockName ); ListViewItem.ListViewSubItem listViewSubItemAll1 = new ListViewItem.ListViewSubItem( listViewItemAll, fileInfo.StockSymbol ); ListViewItem.ListViewSubItem listViewSubItemAll2 = new ListViewItem.ListViewSubItem( listViewItemAll, fileInfo.FilePath ); listViewItemAll.SubItems.Add( listViewSubItemAll1 ); listViewItemAll.SubItems.Add( listViewSubItemAll2 ); configBControlAll.ListView.Items.Add( listViewItemAll ); } this.Panel.Controls.Add( configAControlSub ); } this.TreeView.Nodes.Add( newTreeNodeParent ); this.Panel.Controls.Add( configBControlAll ); m_PlateName.Add( newTreeNodeParent, treeNodePlateName ); } }
private void ButtonNewSubItem_Click( object sender, EventArgs e ) { TreeNode treeNodeSelected = this.TreeView.SelectedNode; if ( treeNodeSelected == null ) return; TreeNode treeNodeParent = treeNodeSelected.Parent == null ? treeNodeSelected : treeNodeSelected.Parent; TreeNodePlateName outPlateName = null; if ( m_PlateName.TryGetValue( treeNodeParent, out outPlateName ) == false ) return; string strVarietyName = string.Empty; do { strVarietyName = string.Format( "新建的分类{0}", m_VarietyCount++ ); bool isOK = true; foreach ( var item in outPlateName.VarietyName ) { if ( item.Value == strVarietyName ) { isOK = false; break; } } if ( isOK == true ) break; } while ( true ); TreeNode newTreeNodeVariety = new TreeNode( strVarietyName ); ConfigAControl configAControl = new ConfigAControl(); configAControl.Dock = DockStyle.Fill; configAControl.ButtonSaveChanged += new EventHandler( ConfigAControl_ButtonSaveChanged ); this.m_AllConfigControlInfo.Add( newTreeNodeVariety, configAControl ); treeNodeParent.Nodes.Add( newTreeNodeVariety ); // outPlateName.VarietyName.Add( newTreeNodeVariety, strVarietyName ); this.Panel.Controls.Add( configAControl ); this.TreeView.SelectedNode = newTreeNodeVariety; this.ButtonSave.Enabled = true; }