protected void Page_Load(object sender, EventArgs e) { WorkareaGraphBase graph; string tmp = Request.QueryString["type"]; if (tmp == "pie") { graph = new CircleGraph(); } else if (tmp == "time") { graph = new TimeGraph(); } else { graph = new BarGraph(); } graph.Init(this); }
private UIElement GetCirclePath(CircleGraph circleGraph, GraphParams graphParams) { var circleGeometry = new EllipseGeometry { Center = GraphMathUtilities.TransformToCanvasCoords(graphParams, circleGraph.Center), RadiusX = circleGraph.Radius, RadiusY = circleGraph.Radius }; var pathGeometry = PathGeometry.CreateFromGeometry(circleGeometry); var path = new Path { Stroke = new SolidColorBrush(circleGraph.Color), StrokeThickness = 2, Data = pathGeometry }; if (circleGraph.Filled) { path.Fill = new SolidColorBrush(circleGraph.Color); } if (circleGraph.LineType != LinePattern.Solid) { path.StrokeDashArray = GraphMappingUtilities.GetLinePattern(circleGraph.LineType); } return(path); }
public GraphBase CreateGraphFromData(Dictionary <string, string> data) { var graphType = GraphMappingUtilities.GetGraphType(data); GraphBase graph; switch (graphType) { case Models.Enums.GraphType.Circle: graph = new CircleGraph { Radius = Convert.ToDouble(data[GraphVariables.Radius]), Center = GraphMappingUtilities.BuildPoint(data[GraphVariables.Center]), Filled = Convert.ToBoolean(data[GraphVariables.Filled]) }; break; case Models.Enums.GraphType.Triangle: graph = new TriangleGraph { Filled = Convert.ToBoolean(data[GraphVariables.Filled]), Points = GraphMappingUtilities.GetPointsDictionary(data, graphType) }; break; case Models.Enums.GraphType.Rectangle: graph = new RectangleGraph { Filled = Convert.ToBoolean(data[GraphVariables.Filled]), Points = GraphMappingUtilities.GetPointsDictionary(data, graphType) }; break; default: throw new ArgumentOutOfRangeException($"Graph type[{graphType}] is invalid!"); } graph.LineType = GraphMappingUtilities.GetLineType(data); graph.Color = GraphMappingUtilities.BuildColor(data[GraphVariables.Color]); return(graph); }
internal override void CreatePlatforms(float[] oI, float[] aI, int numberGeneric, int numberAgent, float[] agentsInfo) { List <Platform> platforms = new List <Platform>(); int temp = 1; if (numberGeneric > 0) { while (temp <= numberGeneric) { Platform platform = new CirclePlatform((int)oI[(temp * 4) - 4], (int)oI[(temp * 4) - 3], (int)oI[(temp * 4) - 2], (int)oI[(temp * 4) - 1], _model); if (!(platform.Bottom <= _model.Area.Top || platform.Top >= _model.Area.Bottom || platform.Left >= _model.Area.Right || platform.Right <= _model.Area.Left)) { platforms.Add(platform); } temp++; } } temp = 1; if (numberAgent > 0) { while (temp <= numberAgent) { Platform platform = new CirclePlatform((int)oI[(temp * 4) - 4], (int)oI[(temp * 4) - 3], (int)oI[(temp * 4) - 2], (int)oI[(temp * 4) - 1], _model); if (!(platform.Bottom <= _model.Area.Top || platform.Top >= _model.Area.Bottom || platform.Left >= _model.Area.Right || platform.Right <= _model.Area.Left)) { platforms.Add(platform); } temp++; } } Platform groundPlatform = new CirclePlatform(_model.Area.Left + _model.Area.Width / 2, _model.Area.Bottom, 0, _model.Area.Width, _model); groundPlatform.LeftWall = true; groundPlatform.RightWall = true; platforms.Add(groundPlatform); int squareArea = SquareWorldModel.DEFAULT_HEIGHT * SquareWorldModel.DEFAULT_HEIGHT; int width = squareArea / (int)agentsInfo[4]; if (OtherAgentIsInPlay(agentsInfo)) { Platform squareAgent = new CirclePlatform((int)agentsInfo[0], (int)agentsInfo[1], (int)agentsInfo[4], width, _model); platforms.Add(squareAgent); } platforms.Sort(); List <Platform> finalPlatforms = SplitPlatforms(platforms); _platforms = new ConcurrentDictionary <int, Platform>(); for (temp = 0; temp < finalPlatforms.Count; temp++) { finalPlatforms[temp].ID = temp; _platforms.GetOrAdd(temp, finalPlatforms[temp]); } graph = new CircleGraph(new List <Platform>(_platforms.Values)); // ConsolePrinter.PrintLine(graph.ToString()); }