Beispiel #1
0
        protected override void Initialize()
        {
            base.Initialize();

            var mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (null != mcs)
            {
                var id = new CommandID(GuidList.GuidCmdSet, (int)PkgCmdIDList.FormatDocumentCommand);
                _formatDocMenuCommand = new OleMenuCommand(FormatDocumentCallback, id);
                mcs.AddCommand(_formatDocMenuCommand);
                _formatDocMenuCommand.BeforeQueryStatus += OnBeforeQueryStatus;

                id = new CommandID(GuidList.GuidCmdSet, (int)PkgCmdIDList.FormatSelectionCommand);
                _formatSelMenuCommand = new OleMenuCommand(FormatSelectionCallback, id);
                mcs.AddCommand(_formatSelMenuCommand);
                _formatSelMenuCommand.BeforeQueryStatus += OnBeforeQueryStatus;
            }

            _dte = (DTE)GetService(typeof(DTE));

            _documentEventListener             = new DocumentEventListener(this);
            _documentEventListener.BeforeSave += OnBeforeDocumentSave;

            if (_dte.RegistryRoot.Contains("VisualStudio"))
            {
                _isCSharpEnabled = true;
            }

            _dialog = (AStyleGeneralOptionsPage)GetDialogPage(typeof(AStyleGeneralOptionsPage));
            _dialog.IsCSarpEnabled = _isCSharpEnabled;
        }
        protected override void Initialize()
        {
            base.Initialize();

            var mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
            if (null != mcs) {
                var id = new CommandID(GuidList.GuidCmdSet, (int)PkgCmdIDList.FormatDocumentCommand);
                _formatDocMenuCommand = new OleMenuCommand(FormatDocumentCallback, id);
                mcs.AddCommand(_formatDocMenuCommand);
                _formatDocMenuCommand.BeforeQueryStatus += OnBeforeQueryStatus;

                id = new CommandID(GuidList.GuidCmdSet, (int)PkgCmdIDList.FormatSelectionCommand);
                _formatSelMenuCommand = new OleMenuCommand(FormatSelectionCallback, id);
                mcs.AddCommand(_formatSelMenuCommand);
                _formatSelMenuCommand.BeforeQueryStatus += OnBeforeQueryStatus;
            }

            _dte = (DTE)GetService(typeof(DTE));

            _documentEventListener = new DocumentEventListener(this);
            _documentEventListener.BeforeSave += OnBeforeDocumentSave;

            if (_dte.RegistryRoot.Contains("VisualStudio")) {
                _isCSharpEnabled = true;
            }

            _props = _dte.Properties["AStyle Formatter", "General"];
            _props.Item("IsCSarpEnabled").Value = _isCSharpEnabled;
        }