/// <summary> /// Handles when the error check dialogue is closed /// </summary> void errorCheckDialog_FormClosed(object sender, FormClosedEventArgs e) { // store its previous position _previousCheckDialogPosition = _errorCheckDialog.Location; _hasOldCheckDialogPosition = true; // we have to create a new dialogue the next time so we clear it _errorCheckDialog = null; }
public static void ShowErrorDialog(ref ErrorCheckDialog errorDialog, BehaviorTreeList behaviorTreeList, BehaviorTreeView behaviorTreeView, Form owner, string title, List <Node.ErrorCheck> result) { // store the old position of the check dialogue and close it if (errorDialog != null) { errorDialog.Close(); } // prepare the new dialogue errorDialog = new ErrorCheckDialog(); errorDialog.Owner = owner; errorDialog.BehaviorTreeList = behaviorTreeList; errorDialog.BehaviorTreeView = behaviorTreeView; errorDialog.Text = title; // add the errors to the check dialogue foreach (Node.ErrorCheck check in result) { BehaviorNode behavior = check.Node != null ? check.Node.Behavior : null; // group the errors by the behaviour their occured in // get the group for the error's behaviour ListViewGroup group = null; foreach (ListViewGroup grp in errorDialog.listView.Groups) { if (grp.Tag == behavior) { group = grp; break; } } // if there is no group, create it if (group == null) { group = new ListViewGroup(behavior != null ? ((Node)behavior).Label : "Error"); group.Tag = behavior; errorDialog.listView.Groups.Add(group); } // create an item for the error in the group ListViewItem item = new ListViewItem(check.Description); item.Group = group; item.Tag = check.Node; switch (check.Level) { case (ErrorCheckLevel.Message): item.ImageIndex = 0; break; case (ErrorCheckLevel.Warning): item.ImageIndex = 1; break; case (ErrorCheckLevel.Error): item.ImageIndex = 2; break; } errorDialog.listView.Items.Add(item); } // if no errors were found, tell the user so if (result.Count < 1) { errorDialog.listView.Items.Add(new ListViewItem("No Errors.", (int)ErrorCheckLevel.Message)); } // show the dialogue errorDialog.Show(); }
public void ShowErrorDialog(string title, string groupLabel, List<Node.ErrorCheck> result) { // store the old position of the check dialogue and close it if (_errorCheckDialog != null) { _errorCheckDialog.Close(); } // prepare the new dialogue _errorCheckDialog = new ErrorCheckDialog(); _errorCheckDialog.Owner = this.ParentForm; _errorCheckDialog.BehaviorTreeList = _behaviorTreeList; _errorCheckDialog.BehaviorTreeView = this; _errorCheckDialog.Text = title; _errorCheckDialog.FormClosed += new FormClosedEventHandler(errorCheckDialog_FormClosed); // add the errors to the check dialogue foreach(Node.ErrorCheck check in result) { BehaviorNode behavior = check.Node.Behavior; // group the errors by the behaviour their occured in // get the group for the error's behaviour ListViewGroup group = null; foreach(ListViewGroup grp in _errorCheckDialog.listView.Groups) { if (grp.Tag == behavior) { group = grp; break; } } // if there is no group, create it if (group == null) { group = new ListViewGroup(groupLabel); group.Tag = behavior; _errorCheckDialog.listView.Groups.Add(group); } // create an item for the error in the group ListViewItem item = new ListViewItem(check.Description); item.Group = group; item.Tag = check.Node; switch (check.Level) { case (ErrorCheckLevel.Message): item.ImageIndex = 0; break; case (ErrorCheckLevel.Warning): item.ImageIndex = 1; break; case (ErrorCheckLevel.Error): item.ImageIndex = 2; break; } _errorCheckDialog.listView.Items.Add(item); } // if no errors were found, tell the user so if (result.Count < 1) { _errorCheckDialog.listView.Items.Add(new ListViewItem("No Errors.", (int)ErrorCheckLevel.Message)); } // show the dialogue _errorCheckDialog.Show(); // set its position to the position of the previous dialogue if (_hasOldCheckDialogPosition) { _errorCheckDialog.Location = _previousCheckDialogPosition; } }
public static void ShowErrorDialog(ref ErrorCheckDialog errorDialog, BehaviorTreeList behaviorTreeList, BehaviorTreeView behaviorTreeView, Form owner, string title, List<Node.ErrorCheck> result) { // store the old position of the check dialogue and close it if (errorDialog != null) { errorDialog.Close(); } // prepare the new dialogue errorDialog = new ErrorCheckDialog(); errorDialog.Owner = owner; errorDialog.BehaviorTreeList = behaviorTreeList; errorDialog.BehaviorTreeView = behaviorTreeView; errorDialog.Text = title; // add the errors to the check dialogue foreach (Node.ErrorCheck check in result) { BehaviorNode behavior = check.Node != null ? check.Node.Behavior : null; // group the errors by the behaviour their occured in // get the group for the error's behaviour ListViewGroup group = null; foreach (ListViewGroup grp in errorDialog.listView.Groups) { if (grp.Tag == behavior) { group = grp; break; } } // if there is no group, create it if (group == null) { group = new ListViewGroup(behavior != null ? ((Node)behavior).Label : "Error"); group.Tag = behavior; errorDialog.listView.Groups.Add(group); } // create an item for the error in the group ListViewItem item = new ListViewItem(check.Description); item.Group = group; item.Tag = check.Node; switch (check.Level) { case (ErrorCheckLevel.Message): item.ImageIndex = 0; break; case (ErrorCheckLevel.Warning): item.ImageIndex = 1; break; case (ErrorCheckLevel.Error): item.ImageIndex = 2; break; } errorDialog.listView.Items.Add(item); } // if no errors were found, tell the user so if (result.Count < 1) { errorDialog.listView.Items.Add(new ListViewItem("No Errors.", (int)ErrorCheckLevel.Message)); } // show the dialogue errorDialog.Show(); }