/// <summary>
        /// Save a source or target file of the diff view.
        /// </summary>
        /// <param name="paths">file path</param>
        public void SaveFile(string filePath, ProcessDestination fDestin)
        {
            Action <CancellationTokenSource> processingRequest;

            switch (fDestin)
            {
            case ProcessDestination.Source:
                processingRequest = cts =>
                {
                    if (mProcessItems.SetIsProcessingSolution(true, mSaveFileProcessID) == false)
                    {
                        throw new Exception(string.Format(Local.Strings.STR_BLOCKED_SOLUTION_TASK, mProcessItems.CurrentProcessId));
                    }

                    try
                    {
                        DiffSource.SaveSource(filePath);
                    }
                    finally
                    {
                        if (mProcessItems.SetIsProcessingSolution(false, mSaveFileProcessID) == false)
                        {
                            throw new Exception(string.Format(Local.Strings.STR_FAILED_RESET_OF_SOLUTION_TASK, mProcessItems.CurrentProcessId));
                        }
                    }
                };
                break;

            case ProcessDestination.Target:
                processingRequest = cts =>
                {
                    if (mProcessItems.SetIsProcessingSolution(true, mSaveFileProcessID) == false)
                    {
                        throw new Exception(string.Format(Local.Strings.STR_BLOCKED_SOLUTION_TASK, mProcessItems.CurrentProcessId));
                    }

                    try
                    {
                        DiffSource.SaveTarget(filePath);
                    }
                    finally
                    {
                        if (mProcessItems.SetIsProcessingSolution(false, mSaveFileProcessID) == false)
                        {
                            throw new Exception(string.Format(Local.Strings.STR_FAILED_RESET_OF_SOLUTION_TASK, mProcessItems.CurrentProcessId));
                        }
                    }
                };
                break;

            default:
                throw new NotImplementedException(fDestin.ToString());
            }

            mProcessAction.StartCancelableProcess(processingRequest,
                                                  SaveFinishedEvent,
                                                  Local.Strings.STR_CANCEL_SAVE_MESSAGE);
        }
Beispiel #2
0
        public override int GetHashCode()
        {
            var hashCode = 0;

            if (DiffSource != null)
            {
                hashCode = DiffSource.GetHashCode();
            }
            if (DiffOptions != null)
            {
                hashCode ^= DiffOptions.GetHashCode();
            }
            return(hashCode);
        }
Beispiel #3
0
 private void UpdateText()
 {
     if (Guid != Guids.ContextualDiffViewGuid)
     {
         if (DiffSource != null)
         {
             Text = DiffSource.ToString();
         }
         else
         {
             Text = Resources.StrDiff;
         }
     }
     else
     {
         Text = Resources.StrContextualDiff;
     }
 }
Beispiel #4
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));
        }