public void InitializeActions(ArrayList actions) { _actions = new Actions(); int count = 0; foreach (Action action in actions) { _actions.Action.AddActionRow( Convert.ToString(count), Convert.ToString(action.CloseNode), Convert.ToString(action.AllyAction), Convert.ToString(action.AxisAction), Convert.ToString(action.Radius), Convert.ToString(action.Goal), Convert.ToString(action.Group), Convert.ToString(action.Class), Convert.ToString(action.Links), Convert.ToString(action.Prone), Convert.ToString(action.Active), Convert.ToString(action.Entity)); count++; } this.SuspendLayout(); dgActions.DataSource = _actions.Tables[0]; this.ResumeLayout(false); //no adding of new rows thru dataview... CurrencyManager cm = (CurrencyManager)this.BindingContext[dgActions.DataSource, dgActions.DataMember]; ((DataView)cm.List).AllowNew = false; }
public ActionPrinter(PrintDocument document, Actions actions, string fileName) { _fileName = fileName; _printDocument = document; _actions = actions; //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; }
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; }
private bool IsActionValid(Actions.ActionRow actionRow) { bool isValid = true; StringBuilder msg = new StringBuilder(); string id = ""; string allyAction = ""; string axisAction = ""; string ent = ""; string linked = ""; string classNum = ""; if (!actionRow.IsIDNull()) { id = Convert.ToString(actionRow["ID"]); } if (!actionRow.IsAllyActionNull()) { allyAction = Convert.ToString(actionRow["AllyAction"]); } if (!actionRow.IsAxisActionNull()) { axisAction = Convert.ToString(actionRow["AxisAction"]); } if (!actionRow.IsEntityNull()) { ent = Convert.ToString(actionRow["Entity"]); if (ent == "1023") ent = ""; // default if (ent == "-1") ent = ""; // shouldn't be -1 } if (!actionRow.IsLinksNull()) { linked = Convert.ToString(actionRow["Links"]); } if (!actionRow.IsClassNull()) { classNum = Convert.ToString(actionRow["Class"]); } if ((allyAction == "-1" || allyAction == "") && (axisAction == "-1" || axisAction == "")) { msg.Append("Action " + id + " has no valid ally or axis actions.\r\n"); isValid = false; } if (ent == "") { if (_entityActions.ContainsKey(allyAction)) { msg.Append("Action " + id + " is an " + _entityActions[allyAction] + " action with no entity.\r\n"); isValid = false; } if (_entityActions.ContainsKey(axisAction)) { msg.Append("Action " + id + " is an " + _entityActions[axisAction] + " action with no entity.\r\n"); isValid = false; } } if (_campActions.ContainsKey(allyAction)) { if (linked.Trim() == "") { msg.Append("Action " + id + " is an ally " + _campActions[allyAction] + " with no links.\r\n"); isValid = false; } else { // check the links string[] links = linked.Split(new char[] { ' ' }); for (int x = 0; x < links.Length; x++) { int ndx = Convert.ToInt32(links[x]); // check to see if the action exists!!! if (ndx > _actions.Action.Count - 1) { msg.Append("Action " + id + " has link to an action that doesn't exist [" + ndx + "]"); isValid = false; } else { Actions.ActionRow linkedAction = _actions.Action[ndx]; // we don't allow sorting, so this is ok if (linkedAction.IsAllyActionNull() || linkedAction.AllyAction != "3") { msg.Append("Action " + id + " is an ally " + _campActions[allyAction] + " with an invalid link to Action " + links[x] + " (either no ally action or an ally action that is not an Aim action)\r\n"); isValid = false; } } } } } if (_campActions.ContainsKey(axisAction)) { if (linked.Trim() == "") { msg.Append("Action " + id + " is an axis " + _campActions[axisAction] + " with no links.\r\n"); isValid = false; } else { // check the links string[] links = linked.Split(new char[] { ' ' }); for (int x = 0; x < links.Length; x++) { int ndx = Convert.ToInt32(links[x]); // the axis action should be 3 Actions.ActionRow linkedAction = _actions.Action[ndx]; // we don't allow sorting, so this is ok if (linkedAction.IsAxisActionNull() || linkedAction.AxisAction != "3") { msg.Append("Action " + id + " is an axis " + _campActions[axisAction] + " with an invalid link to Action " + links[x] + " (either no axis action or an axis action that is not an Aim action)\r\n"); isValid = false; } } } } if (!isValid) { MessageBox.Show(this.ParentForm, msg.ToString(), "Invalid", MessageBoxButtons.OK, MessageBoxIcon.Error); } return isValid; }
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(); }
public void FromActionRow(Actions.ActionRow actionRow) { if (!actionRow.IsAllyActionNull()) AllyAction = Convert.ToInt32(actionRow.AllyAction); if (!actionRow.IsAxisActionNull()) AxisAction = Convert.ToInt32(actionRow.AxisAction); if (!actionRow.IsRadiusNull()) Radius = Convert.ToInt32(actionRow.Radius); if (!actionRow.IsGoalNull()) Goal = Convert.ToInt32(actionRow.Goal); if (!actionRow.IsGroupNull()) Group = Convert.ToInt32(actionRow.Group); if (!actionRow.IsClassNull()) Class = Convert.ToInt32(actionRow.Class); if (!actionRow.IsCloseNodeNull()) CloseNode = Convert.ToInt32(actionRow.CloseNode); if (!actionRow.IsLinksNull()) Links = actionRow.Links; if (!actionRow.IsProneNull()) Prone = Convert.ToInt32(actionRow.Prone); if (!actionRow.IsActiveNull()) Active = Convert.ToInt32(actionRow.Active); if (!actionRow.IsEntityNull()) Entity = Convert.ToInt32(actionRow.Entity); }
public static void WriteActions(string fileName, Actions actions) { fileName = GetActionFile(fileName); StringBuilder buff = new StringBuilder(); StringBuilder execBuff = new StringBuilder(); int startNode = 0; int endNode = 99; int count = 0; foreach (DataRow row in actions.Action.Rows) { Actions.ActionRow actionRow = (Actions.ActionRow)row; if (actionRow.ID == null) { continue; } // action_axis if (!actionRow.IsAxisActionNull()) { buff.Append("action_axis " + actionRow.ID + " " + actionRow.AxisAction + ";"); } else { buff.Append("action_axis " + actionRow.ID + " -1;"); } // action_allies if (!actionRow.IsAllyActionNull()) { buff.Append("action_allies " + actionRow.ID + " " + actionRow.AllyAction + ";"); } else { buff.Append("action_allies " + actionRow.ID + " -1;"); } if (!actionRow.IsCloseNodeNull()) { buff.Append("action_closenode " + actionRow.ID + " " + actionRow.CloseNode + ";"); } if (!actionRow.IsEntityNull()) { buff.Append("action_ent " + actionRow.ID + " " + actionRow.Entity + ";"); } if (!actionRow.IsRadiusNull()) { buff.Append("action_radius " + actionRow.ID + " " + actionRow.Radius + ";"); } if (!actionRow.IsGoalNull()) { buff.Append("action_goal " + actionRow.ID + " " + actionRow.Goal + ";"); } if (!actionRow.IsGroupNull()) { buff.Append("action_group " + actionRow.ID + " " + actionRow.Group + ";"); } if (!actionRow.IsActiveNull()) { buff.Append("action_active " + actionRow.ID + " " + actionRow.Active + ";"); } if (!actionRow.IsClassNull()) { buff.Append("action_class " + actionRow.ID + " " + actionRow.Class + ";"); } if (!actionRow.IsLinksNull()) { buff.Append("action_links " + actionRow.ID + " " + actionRow.Links + ";"); } if (!actionRow.IsProneNull()) { buff.Append("action_prone " + actionRow.ID + " " + actionRow.Prone + ";"); } 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); }
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(); Actions ds = new Actions(); 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 = "ActionDataTable"; type.Attributes.Add(attribute2); type.Particle = sequence; return type; }
public static System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(System.Xml.Schema.XmlSchemaSet xs) { Actions ds = new Actions(); 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; }
private void InitializeActions(ArrayList actions) { try { if (_actions != null) { _actions.Clear(); } else { _actions = new Actions(); } int count = 0; foreach (Action action in actions) { if (action.AllyAction == 4 || action.AxisAction == 4 || action.AllyAction == 8 || action.AxisAction == 8 || action.AllyAction == 19 || action.AxisAction == 19 || action.AllyAction == 2 || action.AxisAction == 2 || action.AllyAction == 22 || action.AxisAction == 22 || action.AllyAction == 6 || action.AxisAction == 6) { _actions.Action.AddActionRow( Convert.ToString(count), Convert.ToString(action.CloseNode), Convert.ToString(action.AllyAction), Convert.ToString(action.AxisAction), Convert.ToString(action.Radius), Convert.ToString(action.Goal), Convert.ToString(action.Group), Convert.ToString(action.Class), Convert.ToString(action.Links), Convert.ToString(action.Prone), Convert.ToString(action.Active), Convert.ToString(action.Entity)); } count++; } dgActions.DataSource = _actions.Tables[0]; } catch (Exception ex) { MessageBox.Show(this.ParentForm, "Error Loading Actions. " + ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
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(); }