Пример #1
0
        public static CompareState Compare(BitmapSource img1, BitmapSource img2)
        {
            CompareState res = CompareState.OK;

            if (img1.Width != img2.Width || img1.Height != img2.Height)
            {
                res = CompareState.SizeMisMatch;
                return(res);
            }

            byte[] ipi1, ipi2;
            ipi1 = new byte[(int)(img1.Height * (int)((img1.Width * img1.Format.BitsPerPixel + 7) / 8))];
            ipi2 = new byte[(int)(img2.Height * (int)((img2.Width * img2.Format.BitsPerPixel + 7) / 8))];
            img1.CopyPixels(ipi1, (int)((img1.Width * img1.Format.BitsPerPixel + 7) / 8), 0);
            img2.CopyPixels(ipi2, (int)((img2.Width * img2.Format.BitsPerPixel + 7) / 8), 0);
            SHA256Managed shaM = new SHA256Managed();

            byte[] hash1 = shaM.ComputeHash(ipi1);
            byte[] hash2 = shaM.ComputeHash(ipi2);
            for (int i = 0; i < hash1.Length; i++)
            {
                if (hash1[i] != hash2[i])
                {
                    res = CompareState.PixelMisMatch;
                    return(res);
                }
            }
            return(res);
        }
Пример #2
0
        private void SetNotComparedState()
        {
            if (_comparison != null)
            {
                _comparison.Disconnect();
            }

            btnCompareTabularModels.Enabled                     = true;
            ddSelectActions.Enabled                             = false;
            mnuHideSkipObjects.Enabled                          = false;
            mnuShowSkipObjects.Enabled                          = false;
            mnuSkipAllObjectsMissingInSource.Enabled            = false;
            mnuDeleteAllObjectsMissingInSource.Enabled          = false;
            mnuSkipAllObjectsMissingInTarget.Enabled            = false;
            mnuCreateAllObjectsMissingInTarget.Enabled          = false;
            mnuSkipAllObjectsWithDifferentDefinitions.Enabled   = false;
            mnuUpdateAllObjectsWithDifferentDefinitions.Enabled = false;
            btnValidateSelection.Enabled                        = false;
            btnUpdate.Enabled            = false;
            btnGenerateScript.Enabled    = false;
            btnReportDifferences.Enabled = false;
            toolStripStatusLabel1.Text   = "";

            //ComparisonCtrl.SetNotComparedState();

            _compareState = CompareState.NotCompared;
            SetGridState(false);
        }
Пример #3
0
        private static CombinedState Compare(IEnumerable <byte> subjectCollection, IEnumerable <byte> expectedCollection)
        {
            var subject  = new CompareState(subjectCollection);
            var expected = new CompareState(expectedCollection);

            bool subjectHasMovedNext, expectedHasMovedNext;

            while (true)
            {
                subjectHasMovedNext  = subject.MoveNext();
                expectedHasMovedNext = expected.MoveNext();
                if (!subjectHasMovedNext && !expectedHasMovedNext)
                {
                    // Finished iteration.
                    return(new CombinedState {
                        Subject = subject, Expected = expected
                    });
                }

                if (
                    subjectHasMovedNext != expectedHasMovedNext ||                  // One moved but the other did not.
                    subject.Current != expected.Current                 // Bytes not equal
                    )
                {
                    return(new CombinedState
                    {
                        Subject = subject,
                        Expected = expected
                    });
                }
            }
        }
Пример #4
0
        private void SetValidatedState()
        {
            btnUpdate.Enabled         = true;
            btnGenerateScript.Enabled = true;

            _compareState = CompareState.Validated;
        }
Пример #5
0
        private void SetValidatedState()
        {
            btnUpdate.Enabled         = true;
            btnGenerateScript.Enabled = true;

            _compareState = CompareState.Validated;
            // This method needs to be moved out of comparison control during clean up
            //ComparisonCtrl.SetValidatedState();
        }
Пример #6
0
 public CompareLog(CompareType type, CompareState state, string name,
                   CompareAttributes attribute = CompareAttributes.MatchAnything, string expected = null, string found = null)
 {
     Type      = type;
     State     = state;
     Name      = name;
     Attribute = attribute;
     Expected  = expected;
     Found     = found;
     SubLogs   = new List <CompareLog>();
 }
Пример #7
0
        public CompareState GetByIndex(int index)
        {
            CompareState compareState = compareStateArray[index];

            if (compareState == null)
            {
                compareState             = new CompareState();
                compareStateArray[index] = compareState;
            }
            return(compareState);
        }
