public void Dispose_is_idempotent()
        {
            var sequence = new CancellationTokenSequence();

            sequence.Next();

            sequence.Dispose();
            sequence.Dispose();
            sequence.Dispose();
            sequence.Dispose();
        }
예제 #2
0
        public void Dispose()
        {
            CancelBuildStatusFetchOperation();

            _buildServerAdapter?.Dispose();
            _launchCancellation.Dispose();
        }
        public void Next_throws_if_disposed()
        {
            var sequence = new CancellationTokenSequence();

            sequence.Dispose();

            Assert.Throws <OperationCanceledException>(() => sequence.Next());
        }
예제 #4
0
 private void Dispose(bool disposing)
 {
     if (disposing)
     {
         Stop();
         _cancellationTokenSequence.Dispose();
     }
 }
        private void Dispose(bool disposing)
        {
            if (disposing)
            {
                CancelBuildStatusFetchOperation();

                DisposeBuildServerAdapter();

                _launchCancellation.Dispose();
            }
        }
        public void Dispose_cancels_previous_token()
        {
            var sequence = new CancellationTokenSequence();

            var token = sequence.Next();

            Assert.False(token.IsCancellationRequested);

            sequence.Dispose();

            Assert.True(token.IsCancellationRequested);
        }
 public void Dispose()
 {
     _submodulesStatusSequence.Dispose();
 }
예제 #8
0
 protected override void OnFormClosed(FormClosedEventArgs e)
 {
     _cancellationTokenSequence.Dispose();
     base.OnFormClosed(e);
 }
        public void Dispose_does_not_throw_if_no_token_yet_issued()
        {
            var sequence = new CancellationTokenSequence();

            sequence.Dispose();
        }
예제 #10
0
 public void Dispose()
 {
     Stop();
     _cancellationTokenSequence.Dispose();
 }
 public void Dispose()
 {
     Detached();
     _reloadCancellationTokenSequence.Dispose();
 }
