Browse Source

- Implementation of options dialog

- some minor bug fixes

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@3015 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Siegfried Pammer 18 years ago
parent
commit
0002600457
  1. 9
      src/AddIns/DisplayBindings/HexEditor/Project/HexEditor.addin
  2. 3
      src/AddIns/DisplayBindings/HexEditor/Project/HexEditor.csproj
  3. 302
      src/AddIns/DisplayBindings/HexEditor/Project/Resources/HexEditOptions.xfrm
  4. 27
      src/AddIns/DisplayBindings/HexEditor/Project/Src/Editor.Designer.cs
  5. 355
      src/AddIns/DisplayBindings/HexEditor/Project/Src/Editor.cs
  6. 38
      src/AddIns/DisplayBindings/HexEditor/Project/Src/Util/NativeMethods.cs
  7. 165
      src/AddIns/DisplayBindings/HexEditor/Project/Src/Util/Settings.cs
  8. 15
      src/AddIns/DisplayBindings/HexEditor/Project/Src/View/HexEditContainer.Designer.cs
  9. 22
      src/AddIns/DisplayBindings/HexEditor/Project/Src/View/HexEditContainer.cs
  10. 22
      src/AddIns/DisplayBindings/HexEditor/Project/Src/View/HexEditDisplayBinding.cs
  11. 191
      src/AddIns/DisplayBindings/HexEditor/Project/Src/View/HexEditOptionsPanel.cs
  12. 14
      src/AddIns/DisplayBindings/HexEditor/Project/changes.txt

9
src/AddIns/DisplayBindings/HexEditor/Project/HexEditor.addin

@ -21,11 +21,11 @@ @@ -21,11 +21,11 @@
class = "HexEditor.View.HexEditDisplayBinding"/>
</Path>
<!-- <Path name = "/SharpDevelop/Dialogs/OptionsDialog/ToolsOptions">
<Path name = "/SharpDevelop/Dialogs/OptionsDialog/ToolsOptions">
<DialogPanel id = "HexEditor"
label = "HexEditor"
class = "HexEditor.View.HexEditOptionsPanel"/>
</Path> -->
</Path>
<!-- Right click menu -->
<Path name = "/AddIns/HexEditor/Editor/ContextMenu">
@ -49,9 +49,4 @@ @@ -49,9 +49,4 @@
label = "${res:XML.MainMenu.FileMenu.Close}"
class = "ICSharpCode.SharpDevelop.Commands.CloseFile"/>
</Path>
<!-- File extensions that will be opened in the Hex Editor -->
<Path name = "/AddIns/HexEditor/Editor">
<String id = "SupportedFileExtensions" text = ".exe;.dll"/>
</Path>
</AddIn>

3
src/AddIns/DisplayBindings/HexEditor/Project/HexEditor.csproj

@ -67,8 +67,9 @@ @@ -67,8 +67,9 @@
</Compile>
<Compile Include="Src\Util\BufferManager.cs" />
<Compile Include="Src\Util\Caret.cs" />
<Compile Include="Src\Util\Change.cs" />
<Compile Include="Src\Util\ClipboardManager.cs" />
<Compile Include="Src\Util\NativeMethods.cs" />
<Compile Include="Src\Util\Settings.cs" />
<Compile Include="Src\Util\UndoAction.cs" />
<Compile Include="Src\Util\UndoEventArgs.cs" />
<Compile Include="Src\Util\UndoStep.cs" />

302
src/AddIns/DisplayBindings/HexEditor/Project/Resources/HexEditOptions.xfrm

@ -1,129 +1,217 @@ @@ -1,129 +1,217 @@
<Components version="1.0">
<System.Windows.Forms.UserControl>
<Name value="HexEditOptions" />
<ClientSize value="{Width=348, Height=210}" />
<ClientSize value="{Width=334, Height=339}" />
<Controls>
<System.Windows.Forms.Button>
<Name value="btnSelectFont" />
<Location value="128, 90" />
<Text value="Select font ..." />
<UseVisualStyleBackColor value="True" />
<Size value="93, 26" />
<TabIndex value="13" />
</System.Windows.Forms.Button>
<System.Windows.Forms.GroupBox>
<Name value="groupBox2" />
<Location value="3, 122" />
<Text value="Preview" />
<Size value="340, 82" />
<TabIndex value="12" />
<Name value="groupBox4" />
<Location value="3, 192" />
<Text value="General" />
<Size value="325, 140" />
<TabIndex value="22" />
<Controls>
<System.Windows.Forms.TextBox>
<Name value="txtExtensions" />
<TabIndex value="7" />
<Location value="9, 115" />
<Text value=".exe;.dll" />
<Size value="298, 20" />
<Lines>
<System.String value=".exe;.dll" />
</Lines>
</System.Windows.Forms.TextBox>
<System.Windows.Forms.Label>
<Name value="lblOffsetPreview" />
<Location value="3, 16" />
<Text value="Offset" />
<TextAlign value="MiddleCenter" />
<Size value="334, 31" />
<ForeColor value="Color [ControlText]" />
<Dock value="Top" />
<TabIndex value="2" />
<Name value="label5" />
<Location value="9, 96" />
<Text value="Extensions to open with hex editor: (separated with ';')" />
<Size value="305, 23" />
<TabIndex value="6" />
</System.Windows.Forms.Label>
<System.Windows.Forms.NumericUpDown>
<Name value="nUDBytesPerLine" />
<TabIndex value="5" />
<Location value="184, 69" />
<Size value="120, 20" />
<Controls>
<System.Windows.Forms.UpDownBase_x002B_UpDownButtons>
<Name value="" />
<TabStop value="False" />
<TabIndex value="0" />
<Size value="16, 16" />
<Location value="100, 0" />
</System.Windows.Forms.UpDownBase_x002B_UpDownButtons>
<System.Windows.Forms.UpDownBase_x002B_UpDownEdit>
<Name value="" />
<TabIndex value="1" />
<Size value="96, 12" />
<Location value="2, 2" />
<BorderStyle value="None" />
<Text value="0" />
<Lines>
<System.String value="0" />
</Lines>
</System.Windows.Forms.UpDownBase_x002B_UpDownEdit>
</Controls>
</System.Windows.Forms.NumericUpDown>
<System.Windows.Forms.DomainUpDown>
<Name value="dUDViewModes" />
<TabIndex value="4" />
<Location value="184, 47" />
<Size value="120, 20" />
<Controls>
<System.Windows.Forms.UpDownBase_x002B_UpDownButtons>
<Name value="" />
<TabStop value="False" />
<TabIndex value="0" />
<Size value="16, 16" />
<Location value="100, 0" />
</System.Windows.Forms.UpDownBase_x002B_UpDownButtons>
<System.Windows.Forms.UpDownBase_x002B_UpDownEdit>
<Name value="" />
<TabIndex value="1" />
<Size value="96, 12" />
<Location value="2, 2" />
<BorderStyle value="None" />
</System.Windows.Forms.UpDownBase_x002B_UpDownEdit>
</Controls>
</System.Windows.Forms.DomainUpDown>
<System.Windows.Forms.Label>
<Name value="lblDataPreview" />
<Location value="3, 47" />
<Text value="Data" />
<TextAlign value="MiddleCenter" />
<Size value="334, 32" />
<Dock value="Bottom" />
<Name value="label4" />
<Location value="9, 71" />
<Text value="Standard number of bytes per line:" />
<Size value="190, 22" />
<TabIndex value="3" />
</System.Windows.Forms.Label>
<System.Windows.Forms.Label>
<Name value="label3" />
<Location value="9, 49" />
<Text value="Standard view-mode:" />
<Size value="187, 21" />
<TabIndex value="2" />
</System.Windows.Forms.Label>
<System.Windows.Forms.CheckBox>
<Name value="cbFitToWidth" />
<Location value="9, 19" />
<Text value="Always resize to fit current width." />
<TabIndex value="0" />
<Size value="295, 24" />
<UseVisualStyleBackColor value="True" />
</System.Windows.Forms.CheckBox>
</Controls>
</System.Windows.Forms.GroupBox>
<System.Windows.Forms.GroupBox>
<Name value="groupBox1" />
<Location value="256, 3" />
<Text value="Textstyles" />
<Size value="87, 81" />
<TabIndex value="11" />
<Name value="groupBox3" />
<Location value="3, 3" />
<Text value="Display" />
<Size value="325, 183" />
<TabIndex value="21" />
<Controls>
<System.Windows.Forms.CheckBox>
<Name value="cbItalic" />
<AutoSize value="True" />
<Location value="6, 40" />
<Text value="Italic" />
<TabIndex value="5" />
<Size value="48, 17" />
<System.Windows.Forms.GroupBox>
<Name value="groupBox2" />
<Location value="6, 107" />
<Text value="Preview" />
<Size value="310, 45" />
<TabIndex value="26" />
<Controls>
<System.Windows.Forms.Label>
<Name value="lblOffsetPreview" />
<Location value="3, 15" />
<ForeColor value="Color [ControlText]" />
<Text value="Offset" />
<Size value="305, 15" />
<TextAlign value="MiddleCenter" />
<Dock value="Top" />
<TabIndex value="2" />
</System.Windows.Forms.Label>
<System.Windows.Forms.Label>
<Name value="lblDataPreview" />
<Location value="3, 15" />
<Text value="Data" />
<Size value="305, 15" />
<TextAlign value="MiddleCenter" />
<Dock value="Bottom" />
<TabIndex value="3" />
</System.Windows.Forms.Label>
</Controls>
</System.Windows.Forms.GroupBox>
<System.Windows.Forms.GroupBox>
<Name value="groupBox1" />
<Location value="230, 16" />
<Text value="Textstyles" />
<Size value="87, 81" />
<TabIndex value="25" />
<Controls>
<System.Windows.Forms.CheckBox>
<Name value="cbItalic" />
<AutoSize value="True" />
<Location value="6, 40" />
<Text value="Italic" />
<TabIndex value="5" />
<Size value="48, 17" />
<UseVisualStyleBackColor value="True" />
</System.Windows.Forms.CheckBox>
<System.Windows.Forms.CheckBox>
<Name value="cbBold" />
<AutoSize value="True" />
<Location value="6, 19" />
<Text value="Bold" />
<TabIndex value="4" />
<Size value="47, 17" />
<UseVisualStyleBackColor value="True" />
</System.Windows.Forms.CheckBox>
<System.Windows.Forms.CheckBox>
<Name value="cbUnderline" />
<AutoSize value="True" />
<Location value="6, 60" />
<Text value="Underline" />
<TabIndex value="6" />
<Size value="71, 17" />
<UseVisualStyleBackColor value="True" />
</System.Windows.Forms.CheckBox>
</Controls>
</System.Windows.Forms.GroupBox>
<System.Windows.Forms.Button>
<Name value="btnSelectFont" />
<Location value="115, 59" />
<Text value="Select font ..." />
<UseVisualStyleBackColor value="True" />
</System.Windows.Forms.CheckBox>
<System.Windows.Forms.CheckBox>
<Name value="cbBold" />
<Size value="93, 26" />
<TabIndex value="27" />
</System.Windows.Forms.Button>
<System.Windows.Forms.Label>
<Name value="label2" />
<Location value="114, 16" />
<Text value="Foreground color:" />
<Size value="90, 13" />
<AutoSize value="True" />
<Location value="6, 19" />
<Text value="Bold" />
<TabIndex value="4" />
<Size value="47, 17" />
<UseVisualStyleBackColor value="True" />
</System.Windows.Forms.CheckBox>
<System.Windows.Forms.CheckBox>
<Name value="cbUnderline" />
<TabIndex value="24" />
</System.Windows.Forms.Label>
<System.Windows.Forms.Label>
<Name value="label1" />
<Location value="3, 16" />
<Text value="Elements:" />
<Size value="53, 13" />
<AutoSize value="True" />
<Location value="6, 60" />
<Text value="Underline" />
<TabIndex value="6" />
<Size value="71, 17" />
<UseVisualStyleBackColor value="True" />
</System.Windows.Forms.CheckBox>
<TabIndex value="23" />
</System.Windows.Forms.Label>
<System.Windows.Forms.ListBox>
<Name value="lstElements" />
<TabIndex value="22" />
<Location value="6, 32" />
<Size value="102, 69" />
<FormattingEnabled value="True" />
</System.Windows.Forms.ListBox>
<System.Windows.Forms.ComboBox>
<Name value="cmbForeColor" />
<TabIndex value="21" />
<DrawMode value="OwnerDrawFixed" />
<Location value="115, 32" />
<Size value="109, 21" />
<FormattingEnabled value="True" />
<DropDownStyle value="DropDownList" />
</System.Windows.Forms.ComboBox>
</Controls>
</System.Windows.Forms.GroupBox>
<System.Windows.Forms.Label>
<Name value="label3" />
<Location value="111, 47" />
<Text value="Background color:" />
<Size value="94, 13" />
<AutoSize value="True" />
<TabIndex value="10" />
</System.Windows.Forms.Label>
<System.Windows.Forms.Label>
<Name value="label2" />
<Location value="111, 0" />
<Text value="Foreground color:" />
<Size value="90, 13" />
<AutoSize value="True" />
<TabIndex value="9" />
</System.Windows.Forms.Label>
<System.Windows.Forms.Label>
<Name value="label1" />
<Location value="0, 0" />
<Text value="Elements:" />
<Size value="53, 13" />
<AutoSize value="True" />
<TabIndex value="8" />
</System.Windows.Forms.Label>
<System.Windows.Forms.ListBox>
<Name value="lstElements" />
<Size value="102, 69" />
<TabIndex value="7" />
<FormattingEnabled value="True" />
<Location value="3, 16" />
</System.Windows.Forms.ListBox>
<System.Windows.Forms.ComboBox>
<Name value="cmbBackColor" />
<Size value="138, 21" />
<TabIndex value="1" />
<DrawMode value="OwnerDrawFixed" />
<FormattingEnabled value="True" />
<DropDownStyle value="DropDownList" />
<Location value="111, 63" />
</System.Windows.Forms.ComboBox>
<System.Windows.Forms.ComboBox>
<Name value="cmbForeColor" />
<Size value="137, 21" />
<TabIndex value="0" />
<DrawMode value="OwnerDrawFixed" />
<FormattingEnabled value="True" />
<DropDownStyle value="DropDownList" />
<Location value="112, 16" />
</System.Windows.Forms.ComboBox>
</Controls>
</System.Windows.Forms.UserControl>
</Components>
</Components>