Пример #8
0
        /// <summary>
        /// Constructor with parent folder, name, size and modified date
        /// </summary>
        /// <param name="parentFolder">The parent folder this item is in</param>
        /// <param name="name">The name of this item</param>
        /// <param name="size">The size of this item</param>
        /// <param name="modifiedDateTime">The modified date/time of this item</param>
        public FileSystemItem(FolderItem parentFolder, string name, long size, DateTime modifiedDateTime)
        {
            this.parentFolder     = parentFolder;
            this.name             = name;
            this.size             = size;
            this.modifiedDateTime = modifiedDateTime;

            // Default sync state is NONE
            this.state = CompareState.None;

            // Icons are not initialized here, because that is slow
        }
        public void SetNotComparedState()
        {
            _compareState = CompareState.NotCompared;

            treeGridComparisonResults.Unloading = true;
            treeGridComparisonResults.Nodes.Clear();
            treeGridComparisonResults.Unloading = false;

            txtSourceObjectDefinition.Text = "";
            txtTargetObjectDefinition.Text = "";
            //txtSource.Text = "";
            //txtTarget.Text = "";

            //Just in case did an AMO comparison and messed up the fonts
            txtSourceObjectDefinition.Font = new System.Drawing.Font("Consolas", 9.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            txtTargetObjectDefinition.Font = new System.Drawing.Font("Consolas", 9.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
        }
        private void Awake()
        {
            //Modulok beállítása
            this.modules = Module_Controller.CreateModuleController(this, factory, client);

            //Interakciók beállítása
            this.interactions = new Interactions(this, modules);

            //Játékfázisok beállítása
            this.orderChangeState     = new OrderChangeState(modules, this, interactions);
            this.preparationState     = new PreparationState(modules, this, interactions);
            this.starterDrawState     = new StarterDrawState(modules, this, interactions);
            this.settingRoleState     = new SettingRoleState(modules, this, interactions);
            this.selectFightTypeState = new SelectFightTypeState(modules, this, interactions);
            this.summonState          = new SummonState(modules, this, interactions);
            this.revealCardsState     = new RevealCardsState(modules, this, interactions);
            this.quickSkillState      = new QuickSkillState(modules, this, interactions);
            this.mainSkillState       = new MainSkillState(modules, this, interactions);
            this.compareState         = new CompareState(modules, this, interactions);
            this.lateSkillState       = new LateSkillState(modules, this, interactions);
            this.cardPutAwayState     = new CardPutAwayState(modules, this, interactions);
            this.blindMatchState      = new BlindMatchState(modules, this, interactions);
            this.resultState          = new ResultState(modules, this, interactions);

            //Játékfázisok és státuszok alapértékezése
            this.currentPhase           = MainGameStates.SetupGame;
            this.currentStat            = CardStatType.NotDecided;
            this.currentAction          = SkillEffectAction.None;
            this.currentSelectionType   = CardListTarget.None;
            this.currentKey             = -1;
            this.currentActiveCard      = -1;
            this.lastWinnerKey          = -1;
            this.phaseChange            = true;
            this.firstRound             = true;
            this.displayedMessageStatus = false;
            this.blindMatch             = false;
            this.actionFinished         = true;
            this.turnFinished           = true;
            this.skillFinished          = true;
            this.changedOrder           = false;
            this.lateSkillKeys          = new List <int>();
            this.instantWin             = false;
            this.negatedSkills          = false;

            rng = new System.Random();
        }
Пример #11
0
 private void SetComparedState()
 {
     _compareState = CompareState.Compared;
     btnCompareTabularModels.Enabled                     = true;
     ddSelectActions.Enabled                             = true;
     mnuHideSkipObjects.Enabled                          = true;
     mnuShowSkipObjects.Enabled                          = true;
     mnuSkipAllObjectsMissingInSource.Enabled            = true;
     mnuDeleteAllObjectsMissingInSource.Enabled          = true;
     mnuSkipAllObjectsMissingInTarget.Enabled            = true;
     mnuCreateAllObjectsMissingInTarget.Enabled          = true;
     mnuSkipAllObjectsWithDifferentDefinitions.Enabled   = true;
     mnuUpdateAllObjectsWithDifferentDefinitions.Enabled = true;
     btnValidateSelection.Enabled                        = true;
     btnUpdate.Enabled            = false;
     btnGenerateScript.Enabled    = false;
     btnReportDifferences.Enabled = true;
 }
Пример #12
0
        internal void SetNotComparedState()
        {
            _compareState = CompareState.NotCompared;

            if (_comparison != null)
            {
                _comparison.Disconnect();
            }
            treeGridComparisonResults.Unloading = true;
            treeGridComparisonResults.Nodes.Clear();
            treeGridComparisonResults.Unloading = false;

            if (_bismNormalizerPackage.Dte != null)
            {
                _bismNormalizerPackage.Dte.StatusBar.Text = "";
            }
            txtSourceObjectDefinition.Text = "";
            txtTargetObjectDefinition.Text = "";
            //txtSource.Text = "";
            //txtTarget.Text = "";

            btnCompareTabularModels.Enabled                     = true;
            ddSelectActions.Enabled                             = false;
            mnuHideSkipObjects.Enabled                          = false;
            mnuShowSkipObjects.Enabled                          = false;
            mnuSkipAllObjectsMissingInSource.Enabled            = false;
            mnuDeleteAllObjectsMissingInSource.Enabled          = false;
            mnuSkipAllObjectsMissingInTarget.Enabled            = false;
            mnuCreateAllObjectsMissingInTarget.Enabled          = false;
            mnuSkipAllObjectsWithDifferentDefinitions.Enabled   = false;
            mnuUpdateAllObjectsWithDifferentDefinitions.Enabled = false;
            btnValidateSelection.Enabled                        = false;
            btnUpdate.Enabled            = false;
            btnGenerateScript.Enabled    = false;
            btnReportDifferences.Enabled = false;

            ClearMessages();

            //Just in case did an AMO comparison and messed up the fonts
            txtSourceObjectDefinition.Font = new System.Drawing.Font("Consolas", 9.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            txtTargetObjectDefinition.Font = new System.Drawing.Font("Consolas", 9.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
        }
Пример #13
0
        private void SetComparedState()
        {
            btnCompareTabularModels.Enabled                     = true;
            ddSelectActions.Enabled                             = true;
            mnuHideSkipObjects.Enabled                          = true;
            mnuShowSkipObjects.Enabled                          = true;
            mnuSkipAllObjectsMissingInSource.Enabled            = true;
            mnuDeleteAllObjectsMissingInSource.Enabled          = true;
            mnuSkipAllObjectsMissingInTarget.Enabled            = true;
            mnuCreateAllObjectsMissingInTarget.Enabled          = true;
            mnuSkipAllObjectsWithDifferentDefinitions.Enabled   = true;
            mnuUpdateAllObjectsWithDifferentDefinitions.Enabled = true;
            btnValidateSelection.Enabled                        = true;
            btnUpdate.Enabled            = false;
            btnGenerateScript.Enabled    = false;
            btnReportDifferences.Enabled = true;

            //ComparisonCtrl.SetComparedState();

            // NG: Disable skip and other actions for the control here
            _compareState = CompareState.Compared;

            SetGridState(true);
        }
 public void SetValidatedState()
 {
     _compareState = CompareState.Validated;
 }
 public void SetComparedState()
 {
     _compareState = CompareState.Compared;
 }
Пример #16
0
 public CompareStateFilterExpression(CompareState state)
 {
     CompareState = state;
 }
Пример #17
0
        /// <summary>
        /// Compare this folder to another one. Set all states of files and folders
        /// INCLUDING OUR OWN STATE
        /// </summary>
        /// <param name="otherFolder"></param>
        public void CompareTo(FolderItem otherFolder)
        {
            // Assume the lowest state for each
            CompareState myState    = CompareState.Unchanged;
            CompareState otherState = CompareState.Unchanged;

            //if (this.files.Count == 0 && otherFolder.files.Count == 0)
            //{
            //  myState = CompareState.Equal;
            //  otherState = CompareState.Equal;
            //}
            //else
            //{
            // Iterate over our own files, comparing each
            foreach (FileItem file in this.files)
            {
                string name = file.Name;

                FileItem otherFile = otherFolder.FindFileByName(name);
                if (otherFile == null)
                {
                    // Hey - no equivalent of our file found! Upgrade our own state to Added:
                    myState = CompareState.Added;
                }
                else
                {
                    file.CompareTo(otherFile);

                    // If the file has a more important state than we do, update our state
                    if (file.State > myState)
                    {
                        myState = file.State;
                    }
                }
            }

            if (myState == CompareState.Added)
            {
                otherState = CompareState.Older;
            }
            else
            {
                // Update the other folder's state based on its files:
                foreach (FileItem file in otherFolder.files)
                {
                    if (file.State > otherState)
                    {
                        otherState = file.State;
                    }
                }
            }
            //}

            // Compare all folders
            foreach (FolderItem folder in this.folders)
            {
                string name = folder.Name;

                FolderItem folder2 = otherFolder.FindFolderByName(Path.GetFileName(name));
                if (folder2 != null)
                {
                    // Compare the two folders:
                    folder.CompareTo(folder2);

                    // Upgrade our own state if we have to:
                    if (folder.State > myState)
                    {
                        myState = folder.State;
                    }
                }
            }

            if (myState == CompareState.Added)
            {
                otherState = CompareState.Older;
            }
            else
            {
                // Update the other folder's state based on its folders:
                foreach (FolderItem folder in otherFolder.folders)
                {
                    if (folder.State > otherState)
                    {
                        otherState = folder.State;
                    }
                }
            }

            // Now update our own and the other folder's states:
            this.State        = myState;
            otherFolder.State = otherState;
        }
Пример #18
0
 /// <summary>
 /// Set the display state of a compare state to true or false
 /// </summary>
 /// <param name="state">The compare state to change</param>
 /// <param name="show">Whether to show that compare state</param>
 public void SetStateDisplay(CompareState state, bool show)
 {
     this.stateDisplay[(int)state] = show;
 }
Пример #19
0
 /// <summary>
 /// Get the display state of a compare state
 /// </summary>
 /// <param name="state"></param>
 /// <returns></returns>
 public bool GetStateDisplay(CompareState state)
 {
     return(this.stateDisplay[(int)state]);
 }