예제 #12
0
        public RepoObjectsTree()
        {
            Disposed += (s, e) => _selectionCancellationTokenSequence.Dispose();

            InitializeComponent();
            InitImageList();
            _txtBranchCriterion = CreateSearchBox();
            branchSearchPanel.Controls.Add(_txtBranchCriterion, 1, 0);

            treeMain.PreviewKeyDown  += OnPreviewKeyDown;
            btnSearch.PreviewKeyDown += OnPreviewKeyDown;
            PreviewKeyDown           += OnPreviewKeyDown;

            mnubtnCollapseAll.AdaptImageLightness();
            btnCollapseAll.AdaptImageLightness();
            btnSettings.AdaptImageLightness();
            mnubtnExpandAll.AdaptImageLightness();
            mnubtnFetchAllBranchesFromARemote.AdaptImageLightness();
            mnuBtnPruneAllBranchesFromARemote.AdaptImageLightness();
            mnuBtnFetchAllRemotes.AdaptImageLightness();
            mnuBtnPruneAllRemotes.AdaptImageLightness();
            mnubtnFetchCreateBranch.AdaptImageLightness();
            mnubtnPullFromRemoteBranch.AdaptImageLightness();
            InitializeComplete();

            RegisterContextActions();

            treeMain.ShowNodeToolTips = true;
            treeMain.HideSelection    = false;

            toolTip.SetToolTip(btnCollapseAll, mnubtnCollapseAll.ToolTipText);
            toolTip.SetToolTip(btnSearch, _searchTooltip.Text);
            toolTip.SetToolTip(btnSettings, _showHideRefsTooltip.Text);
            tsmiShowBranches.Checked   = AppSettings.RepoObjectsTreeShowBranches;
            tsmiShowRemotes.Checked    = AppSettings.RepoObjectsTreeShowRemotes;
            tsmiShowTags.Checked       = AppSettings.RepoObjectsTreeShowTags;
            tsmiShowSubmodules.Checked = AppSettings.RepoObjectsTreeShowSubmodules;

            _doubleClickDecorator = new NativeTreeViewDoubleClickDecorator(treeMain);
            _doubleClickDecorator.BeforeDoubleClickExpandCollapse += BeforeDoubleClickExpandCollapse;

            _explorerNavigationDecorator              = new NativeTreeViewExplorerNavigationDecorator(treeMain);
            _explorerNavigationDecorator.AfterSelect += OnNodeSelected;

            treeMain.NodeMouseClick       += OnNodeClick;
            treeMain.NodeMouseDoubleClick += OnNodeDoubleClick;

            mnubtnFilterRemoteBranchInRevisionGrid.ToolTipText = _showBranchOnly.Text;
            mnubtnFilterLocalBranchInRevisionGrid.ToolTipText  = _showBranchOnly.Text;

            return;

            void InitImageList()
            {
                const int rowPadding = 1; // added to top and bottom, so doubled -- this value is scaled *after*, so consider 96dpi here

                treeMain.ImageList = new ImageList
                {
                    ColorDepth = ColorDepth.Depth32Bit,
                    ImageSize  = DpiUtil.Scale(new Size(16, 16 + rowPadding + rowPadding)), // Scale ImageSize and images scale automatically
                    Images     =
                    {
                        { nameof(Images.ArrowUp),                        Pad(Images.ArrowUp)                        },
                        { nameof(Images.ArrowDown),                      Pad(Images.ArrowDown)                      },
                        { nameof(Images.FolderClosed),                   Pad(Images.FolderClosed)                   },
                        { nameof(Images.BranchLocal),                    Pad(Images.BranchLocal)                    },
                        { nameof(Images.BranchLocalMerged),              Pad(Images.BranchLocalMerged)              },
                        { nameof(Images.Branch),                         Pad(Images.Branch.AdaptLightness())        },
                        { nameof(Images.Remote),                         Pad(Images.Remote)                         },
                        { nameof(Images.BitBucket),                      Pad(Images.BitBucket)                      },
                        { nameof(Images.GitHub),                         Pad(Images.GitHub)                         },
                        { nameof(Images.VisualStudioTeamServices),       Pad(Images.VisualStudioTeamServices)       },
                        { nameof(Images.BranchLocalRoot),                Pad(Images.BranchLocalRoot)                },
                        { nameof(Images.BranchRemoteRoot),               Pad(Images.BranchRemoteRoot)               },
                        { nameof(Images.BranchRemote),                   Pad(Images.BranchRemote)                   },
                        { nameof(Images.BranchRemoteMerged),             Pad(Images.BranchRemoteMerged)             },
                        { nameof(Images.BranchFolder),                   Pad(Images.BranchFolder)                   },
                        { nameof(Images.TagHorizontal),                  Pad(Images.TagHorizontal)                  },
                        { nameof(Images.EyeOpened),                      Pad(Images.EyeOpened)                      },
                        { nameof(Images.EyeClosed),                      Pad(Images.EyeClosed)                      },
                        { nameof(Images.RemoteEnableAndFetch),           Pad(Images.RemoteEnableAndFetch)           },
                        { nameof(Images.FileStatusModified),             Pad(Images.FileStatusModified)             },
                        { nameof(Images.FolderSubmodule),                Pad(Images.FolderSubmodule)                },
                        { nameof(Images.SubmoduleDirty),                 Pad(Images.SubmoduleDirty)                 },
                        { nameof(Images.SubmoduleRevisionUp),            Pad(Images.SubmoduleRevisionUp)            },
                        { nameof(Images.SubmoduleRevisionDown),          Pad(Images.SubmoduleRevisionDown)          },
                        { nameof(Images.SubmoduleRevisionSemiUp),        Pad(Images.SubmoduleRevisionSemiUp)        },
                        { nameof(Images.SubmoduleRevisionSemiDown),      Pad(Images.SubmoduleRevisionSemiDown)      },
                        { nameof(Images.SubmoduleRevisionUpDirty),       Pad(Images.SubmoduleRevisionUpDirty)       },
                        { nameof(Images.SubmoduleRevisionDownDirty),     Pad(Images.SubmoduleRevisionDownDirty)     },
                        { nameof(Images.SubmoduleRevisionSemiUpDirty),   Pad(Images.SubmoduleRevisionSemiUpDirty)   },
                        { nameof(Images.SubmoduleRevisionSemiDownDirty), Pad(Images.SubmoduleRevisionSemiDownDirty) },
                    }
                };
                treeMain.SelectedImageKey = treeMain.ImageKey;

                Image Pad(Image image)
                {
                    var padded = new Bitmap(image.Width, image.Height + rowPadding + rowPadding, PixelFormat.Format32bppArgb);

                    using (var g = Graphics.FromImage(padded))
                    {
                        g.DrawImageUnscaled(image, 0, rowPadding);
                        return(padded);
                    }
                }
            }

            SearchControl <string> CreateSearchBox()
            {
                var search = new SearchControl <string>(SearchForBranch, i => { })
                {
                    Anchor   = AnchorStyles.Left | AnchorStyles.Right,
                    Name     = "txtBranchCritierion",
                    TabIndex = 1
                };

                search.OnTextEntered += () =>
                {
                    OnBranchCriterionChanged(null, null);
                    OnBtnSearchClicked(null, null);
                };
                search.TextChanged    += OnBranchCriterionChanged;
                search.KeyDown        += TxtBranchCriterion_KeyDown;
                search.PreviewKeyDown += OnPreviewKeyDown;
                return(search);

                IEnumerable <string> SearchForBranch(string arg)
                {
                    return(CollectFilterCandidates()
                           .Where(r => r.IndexOf(arg, StringComparison.OrdinalIgnoreCase) != -1));
                }

                IEnumerable <string> CollectFilterCandidates()
                {
                    var list = new List <string>();

                    foreach (TreeNode rootNode in treeMain.Nodes)
                    {
                        CollectFromNodes(rootNode.Nodes);
                    }

                    return(list);

                    void CollectFromNodes(TreeNodeCollection nodes)
                    {
                        foreach (TreeNode node in nodes)
                        {
                            if (node.Tag is BaseBranchNode branch)
                            {
                                if (branch.Nodes.Count == 0)
                                {
                                    list.Add(branch.FullPath);
                                }
                            }
                            else
                            {
                                list.Add(node.Text);
                            }

                            CollectFromNodes(node.Nodes);
                        }
                    }
                }
            }
        }