public StyleCustomizationDialog(Package packageArg, StyleDatabase styleDatabaseArg, CustomStyleInfo initialStyle) { InitializeComponent(); pasteCommand.InputGestures.Add(new KeyGesture(Key.V, ModifierKeys.Control)); CommandBindings.Add(new CommandBinding(pasteCommand, doPaste)); curStyle = new ClangFormatStyle(); styleDatabase = styleDatabaseArg; CustomStyleListCombobox.SelectionChanged += CustomStyleListCombobox_SelectionChanged; CustomStyleListCombobox.ItemsSource = styleDatabase.viewOnlyCustom (); cw = new CodeWindow(packageArg); CodeWindowContainer.Content = cw; if (initialStyle != null) CustomStyleListCombobox.SelectedItem = initialStyle; else CustomStyleListCombobox.SelectedIndex = 0; clangStylePropertyGrid.SelectedObject = curStyle; clangStylePropertyGrid.PropertyValueChanged += clangStylePropertyGrid_PropertyValueChanged; StyleNameTextbox.DataContext = this; updatePreview(); }
/// <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() { base.Initialize(); dte = Package.GetGlobalService(typeof(DTE)) as EnvDTE80.DTE2; var shellSettingsManager = new ShellSettingsManager(this); var writableSettingsStore = shellSettingsManager.GetWritableSettingsStore(SettingsScope.UserSettings); var settings = new SettingsHelper (CollectionPath, writableSettingsStore); clangStyle = new ClangFormatStyle(); styleDb = new StyleDatabase(settings); dte.Events.SolutionEvents.Opened += onSolutionOpened; dte.Events.SolutionEvents.AfterClosing += onSolutionClosed; dte.Events.SolutionEvents.Renamed += onSolutionRenamed; appEvents = dte.Events; solutionEvents = appEvents.SolutionEvents; rdt = new RunningDocumentTable (this); rdt.Advise(new RunningDocTableEvents(this)); // Add our command handlers for menu (commands must exist in the .vsct // file) OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (null != mcs) { // Create the command for the menu item. CommandID menuCommandID = new CommandID( GuidList.GuidCmdSet, (int)PkgCmdIDList.cmdIdOptions); OleMenuCommand menuItem = new OleMenuCommand(optionsDialogCallback, menuCommandID); mcs.AddCommand(menuItem); menuCommandID = new CommandID( GuidList.GuidCmdSet, (int)PkgCmdIDList.cmdIdFormatDocument); menuItem = new OleMenuCommand(formatDocumentCallback, menuCommandID); menuItem.BeforeQueryStatus += onBeforeQueryStatus; mcs.AddCommand(menuItem); menuCommandID = new CommandID( GuidList.GuidCmdSet, (int)PkgCmdIDList.cmdIdFormatFunction); menuItem = new OleMenuCommand(formatFunctionCallback, menuCommandID); menuItem.BeforeQueryStatus += onBeforeQueryStatus; mcs.AddCommand(menuItem); menuCommandID = new CommandID( GuidList.GuidCmdSet, (int)PkgCmdIDList.cmdIdFormatSelection); menuItem = new OleMenuCommand(formatSelectionCallback, menuCommandID); menuItem.BeforeQueryStatus += onBeforeQueryStatus; mcs.AddCommand(menuItem); } }