Ejemplo n.º 1
0
 private static string GetEffectivePreference(bool integrate, VisualStudioIntegrationViewModel model)
 {
     // if "Yes" was clicked, use the checkbox setting; else use the already-installed settgin
     if (integrate)
         return (model.IsChecked ? "+" : "-") + model.Version;
     else
         return (model.IntegrationStatus == VisualStudioIntegrationStatus.Installed ? "+" : "-") + model.Version;
 }
Ejemplo n.º 2
0
        private static ICollection<VisualStudioIntegrationViewModel> GetPossibleIntegrationStatus(string commandPath)
        {
            var possibleIntegrationStatus = new List<VisualStudioIntegrationViewModel>();
            try
            {
                using (var visualStudio = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\VisualStudio"))
                {
                    if (visualStudio != null)
                    {
                        foreach (string subKeyName in s_knownVisualStudioVersions)
                        {
                            using (var externalTools = visualStudio.OpenSubKey(subKeyName + @".0\External Tools"))
                            {
                                if (externalTools != null)
                                {
                                    VisualStudioIntegrationViewModel model = new VisualStudioIntegrationViewModel
                                    {
                                        Version = subKeyName,
                                        IntegrationStatus = VisualStudioIntegrationStatus.Available
                                    };
                                    for (int tool = 0; tool < (int) externalTools.GetValue("ToolNumKeys"); tool++)
                                    {
                                        if (commandPath.Equals(externalTools.GetValue("ToolCmd" + tool)))
                                        {
                                            model.IntegrationStatus = VisualStudioIntegrationStatus.Installed;
                                            model.ToolIndex = tool;
                                        }
                                    }

                                    possibleIntegrationStatus.Add(model);
                                }
                            }
                        }
                    }
                }
            }
            catch (SecurityException)
            {
            }
            catch (UnauthorizedAccessException)
            {
            }

            return possibleIntegrationStatus;
        }