private bool PrintRoutes(Graphics g) { _pageCounter++; _currentX = _pageMarginLeft; int height = 20; for (int i = _currentRow; i < _routes.Route.Rows.Count; i++) { for (int j = 0; j < _routes.Route.Columns.Count; j++) { DataColumn column = _routes.Route.Columns[j]; int width = GetColumnWidth(column); g.FillRectangle(new SolidBrush(Color.White), _currentX, _currentY, width, height); g.DrawRectangle(new Pen(Color.Black), _currentX, _currentY, width, height); Routes.RouteRow row = (Routes.RouteRow)_routes.Route.Rows[_currentRow]; object obj = row[column]; string val = obj == null ? "" : obj.ToString(); g.DrawString(GetValueString(column, val), _font, new SolidBrush(Color.Black), new RectangleF(_currentX, _currentY, width, height)); //next cell _currentX += width; } _currentX = _pageMarginLeft; //advance to next row _currentY = _currentY + height; _currentRow++; //if portrait is selected if ((_currentY > _pageHeight - _pageMarginBottom) && (!_pageLandscape)) { _currentY = _pageMarginTop; _currentX = _pageMarginLeft; return(true); } //if landscape is selected if ((_currentY > _pageWidth - _pageMarginRight) && (_pageLandscape)) { _currentY = _pageMarginTop; _currentX = _pageMarginLeft; return(true); } } _currentRow = 0; _currentY = _pageMarginTop; _currentX = _pageMarginLeft; return(false); }
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; } }
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); } }