void Init( object sender, EventArgs args ) { Server.InitLibrary( Environment.GetCommandLineArgs() ); Config.Load( false, false ); rankList = RankManager.Ranks.Select( r => r.Prefix + r.Name ).ToArray(); cFromRank.Items.AddRange( rankList ); cToRank.Items.AddRange( rankList ); using( LogRecorder recorder = new LogRecorder() ) { AutoRankManager.Init(); if( recorder.HasMessages ) { MessageBox.Show( recorder.MessageString, "Loading autorank.xml..." ); } } if( AutoRankManager.HasCriteria ) { foreach( Criterion crit in AutoRankManager.Criteria ) { ActionNode newNode = new ActionNode { Action = ActionType.Automatic, FromRank = crit.FromRank, ToRank = crit.ToRank }; if( crit.Condition is ConditionAND ) { newNode.Op = GroupNodeType.AND; } else if( crit.Condition is ConditionOR ) { newNode.Op = GroupNodeType.OR; } else if( crit.Condition is ConditionNAND ) { newNode.Op = GroupNodeType.NAND; } else if( crit.Condition is ConditionNOR ) { newNode.Op = GroupNodeType.NOR; } else { throw new FormatException(); } foreach( Condition subCondition in crit.Condition.Conditions ) { ImportCondition( newNode, subCondition ); } treeData.Nodes.Add( newNode ); newNode.UpdateLabel(); } } else { treeData.Nodes.Add( new ActionNode() ); } treeData.ExpandAll(); treeData.SelectedNode = treeData.Nodes[0]; }
private void bOK_Click(object sender, EventArgs e) { XDocument doc = new XDocument(); XElement root = new XElement(AutoRankManager.TagName); foreach (TreeNode node in treeData.Nodes) { ActionNode anode = (ActionNode)node; if (anode.FromRank == null || anode.ToRank == null) { continue; } Criterion crit = new Criterion { FromRank = anode.FromRank, ToRank = anode.ToRank, Condition = ExportConditions(anode) }; root.Add(crit.Serialize()); } doc.Add(root); doc.Save(Paths.AutoRankFileName); Application.Exit(); }
private void bAction_Click( object sender, EventArgs e ) { ActionNode newNode = new ActionNode(); treeData.Nodes.Add( newNode); treeData.SelectedNode = newNode; }
void Init(object sender, EventArgs args) { Server.InitLibrary(Environment.GetCommandLineArgs()); Config.Load(false, false); rankList = RankManager.Ranks.Select(r => r.Prefix + r.Name).ToArray(); cFromRank.Items.AddRange(rankList); cToRank.Items.AddRange(rankList); using (LogRecorder recorder = new LogRecorder()) { AutoRankManager.Init(); if (recorder.HasMessages) { MessageBox.Show(recorder.MessageString, "Loading autorank.xml..."); } } if (AutoRankManager.HasCriteria) { foreach (Criterion crit in AutoRankManager.Criteria) { ActionNode newNode = new ActionNode { Action = ActionType.Automatic, FromRank = crit.FromRank, ToRank = crit.ToRank }; if (crit.Condition is ConditionAND) { newNode.Op = GroupNodeType.AND; } else if (crit.Condition is ConditionOR) { newNode.Op = GroupNodeType.OR; } else if (crit.Condition is ConditionNAND) { newNode.Op = GroupNodeType.NAND; } else if (crit.Condition is ConditionNOR) { newNode.Op = GroupNodeType.NOR; } else { throw new FormatException(); } foreach (Condition subCondition in crit.Condition.Conditions) { ImportCondition(newNode, subCondition); } treeData.Nodes.Add(newNode); newNode.UpdateLabel(); } } else { treeData.Nodes.Add(new ActionNode()); } treeData.ExpandAll(); treeData.SelectedNode = treeData.Nodes[0]; }