Exemplo n.º 1
0
        public RemoteMenu(Remote remote)
        {
            Verify.Argument.IsValidGitObject(remote, "remote");

            _remote = remote;

            Items.Add(GuiItemFactory.GetShowRemoteItem <ToolStripMenuItem>(remote));
            Items.Add(GuiItemFactory.GetEditRemotePropertiesItem <ToolStripMenuItem>(remote));

            Items.Add(new ToolStripSeparator());

            Items.Add(GuiItemFactory.GetFetchFromItem <ToolStripMenuItem>(remote, "{0}"));
            Items.Add(GuiItemFactory.GetPullFromItem <ToolStripMenuItem>(remote, "{0}"));
            Items.Add(GuiItemFactory.GetPruneRemoteItem <ToolStripMenuItem>(remote, "{0}"));

            Items.Add(new ToolStripSeparator());

            Items.Add(GuiItemFactory.GetRemoveRemoteItem <ToolStripMenuItem>(remote, "{0}"));
            Items.Add(GuiItemFactory.GetRenameRemoteItem <ToolStripMenuItem>(remote, "{0}"));

            Items.Add(new ToolStripSeparator());

            var item = new ToolStripMenuItem(Resources.StrCopyToClipboard);

            item.DropDownItems.Add(GuiItemFactory.GetCopyToClipboardItem <ToolStripMenuItem>(Resources.StrName, remote.Name));
            item.DropDownItems.Add(GuiItemFactory.GetCopyToClipboardItem <ToolStripMenuItem>(Resources.StrFetchUrl, remote.FetchUrl));
            item.DropDownItems.Add(GuiItemFactory.GetCopyToClipboardItem <ToolStripMenuItem>(Resources.StrPushUrl, remote.PushUrl));

            Items.Add(item);
        }
Exemplo n.º 2
0
 private void OnRemoteAdded(object sender, RemoteEventArgs e)
 {
     _fetchButton.DropDown.Items.Add(GuiItemFactory.GetFetchFromItem <ToolStripMenuItem>(e.Object, "{1}"));
     _pullButton.DropDown.Items.Add(GuiItemFactory.GetPullFromItem <ToolStripMenuItem>(e.Object, "{1}"));
     if (_repository.Remotes.Count == 1)
     {
         _fetchButton.Enabled = true;
         _pullButton.Enabled  = true;
         _pushButton.Enabled  = true;
     }
 }
Exemplo n.º 3
0
        private void AttachToRepository(Repository repository)
        {
            _repository          = repository;
            _mergeButton.Enabled = !repository.Head.IsDetached;
            if (repository.Remotes.Count != 0)
            {
                foreach (var remote in repository.Remotes)
                {
                    _fetchButton.DropDown.Items.Add(GuiItemFactory.GetFetchFromItem <ToolStripMenuItem>(remote, "{1}"));
                    _pullButton.DropDown.Items.Add(GuiItemFactory.GetPullFromItem <ToolStripMenuItem>(remote, "{1}"));
                }
                _fetchButton.Enabled = true;
                _pullButton.Enabled  = true;
                _pushButton.Enabled  = true;
            }
            else
            {
                _fetchButton.Enabled = false;
                _pullButton.Enabled  = false;
                _pushButton.Enabled  = false;
            }

            if (repository.Stash.Count != 0)
            {
                _stashPopItem.Enabled   = true;
                _stashApplyItem.Enabled = true;
            }
            else
            {
                _stashPopItem.Enabled   = false;
                _stashApplyItem.Enabled = false;
            }

            _stashButton.Enabled = !repository.IsEmpty;

            repository.Head.PointerChanged   += OnHeadChanged;
            repository.Remotes.ObjectAdded   += OnRemoteAdded;
            repository.Remotes.ObjectRemoved += OnRemoteRemoved;
            repository.Remotes.Renamed       += OnRemoteRenamed;

            repository.Stash.StashedStateCreated += OnStashCreated;
            repository.Stash.StashedStateDeleted += OnStashDeleted;

            Enabled = true;
        }