1
0
mirror of https://github.com/fadden/6502bench.git synced 2026-04-25 21:18:25 +00:00

Move WinForms code to SourceGenWF

This commit is contained in:
Andy McFadden
2019-07-20 13:02:54 -07:00
parent b617d72b70
commit e3906e021b
138 changed files with 128 additions and 128 deletions
-98
View File
@@ -1,98 +0,0 @@
/*
* Copyright 2018 faddenSoft
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace SourceGen.Tools {
partial class AsciiChart {
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing) {
if (disposing && (components != null)) {
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent() {
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AsciiChart));
this.chartTextBox = new System.Windows.Forms.TextBox();
this.modeComboBox = new System.Windows.Forms.ComboBox();
this.SuspendLayout();
//
// chartTextBox
//
this.chartTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.chartTextBox.Font = new System.Drawing.Font("Consolas", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.chartTextBox.Location = new System.Drawing.Point(13, 13);
this.chartTextBox.Multiline = true;
this.chartTextBox.Name = "chartTextBox";
this.chartTextBox.ReadOnly = true;
this.chartTextBox.Size = new System.Drawing.Size(370, 450);
this.chartTextBox.TabIndex = 0;
this.chartTextBox.Text = resources.GetString("chartTextBox.Text");
//
// modeComboBox
//
this.modeComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.modeComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.modeComboBox.FormattingEnabled = true;
this.modeComboBox.Items.AddRange(new object[] {
"Standard ASCII",
"High ASCII"});
this.modeComboBox.Location = new System.Drawing.Point(13, 474);
this.modeComboBox.Name = "modeComboBox";
this.modeComboBox.Size = new System.Drawing.Size(167, 21);
this.modeComboBox.TabIndex = 1;
this.modeComboBox.SelectedIndexChanged += new System.EventHandler(this.modeComboBox_SelectedIndexChanged);
//
// AsciiChart
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(395, 507);
this.Controls.Add(this.modeComboBox);
this.Controls.Add(this.chartTextBox);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "AsciiChart";
this.Text = "ASCII Chart";
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.AsciiChart_FormClosed);
this.Load += new System.EventHandler(this.AsciiChart_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox chartTextBox;
private System.Windows.Forms.ComboBox modeComboBox;
}
}
-112
View File
@@ -1,112 +0,0 @@
/*
* Copyright 2018 faddenSoft
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.Text;
using System.Windows.Forms;
namespace SourceGen.Tools {
public partial class AsciiChart : Form {
/// <summary>
/// Chart mode. Must match combo box entries.
/// </summary>
private enum Mode {
Standard = 0,
High = 1
};
/// <summary>
/// Subscribe to this to be notified when the dialog closes.
/// </summary>
public event WindowClosing OnWindowClosing;
public delegate void WindowClosing(object sender, EventArgs e);
public AsciiChart() {
InitializeComponent();
}
private void AsciiChart_Load(object sender, EventArgs e) {
int mode = AppSettings.Global.GetInt(AppSettings.ASCCH_MODE, 0);
if (mode >= 0 && mode < modeComboBox.Items.Count) {
modeComboBox.SelectedIndex = mode;
}
DrawContents();
}
private void AsciiChart_FormClosed(object sender, FormClosedEventArgs e) {
if (OnWindowClosing != null) {
OnWindowClosing(this, e);
}
}
private void modeComboBox_SelectedIndexChanged(object sender, EventArgs e) {
AppSettings.Global.SetInt(AppSettings.ASCCH_MODE, modeComboBox.SelectedIndex);
DrawContents();
}
private void DrawContents() {
const string hdr = "Dec Hex Chr";
const string div = " | ";
const string eol = "\r\n";
Mode mode = (Mode) modeComboBox.SelectedIndex;
StringBuilder sb = new StringBuilder(
(hdr.Length * 4 + div.Length * 3 + eol.Length) * 32);
sb.Append(hdr);
sb.Append(div);
sb.Append(hdr);
sb.Append(div);
sb.Append(hdr);
sb.Append(div);
sb.Append(hdr);
sb.Append(eol);
for (int i = 0; i < 32; i++) {
DrawEntry(mode, i, sb);
sb.Append(div);
DrawEntry(mode, i + 32, sb);
sb.Append(div);
DrawEntry(mode, i + 64, sb);
sb.Append(div);
DrawEntry(mode, i + 96, sb);
sb.Append(eol);
}
chartTextBox.Text = sb.ToString();
chartTextBox.SelectionStart = sb.Length;
chartTextBox.SelectionLength = 0;
}
private void DrawEntry(Mode mode, int val, StringBuilder sb) {
// Format is: Dec Hex Chr
int modVal = (mode == Mode.High) ? val | 0x80 : val;
sb.AppendFormat("{0,3:D} {1,3:X2} ", modVal, modVal);
if (val < 0x20) {
sb.Append('^');
sb.Append((char)(val + 0x40));
sb.Append(' ');
} else if (val == 0x20) {
sb.Append("' '");
} else if (val < 0x7f) {
sb.Append(' ');
sb.Append((char)val);
sb.Append(' ');
} else {
sb.Append("DEL");
}
}
}
}
-156
View File
@@ -1,156 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="chartTextBox.Text" xml:space="preserve">
<value>Hex Dec Chr | Hex Dec Chr | Hex Dec Chr | Hex Dec Chr
00
01
02
03
04
05
06
07
08
09
0a
0b
0c
0d
0e
0f
10
11
12
13
14
15
16
17
18
19
1a
1b
1c
1d
1e
1f
</value>
</data>
</root>
-150
View File
@@ -1,150 +0,0 @@
/*
* Copyright 2018 faddenSoft
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace SourceGen.Tools {
partial class HexDumpViewer {
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing) {
if (disposing && (components != null)) {
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent() {
this.hexDumpListView = new System.Windows.Forms.ListView();
this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.charConvComboBox = new System.Windows.Forms.ComboBox();
this.charConvLabel = new System.Windows.Forms.Label();
this.topMostCheckBox = new System.Windows.Forms.CheckBox();
this.asciiOnlyCheckBox = new System.Windows.Forms.CheckBox();
this.SuspendLayout();
//
// hexDumpListView
//
this.hexDumpListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.hexDumpListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1});
this.hexDumpListView.Font = new System.Drawing.Font("Consolas", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.hexDumpListView.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
this.hexDumpListView.HideSelection = false;
this.hexDumpListView.Location = new System.Drawing.Point(13, 13);
this.hexDumpListView.Name = "hexDumpListView";
this.hexDumpListView.Size = new System.Drawing.Size(477, 514);
this.hexDumpListView.TabIndex = 0;
this.hexDumpListView.UseCompatibleStateImageBehavior = false;
this.hexDumpListView.View = System.Windows.Forms.View.Details;
this.hexDumpListView.VirtualMode = true;
this.hexDumpListView.CacheVirtualItems += new System.Windows.Forms.CacheVirtualItemsEventHandler(this.hexDumpListView_CacheVirtualItems);
this.hexDumpListView.RetrieveVirtualItem += new System.Windows.Forms.RetrieveVirtualItemEventHandler(this.hexDumpListView_RetrieveVirtualItem);
//
// columnHeader1
//
this.columnHeader1.Text = "Offset 0 1 2 3 4 5 6 7 8 9 A B C D E F ASCII";
this.columnHeader1.Width = 455;
//
// charConvComboBox
//
this.charConvComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.charConvComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.charConvComboBox.FormattingEnabled = true;
this.charConvComboBox.Items.AddRange(new object[] {
"Basic ASCII",
"High/Low ASCII"});
this.charConvComboBox.Location = new System.Drawing.Point(130, 533);
this.charConvComboBox.Name = "charConvComboBox";
this.charConvComboBox.Size = new System.Drawing.Size(136, 21);
this.charConvComboBox.TabIndex = 1;
this.charConvComboBox.SelectedIndexChanged += new System.EventHandler(this.charConvComboBox_SelectedIndexChanged);
//
// charConvLabel
//
this.charConvLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.charConvLabel.AutoSize = true;
this.charConvLabel.Location = new System.Drawing.Point(13, 536);
this.charConvLabel.Name = "charConvLabel";
this.charConvLabel.Size = new System.Drawing.Size(111, 13);
this.charConvLabel.TabIndex = 2;
this.charConvLabel.Text = "Character conversion:";
//
// topMostCheckBox
//
this.topMostCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.topMostCheckBox.AutoSize = true;
this.topMostCheckBox.Location = new System.Drawing.Point(398, 535);
this.topMostCheckBox.Name = "topMostCheckBox";
this.topMostCheckBox.Size = new System.Drawing.Size(92, 17);
this.topMostCheckBox.TabIndex = 3;
this.topMostCheckBox.Text = "Always on top";
this.topMostCheckBox.UseVisualStyleBackColor = true;
this.topMostCheckBox.CheckedChanged += new System.EventHandler(this.topMostCheckBox_CheckedChanged);
//
// asciiOnlyCheckBox
//
this.asciiOnlyCheckBox.AutoSize = true;
this.asciiOnlyCheckBox.Location = new System.Drawing.Point(284, 535);
this.asciiOnlyCheckBox.Name = "asciiOnlyCheckBox";
this.asciiOnlyCheckBox.Size = new System.Drawing.Size(104, 17);
this.asciiOnlyCheckBox.TabIndex = 4;
this.asciiOnlyCheckBox.Text = "ASCII-only dump";
this.asciiOnlyCheckBox.UseVisualStyleBackColor = true;
this.asciiOnlyCheckBox.CheckedChanged += new System.EventHandler(this.asciiOnlyCheckBox_CheckedChanged);
//
// HexDumpViewer
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(502, 561);
this.Controls.Add(this.asciiOnlyCheckBox);
this.Controls.Add(this.topMostCheckBox);
this.Controls.Add(this.charConvLabel);
this.Controls.Add(this.charConvComboBox);
this.Controls.Add(this.hexDumpListView);
this.MinimumSize = new System.Drawing.Size(518, 180);
this.Name = "HexDumpViewer";
this.Text = "Hex Dump Viewer";
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.HexDumpViewer_FormClosed);
this.Load += new System.EventHandler(this.HexDumpViewer_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.ListView hexDumpListView;
private System.Windows.Forms.ColumnHeader columnHeader1;
private System.Windows.Forms.ComboBox charConvComboBox;
private System.Windows.Forms.Label charConvLabel;
private System.Windows.Forms.CheckBox topMostCheckBox;
private System.Windows.Forms.CheckBox asciiOnlyCheckBox;
}
}
-276
View File
@@ -1,276 +0,0 @@
/*
* Copyright 2018 faddenSoft
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.Diagnostics;
using System.Text;
using System.Windows.Forms;
using Asm65;
using CommonWinForms;
namespace SourceGen.Tools {
/// <summary>
/// Display a hex dump.
/// </summary>
public partial class HexDumpViewer : Form {
/// <summary>
/// Maximum length of data we will display.
/// </summary>
public const int MAX_LENGTH = 1 << 24;
/// <summary>
/// Character conversion mode. The enum must match the items in the combo box.
/// </summary>
private enum CharConvMode {
PlainAscii = 0,
HighLowAscii
}
/// <summary>
/// Data to display. We currently require that the entire file fit in memory,
/// which is reasonable because we impose a 2^24 (16MB) limit.
/// </summary>
private byte[] mData;
/// <summary>
/// Data formatter object.
///
/// There's currently no way to update this after the dialog is opened, which means
/// we won't track changes to hex case preference. I'm okay with that.
/// </summary>
private Formatter mFormatter;
/// <summary>
/// If true, don't include non-ASCII characters in text area.
/// </summary>
private bool mAsciiOnlyDump;
/// <summary>
/// Subscribe to this to be notified when the dialog closes.
/// </summary>
public event WindowClosing OnWindowClosing;
public delegate void WindowClosing(object sender, EventArgs e);
public HexDumpViewer(byte[] data, Formatter formatter) {
InitializeComponent();
hexDumpListView.SetDoubleBuffered(true);
Debug.Assert(data.Length <= MAX_LENGTH);
mData = data;
mFormatter = formatter;
hexDumpListView.VirtualListSize = (mData.Length + 15) / 16;
}
private void HexDumpViewer_Load(object sender, EventArgs e) {
topMostCheckBox.Checked = TopMost;
// Configure ASCII-only mode. Note this causes the CheckedChange callback to
// fire, which sets the field and replaces the formatter.
bool asciiOnly = AppSettings.Global.GetBool(AppSettings.HEXD_ASCII_ONLY, false);
asciiOnlyCheckBox.Checked = asciiOnly;
// Just save and restore the combo box index. This might come up wrong after
// an upgrade that shuffles the options, but doing it right isn't worth the effort.
int charConv = AppSettings.Global.GetInt(AppSettings.HEXD_CHAR_CONV, 0);
if (charConv >= 0 && charConv <= charConvComboBox.Items.Count) {
charConvComboBox.SelectedIndex = charConv;
}
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData) {
if (keyData == (Keys.Control | Keys.A)) {
hexDumpListView.SelectAll();
return true;
} else if (keyData == (Keys.Control | Keys.C)) {
CopySelectionToClipboard();
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
private void asciiOnlyCheckBox_CheckedChanged(object sender, EventArgs e) {
mAsciiOnlyDump = asciiOnlyCheckBox.Checked;
AppSettings.Global.SetBool(AppSettings.HEXD_ASCII_ONLY, mAsciiOnlyDump);
ReplaceFormatter();
InvalidateListView();
}
private void topMostCheckBox_CheckedChanged(object sender, EventArgs e) {
TopMost = topMostCheckBox.Checked;
}
private void charConvComboBox_SelectedIndexChanged(object sender, EventArgs e) {
Debug.WriteLine("charConvCombBox selected: " + charConvComboBox.SelectedIndex);
AppSettings.Global.SetInt(AppSettings.HEXD_CHAR_CONV, charConvComboBox.SelectedIndex);
ReplaceFormatter();
InvalidateListView();
}
private void HexDumpViewer_FormClosed(object sender, FormClosedEventArgs e) {
if (OnWindowClosing != null) {
OnWindowClosing(this, e);
}
}
/// <summary>
/// Replaces the Formatter with a new one, using the current dialog configuration.
/// </summary>
private void ReplaceFormatter() {
Formatter.FormatConfig config = mFormatter.Config;
config.mHexDumpAsciiOnly = mAsciiOnlyDump;
CharConvMode mode = (CharConvMode)charConvComboBox.SelectedIndex;
switch (mode) {
case CharConvMode.PlainAscii:
config.mHexDumpCharConvMode = Formatter.FormatConfig.CharConvMode.PlainAscii;
break;
case CharConvMode.HighLowAscii:
config.mHexDumpCharConvMode = Formatter.FormatConfig.CharConvMode.HighLowAscii;
break;
case (CharConvMode)(-1):
// this happens during dialog init, before combo box is configured
break;
default:
Debug.Assert(false);
break;
}
mFormatter = new Formatter(config);
}
/// <summary>
/// Generates a string for every selected line, then copies the full thing to the
/// clipboard.
/// </summary>
private void CopySelectionToClipboard() {
ListView.SelectedIndexCollection indices = hexDumpListView.SelectedIndices;
if (indices.Count == 0) {
Debug.WriteLine("Nothing selected");
return;
}
// Try to make the initial allocation big enough to hold the full thing.
// Each line is currently 73 bytes, plus we throw in a CRLF. Doesn't have to
// be exact. With a 16MB max file size we're creating a ~75MB string for the
// clipboard, which .NET and Win10-64 seem to be able to handle.
StringBuilder sb = new StringBuilder(indices.Count * (73 + 2));
try {
Application.UseWaitCursor = true;
Cursor.Current = Cursors.WaitCursor;
foreach (int index in indices) {
mFormatter.FormatHexDump(mData, index * 16, sb);
sb.Append("\r\n");
}
} finally {
Application.UseWaitCursor = false;
Cursor.Current = Cursors.Arrow;
}
Clipboard.SetText(sb.ToString(), TextDataFormat.Text);
}
/// <summary>
/// Sets the scroll position to show the specified range.
/// </summary>
/// <param name="startOffset">First offset to show.</param>
/// <param name="endOffset">Last offset to show.</param>
public void ShowOffsetRange(int startOffset, int endOffset) {
Debug.WriteLine("HexDumpViewer: show +" + startOffset.ToString("x6") + " - +" +
endOffset.ToString("x6"));
int startLine = startOffset / 16;
int endLine = endOffset / 16;
// TODO(someday): instead of selecting the lines, highlight the individual
// bytes. This requires an owner-drawn ListView.
hexDumpListView.SelectedIndices.Clear();
for (int i = startLine; i <= endLine; i++) {
hexDumpListView.SelectedIndices.Add(i);
}
hexDumpListView.EnsureVisible(endLine);
hexDumpListView.EnsureVisible(startLine);
}
#region Virtual List View
// Using a virtual list view means we're allocating objects frequently when the
// list is being scrolled, but get to avoid massive trauma when opening a large file,
// and don't have to turn a 16MB file into a 74+MB string collection.
/// <summary>
/// Cache of previously-constructed ListViewItems. The ListView will request items
/// continuously as they are moused-over, so this is fairly important.
/// </summary>
private ListViewItem[] mItemCache;
private int mItemCacheFirst;
private void hexDumpListView_RetrieveVirtualItem(object sender,
RetrieveVirtualItemEventArgs e) {
// Is item cached?
if (mItemCache != null && e.ItemIndex >= mItemCacheFirst &&
e.ItemIndex < mItemCacheFirst + mItemCache.Length) {
// Yes, return existing item.
e.Item = mItemCache[e.ItemIndex - mItemCacheFirst];
} else {
// No, create item.
e.Item = CreateListViewItem(e.ItemIndex);
}
}
private void hexDumpListView_CacheVirtualItems(object sender,
CacheVirtualItemsEventArgs e) {
if (mItemCache != null && e.StartIndex >= mItemCacheFirst &&
e.EndIndex <= mItemCacheFirst + mItemCache.Length) {
// Already have this span cached.
return;
}
// Discard old cache, create new one, populate it.
mItemCacheFirst = e.StartIndex;
int len = e.EndIndex - e.StartIndex + 1; // end is inclusive
mItemCache = new ListViewItem[len];
for (int i = 0; i < len; i++) {
mItemCache[i] = CreateListViewItem(e.StartIndex + i);
}
}
private ListViewItem CreateListViewItem(int index) {
string fmtd = mFormatter.FormatHexDump(mData, index * 16);
return new ListViewItem(fmtd);
}
/// <summary>
/// Invalidates the contents of the list view, forcing a redraw. Useful when
/// the desired output format changes.
/// </summary>
private void InvalidateListView() {
hexDumpListView.BeginUpdate();
mItemCache = null;
mItemCacheFirst = -1;
hexDumpListView.EndUpdate();
}
#endregion Virtual List View
}
}
-120
View File
@@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
-80
View File
@@ -1,80 +0,0 @@
/*
* Copyright 2018 faddenSoft
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace SourceGen.Tools {
partial class ShowText {
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing) {
if (disposing && (components != null)) {
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent() {
this.textBox = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// textBox
//
this.textBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.textBox.Font = new System.Drawing.Font("Consolas", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.textBox.Location = new System.Drawing.Point(13, 13);
this.textBox.MaxLength = 0;
this.textBox.Multiline = true;
this.textBox.Name = "textBox";
this.textBox.ReadOnly = true;
this.textBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.textBox.Size = new System.Drawing.Size(629, 431);
this.textBox.TabIndex = 0;
this.textBox.Text = "012345678901234567890123456789012345678901234567890123456789012345678901234567890" +
"1234567890123456789";
//
// ShowText
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(654, 456);
this.Controls.Add(this.textBox);
this.Name = "ShowText";
this.Text = "Title";
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.ShowText_FormClosed);
this.Load += new System.EventHandler(this.ShowText_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox textBox;
}
}
-78
View File
@@ -1,78 +0,0 @@
/*
* Copyright 2018 faddenSoft
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.Diagnostics;
using System.Windows.Forms;
namespace SourceGen.Tools {
/// <summary>
/// Simple form for showing text in a TextBox. This can be used as a modeless
/// dialog, so a "window closing" event is available.
/// </summary>
public partial class ShowText : Form {
/// <summary>
/// Window title.
/// </summary>
public string Title {
set {
Text = value;
}
}
/// <summary>
/// Text to display.
/// </summary>
public string BodyText {
get {
return textBox.Text;
}
set {
textBox.Text = value;
textBox.SelectionStart = textBox.Text.Length;
textBox.ScrollToCaret();
}
}
/// <summary>
/// Subscribe to this to be notified when the dialog closes.
/// </summary>
public event WindowClosing OnWindowClosing;
public delegate void WindowClosing(object sender, EventArgs e);
public ShowText() {
InitializeComponent();
}
private void ShowText_Load(object sender, EventArgs e) {
//textBox.Select(BodyText.Length, BodyText.Length);
if (Modal) {
MaximizeBox = false;
MinimizeBox = false;
// Changing the ShowInTaskbar value kills the dialog. If we really care we
// can pass a "will be modal" parameter to the constructor and do it there.
// https://stackoverflow.com/a/20443430/294248
//ShowInTaskbar = false;
}
}
private void ShowText_FormClosed(object sender, FormClosedEventArgs e) {
if (OnWindowClosing != null) {
OnWindowClosing(this, e);
}
}
}
}
-120
View File
@@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>