27
src/AddIns/DisplayBindings/HexEditor/Project/Src/Editor.Designer.cs generated

@ -35,7 +35,6 @@ namespace HexEditor @@ -35,7 +35,6 @@ namespace HexEditor
/// </summary>
private void InitializeComponent()
{
this.bWorker = new System.ComponentModel.BackgroundWorker();
this.VScrollBar = new System.Windows.Forms.VScrollBar();
this.textView = new System.Windows.Forms.Panel();
this.hexView = new System.Windows.Forms.Panel();
@ -53,12 +52,13 @@ namespace HexEditor @@ -53,12 +52,13 @@ namespace HexEditor
this.VScrollBar.TabIndex = 9;
this.VScrollBar.Scroll += new System.Windows.Forms.ScrollEventHandler(this.VScrollBarScroll);
//
// TextView
// textView
//
this.textView.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)));
this.textView.Cursor = System.Windows.Forms.Cursors.IBeam;
this.textView.Location = new System.Drawing.Point(561, 18);
this.textView.Name = "TextView";
this.textView.MinimumSize = new System.Drawing.Size(1, 1);
this.textView.Name = "textView";
this.textView.Size = new System.Drawing.Size(108, 347);
this.textView.TabIndex = 12;
this.textView.MouseMove += new System.Windows.Forms.MouseEventHandler(this.TextViewMouseMove);
@ -66,13 +66,14 @@ namespace HexEditor @@ -66,13 +66,14 @@ namespace HexEditor
this.textView.MouseDown += new System.Windows.Forms.MouseEventHandler(this.TextViewMouseDown);
this.textView.MouseUp += new System.Windows.Forms.MouseEventHandler(this.TextViewMouseUp);
//
// HexView
// hexView
//
this.hexView.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.hexView.Cursor = System.Windows.Forms.Cursors.IBeam;
this.hexView.Location = new System.Drawing.Point(92, 18);
this.hexView.Name = "HexView";
this.hexView.MinimumSize = new System.Drawing.Size(1, 1);
this.hexView.Name = "hexView";
this.hexView.Size = new System.Drawing.Size(463, 347);
this.hexView.TabIndex = 11;
this.hexView.MouseMove += new System.Windows.Forms.MouseEventHandler(this.HexViewMouseMove);
@ -80,23 +81,25 @@ namespace HexEditor @@ -80,23 +81,25 @@ namespace HexEditor
this.hexView.MouseDown += new System.Windows.Forms.MouseEventHandler(this.HexViewMouseDown);
this.hexView.MouseUp += new System.Windows.Forms.MouseEventHandler(this.HexViewMouseUp);
//
// Side
// side
//
this.side.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.side.Location = new System.Drawing.Point(0, 0);
this.side.Name = "Side";
this.side.MinimumSize = new System.Drawing.Size(1, 1);
this.side.Name = "side";
this.side.Size = new System.Drawing.Size(76, 365);
this.side.TabIndex = 10;
//
// Header
// header
//
this.header.Location = new System.Drawing.Point(92, 0);
this.header.Name = "Header";
this.header.MinimumSize = new System.Drawing.Size(1, 1);
this.header.Name = "header";
this.header.Size = new System.Drawing.Size(463, 18);
this.header.TabIndex = 13;
//
// HexEditControl
// Editor
//
this.BackColor = System.Drawing.Color.White;
this.Controls.Add(this.header);
@ -105,7 +108,8 @@ namespace HexEditor @@ -105,7 +108,8 @@ namespace HexEditor
this.Controls.Add(this.side);
this.Controls.Add(this.VScrollBar);
this.DoubleBuffered = true;
this.Name = "HexEditControl";
this.MinimumSize = new System.Drawing.Size(1, 1);
this.Name = "Editor";
this.Size = new System.Drawing.Size(688, 365);
this.Paint += new System.Windows.Forms.PaintEventHandler(this.HexEditPaint);
this.ContextMenuStripChanged += new System.EventHandler(this.HexEditControlContextMenuStripChanged);
@ -119,7 +123,6 @@ namespace HexEditor @@ -119,7 +123,6 @@ namespace HexEditor
private System.Windows.Forms.Panel side;
private System.Windows.Forms.Panel hexView;
private System.Windows.Forms.Panel textView;
private System.ComponentModel.BackgroundWorker bWorker;
private System.Windows.Forms.VScrollBar VScrollBar;
}
}

355
src/AddIns/DisplayBindings/HexEditor/Project/Src/Editor.cs

