Ejemplo n.º 1
0
        protected override void ConfigurationPresent()
        {
            config = ObjectFactory.LoadConfiguration(VisualStudioCloseQuestion.ConfigurationName);

            // present configuration on the screen:
            promptOnClosing.Checked = config.GetUInt(VisualStudioCloseQuestion.Config_Prompt, 0) > 0;
        }
Ejemplo n.º 2
0
        private void CheckVersion()
        {
            PersistentStorageData data = PersistentStorageHelper.Load(PersistantStorageName);
            bool executeCheck          = false;

            if (data != null && data.Count > 0)
            {
                // get the last update date from the registry:
                lastUpdateCheck = data.GetDateTime("LastUpdateDate");
                sleepTime       = (int)data.GetUInt("SleepTimeBeforeUpdateCheck", SleepTimeBeforeUpdateCheck) * 1000;

                // check if update-check was performed at least one week ago:
                if (lastUpdateCheck.AddDays(PeriodBeforeUpdateCheck) < DateTime.Today)
                {
                    executeCheck = true;
                }
                else
                {
                    // prevent updating the date inside the registry:
                    lastUpdateCheck = DateTime.MinValue;
                }
            }
            else
            {
                executeCheck = true;
            }

            if (executeCheck && sleepTime != 0)
            {
                // start asynchronously new thread that will perform check and update the registry:
                Thread threadCheck = new Thread(PerformUpdateCheck);
                threadCheck.Start();
            }
        }
