Ejemplo n.º 1
0
        private void OnStatusFilterChanged(object sender, EventArgs e)
        {
            var changedFilesPanel = (ChangedFilesPanel)sender;
            var index             = DiffViewer.Panels.IndexOf(changedFilesPanel) + 2;

            DiffViewer.BeginUpdate();
            if (index < DiffViewer.Panels.Count)
            {
                DiffViewer.Panels.RemoveRange(index, DiffViewer.Panels.Count - index);
            }
            FlowPanelSeparator separator = null;

            for (int i = 0; i < _allDiffPanels.Count; ++i)
            {
                if ((_allDiffPanels[i].DiffFile.Status & changedFilesPanel.StatusFilter) != FileStatus.Unknown)
                {
                    DiffViewer.Panels.Add(_allDiffPanels[i]);
                    DiffViewer.Panels.Add(separator = new FlowPanelSeparator()
                    {
                        SeparatorStyle = FlowPanelSeparatorStyle.Simple
                    });
                }
            }
            if (separator != null)
            {
                separator.Height = 6;
            }
            DiffViewer.EndUpdate();
        }
Ejemplo n.º 2
0
        public DiffBinding(IDiffSource diffSource, DiffViewer diffViewer, DiffOptions diffOptions)
        {
            Verify.Argument.IsNotNull(diffSource, "diffSource");
            Verify.Argument.IsNotNull(diffViewer, "diffViewer");
            Verify.Argument.IsNotNull(diffOptions, "diffOptions");

            _diffSource  = diffSource;
            _diffViewer  = diffViewer;
            _diffOptions = diffOptions;

            _allDiffPanels = new List <FileDiffPanel>();
            _progressPanel = new FlowProgressPanel();
            Progress       = _progressPanel.ProgressMonitor;
        }
Ejemplo n.º 3
0
        public SplitDiffBinding(IDiffSource diffSource, DiffViewer diffViewerHeaders, DiffViewer diffViewerFiles, DiffOptions diffOptions)
        {
            Verify.Argument.IsNotNull(diffSource, nameof(diffSource));
            Verify.Argument.IsNotNull(diffViewerHeaders, nameof(diffViewerHeaders));
            Verify.Argument.IsNotNull(diffViewerFiles, nameof(diffViewerFiles));
            Verify.Argument.IsNotNull(diffOptions, nameof(diffOptions));

            _diffSource        = diffSource;
            _diffViewerHeaders = diffViewerHeaders;
            _diffViewerFiles   = diffViewerFiles;
            _diffOptions       = diffOptions;

            _allDiffPanels = new List <FileDiffPanel>();
            _progressPanel = new FlowProgressPanel();
            Progress       = _progressPanel.ProgressMonitor;
        }
Ejemplo n.º 4
0
 protected override void OnFetchFailed(Exception exception)
 {
     if (DiffViewer.IsDisposed)
     {
         return;
     }
     DiffViewer.BeginUpdate();
     _progressPanel.Remove();
     if (exception != null && !string.IsNullOrWhiteSpace(exception.Message))
     {
         DiffViewer.Panels.Add(new FlowProgressPanel()
         {
             Message = exception.Message
         });
     }
     DiffViewer.EndUpdate();
 }
Ejemplo n.º 5
0
        protected override Task <Diff> FetchDataAsync(IProgress <OperationProgress> progress, CancellationToken cancellationToken)
        {
            Verify.State.IsFalse(IsDisposed, "DiffBinding is disposed.");

            if (!DiffViewer.Created)
            {
                DiffViewer.CreateControl();
            }
            _scrollPosAfterReload = DiffViewer.VScrollPos;
            DiffViewer.BeginUpdate();
            DiffViewer.Panels.Clear();
            DiffViewer.ScrollToTopLeft();
            AddSourceSpecificPanels();
            DiffViewer.Panels.Add(_progressPanel);
            DiffViewer.EndUpdate();
            _allDiffPanels.Clear();
            return(DiffSource.GetDiffAsync(DiffOptions, progress, cancellationToken));
        }
Ejemplo n.º 6
0
        protected override void OnFetchCompleted(Diff diff)
        {
            if (DiffViewer.IsDisposed)
            {
                return;
            }

            DiffViewer.BeginUpdate();
            _allDiffPanels.Clear();
            _progressPanel.Remove();
            if (diff != null)
            {
                FlowPanelSeparator separator = null;
                var changedFilesPanel        = new ChangedFilesPanel()
                {
                    Diff = diff
                };
                changedFilesPanel.StatusFilterChanged += OnStatusFilterChanged;
                DiffViewer.Panels.Add(changedFilesPanel);
                DiffViewer.Panels.Add(new FlowPanelSeparator()
                {
                    SeparatorStyle = FlowPanelSeparatorStyle.Line
                });
                foreach (var file in diff)
                {
                    var fileDiffPanel = new FileDiffPanel(DiffSource.Repository, file, diff.Type);
                    _allDiffPanels.Add(fileDiffPanel);
                    DiffViewer.Panels.Add(fileDiffPanel);
                    DiffViewer.Panels.Add(separator = new FlowPanelSeparator()
                    {
                        SeparatorStyle = FlowPanelSeparatorStyle.Simple
                    });
                }
                if (separator != null)
                {
                    separator.Height = 6;
                }
            }
            DiffViewer.EndUpdate();
            if (_scrollPosAfterReload != 0)
            {
                DiffViewer.BeginInvoke(new Action <int>(SetScrollPos), _scrollPosAfterReload);
            }
        }