Ejemplo n.º 1
0
 public void FromRouteRow(Routes.RouteRow routeRow)
 {
     if (!routeRow.IsTeamNull()) Team = Convert.ToInt32(routeRow.Team);
     if (!routeRow.IsRadiusNull()) Radius = Convert.ToInt32(routeRow.Radius);
     if (!routeRow.IsActionsNull()) Actions = routeRow.Actions;
     if (!routeRow.IsPathActionsNull()) PathActions = routeRow.PathActions;
 }
Ejemplo n.º 2
0
        public RoutePrinter(PrintDocument document, Routes routes, string fileName)
        {
            _printDocument = document;
            _routes = routes;
            _fileName = fileName;

            //init page settings
            _pageWidth = document.DefaultPageSettings.PaperSize.Width;
            _pageHeight = document.DefaultPageSettings.PaperSize.Height;
            _pageLandscape = document.DefaultPageSettings.Landscape;

            //init margin settings
            _pageMarginLeft = document.DefaultPageSettings.Margins.Left;
            _pageMarginTop = document.DefaultPageSettings.Margins.Top;
            _pageMarginRight = document.DefaultPageSettings.Margins.Right;
            _pageMarginBottom = document.DefaultPageSettings.Margins.Bottom;

            _currentY = _pageMarginTop;
            _currentX =  _pageMarginLeft;
        }
Ejemplo n.º 3
0
        public void InitializeRoutes(ArrayList routes, Actions actions)
        {
            _actions = actions;
            _routes = new Routes();

            foreach (Route route in routes)
            {
                _routes.Route.AddRouteRow(
                    Convert.ToString(route.ID),
                    Convert.ToString(route.Team),
                    Convert.ToString(route.Radius),
                    route.Actions,
                    route.PathActions);
            }

            this.SuspendLayout();
            dgRoutes.DataSource = _routes.Tables[0];
            this.ResumeLayout(false);

            //no adding of new rows thru dataview...
            CurrencyManager cm = (CurrencyManager)this.BindingContext[dgRoutes.DataSource, dgRoutes.DataMember];
            ((DataView)cm.List).AllowNew = false;
        }
Ejemplo n.º 4
0
        public void Write(string fileName, Nodes nodes, Actions actions, Routes routes)
        {
            if (File.Exists(fileName))
            {
                // copy the .nav file
                string backupNavFile = fileName + "_" + DateTime.Now.Month + "_" + DateTime.Now.Day + "_" + DateTime.Now.Year + "_" + DateTime.Now.Hour + "_" + DateTime.Now.Minute + "_" + DateTime.Now.Second + ".nav";
                File.Move(fileName, backupNavFile);
                File.SetLastWriteTime(backupNavFile, DateTime.Now);
            }

            FileStream fs = File.Create(fileName);
            BinaryWriter writer = new BinaryWriter(fs);

            byte[] header = new byte[] { 70, 114, 105, 116, 122, 66, 111, 116, 0, 7, 0, 0, 0 };

            writer.Write(header);
            writer.Write(FromInt(nodes.Node.Count));

            if (nodes.Node.Count > 0)
            {
                int nodeCounter = 0;
                foreach (Nodes.NodeRow nodeRow in nodes.Node)
                {
                    Node node = (Node)_nodes[nodeCounter];
                    node.FromNodeRow(nodeRow);
                    writer.Write(node.ToByteArray());
                    nodeCounter++;
                }

                if (actions.Action.Count > 0)
                {
                    int actionCounter = 0;
                    writer.Write(FromInt(actions.Action.Count));
                    foreach (Actions.ActionRow actionRow in actions.Action)
                    {
                        Action action = (Action)_actions[actionCounter];
                        action.FromActionRow(actionRow);
                        writer.Write(action.ToByteArray());
                        actionCounter++;
                    }

                    if (routes.Route.Count > 0)
                    {
                        int routeCounter = 0;
                        writer.Write(FromInt(routes.Route.Count));
                        foreach (Routes.RouteRow routeRow in routes.Route)
                        {
                            Route route = (Route)_routes[routeCounter];
                            route.FromRouteRow(routeRow);
                            writer.Write(route.ToByteArray());
                            routeCounter++;
                        }
                    }
                    else
                    {
                        writer.Write(FromInt(0));
                    }
                }
                else
                {
                    writer.Write(FromInt(0));
                    writer.Write(FromInt(0));
                }
            }
            else
            {
                writer.Write(FromInt(0));
                writer.Write(FromInt(0));
            }

            writer.Close();
            fs.Close();
        }
