コード例 #1
0
        /// <summary>
        /// Class constructor
        /// </summary>
        public DirDiffDocViewViewModel(EventHandler <OpenFileDiffEventArgs> openFileContentDiffRequestHandler
                                       , DirDiffArgs args)
            : this()
        {
            DirDiffDoc = AehnlichDirViewModelLib.ViewModels.Factory.ConstructAppViewModel(args);

            //DirDiffDoc.DirDiffDoc.CompareFilesRequest += openFileContentDiffRequestHandler;
            WeakEventManager <IDirDiffDocViewModel, OpenFileDiffEventArgs> .AddHandler(
                DirDiffDoc.DirDiffDoc, "CompareFilesRequest", openFileContentDiffRequestHandler);
        }
コード例 #2
0
ファイル: AppViewModel.cs プロジェクト: softworkz/Aehnlich
        /// <summary>
        /// Class constructor from specific diff options (rather than using defaults)
        /// </summary>
        /// <param name="args"></param>
        public AppViewModel(DirDiffArgs args)
            : this()
        {
            _Args = args;

            // Update redundant copy of file diff mode viewmodel selection in this viewmodel
            // This enables the user to change this property within the document view
            _FileDiffMode.DiffFileModeSelected =
                _FileDiffMode.DiffFileModes.ToList().First(i => i.Key == (uint)args.CompareDirFileMode);

            _LeftDirPath  = args.LeftDir;
            _RightDirPath = args.RightDir;
        }
コード例 #3
0
        /// <summary>
        /// Class constructor from specific diff options (rather than using defaults)
        /// </summary>
        /// <param name="args"></param>
        /// <param name="dataSourceFactory"></param>
        public AppViewModel(DirDiffArgs args,
                            IDataSourceFactory dataSourceFactory)
            : this()
        {
            _Args = args;

            // Get a data object provider for browsing directories and files
            _DataSource = dataSourceFactory.CreateDataSource();

            // Update redundant copy of file diff mode viewmodel selection in this viewmodel
            // This enables the user to change this property within the document view
            _FileDiffMode.DiffFileModeSelected =
                _FileDiffMode.DiffFileModes.ToList().First(i => i.Key == (uint)args.CompareDirFileMode);

            _LeftDirPath  = args.LeftDir;
            _RightDirPath = args.RightDir;
        }
コード例 #4
0
        internal void ShowDifferences(DirDiffArgs args,
                                      IDirectoryDiffRoot diffResults
                                      )
        {
            try
            {
                SetData(diffResults, _CurrentViewMode);
                _Results = diffResults;

                _CompareOptions = args;                 // Record comparison options for later

                IsDiffDataAvailable = true;
            }
            catch
            {
                IsDiffDataAvailable = false;
            }
        }
コード例 #5
0
        internal DirDiffArgs GetDirDiffSetup()
        {
            var setup = new DirDiffArgs(LeftDirectoryPath, RightDirectoryPath);

            setup.CompareDirFileMode = this.FileDiffMode.DiffFileModeSelected.ModeKey;

            setup.Recursive                 = this.IsRecursive;
            setup.ShowOnlyInA               = ShowOnlyInA;
            setup.ShowOnlyInB               = ShowOnlyInB;
            setup.ShowDifferent             = ShowIfDifferent;
            setup.ShowSame                  = ShowIfSameFile;
            setup.IgnoreDirectoryComparison = !ShowIfSameDirectory;

            // Set file filter aka '*.cs' if any selected
            if (string.IsNullOrEmpty(FilterText) == false)
            {
                setup.FileFilter = new DirectoryDiffFileFilter(FilterText, IncludeFilter);
            }

            return(setup);
        }
コード例 #6
0
 /// <summary>
 /// Gets an initialized application viewmodel.
 /// </summary>
 /// <param name="args">Options to be used in this directory diff.</param>
 /// <returns></returns>
 public static IAppViewModel ConstructAppViewModel(DirDiffArgs args)
 {
     return(new AppViewModel(args));
 }
コード例 #7
0
        private void CompareFilesCommand_Executed(string leftDir,
                                                  string rightDir,
                                                  DiffDirFileMode dirFileMode)
        {
            if (_cancelTokenSource.IsCancellationRequested == true)
            {
                return;
            }

            DirDiffArgs args = _Args;

            _Args.CompareDirFileMode = dirFileMode;

            // Construct deffault options if there are no others
            if (_Args == null)
            {
                args = new DirDiffArgs(leftDir, rightDir);
            }
            else
            {
                _Args.LeftDir  = leftDir;
                _Args.RightDir = rightDir;
            }

            var diff = new DirectoryDiff(args);

            try
            {
                _DiffProgress.ResetProgressValues(_cancelTokenSource.Token);

                Task.Factory.StartNew <IDiffProgress>(
                    (p) => diff.Execute(args.LeftDir, args.RightDir, _DiffProgress, _DataSource)
                    , 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 IDirectoryDiffRoot;
                        _DirDiffDoc.ShowDifferences(args, diffResults);
                    }
                    else
                    {
                        // Display Error
                    }
                });
            }
            catch
            {
                // Handle task based error and display error
            }
        }
コード例 #8
0
ファイル: Factory.cs プロジェクト: huaxing-yuan/Aehnlich
 /// <summary>
 /// Gets an initialized application viewmodel.
 /// </summary>
 /// <param name="args">Options to be used in this directory diff.</param>
 /// <returns></returns>
 public static IAppViewModel ConstructAppViewModel(DirDiffArgs args)
 {
     return(new AppViewModel(args, new FsDataLib.Dir.DirDataSourceFactory()));
 }