Ejemplo n.º 3
0
        protected override void ConfigurationUpdate(out PersistentStorageData actionConfig)
        {
            // update configuration:
            config.Add(VisualStudioCloseQuestion.Config_Prompt, (uint)(promptOnClosing.Checked ? 1 : 0));

            actionConfig = config;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Performs initialization of this action and
        /// also registers all the UI elements required by the action, e.g.: menus / menu groups / toolbars.
        /// </summary>
        public void Initialize(IPackageEnvironment env, IMenuCreator mc)
        {
            solutionListener = new SolutionEventsListener(env.DTE);
            solutionListener.SolutionQueryClose += SolutionEvents_SolutionQueryClose;

            config = ObjectFactory.LoadConfiguration(ConfigurationName);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Loads system assemblies and the list of forbidden names.
        /// </summary>
        private void LoadAndSortSystemAssemblies()
        {
            // load some configuration options from registry:
            PersistentStorageData data = ObjectFactory.LoadConfiguration(CofigurationName);

            string[] forbiddenNames   = data.GetMultiString(Persistent_ForbiddenNames);
            string[] systemAssemblies = data.GetMultiString(Persistent_SystemAssemblies);

            if (forbiddenNames != null && forbiddenNames.Length > 0)
            {
                ForbiddenNames = forbiddenNames;
            }
            if (systemAssemblies != null && systemAssemblies.Length > 0)
            {
                SystemAssemblies = systemAssemblies;
            }
            else
            {
                SystemAssemblies = DefaultSystemAssemblies;
            }
            if (SystemAssemblies != null)
            {
                Array.Sort(SystemAssemblies);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Sets the configuration description for given action.
        /// </summary>
        public void UpdateConfiguration(Type actionType, PersistentStorageData config)
        {
            IPackageAction action = actions.Get(actionType);

            if (action != null)
            {
                action.Configuration = config;
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Writes the current state of the control to a persistent storage area.
        /// </summary>
        public void StoreState()
        {
            if (treeView.SelectedNode != null)
            {
                PersistentStorageData data = new PersistentStorageData(ToolName);

                data.Add(Settings_Path, treeView.SelectedNode.FullPath);
                data.Add(Settings_Favorites, ExportFavorites());

                PersistentStorageHelper.Save(data);
            }
        }
Ejemplo n.º 8
0
        protected override void ConfigurationPresent()
        {
            string[] assemblies;
            config = ObjectFactory.LoadConfiguration(ReferenceProjectAction.CofigurationName);

            // add assemblies to the screen:
            listReferences.Items.Clear();
            assemblies = config.GetMultiString(ReferenceProjectAction.Persistent_SystemAssemblies);
            if (assemblies != null)
            {
                Add(assemblies);
            }
        }
Ejemplo n.º 9
0
        public void SaveState()
        {
            string[] storedFilter = FilterMessages;

            if (storedFilter != null && storedFilter.Length > 0)
            {
                PersistentStorageData data = new PersistentStorageData(ToolName);

                data.Add("Filter", storedFilter);

                PersistentStorageHelper.Save(data);
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Performs initialization of this action and
        /// also registers all the UI elements required by the action, e.g.: menus / menu groups / toolbars.
        /// </summary>
        public void Initialize(IPackageEnvironment env, IMenuCreator mc)
        {
            MenuCommand menu = ObjectFactory.CreateCommand(GuidList.guidCmdSet, ID, Execute, BeforeQueryStatus);

            parent = env;

            // load configuration:
            config = ObjectFactory.LoadConfiguration(ConfigurationName);

            // -------------------------------------------------------
            mc.AddCommand(menu, "MultiRenameRefactor", "Multi Method &Rename...", 9004, "Global::Ctrl+R, L", null, false);
            mc.Customizator.AddRefactoring(menu, false, -1, null);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Store inside the persistent storage, when the last update took place.
        /// </summary>
        private void StoreCheckState()
        {
            if (lastUpdateCheck == DateTime.MinValue)
            {
                return;
            }

            PersistentStorageData data = new PersistentStorageData(PersistantStorageName);

            data.Add("LastUpdateDate", lastUpdateCheck.ToShortDateString());

            // store:
            PersistentStorageHelper.Save(data);
        }
Ejemplo n.º 12
0
 public static Task LogOutAsync()
 {
     EnsureInitialized();
     return(Task.Run(() =>
     {
         if (SessionKey == null)
         {
             return;
         }
         var resp = Rest.DoPost("Logout", new { SessionKey = SessionKey });
         StoredData = new PersistentStorageData();
         RaiseStorageChanged();
     }));
 }
Ejemplo n.º 13
0
        /// <summary>
        /// Restores the stored state of the editor.
        /// </summary>
        public void RestoreState()
        {
            PersistentStorageData data = PersistentStorageHelper.Load(ToolName);

            if (data != null && data.Count > 0)
            {
                NavigateTo(data.GetString(Settings_Path));
                ImportFavorites(data.GetMultiString(Settings_Favorites));
            }

            navigator.Clear();
            RefreshNavigationButtons();
            RefreshFavoritesMenu();
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Loads the persistent storage data for particular tool.
        /// </summary>
        public static PersistentStorageData Load(string toolName)
        {
            try
            {
                PersistentStorageData data = new PersistentStorageData(toolName);
                RegistryKey           key  = OpenKey(toolName, false);

                if (key == null)
                {
                    return(data);
                }

                string[] names = key.GetValueNames();
                foreach (string k in names)
                {
                    object d = key.GetValue(k);
                    switch (key.GetValueKind(k))
                    {
                    case RegistryValueKind.MultiString:
                        data.Add(k, (string[])d);
                        break;

                    case RegistryValueKind.ExpandString:
                    case RegistryValueKind.String:
                        data.Add(k, (string)d);
                        break;

                    case RegistryValueKind.Binary:
                        data.Add(k, (byte[])d);
                        break;

                    case RegistryValueKind.DWord:
                    case RegistryValueKind.QWord:
                        data.Add(k, Convert.ToUInt32(d));
                        break;
                    }
                }

                CloseKey(key);
                return(data);
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
                Trace.WriteLine(ex.StackTrace);
                return(null);
            }
        }
Ejemplo n.º 15
0
        protected override void ConfigurationUpdate(out PersistentStorageData actionConfig)
        {
            string[] assemblies = GetSerializedAssemblies();

            // set new set of system assemblies:
            if (assemblies != null)
            {
                config.Add(ReferenceProjectAction.Persistent_SystemAssemblies, assemblies);
            }
            else
            {
                config.Remove(ReferenceProjectAction.Persistent_SystemAssemblies);
            }

            actionConfig = config;
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Writes the particular data to the persistent storage area.
        /// </summary>
        public static bool Save(PersistentStorageData data)
        {
            try
            {
                RegistryKey key = OpenKey(data.Name, true);

                // store the data:
                if (key != null)
                {
                    // remove deleted keys:
                    foreach (string k in data.Removed)
                    {
                        key.DeleteValue(k, false);
                    }

                    // set values for the others:
                    foreach (string k in data.KeysStrings)
                    {
                        key.SetValue(k, data.GetString(k), RegistryValueKind.String);
                    }

                    foreach (string k in data.KeysMultiString)
                    {
                        key.SetValue(k, data.GetMultiString(k), RegistryValueKind.MultiString);
                    }

                    foreach (string k in data.KeysBytes)
                    {
                        key.SetValue(k, data.GetByte(k), RegistryValueKind.Binary);
                    }

                    foreach (string k in data.KeysUInts)
                    {
                        key.SetValue(k, data.GetUInt(k), RegistryValueKind.DWord);
                    }
                }

                CloseKey(key);
                return(true);
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
                Trace.WriteLine(ex.StackTrace);
                return(false);
            }
        }
Ejemplo n.º 17
0
        private void StoreConfig(MultiRenameForm dlg)
        {
            if (dlg != null)
            {
                if (config == null)
                {
                    config = ObjectFactory.LoadConfiguration(ConfigurationName);
                }

                StringHelper.CounterDetails counter = dlg.Counter;

                config.Add("Formula", dlg.Formula);
                config.Add("CounterStart", counter.Current);
                config.Add("CounterStep", counter.Step);
                config.Add("CounterDigits", (uint)counter.Digits);
                config.Add("FormatIndex", (uint)dlg.FormatIndex);
            }
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Performs the cleanup actions.
        /// </summary>
        public void Dispose()
        {
            // notify about the exit event:
            foreach (IPackageAction addIn in data)
            {
                PersistentStorageData config = addIn.Configuration;

                // write configuration if needed:
                if (config != null && config.IsDirty)
                {
                    PersistentStorageHelper.Save(config);
                }

                // and finally release resources:
                addIn.Destroy();
            }

            data.Clear();
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Initialize customizator and associate with given manager.
        /// </summary>
        public void Initialize(CustomAddInManager m)
        {
            IMenuCreator mc = m.MenuCreator;

            // read the global settings for an add-in:
            config = ObjectFactory.LoadConfiguration(null);

            // configure the management objects:
            manager       = m;
            tytanToolbar  = mc.AddToolbar(ToolbarName);
            tytanAuxTools = mc.AddPopup(tytanToolbar, AuxiliaryToolsName, null, false, -1);

            tytanRefactors = mc.AddPopup(tytanToolbar, RefactorMenu, null, true, -1);
            refactors      = new List <CommandBar>();
            if (tytanRefactors != null)
            {
                refactors.Add(tytanRefactors.CommandBar);
            }
            refactors.Add(mc.GetMainMenuCommandBar(RefactorMenu));
            refactors.Add(mc.GetCodeWindowCommandBar(RefactorMenu));
        }
Ejemplo n.º 20
0
        public void RestoreState()
        {
            PersistentStorageData data = PersistentStorageHelper.Load(ToolName);

            if (data != null && data.Count > 0)
            {
                string[] storedFilter = data.GetMultiString("Filter");
                if (storedFilter == null)
                {
                    string f = data.GetString("Filter");

                    if (f != null)
                    {
                        storedFilter = new string[] { f }
                    }
                    ;
                }

                FilterMessages = storedFilter;
            }
        }
Ejemplo n.º 21
0
 /// <summary>
 /// Writes the configuration items into persistent storage.
 /// To have a valid effect ActionType property must be overwritten and return
 /// correct type of an associated action.
 /// </summary>
 protected virtual void ConfigurationUpdate(out PersistentStorageData actionConfig)
 {
     actionConfig = null;
 }
Ejemplo n.º 22
0
 /// <summary>
 /// Sets the configuration object for given action.
 /// </summary>
 private static void UpdateActionConfig(IPackageConfigUpdater cu, Type actionType, PersistentStorageData config)
 {
     if (cu != null && config != null && actionType != null)
     {
         PersistentStorageHelper.Save(config);
         cu.UpdateConfiguration(actionType, config);
     }
 }