예제 #1
0
        private CsvWriter GetNodeCsvWriter()
        {
            CsvWriter writer = new CsvWriter();

            writer.Columns.Add("ID");
            writer.Columns.Add("Radius");
            writer.Columns.Add("Entity");
            writer.Columns.Add("Group");
            writer.Columns.Add("Connection 1");
            writer.Columns.Add("Connection 2");
            writer.Columns.Add("Connection 3");
            writer.Columns.Add("Connection 4");

            for (int x = 0; x < _nodeControl.Nodes.Node.Rows.Count; x++)
            {
                Node node = new Node();
                node.FromNodeRow((Nodes.NodeRow)_nodeControl.Nodes.Node.Rows[x]);

                ArrayList nodeRow = new ArrayList();

                nodeRow.Add(Convert.ToString(node.ID));
                nodeRow.Add(Convert.ToString(node.Radius));
                nodeRow.Add(Convert.ToString(node.Entity));
                nodeRow.Add(Convert.ToString(node.Group));
                nodeRow.Add(Convert.ToString(node.Connect1));
                nodeRow.Add(Convert.ToString(node.Connect2));
                nodeRow.Add(Convert.ToString(node.Connect3));
                nodeRow.Add(Convert.ToString(node.Connect4));

                writer.AddRow(nodeRow);
            }

            return(writer);
        }
예제 #2
0
        private CsvWriter GetNodeCsvWriter()
        {
            CsvWriter writer = new CsvWriter();

            writer.Columns.Add("ID");
            writer.Columns.Add("Radius");
            writer.Columns.Add("Entity");
            writer.Columns.Add("Group");
            writer.Columns.Add("Connection 1");
            writer.Columns.Add("Connection 2");
            writer.Columns.Add("Connection 3");
            writer.Columns.Add("Connection 4");

            for (int x = 0; x < _nodeControl.Nodes.Node.Rows.Count; x++)
            {
                Node node = new Node();
                node.FromNodeRow((Nodes.NodeRow)_nodeControl.Nodes.Node.Rows[x]);

                ArrayList nodeRow = new ArrayList();

                nodeRow.Add(Convert.ToString(node.ID));
                nodeRow.Add(Convert.ToString(node.Radius));
                nodeRow.Add(Convert.ToString(node.Entity));
                nodeRow.Add(Convert.ToString(node.Group));
                nodeRow.Add(Convert.ToString(node.Connect1));
                nodeRow.Add(Convert.ToString(node.Connect2));
                nodeRow.Add(Convert.ToString(node.Connect3));
                nodeRow.Add(Convert.ToString(node.Connect4));

                writer.AddRow(nodeRow);
            }

            return writer;
        }
예제 #3
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();
        }