예제 #1
0
        private void LoadPresetData(object param)
        {
            //IsBusy = true;

            StatusMessage = string.Empty;

            BuildingPresets buildingPresets = null;

            try
            {
                buildingPresets = SerializationHelper.LoadFromFile <BuildingPresets>(PresetsVM.SelectedFile);
            }
            catch (Exception ex)
            {
                var message = $"Error parsing {nameof(BuildingPresets)}.";
                Trace.WriteLine($"{message}{Environment.NewLine}{ex}");
                MessageBox.Show(message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);

                StatusMessage = $"{message} -> Maybe wrong selected file?";
                return;
            }

            PresetsVersion = buildingPresets.Version;

            fillAvailableTemplates(buildingPresets);
            fillAvailableIdentifiers(buildingPresets);
            fillTemplateIdentifierMapping(buildingPresets);

            AvailableColorSchemes.Clear();

            ColorPresets colorPresets = null;

            try
            {
                ColorPresetsLoader loader = new ColorPresetsLoader();
                colorPresets = loader.Load(ColorsVM.SelectedFile);
            }
            catch (Exception ex)
            {
                var message = $"Error parsing {nameof(ColorPresets)}.";
                Trace.WriteLine($"{message}{Environment.NewLine}{ex}");
                MessageBox.Show(message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);

                StatusMessage = $"{message} -> Maybe wrong selected file?";
                return;
            }

            foreach (var curScheme in colorPresets.AvailableSchemes)
            {
                AvailableColorSchemes.Add(new ColorSchemeViewModel(curScheme));
            }
            //var defaultScheme = loader.LoadDefaultScheme(vmColors.SelectedFile);

            ColorPresetsVersion        = colorPresets.Version;
            ColorPresetsVersionUpdated = ColorPresetsVersion;

            SelectedColorScheme = AvailableColorSchemes.First();

            //IsBusy = false;
        }
예제 #2
0
        private void AddColorScheme(object param)
        {
            var newScheme = new ColorSchemeViewModel(new ColorScheme
            {
                Name = NewColorSchemeName
            });

            AvailableColorSchemes.Add(newScheme);
            SelectedColorScheme = newScheme;
        }