예제 #1
0
        /// <summary>
        /// Sets up the left and right diff viewmodels which contain line by line information
        /// with reference to textual contents and whether it should be handled as insertion,
        /// deletion, change, or no change when comparing left side (ViewA) with right side (ViewB).
        /// </summary>
        /// <param name="listA"></param>
        /// <param name="listB"></param>
        /// <param name="script"></param>
        /// <param name="args"></param>
        /// <param name="changeDiffIgnoreCase"></param>
        /// <param name="changeDiffIgnoreWhiteSpace"></param>
        /// <param name="changeDiffTreatAsBinaryLines"></param>
        private void SetData(IList <string> listA, IList <string> listB,
                             EditScript script,
                             TextBinaryDiffArgs args,
                             bool changeDiffIgnoreCase,
                             bool changeDiffIgnoreWhiteSpace,
                             bool changeDiffTreatAsBinaryLines)
        {
            _Args = args;

            ChangeDiffOptions changeDiffOptions = ChangeDiffOptions.None;

            if (changeDiffTreatAsBinaryLines)
            {
                changeDiffOptions |= ChangeDiffOptions.IgnoreBinaryPrefix;
            }
            else
            {
                if (changeDiffIgnoreCase)
                {
                    changeDiffOptions |= ChangeDiffOptions.IgnoreCase;
                }

                if (changeDiffIgnoreWhiteSpace)
                {
                    changeDiffOptions |= ChangeDiffOptions.IgnoreWhitespace;
                }
            }

            _ViewA.ChangeDiffOptions        = changeDiffOptions;
            _ViewB.ChangeDiffOptions        = changeDiffOptions;
            _ViewLineDiff.ChangeDiffOptions = changeDiffOptions;

            var factory = new LinesFactory();

            factory.SetData(listA, listB, script);

            _ViewA.SetData(args.A, factory.LinesA, factory.TextA, args.SpacesPerTab);
            _ViewB.SetData(args.B, factory.LinesB, factory.TextB, args.SpacesPerTab);

            NotifyPropertyChanged(() => this.IsDiffDataAvailable);

            Debug.Assert(this._ViewA.LineCount == this._ViewB.LineCount, "Both DiffView's LineCounts must be the same");

            // Sets the similarity value (0% - 100%) between 2 things shown in toolbar
            this.Similarity_Text = string.Format("{0:P}", script.Similarity);

            // Show left and right file name labels over each ViewA and ViewB
            bool showNames = !string.IsNullOrEmpty(args.A) || !string.IsNullOrEmpty(args.B);

            this.edtLeft_Right_Visible = showNames;

            if (showNames)
            {
                this.edtLeft_Text  = args.A;
                this.edtRight_Text = args.B;
            }

            this.currentDiffLine = -1;
            this.UpdateViewLineDiff(args.SpacesPerTab);    // Update 2 line diff ViewLineDiff
        }
예제 #2
0
        static Program()
        {
            var configFactory = new ConfigFactory();
            var cellFactory   = new CellFactory();
            var figureFactory = new FigureFactory();
            var boardFactory  = new BoardFactory(figureFactory, cellFactory);
            var linesFactory  = new LinesFactory();

            Console = new ConcreteConsole();
            var consoleInputProvider = new ConsoleInputProvider(Console);

            var playerRegisterManager = new PlayerRegisterManager(consoleInputProvider, Console);

            PreparationService = new GamePreparationService(configFactory, playerRegisterManager, consoleInputProvider, Console);
            var inputManager = new GameInputProvider(consoleInputProvider, Console);

            PartyFinishedProvider = new PartyFinishProvider(consoleInputProvider);

            GameFactory = new GameFactory(boardFactory, linesFactory, inputManager);

            var figureDrawerFactory  = new FigureDrawerFactory(Console);
            var figureDrawerProvider = new FigureDrawerProvider(figureDrawerFactory);

            BoardDrawer = new BoardDrawer(Console, figureDrawerProvider);
        }
예제 #3
0
        /// <summary>
        /// Sets up the left and right diff viewmodels which contain line by line information
        /// with reference to textual contents and whether it should be handled as insertion,
        /// deletion, change, or no change when comparing left side (ViewA) with right side (ViewB).
        /// </summary>
        /// <param name="args"></param>
        /// <param name="r"></param>
        private void SetData(TextBinaryDiffArgs args,
                             ProcessTextDiff r)
        {
            _Args = args;

            ChangeDiffOptions changeDiffOptions = ChangeDiffOptions.None;

            if (r.IsComparedAs == CompareType.Binary)
            {
                changeDiffOptions |= ChangeDiffOptions.IgnoreBinaryPrefix;
            }
            else
            {
                if (r.IgnoreCase)
                {
                    changeDiffOptions |= ChangeDiffOptions.IgnoreCase;
                }

                if (r.IgnoreTextWhitespace)
                {
                    changeDiffOptions |= ChangeDiffOptions.IgnoreWhitespace;
                }
            }

            _ViewA.ChangeDiffOptions        = changeDiffOptions;
            _ViewB.ChangeDiffOptions        = changeDiffOptions;
            _ViewLineDiff.ChangeDiffOptions = changeDiffOptions;

            var factory = new LinesFactory();

            factory.SetData(r.ListA, r.ListB, r.Script);

            _ViewA.SetData(args.A, factory.LinesA, factory.TextA
                           , r.TextEncodingA, r.TextOriginalA, r.TextIsDirtyA, args.SpacesPerTab, r.IsComparedAs);

            _ViewB.SetData(args.B, factory.LinesB, factory.TextB
                           , r.TextEncodingB, r.TextOriginalB, r.TextIsDirtyB, args.SpacesPerTab, r.IsComparedAs);

            NotifyPropertyChanged(() => this.IsDiffDataAvailable);

            this.IsComparedAs = r.IsComparedAs;
            Debug.Assert(IsComparedAs != CompareType.Auto, "This should always be specific (eg: Xml, Bunary, or Text)");

            Debug.Assert(this._ViewA.LineCount == this._ViewB.LineCount, "Both DiffView's LineCounts must be the same");

            // Sets the similarity value (0% - 100%) between 2 things shown in toolbar
            this.Similarity_Text = string.Format("{0:P}", r.Script.Similarity);

            // Show left and right file name labels over each ViewA and ViewB
            bool showNames = !string.IsNullOrEmpty(args.A) || !string.IsNullOrEmpty(args.B);

            this.edtLeft_Right_Visible = showNames;

            if (showNames)
            {
                this.edtLeft_Text  = args.A;
                this.edtRight_Text = args.B;
            }

            this.currentDiffLine = -1;
            this.UpdateViewLineDiff(args.SpacesPerTab);                // Update 2 line diff ViewLineDiff
        }