internal FormFileHistory(GitUICommands commands) : base(commands) { InitializeComponent(); _asyncLoader = new AsyncLoader(); tabControl1.ImageList = new ImageList { ColorDepth = ColorDepth.Depth8Bit, ImageSize = DpiUtil.Scale(new Size(16, 16)), Images = { Properties.Resources.IconCommit, Properties.Resources.IconViewFile, Properties.Resources.IconDiff, Properties.Resources.IconBlame } }; tabControl1.TabPages[0].ImageIndex = 0; tabControl1.TabPages[1].ImageIndex = 1; tabControl1.TabPages[2].ImageIndex = 2; tabControl1.TabPages[3].ImageIndex = 3; _filterBranchHelper = new FilterBranchHelper(toolStripBranchFilterComboBox, toolStripBranchFilterDropDownButton, FileChanges); _filterRevisionsHelper = new FilterRevisionsHelper(toolStripRevisionFilterTextBox, toolStripRevisionFilterDropDownButton, FileChanges, toolStripRevisionFilterLabel, ShowFirstParent, form: this); _formBrowseMenus = new FormBrowseMenus(FileHistoryContextMenu); _formBrowseMenus.ResetMenuCommandSets(); _formBrowseMenus.AddMenuCommandSet(MainMenuItem.NavigateMenu, FileChanges.MenuCommands.GetNavigateMenuCommands()); _formBrowseMenus.AddMenuCommandSet(MainMenuItem.ViewMenu, FileChanges.MenuCommands.GetViewMenuCommands()); _formBrowseMenus.InsertAdditionalMainMenuItems(toolStripSeparator4); _commitDataManager = new CommitDataManager(() => Module); _fullPathResolver = new FullPathResolver(() => Module.WorkingDir); _longShaProvider = new LongShaProvider(() => Module); copyToClipboardToolStripMenuItem.GetViewModel = () => new CopyContextMenuViewModel(FileChanges.GetSelectedRevisions().FirstOrDefault()); this.AdjustForDpiScaling(); }
private void UpdateSelectedFileViewers() { var selectedRows = FileChanges.GetSelectedRevisions(); if (selectedRows.Count == 0) { return; } IGitItem revision = selectedRows[0]; var fileName = revision.Name; if (string.IsNullOrEmpty(fileName)) { fileName = FileName; } Text = string.Format("File History ({0})", fileName); if (tabControl1.SelectedTab == Blame) { blameControl1.LoadBlame(revision.Guid, fileName, FileChanges); } if (tabControl1.SelectedTab == ViewTab) { var scrollpos = View.ScrollPos; View.ViewGitItemRevision(fileName, revision.Guid); View.ScrollPos = scrollpos; } switch (selectedRows.Count) { case 1: { IGitItem revision1 = selectedRows[0]; if (tabControl1.SelectedTab == DiffTab) { Diff.ViewPatch( () => { Patch diff = Settings.Module.GetSingleDiff(revision1.Guid, revision1.Guid + "^", fileName, Diff.GetExtraDiffArguments(), Diff.Encoding); if (diff == null) { return(string.Empty); } return(diff.Text); } ); } } break; case 2: { IGitItem revision1 = selectedRows[0]; IGitItem revision2 = selectedRows[1]; if (tabControl1.SelectedTab == DiffTab) { Diff.ViewPatch( () => Settings.Module.GetSingleDiff(revision1.Guid, revision2.Guid, fileName, Diff.GetExtraDiffArguments(), Diff.Encoding).Text); } } break; default: Diff.ViewPatch("You need to select 2 files to view diff."); break; } }
private void diffToolremotelocalStripMenuItem_Click(object sender, EventArgs e) { UICommands.OpenWithDifftool(this, FileChanges.GetSelectedRevisions(), FileName, string.Empty, RevisionDiffKind.DiffBLocal, true); }
private void UpdateSelectedFileViewers(bool force = false) { var selectedRevisions = FileChanges.GetSelectedRevisions(); if (selectedRevisions.Count == 0) { return; } GitRevision revision = selectedRevisions[0]; var children = FileChanges.GetRevisionChildren(revision.ObjectId); var fileName = revision.Name; if (string.IsNullOrEmpty(fileName)) { fileName = FileName; } SetTitle(fileName); if (revision.IsArtificial) { tabControl1.SelectedTab = DiffTab; CommitInfoTabPage.Parent = null; BlameTab.Parent = null; ViewTab.Parent = null; } else { if (CommitInfoTabPage.Parent == null) { tabControl1.TabPages.Insert(0, CommitInfoTabPage); } if (ViewTab.Parent == null) { var index = tabControl1.TabPages.IndexOf(DiffTab); Debug.Assert(index != -1, "TabControl should contain diff tab page"); tabControl1.TabPages.Insert(index + 1, ViewTab); } if (BlameTab.Parent == null) { var index = tabControl1.TabPages.IndexOf(ViewTab); Debug.Assert(index != -1, "TabControl should contain view tab page"); tabControl1.TabPages.Insert(index + 1, BlameTab); } } if (tabControl1.SelectedTab == BlameTab) { Blame.LoadBlame(revision, children, fileName, FileChanges, BlameTab, Diff.Encoding, force: force); } else if (tabControl1.SelectedTab == ViewTab) { View.Encoding = Diff.Encoding; View.ViewGitItemRevisionAsync(fileName, revision.ObjectId); } else if (tabControl1.SelectedTab == DiffTab) { var file = new GitItemStatus { IsTracked = true, Name = fileName, IsSubmodule = GitModule.IsValidGitWorkingDir(_fullPathResolver.Resolve(fileName)) }; Diff.ViewChangesAsync(FileChanges.GetSelectedRevisions(), file, "You need to select at least one revision to view diff."); } else if (tabControl1.SelectedTab == CommitInfoTabPage) { CommitDiff.SetRevision(revision.ObjectId, fileName); } if (_buildReportTabPageExtension == null) { _buildReportTabPageExtension = new BuildReportTabPageExtension(() => Module, tabControl1, _buildReportTabCaption.Text); } _buildReportTabPageExtension.FillBuildReport(selectedRevisions.Count == 1 ? revision : null); }