/// <summary> /// Creates UIElement for stop. /// </summary> /// <param name="stop">Stop as source.</param> /// <param name="mapImage">Map image.</param> /// <param name="fillingBrush">Filling brush.</param> /// <returns>Created element fro stop.</returns> private UIElement _CreateStopUIElement(Stop stop, MapImage mapImage, SolidColorBrush fillingBrush) { Debug.Assert(null != stop); Debug.Assert(null != mapImage); Debug.Assert(null != fillingBrush); UIElement element = null; if (stop.AssociatedObject is Order) { SysWindows.Point position = _ConvertPoint(stop.MapLocation.Value, (EnvelopeN)mapImage.Extent, mapImage.ImageWidth, mapImage.ImageHeight); var stopSymbolBox = new SymbolControl(_sequenceSymbolTemplate); stopSymbolBox.Margin = new Thickness(position.X, position.Y, 0, 0); stopSymbolBox.SequenceNumber = stop.OrderSequenceNumber.Value.ToString(); stopSymbolBox.Fill = fillingBrush; element = stopSymbolBox; } else if (stop.AssociatedObject is Location) { SysWindows.Point position = _ConvertPoint(stop.MapLocation.Value, (EnvelopeN)mapImage.Extent, mapImage.ImageWidth, mapImage.ImageHeight); var control = new SysControls.Control(); control.Template = _stopSymbolTemplate; control.Margin = new Thickness(position.X, position.Y, 0, 0); element = control; } // else Do nothing return(element); }
/// <summary> /// Creates UIElement for stop. /// </summary> /// <param name="stop">Stop as source.</param> /// <param name="mapImage">Map image.</param> /// <param name="fillingBrush">Filling brush.</param> /// <returns>Created element fro stop.</returns> private UIElement _CreateStopUIElement(Stop stop, MapImage mapImage, SolidColorBrush fillingBrush) { Debug.Assert(null != stop); Debug.Assert(null != mapImage); Debug.Assert(null != fillingBrush); UIElement element = null; if (stop.AssociatedObject is Order) { SysWindows.Point position = _ConvertPoint(stop.MapLocation.Value, (EnvelopeN)mapImage.Extent, mapImage.ImageWidth, mapImage.ImageHeight); var stopSymbolBox = new SymbolControl(_sequenceSymbolTemplate); stopSymbolBox.Margin = new Thickness(position.X, position.Y, 0, 0); stopSymbolBox.SequenceNumber = stop.OrderSequenceNumber.Value.ToString(); stopSymbolBox.Fill = fillingBrush; element = stopSymbolBox; } else if (stop.AssociatedObject is Location) { SysWindows.Point position = _ConvertPoint(stop.MapLocation.Value, (EnvelopeN)mapImage.Extent, mapImage.ImageWidth, mapImage.ImageHeight); var control = new SysControls.Control(); control.Template = _stopSymbolTemplate; control.Margin = new Thickness(position.X, position.Y, 0, 0); element = control; } // else Do nothing return element; }
/// <summary> /// Creates canvas with invalidated route and its stops. /// </summary> /// <param name="route">Route to draw.</param> /// <param name="sortedRouteStops">Sorted stops from route.</param> /// <param name="mapImage">Map image.</param> /// <returns>Canvas with invalidated route and its stops.</returns> private SysControls.Canvas _CreateRouteCanvas(Route route, IList<Stop> sortedRouteStops, MapImage mapImage) { Debug.Assert(null != route); Debug.Assert(null != mapImage); Debug.Assert(null != sortedRouteStops); // create canvas var canvas = new SysControls.Canvas(); canvas.InvalidateVisual(); canvas.Height = mapImage.ImageHeight; canvas.Width = mapImage.ImageWidth; // init route brush from route color System.Drawing.Color color = route.Color; var mediaColor = SysWindows.Media.Color.FromArgb(color.A, color.R, color.G, color.B); var fillingBrush = new SolidColorBrush(mediaColor); // create and init route image SymbolControl routeBox = new SymbolControl(_routeSymbolTemplate); routeBox.Geometry = _CreatePath(route, sortedRouteStops, mapImage.Extent, mapImage.ImageWidth, mapImage.ImageHeight); routeBox.Fill = (SolidColorBrush)fillingBrush.GetCurrentValueAsFrozen(); routeBox.HorizontalAlignment = HorizontalAlignment.Stretch; routeBox.VerticalAlignment = VerticalAlignment.Stretch; // draw route canvas.Children.Add(routeBox); // draw stops - from last to first (visual elements) int stopLastIndex = sortedRouteStops.Count - 1; for (int index = stopLastIndex; index >= 0; --index) { Stop stop = sortedRouteStops[index]; if (!stop.MapLocation.HasValue) continue; // skip empty bool isVisible = true; if (stop.AssociatedObject is Location) { if (index == 0) { isVisible = _showLeadingStemTime; } else if (index == stopLastIndex) { isVisible = _showTrailingStemTime; } // else do nothing } if (isVisible) { UIElement element = _CreateStopUIElement(stop, mapImage, fillingBrush); if (element != null) canvas.Children.Add(element); } } return canvas; }
/// <summary> /// Creates canvas with invalidated route and its stops. /// </summary> /// <param name="route">Route to draw.</param> /// <param name="sortedRouteStops">Sorted stops from route.</param> /// <param name="mapImage">Map image.</param> /// <returns>Canvas with invalidated route and its stops.</returns> private SysControls.Canvas _CreateRouteCanvas(Route route, IList <Stop> sortedRouteStops, MapImage mapImage) { Debug.Assert(null != route); Debug.Assert(null != mapImage); Debug.Assert(null != sortedRouteStops); // create canvas var canvas = new SysControls.Canvas(); canvas.InvalidateVisual(); canvas.Height = mapImage.ImageHeight; canvas.Width = mapImage.ImageWidth; // init route brush from route color System.Drawing.Color color = route.Color; var mediaColor = SysWindows.Media.Color.FromArgb(color.A, color.R, color.G, color.B); var fillingBrush = new SolidColorBrush(mediaColor); // create and init route image SymbolControl routeBox = new SymbolControl(_routeSymbolTemplate); routeBox.Geometry = _CreatePath(route, sortedRouteStops, mapImage.Extent, mapImage.ImageWidth, mapImage.ImageHeight); routeBox.Fill = (SolidColorBrush)fillingBrush.GetCurrentValueAsFrozen(); routeBox.HorizontalAlignment = HorizontalAlignment.Stretch; routeBox.VerticalAlignment = VerticalAlignment.Stretch; // draw route canvas.Children.Add(routeBox); // draw stops - from last to first (visual elements) int stopLastIndex = sortedRouteStops.Count - 1; for (int index = stopLastIndex; index >= 0; --index) { Stop stop = sortedRouteStops[index]; if (!stop.MapLocation.HasValue) { continue; // skip empty } bool isVisible = true; if (stop.AssociatedObject is Location) { if (index == 0) { isVisible = _showLeadingStemTime; } else if (index == stopLastIndex) { isVisible = _showTrailingStemTime; } // else do nothing } if (isVisible) { UIElement element = _CreateStopUIElement(stop, mapImage, fillingBrush); if (element != null) { canvas.Children.Add(element); } } } return(canvas); }