Пример #1
0
 public MemoryViewModel(IMemory memory)
 {
     this.memory = memory;
     page = new MemoryPage();
     addresses = new Addresses(memory.Size - 0x100);
     Address = new Address();
     Address.PropertyChanged += Address_PropertyChanged;
     Address.Maximum = memory.Size - 0x100;
     size = (int)memory.Size / 1024;
     fillingFactor = memory.FillingFactor;
     fillingFactorPercents = fillingFactor / (double)memory.Size * 100.0;
 }
Пример #2
0
        private void _Update()
        {
            leftMemory = files[IndexOfTheSelectedLeftFile].memory;
            rightMemory = files[IndexOfTheSelectedRightFile].memory;

            List<long> addressesOfDifferences;
            if (Memory.Equals(leftMemory,rightMemory, out addressesOfDifferences))
            {
                Status = Resources.FilesAreEquals;
                FilesAreEqual = true;
                Differences = "";
            }
            else
            {
                Status = Resources.FilesAreNotEquals;
                FilesAreEqual = false;
                Differences = string.Format(Resources.Difference, addressesOfDifferences.Count);
            }

            addressesOfDiffPages = new SortedSet<long>();

            foreach (var address in addressesOfDifferences)
            {
                addressesOfDiffPages.Add((address/Page.Size) * Page.Size);
            }

            if (!init)
            {
                init = true;
                leftPage = new MemoryPage();
                rightPage = new MemoryPage();
                addresses = new Addresses(leftMemory.Size - 0x100);
                Address = new Address();
                Address.PropertyChanged += Address_PropertyChanged;
                Address.Maximum = leftMemory.Size - 0x100;
                AddressesOfDiffPages = new ObservableCollection<string>();
            }
            AddressesOfDiffPages.Clear();
            foreach (var address in addressesOfDiffPages)
            {
                var lenght = Address.Maximum.ToString("X").Length;
                AddressesOfDiffPages.Add(address.ToString("X" + lenght));
            }
            IndexOfTheSelectedAddress = 0;
            Update();
        }