예제 #1
0
        /// <summary>Update the theme contents.</summary>
        /// <param name="themeInformation">The theme Information.</param>
        /// <param name="colorPalette">The color Palette.</param>
        public void UpdateTheme(ThemeInformation themeInformation, ColorPalette colorPalette)
        {
            _information  = themeInformation;
            _colorPalette = colorPalette;

            _rawTheme = ThemeSerialization.Serialize(this);
        }
예제 #2
0
        /// <summary>Loads the <see cref="Theme" /> from the file path.</summary>
        /// <param name="filePath">The file path.</param>
        public void Load(string filePath)
        {
            if (string.IsNullOrEmpty(filePath))
            {
                throw new NoNullAllowedException(ArgumentMessages.IsNullOrEmpty());
            }

            if (!File.Exists(filePath))
            {
                throw new FileNotFoundException(ArgumentMessages.FileNotFound(filePath));
            }

            try
            {
                if (File.Exists(filePath))
                {
                    Theme theme = ThemeSerialization.Deserialize(filePath);
                    UpdateTheme(theme.Information, theme.ColorPalette);
                }
                else
                {
                    Logger.WriteDebug(new FileNotFoundException(ArgumentMessages.FileNotFound(filePath)));
                }
            }
            catch (Exception e)
            {
                Logger.WriteDebug(e);
            }
        }
예제 #3
0
 /// <summary>Loads a <see cref="Theme" /> from resources.</summary>
 /// <param name="themes">The theme.</param>
 private void LoadThemeFromResources(Themes themes)
 {
     try
     {
         Theme theme = ThemeSerialization.Deserialize(themes);
         UpdateTheme(theme.Information, theme.ColorPalette);
     }
     catch (Exception e)
     {
         Logger.WriteDebug(e);
     }
 }
예제 #4
0
        /// <summary>Saves the theme to a file.</summary>
        /// <param name="filePath">The file path.</param>
        public void Save(string filePath)
        {
            if (string.IsNullOrEmpty(filePath))
            {
                throw new NoNullAllowedException(ArgumentMessages.IsNullOrEmpty());
            }

            _rawTheme = ThemeSerialization.Serialize(this);

            if (string.IsNullOrEmpty(_rawTheme))
            {
                throw new ArgumentNullException(nameof(_rawTheme));
            }

            XDocument _theme = XDocument.Parse(_rawTheme);

            _theme.Save(filePath);
        }