Ejemplo n.º 5
0
        private bool IsRouteValid(Routes.RouteRow route)
        {
            try
            {
                bool isValid = true;
                StringBuilder buff = new StringBuilder();

                // validate actions
                if (route.IsActionsNull() || route.Actions.Trim().Length == 0)
                {
                    // do we need actions?
                    isValid = false;
                    buff.Append("Route " + route.ID + " has no actions defined.\r\n");
                }
                else
                {
                    // check that the actions exist
                    string[] ids = route.Actions.Split(new char[] { ' ' });

                    for (int x = 0; x < ids.Length; x++)
                    {
                        int actionID = Int32.MinValue;

                        try
                        {
                            actionID = Convert.ToInt32(ids[x]);
                        }
                        catch
                        {
                            isValid = false;
                            buff.Append("Route " + route.ID + " has an action link that is non-numeric.\r\n");
                        }

                        if (actionID != Int32.MinValue)
                        {
                            if (actionID < 0 || actionID > _actions.Action.Count - 1)
                            {
                                isValid = false;
                                buff.Append("Route " + route.ID + " is linked to action " + actionID + " which does not exist in the navigation file.\r\n");
                            }
                        }
                    }
                }

                // validate path actions
                if (route.IsPathActionsNull() || route.PathActions.Trim().Length == 0)
                {
                    // do we need path actions?
                    isValid = false;
                    buff.Append("Route " + route.ID + " has no path actions defined.\r\n");
                }
                else
                {
                    // check that the actions exist
                    string[] ids = route.PathActions.Split(new char[] { ' ' });

                    for (int x = 0; x < ids.Length; x++)
                    {
                        int actionID = Int32.MinValue;

                        try
                        {
                            actionID = Convert.ToInt32(ids[x]);
                        }
                        catch
                        {
                            isValid = false;
                            buff.Append("Route " + route.ID + " has a path action link that is non-numeric.\r\n");
                        }

                        if (actionID != Int32.MinValue)
                        {
                            if (actionID < 0 || actionID > _actions.Action.Count - 1)
                            {
                                isValid = false;
                                buff.Append("Route " + route.ID + " is linked to path action " + actionID + " which does not exist in the navigation file.\r\n");
                            }
                            else
                            {
                                Actions.ActionRow actionRow = _actions.Action[actionID];

                                // these need to be 17, alt-roams
                                switch (route.Team)
                                {
                                    case "0":
                                        if (actionRow.IsAllyActionNull() || actionRow.IsAxisActionNull())
                                        {
                                            isValid = false;
                                            buff.Append("Route " + route.ID + " is linked to a path action [" + actionID + "] that is not an Alternate Roam for both teams.\r\n");
                                        }
                                        else
                                        {
                                            if (actionRow.AllyAction != "17" || actionRow.AxisAction != "17")
                                            {
                                                isValid = false;
                                                buff.Append("Route " + route.ID + " is linked to a path action [" + actionID + "] that is not an Alternate Roam for both teams.\r\n");
                                            }
                                        }
                                        break;
                                    case "1":
                                        if (actionRow.IsAxisActionNull())
                                        {
                                            isValid = false;
                                            buff.Append("Route " + route.ID + " is linked to a path action [" + actionID + "] that is not an Axis Alternate Roam action.\r\n");
                                        }
                                        else
                                        {
                                            if (actionRow.AxisAction != "17")
                                            {
                                                isValid = false;
                                                buff.Append("Route " + route.ID + " is linked to a path action [" + actionID + "] that is not an Axis Alternate Roam action.\r\n");
                                            }
                                        }
                                        break;
                                    case "2":
                                        if (actionRow.IsAllyActionNull())
                                        {
                                            isValid = false;
                                            buff.Append("Route " + route.ID + " is linked to a path action [" + actionID + "] that is not an Ally Alternate Roam action.\r\n");
                                        }
                                        else
                                        {
                                            if (actionRow.AllyAction != "17")
                                            {
                                                isValid = false;
                                                buff.Append("Route " + route.ID + " is linked to a path action [" + actionID + "] that is not an Ally Alternate Roam action.\r\n");
                                            }
                                        }
                                        break;
                                }
                            }
                        }
                    }
                }

                if (!isValid)
                {
                    MessageBox.Show(this.ParentForm, buff.ToString(), "Invalid", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                return isValid;
            }
            catch (Exception ex)
            {
                MessageBox.Show(this.ParentForm, "Error validation route " + route.ID + ". " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return false;
            }
        }
Ejemplo n.º 6
0
        public static void WriteRoutes(string fileName, Routes routes)
        {
            fileName = GetRouteFile(fileName);
            StringBuilder buff = new StringBuilder();
            StringBuilder execBuff = new StringBuilder();

            int startNode = 0;
            int endNode = 99;
            int count = 0;

            foreach (Routes.RouteRow row in routes.Route.Rows)
            {
                // team
                if (!row.IsTeamNull())
                {
                    buff.Append("route_team " + row.ID + " " + row.Team + "; ");
                }

                if (!row.IsRadiusNull())
                {
                    buff.Append("route_radius " + row.ID + " " + row.Radius + "; ");
                }

                if (!row.IsActionsNull())
                {
                    buff.Append("route_actions " + row.ID + " " + row.Actions + "; ");
                }

                if (!row.IsPathActionsNull())
                {
                    buff.Append("route_pathactions " + row.ID + " " + row.PathActions + "; ");
                }

                buff.Append("\r\n");

                count++;

                if (count > endNode)
                {
                    string subConfigFileName = fileName.Substring(0, fileName.LastIndexOf(".")) + "_" + startNode + "_" + endNode + ".cfg";
                    WriteConfig(subConfigFileName, buff);
                    buff = new StringBuilder();
                    startNode = endNode + 1;
                    endNode = startNode + 99;
                    execBuff.Append("exec " + subConfigFileName + "\r\n");
                }
            }

            if (buff.Length > 0)
            {
                string subConfigFileName = fileName.Substring(0, fileName.LastIndexOf(".")) + "_" + startNode + "_" + (count - 1) + ".cfg";
                WriteConfig(subConfigFileName, buff);
                execBuff.Append("exec " + subConfigFileName + "\r\n");
            }

            WriteConfig(fileName, execBuff);
        }
Ejemplo n.º 7
0
 public static System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(System.Xml.Schema.XmlSchemaSet xs) {
     System.Xml.Schema.XmlSchemaComplexType type = new System.Xml.Schema.XmlSchemaComplexType();
     System.Xml.Schema.XmlSchemaSequence sequence = new System.Xml.Schema.XmlSchemaSequence();
     Routes ds = new Routes();
     xs.Add(ds.GetSchemaSerializable());
     System.Xml.Schema.XmlSchemaAny any1 = new System.Xml.Schema.XmlSchemaAny();
     any1.Namespace = "http://www.w3.org/2001/XMLSchema";
     any1.MinOccurs = new decimal(0);
     any1.MaxOccurs = decimal.MaxValue;
     any1.ProcessContents = System.Xml.Schema.XmlSchemaContentProcessing.Lax;
     sequence.Items.Add(any1);
     System.Xml.Schema.XmlSchemaAny any2 = new System.Xml.Schema.XmlSchemaAny();
     any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1";
     any2.MinOccurs = new decimal(1);
     any2.ProcessContents = System.Xml.Schema.XmlSchemaContentProcessing.Lax;
     sequence.Items.Add(any2);
     System.Xml.Schema.XmlSchemaAttribute attribute1 = new System.Xml.Schema.XmlSchemaAttribute();
     attribute1.Name = "namespace";
     attribute1.FixedValue = ds.Namespace;
     type.Attributes.Add(attribute1);
     System.Xml.Schema.XmlSchemaAttribute attribute2 = new System.Xml.Schema.XmlSchemaAttribute();
     attribute2.Name = "tableTypeName";
     attribute2.FixedValue = "RouteDataTable";
     type.Attributes.Add(attribute2);
     type.Particle = sequence;
     return type;
 }
Ejemplo n.º 8
0
 public static System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(System.Xml.Schema.XmlSchemaSet xs) {
     Routes ds = new Routes();
     System.Xml.Schema.XmlSchemaComplexType type = new System.Xml.Schema.XmlSchemaComplexType();
     System.Xml.Schema.XmlSchemaSequence sequence = new System.Xml.Schema.XmlSchemaSequence();
     xs.Add(ds.GetSchemaSerializable());
     System.Xml.Schema.XmlSchemaAny any = new System.Xml.Schema.XmlSchemaAny();
     any.Namespace = ds.Namespace;
     sequence.Items.Add(any);
     type.Particle = sequence;
     return type;
 }
Ejemplo n.º 9
0
        public void Write(string fileName, Nodes nodes, Actions actions, Routes routes)
        {
            if (File.Exists(fileName))
            {
                // copy the .nav file
                string backupNavFile = fileName + "_" + DateTime.Now.Month + "_" + DateTime.Now.Day + "_" + DateTime.Now.Year + "_" + DateTime.Now.Hour + "_" + DateTime.Now.Minute + "_" + DateTime.Now.Second + ".nav";
                File.Move(fileName, backupNavFile);
                File.SetLastWriteTime(backupNavFile, DateTime.Now);
            }

            FileStream   fs     = File.Create(fileName);
            BinaryWriter writer = new BinaryWriter(fs);

            byte[] header = new byte[] { 70, 114, 105, 116, 122, 66, 111, 116, 0, 7, 0, 0, 0 };

            writer.Write(header);
            writer.Write(FromInt(nodes.Node.Count));

            if (nodes.Node.Count > 0)
            {
                int nodeCounter = 0;
                foreach (Nodes.NodeRow nodeRow in nodes.Node)
                {
                    Node node = (Node)_nodes[nodeCounter];
                    node.FromNodeRow(nodeRow);
                    writer.Write(node.ToByteArray());
                    nodeCounter++;
                }

                if (actions.Action.Count > 0)
                {
                    int actionCounter = 0;
                    writer.Write(FromInt(actions.Action.Count));
                    foreach (Actions.ActionRow actionRow in actions.Action)
                    {
                        Action action = (Action)_actions[actionCounter];
                        action.FromActionRow(actionRow);
                        writer.Write(action.ToByteArray());
                        actionCounter++;
                    }

                    if (routes.Route.Count > 0)
                    {
                        int routeCounter = 0;
                        writer.Write(FromInt(routes.Route.Count));
                        foreach (Routes.RouteRow routeRow in routes.Route)
                        {
                            Route route = (Route)_routes[routeCounter];
                            route.FromRouteRow(routeRow);
                            writer.Write(route.ToByteArray());
                            routeCounter++;
                        }
                    }
                    else
                    {
                        writer.Write(FromInt(0));
                    }
                }
                else
                {
                    writer.Write(FromInt(0));
                    writer.Write(FromInt(0));
                }
            }
            else
            {
                writer.Write(FromInt(0));
                writer.Write(FromInt(0));
            }

            writer.Close();
            fs.Close();
        }