Beispiel #1
0
 protected void BindCommand(DteCommand dteCommand)
 {
     try{
         if (dteCommand != null)
         {
             Command.Bindings = !string.IsNullOrWhiteSpace(dteCommand.Shortcut) ? new object[] { dteCommand.Shortcut } : new object[0];
         }
     }
     catch (Exception e) {
         DTE2.LogError($"bindings:{dteCommand?.Shortcut+Environment.NewLine+e}");
         if (!_errorMessage)
         {
             _errorMessage = true;
             MessageBox.Show($@"Errors during {GetType().Name} binding, please check your %APPDATA%\Microsoft\VisualStudio\{DTE2.Version}\ActivityLog.xml");
         }
     }
 }
Beispiel #2
0
        static OptionClass()
        {
            try{
                var directory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\Xpand\VSIX\";
                Path = System.IO.Path.Combine(directory, "Xpand.VSIX.Options.xml");
                if (File.Exists(Path))
                {
                    Instance = GetOptionClass();
                }
                else
                {
                    if (!Directory.Exists(directory))
                    {
                        Directory.CreateDirectory(directory);
                    }
                    Instance = new OptionClass {
                        KillModelEditor = true,
                        SpecificVersion = true
                    };

                    Instance.ConnectionStrings.Add(new ConnectionString()
                    {
                        Name = "ConnectionString"
                    });
                    Instance.ConnectionStrings.Add(new ConnectionString()
                    {
                        Name = "WorldCreatorConnectionString"
                    });
                    Instance.ConnectionStrings.Add(new ConnectionString()
                    {
                        Name = "EasyTestConnectionString"
                    });
                    Instance.ConnectionStrings.Add(new ConnectionString()
                    {
                        Name = "NorthWind"
                    });
                    var registryKey = Registry.LocalMachine.OpenSubKey(@"Software\WOW6432node\DevExpress\Components\");
                    if (registryKey != null)
                    {
                        foreach (var keyName in registryKey.GetSubKeyNames())
                        {
                            directory = (string)registryKey.OpenSubKey(keyName)?.GetValue("RootDirectory");
                            Instance.ReferencedAssembliesFolders.Add(new ReferencedAssembliesFolder()
                            {
                                Folder = directory
                            });
                            var sourceCodeInfo = new SourceCodeInfo {
                                ProjectRegex = "DevExpress.*csproj", RootPath = directory
                            };
                            sourceCodeInfo.AddProjectPaths();
                            Instance.SourceCodeInfos.Add(sourceCodeInfo);
                        }
                    }
                    Instance.ReferencedAssembliesFolders.Add(new ReferencedAssembliesFolder()
                    {
                        Folder = ModuleManager.GetXpandDllPath()
                    });
                    Instance.Exceptions.Add(new ExceptionsBreak()
                    {
                        Break = false, Exception = typeof(FileNotFoundException).FullName
                    });
                    Instance.Exceptions.Add(new ExceptionsBreak()
                    {
                        Break = false, Exception = typeof(SqlException).FullName
                    });
                    Instance.DisableExceptions = false;
                    Instance.SourceCodeInfos.Add(new SourceCodeInfo {
                        ProjectRegex = "Xpand.*csproj", RootPath = ModuleManager.GetXpandDllPath() + @"\..\"
                    });
                }

                if (!Instance.DteCommandsBindings)
                {
                    Instance.DteCommandsBindings = true;
                    Instance.DteCommands.Add(new DteCommand()
                    {
                        Command = nameof(BuildSelectionCommand), Shortcut = "Global::Ctrl+Alt+Enter"
                    });
                    Instance.DteCommands.Add(new DteCommand()
                    {
                        Command = nameof(DuplicateLineCommand), Shortcut = "Text Editor::Ctrl+D"
                    });
                    Instance.DteCommands.Add(new DteCommand()
                    {
                        Command = nameof(DropDataBaseCommand), Shortcut = "Global::Ctrl+Shift+Alt+D"
                    });
                    Instance.DteCommands.Add(new DteCommand()
                    {
                        Command = $"Run{nameof(EasyTestCommand)}", Shortcut = "Text Editor::Alt+T"
                    });
                    Instance.DteCommands.Add(new DteCommand()
                    {
                        Command = $"Debug{nameof(EasyTestCommand)}", Shortcut = "Text Editor::Alt+D"
                    });
                    Instance.DteCommands.Add(new DteCommand()
                    {
                        Command = $"{nameof(FindInSolutionCommand)}", Shortcut = "Text Editor::Alt+Shift+L"
                    });
                    Instance.DteCommands.Add(new DteCommand()
                    {
                        Command = $"{nameof(KillIISExpressCommand)}", Shortcut = "Global::Ctrl+Alt+Shift+I"
                    });
                    Instance.DteCommands.Add(new DteCommand()
                    {
                        Command = $"{nameof(LoadProjectFromReferenceCommand)}", Shortcut = "Solution Explorer::Ctrl+Alt+Shift+L"
                    });
                    Instance.DteCommands.Add(new DteCommand()
                    {
                        Command = $"{nameof(NavigateNextSubwordCommand)}", Shortcut = "Text Editor::ALT+Right Arrow"
                    });
                    Instance.DteCommands.Add(new DteCommand()
                    {
                        Command = $"{nameof(NavigatePreviousSubwordCommand)}", Shortcut = "Text Editor::ALT+Left Arrow"
                    });
                    Instance.DteCommands.Add(new DteCommand()
                    {
                        Command = $"{nameof(ShowModelsWindowCommand)}", Shortcut = "Global::Ctrl+Alt+Shift+M"
                    });
                    Instance.DteCommands.Add(new DteCommand()
                    {
                        Command = $"{nameof(ShowOptionsCommand)}", Shortcut = "Global::Alt+Shift+0"
                    });
                }
            }
            catch (Exception e) {
                DTE.LogError(e.ToString());
                throw;
            }
        }