Commit 5e09be2c authored by Alexander Dietsch's avatar Alexander Dietsch

-Fixed error of overlaying text; now usus Custom Textbox that replaces Tab

with four spaces.
-Potentially fixed error of Undo leading to exceptions (same reason?)
parent 0d9a5a81
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace LWSimulatorGUI
{
class CustomRichTextBox : RichTextBox
{
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == Keys.Tab)
{
SelectionLength = 0;
SelectedText = new string(' ', 4);
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
}
}
......@@ -90,6 +90,9 @@
<Reference Include="WindowsFormsIntegration" />
</ItemGroup>
<ItemGroup>
<Compile Include="CustomRichTextBox.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="InsertRegisters.cs">
<SubType>Form</SubType>
</Compile>
......
......@@ -29,9 +29,9 @@
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainGUI));
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
this.mSMainMenu = new System.Windows.Forms.MenuStrip();
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.newToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
......@@ -62,7 +62,7 @@
this.spCMainGUI = new System.Windows.Forms.SplitContainer();
this.pBIndicateLine = new System.Windows.Forms.PictureBox();
this.rTBLineNumbers = new System.Windows.Forms.RichTextBox();
this.fCTBProgram = new System.Windows.Forms.RichTextBox();
this.fCTBProgram = new LWSimulatorGUI.CustomRichTextBox();
this.dGVRegisters = new System.Windows.Forms.DataGridView();
this.cRegisters = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.cValues = new System.Windows.Forms.DataGridViewTextBoxColumn();
......@@ -397,14 +397,14 @@
this.dGVRegisters.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.cRegisters,
this.cValues});
dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle6.BackColor = System.Drawing.SystemColors.Window;
dataGridViewCellStyle6.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
dataGridViewCellStyle6.ForeColor = System.Drawing.SystemColors.ControlText;
dataGridViewCellStyle6.SelectionBackColor = System.Drawing.SystemColors.Window;
dataGridViewCellStyle6.SelectionForeColor = System.Drawing.SystemColors.ControlText;
dataGridViewCellStyle6.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
this.dGVRegisters.DefaultCellStyle = dataGridViewCellStyle6;
dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Window;
dataGridViewCellStyle3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.ControlText;
dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Window;
dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.ControlText;
dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
this.dGVRegisters.DefaultCellStyle = dataGridViewCellStyle3;
this.dGVRegisters.EditMode = System.Windows.Forms.DataGridViewEditMode.EditOnEnter;
this.dGVRegisters.Location = new System.Drawing.Point(0, 0);
this.dGVRegisters.MultiSelect = false;
......@@ -420,8 +420,8 @@
// cRegisters
//
this.cRegisters.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
this.cRegisters.DefaultCellStyle = dataGridViewCellStyle4;
dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
this.cRegisters.DefaultCellStyle = dataGridViewCellStyle1;
this.cRegisters.HeaderText = "Register";
this.cRegisters.MaxInputLength = 10;
this.cRegisters.Name = "cRegisters";
......@@ -433,8 +433,8 @@
// cValues
//
this.cValues.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
this.cValues.DefaultCellStyle = dataGridViewCellStyle5;
dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
this.cValues.DefaultCellStyle = dataGridViewCellStyle2;
this.cValues.HeaderText = "Value";
this.cValues.MaxInputLength = 15;
this.cValues.Name = "cValues";
......@@ -535,10 +535,10 @@
private System.Windows.Forms.Button bRevertReg;
private System.Windows.Forms.ToolStripMenuItem checkSyntaxToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem checkSyntaxToolStripMenuItem1;
private System.Windows.Forms.RichTextBox fCTBProgram;
private System.Windows.Forms.RichTextBox rTBLineNumbers;
private System.Windows.Forms.PictureBox pBIndicateLine;
private System.Windows.Forms.ToolStripMenuItem saveAsToolStripMenuItem;
private CustomRichTextBox fCTBProgram;
}
}
......@@ -25,7 +25,7 @@ namespace LWSimulatorGUI
private int curCharIndex = -1;
private bool dirty = false; //whether text was changed
internal string currentFilePath = String.Empty;
private const string tabReplacement = " "; //Replacement to prevent bugginess in Monoversion e.g. on Linux
// Contains all regex that are highlighted
private string[] regex = new string[]
......@@ -657,7 +657,9 @@ namespace LWSimulatorGUI
{
try
{
fCTBProgram.Text = File.ReadAllText(programFileDialog.FileName);
string tmp = File.ReadAllText(programFileDialog.FileName);
fCTBProgram.Text = tmp.Replace("\t", tabReplacement);
currentFilePath = programFileDialog.FileName;
dirty = false;
refreshTitle();
......@@ -819,8 +821,21 @@ namespace LWSimulatorGUI
insertReg.ShowDialog(this);
}
#endregion
/// <summary>
/// Eventhandler for Keypressevent in Program Textbox;
/// Replaces pressed Tab
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void fCTBProgram_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == '\t')
{
e.Handled = true;
SendKeys.Send(tabReplacement);
}
}
#endregion
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment