public GitDiffViewModel(IDbObjectText DbObjectText, IIDEProvider IDE, IGitAPI Git, IWarnings Warnings, ISettings Settings) { _DbObjectText = DbObjectText; IDiffText DiffText = Git.GitDiff(DbObjectText); FillDocument(DiffText); CurrentBranch = Git.GetCurrentBranch(); CurrentDataBase = IDE.GetDatabaseConnection(); ObjectDescrName = DbObjectText.DescriptionName; ObjectFullPath = DbObjectText.GetRawFilePath(); if (Settings.UnexpectedBranch) { UnexpectedBranch = Warnings.IsBranchUnexsepted(CurrentBranch, true); } if (Settings.UnexpectedServer) { UnexpectedServer = Warnings.IsServerUnexsepted(CurrentDataBase, true); } SaveTextCommand = NinjectCore.Get <CommandSaveTextToRepository>(); LoadTextCommand = NinjectCore.Get <CommandLoadTextFromRepository>(); ButtonsClassicStyle = Settings.ClassicButtonsPosition; }
private void FillDocument(IDiffText DiffText) { var CurrentType = eDiffLineType.None; var sb = new StringBuilder(); ListRuns = new List <Run>(); while (DiffText.MoveNext()) { if (DiffText.CurrentDiffLine.Type != CurrentType) { if (CurrentType != eDiffLineType.None) { ListRuns.Add(new Run(sb.ToString()) { Background = Helper.LineBackColor[CurrentType], Foreground = Helper.LineTextColor[CurrentType] }); } CurrentType = DiffText.CurrentDiffLine.Type; sb = new StringBuilder(); } sb.Append(DiffText.CurrentLine); } if (!ListRuns.Any()) { ListRuns.Add(new Run("<Изменения отсутствуют>") { FontSize = 16 }); } OnPropertyChanged("ListRuns"); }