//public static List<MarkerViewModel> CreateChooser(List<MapPinType> Pintypes) //{ // if (DesignerProperties.GetIsInDesignMode(new System.Windows.DependencyObject())) // return new List<MarkerViewModel>(); // MarkerViewModel root = new MarkerViewModel("All", "All Items"); // root.IsChecked = true; // foreach(MapPinType mpt in Pintypes) // { // MarkerViewModel child = new MarkerViewModel(mpt.InternalName, mpt.Name); // child.IsChecked = mpt.Shown; // root.Children.Add(child); // } // root.Initialize(); // return new List<MarkerViewModel> { root }; //} public static MarkerViewModel CreateRoot(string iconfolder) { MarkerViewModel root = new MarkerViewModel("All", "All Items"); root._smallIconFolder = iconfolder; return(root); }
private void ToggleGwentPlayers(bool ShowLayer) { Markers[0].IsChecked = !ShowLayer; //turn off all MarkerViewModel gw = Markers[0].FindChild("GwentPlayer"); if (gw != null) { gw.IsChecked = ShowLayer; //enable only gwent players } RandomPlayersOnMap = ShowLayer; }
private void LoadMap(string location) { ObservableCollection <MarkerViewModel> tempmarkers = new ObservableCollection <MarkerViewModel>(); MarkerViewModel root; bool worldWasAlreadyLoaded = MarkersPerWorld.ContainsKey(location); if (worldWasAlreadyLoaded) { root = MarkersPerWorld[location]; } else { root = MarkerViewModel.CreateRoot(Path.Combine(appdir, smalliconpath)); MarkersPerWorld.Add(location, root); } currentLocation = location; CurrentConvertor = ConversionLibrary[location]; if (tileLayer != null) { //fixes memory leak in Mapsui tileLayer.AbortFetch(); MyMapControl.Map.Layers.Clear(); } MbTilesTileSource _source = new MbTilesTileSource(new SQLiteConnectionString(PathLibrary[location], false)); tileLayer = new Mapsui.Layers.TileLayerAbort(_source); MyMapControl.Map.Layers.Add(tileLayer); Dictionary <MapPinType, MapPinCollection> worldpindata = mappindata.GetPins(ShortNameLookup[location]); foreach (MapPinType pintype in worldpindata.Keys) { //I want to do this last if (pintype.InternalName == "RoadSign") { continue; } if (worldWasAlreadyLoaded) { MyMapControl.Map.Layers.Add(root.FindChild(pintype.InternalName).AssociatedLayer); continue; } Mapsui.Layers.MemoryLayer _pointlayer = new Mapsui.Layers.MemoryLayer { Style = null }; List <Mapsui.Geometries.Point> _points = new List <Mapsui.Geometries.Point>(); string path = Path.Combine(appdir, largeiconpath, pintype.IconFile); //Load the image if needed if (!IconCache.ContainsKey(path)) { using (FileStream fs = new FileStream(path, FileMode.Open)) { MemoryStream ms = new MemoryStream(); fs.CopyTo(ms); int id = BitmapRegistry.Instance.Register(ms); IconCache[path] = id; } } if (pintype.InternalName.Contains("Quest")) { foreach (MapPin c in worldpindata[pintype].Locations) { //Try to match Pin coords and Quest coords Quest q = progressStatus.getQuestByCoordinates(Convert.ToInt32(c.Location.X), Convert.ToInt32(c.Location.Y)); //If no matching quest found then still display the Pin bool questNotDoneOrNotFound = q == null || !q.Done; if (questNotDoneOrNotFound) { _points.Add(CurrentConvertor.ToWorldSpace(c.Location)); } } } else { foreach (MapPin c in worldpindata[pintype].Locations) { _points.Add(CurrentConvertor.ToWorldSpace(c.Location)); } } _pointlayer.DataSource = new Mapsui.Providers.MemoryProvider(_points); SymbolStyle _style = new SymbolStyle(); _style.BitmapId = IconCache[path]; _pointlayer.Style = _style; _pointlayer.Name = pintype.Name; MyMapControl.Map.Layers.Add(_pointlayer); root.AddChild(new MarkerViewModel(pintype, _pointlayer)); } root.VerifyCheckState(); AddCircleLayer(); //Add label layer last so that it's on top MyMapControl.Map.Layers.Add(GetLabelLayer(worldpindata)); MyMapControl.Map.BackColor = new Color(184, 222, 230); tempmarkers.Add(root); _markers = tempmarkers; RaisePropertyChanged("Markers"); if (RandomPlayersOnMap) { ToggleGwentPlayers(true); } else { MarkerViewModel gw = Markers[0].FindChild("GwentPlayer"); if (gw != null) { gw.IsChecked = false; } } MyMapControl.Refresh(); }
public void AddChild(MarkerViewModel child) { child._parent = this; child._smallIconFolder = _smallIconFolder; Children.Add(child); }