public void NewPolicy() { if (m_IsInitializing == false) { ConfigForm_Load(this, EventArgs.Empty); } U50PolicyInfo policyInfo = new U50PolicyInfo(); policyInfo.Guid = Guid.NewGuid().ToString(); do { policyInfo.Name = string.Format("U50策略{0}", m_PolicyCount++); if (m_PolicyName.Contains(policyInfo.Name) == false) { break; } } while (true); // U50策略01 TreeNode newTreeNodePolicy = new TreeNode(policyInfo.Name); TreeNode newTreeNodePolicySub = new TreeNode("常规选项"); TreeNode newTreeNodePolicySub1 = new TreeNode("取样方法"); TreeNode newTreeNodePolicySub2 = new TreeNode("形态函数"); TreeNode newTreeNodePolicySub3 = new TreeNode("增强刷选"); newTreeNodePolicy.Nodes.Add(newTreeNodePolicySub); newTreeNodePolicy.Nodes.Add(newTreeNodePolicySub1); newTreeNodePolicy.Nodes.Add(newTreeNodePolicySub2); newTreeNodePolicy.Nodes.Add(newTreeNodePolicySub3); PolicyBControl configBControl = new PolicyBControl { Dock = DockStyle.Fill, Visible = false }; this.m_AllConfigControlInfo.Add(newTreeNodePolicy, configBControl); this.m_AllConfigControlInfo.Add(newTreeNodePolicySub, configBControl); this.Panel.Controls.Add(configBControl); PolicyCControl configCControl = new PolicyCControl { Dock = DockStyle.Fill, Visible = false }; policyInfo.Policy = configCControl.GetConfigPolicy(); this.m_AllConfigControlInfo.Add(newTreeNodePolicySub1, configCControl); this.Panel.Controls.Add(configCControl); PolicyDControl configDControl = new PolicyDControl { Dock = DockStyle.Fill, Visible = false }; policyInfo.Filtrate = configDControl.GetConfigFiltrate(); this.m_AllConfigControlInfo.Add(newTreeNodePolicySub2, configDControl); this.Panel.Controls.Add(configDControl); PolicyEControl configEControl = new PolicyEControl { Dock = DockStyle.Fill, Visible = false }; configEControl.EventButtonSetting += new EventHandler(OnEventButtonSetting); m_ButtonSetting.Add(configEControl, newTreeNodePolicySub2); policyInfo.Extend = configEControl.GetConfigExtend(); this.m_AllConfigControlInfo.Add(newTreeNodePolicySub3, configEControl); this.Panel.Controls.Add(configEControl); this.TreeView.Nodes.Add(newTreeNodePolicy); this.TreeView.SelectedNode = newTreeNodePolicy; m_NewTreeNode.Add(newTreeNodePolicy); m_TreeNodePolicyInfo.Add(newTreeNodePolicy, policyInfo); }
public void NewPolicy() { if ( m_IsInitializing == false ) ConfigForm_Load( this, EventArgs.Empty ); U50PolicyInfo policyInfo = new U50PolicyInfo(); policyInfo.Guid = Guid.NewGuid().ToString(); do { policyInfo.Name = string.Format( "U50策略{0}", m_PolicyCount++ ); if ( m_PolicyName.Contains( policyInfo.Name ) == false ) break; } while ( true ); // U50策略01 TreeNode newTreeNodePolicy = new TreeNode( policyInfo.Name ); TreeNode newTreeNodePolicySub = new TreeNode( "常规选项" ); TreeNode newTreeNodePolicySub1 = new TreeNode( "取样方法" ); TreeNode newTreeNodePolicySub2 = new TreeNode( "形态函数" ); TreeNode newTreeNodePolicySub3 = new TreeNode( "增强刷选" ); newTreeNodePolicy.Nodes.Add( newTreeNodePolicySub ); newTreeNodePolicy.Nodes.Add( newTreeNodePolicySub1 ); newTreeNodePolicy.Nodes.Add( newTreeNodePolicySub2 ); newTreeNodePolicy.Nodes.Add( newTreeNodePolicySub3 ); PolicyBControl configBControl = new PolicyBControl { Dock = DockStyle.Fill, Visible = false }; this.m_AllConfigControlInfo.Add( newTreeNodePolicy, configBControl ); this.m_AllConfigControlInfo.Add( newTreeNodePolicySub, configBControl ); this.Panel.Controls.Add( configBControl ); PolicyCControl configCControl = new PolicyCControl { Dock = DockStyle.Fill, Visible = false }; policyInfo.Policy = configCControl.GetConfigPolicy(); this.m_AllConfigControlInfo.Add( newTreeNodePolicySub1, configCControl ); this.Panel.Controls.Add( configCControl ); PolicyDControl configDControl = new PolicyDControl { Dock = DockStyle.Fill, Visible = false }; policyInfo.Filtrate = configDControl.GetConfigFiltrate(); this.m_AllConfigControlInfo.Add( newTreeNodePolicySub2, configDControl ); this.Panel.Controls.Add( configDControl ); PolicyEControl configEControl = new PolicyEControl { Dock = DockStyle.Fill, Visible = false }; configEControl.EventButtonSetting += new EventHandler( OnEventButtonSetting ); m_ButtonSetting.Add( configEControl, newTreeNodePolicySub2 ); policyInfo.Extend = configEControl.GetConfigExtend(); this.m_AllConfigControlInfo.Add( newTreeNodePolicySub3, configEControl ); this.Panel.Controls.Add( configEControl ); this.TreeView.Nodes.Add( newTreeNodePolicy ); this.TreeView.SelectedNode = newTreeNodePolicy; m_NewTreeNode.Add( newTreeNodePolicy ); m_TreeNodePolicyInfo.Add( newTreeNodePolicy, policyInfo ); }
private void ButtonOK_Click(object sender, EventArgs e) { foreach (var item in m_DeleteTreeNode) { UserControl outConfigControl = null; if (this.m_AllConfigControlInfo.TryGetValue(item.Nodes[0], out outConfigControl) == true) { if (outConfigControl == m_CurrentConfigControl) { this.TreeView.SelectedNode = m_MainTreeNodeSub; } this.Panel.Controls.Remove(outConfigControl); } if (this.m_AllConfigControlInfo.TryGetValue(item.Nodes[1], out outConfigControl) == true) { if (outConfigControl == m_CurrentConfigControl) { this.TreeView.SelectedNode = m_MainTreeNodeSub; } this.Panel.Controls.Remove(outConfigControl); } if (this.m_AllConfigControlInfo.TryGetValue(item.Nodes[2], out outConfigControl) == true) { if (outConfigControl == m_CurrentConfigControl) { this.TreeView.SelectedNode = m_MainTreeNodeSub; } this.Panel.Controls.Remove(outConfigControl); } if (this.m_AllConfigControlInfo.TryGetValue(item.Nodes[3], out outConfigControl) == true) { if (outConfigControl == m_CurrentConfigControl) { this.TreeView.SelectedNode = m_MainTreeNodeSub; } this.Panel.Controls.Remove(outConfigControl); } this.m_AllConfigControlInfo.Remove(item.Nodes[0]); this.m_AllConfigControlInfo.Remove(item.Nodes[1]); this.m_AllConfigControlInfo.Remove(item.Nodes[2]); this.m_AllConfigControlInfo.Remove(item.Nodes[3]); this.m_AllConfigControlInfo.Remove(item); U50PolicyInfo outPolicyInfo = null; if (this.m_TreeNodePolicyInfo.TryGetValue(item, out outPolicyInfo) == true) { this.m_TreeNodePolicyInfo.Remove(item); PolicyManager.Instance.RemovePolicyInfoByGuid(outPolicyInfo.Guid); } } foreach (var item in m_TreeNodePolicyInfo) { UserControl outConfigControl = null; if (m_AllConfigControlInfo.TryGetValue(item.Key.Nodes[1], out outConfigControl) == false) { continue; } PolicyCControl configCControl = outConfigControl as PolicyCControl; if (configCControl == null) { continue; } item.Value.Policy = configCControl.GetConfigPolicy(); if (m_AllConfigControlInfo.TryGetValue(item.Key.Nodes[2], out outConfigControl) == false) { continue; } PolicyDControl configDControl = outConfigControl as PolicyDControl; if (configDControl == null) { continue; } item.Value.Filtrate = configDControl.GetConfigFiltrate(); if (m_AllConfigControlInfo.TryGetValue(item.Key.Nodes[3], out outConfigControl) == false) { continue; } PolicyEControl configEControl = outConfigControl as PolicyEControl; if (configEControl == null) { continue; } item.Value.Extend = configEControl.GetConfigExtend(); if (m_NewTreeNode.Contains(item.Key) == true) { PolicyManager.Instance.AddStockInfo(item.Value); } } U50GlobalSetting.SavePolicySetting(U50GlobalSetting.PolicyFilePath, PolicyManager.Instance.ToArray()); U50GlobalSetting.SaveGlobalRegistry(); m_NewTreeNode.Clear(); m_DeleteTreeNode.Clear(); }