Beispiel #1
0
        private void btnCompare_Click(object sender, System.EventArgs e)
        {
            try
            {
                txtSummary.Clear();

                if (txtNavigationFile1.Text.Trim().Length == 0 ||
                    txtNavigationFile2.Text.Trim().Length == 0)
                {
                    MessageBox.Show(this.ParentForm, "Please choose two files to compare.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                NavigationReader left  = new NavigationReader();
                NavigationReader right = new NavigationReader();

                left.Read(txtNavigationFile1.Text);
                right.Read(txtNavigationFile2.Text);

                NavigationDiff diff = new NavigationDiff();
                diff.DoDiff(left, right);

                if (diff.DifferentActions.Count == 0 && diff.DifferentNodes.Count == 0 && diff.DifferentRoutes.Count == 0)
                {
                    txtSummary.AppendText("The navigation files are the same.");
                    return;
                }

                foreach (NodeDifference nodeDiff in diff.DifferentNodes)
                {
                    if (nodeDiff.LeftNode == null)
                    {
                        txtSummary.AppendText("Left Navigation is missing Node " + nodeDiff.RightNode.ID + "\r\n\r\n");
                    }
                    else if (nodeDiff.RightNode == null)
                    {
                        txtSummary.AppendText("Right Navigation is missing Node " + nodeDiff.LeftNode.ID + "\r\n\r\n");
                    }
                    else
                    {
                        txtSummary.AppendText("Node " + nodeDiff.LeftNode.ID + " is different.\r\n");

                        if (nodeDiff.LeftNode.Connect1 != nodeDiff.RightNode.Connect1)
                        {
                            txtSummary.AppendText("\tLeft Connect 1 = " + nodeDiff.LeftNode.Connect1 + ", Right Connect 1 = " + nodeDiff.RightNode.Connect1 + "\r\n");
                        }

                        if (nodeDiff.LeftNode.Connect2 != nodeDiff.RightNode.Connect2)
                        {
                            txtSummary.AppendText("\tLeft Connect 2 = " + nodeDiff.LeftNode.Connect2 + ", Right Connect 2 = " + nodeDiff.RightNode.Connect2 + "\r\n");
                        }

                        if (nodeDiff.LeftNode.Connect3 != nodeDiff.RightNode.Connect3)
                        {
                            txtSummary.AppendText("\tLeft Connect 3 = " + nodeDiff.LeftNode.Connect3 + ", Right Connect 3 = " + nodeDiff.RightNode.Connect3 + "\r\n");
                        }

                        if (nodeDiff.LeftNode.Connect4 != nodeDiff.RightNode.Connect4)
                        {
                            txtSummary.AppendText("\tLeft Connect 4 = " + nodeDiff.LeftNode.Connect4 + ", Right Connect 4 = " + nodeDiff.RightNode.Connect4 + "\r\n");
                        }

                        if (nodeDiff.LeftNode.Entity != nodeDiff.RightNode.Entity)
                        {
                            txtSummary.AppendText("\tLeft Entity = " + nodeDiff.LeftNode.Entity + ", Right Entity = " + nodeDiff.RightNode.Entity + "\r\n");
                        }

                        if (nodeDiff.LeftNode.Flags != nodeDiff.RightNode.Flags)
                        {
                            txtSummary.AppendText("\tLeft Flags = " + nodeDiff.LeftNode.Flags + ", Right Flags = " + nodeDiff.RightNode.Flags + "\r\n");
                        }

                        if (nodeDiff.LeftNode.Group != nodeDiff.RightNode.Group)
                        {
                            txtSummary.AppendText("\tLeft Group = " + nodeDiff.LeftNode.Group + ", Right Group = " + nodeDiff.RightNode.Group + "\r\n");
                        }

                        if (nodeDiff.LeftNode.NumberOfConnects != nodeDiff.RightNode.NumberOfConnects)
                        {
                            txtSummary.AppendText("\tLeft Number of Connections = " + nodeDiff.LeftNode.NumberOfConnects + ", Right Number of Connections = " + nodeDiff.RightNode.NumberOfConnects + "\r\n");
                        }

                        if (nodeDiff.LeftNode.Radius != nodeDiff.RightNode.Radius)
                        {
                            txtSummary.AppendText("\tLeft Radius = " + nodeDiff.LeftNode.Radius + ", Right Radius = " + nodeDiff.RightNode.Radius + "\r\n");
                        }

                        if (nodeDiff.LeftNode.Team != nodeDiff.RightNode.Team)
                        {
                            txtSummary.AppendText("\tLeft Team = " + nodeDiff.LeftNode.Team + ", Right Team = " + nodeDiff.RightNode.Team + "\r\n");
                        }
                    }
                }

                foreach (ActionDifference actionDiff in diff.DifferentActions)
                {
                    if (actionDiff.LeftAction == null)
                    {
                        txtSummary.AppendText("Left Navigation is missing Action " + actionDiff.RightAction.ID + "\r\n\r\n");
                    }
                    else if (actionDiff.RightAction == null)
                    {
                        txtSummary.AppendText("Right Navigation is missing Action " + actionDiff.LeftAction.ID + "\r\n\r\n");
                    }
                    else
                    {
                        txtSummary.AppendText("Action " + actionDiff.LeftAction.ID + " is different.\r\n");

                        if (actionDiff.LeftAction.Active != actionDiff.RightAction.Active)
                        {
                            txtSummary.AppendText("\tLeft Active = " + actionDiff.LeftAction.Active + ", Right Active = " + actionDiff.RightAction.Active + "\r\n");
                        }

                        if (actionDiff.LeftAction.AllyAction != actionDiff.RightAction.AllyAction)
                        {
                            txtSummary.AppendText("\tLeft Ally Action = " + actionDiff.LeftAction.AllyAction + ", Right Ally Action = " + actionDiff.RightAction.AllyAction + "\r\n");
                        }

                        if (actionDiff.LeftAction.AxisAction != actionDiff.RightAction.AxisAction)
                        {
                            txtSummary.AppendText("\tLeft Axis Action = " + actionDiff.LeftAction.AxisAction + ", Right Axis Action = " + actionDiff.RightAction.AxisAction + "\r\n");
                        }

                        if (actionDiff.LeftAction.Class != actionDiff.RightAction.Class)
                        {
                            txtSummary.AppendText("\tLeft Class = " + actionDiff.LeftAction.Class + ", Right Class = " + actionDiff.RightAction.Class + "\r\n");
                        }

                        if (actionDiff.LeftAction.CloseNode != actionDiff.RightAction.CloseNode)
                        {
                            txtSummary.AppendText("\tLeft Close Node = " + actionDiff.LeftAction.CloseNode + ", Right Close Node = " + actionDiff.RightAction.CloseNode + "\r\n");
                        }

                        if (actionDiff.LeftAction.Entity != actionDiff.RightAction.Entity)
                        {
                            txtSummary.AppendText("\tLeft Entity = " + actionDiff.LeftAction.Entity + ", Right Entity = " + actionDiff.RightAction.Entity + "\r\n");
                        }

                        if (actionDiff.LeftAction.Goal != actionDiff.RightAction.Goal)
                        {
                            txtSummary.AppendText("\tLeft Goal = " + actionDiff.LeftAction.Goal + ", Right Goal = " + actionDiff.RightAction.Goal + "\r\n");
                        }

                        if (actionDiff.LeftAction.Group != actionDiff.RightAction.Group)
                        {
                            txtSummary.AppendText("\tLeft Group = " + actionDiff.LeftAction.Group + ", Right Group = " + actionDiff.RightAction.Group + "\r\n");
                        }

                        if (actionDiff.LeftAction.Links != actionDiff.RightAction.Links)
                        {
                            txtSummary.AppendText("\tLeft Links = " + actionDiff.LeftAction.Links + ", Right Links = " + actionDiff.RightAction.Links + "\r\n");
                        }

                        if (actionDiff.LeftAction.Prone != actionDiff.RightAction.Prone)
                        {
                            txtSummary.AppendText("\tLeft Prone = " + actionDiff.LeftAction.Prone + ", Right Prone = " + actionDiff.RightAction.Prone + "\r\n");
                        }

                        if (actionDiff.LeftAction.Radius != actionDiff.RightAction.Radius)
                        {
                            txtSummary.AppendText("\tLeft Radius = " + actionDiff.LeftAction.Radius + ", Right Radius = " + actionDiff.RightAction.Radius + "\r\n");
                        }
                    }
                }

                foreach (RouteDifference routeDiff in diff.DifferentRoutes)
                {
                    if (routeDiff.LeftRoute == null)
                    {
                        txtSummary.AppendText("Left Navigation is missing Route " + routeDiff.RightRoute.ID + "\r\n\r\n");
                    }
                    else if (routeDiff.RightRoute == null)
                    {
                        txtSummary.AppendText("Right Navigation is missing Route " + routeDiff.LeftRoute.ID + "\r\n\r\n");
                    }
                    else
                    {
                        txtSummary.AppendText("Route " + routeDiff.LeftRoute.ID + " is different.\r\n");

                        if (routeDiff.LeftRoute.Team != routeDiff.RightRoute.Team)
                        {
                            txtSummary.AppendText("\tLeft Team = " + routeDiff.LeftRoute.Team + ", Right Team = " + routeDiff.RightRoute.Team + "\r\n");
                        }

                        if (routeDiff.LeftRoute.Radius != routeDiff.RightRoute.Radius)
                        {
                            txtSummary.AppendText("\tLeft Radius = " + routeDiff.LeftRoute.Radius + ", Right Radius = " + routeDiff.RightRoute.Radius + "\r\n");
                        }

                        if (routeDiff.LeftRoute.Actions != routeDiff.RightRoute.Actions)
                        {
                            txtSummary.AppendText("\tLeft Actions = " + routeDiff.LeftRoute.Actions + ", Right Actions = " + routeDiff.RightRoute.Actions + "\r\n");
                        }

                        if (routeDiff.LeftRoute.PathActions != routeDiff.RightRoute.PathActions)
                        {
                            txtSummary.AppendText("\tLeft PathActions = " + routeDiff.LeftRoute.PathActions + ", Right PathActions = " + routeDiff.RightRoute.PathActions + "\r\n");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this.ParentForm, "Error comparing navigation files. " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void btnCompare_Click(object sender, System.EventArgs e)
        {
            try
            {
                txtSummary.Clear();

                if (txtNavigationFile1.Text.Trim().Length == 0 ||
                    txtNavigationFile2.Text.Trim().Length == 0)
                {
                    MessageBox.Show(this.ParentForm, "Please choose two files to compare.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                NavigationReader left = new NavigationReader();
                NavigationReader right = new NavigationReader();

                left.Read(txtNavigationFile1.Text);
                right.Read(txtNavigationFile2.Text);

                NavigationDiff diff = new NavigationDiff();
                diff.DoDiff(left, right);

                if (diff.DifferentActions.Count == 0 && diff.DifferentNodes.Count == 0 && diff.DifferentRoutes.Count == 0)
                {
                    txtSummary.AppendText("The navigation files are the same.");
                    return;
                }

                foreach (NodeDifference nodeDiff in diff.DifferentNodes)
                {
                    if (nodeDiff.LeftNode == null)
                    {
                        txtSummary.AppendText("Left Navigation is missing Node " + nodeDiff.RightNode.ID + "\r\n\r\n");
                    }
                    else if (nodeDiff.RightNode == null)
                    {
                        txtSummary.AppendText("Right Navigation is missing Node " + nodeDiff.LeftNode.ID + "\r\n\r\n");
                    }
                    else
                    {
                        txtSummary.AppendText("Node " + nodeDiff.LeftNode.ID + " is different.\r\n");

                        if (nodeDiff.LeftNode.Connect1 != nodeDiff.RightNode.Connect1)
                        {
                            txtSummary.AppendText("\tLeft Connect 1 = " + nodeDiff.LeftNode.Connect1 + ", Right Connect 1 = " + nodeDiff.RightNode.Connect1 + "\r\n");
                        }

                        if (nodeDiff.LeftNode.Connect2 != nodeDiff.RightNode.Connect2)
                        {
                            txtSummary.AppendText("\tLeft Connect 2 = " + nodeDiff.LeftNode.Connect2 + ", Right Connect 2 = " + nodeDiff.RightNode.Connect2 + "\r\n");
                        }

                        if (nodeDiff.LeftNode.Connect3 != nodeDiff.RightNode.Connect3)
                        {
                            txtSummary.AppendText("\tLeft Connect 3 = " + nodeDiff.LeftNode.Connect3 + ", Right Connect 3 = " + nodeDiff.RightNode.Connect3 + "\r\n");
                        }

                        if (nodeDiff.LeftNode.Connect4 != nodeDiff.RightNode.Connect4)
                        {
                            txtSummary.AppendText("\tLeft Connect 4 = " + nodeDiff.LeftNode.Connect4 + ", Right Connect 4 = " + nodeDiff.RightNode.Connect4 + "\r\n");
                        }

                        if (nodeDiff.LeftNode.Entity != nodeDiff.RightNode.Entity)
                        {
                            txtSummary.AppendText("\tLeft Entity = " + nodeDiff.LeftNode.Entity + ", Right Entity = " + nodeDiff.RightNode.Entity + "\r\n");
                        }

                        if (nodeDiff.LeftNode.Flags != nodeDiff.RightNode.Flags)
                        {
                            txtSummary.AppendText("\tLeft Flags = " + nodeDiff.LeftNode.Flags + ", Right Flags = " + nodeDiff.RightNode.Flags + "\r\n");
                        }

                        if (nodeDiff.LeftNode.Group != nodeDiff.RightNode.Group)
                        {
                            txtSummary.AppendText("\tLeft Group = " + nodeDiff.LeftNode.Group + ", Right Group = " + nodeDiff.RightNode.Group + "\r\n");
                        }

                        if (nodeDiff.LeftNode.NumberOfConnects != nodeDiff.RightNode.NumberOfConnects)
                        {
                            txtSummary.AppendText("\tLeft Number of Connections = " + nodeDiff.LeftNode.NumberOfConnects + ", Right Number of Connections = " + nodeDiff.RightNode.NumberOfConnects + "\r\n");
                        }

                        if (nodeDiff.LeftNode.Radius != nodeDiff.RightNode.Radius)
                        {
                            txtSummary.AppendText("\tLeft Radius = " + nodeDiff.LeftNode.Radius + ", Right Radius = " + nodeDiff.RightNode.Radius + "\r\n");
                        }

                        if (nodeDiff.LeftNode.Team != nodeDiff.RightNode.Team)
                        {
                            txtSummary.AppendText("\tLeft Team = " + nodeDiff.LeftNode.Team + ", Right Team = " + nodeDiff.RightNode.Team + "\r\n");
                        }
                    }
                }

                foreach (ActionDifference actionDiff in diff.DifferentActions)
                {
                    if (actionDiff.LeftAction == null)
                    {
                        txtSummary.AppendText("Left Navigation is missing Action " + actionDiff.RightAction.ID + "\r\n\r\n");
                    }
                    else if (actionDiff.RightAction == null)
                    {
                        txtSummary.AppendText("Right Navigation is missing Action " + actionDiff.LeftAction.ID + "\r\n\r\n");
                    }
                    else
                    {
                        txtSummary.AppendText("Action " + actionDiff.LeftAction.ID + " is different.\r\n");

                        if (actionDiff.LeftAction.Active != actionDiff.RightAction.Active)
                        {
                            txtSummary.AppendText("\tLeft Active = " + actionDiff.LeftAction.Active + ", Right Active = " + actionDiff.RightAction.Active + "\r\n");
                        }

                        if (actionDiff.LeftAction.AllyAction != actionDiff.RightAction.AllyAction)
                        {
                            txtSummary.AppendText("\tLeft Ally Action = " + actionDiff.LeftAction.AllyAction + ", Right Ally Action = " + actionDiff.RightAction.AllyAction + "\r\n");
                        }

                        if (actionDiff.LeftAction.AxisAction != actionDiff.RightAction.AxisAction)
                        {
                            txtSummary.AppendText("\tLeft Axis Action = " + actionDiff.LeftAction.AxisAction + ", Right Axis Action = " + actionDiff.RightAction.AxisAction + "\r\n");
                        }

                        if (actionDiff.LeftAction.Class != actionDiff.RightAction.Class)
                        {
                            txtSummary.AppendText("\tLeft Class = " + actionDiff.LeftAction.Class + ", Right Class = " + actionDiff.RightAction.Class + "\r\n");
                        }

                        if (actionDiff.LeftAction.CloseNode != actionDiff.RightAction.CloseNode)
                        {
                            txtSummary.AppendText("\tLeft Close Node = " + actionDiff.LeftAction.CloseNode + ", Right Close Node = " + actionDiff.RightAction.CloseNode + "\r\n");
                        }

                        if (actionDiff.LeftAction.Entity != actionDiff.RightAction.Entity)
                        {
                            txtSummary.AppendText("\tLeft Entity = " + actionDiff.LeftAction.Entity + ", Right Entity = " + actionDiff.RightAction.Entity + "\r\n");
                        }

                        if (actionDiff.LeftAction.Goal != actionDiff.RightAction.Goal)
                        {
                            txtSummary.AppendText("\tLeft Goal = " + actionDiff.LeftAction.Goal + ", Right Goal = " + actionDiff.RightAction.Goal + "\r\n");
                        }

                        if (actionDiff.LeftAction.Group != actionDiff.RightAction.Group)
                        {
                            txtSummary.AppendText("\tLeft Group = " + actionDiff.LeftAction.Group + ", Right Group = " + actionDiff.RightAction.Group + "\r\n");
                        }

                        if (actionDiff.LeftAction.Links != actionDiff.RightAction.Links)
                        {
                            txtSummary.AppendText("\tLeft Links = " + actionDiff.LeftAction.Links + ", Right Links = " + actionDiff.RightAction.Links + "\r\n");
                        }

                        if (actionDiff.LeftAction.Prone != actionDiff.RightAction.Prone)
                        {
                            txtSummary.AppendText("\tLeft Prone = " + actionDiff.LeftAction.Prone + ", Right Prone = " + actionDiff.RightAction.Prone + "\r\n");
                        }

                        if (actionDiff.LeftAction.Radius != actionDiff.RightAction.Radius)
                        {
                            txtSummary.AppendText("\tLeft Radius = " + actionDiff.LeftAction.Radius + ", Right Radius = " + actionDiff.RightAction.Radius + "\r\n");
                        }
                    }
                }

                foreach (RouteDifference routeDiff in diff.DifferentRoutes)
                {
                    if (routeDiff.LeftRoute == null)
                    {
                        txtSummary.AppendText("Left Navigation is missing Route " + routeDiff.RightRoute.ID + "\r\n\r\n");
                    }
                    else if (routeDiff.RightRoute == null)
                    {
                        txtSummary.AppendText("Right Navigation is missing Route " + routeDiff.LeftRoute.ID + "\r\n\r\n");
                    }
                    else
                    {
                        txtSummary.AppendText("Route " + routeDiff.LeftRoute.ID + " is different.\r\n");

                        if (routeDiff.LeftRoute.Team != routeDiff.RightRoute.Team)
                        {
                            txtSummary.AppendText("\tLeft Team = " + routeDiff.LeftRoute.Team + ", Right Team = " + routeDiff.RightRoute.Team + "\r\n");
                        }

                        if (routeDiff.LeftRoute.Radius != routeDiff.RightRoute.Radius)
                        {
                            txtSummary.AppendText("\tLeft Radius = " + routeDiff.LeftRoute.Radius + ", Right Radius = " + routeDiff.RightRoute.Radius + "\r\n");
                        }

                        if (routeDiff.LeftRoute.Actions != routeDiff.RightRoute.Actions)
                        {
                            txtSummary.AppendText("\tLeft Actions = " + routeDiff.LeftRoute.Actions + ", Right Actions = " + routeDiff.RightRoute.Actions + "\r\n");
                        }

                        if (routeDiff.LeftRoute.PathActions != routeDiff.RightRoute.PathActions)
                        {
                            txtSummary.AppendText("\tLeft PathActions = " + routeDiff.LeftRoute.PathActions + ", Right PathActions = " + routeDiff.RightRoute.PathActions + "\r\n");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this.ParentForm, "Error comparing navigation files. " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }