public C1Mapper(IMapperOwner owner) { InitializeComponent(); #if !DYN _c1maps = new C1.WPF.Maps.C1Maps(); #else _c1maps = DynLoader.CreateC1MapsInstance("C1.WPF.Maps.C1Maps"); #endif // this._grid.Children.Add(_c1maps); _owner = owner; _owner.LayersChanged += new EventHandler(Map_LayersChanged); _owner.Layers.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(Layers_CollectionChanged); this.Background = Util.BrushFromGdiColor(Utils.FromWpfColor(_owner.BackColor)); // hide/show standard tools as required: this.LayoutUpdated += (ss, ee) => HideShowTools(); // TBD: add a property to automatically move scale so as not to obscure data _c1maps.FadeInTiles = false; #if !DYN _c1maps.TilesLoadProgress += new EventHandler <TilesLoadProgressEventArgs>(_c1maps_TilesLoadProgress); #else var handlerType = typeof(EventHandler <>).MakeGenericType(DynLoader.GetC1MapsType("TilesLoadProgressEventArgs")); var handlerMethod = typeof(C1Mapper).GetMethod("_c1maps_TilesLoadProgress", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); var handler = Delegate.CreateDelegate(handlerType, this, handlerMethod); _c1maps.TilesLoadProgress += handler; #endif // ResetLayers(); }
public LinesMapsLayer(LayerBase owner) : base(owner) { #if !DYN _lines = new ObservableCollection <WPF.Maps.C1VectorPolyline>(); #else var genericCollType = typeof(ObservableCollection <>); var specLinesCollType = genericCollType.MakeGenericType(DynLoader.GetC1MapsType("C1.WPF.Maps.C1VectorPolyline")); _lines = Activator.CreateInstance(specLinesCollType); #endif _vectorLayer.ItemsSource = _lines; }
public PointsMapsLayer(LayerBase owner) : base(owner) { #if !DYN _marks = new ObservableCollection <WPF.Maps.C1VectorPlacemark>(); #else var genericCollType = typeof(ObservableCollection <>); var specMarksCollType = genericCollType.MakeGenericType(DynLoader.GetC1MapsType("C1.WPF.Maps.C1VectorPlacemark")); _marks = Activator.CreateInstance(specMarksCollType); #endif _vectorLayer.ItemsSource = _marks; }
/// <summary> /// Loads a KML or KMZ file from the specified stream into the layer. /// </summary> /// <param name="vl">The layer to load the stream into.</param> /// <param name="stream">The source stream.</param> /// <param name="addingItemProc">The callback to call for each KML item.</param> /// <param name="maxBounds">OUT: The union of all loaded items' bounds.</param> private static void LoadKML(dynamic vl, Stream stream, AddingKmlItemDelegate addingItemProc, out Rect maxBounds) { maxBounds = Rect.Empty; #if !DYN var vects = KmlReader.Read(stream); #else dynamic vects = DynLoader.CallC1MapsStaticMethod("C1.WPF.Maps.KmlReader", "Read", stream); #endif vl.BeginUpdate(); #if !DYN foreach (C1VectorItemBase vect in vects) { #else for (int i = 0; i < vects.Count; ++i) { dynamic vect = vects[i]; #endif if (addingItemProc != null) { var oldName = ToolTipService.GetToolTip(vect) as string; var newName = oldName; Nullable <System.Drawing.Color> stroke, fill; bool trackCoords; if (!addingItemProc(ref newName, out stroke, out fill, out trackCoords)) { continue; } if (stroke.HasValue) { vect.Stroke = Util.BrushFromGdiColor(stroke.Value); } if (fill.HasValue) { vect.Fill = Util.BrushFromGdiColor(fill.Value); } if (newName != oldName) { ToolTipService.SetToolTip(vect, newName); #if !DYN if (vect is C1VectorPlacemark) { ((C1VectorPlacemark)vect).Label = newName; } #else if (vect.GetType() == DynLoader.GetC1MapsType("C1VectorPlacemark")) { vect.Label = newName; } #endif } if (trackCoords) { maxBounds.Union(vect.Bounds); } } else { maxBounds.Union(vect.Bounds); } vl.Children.Add(vect); } vl.EndUpdate(); }