public ThemeOptionsControl(IThemeAwareDialog child)
        {
            InitializeComponent();

            Child = child;
            var control = child as Control;

            Debug.Assert(Child != null);
            Debug.Assert(control != null);

            tableContent.Controls.Add(control);
            tableContent.SetColumn(control, 0);
            tableContent.SetRow(control, 1);
            control.Dock = DockStyle.Fill;

            var provider = ServiceProvider.GlobalProvider;

            Service       = provider.GetService(typeof(SIndentGuide)) as IndentGuideService;
            Child.Service = (IIndentGuide)Service;

            TextManagerService = (IVsTextManager)provider.GetService(typeof(SVsTextManager));

            var componentModel = (IComponentModel)provider.GetService(typeof(SComponentModel));

            EditorAdapters = (IVsEditorAdaptersFactoryService)componentModel
                             .GetService <IVsEditorAdaptersFactoryService>();

            ActiveThemeChanged += ActiveTheme_Changed;
        }
        public ThemeOptionsControl(IThemeAwareDialog child)
        {
            InitializeComponent();

            Child = child;
            var control = child as Control;
            Debug.Assert(Child != null);
            Debug.Assert(control != null);

            tableContent.Controls.Add(control);
            tableContent.SetColumn(control, 0);
            tableContent.SetRow(control, 1);
            control.Dock = DockStyle.Fill;

            var provider = ServiceProvider.GlobalProvider;
            Service = provider.GetService(typeof(SIndentGuide)) as IndentGuideService;
            Child.Service = (IIndentGuide)Service;

            TextManagerService = (IVsTextManager)provider.GetService(typeof(SVsTextManager));

            var componentModel = (IComponentModel)provider.GetService(typeof(SComponentModel));
            EditorAdapters = (IVsEditorAdaptersFactoryService)componentModel
                .GetService<IVsEditorAdaptersFactoryService>();

            ActiveThemeChanged += ActiveTheme_Changed;
        }
Exemple #3
0
        protected override void Initialize()
        {
            base.Initialize();

            // Prepare event
            DTE dte = GetService(typeof(DTE)) as DTE;

            if (dte != null)
            {
                CommandVisible = false;
                WindowEvents   = dte.Events.WindowEvents;
                WindowEvents.WindowActivated += WindowEvents_WindowActivated;
                WindowEvents.WindowClosing   += WindowEvents_WindowClosing;
            }

            // Add our command handlers for menu (commands must exist in the .vsct file)
            if (GetService(typeof(IMenuCommandService)) is OleMenuCommandService mcs)
            {
                // Create the command for the tool window
                CommandID      viewIndentCommandID = new CommandID(guidIndentGuideCmdSet, cmdidViewIndentGuides);
                OleMenuCommand menuCmd             = new OleMenuCommand(ToggleVisibility, viewIndentCommandID);
                menuCmd.BeforeQueryStatus += BeforeQueryStatus;

                mcs.AddCommand(menuCmd);
            }

            Service = new IndentGuideService(this);
            (this as IServiceContainer).AddService(typeof(SIndentGuide), Service, true);
            Service.Upgrade();
            Service.Load();
        }
        protected override void Initialize()
        {
            base.Initialize();

            JoinableTaskFactory = ThreadHelper.JoinableTaskFactory;

            // Prepare event
            var dte = GetService(typeof(EnvDTE.DTE)) as EnvDTE.DTE;

            if (dte != null)
            {
                CommandVisible = false;
                WindowEvents   = dte.Events.WindowEvents;
                WindowEvents.WindowActivated += WindowEvents_WindowActivated;
                WindowEvents.WindowClosing   += WindowEvents_WindowClosing;
            }

            // Add our command handlers for menu (commands must exist in the .vsct file)
            var mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (mcs != null)
            {
                // Create the command for the tool window
                CommandID viewIndentCommandID = new CommandID(guidIndentGuideCmdSet, cmdidViewIndentGuides);
                var       menuCmd             = new OleMenuCommand(ToggleVisibility, viewIndentCommandID);
                menuCmd.BeforeQueryStatus += new EventHandler(BeforeQueryStatus);

                mcs.AddCommand(menuCmd);
            }

            Service = new IndentGuideService(this);
            ((IServiceContainer)this).AddService(typeof(SIndentGuide), Service, true);
            Service.Upgrade();
            Service.Load();
        }
        protected async override Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            await base.InitializeAsync(cancellationToken, progress);

            // Prepare event
            var dte = GetService(typeof(EnvDTE.DTE)) as EnvDTE.DTE;

            if (dte != null)
            {
                CommandVisible = false;
                WindowEvents   = dte.Events.WindowEvents;
                WindowEvents.WindowActivated += WindowEvents_WindowActivated;
                WindowEvents.WindowClosing   += WindowEvents_WindowClosing;
            }

            // Add our command handlers for menu (commands must exist in the .vsct file)
            var mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (mcs != null)
            {
                // Create the command for the tool window
                CommandID viewIndentCommandID = new CommandID(guidIndentGuideCmdSet, cmdidViewIndentGuides);
                var       menuCmd             = new OleMenuCommand(ToggleVisibility, viewIndentCommandID);
                menuCmd.BeforeQueryStatus += new EventHandler(BeforeQueryStatus);

                mcs.AddCommand(menuCmd);
            }

            Service = new IndentGuideService(this);
            AddService(typeof(SIndentGuide), async(container, ct, type) => Service, true);
            Service.Upgrade();
            Service.Load();
        }
