private void loadSavedInfo() { ChooserViewModel root = itemChooser.Items[0] as ChooserViewModel; List <string> categories = root.GetSelectedCategories(); map.ClearMarkers(); map.MarkerImages.Clear(); AddIcon(map.MarkerImages, -1, "noicon"); List <string> iconNames = new List <string>(); try { Dictionary <string, SavedSettlementInfo> settlements = _saveFile.GetSettlementsInfo(); Dictionary <string, int> counts; loadMarkers(categories, map.RootLayer.MarkerCache, iconNames, map.MarkerImages, _saveFile.GetSavedObjectInfo(out counts), settlements); foreach (string c in counts.Keys) { root.UpdateCount(c, counts[c], SavedObjectInfoLookup.TotalCountByCategory[c]); } } catch (Exception ex) { Error.Text = ex.Message; Renderer.AnimateOpacity(errorBorder, 0.75, 0, 8000); return; } map.Refresh(); }
public static List <ChooserViewModel> CreateChooser() { if (DesignerProperties.GetIsInDesignMode(new System.Windows.DependencyObject())) { return(new List <ChooserViewModel>()); } ChooserViewModel root = new ChooserViewModel("All Items", "All Items"); foreach (string categoryPath in SavedObjectInfoLookup.Categories) { string[] path = categoryPath.Split('\\'); ChooserViewModel newroot = root; ChooserViewModel oldroot = root; foreach (string s in path) { newroot = newroot.getChild(s); if (newroot == null) { newroot = new ChooserViewModel(s, s); oldroot.Children.Add(newroot); } oldroot = newroot; } oldroot._category = categoryPath; } root.Initialize(); return(new List <ChooserViewModel> { root }); }
private ChooserViewModel getByPath(string[] path) { ChooserViewModel current = this; foreach (string s in path) { current = current.getChild(s); if (current == null) { return(null); } } return(current); }
public Window1() { _dispatcherTimer.Tick += new EventHandler(_dispatcherTimer_Tick); AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; InitializeComponent(); map.ErrorMessageChanged += map_ErrorMessageChanged; Loaded += Window1_Loaded; ChooserViewModel root = itemChooser.Items[0] as ChooserViewModel; CommandBindings.Add( new CommandBinding( ApplicationCommands.Undo, (sender, e) => // Execute { e.Handled = true; root.IsChecked = false; itemChooser.Focus(); }, (sender, e) => // CanExecute { e.Handled = true; e.CanExecute = (root.IsChecked != false); })); itemChooser.Focus(); string appdir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); TileSource tileSource = new TileSource( new FileTileProvider(new FileCache(appdir + "\\Tiles", "jpg")), new TileSchema() ); map.RootLayer = new TileLayer(tileSource); _fileSystemWatcher.Changed += fileSystemWatcher_Changed; InitializeTransform(tileSource.Schema); }
public void UpdateCount(string category, int have, int shouldhave) { if (Children == null || Children.Count == 0) { return; } string[] path = category.Split('\\'); ChooserViewModel m = getByPath(path); if (m != null) { if (have != shouldhave) { m.IsInComplete = true; } else { m.IsInComplete = false; } m.Text = string.Format("{0} ({1}/{2})", path[path.Length - 1], have, shouldhave); } }
public static List<ChooserViewModel> CreateChooser() { if (DesignerProperties.GetIsInDesignMode(new System.Windows.DependencyObject())) { return new List<ChooserViewModel>(); } ChooserViewModel root = new ChooserViewModel("All Items", "All Items"); foreach (string categoryPath in SavedObjectInfoLookup.Categories) { string[] path = categoryPath.Split('\\'); ChooserViewModel newroot = root; ChooserViewModel oldroot = root; foreach (string s in path) { newroot = newroot.getChild(s); if (newroot == null) { newroot = new ChooserViewModel(s, s); oldroot.Children.Add(newroot); } oldroot = newroot; } oldroot._category = categoryPath; } root.Initialize(); return new List<ChooserViewModel> { root }; }