예제 #1
0
 public FolderWorker(SettingsHelper parentArg, string name)
 {
     parent = parentArg; parent.startFolder(name);
 }
예제 #2
0
 public void save(SettingsHelper helper)
 {
     helper.SetString(SettingsActiveStyle, style.ToString());
     helper.SetBoolean(SettingsFormatOnSave, applyOnSave ?? false);
 }
예제 #3
0
 public StyleDatabase(SettingsHelper helperArg)
 {
     Global.CallNew(out settings);
     foreach (var e in Enum.GetValues(typeof(FormatterSettingsScope)).Cast<FormatterSettingsScope> ())
         settings.Add(e, new FormatSettings());
     settingsHelper = helperArg;
     styles = new TrulyObservableCollection<StyleInfo>();
     foreach (ClangFormat.StyleId id in Enum.GetValues(typeof(ClangFormat.StyleId)))
         styles.Add(new PredefinedStyleInfo(id));
     styles.Add(new FileStyleInfo());
     customViewSource = new CollectionViewSource { Source = styles };
     customViewSource.View.Filter = p => p is CustomStyleInfo;
     allViewSource = new CollectionViewSource { Source = styles };
     loadSettings();
 }
예제 #4
0
 public void load(SettingsHelper helper, StyleDatabase db)
 {
     var styleName = helper.GetString(SettingsActiveStyle);
     style = db.styles.FirstOrDefault(s => s.ToString() == styleName);
     applyOnSave = helper.GetBoolean(SettingsFormatOnSave);
 }
예제 #5
0
        /// <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);
                }
        }