Exemple #6
0
        protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            await base.InitializeAsync(cancellationToken, progress);

            JoinableTaskFactory = ThreadHelper.JoinableTaskFactory;

            // Switches to the UI thread in order to consume some services used in command initialization
            await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            // Prepare event
            var dte = await GetServiceAsync(typeof(EnvDTE.DTE)) as EnvDTE.DTE;

            if (dte != null)
            {
                CommandVisible = false;
                WindowEvents   = dte.Events.WindowEvents;
                WindowEvents.WindowActivated += WindowEvents_WindowActivated;
                WindowEvents.WindowClosing   += WindowEvents_WindowClosing;
            }

            // Add our command handlers for menu (commands must exist in the .vsct file)
            var mcs = await GetServiceAsync(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (mcs != null)
            {
                // Create the command for the tool window
                CommandID viewIndentCommandID = new CommandID(guidIndentGuideCmdSet, cmdidViewIndentGuides);
                var       menuCmd             = new OleMenuCommand(ToggleVisibility, viewIndentCommandID);
                menuCmd.BeforeQueryStatus += new EventHandler(BeforeQueryStatus);

                mcs.AddCommand(menuCmd);
            }

            Service = new IndentGuideService(this);
            // Adds a service on the background thread
            AddService(typeof(SIndentGuide), async(container, ct, type) => await System.Threading.Tasks.Task.FromResult(Service), true);

            Service.Upgrade();
            Service.Load();
        }
        protected override void Initialize()
        {
            base.Initialize();

            // Prepare event
            var dte = GetService(typeof(EnvDTE.DTE)) as EnvDTE.DTE;
            if (dte != null) {
                CommandVisible = false;
                WindowEvents = dte.Events.WindowEvents;
                WindowEvents.WindowActivated += WindowEvents_WindowActivated;
                WindowEvents.WindowClosing += WindowEvents_WindowClosing;
            }

            // Add our command handlers for menu (commands must exist in the .vsct file)
            var mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
            if (mcs != null) {
                // Create the command for the tool window
                CommandID viewIndentCommandID = new CommandID(guidIndentGuideCmdSet, cmdidViewIndentGuides);
                var menuCmd = new OleMenuCommand(ToggleVisibility, viewIndentCommandID);
                menuCmd.BeforeQueryStatus += new EventHandler(BeforeQueryStatus);

                mcs.AddCommand(menuCmd);
            }

            Service = new IndentGuideService(this);
            ((IServiceContainer)this).AddService(typeof(SIndentGuide), Service, true);
            Service.Upgrade();
            Service.Load();
        }