public RevisionDiff() { InitializeComponent(); Translate(); this.HotkeysEnabled = true; _fullPathResolver = new FullPathResolver(() => Module.WorkingDir); }
public RevisionFileTree() { InitializeComponent(); Translate(); _fullPathResolver = new FullPathResolver(() => Module.WorkingDir); _findFilePredicateProvider = new FindFilePredicateProvider(); }
internal FormFileHistory(GitUICommands commands) : base(commands) { InitializeComponent(); _asyncLoader = new AsyncLoader(); // set tab page images { var imageList = new ImageList(); tabControl1.ImageList = imageList; imageList.ColorDepth = ColorDepth.Depth8Bit; imageList.Images.Add(Properties.Resources.IconCommit); imageList.Images.Add(Properties.Resources.IconViewFile); imageList.Images.Add(Properties.Resources.IconDiff); imageList.Images.Add(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); }
public FormGitAttributes(GitUICommands aCommands) : base(aCommands) { InitializeComponent(); Translate(); _fullPathResolver = new FullPathResolver(() => Module.WorkingDir); }
public GitIgnoreModel(IGitModule module) { _module = module; Translator.Translate(this, AppSettings.CurrentTranslation); _fullPathResolver = new FullPathResolver(() => _module.WorkingDir); }
public FormMailMap(GitUICommands commands) : base(commands) { InitializeComponent(); Translate(); _fullPathResolver = new FullPathResolver(() => Module.WorkingDir); }
public FormResolveConflicts(GitUICommands commands, bool offerCommit = true) : base(commands) { InitializeComponent(); Translate(); _offerCommit = offerCommit; _fullPathResolver = new FullPathResolver(() => Module.WorkingDir); }
public RevisionDiff() { InitializeComponent(); Translate(); HotkeysEnabled = true; _fullPathResolver = new FullPathResolver(() => Module.WorkingDir); _findFilePredicateProvider = new FindFilePredicateProvider(); }
public void Setup() { _file = Substitute.For <FileBase>(); _fileSystem = Substitute.For <IFileSystem>(); _fileSystem.File.Returns(_file); _fullPathResolver = Substitute.For <IFullPathResolver>(); _tester = new GitRevisionTester(_fullPathResolver, _fileSystem); }
public RevisionFileTree() { InitializeComponent(); Translate(); _fullPathResolver = new FullPathResolver(() => Module.WorkingDir); _findFilePredicateProvider = new FindFilePredicateProvider(); _revisionFileTreeController = new RevisionFileTreeController(() => Module.WorkingDir, new GitRevisionInfoProvider(() => Module), new FileAssociatedIconProvider()); }
public FormDiff( GitUICommands commands, bool firstParentIsValid, ObjectId baseId, ObjectId headId, string baseCommitDisplayStr, string headCommitDisplayStr) : base(commands) { _baseCommitDisplayStr = baseCommitDisplayStr; _headCommitDisplayStr = headCommitDisplayStr; _firstParentIsValid = firstParentIsValid; InitializeComponent(); btnSwap.AdaptImageLightness(); InitializeComplete(); _toolTipControl.SetToolTip(btnAnotherBaseBranch, _anotherBranchTooltip.Text); _toolTipControl.SetToolTip(btnAnotherHeadBranch, _anotherBranchTooltip.Text); _toolTipControl.SetToolTip(btnAnotherBaseCommit, _anotherCommitTooltip.Text); _toolTipControl.SetToolTip(btnAnotherHeadCommit, _anotherCommitTooltip.Text); _toolTipControl.SetToolTip(btnSwap, _btnSwapTooltip.Text); _baseRevision = new GitRevision(baseId); _headRevision = new GitRevision(headId); ObjectId mergeBase; if (_baseRevision.ObjectId.IsArtificial || _headRevision.ObjectId.IsArtificial) { mergeBase = null; } else { mergeBase = Module.GetMergeBase(_baseRevision.ObjectId, _headRevision.ObjectId); } _mergeBase = mergeBase != null ? new GitRevision(mergeBase) : null; ckCompareToMergeBase.Text = $"{_ckCompareToMergeBase} ({_mergeBase?.ObjectId.ToShortString()})"; ckCompareToMergeBase.Enabled = _mergeBase != null; _fullPathResolver = new FullPathResolver(() => Module.WorkingDir); _findFilePredicateProvider = new FindFilePredicateProvider(); _revisionTester = new GitRevisionTester(_fullPathResolver); _revisionDiffContextMenuController = new FileStatusListContextMenuController(); lblBaseCommit.BackColor = AppColor.DiffRemoved.GetThemeColor(); lblHeadCommit.BackColor = AppColor.DiffAdded.GetThemeColor(); DiffFiles.ContextMenuStrip = DiffContextMenu; DiffFiles.SelectedIndexChanged += delegate { ShowSelectedFileDiff(); }; DiffText.ExtraDiffArgumentsChanged += delegate { ShowSelectedFileDiff(); }; DiffText.TopScrollReached += FileViewer_TopScrollReached; DiffText.BottomScrollReached += FileViewer_BottomScrollReached; Load += delegate { PopulateDiffFiles(); }; }
public RevisionDiff() { InitializeComponent(); DiffFiles.AlwaysRevisionGroups = true; Translate(); HotkeysEnabled = true; _fullPathResolver = new FullPathResolver(() => Module.WorkingDir); _findFilePredicateProvider = new FindFilePredicateProvider(); _gitRevisionTester = new GitRevisionTester(_fullPathResolver); _revisionDiffContextMenuController = new FileStatusListContextMenuController(); }
public FormResolveConflicts(GitUICommands commands, bool offerCommit = true) : base(commands) { InitializeComponent(); InitializeComplete(); _offerCommit = offerCommit; _fullPathResolver = new FullPathResolver(() => Module.WorkingDir); FileName.DataPropertyName = nameof(ConflictData.Filename); authorDataGridViewTextBoxColumn1.DataPropertyName = "Author"; // TODO this property does not exist on the target type }
public void Setup() { _module = Substitute.For <IGitModule>(); _fullPathResolver = Substitute.For <IFullPathResolver>(); _file = Substitute.For <FileBase>(); _fileSystem = Substitute.For <IFileSystem>(); _fileSystem.File.Returns(_file); _manager = new CommitTemplateManager(_module, _fullPathResolver, _fileSystem); }
public RevisionDiffControl() { InitializeComponent(); DiffFiles.GroupByRevision = true; InitializeComplete(); HotkeysEnabled = true; _fullPathResolver = new FullPathResolver(() => Module.WorkingDir); _findFilePredicateProvider = new FindFilePredicateProvider(); _gitRevisionTester = new GitRevisionTester(_fullPathResolver); _revisionDiffContextMenuController = new FileStatusListContextMenuController(); DiffText.TopScrollReached += FileViewer_TopScrollReached; DiffText.BottomScrollReached += FileViewer_BottomScrollReached; }
private FormFileHistory([NotNull] GitUICommands commands) : base(commands) { InitializeComponent(); ConfigureTabControl(); _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.NavigateMenuCommands); _formBrowseMenus.AddMenuCommandSet(MainMenuItem.ViewMenu, FileChanges.MenuCommands.ViewMenuCommands); _formBrowseMenus.InsertAdditionalMainMenuItems(toolStripSeparator4); _commitDataManager = new CommitDataManager(() => Module); _fullPathResolver = new FullPathResolver(() => Module.WorkingDir); CommitDiff.EscapePressed += Close; View.EscapePressed += Close; Diff.EscapePressed += Close; Blame.EscapePressed += Close; copyToClipboardToolStripMenuItem.SetRevisionFunc(() => FileChanges.GetSelectedRevisions()); InitializeComplete(); Blame.ConfigureRepositoryHostPlugin(PluginRegistry.TryGetGitHosterForModule(Module)); return; void ConfigureTabControl() { tabControl1.ImageList = new ImageList { ColorDepth = ColorDepth.Depth32Bit, ImageSize = DpiUtil.Scale(new Size(16, 16)), Images = { Images.CommitSummary, Images.Diff, Images.ViewFile, Images.Blame } }; tabControl1.TabPages[0].ImageIndex = 0; tabControl1.TabPages[1].ImageIndex = 1; tabControl1.TabPages[2].ImageIndex = 2; tabControl1.TabPages[3].ImageIndex = 3; } }
public FormPull(GitUICommands commands, string defaultRemoteBranch, string defaultRemote) : base(commands) { InitializeComponent(); InitializeComplete(); helpImageDisplayUserControl1.Visible = !AppSettings.DontShowHelpImages; helpImageDisplayUserControl1.IsOnHoverShowImage2NoticeText = _hoverShowImageLabelText.Text; _remoteManager = new GitRemoteManager(() => Module); _branch = Module.GetSelectedBranch(); BindRemotesDropDown(defaultRemote); if (AppSettings.DefaultPullAction == AppSettings.PullAction.Merge) { Merge.Checked = true; } else if (AppSettings.DefaultPullAction == AppSettings.PullAction.Rebase) { Rebase.Checked = true; } else { // Set to fetch for Fetch, FetchAll, FetchPruneAll and None Fetch.Checked = true; } localBranch.Enabled = Fetch.Checked; AutoStash.Checked = AppSettings.AutoStash; Prune.Enabled = AppSettings.DefaultPullAction == AppSettings.PullAction.Merge || AppSettings.DefaultPullAction == AppSettings.PullAction.Fetch; ErrorOccurred = false; if (!string.IsNullOrEmpty(defaultRemoteBranch)) { Branches.Text = defaultRemoteBranch; } // If this repo is shallow, show an option to Unshallow // Detect by presence of the shallow file, not 100% sure it's the best way, but it's created upon shallow cloning and removed upon unshallowing bool isRepoShallow = File.Exists(commands.Module.ResolveGitInternalPath("shallow")); if (isRepoShallow) { Unshallow.Visible = true; } _fullPathResolver = new FullPathResolver(() => Module.WorkingDir); }
public FileStatusList() { InitializeComponent(); CreateOpenSubmoduleMenuItem(); Translate(); FilterVisible = false; SelectFirstItemOnSetItems = true; FileStatusListView.MouseMove += FileStatusListView_MouseMove; FileStatusListView.MouseDown += FileStatusListView_MouseDown; if (_images == null) { _images = new ImageList { ImageSize = DpiUtil.Scale(new Size(16, 16)), // Scale ImageSize and images scale automatically Images = { Resources.Removed, // 0 Resources.Added, // 1 Resources.Modified, // 2 Resources.Renamed, // 3 Resources.Copied, // 4 Resources.IconSubmoduleDirty, // 5 Resources.IconSubmoduleRevisionUp, // 6 Resources.IconSubmoduleRevisionUpDirty, // 7 Resources.IconSubmoduleRevisionDown, // 8 Resources.IconSubmoduleRevisionDownDirty, // 9 Resources.IconSubmoduleRevisionSemiUp, // 10 Resources.IconSubmoduleRevisionSemiUpDirty, // 11 Resources.IconSubmoduleRevisionSemiDown, // 12 Resources.IconSubmoduleRevisionSemiDownDirty, // 13 Resources.IconFileStatusUnknown // 14 } }; } FileStatusListView.SmallImageList = _images; FileStatusListView.LargeImageList = _images; HandleVisibility_NoFilesLabel_FilterComboBox(filesPresent: true); Controls.SetChildIndex(NoFiles, 0); NoFiles.Font = new Font(SystemFonts.MessageBoxFont, FontStyle.Italic); _filter = new Regex(".*"); _fullPathResolver = new FullPathResolver(() => Module.WorkingDir); _revisionTester = new GitRevisionTester(_fullPathResolver); }
public void Setup() { _module = Substitute.For <IGitModule>(); _fullPathResolver = Substitute.For <IFullPathResolver>(); _file = Substitute.For <FileBase>(); _fileSystem = Substitute.For <IFileSystem>(); _fileSystem.File.Returns(_file); _manager = new CommitTemplateManager(_module, _fullPathResolver, _fileSystem); if (Type.GetType("Mono.Runtime") != null) { _workingDir = "/home/user/repo"; } }
public FormAddToGitIgnore(GitUICommands aCommands, bool localExclude, params string[] filePatterns) : base(aCommands) { InitializeComponent(); _localExclude = localExclude; _ignoredFilesLoader = new AsyncLoader(); Translate(); if (localExclude) { Text = _addToLocalExcludeTitle.Text; } if (filePatterns != null) { FilePattern.Text = string.Join(Environment.NewLine, filePatterns); } _fullPathResolver = new FullPathResolver(() => Module.WorkingDir); }
public FileStatusList() { InitializeComponent(); CreateOpenSubmoduleMenuItem(); Translate(); FilterVisible = false; SelectFirstItemOnSetItems = true; _noDiffFilesChangesDefaultText = NoFiles.Text; #if !__MonoCS__ // TODO Drag'n'Drop doesn't work on Mono/Linux FileStatusListView.MouseMove += FileStatusListView_MouseMove; FileStatusListView.MouseDown += FileStatusListView_MouseDown; #endif if (_images == null) { _images = new ImageList(); _images.Images.Add(Resources.Removed); // 0 _images.Images.Add(Resources.Added); // 1 _images.Images.Add(Resources.Modified); // 2 _images.Images.Add(Resources.Renamed); // 3 _images.Images.Add(Resources.Copied); // 4 _images.Images.Add(Resources.IconSubmoduleDirty); // 5 _images.Images.Add(Resources.IconSubmoduleRevisionUp); // 6 _images.Images.Add(Resources.IconSubmoduleRevisionUpDirty); // 7 _images.Images.Add(Resources.IconSubmoduleRevisionDown); // 8 _images.Images.Add(Resources.IconSubmoduleRevisionDownDirty); // 9 _images.Images.Add(Resources.IconSubmoduleRevisionSemiUp); // 10 _images.Images.Add(Resources.IconSubmoduleRevisionSemiUpDirty); // 11 _images.Images.Add(Resources.IconSubmoduleRevisionSemiDown); // 12 _images.Images.Add(Resources.IconSubmoduleRevisionSemiDownDirty); // 13 _images.Images.Add(Resources.IconFileStatusUnknown); // 14 } FileStatusListView.SmallImageList = _images; FileStatusListView.LargeImageList = _images; HandleVisibility_NoFilesLabel_FilterComboBox(filesPresent: true); this.Controls.SetChildIndex(NoFiles, 0); NoFiles.Font = new Font(SystemFonts.MessageBoxFont, FontStyle.Italic); _filter = new Regex(".*"); _fullPathResolver = new FullPathResolver(() => Module.WorkingDir); }
public FormDiff( GitUICommands commands, bool firstParentIsValid, ObjectId baseId, ObjectId headId, string baseCommitDisplayStr, string headCommitDisplayStr) : base(commands) { _baseCommitDisplayStr = baseCommitDisplayStr; _headCommitDisplayStr = headCommitDisplayStr; _firstParentIsValid = firstParentIsValid; InitializeComponent(); InitializeComplete(); _toolTipControl.SetToolTip(btnAnotherBaseBranch, _anotherBranchTooltip.Text); _toolTipControl.SetToolTip(btnAnotherHeadBranch, _anotherBranchTooltip.Text); _toolTipControl.SetToolTip(btnAnotherBaseCommit, _anotherCommitTooltip.Text); _toolTipControl.SetToolTip(btnAnotherHeadCommit, _anotherCommitTooltip.Text); _toolTipControl.SetToolTip(btnSwap, _btnSwapTooltip.Text); if (!IsUICommandsInitialized) { // UICommands is not initialized in translation unit test. return; } _baseRevision = new GitRevision(baseId); _headRevision = new GitRevision(headId); _mergeBase = new GitRevision(Module.GetMergeBase(_baseRevision.ObjectId, _headRevision.ObjectId)); ckCompareToMergeBase.Text += $" ({_mergeBase?.ObjectId.ToShortString()})"; _fullPathResolver = new FullPathResolver(() => Module.WorkingDir); _findFilePredicateProvider = new FindFilePredicateProvider(); _revisionTester = new GitRevisionTester(_fullPathResolver); _revisionDiffContextMenuController = new FileStatusListContextMenuController(); lblBaseCommit.BackColor = AppSettings.DiffRemovedColor; lblHeadCommit.BackColor = AppSettings.DiffAddedColor; DiffFiles.ContextMenuStrip = DiffContextMenu; DiffFiles.SelectedIndexChanged += delegate { ShowSelectedFileDiff(); }; DiffText.ExtraDiffArgumentsChanged += delegate { ShowSelectedFileDiff(); }; Load += delegate { PopulateDiffFiles(); }; }
public FormPull(GitUICommands aCommands, string defaultRemoteBranch, string defaultRemote) : base(aCommands) { InitializeComponent(); Translate(); if (aCommands == null) { return; } helpImageDisplayUserControl1.Visible = !AppSettings.DontShowHelpImages; helpImageDisplayUserControl1.IsOnHoverShowImage2NoticeText = _hoverShowImageLabelText.Text; _remoteManager = new GitRemoteManager(() => Module); Init(defaultRemote); Merge.Checked = AppSettings.FormPullAction == AppSettings.PullAction.Merge; Rebase.Checked = AppSettings.FormPullAction == AppSettings.PullAction.Rebase; Fetch.Checked = AppSettings.FormPullAction == AppSettings.PullAction.Fetch; localBranch.Enabled = Fetch.Checked; AutoStash.Checked = AppSettings.AutoStash; Prune.Enabled = AppSettings.FormPullAction == AppSettings.PullAction.Merge || AppSettings.FormPullAction == AppSettings.PullAction.Fetch; ErrorOccurred = false; if (!string.IsNullOrEmpty(defaultRemoteBranch)) { Branches.Text = defaultRemoteBranch; } // If this repo is shallow, show an option to Unshallow // Detect by presence of the shallow file, not 100% sure it's the best way, but it's created upon shallow cloning and removed upon unshallowing bool isRepoShallow = File.Exists(aCommands.Module.ResolveGitInternalPath("shallow")); if (isRepoShallow) { Unshallow.Visible = true; } _fullPathResolver = new FullPathResolver(() => Module.WorkingDir); }
public FormAddToGitIgnore(GitUICommands commands, bool localExclude, params string[] filePatterns) : base(commands) { _localExclude = localExclude; InitializeComponent(); InitializeComplete(); if (localExclude) { Text = _addToLocalExcludeTitle.Text; } if (filePatterns is not null) { FilePattern.Text = string.Join(Environment.NewLine, filePatterns); } _fullPathResolver = new FullPathResolver(() => Module.WorkingDir); }
public FileStatusList() { InitializeComponent(); CreateOpenSubmoduleMenuItem(); Translate(); FilterVisible = false; SelectFirstItemOnSetItems = true; FileStatusListView.SmallImageList = CreateImageList(); FileStatusListView.LargeImageList = CreateImageList(); HandleVisibility_NoFilesLabel_FilterComboBox(filesPresent: true); Controls.SetChildIndex(NoFiles, 0); NoFiles.Font = new Font(SystemFonts.MessageBoxFont, FontStyle.Italic); _filter = new Regex(".*"); _fullPathResolver = new FullPathResolver(() => Module.WorkingDir); _revisionTester = new GitRevisionTester(_fullPathResolver); }
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(); }
public FormDiff(GitUICommands commands, RevisionGrid revisionGrid, string baseCommitSha, string headCommitSha, string baseCommitDisplayStr, string headCommitDisplayStr) : base(commands) { _revisionGrid = revisionGrid; _baseCommitDisplayStr = baseCommitDisplayStr; _headCommitDisplayStr = headCommitDisplayStr; InitializeComponent(); Translate(); _toolTipControl.SetToolTip(btnAnotherBaseBranch, _anotherBranchTooltip.Text); _toolTipControl.SetToolTip(btnAnotherHeadBranch, _anotherBranchTooltip.Text); _toolTipControl.SetToolTip(btnAnotherBaseCommit, _anotherCommitTooltip.Text); _toolTipControl.SetToolTip(btnAnotherHeadCommit, _anotherCommitTooltip.Text); _toolTipControl.SetToolTip(btnSwap, _btnSwapTooltip.Text); if (!IsUICommandsInitialized) { // UICommands is not initialized in translation unit test. return; } _baseRevision = new GitRevision(baseCommitSha); _headRevision = new GitRevision(headCommitSha); _mergeBase = new GitRevision(Module.GetMergeBase(_baseRevision.Guid, _headRevision.Guid)); _fullPathResolver = new FullPathResolver(() => Module.WorkingDir); _findFilePredicateProvider = new FindFilePredicateProvider(); _revisionTester = new GitRevisionTester(_fullPathResolver); _revisionDiffContextMenuController = new FileStatusListContextMenuController(); lblBaseCommit.BackColor = AppSettings.DiffRemovedColor; lblHeadCommit.BackColor = AppSettings.DiffAddedColor; DiffFiles.SelectedIndexChanged += DiffFiles_SelectedIndexChanged; DiffFiles.ContextMenuStrip = DiffContextMenu; Load += (sender, args) => PopulateDiffFiles(); DiffText.ExtraDiffArgumentsChanged += DiffTextOnExtraDiffArgumentsChanged; }
public CommitTemplateManager(IGitModule module, IFullPathResolver fullPathResolver, IFileSystem fileSystem) { _module = module; _fullPathResolver = fullPathResolver; _fileSystem = fileSystem; }
public FileViewer() { TreatAllFilesAsText = false; ShowEntireFile = false; NumberOfContextLines = AppSettings.NumberOfContextLines; InitializeComponent(); InitializeComplete(); UICommandsSourceSet += OnUICommandsSourceSet; internalFileViewer.MouseEnter += (_, e) => OnMouseEnter(e); internalFileViewer.MouseLeave += (_, e) => OnMouseLeave(e); internalFileViewer.MouseMove += (_, e) => OnMouseMove(e); internalFileViewer.KeyUp += (_, e) => OnKeyUp(e); _async = new AsyncLoader(); _async.LoadingError += (_, e) => { if (!IsDisposed) { ResetForText(null); internalFileViewer.SetText("Unsupported file: \n\n" + e.Exception.ToString(), openWithDifftool: null /* not applicable */); TextLoaded?.Invoke(this, null); } }; IgnoreWhitespaceChanges = AppSettings.IgnoreWhitespaceChanges; ignoreWhiteSpaces.Checked = IgnoreWhitespaceChanges; ignoreWhiteSpaces.Image = Images.WhitespaceIgnore; ignoreWhitespaceChangesToolStripMenuItem.Checked = IgnoreWhitespaceChanges; ignoreWhitespaceChangesToolStripMenuItem.Image = ignoreWhiteSpaces.Image; ignoreAllWhitespaces.Checked = AppSettings.IgnoreAllWhitespaceChanges; ignoreAllWhitespaces.Image = Images.WhitespaceIgnoreAll; ignoreAllWhitespaceChangesToolStripMenuItem.Checked = ignoreAllWhitespaces.Checked; ignoreAllWhitespaceChangesToolStripMenuItem.Image = ignoreAllWhitespaces.Image; ShowEntireFile = AppSettings.ShowEntireFile; showEntireFileButton.Checked = ShowEntireFile; showEntireFileToolStripMenuItem.Checked = ShowEntireFile; SetStateOfContextLinesButtons(); showNonPrintChars.Checked = AppSettings.ShowNonPrintingChars; showNonprintableCharactersToolStripMenuItem.Checked = AppSettings.ShowNonPrintingChars; ToggleNonPrintingChars(AppSettings.ShowNonPrintingChars); IsReadOnly = true; internalFileViewer.MouseMove += (_, e) => { if (_currentViewIsPatch && !fileviewerToolbar.Visible) { fileviewerToolbar.Visible = true; fileviewerToolbar.Location = new Point(Width - fileviewerToolbar.Width - 40, 0); fileviewerToolbar.BringToFront(); } }; internalFileViewer.MouseLeave += (_, e) => { if (GetChildAtPoint(PointToClient(MousePosition)) != fileviewerToolbar && fileviewerToolbar != null) { fileviewerToolbar.Visible = false; } }; internalFileViewer.TextChanged += (sender, e) => { if (_patchHighlighting) { internalFileViewer.AddPatchHighlighting(); } TextChanged?.Invoke(sender, e); }; internalFileViewer.ScrollPosChanged += (sender, e) => ScrollPosChanged?.Invoke(sender, e); internalFileViewer.SelectedLineChanged += (sender, e) => SelectedLineChanged?.Invoke(sender, e); internalFileViewer.DoubleClick += (_, args) => RequestDiffView?.Invoke(this, EventArgs.Empty); HotkeysEnabled = true; if (!IsDesignModeActive && ContextMenuStrip == null) { ContextMenuStrip = contextMenu; } contextMenu.Opening += (sender, e) => { copyToolStripMenuItem.Enabled = internalFileViewer.GetSelectionLength() > 0; ContextMenuOpening?.Invoke(sender, e); }; _fullPathResolver = new FullPathResolver(() => Module.WorkingDir); }
static (bool allFilesExist, bool allFilesOrUntrackedDirectoriesExist) FileOrUntrackedDirExists(List <FileStatusItem> items, IFullPathResolver fullPathResolver) { bool allFilesExist = items.Any(); bool allFilesOrUntrackedDirectoriesExist = items.Any(); foreach (var item in items) { var path = fullPathResolver.Resolve(item.Item.Name); var fileExists = File.Exists(path); allFilesExist = allFilesExist && fileExists; var fileOrUntrackedDirectoryExists = fileExists || (!item.Item.IsTracked && Directory.Exists(path)); allFilesOrUntrackedDirectoriesExist = allFilesOrUntrackedDirectoriesExist && fileOrUntrackedDirectoryExists; if (allFilesExist == false && allFilesOrUntrackedDirectoriesExist == false) { break; } } return(allFilesExist, allFilesOrUntrackedDirectoriesExist); }