示例#1
0
        private void CreateProvider_Click(object sender, RoutedEventArgs e)
        {
            _service = this.GetService();
            if (_service != null)
            {
                _provider = new MyTaskProvider();
                _provider.AddItems(new MyTaskItem(_provider, document: @"d:\test\a.txt", text: "test 1 2 3", category: VSTASKCATEGORY.CAT_BUILDCOMPILE),
                                   new MyTaskItem(_provider, document: @"d:\test\b.txt", text: "test 4 5 6", subcategoryIndex: 1));

                int hr = _service.RegisterTaskProvider(_provider, out _providerCookie);

                if (ErrorHandler.Succeeded(hr))
                {
                    this.CreateProvider.Foreground = Brushes.Green;
                    this.RemoveProvider.IsEnabled  = true;
                    this.Refresh.IsEnabled         = true;
                    this.Add1000.IsEnabled         = true;
                    this.RemoveHalf.IsEnabled      = true;
                    this.CreateProvider.IsEnabled  = false;

                    return;
                }
            }

            this.CreateProvider.Foreground = Brushes.Red;
        }
示例#2
0
        private void RemoveProvider_Click(object sender, RoutedEventArgs e)
        {
            if ((_service != null) && (_providerCookie != VSConstants.VSCOOKIE_NIL))
            {
                _provider.ClearItems();
                _service.RefreshTasks(_providerCookie);
                int hr = _service.UnregisterTaskProvider(_providerCookie);

                if (ErrorHandler.Succeeded(hr))
                {
                    _providerCookie = VSConstants.VSCOOKIE_NIL;
                    _provider       = null;
                    _service        = null;

                    this.RemoveProvider.Foreground = Brushes.Green;
                    this.CreateProvider.IsEnabled  = true;
                    this.Refresh.IsEnabled         = false;
                    this.Add1000.IsEnabled         = false;
                    this.RemoveHalf.IsEnabled      = false;
                    this.RemoveProvider.IsEnabled  = false;
                    this.RemoveProvider.IsEnabled  = false;

                    return;
                }
            }

            this.RemoveProvider.Foreground = Brushes.Red;
        }