@ -22,8 +22,7 @@ using HexEditor.Util; @@ -22,8 +22,7 @@ using HexEditor.Util;
namespace HexEditor
{
// TODO : Make BIG FILES COMPATIBLE (Data structures are bad)
// TODO : Add options
// TODO : Make BIG FILES COMPATIBLE (data structures are bad)
/// <summary>
/// Hexadecimal editor control.
@ -43,32 +42,7 @@ namespace HexEditor @@ -43,32 +42,7 @@ namespace HexEditor
int underscorewidth, underscorewidth3, fontheight;
bool insertmode, hexinputmode, selectionmode, handled, moved;
public bool Moved {
get { return moved; }
set { moved = value; }
}
public bool Handled {
get { return handled; }
set { handled = value; }
}
public bool Selectionmode {
get { return selectionmode; }
set { selectionmode = value; }
}
public bool HexInputMode {
get { return hexinputmode; }
set { hexinputmode = value; }
}
public bool Insertmode {
get { return insertmode; }
set { insertmode = value; }
}
Settings settings;
Rectangle[] selregion;
Point[] selpoints;
@ -80,15 +54,8 @@ namespace HexEditor @@ -80,15 +54,8 @@ namespace HexEditor
}
SelectionManager selection;
UndoManager undoStack;
Color offsetForeColor, offsetBackColor, dataForeColor, dataBackColor;
bool offsetBold, offsetItalic, offsetUnderline, dataBold, dataItalic, dataUnderline;
Font offsetFont, dataFont;
Panel activeView;
//HexInput hexInputHandler;
// public HexInput HexInputHandler {
// get { return hexInputHandler; }
// }
public Panel ActiveView {
get { return activeView; }
@ -126,29 +93,25 @@ namespace HexEditor @@ -126,29 +93,25 @@ namespace HexEditor
//
InitializeComponent();
LoadSettings();
buffer = new BufferManager(this);
selection = new SelectionManager(ref buffer);
undoStack = new UndoManager();
insertmode = true;
underscorewidth = MeasureStringWidth(this.CreateGraphics(), "_", this.Font);
underscorewidth = MeasureStringWidth(this.CreateGraphics(), "_", this.settings.DataFont);
underscorewidth3 = underscorewidth * 3;
fontheight = GetFontHeight(this.Font);
fontheight = GetFontHeight(this.settings.DataFont);
selregion = new Rectangle[] {};
selpoints = new Point[] {};
headertext = GetHeaderText();
this.offsetFont = new Font(this.Font, FontStyle.Regular);
this.dataFont = new Font(this.Font, FontStyle.Regular);
this.ActiveView = this.hexView;
UpdatePainters();
caret = new Caret(this.gbHex, 1, fontheight, 0);
// TODO : Implement settings
//LoadSettings();
HexEditSizeChanged(null, EventArgs.Empty);
AdjustScrollBar();
}
@ -156,59 +119,16 @@ namespace HexEditor @@ -156,59 +119,16 @@ namespace HexEditor
/// <summary>
/// Loads the settings out of the config file of hexeditor.
/// </summary>
/// <remarks>Currently not working, because there's no options dialog implemented.</remarks>
public void LoadSettings()
{
string configpath = Path.GetDirectoryName(typeof(Editor).Assembly.Location) + Path.DirectorySeparatorChar + "config.xml";
if (!File.Exists(configpath)) return;
XmlDocument file = new XmlDocument();
file.Load(configpath);
foreach (XmlElement el in file.GetElementsByTagName("Setting")) {
switch(el.GetAttribute("Name")) {
case "OffsetFore" :
this.offsetForeColor = Color.FromArgb(int.Parse(el.GetAttribute("R")), int.Parse(el.GetAttribute("G")), int.Parse(el.GetAttribute("B")));
break;
case "OffsetBack" :
this.offsetBackColor = Color.FromArgb(int.Parse(el.GetAttribute("R")), int.Parse(el.GetAttribute("G")), int.Parse(el.GetAttribute("B")));
break;
case "DataFore" :
this.dataForeColor = Color.FromArgb(int.Parse(el.GetAttribute("R")), int.Parse(el.GetAttribute("G")), int.Parse(el.GetAttribute("B")));
break;
case "DataBack" :
this.dataBackColor = Color.FromArgb(int.Parse(el.GetAttribute("R")), int.Parse(el.GetAttribute("G")), int.Parse(el.GetAttribute("B")));
break;
case "OffsetStyle" :
this.offsetBold = bool.Parse(el.GetAttribute("Bold"));
this.offsetItalic = bool.Parse(el.GetAttribute("Italic"));
this.offsetUnderline = bool.Parse(el.GetAttribute("Underline"));
break;
case "DataStyle" :
this.dataBold = bool.Parse(el.GetAttribute("Bold"));
this.dataItalic = bool.Parse(el.GetAttribute("Italic"));
this.dataUnderline = bool.Parse(el.GetAttribute("Underline"));
break;
case "Font" :
this.Font = new Font(el.GetAttribute("FontName"), float.Parse(el.GetAttribute("FontSize")));
break;
}
}
FontStyle offsetStyle = FontStyle.Regular;
if (this.offsetBold) offsetStyle &= FontStyle.Bold;
if (this.offsetItalic) offsetStyle &= FontStyle.Italic;
if (this.offsetUnderline) offsetStyle &= FontStyle.Underline;
XmlDocument doc = new XmlDocument();
doc.Load(configpath);
this.offsetFont = new Font(this.Font, offsetStyle);
FontStyle dataStyle = FontStyle.Regular;
if (this.dataBold) dataStyle &= FontStyle.Bold;
if (this.dataItalic) dataStyle &= FontStyle.Italic;
if (this.dataUnderline) dataStyle &= FontStyle.Underline;
this.dataFont = new Font(this.Font, dataStyle);
this.settings = Settings.FromXML(doc);
}
#region Measure functions
@ -266,7 +186,6 @@ namespace HexEditor @@ -266,7 +186,6 @@ namespace HexEditor
ViewMode viewMode = ViewMode.Hexadecimal;
int bytesPerLine = 16;
bool fitToWindowWidth;
Font font = new Font("Courier New", 10f);
string fileName;
Encoding encoding = Encoding.Default;
@ -336,19 +255,40 @@ namespace HexEditor @@ -336,19 +255,40 @@ namespace HexEditor
}
/// <summary>
/// The font used in the hex editor.
/// The font used for all data displays in the hex editor.
/// </summary>
new public Font Font {
get { return font; }
public Font DataFont {
get { return this.settings.DataFont; }
set {
font = value;
underscorewidth = MeasureStringWidth(this.CreateGraphics(), "_", this.Font);
this.settings.DataFont = value;
underscorewidth = MeasureStringWidth(this.CreateGraphics(), "_", value);
underscorewidth3 = underscorewidth * 3;
fontheight = GetFontHeight(this.Font);
fontheight = GetFontHeight(value);
this.Invalidate();
}
}
/// <summary>
/// The font used for all offset displays in the hex editor.
/// </summary>
public Font OffsetFont {
get { return this.settings.OffsetFont; }
set {
this.settings.OffsetFont = value;
underscorewidth = MeasureStringWidth(this.CreateGraphics(), "_", value);
underscorewidth3 = underscorewidth * 3;
fontheight = GetFontHeight(value);
this.Invalidate();
}
}
new public Font Font {
get { return null; }
set {
}
}
/// <summary>
/// The ViewMode used in the hex editor.
/// </summary>
@ -357,7 +297,7 @@ namespace HexEditor @@ -357,7 +297,7 @@ namespace HexEditor
get { return viewMode; }
set {
viewMode = value;
SetViews();
UpdateViews();
this.headertext = GetHeaderText();
@ -387,12 +327,10 @@ namespace HexEditor @@ -387,12 +327,10 @@ namespace HexEditor
if (value < 1) value = 1;
if (value > CalculateMaxBytesPerLine()) value = CalculateMaxBytesPerLine();
bytesPerLine = value;
SetViews();
UpdateViews();
this.headertext = GetHeaderText();
UpdatePainters();
this.Invalidate();
}
}
@ -457,7 +395,7 @@ namespace HexEditor @@ -457,7 +395,7 @@ namespace HexEditor
/// </summary>
void VScrollBarScroll(object sender, ScrollEventArgs e)
{
SetViews();
UpdateViews();
this.topline = VScrollBar.Value;
Point pos = GetPositionForOffset(caret.Offset, charwidth);
caret.SetToPosition(pos);
@ -471,6 +409,8 @@ namespace HexEditor @@ -471,6 +409,8 @@ namespace HexEditor
protected override void OnMouseWheel(MouseEventArgs e)
{
base.OnMouseWheel(e);
if (!this.VScrollBar.Enabled) return;
@ -568,6 +508,10 @@ namespace HexEditor @@ -568,6 +508,10 @@ namespace HexEditor
// Refresh selection.
CalculateSelectionRegions();
// Calculate views and reset scrollbar.
UpdateViews();
AdjustScrollBar();
// Paint using double buffering for better painting!
// Do painting.
@ -578,11 +522,12 @@ namespace HexEditor @@ -578,11 +522,12 @@ namespace HexEditor
PaintPointer(gbHex, gbText);
PaintSelection(gbHex, gbText, true);
this.caret.DrawCaret();
if (activeView == hexView)
this.caret.Graphics = gbHex;
else
this.caret.Graphics = gbText;
// Calculate views and reset scrollbar.
SetViews();
AdjustScrollBar();
this.caret.DrawCaret();
// Paint on device ...
this.gHeader.DrawImageUnscaled(bHeader, 0, 0);
@ -598,9 +543,8 @@ namespace HexEditor @@ -598,9 +543,8 @@ namespace HexEditor
void PaintHeader(System.Drawing.Graphics g)
{
g.Clear(Color.White);
TextRenderer.DrawText(g, headertext,
this.Font, new Rectangle(1, 1, this.hexView.Width + 5, fontheight),
Color.Blue, this.BackColor, TextFormatFlags.Left & TextFormatFlags.Top);
TextRenderer.DrawText(g, headertext, this.settings.OffsetFont, new Rectangle(1, 1, this.hexView.Width + 5, fontheight),
this.settings.OffsetForeColor, this.BackColor, TextFormatFlags.Left & TextFormatFlags.Top);
}
/// <summary>
@ -613,7 +557,6 @@ namespace HexEditor @@ -613,7 +557,6 @@ namespace HexEditor
g.Clear(Color.White);
string text = String.Empty;
int count = top + this.GetMaxVisibleLines();
string tmpcls = String.Empty;
StringBuilder builder = new StringBuilder("Offset\n0\n");
@ -624,23 +567,24 @@ namespace HexEditor @@ -624,23 +567,24 @@ namespace HexEditor
switch (this.ViewMode) {
case ViewMode.Decimal:
builder.AppendLine((i * this.BytesPerLine).ToString());
if (string.IsNullOrEmpty(tmpcls)) tmpcls = (i * this.BytesPerLine).ToString();
break;
case ViewMode.Hexadecimal:
builder.AppendFormat("{0:X}", i * this.BytesPerLine);
builder.AppendLine();
if (string.IsNullOrEmpty(tmpcls)) tmpcls = string.Format("{0:X}", i * this.BytesPerLine);
break;
case ViewMode.Octal:
StringBuilder num = new StringBuilder();
int tmp = i * this.BytesPerLine;
if (tmp == 0) num.Append("0");
while (tmp != 0) {
num.Insert(0, (tmp % 8).ToString());
tmp = (int)(tmp / 8);
if (tmp == 0) {
builder.AppendLine("0");
} else {
StringBuilder num = new StringBuilder();
while (tmp != 0) {
num.Insert(0, (tmp % 8).ToString());
tmp = (int)(tmp / 8);
}
builder.AppendLine(num.ToString());
}
builder.AppendLine(num.ToString());
if (string.IsNullOrEmpty(tmpcls)) tmpcls = num.ToString();
break;
}
}
@ -649,7 +593,8 @@ namespace HexEditor @@ -649,7 +593,8 @@ namespace HexEditor
text = builder.ToString();
builder = null;
TextRenderer.DrawText(g, text, this.Font, new Rectangle(0, 0, this.side.Width, this.side.Height), Color.Blue, this.BackColor, TextFormatFlags.Right);
TextRenderer.DrawText(g, text, this.settings.OffsetFont,this.side.ClientRectangle,
this.settings.OffsetForeColor, Color.White, TextFormatFlags.Right);
}
/// <summary>
@ -669,7 +614,7 @@ namespace HexEditor @@ -669,7 +614,7 @@ namespace HexEditor
offset = GetOffsetForLine(top + i + 1);
}
TextRenderer.DrawText(g, builder.ToString(), this.Font, new Rectangle(0, 0, this.hexView.Width, this.hexView.Height), this.ForeColor, this.BackColor, TextFormatFlags.Left & TextFormatFlags.Top);
TextRenderer.DrawText(g, builder.ToString(), this.settings.DataFont, new Rectangle(0, 0, this.hexView.Width, this.hexView.Height), this.settings.DataForeColor, Color.White, TextFormatFlags.Left & TextFormatFlags.Top);
}
/// <summary>
@ -689,7 +634,7 @@ namespace HexEditor @@ -689,7 +634,7 @@ namespace HexEditor
builder.AppendLine(GetText(buffer.GetBytes(offset, this.BytesPerLine)));
offset = GetOffsetForLine(top + i + 1);
}
TextRenderer.DrawText(g, builder.ToString(), this.Font, new Point(0, 0), this.ForeColor, this.BackColor);
TextRenderer.DrawText(g, builder.ToString(), this.settings.DataFont, new Point(0, 0), this.settings.DataForeColor, Color.White);
}
/// <summary>
@ -745,9 +690,13 @@ namespace HexEditor @@ -745,9 +690,13 @@ namespace HexEditor
if (end > GetOffsetForLine(topline + GetMaxVisibleLines())) end = GetOffsetForLine(topline + GetMaxVisibleLines() + 1);
int tmp_start = start;
if (((selection.End % this.bytesPerLine) == 0) && (selection.End < selection.Start))
tmp_start++;
if (this.activeView == this.hexView)
{
if (GetLineForOffset(end) == GetLineForOffset(start)) {
if (GetLineForOffset(end) == GetLineForOffset(tmp_start)) {
Point pt = GetPositionForOffset(start, 3);
al.Add(new Rectangle(new Point(pt.X - 4, pt.Y), new Size((end - start) * underscorewidth3 + 2, fontheight)));
} else {
@ -770,7 +719,7 @@ namespace HexEditor @@ -770,7 +719,7 @@ namespace HexEditor
start = start_dummy;
if (GetLineForOffset(end) == GetLineForOffset(start)) {
if (GetLineForOffset(end) == GetLineForOffset(tmp_start)) {
Point pt = GetPositionForOffset(start, 1);
al.Add(new Point(pt.X - 1, pt.Y));
al.Add(new Point(pt.X - 1, pt.Y + fontheight));
@ -824,7 +773,7 @@ namespace HexEditor @@ -824,7 +773,7 @@ namespace HexEditor
selpoints = (Point[])al.ToArray(typeof(Point));
} else {
if (GetLineForOffset(end) == GetLineForOffset(start)) {
if (GetLineForOffset(end) == GetLineForOffset(tmp_start)) {
Point pt = GetPositionForOffset(start, 1);
al.Add(new Rectangle(new Point(pt.X - 4, pt.Y), new Size((end - start) * underscorewidth + 3, fontheight)));
} else {
@ -846,8 +795,8 @@ namespace HexEditor @@ -846,8 +795,8 @@ namespace HexEditor
al.Clear();
start = start_dummy;
if (GetLineForOffset(end) == GetLineForOffset(start)) {
if (GetLineForOffset(end) == GetLineForOffset(tmp_start)) {
Point pt = GetPositionForOffset(start, 3);
al.Add(new Point(pt.X - 1, pt.Y));
al.Add(new Point(pt.X - 1, pt.Y + fontheight));
@ -937,14 +886,14 @@ namespace HexEditor @@ -937,14 +886,14 @@ namespace HexEditor
}
if (selregion.Length == 3) {
TextRenderer.DrawText(hexView, GetHex(buffer.GetBytes(start, this.BytesPerLine)), this.Font, (Rectangle)selregion[0], Color.White, SystemColors.Highlight, TextFormatFlags.Left & TextFormatFlags.SingleLine);
TextRenderer.DrawText(hexView, builder.ToString(), this.Font, (Rectangle)selregion[1], Color.White, SystemColors.Highlight, TextFormatFlags.Left);
TextRenderer.DrawText(hexView, GetLineHex(GetLineForOffset(end)), this.Font, (Rectangle)selregion[2], Color.White, SystemColors.Highlight, TextFormatFlags.Left & TextFormatFlags.SingleLine);
TextRenderer.DrawText(hexView, GetHex(buffer.GetBytes(start, this.BytesPerLine)), this.settings.DataFont, (Rectangle)selregion[0], Color.White, SystemColors.Highlight, TextFormatFlags.Left & TextFormatFlags.SingleLine);
TextRenderer.DrawText(hexView, builder.ToString(), this.settings.DataFont, (Rectangle)selregion[1], Color.White, SystemColors.Highlight, TextFormatFlags.Left);
TextRenderer.DrawText(hexView, GetLineHex(GetLineForOffset(end)), this.settings.DataFont, (Rectangle)selregion[2], Color.White, SystemColors.Highlight, TextFormatFlags.Left & TextFormatFlags.SingleLine);
} else if (selregion.Length == 2) {
TextRenderer.DrawText(hexView, GetHex(buffer.GetBytes(start, this.BytesPerLine)), this.Font, (Rectangle)selregion[0], Color.White, SystemColors.Highlight, TextFormatFlags.Left & TextFormatFlags.SingleLine);
TextRenderer.DrawText(hexView, GetLineHex(GetLineForOffset(end)), this.Font, (Rectangle)selregion[1], Color.White, SystemColors.Highlight, TextFormatFlags.Left & TextFormatFlags.SingleLine);
TextRenderer.DrawText(hexView, GetHex(buffer.GetBytes(start, this.BytesPerLine)), this.settings.DataFont, (Rectangle)selregion[0], Color.White, SystemColors.Highlight, TextFormatFlags.Left & TextFormatFlags.SingleLine);
TextRenderer.DrawText(hexView, GetLineHex(GetLineForOffset(end)), this.settings.DataFont, (Rectangle)selregion[1], Color.White, SystemColors.Highlight, TextFormatFlags.Left & TextFormatFlags.SingleLine);
} else {
TextRenderer.DrawText(hexView, GetHex(buffer.GetBytes(start, this.BytesPerLine)), this.Font, (Rectangle)selregion[0], Color.White, SystemColors.Highlight, TextFormatFlags.Left & TextFormatFlags.SingleLine);
TextRenderer.DrawText(hexView, GetHex(buffer.GetBytes(start, this.BytesPerLine)), this.settings.DataFont, (Rectangle)selregion[0], Color.White, SystemColors.Highlight, TextFormatFlags.Left & TextFormatFlags.SingleLine);
}
if (!paintMarker) return;
@ -964,14 +913,14 @@ namespace HexEditor @@ -964,14 +913,14 @@ namespace HexEditor
}
if (selregion.Length == 3) {
TextRenderer.DrawText(textView, GetText(buffer.GetBytes(start, this.BytesPerLine)), this.Font, (Rectangle)selregion[0], Color.White, SystemColors.Highlight, TextFormatFlags.Left & TextFormatFlags.SingleLine);
TextRenderer.DrawText(textView, builder.ToString(), this.Font, (Rectangle)selregion[1], Color.White, SystemColors.Highlight, TextFormatFlags.Left);
TextRenderer.DrawText(textView, GetLineText(GetLineForOffset(end)), this.Font, (Rectangle)selregion[2], Color.White, SystemColors.Highlight, TextFormatFlags.Left & TextFormatFlags.SingleLine);
TextRenderer.DrawText(textView, GetText(buffer.GetBytes(start, this.BytesPerLine)), this.settings.DataFont, (Rectangle)selregion[0], Color.White, SystemColors.Highlight, TextFormatFlags.Left & TextFormatFlags.SingleLine);
TextRenderer.DrawText(textView, builder.ToString(), this.settings.DataFont, (Rectangle)selregion[1], Color.White, SystemColors.Highlight, TextFormatFlags.Left);
TextRenderer.DrawText(textView, GetLineText(GetLineForOffset(end)), this.settings.DataFont, (Rectangle)selregion[2], Color.White, SystemColors.Highlight, TextFormatFlags.Left & TextFormatFlags.SingleLine);
} else if (selregion.Length == 2) {
TextRenderer.DrawText(textView, GetText(buffer.GetBytes(start, this.BytesPerLine)), this.Font, (Rectangle)selregion[0], Color.White, SystemColors.Highlight, TextFormatFlags.Left & TextFormatFlags.SingleLine);
TextRenderer.DrawText(textView, GetLineText(GetLineForOffset(end)), this.Font, (Rectangle)selregion[1], Color.White, SystemColors.Highlight, TextFormatFlags.Left & TextFormatFlags.SingleLine);
TextRenderer.DrawText(textView, GetText(buffer.GetBytes(start, this.BytesPerLine)), this.settings.DataFont, (Rectangle)selregion[0], Color.White, SystemColors.Highlight, TextFormatFlags.Left & TextFormatFlags.SingleLine);
TextRenderer.DrawText(textView, GetLineText(GetLineForOffset(end)), this.settings.DataFont, (Rectangle)selregion[1], Color.White, SystemColors.Highlight, TextFormatFlags.Left & TextFormatFlags.SingleLine);
} else {
TextRenderer.DrawText(textView, GetText(buffer.GetBytes(start, this.BytesPerLine)), this.Font, (Rectangle)selregion[0], Color.White, SystemColors.Highlight, TextFormatFlags.Left & TextFormatFlags.SingleLine);
TextRenderer.DrawText(textView, GetText(buffer.GetBytes(start, this.BytesPerLine)), this.settings.DataFont, (Rectangle)selregion[0], Color.White, SystemColors.Highlight, TextFormatFlags.Left & TextFormatFlags.SingleLine);
}
if (!paintMarker) return;
@ -1064,7 +1013,12 @@ namespace HexEditor @@ -1064,7 +1013,12 @@ namespace HexEditor
* */
public string Copy()
{
return selection.SelectionText;
string text = selection.SelectionText;
if (text.Contains("\0"))
text = text.Replace("\0", "");
return text;
}
public void Paste(string text)
@ -1193,9 +1147,8 @@ namespace HexEditor @@ -1193,9 +1147,8 @@ namespace HexEditor
if (this.FitToWindowWidth) this.BytesPerLine = CalculateMaxBytesPerLine();
this.Invalidate();
SetViews();
UpdateViews();
UpdatePainters();
}
void UpdatePainters()
@ -1220,10 +1173,12 @@ namespace HexEditor @@ -1220,10 +1173,12 @@ namespace HexEditor
/// <summary>
/// Resets the current viewpanels to fit the new sizes and settings.
/// </summary>
void SetViews()
void UpdateViews()
{
this.UpdatePainters();
int sidetext = this.GetMaxLines() * this.BytesPerLine;
int textwidth = MeasureStringWidth(this.textView.CreateGraphics(), new string('_', this.BytesPerLine + 1), this.Font);
int textwidth = MeasureStringWidth(this.textView.CreateGraphics(), new string('_', this.BytesPerLine + 1), this.settings.DataFont);
int hexwidth = underscorewidth3 * this.BytesPerLine;
int top = hexView.Top;
this.hexView.Top = fontheight - 1;
@ -1265,7 +1220,7 @@ namespace HexEditor @@ -1265,7 +1220,7 @@ namespace HexEditor
break;
}
this.side.Width = MeasureStringWidth(this.side.CreateGraphics(), st, this.Font);
this.side.Width = MeasureStringWidth(this.side.CreateGraphics(), st, this.settings.OffsetFont);
this.side.Left = 0;
this.hexView.Left = this.side.Width + 10;
@ -1303,45 +1258,48 @@ namespace HexEditor @@ -1303,45 +1258,48 @@ namespace HexEditor
hexinputmodepos = 0;
}
// if (e.Control)
// {
// switch (e.KeyCode)
// {
// case Keys.Up:
// if (this.topline > 0)
// this.topline--;
// break;
// case Keys.Down:
// if (this.topline < this.GetMaxLines())
// this.topline++;
// break;
// }
//
// this.VScrollBar.Value = this.topline;
//
// this.handled = true;
// }
if (e.Control)
{
switch (e.KeyCode)
{
case Keys.Up:
if (this.topline > 0)
this.topline--;
break;
case Keys.Down:
if (this.topline < this.GetMaxLines())
this.topline++;
break;
}
this.VScrollBar.Value = this.topline;
this.handled = true;
}
switch (e.KeyCode) {
case Keys.Up:
case Keys.Down:
case Keys.Left:
case Keys.Right:
int oldoffset = caret.Offset;
// if (!e.Control)
MoveCaret(e);
if (GetLineForOffset(caret.Offset) < this.topline) this.topline = GetLineForOffset(caret.Offset);
if (GetLineForOffset(caret.Offset) > this.topline + this.GetMaxVisibleLines() - 2) this.topline = GetLineForOffset(caret.Offset) - this.GetMaxVisibleLines() + 2;
VScrollBar.Value = this.topline;
if (e.Shift) {
if (selection.HasSomethingSelected) {
this.SetSelection(selection.Start, caret.Offset);
if (!e.Control) {
int oldoffset = caret.Offset;
MoveCaret(e);
if (GetLineForOffset(caret.Offset) < this.topline) this.topline = GetLineForOffset(caret.Offset);
if (GetLineForOffset(caret.Offset) > this.topline + this.GetMaxVisibleLines() - 2) this.topline = GetLineForOffset(caret.Offset) - this.GetMaxVisibleLines() + 2;
VScrollBar.Value = this.topline;
if (e.Shift) {
if (selection.HasSomethingSelected) {
this.SetSelection(selection.Start, caret.Offset);
} else {
this.SetSelection(oldoffset, caret.Offset);
}
} else {
this.SetSelection(oldoffset, caret.Offset);
this.selection.Clear();
}
handled = true;
}
handled = true;
break;
case Keys.Insert:
insertmode = !insertmode;
@ -1353,7 +1311,7 @@ namespace HexEditor @@ -1353,7 +1311,7 @@ namespace HexEditor
} else {
this.caret.Width = 1;
}
caret.SetToPosition(GetPositionForOffset(caret.Offset, this.charwidth));
handled = true;
break;
@ -1434,31 +1392,12 @@ namespace HexEditor @@ -1434,31 +1392,12 @@ namespace HexEditor
break;
// Ctrl-C is pressed -> copy text to ClipboardManager
case 67 :
ClipboardManager.Copy(selection.SelectionText);
ClipboardManager.Copy(this.Copy());
break;
// Ctrl-V is pressed -> paste from ClipboardManager
case 86 :
if (ClipboardManager.ContainsText) {
if (caret.Offset > buffer.BufferSize) caret.Offset = buffer.BufferSize;
if (selection.HasSomethingSelected) {
byte[] old = selection.GetSelectionBytes();
buffer.RemoveBytes(selection.Start, Math.Abs(selection.End - selection.Start));
buffer.SetBytes(selection.Start, this.Encoding.GetBytes(ClipboardManager.Paste().ToCharArray()), false);
UndoAction action = UndoAction.Overwrite;
undoStack.AddUndoStep(new UndoStep(this.Encoding.GetBytes(ClipboardManager.Paste().ToCharArray()), old, caret.Offset, action));
caret.Offset = selection.Start + ClipboardManager.Paste().Length;
selection.Clear();
} else {
buffer.SetBytes(caret.Offset, this.Encoding.GetBytes(ClipboardManager.Paste().ToCharArray()), false);
UndoAction action = UndoAction.Remove;
undoStack.AddUndoStep(new UndoStep(this.Encoding.GetBytes(ClipboardManager.Paste().ToCharArray()), null, caret.Offset, action));
caret.Offset += ClipboardManager.Paste().Length;
}
this.Paste(ClipboardManager.Paste());
if (GetLineForOffset(caret.Offset) < this.topline) this.topline = GetLineForOffset(caret.Offset);
if (GetLineForOffset(caret.Offset) > this.topline + this.GetMaxVisibleLines() - 2) this.topline = GetLineForOffset(caret.Offset) - this.GetMaxVisibleLines() + 2;
if (this.topline < 0) this.topline = 0;
@ -1467,31 +1406,13 @@ namespace HexEditor @@ -1467,31 +1406,13 @@ namespace HexEditor
if (this.topline > VScrollBar.Maximum) this.topline = VScrollBar.Maximum;
}
VScrollBar.Value = this.topline;
e2 = new EventArgs();
OnDocumentChanged(e2);
}
break;
// Ctrl-X is pressed -> cut from document
case 88 :
if (selection.HasSomethingSelected) {
ClipboardManager.Copy(selection.SelectionText);
if (selection.End < selection.Start)
{
int help = selection.End;
selection.End = selection.Start;
selection.Start = help;
}
UndoAction action = UndoAction.Add;
undoStack.AddUndoStep(new UndoStep(selection.GetSelectionBytes(), null, caret.Offset, action));
buffer.RemoveBytes(selection.Start, selection.SelectionText.Length);
selection.Clear();
e2 = new EventArgs();
OnDocumentChanged(e2);
ClipboardManager.Copy(this.Copy());
this.Delete();
}
break;
}

38
src/AddIns/DisplayBindings/HexEditor/Project/Src/Util/NativeMethods.cs

@ -1,38 +0,0 @@ @@ -1,38 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Siegfried Pammer" email="sie_pam@gmx.at"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Runtime.InteropServices;
namespace HexEditor.Util
{
/// <summary>
/// Description of NativeMethods.
/// </summary>
public static class NativeMethods
{
[DllImport("User32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool CreateCaret(IntPtr hWnd, int hBitmap, int nWidth, int nHeight);
[DllImport("User32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool SetCaretPos(int x, int y);
[DllImport("User32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool DestroyCaret();
[DllImport("User32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool ShowCaret(IntPtr hWnd);
[DllImport("User32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool HideCaret(IntPtr hWnd);
}
}

165
src/AddIns/DisplayBindings/HexEditor/Project/Src/Util/Settings.cs

@ -0,0 +1,165 @@ @@ -0,0 +1,165 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Siegfried Pammer" email="sie_pam@gmx.at"/>
// <version>$Revision: 2984 $</version>
// </file>
using System;
using System.Xml;
using System.Drawing;
namespace HexEditor.Util
{
/// <summary>
/// Description of Settings.
/// </summary>
public class Settings
{
Color offsetForeColor, dataForeColor;
bool offsetBold, offsetItalic, offsetUnderline, dataBold, dataItalic, dataUnderline;
Font offsetFont, dataFont;
bool fitToWidth;
int bytesPerLine;
ViewMode viewMode;
string[] fileTypes;
public Settings()
{
}
public static Settings FromXML(XmlDocument document)
{
Settings settings = new Settings();
Font tmpFont = new Font("Courier New", 9.75f);
foreach (XmlNode node in document.FirstChild.ChildNodes)
{
switch (node.Attributes["Name"].Value)
{
case "OffsetFore":
settings.offsetForeColor = CreateColor(node);
break;
case "DataFore":
settings.dataForeColor = CreateColor(node);
break;
case "OffsetStyle":
settings.offsetBold = bool.Parse(node.Attributes["Bold"].Value);
settings.offsetItalic = bool.Parse(node.Attributes["Italic"].Value);
settings.offsetUnderline = bool.Parse(node.Attributes["Underline"].Value);
break;
case "DataStyle":
settings.dataBold = bool.Parse(node.Attributes["Bold"].Value);
settings.dataItalic = bool.Parse(node.Attributes["Italic"].Value);
settings.dataUnderline = bool.Parse(node.Attributes["Underline"].Value);
break;
case "Font":
tmpFont = new Font(node.Attributes["FontName"].Value,
float.Parse(node.Attributes["FontSize"].Value));
break;
case "TextDisplay":
settings.bytesPerLine = int.Parse(node.Attributes["BytesPerLine"].Value);
settings.viewMode = (ViewMode)ViewMode.Parse(typeof(ViewMode),node.Attributes["ViewMode"].Value);
settings.fitToWidth = bool.Parse(node.Attributes["FitToWidth"].Value);
break;
case "FileTypes":
settings.fileTypes = node.Attributes["FileTypes"].Value.Split(new char[] {';'});
break;
}
FontStyle offsetStyle = FontStyle.Regular;
if (settings.offsetBold) offsetStyle |= FontStyle.Bold;
if (settings.offsetItalic) offsetStyle |= FontStyle.Italic;
if (settings.offsetUnderline) offsetStyle |= FontStyle.Underline;
settings.offsetFont = new Font(tmpFont, offsetStyle);
FontStyle dataStyle = FontStyle.Regular;
if (settings.dataBold) dataStyle |= FontStyle.Bold;
if (settings.dataItalic) dataStyle |= FontStyle.Italic;
if (settings.dataUnderline) dataStyle |= FontStyle.Underline;
settings.dataFont = new Font(tmpFont, dataStyle);
}
return settings;
}
private static Color CreateColor(XmlNode node)
{
return Color.FromArgb(int.Parse(node.Attributes["R"].Value),
int.Parse(node.Attributes["G"].Value),
int.Parse(node.Attributes["B"].Value));
}
public Color OffsetForeColor {
get { return offsetForeColor; }
set { offsetForeColor = value; }
}
public Color DataForeColor {
get { return dataForeColor; }
set { dataForeColor = value; }
}
public bool OffsetBold {
get { return offsetBold; }
set { offsetBold = value; }
}
public bool OffsetItalic {
get { return offsetItalic; }
set { offsetItalic = value; }
}
public bool OffsetUnderline {
get { return offsetUnderline; }
set { offsetUnderline = value; }
}
public bool DataBold {
get { return dataBold; }
set { dataBold = value; }
}
public bool DataItalic {
get { return dataItalic; }
set { dataItalic = value; }
}
public bool DataUnderline {
get { return dataUnderline; }
set { dataUnderline = value; }
}
public Font OffsetFont {
get { return offsetFont; }
set { offsetFont = value; }
}
public Font DataFont {
get { return dataFont; }
set { dataFont = value; }
}
public bool FitToWidth {
get { return fitToWidth; }
set { fitToWidth = value; }
}
public int BytesPerLine {
get { return bytesPerLine; }
set { bytesPerLine = value; }
}
public ViewMode ViewMode {
get { return viewMode; }
set { viewMode = value; }
}
public string[] FileTypes {
get { return fileTypes; }
set { fileTypes = value; }
}
}
}

15
src/AddIns/DisplayBindings/HexEditor/Project/Src/View/HexEditContainer.Designer.cs generated

@ -40,9 +40,9 @@ namespace HexEditor.View @@ -40,9 +40,9 @@ namespace HexEditor.View
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(HexEditContainer));
this.tbSizeToFit = new System.Windows.Forms.ToolStripButton();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.tCBViewMode = new System.Windows.Forms.ToolStripComboBox();
this.tCBViewMode = new System.Windows.Forms.DomainUpDown();
this.toolStrip1 = new System.Windows.Forms.ToolStrip();
this.tSTBCharsPerLine = new System.Windows.Forms.ToolStripTextBox();
this.tSTBCharsPerLine = new System.Windows.Forms.NumericUpDown();
this.toolStripProgressBar1 = new System.Windows.Forms.ToolStripProgressBar();
this.hexEditControl = new HexEditor.Editor();
this.toolStrip1.SuspendLayout();
@ -57,7 +57,7 @@ namespace HexEditor.View @@ -57,7 +57,7 @@ namespace HexEditor.View
this.tbSizeToFit.ImageTransparentColor = System.Drawing.Color.Magenta;
this.tbSizeToFit.Name = "tbSizeToFit";
this.tbSizeToFit.Size = new System.Drawing.Size(23, 22);
this.tbSizeToFit.Text = "Size to fit";
this.tbSizeToFit.Text = "Resize to fit current width";
this.tbSizeToFit.Click += new System.EventHandler(this.TbSizeToFitClick);
//
// toolStripSeparator1
@ -67,22 +67,19 @@ namespace HexEditor.View @@ -67,22 +67,19 @@ namespace HexEditor.View
//
// tCBViewMode
//
this.tCBViewMode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.tCBViewMode.Items.AddRange(new object[] {
"Hexadecimal",
"Octal",
"Decimal"});
this.tCBViewMode.Name = "tCBViewMode";
this.tCBViewMode.Size = new System.Drawing.Size(121, 25);
this.tCBViewMode.SelectedIndexChanged += new System.EventHandler(this.TCBViewModeSelectedIndexChanged);
this.tCBViewMode.SelectedItemChanged += new System.EventHandler(this.TCBViewModeSelectedIndexChanged);
//
// toolStrip1
//
this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.tbSizeToFit,
this.tSTBCharsPerLine,
this.toolStripSeparator1,
this.tCBViewMode,
this.toolStripProgressBar1});
this.toolStrip1.Location = new System.Drawing.Point(0, 0);
this.toolStrip1.Name = "toolStrip1";
@ -136,10 +133,10 @@ namespace HexEditor.View @@ -136,10 +133,10 @@ namespace HexEditor.View
}
private System.Windows.Forms.ToolStripProgressBar toolStripProgressBar1;
internal HexEditor.Editor hexEditControl;
private System.Windows.Forms.ToolStripComboBox tCBViewMode;
private System.Windows.Forms.DomainUpDown tCBViewMode;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.ToolStripButton tbSizeToFit;
private System.Windows.Forms.ToolStrip toolStrip1;
private System.Windows.Forms.ToolStripTextBox tSTBCharsPerLine;
private System.Windows.Forms.NumericUpDown tSTBCharsPerLine;
}
}

22
src/AddIns/DisplayBindings/HexEditor/Project/Src/View/HexEditContainer.cs

@ -38,9 +38,31 @@ namespace HexEditor.View @@ -38,9 +38,31 @@ namespace HexEditor.View
{
InitializeComponent();
ToolStripControlHost bytesPerLine = new ToolStripControlHost(tSTBCharsPerLine);
this.toolStrip1.Items.Insert(1, bytesPerLine);
ToolStripControlHost viewMode = new ToolStripControlHost(tCBViewMode);
this.toolStrip1.Items.Insert(3, viewMode);
tSTBCharsPerLine.Text = hexEditControl.BytesPerLine.ToString();
this.hexEditControl.ContextMenuStrip = MenuService.CreateContextMenu(this.hexEditControl, "/AddIns/HexEditor/Editor/ContextMenu");
tCBViewMode.SelectedIndex = 0;
string configpath = Path.GetDirectoryName(typeof(Editor).Assembly.Location) + Path.DirectorySeparatorChar + "config.xml";
if (System.IO.File.Exists(configpath)) {
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.Load(configpath);
Settings settings = Settings.FromXML(doc);
tSTBCharsPerLine.Value = settings.BytesPerLine;
tCBViewMode.SelectedItem = settings.ViewMode.ToString();
hexEditControl.ViewMode = settings.ViewMode;
hexEditControl.BytesPerLine = settings.BytesPerLine;
tbSizeToFit.Checked = hexEditControl.FitToWindowWidth = settings.FitToWidth;
tSTBCharsPerLine.Enabled = !settings.FitToWidth;
}
}
void TbSizeToFitClick(object sender, EventArgs e)

22
src/AddIns/DisplayBindings/HexEditor/Project/Src/View/HexEditDisplayBinding.cs

@ -14,11 +14,13 @@ using ICSharpCode.SharpDevelop.Gui; @@ -14,11 +14,13 @@ using ICSharpCode.SharpDevelop.Gui;
using System.Diagnostics;
using HexEditor.Util;
namespace HexEditor.View
{
public class HexEditDisplayBinding : IDisplayBinding
{
string[] supportedBinaryFileNameExtensions;
static string[] supportedExtensions;
public HexEditDisplayBinding()
{
@ -39,13 +41,19 @@ namespace HexEditor.View @@ -39,13 +41,19 @@ namespace HexEditor.View
string[] GetSupportedBinaryFileExtensions()
{
if (supportedBinaryFileNameExtensions == null) {
string extensionList = (string)AddInTree.BuildItem("/AddIns/HexEditor/Editor/SupportedFileExtensions", null);
if (extensionList != null) {
supportedBinaryFileNameExtensions = extensionList.Split(';');
}
if (supportedExtensions == null) {
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
string configpath = Path.GetDirectoryName(typeof(Editor).Assembly.Location) + Path.DirectorySeparatorChar + "config.xml";
if (!File.Exists(configpath))
return new string[] {".exe;.dll"};
doc.Load(configpath);
supportedExtensions = Settings.FromXML(doc).FileTypes;
}
return supportedBinaryFileNameExtensions;
return supportedExtensions;
}
bool IsBinary(string fileName)

191
src/AddIns/DisplayBindings/HexEditor/Project/Src/View/HexEditOptionsPanel.cs

@ -22,31 +22,34 @@ namespace HexEditor.View @@ -22,31 +22,34 @@ namespace HexEditor.View
public class HexEditOptionsPanel : AbstractOptionPanel
{
ComboBox cmbForeColor;
ComboBox cmbBackColor;
ListBox lstElements;
CheckBox cbBold;
CheckBox cbItalic;
CheckBox cbUnderline;
CheckBox cbFitToWidth;
Label lblOffsetPreview;
Label lblDataPreview;
Button btnSelectFont;
FontDialog fdSelectFont;
TextBox txtExtensions;
NumericUpDown nUDBytesPerLine;
DomainUpDown dUDViewModes;
List<Color> Colors;
Color customFore = Color.Transparent;
Color customBack = Color.Transparent;
bool fcmanualchange = false;
bool bcmanualchange = false;
// New values
Color OffsetForeColor, OffsetBackColor;
Color DataForeColor, DataBackColor;
Color OffsetForeColor;
Color DataForeColor;
bool OffsetBold, OffsetItalic, OffsetUnderline;
bool DataBold, DataItalic, DataUnderline;
float FontSize = 10.0f;
float FontSize = 9.75f;
string FontName;
@ -73,15 +76,9 @@ namespace HexEditor.View @@ -73,15 +76,9 @@ namespace HexEditor.View
case "OffsetFore" :
OffsetForeColor = Color.FromArgb(int.Parse(el.GetAttribute("R")), int.Parse(el.GetAttribute("G")), int.Parse(el.GetAttribute("B")));
break;
case "OffsetBack" :
OffsetBackColor = Color.FromArgb(int.Parse(el.GetAttribute("R")), int.Parse(el.GetAttribute("G")), int.Parse(el.GetAttribute("B")));
break;
case "DataFore" :
DataForeColor = Color.FromArgb(int.Parse(el.GetAttribute("R")), int.Parse(el.GetAttribute("G")), int.Parse(el.GetAttribute("B")));
break;
case "DataBack" :
DataBackColor = Color.FromArgb(int.Parse(el.GetAttribute("R")), int.Parse(el.GetAttribute("G")), int.Parse(el.GetAttribute("B")));
break;
case "OffsetStyle" :
OffsetBold = bool.Parse(el.GetAttribute("Bold"));
OffsetItalic = bool.Parse(el.GetAttribute("Italic"));
@ -96,6 +93,14 @@ namespace HexEditor.View @@ -96,6 +93,14 @@ namespace HexEditor.View
FontName = el.GetAttribute("FontName");
FontSize = float.Parse(el.GetAttribute("FontSize"));
break;
case "TextDisplay":
this.cbFitToWidth.Checked = bool.Parse(el.GetAttribute("FitToWidth"));
this.nUDBytesPerLine.Value = int.Parse(el.GetAttribute("BytesPerLine"));
this.dUDViewModes.SelectedItem = ((HexEditor.Util.ViewMode)HexEditor.Util.ViewMode.Parse(typeof(HexEditor.Util.ViewMode),el.GetAttribute("ViewMode"))).ToString();
break;
case "FileTypes":
txtExtensions.Text = el.GetAttribute("FileTypes");
break;
}
}
@ -118,39 +123,23 @@ namespace HexEditor.View @@ -118,39 +123,23 @@ namespace HexEditor.View
customFore = OffsetForeColor;
}
if (IsNamedColor(OffsetBackColor)) {
OffsetBackColor = Color.FromName(GetColorName(OffsetBackColor));
} else {
customBack = OffsetBackColor;
}
if (IsNamedColor(DataForeColor)) {
DataForeColor = Color.FromName(GetColorName(DataForeColor));
} else {
customFore = DataForeColor;
}
if (IsNamedColor(DataBackColor)) {
DataBackColor = Color.FromName(GetColorName(DataBackColor));
} else {
customBack = DataBackColor;
}
if (!OffsetForeColor.IsNamedColor) {
cmbForeColor.SelectedIndex = 0;
} else {
cmbForeColor.SelectedIndex = cmbForeColor.Items.IndexOf(OffsetForeColor.Name);
}
if (OffsetBackColor.IsNamedColor) {
cmbBackColor.SelectedIndex = 0;
} else {
cmbBackColor.SelectedIndex = cmbBackColor.Items.IndexOf(OffsetBackColor.Name);
}
this.cbBold.Checked = OffsetBold;
this.cbItalic.Checked = OffsetItalic;
this.cbUnderline.Checked = OffsetUnderline;
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1305:SpecifyIFormatProvider", MessageId = "System.Byte.ToString")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1305:SpecifyIFormatProvider", MessageId = "System.Single.ToString")]
public override bool StorePanelContents()
{
string configpath = Path.GetDirectoryName(typeof(Editor).Assembly.Location) + Path.DirectorySeparatorChar + "config.xml";
@ -164,27 +153,13 @@ namespace HexEditor.View @@ -164,27 +153,13 @@ namespace HexEditor.View
el.SetAttribute("B", OffsetForeColor.B.ToString());
file.FirstChild.AppendChild(el);
el = file.CreateElement("Setting");
el.SetAttribute("Name", "OffsetBack");
el.SetAttribute("R", OffsetBackColor.R.ToString());
el.SetAttribute("G", OffsetBackColor.G.ToString());
el.SetAttribute("B", OffsetBackColor.B.ToString());
file.FirstChild.AppendChild(el);
el = file.CreateElement("Setting");
el.SetAttribute("Name", "DataFore");
el.SetAttribute("R", DataForeColor.R.ToString());
el.SetAttribute("G", DataForeColor.G.ToString());
el.SetAttribute("B", DataForeColor.B.ToString());
file.FirstChild.AppendChild(el);
el = file.CreateElement("Setting");
el.SetAttribute("Name", "DataBack");
el.SetAttribute("R", DataBackColor.R.ToString());
el.SetAttribute("G", DataBackColor.G.ToString());
el.SetAttribute("B", DataBackColor.B.ToString());
file.FirstChild.AppendChild(el);
el = file.CreateElement("Setting");
el.SetAttribute("Name", "OffsetStyle");
el.SetAttribute("Bold", OffsetBold.ToString());
@ -205,6 +180,18 @@ namespace HexEditor.View @@ -205,6 +180,18 @@ namespace HexEditor.View
el.SetAttribute("FontSize", FontSize.ToString());
file.FirstChild.AppendChild(el);
el = file.CreateElement("Setting");
el.SetAttribute("Name", "TextDisplay");
el.SetAttribute("FitToWidth", this.cbFitToWidth.Checked.ToString());
el.SetAttribute("BytesPerLine", this.nUDBytesPerLine.Value.ToString());
el.SetAttribute("ViewMode", this.dUDViewModes.SelectedItem.ToString());
file.FirstChild.AppendChild(el);
el = file.CreateElement("Setting");
el.SetAttribute("Name", "FileTypes");
el.SetAttribute("FileTypes", txtExtensions.Text);
file.FirstChild.AppendChild(el);
file.Save(configpath);
return true;
}
@ -212,7 +199,6 @@ namespace HexEditor.View @@ -212,7 +199,6 @@ namespace HexEditor.View
void InitializeComponents()
{
cmbForeColor = (ComboBox)ControlDictionary["cmbForeColor"];
cmbBackColor = (ComboBox)ControlDictionary["cmbBackColor"];
lstElements = (ListBox)ControlDictionary["lstElements"];
cbBold = (CheckBox)ControlDictionary["cbBold"];
cbItalic = (CheckBox)ControlDictionary["cbItalic"];
@ -220,6 +206,13 @@ namespace HexEditor.View @@ -220,6 +206,13 @@ namespace HexEditor.View
lblOffsetPreview = (Label)ControlDictionary["lblOffsetPreview"];
lblDataPreview = (Label)ControlDictionary["lblDataPreview"];
btnSelectFont = (Button)ControlDictionary["btnSelectFont"];
nUDBytesPerLine = (NumericUpDown)ControlDictionary["nUDBytesPerLine"];
dUDViewModes = (DomainUpDown)ControlDictionary["dUDViewModes"];
cbFitToWidth = (CheckBox)ControlDictionary["cbFitToWidth"];
txtExtensions = (TextBox)ControlDictionary["txtExtensions"];
fdSelectFont = new FontDialog();
// Initialize FontDialog
@ -229,11 +222,9 @@ namespace HexEditor.View @@ -229,11 +222,9 @@ namespace HexEditor.View
fdSelectFont.ShowColor = false;
cmbForeColor.Items.Add("Custom");
cmbBackColor.Items.Add("Custom");
foreach (Color c in Colors) {
cmbForeColor.Items.Add(c.Name);
cmbBackColor.Items.Add(c.Name);
}
lstElements.Items.Add("Offset");
@ -241,16 +232,16 @@ namespace HexEditor.View @@ -241,16 +232,16 @@ namespace HexEditor.View
lstElements.SetSelected(0, true);
foreach (string s in HexEditor.Util.ViewMode.GetNames(typeof(HexEditor.Util.ViewMode)))
{
dUDViewModes.Items.Add(s);
}
btnSelectFont.Click += new EventHandler(this.btnSelectFontClick);
cmbForeColor.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.cmbForeColorDrawItem);
cmbForeColor.SelectedValueChanged += new EventHandler(this.cmbForeColorSelectedValueChanged);
cmbForeColor.DropDown += cmbForeColorDropDown;
cmbBackColor.DropDown += cmbBackColorDropDown;
cmbBackColor.DrawItem += new DrawItemEventHandler(this.cmbBackColorDrawItem);
cmbBackColor.SelectedValueChanged += new EventHandler(this.cmbBackColorSelectedValueChanged);
cbBold.CheckedChanged += new EventHandler(this.cbBoldCheckedChanged);
cbItalic.CheckedChanged += new EventHandler(this.cbItalicCheckedChanged);
@ -316,58 +307,14 @@ namespace HexEditor.View @@ -316,58 +307,14 @@ namespace HexEditor.View
}
lblOffsetPreview.ForeColor = OffsetForeColor;
lblOffsetPreview.BackColor = OffsetBackColor;
lblDataPreview.ForeColor = DataForeColor;
lblDataPreview.BackColor = DataBackColor;
} else {
MessageService.ShowError("Please select an element first!");
}
fcmanualchange = false;
}
void cmbBackColorSelectedValueChanged(object sender, EventArgs e)
{
if (lstElements.SelectedIndex != -1) {
if (cmbBackColor.SelectedIndex == 0) {
if (bcmanualchange) {
ColorDialog cdColor = new ColorDialog();
if (cdColor.ShowDialog() == DialogResult.OK) {
customBack = cdColor.Color;
switch (lstElements.SelectedIndex)
{
case 0 :
OffsetBackColor = customBack;
break;
case 1 :
DataBackColor = customBack;
break;
}
}
}
} else {
if (cmbBackColor.SelectedIndex == -1) cmbBackColor.SelectedIndex = 0;
switch (lstElements.SelectedIndex) {
case 0 :
OffsetBackColor = Color.FromName(cmbBackColor.Items[cmbBackColor.SelectedIndex].ToString());
break;
case 1 :
DataBackColor = Color.FromName(cmbBackColor.Items[cmbBackColor.SelectedIndex].ToString());
break;
}
}
lblOffsetPreview.ForeColor = OffsetForeColor;
lblOffsetPreview.BackColor = OffsetBackColor;
lblDataPreview.ForeColor = DataForeColor;
lblDataPreview.BackColor = DataBackColor;
} else {
MessageService.ShowError("Please select an element first!");
}
bcmanualchange = false;
}
void cmbForeColorDrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
{
Rectangle rc = new Rectangle(e.Bounds.X, e.Bounds.Y,
@ -403,41 +350,6 @@ namespace HexEditor.View @@ -403,41 +350,6 @@ namespace HexEditor.View
}
}
void cmbBackColorDrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
{
Rectangle rc = new Rectangle(e.Bounds.X, e.Bounds.Y,
e.Bounds.Width, e.Bounds.Height);
Rectangle rc2 = new Rectangle(e.Bounds.X + 20, e.Bounds.Y,
e.Bounds.Width, e.Bounds.Height);
Rectangle rc3 = new Rectangle(e.Bounds.X + 5, e.Bounds.Y + 2, 10, 10);
string str;
Color color;
if (e.Index != -1) {
str = (string)cmbBackColor.Items[e.Index];
} else {
str = (string)cmbBackColor.Items[0];
}
if (str == "Custom") {
color = customBack;
} else {
color = Color.FromName(str);
}
if ( e.State == (DrawItemState.Selected | DrawItemState.Focus | DrawItemState.NoAccelerator | DrawItemState.NoFocusRect)) {
e.Graphics.FillRectangle(new SolidBrush(SystemColors.Highlight) , rc);
e.Graphics.DrawString(str , cmbBackColor.Font, new SolidBrush(Color.White), rc2);
e.Graphics.FillRectangle(new SolidBrush(color), rc3);
e.Graphics.DrawRectangle(Pens.White, rc3);
} else {
e.Graphics.FillRectangle(new SolidBrush(Color.White), rc);
e.Graphics.DrawString(str , cmbBackColor.Font, new SolidBrush(Color.Black), rc2);
e.Graphics.FillRectangle(new SolidBrush(color), rc3);
e.Graphics.DrawRectangle(Pens.Black, rc3);
}
}
void cbBoldCheckedChanged(object sender, EventArgs e)
{
if (lstElements.SelectedIndex != -1) {
@ -511,11 +423,6 @@ namespace HexEditor.View @@ -511,11 +423,6 @@ namespace HexEditor.View
} else {
cmbForeColor.SelectedIndex = cmbForeColor.Items.IndexOf(OffsetForeColor.Name);
}
if (OffsetBackColor == customBack) {
cmbBackColor.SelectedIndex = 0;
} else {
cmbBackColor.SelectedIndex = cmbBackColor.Items.IndexOf(OffsetBackColor.Name);
}
break;
case 1 :
cbBold.Checked = DataBold;
@ -527,11 +434,6 @@ namespace HexEditor.View @@ -527,11 +434,6 @@ namespace HexEditor.View
} else {
cmbForeColor.SelectedIndex = cmbForeColor.Items.IndexOf(DataForeColor.Name);
}
if (DataBackColor == customBack) {
cmbBackColor.SelectedIndex = 0;
} else {
cmbBackColor.SelectedIndex = cmbBackColor.Items.IndexOf(DataBackColor.Name);
}
break;
}
}
@ -541,11 +443,6 @@ namespace HexEditor.View @@ -541,11 +443,6 @@ namespace HexEditor.View
fcmanualchange = true;
}
void cmbBackColorDropDown(object sender, EventArgs e)
{
bcmanualchange = true;
}
bool IsNamedColor(Color color)
{
foreach (Color c in Colors) {

14
src/AddIns/DisplayBindings/HexEditor/Project/changes.txt

@ -19,15 +19,7 @@ version: 0.0.2 @@ -19,15 +19,7 @@ version: 0.0.2
Known bugs/Problems:
1) When in overwrite mode you have to type into the text display
(right hand side) twice before the value is changed.
2) Might be good to be able to change individual hex parts of a byte.
3) Might be good if the next hex value to be typed in was highlighted
1) Might be good to be able to change individual hex parts of a byte.
2) Might be good if the next hex value to be typed in was highlighted
in the hex display.
4) Seems to be a slight delay with moving the blinking highlight as
you use the keyboard to move around the editor.
5) Maybe the cursor position should just highlight the text and not blink?
6) Copy and paste does not seem to work. The wrong data is copied.
This could be because the Copy menu item is not enabled.
7) When you paste in insert mode the text/hex is inserted. Should it
not replace the selected text/hex?
3) Change data structures (crashes when opening big files)
Loading…
Cancel
Save