public OptionsDialog(StyleDatabase dbArg, Package packageArg) { InitializeComponent(); Global.CallNew(out enumToItem); Global.CallNew(out itemToEnum); db = dbArg; StyleCombo.ItemsSource = db.viewAll (); StyleCombo.SelectedIndex = 0; cw = new CodeWindow(packageArg); package = packageArg; CodeWindowContainer.Content = cw; foreach (var val in Enum.GetValues(typeof(FormatterSettingsScope)).Cast<FormatterSettingsScope>()) { var item = new ComboBoxItem(); enumToItem[val] = item; itemToEnum[item] = val; } regenerateStyleCombo(); foreach (var val in Enum.GetValues(typeof(FormatterSettingsScope)).Cast<FormatterSettingsScope>()) settingsScopeCombo.Items.Add(enumToItem[val]); settingsScopeCombo.SelectedItem = 0; updatePreview(); onActiveSolutionChanged(); db.activeSolutionChanged += onActiveSolutionChanged; }
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(); }
public void load(SettingsHelper helper, StyleDatabase db) { var styleName = helper.GetString(SettingsActiveStyle); style = db.styles.FirstOrDefault(s => s.ToString() == styleName); applyOnSave = helper.GetBoolean(SettingsFormatOnSave); }
// Set at least to some possible default values internal void resolve(StyleDatabase db) { if (style == null) style = db.styles[0]; if (applyOnSave == null) applyOnSave = false; }
/// <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); } }