Ejemplo n.º 1
0
        private void OverviewValueChanged(object p)
        {
            lock (_lockObject)
            {
                if ((p is double) == false)
                {
                    return;
                }

                double param = (double)p;

                if (_IgnoreNextSliderValueChange == true)
                {
                    if (_LastLineToSync == (int)param)
                    {
                        return;
                    }

                    _IgnoreNextSliderValueChange = false;
                    return;
                }

                _LastLineToSync = (int)param;

                IDiffSideViewModel nonActView;
                IDiffSideViewModel activeView = DiffCtrl.GetActiveView(out nonActView);
                var gotoPos = new DiffViewPosition((int)param, 0);
                DiffCtrl.ScrollToLine(gotoPos, nonActView, activeView, false);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Invoke this method to apply a change of theme to the content of the document
 /// (eg: Adjust the highlighting colors when changing from "Dark" to "Light"
 ///      WITH current text document loaded.)
 /// </summary>
 public void OnAppThemeChanged(IThemedHighlightingManager hlManager)
 {
     if (DiffCtrl != null)
     {
         DiffCtrl.OnAppThemeChanged(hlManager);
     }
 }
Ejemplo n.º 3
0
        private bool OverviewValueChangedCanExecute()
        {
            IDiffSideViewModel nonActView;
            IDiffSideViewModel activeView = DiffCtrl.GetActiveView(out nonActView);

            if (activeView == null)
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 4
0
        /// <summary>Changes the view mode for <paramref name="lastView"/> and initializes a new comparison if
        /// modes of <paramref name="lastView"/> and <paramref name="lastViewOther"/> reach the
        /// corresponding <see cref="DisplayMode.Comparing"/> state.</summary>
        /// <param name="viewToSwitch">True: Comparing/editing mode for view A is switched,
        /// False: Comparing/editing mode for view B is switched.</param>
        /// <param name="newMode"></param>
        /// <param name="lastView"></param>
        /// <param name="lastViewOther"></param>
        /// <param name="fileA"></param>
        /// <param name="fileB"></param>
        /// <param name="copyEditor2Comparing">Copy current editor content into comparing viewer
        /// if we switch from editing to comparing while the other side is still editing</param>
        /// <returns></returns>
        private DisplayMode ViewModeChangeCommand_Executed(bool viewToSwitch, DisplayMode newMode
                                                           , IDiffSideTextViewModel lastView, IDiffSideTextViewModel lastViewOther
                                                           , FileContentInfo fileA, FileContentInfo fileB
                                                           , bool copyEditor2Comparing)
        {
            var retMode = DiffCtrl.SwitchViewMode(viewToSwitch, newMode, copyEditor2Comparing);

            // Do a recompare based on in-memory stored/edited texts
            string filePathA, filePathB;

            object[] comParams = new object[] { this.FilePathA, this.FilePathB };

            if (retMode == DisplayMode.Comparing && retMode == lastViewOther.ViewMode && retMode != lastView.ViewMode &&
                lastView.ViewMode == DisplayMode.Editing && lastViewOther.ViewMode == DisplayMode.Comparing)
            {
                if (CompareTextFilesCommand_CanExecute(comParams, out filePathA, out filePathB) == true)
                {
                    CompareTextFilesCommand_Executed(filePathA, filePathB, false, fileA, fileB);
                }
            }

            return(retMode);
        }
Ejemplo n.º 5
0
        private void CompareTextFilesCommand_Executed(string filePathA, string filePathB
                                                      , bool reloadFromFile
                                                      , FileContentInfo fileA, FileContentInfo fileB)
        {
            try
            {
                DiffCtrl.SetDiffViewOptions(_OptionsController.DiffDisplayOptions);
                var args = _OptionsController.GetTextBinaryDiffSetup(filePathA, filePathB, reloadFromFile);

                // Overwrite this on a document specific base (this may indicate Auto or specifc Binary, Xml, Text etc...)
                args.CompareType = DiffCtrl.ShouldBeComparedAs;

                var processDiff = new ProcessTextDiff(args);

                if (args.ReloadFromFile == false)
                {
                    processDiff.SetupForTextComparison(fileA, fileB);
                }

                _DiffProgress.ResetProgressValues(_cancelTokenSource.Token);
                DiffProgress.ShowIndeterminatedProgress();
                Task.Factory.StartNew <IDiffProgress>(
                    (pr) =>
                {
                    return(processDiff.ProcessDiff(_DiffProgress, _DataSource));
                },
                    TaskCreationOptions.LongRunning,
                    _cancelTokenSource.Token)
                .ContinueWith((r) =>
                {
                    try
                    {
                        bool onError       = false;
                        bool taskCancelled = false;

                        if (_cancelTokenSource != null)
                        {
                            // Re-create cancellation token if this task was cancelled
                            // to support cancelable tasks in the future
                            if (_cancelTokenSource.IsCancellationRequested)
                            {
                                taskCancelled = true;
                                _cancelTokenSource.Dispose();
                                _cancelTokenSource = new CancellationTokenSource();
                            }
                        }

                        if (taskCancelled == false)
                        {
                            if (r.Result == null)
                            {
                                onError = true;
                            }
                            else
                            {
                                if (r.Result.ResultData == null)
                                {
                                    onError = true;
                                }
                            }
                        }

                        if (onError == false && taskCancelled == false)
                        {
                            var diffResults = r.Result.ResultData as ProcessTextDiff;

                            _DiffCtrl.ShowDifferences(args, diffResults);

                            ////FocusControl = Focus.None;
                            ////FocusControl = Focus.LeftView;
                            _GotoLineController.MaxLineValue = _DiffCtrl.NumberOfLines;

                            // Position view on first difference if thats available
                            if (_DiffCtrl.GoToFirstDifferenceCommand.CanExecute(null))
                            {
                                _DiffCtrl.GoToFirstDifferenceCommand.Execute(null);
                            }

                            NotifyPropertyChanged(() => DiffCtrl);
                        }
                        else
                        {
                            // Display Error
                        }
                    }
                    finally
                    {
                        DiffProgress.ProgressDisplayOff();
                    }
                }, TaskScheduler.FromCurrentSynchronizationContext());
            }
            catch
            {
                // Extend me with erro displays
            }
        }
Ejemplo n.º 6
0
        private void CompareTextFilesCommand_Executed(string filePathA, string filePathB)
        {
            try
            {
                DiffCtrl.SetDiffViewOptions(_OptionsController.DiffDisplayOptions);
                var args        = _OptionsController.GetTextBinaryDiffSetup(filePathA, filePathB);
                var processDiff = new ProcessTextDiff(args);

                _DiffProgress.ResetProgressValues(_cancelTokenSource.Token);
                Task.Factory.StartNew <IDiffProgress>(
                    (pr) => processDiff.ProcessDiff(_DiffProgress),
                    TaskCreationOptions.LongRunning,
                    _cancelTokenSource.Token)
                .ContinueWith((r) =>
                {
                    bool onError       = false;
                    bool taskCancelled = false;

                    if (_cancelTokenSource != null)
                    {
                        // Re-create cancellation token if this task was cancelled
                        // to support cancelable tasks in the future
                        if (_cancelTokenSource.IsCancellationRequested)
                        {
                            taskCancelled = true;
                            _cancelTokenSource.Dispose();
                            _cancelTokenSource = new CancellationTokenSource();
                        }
                    }

                    if (taskCancelled == false)
                    {
                        if (r.Result == null)
                        {
                            onError = true;
                        }
                        else
                        {
                            if (r.Result.ResultData == null)
                            {
                                onError = true;
                            }
                        }
                    }

                    if (onError == false && taskCancelled == false)
                    {
                        var diffResults = r.Result.ResultData as ProcessTextDiff;

                        _DiffCtrl.ShowDifferences(args, diffResults);

                        ////FocusControl = Focus.None;
                        ////FocusControl = Focus.LeftView;
                        _GotoLineController.MaxLineValue = _DiffCtrl.NumberOfLines;

                        // Position view on first difference if thats available
                        if (_DiffCtrl.GoToFirstDifferenceCommand.CanExecute(null))
                        {
                            _DiffCtrl.GoToFirstDifferenceCommand.Execute(null);
                        }

                        NotifyPropertyChanged(() => DiffCtrl);
                    }
                    else
                    {
                        // Display Error
                    }
                }, TaskScheduler.FromCurrentSynchronizationContext());
            }
            catch
            {
                // Extend me with erro displays
            }
        }