private void PromptToUpgrade()
        {
            string key = "WebEssentials.WebExtensionPackPromptShown";

            try
            {
                var userHasBeenPrompted = bool.Parse(UserRegistryRoot.GetValue(key, false).ToString());

                if (!userHasBeenPrompted)
                {
                    var hwnd   = new IntPtr(_dte.MainWindow.HWnd);
                    var window = (System.Windows.Window)HwndSource.FromHwnd(hwnd).RootVisual;

                    string msg    = "Web Essentials recommends you to install the Web Extension Pack extension if you haven't already. It contains all the features that used to be part of Web Essentials that was extracted into individual extensions.\r\rDo you wish to go to the download page?";
                    var    answer = MessageBox.Show(window, msg, Vsix.Name, MessageBoxButton.YesNo, MessageBoxImage.Information);

                    if (answer == MessageBoxResult.Yes)
                    {
                        System.Diagnostics.Process.Start("https://visualstudiogallery.msdn.microsoft.com/f3b504c6-0095-42f1-a989-51d5fc2a8459");
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
            }
            finally
            {
                UserRegistryRoot.SetValue(key, true);
            }
        }
Ejemplo n.º 2
0
 public bool GetReplInfo(int id, out string evaluator, out string evalType, out string contentType, out string title, out Guid languageServiceGuid, out Guid guid)
 {
     using (var repl = UserRegistryRoot.OpenSubKey(ActiveReplsKey)) {
         if (repl != null)
         {
             using (var curRepl = repl.OpenSubKey(id.ToString())) {
                 if (curRepl != null)
                 {
                     evaluator           = (string)curRepl.GetValue("EvaluatorAssembly");
                     evalType            = (string)curRepl.GetValue("EvaluatorType");
                     contentType         = (string)curRepl.GetValue("ContentType");
                     title               = (string)curRepl.GetValue("Title");
                     guid                = Guid.Parse((string)curRepl.GetValue("Guid"));
                     languageServiceGuid = Guid.Parse((string)curRepl.GetValue("LanguageServiceGuid"));
                     return(true);
                 }
             }
         }
     }
     evaluator           = null;
     contentType         = null;
     title               = null;
     evalType            = null;
     guid                = Guid.Empty;
     languageServiceGuid = Guid.Empty;
     return(false);
 }
Ejemplo n.º 3
0
        /// <summary>Applies a given <see cref="Theme" />.</summary>
        /// <param name="theme">The theme to apply.</param>
        /// <exception cref="ArgumentNullException">Occurs if <paramref name="theme" /> is null.</exception>
        public void ApplyTheme(string themeID)
        {
            if (themeID == null)
            {
                throw new ArgumentNullException(nameof(themeID));
            }

            var key = UserRegistryRoot.OpenSubKey(@"ApplicationPrivateSettings\Microsoft\VisualStudio", true);

            if (key != null)
            {
                object oldColorTheme    = key.GetValue("ColorTheme");
                object oldColorThemeNew = key.GetValue("ColorThemeNew");
                object newColorTheme    = "0*System.String*" + themeID.Trim('{', '}');
                object newColorThemeNew = "0*System.String*" + themeID;
                if (oldColorTheme != newColorTheme || oldColorThemeNew != newColorThemeNew)
                {
                    key.SetValue("ColorTheme", newColorTheme);
                    key.SetValue("ColorThemeNew", newColorThemeNew);

                    NativeMethods.SendNotifyMessage(new IntPtr(NativeMethods.HWND_BROADCAST), NativeMethods.WM_SYSCOLORCHANGE, IntPtr.Zero, IntPtr.Zero);

                    RestoreColorThemeAsync(key, oldColorTheme, oldColorThemeNew).FireAndForget();
                }
            }
        }
        protected override int QueryClose(out bool canClose)
        {
            OutputMessage("::QueryClose");

            using (var registryKey = UserRegistryRoot.CreateSubKey(@"Packages\{" + AsqaPackageGuidString + "}"))
                registryKey.SetValue("SkipLoading", 1);

            return(base.QueryClose(out canClose));
        }
Ejemplo n.º 5
0
        private void AddSkipLoadingReg()
        {
            var myPackage = UserRegistryRoot.CreateSubKey($@"Packages\{{{PackageGuids.HuntingDogPackageIDString}}}");

            if (myPackage != null)
            {
                myPackage.SetValue("SkipLoading", 1);
            }
        }
        /////////////////////////////////////////////////////////////////////////////
        // Overridden Package Implementation
        #region Package Members

        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
            base.Initialize();

#if DEBUG
            System.Windows.Forms.MessageBox.Show("UserRegistryRoot=" + UserRegistryRoot);
#endif

// ReSharper disable once ConvertIfStatementToConditionalTernaryExpression
            if (UserRegistryRoot.ToString().Contains(@"\11"))
            {
                m_vsVersion = VisualStudioVersion.VS2012;
            }
            else
            if (UserRegistryRoot.ToString().Contains(@"\12"))
            {
                m_vsVersion = VisualStudioVersion.VS2013;
            }
            else
            if (UserRegistryRoot.ToString().Contains(@"\14"))
            {
                m_vsVersion = VisualStudioVersion.VS2015;
            }
            else
            if (UserRegistryRoot.ToString().Contains(@"\15"))
            {
                m_vsVersion = VisualStudioVersion.VS2017;
            }
            else
            {
                throw new ApplicationException($"Unknown version of VisualStudioVersion: {UserRegistryRoot}");
            }

            // Add our command handlers for menu (commands must exist in the .vsct file)
            var mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
            if (null != mcs)
            {
                // Create the command for the menu item.
                var menuCommandID = new CommandID(GuidList.GuidTfsVisualHistoryVSExtensionCmdSet, (int)PkgCmdIDList.CmdidSitronicsMotionTooling);
                var menuItem      = new MenuCommand(MenuItemCallback, menuCommandID);

/*
 *              menuItem.BeforeQueryStatus += (sender, evt) =>
 *              {
 *                  // I don't need this next line since this is a lambda.
 *                  // But I just wanted to show that sender is the OleMenuCommand.
 *                  var item = (OleMenuCommand)sender;
 *
 *                  // var service = (EnvDTE.DTE)this.GetService(typeof(EnvDTE.DTE));
 *                  item.Enabled = false;//TeamExplorerIntegrator.IsSingleSelected;
 *              };
 */
                mcs.AddCommand(menuItem);
            }
        }
        /// <summary>
        /// For SSMS 2015 and earlier, this will set a registry key to disable the extension. Strangely, extension loading only works for disabled extensions...
        /// </summary>
        private void SetPackageLoadingDisableKeyIfRequired()
        {
            DTE2   dte          = (DTE2)GetService(typeof(DTE));
            string fullName     = dte.FullName.ToUpperInvariant();
            int    majorVersion = int.Parse(dte.Version.Split('.')[0]);

            if ((fullName.Contains("SSMS") || fullName.Contains("MANAGEMENT STUDIO")) && majorVersion <= 2017)
            {
                UserRegistryRoot.CreateSubKey(@"Packages\{" + guidPoorMansTSqlFormatterSSMSPackagePkgString + "}").SetValue("SkipLoading", 1);
            }
        }
Ejemplo n.º 8
0
 public void SaveReplInfo(int id, IReplEvaluator evaluator, IContentType contentType, string title, Guid languageServiceGuid, Guid replId) {
     using (var repl = UserRegistryRoot.CreateSubKey(ActiveReplsKey)) {
         using (var curRepl = repl.CreateSubKey(id.ToString())) {
             curRepl.SetValue("EvaluatorType", evaluator.GetType().FullName);
             curRepl.SetValue("EvaluatorAssembly", evaluator.GetType().Assembly.FullName);
             curRepl.SetValue("ContentType", contentType.TypeName);
             curRepl.SetValue("Title", title);
             curRepl.SetValue("Guid", replId.ToString());
             curRepl.SetValue("LanguageServiceGuid", languageServiceGuid.ToString());
         }
     }
 }
Ejemplo n.º 9
0
        private void AddSkipLoading()
        {
            var timer = new System.Timers.Timer(2000);

            timer.Elapsed += (sender, args) =>
            {
                timer.Stop();
                var myPackage = UserRegistryRoot.CreateSubKey(@"Packages\{" + PackageGuidString + "}");
                myPackage?.SetValue("SkipLoading", 1);
            };
            timer.Start();
        }
Ejemplo n.º 10
0
        void SetSkipLoading()
        {
            try
            {
                var registryKey = UserRegistryRoot.CreateSubKey(
                    string.Format("Packages\\{{{0}}}", PackageGuidString));

                registryKey.SetValue("SkipLoading", 1, RegistryValueKind.DWord);
                registryKey.Close();
            }
            catch
            { }
        }
Ejemplo n.º 11
0
        // Call this method from the Initialize method
        // to add the SkipLoading value back to the registry
        // 2 seconds after it’s removed by SSMS
        private void AddSkipLoading()
        {
            var timer = new Timer(2000);

            timer.Elapsed += (sender, args) =>
            {
                timer.Stop();

                var myPackage = UserRegistryRoot.CreateSubKey($@"Packages\{{{GuidList.GuidWakaTimePkgString}}}");
                myPackage?.SetValue("SkipLoading", 1);
            };
            timer.Start();
        }
Ejemplo n.º 12
0
        private void SaveSettings()
        {
            var key = UserRegistryRoot.OpenSubKey(RegistryRoot, true);

            if (key == null)
            {
                UserRegistryRoot.CreateSubKey(RegistryRoot);
                key = UserRegistryRoot.OpenSubKey(RegistryRoot, true);
            }
            Debug.Assert(key != null);
            key.SetValue(RegistryProgram, _program);
            key.SetValue(RegistryArguments, _arguments);
        }
Ejemplo n.º 13
0
        private void AddSkipLoading()
        {
            var timer = new Timer();

            timer.Interval = 2000;
            timer.Tick    += (sender, args) =>
            {
                timer.Stop();

                var myPackage = UserRegistryRoot.CreateSubKey(@"Packages\{" + PackageGuidString + "}");
                myPackage?.SetValue("SkipLoading", 1);
            };
            timer.Start();
        }
        protected async override void Initialize()
        {
            try
            {
                // TODO: Remove for RTM
                using (var key = UserRegistryRoot.CreateSubKey("HTML Editor"))
                {
                    key.SetValue("KnockoutSupportEnabled", "1");
                }
            }
            catch {
            }

            JavaScriptIntellisense.Register(UserRegistryRoot);
            await CompatibilityChecker.StartCheckingCompatibility();
        }
Ejemplo n.º 15
0
        void SetSkipLoading()
        {
            try
            {
                var registryKey = UserRegistryRoot.CreateSubKey(
                    string.Format("Packages\\{{{0}}}", PackageGuidString));

                registryKey.SetValue("SkipLoading", 1, RegistryValueKind.DWord);
                registryKey.Close();
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex.Message);
                if (ex.InnerException != null)
                {
                    Trace.TraceError(ex.InnerException.Message);
                }
            }
        }
Ejemplo n.º 16
0
        private void LoadSettings()
        {
            var subKey = UserRegistryRoot.OpenSubKey(RegistryRoot);

            if (subKey != null)
            {
                _program   = (string)subKey.GetValue(RegistryProgram);
                _arguments = (string)subKey.GetValue(RegistryArguments);
            }

            //Didn't exist, try default paths
            if (string.IsNullOrEmpty(_program))
            {
                foreach (var diffTool in DiffTools.GetCandidates())
                {
                    if (File.Exists(diffTool.Path))
                    {
                        _program   = diffTool.Path;
                        _arguments = diffTool.Arguments;
                        return;
                    }
                }
            }
        }
Ejemplo n.º 17
0
        private void AddSkipLoadingRegistryKey()
        {
            var key = UserRegistryRoot.CreateSubKey(@"Packages\{" + PackageGuidString + "}");

            key.SetValue("SkipLoading", 1);
        }