public void AddColorSchemeAction()
 {
     if (SelectedColorSchemeCategory != null)
     {
         var scheme = _colorSchemeResource.NewScheme(SelectedColorSchemeCategory);
         ColorSchemes.Add(scheme);
     }
 }
        public HouseholdPlanPresenter([NotNull] ApplicationPresenter applicationPresenter, [NotNull] HouseholdPlanView view,
                                      [NotNull] HouseholdPlan householdPlan)
            : base(view, "ThisHouseholdPlan.HeaderString", householdPlan, applicationPresenter)
        {
            SuspendStatistics = true;
            CalcObjectTypes   = new ObservableCollection <CalcObjectType>
            {
                CalcObjectType.ModularHousehold
            };

            _householdPlan = householdPlan;
            foreach (var entry in _householdPlan.Entries)
            {
                entry.AllDeviceActions = Sim.DeviceActions.It;
            }

            foreach (var dc in Sim.DeviceCategories.MyItems)
            {
                dc.RefreshSubDevices();
            }

            _householdPlan.RefreshTagCategories(Sim.Affordances.It);

            SortByOptions.Add("By Name");
            SortByOptions.Add("By Person");

            SortByOptions.Add("By Activiations");
            SortByOptions.Add("By Desire");
            SortByOptions.Add("By Total Time");
            SortByOptions.Add("By Category");
            SortBy = SortByOptions[1];
            Resort();
            if (householdPlan.CalcObject != null)
            {
                if (householdPlan.CalcObject.GetType() == typeof(ModularHousehold))
                {
                    SelectedCalcObjectType = CalcObjectType.ModularHousehold;
                }
                else
                {
                    throw new LPGException("Unknown ");
                }
            }
            else
            {
                SelectedCalcObjectType = CalcObjectType.ModularHousehold;
            }

            ColorSchemes.Add("By Activations");
            ColorSchemes.Add("By Traits");
            SelectedColorScheme = ColorSchemes[0];
            RefreshPlan();
            RefreshAlTraits();
            RefreshAlAssignments();
        }
        public void LoadColorSchemes()
        {
            var fileList = Directory.GetFiles(DirectoryGuard.ColorSchemesDirectory, "*.xml");

            foreach (var s in fileList)
            {
                var xDoc = XDocument.Load(s);

                if (xDoc.Root == null)
                {
                    continue;
                }

                var colors = xDoc.XPathSelectElements("/ColorScheme/Color");

                var lightColorScheme = xDoc.Root.XPathSelectElement("UsesLightIconTheme");
                var darkColorScheme  = xDoc.Root.XPathSelectElement("UsesDarkIconTheme");

                var dict = colors.ToDictionary(color => color.Attribute("Key").Value, color => color.Attribute("Value").Value);

                if (darkColorScheme != null)
                {
                    lightColorScheme = null; // to prevent using both at the same time
                    dict.Add("UsesDarkIconTheme", "true");
                }
                else
                {
                    dict.Add("UsesDarkIconTheme", "false");
                }

                dict.Add("UsesLightIconTheme",
                         lightColorScheme != null ? "true" : "false");

                if (xDoc.Root != null)
                {
                    ColorSchemes.Add(xDoc.Root.Attribute("Name").Value, dict);
                }
            }

            ApplyColors();
        }