コード例 #1
0
        /// <summary>
        /// Returns the registry subtree for a specified profile.
        /// </summary>
        /// <param name="profileKey"></param>
        /// <returns></returns>
        private SettingsPersisterHelper getProfileSettings(string profileKey)
        {
            SettingsPersisterHelper settings = SettingsRoot;

            settings = settings.GetSubSettings(_destinationKey + @"\" + profileKey);
            return(settings);
        }
コード例 #2
0
        public void SaveAsDefault(ImagePropertiesInfo imageInfo)
        {
            ImageDecoratorsList decorators = imageInfo.ImageDecorators;

            //delete the existing image settings
            DeleteImageSettings(_contextId);

            using (SettingsPersisterHelper contextImageSettings = GetImageSettingsPersister(_contextId, true))
            {
                //loop over the image decorators and save the settings of any decorators that are defaultable.
                StringBuilder sb = new StringBuilder();
                foreach (string decoratorId in decorators.GetImageDecoratorIds())
                {
                    ImageDecorator decorator = decorators.GetImageDecorator(decoratorId);
                    if (decorator.IsDefaultable)
                    {
                        if (sb.Length > 0)
                        {
                            sb.Append(",");
                        }
                        sb.Append(decorator.Id);
                        using (SettingsPersisterHelper decoratorDefaultSettings = contextImageSettings.GetSubSettings(decoratorId))
                        {
                            PluginSettingsAdaptor settings = new PluginSettingsAdaptor(decoratorDefaultSettings);
                            IProperties           decoratorCurrentSettings = decorators.GetImageDecoratorSettings(decoratorId);
                            CopySettings(decoratorCurrentSettings, settings);
                            ImageDecoratorEditorContext editorContext =
                                new ImageDecoratorEditorContextImpl(decoratorCurrentSettings, null, imageInfo, new NoOpUndoUnitFactory(), _decoratorsManager.CommandManager);
                            decorator.ApplyCustomizeDefaultSettingsHook(editorContext, settings);
                        }
                    }
                }
                contextImageSettings.SetString(ImageDecoratorsListKey, sb.ToString());
            }
        }
コード例 #3
0
        /// <summary>
        /// Remove the destination profile associated with the specified key.
        /// </summary>
        /// <param name="key"></param>
        public void deleteProfile(string key)
        {
            SettingsPersisterHelper settings = SettingsRoot;

            settings = settings.GetSubSettings(_destinationKey);
            settings.SettingsPersister.UnsetSubSettingsTree(key);
        }
コード例 #4
0
 public PostHtmlEditingSettings(string blogId)
 {
     _blogId = blogId;
     using (SettingsPersisterHelper blogSettings = BlogSettings.GetWeblogSettingsKey(blogId))
     {
         _editorTemplateSettings = blogSettings.GetSubSettings("EditorTemplate");
     }
 }
コード例 #5
0
 /// <summary>
 /// Get the settings persister for the specified image context.
 /// </summary>
 /// <param name="contextId"></param>
 /// <param name="autoCreate"></param>
 /// <returns></returns>
 private static SettingsPersisterHelper GetImageSettingsPersister(string contextId, bool autoCreate)
 {
     //unset the existing image defaults
     using (SettingsPersisterHelper contextRootSettings = RootSettingsKey.GetSubSettings(contextId))
     {
         if (autoCreate || contextRootSettings.HasSubSettings(ImageDefaultsKey))
         {
             return(contextRootSettings.GetSubSettings(ImageDefaultsKey));
         }
         else
         {
             return(null);
         }
     }
 }
コード例 #6
0
 /// <summary>
 /// Load the default image decorators for the current image context.
 /// </summary>
 /// <returns></returns>
 public ImageDecoratorsList LoadDefaultImageDecoratorsList()
 {
     using (SettingsPersisterHelper contextImageSettings = GetImageSettingsPersister(_contextId, false))
     {
         ImageDecoratorsList decoratorsList;
         if (contextImageSettings == null)
         {
             decoratorsList = GetInitialLocalImageDecoratorsList();
         }
         else
         {
             decoratorsList = new ImageDecoratorsList(_decoratorsManager, new BlogPostSettingsBag(), false);
             string[] decoratorIds = contextImageSettings.GetString(ImageDecoratorsListKey, "").Split(',');
             foreach (string decoratorId in decoratorIds)
             {
                 ImageDecorator imageDecorator = _decoratorsManager.GetImageDecorator(decoratorId);
                 if (imageDecorator != null) //can be null if the decorator is no longer valid
                 {
                     decoratorsList.AddDecorator(imageDecorator);
                     using (SettingsPersisterHelper decoratorDefaultSettings = contextImageSettings.GetSubSettings(decoratorId))
                     {
                         PluginSettingsAdaptor settings = new PluginSettingsAdaptor(decoratorDefaultSettings);
                         CopySettings(settings, decoratorsList.GetImageDecoratorSettings(decoratorId));
                     }
                 }
             }
         }
         //now add the implicit decorators IFF they aren't already in the list
         decoratorsList.MergeDecorators(GetImplicitLocalImageDecorators());
         return(decoratorsList);
     }
 }
コード例 #7
0
 public VideoServiceSettings(string serviceId, SettingsPersisterHelper parentPersister)
 {
     _settings = parentPersister.GetSubSettings(serviceId);
 }
コード例 #8
0
        public static void Initialize(Assembly rootAssembly, string installationDirectory, string settingsRootKeyName, string productName)
        {
            // initialize name and version based on assembly metadata
            string          rootAssemblyPath = rootAssembly.Location;
            FileVersionInfo fileVersionInfo  = FileVersionInfo.GetVersionInfo(rootAssemblyPath);

            _companyName    = fileVersionInfo.CompanyName;
            _productName    = productName;
            _productVersion = String.Format(CultureInfo.InvariantCulture, "{0}.{1}.{2}.{3}", fileVersionInfo.ProductMajorPart, fileVersionInfo.ProductMinorPart, fileVersionInfo.ProductBuildPart, fileVersionInfo.ProductPrivatePart);
            _appVersion     = new Version(_productVersion);

            Debug.Assert(_appVersion.Build < UInt16.MaxValue &&
                         _appVersion.Revision < UInt16.MaxValue &&
                         _appVersion.Major < UInt16.MaxValue &&
                         _appVersion.Minor < UInt16.MaxValue, "Invalid ApplicationVersion: " + _appVersion);

            // set installation directory and executable name
            _installationDirectory = installationDirectory;
            _mainExecutableName    = Path.GetFileName(rootAssemblyPath);

            // initialize icon/user-agent, etc.
            _userAgent        = FormatUserAgentString(ProductName, true);
            _productIcon      = ResourceHelper.LoadAssemblyResourceIcon("Images.ApplicationIcon.ico");
            _productIconSmall = ResourceHelper.LoadAssemblyResourceIcon("Images.ApplicationIcon.ico", 16, 16);

            // initialize IsHighContrastWhite and IsHighContrastBlack
            InitializeIsHighContrastBlackWhite();

            _settingsRootKeyName = settingsRootKeyName;
            string dataPath;

            // see if we're running in portable mode
#if PORTABLE
            dataPath = Path.Combine(_installationDirectory, "UserData");
            if (Directory.Exists(dataPath))
            {
                _portable = true;
                // initialize application data directories
                _applicationDataDirectory      = Path.Combine(dataPath, "AppData\\Roaming");
                _localApplicationDataDirectory = Path.Combine(dataPath, "AppData\\Local");

                // initialize settings
                _userSettingsRoot        = new SettingsPersisterHelper(XmlFileSettingsPersister.Open(Path.Combine(dataPath, "UserSettings.xml")));
                _machineSettingsRoot     = new SettingsPersisterHelper(XmlFileSettingsPersister.Open(Path.Combine(dataPath, "MachineSettings.xml")));
                _preferencesSettingsRoot = _userSettingsRoot.GetSubSettings(ApplicationConstants.PREFERENCES_SUB_KEY);
            }
            else
#endif
            {
                _portable = false;
                // initialize application data directories.
                _applicationDataDirectory      = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), AppDataFolderName);
                _localApplicationDataDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), AppDataFolderName);

                // initialize settings
                _userSettingsRoot        = new SettingsPersisterHelper(new RegistrySettingsPersister(Registry.CurrentUser, SettingsRootKeyName));
                _machineSettingsRoot     = new SettingsPersisterHelper(new RegistrySettingsPersister(Registry.LocalMachine, SettingsRootKeyName));
                _preferencesSettingsRoot = _userSettingsRoot.GetSubSettings(ApplicationConstants.PREFERENCES_SUB_KEY);

                dataPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            }

            _myWeblogPostsFolder = _userSettingsRoot.GetString("PostsDirectory", null);
            if (string.IsNullOrEmpty(_myWeblogPostsFolder))
            {
                if ((_productName == DefaultProductName) && (string.IsNullOrEmpty(dataPath)))
                {
                    throw new DirectoryException(MessageId.PersonalDirectoryFail);
                }
                else
                {
                    _myWeblogPostsFolder = Path.Combine(dataPath, "My Weblog Posts");
                }
            }

            // initialize diagnostics
            InitializeLogFilePath();
            _applicationDiagnostics = new ApplicationDiagnostics(LogFilePath, rootAssembly.GetName().Name);

            if (!Directory.Exists(_applicationDataDirectory))
            {
                Directory.CreateDirectory(_applicationDataDirectory);
            }
            if (!Directory.Exists(_localApplicationDataDirectory))
            {
                Directory.CreateDirectory(_localApplicationDataDirectory);
            }
        }