public static Control CreateCustomOrderSymbol(object orderOrStop) { DataGraphicObject graphicObject = null; // Create data graphic object that depends on object type. if (orderOrStop is Stop) { graphicObject = StopGraphicObject.Create(orderOrStop as Stop); } else if (orderOrStop is Order) { graphicObject = OrderGraphicObject.Create(orderOrStop as Order); } else { Debug.Assert(false); // Not supported. } // Init graphics object by order symbology manager. SymbologyManager.InitGraphic(graphicObject); // Create symbol control var control = new ESRI.ArcLogistics.App.DragAndDrop.Adornments.Controls.SymbolControl (graphicObject.Symbol.ControlTemplate); // Copy attributes from graphics object to symbol control. control.SymbologyContextDictionary = graphicObject.Attributes; // Offset symbol so it is not rendered shifted. control.RenderTransform = new TranslateTransform(-control.OffsetX, -control.OffsetY); return(control); }
/// <summary> /// Create graphic object for data element. /// </summary> /// <param name="data">Data object to show on map.</param> /// <param name="typeOfData">Type of data.</param> /// <param name="graphicObjectType">Graphic, associated with data object.</param> /// <param name="layerContext">Layer context.</param> /// <returns>Created graphic object.</returns> public Graphic CreateGraphic(object data, Type typeOfData, Type graphicObjectType, object layerContext) { Graphic graphic = null; Type type = data.GetType(); if (type == typeof(Location)) { graphic = LocationGraphicObject.Create((Location)data); } else if (type == typeof(Order)) { graphic = OrderGraphicObject.Create((Order)data); } else if (type == typeof(EditingMarker)) { graphic = EditMarkerGraphicObject.Create((EditingMarker)data); } else if (type == typeof(AddressCandidate)) { graphic = CandidateGraphicObject.Create((AddressCandidate)data); } else if (type == typeof(Route)) { graphic = RouteGraphicObject.Create((Route)data); } else if (type == typeof(Stop)) { graphic = StopGraphicObject.Create((Stop)data); } else if (type == typeof(Zone)) { graphic = ZoneGraphicObject.Create((Zone)data); } else if (type == typeof(Barrier)) { graphic = BarrierGraphicObject.Create((Barrier)data); } else { Debug.Assert(false); } DataGraphicObject dataGraphicObject = graphic as DataGraphicObject; if (dataGraphicObject != null) { dataGraphicObject.ParentLayer = this; _graphicDictionary.Add(data, dataGraphicObject); } return(graphic); }