示例#1
0
        public MainWindowViewModel()
        {
            State = new State();
            journalEntryConverter = new JournalEntryConverter(State.Cargo);
            blueprintConverter    = new BlueprintConverter(State.Cargo);
            LoadBlueprints();
            Filters = new BlueprintFilters(Blueprints);

            LoadState();
        }
示例#2
0
        private void LoadBlueprints()
        {
            var blueprintsJson = IOManager.GetBlueprintsJson();

            Blueprints = new List <Blueprint>(JsonConvert.DeserializeObject <List <Blueprint> >(blueprintsJson, blueprintConverter));
            if (Properties.Settings.Default.Favorites == null)
            {
                Properties.Settings.Default.Favorites = new StringCollection();
            }

            if (Properties.Settings.Default.Ignored == null)
            {
                Properties.Settings.Default.Ignored = new StringCollection();
            }

            foreach (var blueprint in Blueprints)
            {
                if (Properties.Settings.Default.Favorites.Contains(blueprint.ToString()))
                {
                    blueprint.Favorite = true;
                    favoritedBlueprints.Add(blueprint);
                }

                if (Properties.Settings.Default.Ignored.Contains(blueprint.ToString()))
                {
                    blueprint.Ignored = true;
                }

                blueprint.PropertyChanged += (o, e) =>
                {
                    if (e.PropertyName == "Favorite")
                    {
                        if (blueprint.Favorite)
                        {
                            Properties.Settings.Default.Favorites.Add(blueprint.ToString());
                            favoritedBlueprints.Add(blueprint);
                        }
                        else
                        {
                            Properties.Settings.Default.Favorites.Remove(blueprint.ToString());
                            favoritedBlueprints.Remove(blueprint);
                        }

                        Properties.Settings.Default.Save();
                    }
                    else if (e.PropertyName == "Ignored")
                    {
                        if (blueprint.Ignored)
                        {
                            Properties.Settings.Default.Ignored.Add(blueprint.ToString());
                        }
                        else
                        {
                            Properties.Settings.Default.Ignored.Remove(blueprint.ToString());
                        }

                        Properties.Settings.Default.Save();
                    }
                };
            }

            Filters = new BlueprintFilters(Blueprints);
        }