Parent Directory
|
Revision Log
|
Patch
--- trunk/RomCheater/Docking/UI/UIMemoryViewer.cs 2012/05/31 07:29:44 200 +++ trunk/RomCheater/Docking/UI/UIMemoryViewer.cs 2012/05/31 08:38:16 202 @@ -29,7 +29,7 @@ txtData.UseFixedBytesPerLine = true; txtData.StringViewVisible = true; ramScroll.Minimum = (int)MemoryStart; - for (uint i = MemoryStart; i < (MemoryStart + MemorySize); i += max_address_width) { ramScroll.Maximum += (int)max_address_width; } + for (uint i = MemoryStart; i < (MemoryStart + max_ram_view); i += max_address_width) { ramScroll.Maximum += (int)max_address_width; } ramScroll.Value = ramScroll.Minimum; this.CanChangeUpdateInterval = false; @@ -40,7 +40,10 @@ lblAddressMarker.Text = lblAddressMarker.Text + string.Format("{0:X2} ", i); } this.AcceptedPlugin = null; this.AcceptedProcess = null; - } + + txtAddresses.MouseWheel += new MouseEventHandler(txtAddresses_MouseWheel); + txtData.MouseWheel += new MouseEventHandler(txtData_MouseWheel); + } #region IProcessConfig Members private Process _AcceptedProcess; public Process AcceptedProcess @@ -58,8 +61,8 @@ public IConfigPlugin AcceptedPlugin { get; set; } #endregion #region IAcceptsMemoryRange members - public uint MemoryStart { get; set; } - public uint MemorySize { get; set; } + private uint MemoryStart { get { return 0; } } + private uint MemorySize { get { return int.MaxValue; } } #endregion public void GotoTop() { this.CURRENT_TOP_ADDR = 0; } public void GotoBottom() { uint size = MemorySize; this.CURRENT_TOP_ADDR = (uint)((size - 1) - max_ram_view); } @@ -196,46 +199,48 @@ if (AcceptedPlugin == null) { return; } byte[] data = GetMemory(); - - List<byte> ByteData = new List<byte>((int)(address + (max_ram_view - 0))); - try { - AddressList = ""; - AsciiData = ""; + RamData = data; - // create a byte array holding only the bytes that we need - for (uint i = address; i < (address + (max_ram_view + 1)); i += 1) { ByteData.Add(data[i]); } + AddressList = ""; + AsciiData = ""; // write the addreses out for (uint i = address; i < (address + max_ram_view); i += max_address_width) { AddressList = AddressList + string.Format("{0:X8}:\n", i); } - // write out the ascii data + //// write out the ascii data StringBuilder builder = new StringBuilder(); for (uint i = address; i < (address + max_ram_view); i += max_address_width) { - for (uint j = 0; j < max_address_width; j++) + try { - uint current_addr = i + j; - if (current_addr >= MemorySize) break; - byte ascii_value_raw = data[current_addr]; - char ascii_value = (char)data[current_addr]; - if (ascii_value_raw >= 0x20 && ascii_value_raw <= 0x7e) - { - builder.Append(ascii_value.ToString()); - } - else + for (uint j = 0; j < max_address_width; j++) { - builder.Append("."); + uint current_addr = i + j; + if (current_addr >= MemorySize) break; + byte ascii_value_raw = data[j]; + char ascii_value = (char)data[j]; + if (ascii_value_raw >= 0x20 && ascii_value_raw <= 0x7e) + { + builder.Append(ascii_value.ToString()); + } + else + { + builder.Append("."); + } } + builder.AppendLine(); + } + catch (Exception ex) + { + logger.Error.WriteLine("{0}.UpdateMemroyView().BuildingAsciiString:{1}{2}", this.GetType().Name, System.Environment.NewLine, ex.ToString()); + return; } - builder.AppendLine(); } AsciiData = builder.ToString(); - // write out the bytes - RamData = ByteData.ToArray(); } @@ -303,7 +308,7 @@ uint ORIGINAL_ADDR = this.CURRENT_TOP_ADDR; ////if (e.Type == ScrollEventType.EndScroll) return; - uint size = MemorySize; + uint size = max_ram_view; bool haveModifier = false; switch (e.Modifiers) @@ -347,7 +352,7 @@ } if (this.CURRENT_TOP_ADDR < MemoryStart) this.CURRENT_TOP_ADDR = MemoryStart; //if (this.CURRENT_TOP_ADDR >= VTLB_VADDR_SIZE) this.CURRENT_TOP_ADDR = (size - 1) - max_ram_view; - if (this.CURRENT_TOP_ADDR + max_ram_view >= MemoryStart) this.CURRENT_TOP_ADDR = (size - 1) - max_ram_view; + if (this.CURRENT_TOP_ADDR + max_ram_view >= MemorySize) this.CURRENT_TOP_ADDR = (size - 1); //this.UpdateEnabled = reenable; } @@ -357,6 +362,45 @@ private void txtData_KeyDown(object sender, KeyEventArgs e) { this.Handle_KeyDown(sender, e); } private void ramScroll_Scroll(object sender, ScrollEventArgs e) { this.Handle_Scroll(sender, e); } + + private ScrollEventArgs GetMouseWheelScrollChange(int WheelDelta) + { + ScrollEventArgs args = new ScrollEventArgs(ScrollEventType.SmallIncrement,1); + if (WheelDelta < 0) + { + //// negative: scroll down + //// SmallDecrement -or- LargeDecrement + //if (WheelDelta <= small_scroll_change) + //{ + // args = new ScrollEventArgs(ScrollEventType.SmallDecrement,(int)small_scroll_change); + //} + //if (WheelDelta > small_scroll_change && WheelDelta <= large_scroll_change) + //{ + // args = new ScrollEventArgs(ScrollEventType.LargeDecrement, (int)large_scroll_change); + //} + args = new ScrollEventArgs(ScrollEventType.SmallIncrement, 1); + } + else + { + //// positive: scroll up + //// SmallIncrement -or- LargeIncrement + //if (WheelDelta <= small_scroll_change) + //{ + // args = new ScrollEventArgs(ScrollEventType.SmallIncrement, (int)small_scroll_change); + //} + //if (WheelDelta > small_scroll_change && WheelDelta <= large_scroll_change) + //{ + // args = new ScrollEventArgs(ScrollEventType.LargeIncrement, (int)large_scroll_change); + //} + args = new ScrollEventArgs(ScrollEventType.SmallDecrement, 1); + } + return args; + } + + void txtAddresses_MouseWheel(object sender, MouseEventArgs e) { this.Handle_Scroll(sender, GetMouseWheelScrollChange(e.Delta)); } + void txtData_MouseWheel(object sender, MouseEventArgs e) { this.Handle_Scroll(sender, GetMouseWheelScrollChange(e.Delta)); } + + private void Handle_Scroll(object sender, ScrollEventArgs e) { //isScrolling = true; @@ -372,14 +416,28 @@ switch (e.Type) { case ScrollEventType.SmallDecrement: - this.CURRENT_TOP_ADDR -= (small_scroll_change); + if (this.CURRENT_TOP_ADDR == 0 && ((this.CURRENT_TOP_ADDR - small_scroll_change) > this.CURRENT_TOP_ADDR)) + { + this.CURRENT_TOP_ADDR = ORIGINAL_ADDR; + } + else + { + this.CURRENT_TOP_ADDR -= (small_scroll_change); + } break; case ScrollEventType.SmallIncrement: this.CURRENT_TOP_ADDR += (small_scroll_change); break; case ScrollEventType.LargeDecrement: - this.CURRENT_TOP_ADDR -= (large_scroll_change); + if (this.CURRENT_TOP_ADDR == 0 && ((this.CURRENT_TOP_ADDR - large_scroll_change) > this.CURRENT_TOP_ADDR)) + { + this.CURRENT_TOP_ADDR = ORIGINAL_ADDR; + } + else + { + this.CURRENT_TOP_ADDR -= (large_scroll_change); + } break; case ScrollEventType.LargeIncrement: this.CURRENT_TOP_ADDR += (large_scroll_change);
ViewVC Help | |
Powered by ViewVC 1.1.22 |