Esempio n. 1
0
        public bool Check()
        {
            if (!Directory.Exists(RepoDir))
            {
                Console.WriteLine("输入的文件夹不存在");
                return(false);
            }

            if (!Commits.Any())
            {
                Console.WriteLine("未指定任何提交标识");
                return(false);
            }

            if (string.IsNullOrEmpty(OutputDir))
            {
                OutputDir = Path.Combine(Environment.CurrentDirectory, DateTime.Now.ToString("yyyy-MM-dd HH fff"));
            }
            if (Directory.Exists(OutputDir))
            {
                Console.WriteLine($"指定的输出目录已存在,可能导致文件覆盖 {OutputDir}");
            }
            else
            {
                Directory.CreateDirectory(OutputDir);
            }

            return(true);
        }
Esempio n. 2
0
        private void LoadViewModel()
        {
            Timing t = new Timing();

            viewModelService.UpdateViewModel(this);

            UpdateViewModelImpl();

            if (Commits.Any())
            {
                SelectedIndex = 0;
                SelectedItem  = Commits.First();
            }

            t.Log("Updated repository view model");
        }
Esempio n. 3
0
        void ComputeCanvasBoundaries()
        {
            if (!Commits.Any())
            {
                CanvasBoundaries = new Tuple <double, double, double, double>(0, 0, 0, 0);
                return;
            }
            double i1, i2, i3, i4;

            i1 = i3 = Commits.First().Location.X;
            i2 = i4 = Commits.First().Location.Y;
            foreach (GraphItemModel m in Commits.Cast <GraphItemModel>().Union(Branches))
            {
                i1 = Math.Min(i1, m.Location.X);
                i2 = Math.Min(i2, m.Location.Y);
                i3 = Math.Max(i3, m.Location.X);
                i4 = Math.Max(i4, m.Location.Y);
            }
            CanvasBoundaries = new Tuple <double, double, double, double>(i1, i2, i3, i4);
        }
Esempio n. 4
0
        private void TrySetSelectedCommitPosition(
            CommitPosition commitPosition, bool ignoreTopIndex = false)
        {
            if (commitPosition != null)
            {
                if (!ignoreTopIndex && commitPosition.Index == 0)
                {
                    // The index was 0 (top) lest ensure the index remains 0 again
                    Log.Debug("Scroll to 0 since first position was 0");
                    ScrollTo(0);
                    if (Commits.Any())
                    {
                        SelectedIndex = 0;
                        SelectedItem  = Commits.First();
                    }

                    return;
                }

                Commit selected = commitPosition.Commit;

                int indexAfter = Commits.FindIndex(c => c.Commit.Id == selected.Id);

                if (selected != null && indexAfter != -1)
                {
                    int indexBefore = commitPosition.Index;
                    ScrollRows(indexBefore - indexAfter);
                    SelectedIndex = indexAfter;
                    SelectedItem  = Commits[indexAfter];
                    return;
                }
            }

            ScrollTo(0);
            if (Commits.Any())
            {
                SelectedIndex = 0;
                SelectedItem  = Commits.First();
            }
        }