-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added IronyTextBox control, a wrapper for FCTB with Irony parser supp…
…ort.
- Loading branch information
Showing
8 changed files
with
488 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Windows.Forms; | ||
|
||
namespace Irony.WinForms { | ||
/// <summary> | ||
/// Specifies the border style for the control. | ||
/// </summary> | ||
public enum BorderStyleEx { | ||
/// <summary> | ||
/// No border. | ||
/// </summary> | ||
None = BorderStyle.None, | ||
/// <summary> | ||
/// Single-line border. | ||
/// </summary> | ||
FixedSingle = BorderStyle.FixedSingle, | ||
/// <summary> | ||
/// A three-dimensional border. | ||
/// </summary> | ||
Fixed3D = BorderStyle.Fixed3D, | ||
/// <summary> | ||
/// A border supplied by system theme. | ||
/// </summary> | ||
VisualStyle = 100, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Drawing; | ||
using System.Data; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Windows.Forms; | ||
using System.Drawing.Design; | ||
using System.Windows.Forms.VisualStyles; | ||
using Irony.WinForms.Proxies; | ||
|
||
namespace Irony.WinForms { | ||
/// <summary> | ||
/// TextBox with syntax highlighting support based on Irony toolkit. | ||
/// </summary> | ||
public partial class IronyTextBox : UserControl { | ||
BorderStyleEx _borderStyleEx = BorderStyleEx.None; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="IronyTextBox" /> class. | ||
/// </summary> | ||
public IronyTextBox() { | ||
InitializeComponent(); | ||
TextBoxProxy = new Lazy<TextBox>(() => new TextBoxProxy(FastColoredTextBox).Instance); | ||
BorderStyleEx = BorderStyleEx.VisualStyle; | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the TextBox proxy object. | ||
/// </summary> | ||
private Lazy<TextBox> TextBoxProxy { get; set; } | ||
|
||
/// <summary> | ||
/// Allows converting IronyTextBox into TextBox implicitly. | ||
/// </summary> | ||
/// <param name="ironyTextBox">The irony text box.</param> | ||
public static implicit operator TextBox(IronyTextBox ironyTextBox) { | ||
return ironyTextBox.TextBoxProxy.Value; | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the text associated with this <see cref="IronyTextBox"/>. | ||
/// </summary> | ||
[DefaultValue(null), Browsable(true), DesignerSerializationVisibility(DesignerSerializationVisibility.Visible), Localizable(true)] | ||
[Editor("System.ComponentModel.Design.MultilineStringEditor, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor))] | ||
public override string Text { | ||
get { return FastColoredTextBox.Text; } | ||
set { | ||
FastColoredTextBox.Text = value; | ||
FastColoredTextBox.SelectionLength = 0; | ||
FastColoredTextBox.SelectionStart = 0; | ||
FastColoredTextBox.DoCaretVisible(); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the border style of the control. | ||
/// </summary> | ||
[DefaultValue(BorderStyleEx.VisualStyle), Browsable(true)] | ||
public BorderStyleEx BorderStyleEx { | ||
get { return _borderStyleEx; } | ||
set { | ||
if (_borderStyleEx != value) { | ||
_borderStyleEx = value; | ||
if (_borderStyleEx != BorderStyleEx.VisualStyle) { | ||
BorderStyle = (BorderStyle)value; | ||
Padding = new Padding(0); | ||
} else { | ||
BorderStyle = BorderStyle.None; | ||
if (Application.RenderWithVisualStyles) | ||
Padding = new Padding(1); | ||
else | ||
Padding = new Padding(2); | ||
} | ||
Invalidate(); | ||
} | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Hide the inherited BorderStyle property. | ||
/// </summary> | ||
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] | ||
public new BorderStyle BorderStyle { | ||
get { return base.BorderStyle; } | ||
set { base.BorderStyle = value; } | ||
} | ||
|
||
/// <summary> | ||
/// Hide the inherited Padding property. | ||
/// </summary> | ||
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] | ||
public new Padding Padding { | ||
get { return base.Padding; } | ||
set { base.Padding = value; } | ||
} | ||
|
||
/// <summary> | ||
/// Raises the <see cref="E:Paint" /> event. | ||
/// </summary> | ||
/// <param name="args">The <see cref="PaintEventArgs" /> instance containing the event data.</param> | ||
protected override void OnPaint(PaintEventArgs args) { | ||
base.OnPaint(args); | ||
if (Application.RenderWithVisualStyles) | ||
ControlPaint.DrawVisualStyleBorder(args.Graphics, new Rectangle(0, 0, Width - 1, Height - 1)); | ||
else { | ||
ControlPaint.DrawBorder3D(args.Graphics, new Rectangle(0, 0, Width, Height), Border3DStyle.SunkenOuter); | ||
ControlPaint.DrawBorder3D(args.Graphics, new Rectangle(1, 1, Width - 2, Height - 2), Border3DStyle.SunkenInner); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
<?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> |
Oops, something went wrong.