proper import

git-svn-id: https://lsleditor.svn.sourceforge.net/svnroot/lsleditor@9 3f4676ac-adda-40fd-8265-58d1435b1672
This commit is contained in:
dimentox 2010-04-29 07:47:27 +00:00
parent 66730fd649
commit 3151e1e342
454 changed files with 57577 additions and 0 deletions

36
trunk/Editor/GListBox.Designer.cs generated Normal file
View file

@ -0,0 +1,36 @@
namespace LSLEditor
{
partial class GListBox
{
/// <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 Component 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()
{
components = new System.ComponentModel.Container();
}
#endregion
}
}

152
trunk/Editor/GListBox.cs Normal file
View file

@ -0,0 +1,152 @@
// /**
// ********
// *
// * ORIGIONAL CODE BASE IS Copyright (C) 2006-2010 by Alphons van der Heijden
// * The code was donated on 4/28/2010 by Alphons van der Heijden
// * To Brandon'Dimentox Travanti' Husbands & Malcolm J. Kudra which in turn Liscense under the GPLv2.
// * In agreement to Alphons van der Heijden wishes.
// *
// * The community would like to thank Alphons for all of his hard work, blood sweat and tears.
// * Without his work the community would be stuck with crappy editors.
// *
// * The source code in this file ("Source Code") is provided by The LSLEditor Group
// * to you under the terms of the GNU General Public License, version 2.0
// * ("GPL"), unless you have obtained a separate licensing agreement
// * ("Other License"), formally executed by you and The LSLEditor Group. Terms of
// * the GPL can be found in the gplv2.txt document.
// *
// ********
// * GPLv2 Header
// ********
// * LSLEditor, a External editor for the LSL Language.
// * Copyright (C) 2010 The LSLEditor Group.
//
// * This program is free software; you can redistribute it and/or
// * modify it under the terms of the GNU General Public License
// * as published by the Free Software Foundation; either version 2
// * of the License, or (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program; if not, write to the Free Software
// * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// ********
// *
// * The above copyright notice and this permission notice shall be included in all
// * copies or substantial portions of the Software.
// *
// ********
// */
using System;
using System.Drawing;
using System.Windows.Forms;
using System.ComponentModel;
namespace LSLEditor
{
public partial class GListBox : ListBox
{
public ImageList ImageList;
public GListBox(IContainer container)
{
container.Add(this);
InitializeComponent();
// Set owner draw mode
this.DrawMode = DrawMode.OwnerDrawFixed;
this.ImageList = new ImageList();
}
public GListBox()
{
InitializeComponent();
// Set owner draw mode
this.DrawMode = DrawMode.OwnerDrawFixed;
this.ImageList = new ImageList();
}
protected override void OnDrawItem(DrawItemEventArgs e)
{
try
{
GListBoxItem item;
Rectangle bounds = new Rectangle(e.Bounds.X + e.Bounds.Height, e.Bounds.Y, e.Bounds.Width - e.Bounds.Height - 1, e.Bounds.Height);
item = (GListBoxItem)Items[e.Index];
if (item.ImageIndex != -1)
{
e.Graphics.FillRectangle(new SolidBrush(this.BackColor), bounds);
if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
e.Graphics.FillRectangle(SystemBrushes.Highlight, bounds);
e.Graphics.DrawImage(ImageList.Images[item.ImageIndex], bounds.Left - bounds.Height, bounds.Top, bounds.Height, bounds.Height);
e.Graphics.DrawString(item.Text, e.Font, new SolidBrush(e.ForeColor),
bounds.Left, bounds.Top);
}
else
{
e.Graphics.DrawString(item.Text, e.Font, new SolidBrush(e.ForeColor),
bounds.Left, bounds.Top);
}
}
catch
{
e.DrawBackground();
e.DrawFocusRectangle();
if (e.Index != -1)
{
try
{
e.Graphics.DrawString(Items[e.Index].ToString(), e.Font,
new SolidBrush(e.ForeColor), e.Bounds.Left, e.Bounds.Top);
}
catch
{
}
}
else
{
e.Graphics.DrawString(Text, e.Font, new SolidBrush(e.ForeColor),
e.Bounds.Left, e.Bounds.Top);
}
}
base.OnDrawItem(e);
}
}//End of GListBox class
// GListBoxItem class
public class GListBoxItem
{
private string _myText;
private int _myImageIndex;
// properties
public string Text
{
get { return _myText; }
set { _myText = value; }
}
public int ImageIndex
{
get { return _myImageIndex; }
set { _myImageIndex = value; }
}
//constructor
public GListBoxItem(string text, int index)
{
_myText = text;
_myImageIndex = index;
}
public GListBoxItem(string text) : this(text, -1) { }
public GListBoxItem() : this("") { }
public override string ToString()
{
return _myText;
}
}//End of GListBoxItem class
}

64
trunk/Editor/GListBoxWindow.Designer.cs generated Normal file
View file

@ -0,0 +1,64 @@
namespace LSLEditor
{
partial class GListBoxWindow
{
/// <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.components = new System.ComponentModel.Container();
this.gListBox1 = new LSLEditor.GListBox(this.components);
this.SuspendLayout();
//
// gListBox1
//
this.gListBox1.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
this.gListBox1.FormattingEnabled = true;
this.gListBox1.Location = new System.Drawing.Point(0, 0);
this.gListBox1.Name = "gListBox1";
this.gListBox1.Size = new System.Drawing.Size(192, 134);
this.gListBox1.TabIndex = 0;
this.gListBox1.Resize += new System.EventHandler(this.gListBox1_Resize);
//
// GListBoxWindow
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(212, 156);
this.Controls.Add(this.gListBox1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "GListBoxWindow";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
this.Text = "GListBoxWindow";
this.ResumeLayout(false);
}
#endregion
private GListBox gListBox1;
}
}

View file

@ -0,0 +1,177 @@
// /**
// ********
// *
// * ORIGIONAL CODE BASE IS Copyright (C) 2006-2010 by Alphons van der Heijden
// * The code was donated on 4/28/2010 by Alphons van der Heijden
// * To Brandon'Dimentox Travanti' Husbands & Malcolm J. Kudra which in turn Liscense under the GPLv2.
// * In agreement to Alphons van der Heijden wishes.
// *
// * The community would like to thank Alphons for all of his hard work, blood sweat and tears.
// * Without his work the community would be stuck with crappy editors.
// *
// * The source code in this file ("Source Code") is provided by The LSLEditor Group
// * to you under the terms of the GNU General Public License, version 2.0
// * ("GPL"), unless you have obtained a separate licensing agreement
// * ("Other License"), formally executed by you and The LSLEditor Group. Terms of
// * the GPL can be found in the gplv2.txt document.
// *
// ********
// * GPLv2 Header
// ********
// * LSLEditor, a External editor for the LSL Language.
// * Copyright (C) 2010 The LSLEditor Group.
//
// * This program is free software; you can redistribute it and/or
// * modify it under the terms of the GNU General Public License
// * as published by the Free Software Foundation; either version 2
// * of the License, or (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program; if not, write to the Free Software
// * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// ********
// *
// * The above copyright notice and this permission notice shall be included in all
// * copies or substantial portions of the Software.
// *
// ********
// */
using System;
using System.Drawing;
using System.ComponentModel;
using System.Windows.Forms;
namespace LSLEditor
{
public partial class GListBoxWindow : Form
{
public GListBox GListBox
{
get
{
return this.gListBox1;
}
}
public GListBoxItem Selected
{
get
{
return (GListBoxItem)this.gListBox1.Items[this.gListBox1.SelectedIndex];
}
}
public GListBoxWindow(Form parent)
{
InitializeComponent();
this.Owner = parent;
this.GListBox.Cursor = Cursors.Arrow;
this.GListBox.Sorted = true;
this.FontChanged += new EventHandler(GListBoxWindow_FontChanged);
}
void GListBoxWindow_FontChanged(object sender, EventArgs e)
{
this.GListBox.ItemHeight = 2 + (int)LSLEditor.Helpers.Measure.MeasureDisplayString(this.GListBox, "M", this.Font).Height;
}
public void KeyDownHandler(KeyEventArgs e)
{
if (!this.Visible)
return;
if (e.KeyCode == Keys.Enter)
{
// cancel richttext enter if listbox shows
e.Handled = true;
}
if (e.KeyCode == Keys.Down)
{
this.gListBox1.SelectedIndex = Math.Min(this.gListBox1.Items.Count - 1, this.gListBox1.SelectedIndex + 1);
e.Handled = true;
}
if (e.KeyCode == Keys.Up)
{
this.gListBox1.SelectedIndex = Math.Max(0, this.gListBox1.SelectedIndex - 1);
e.Handled = true;
}
if (e.KeyCode == Keys.PageUp)
{
this.gListBox1.SelectedIndex = Math.Max(0,this.gListBox1.SelectedIndex - 10);
e.Handled = true;
}
if (e.KeyCode == Keys.PageDown)
{
this.gListBox1.SelectedIndex = Math.Min(this.gListBox1.Items.Count - 1, this.gListBox1.SelectedIndex + 10);
e.Handled = true;
}
}
public void SetPosition(Rectangle rect,RichTextBox RichTextBox)
{
//Rectangle rect = Screen.PrimaryScreen.WorkingArea;
Point p = RichTextBox.GetPositionFromCharIndex(RichTextBox.SelectionStart);
p = new Point(p.X - 20, p.Y + this.gListBox1.ItemHeight); // ItemHeight = exact line height
Rectangle client = RichTextBox.ClientRectangle;
if (p.X < (client.Left-20) || p.Y < client.Top || p.X > client.Width || p.Y > client.Height)
{
this.Visible = false;
return;
}
Point screen = RichTextBox.PointToScreen(p);
//if ((screen.Y + this.Height) > rect.Height)
// screen = RichTextBox.PointToScreen(new Point(p.X - 20 + this.XOffset, p.Y - this.Height));
if (screen.Y > rect.Bottom)
{
this.Visible = false;
return;
//screen.Y = rect.Bottom;
}
if (screen.X > rect.Right)
{
this.Visible = false;
return;
//screen.X = rect.Right;
}
if (screen.X < rect.Left)
{
this.Visible = false;
return;
//screen.X = rect.Left;
}
if ((screen.Y) < rect.Top)
{
this.Visible = false;
return;
//screen.Y = rect.Top;
}
this.Location = screen;
}
private void gListBox1_Resize(object sender, EventArgs e)
{
this.Size = this.gListBox1.Size;
}
}
}

View file

@ -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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

410
trunk/Editor/KeyWords.cs Normal file
View file

@ -0,0 +1,410 @@
// /**
// ********
// *
// * ORIGIONAL CODE BASE IS Copyright (C) 2006-2010 by Alphons van der Heijden
// * The code was donated on 4/28/2010 by Alphons van der Heijden
// * To Brandon'Dimentox Travanti' Husbands & Malcolm J. Kudra which in turn Liscense under the GPLv2.
// * In agreement to Alphons van der Heijden wishes.
// *
// * The community would like to thank Alphons for all of his hard work, blood sweat and tears.
// * Without his work the community would be stuck with crappy editors.
// *
// * The source code in this file ("Source Code") is provided by The LSLEditor Group
// * to you under the terms of the GNU General Public License, version 2.0
// * ("GPL"), unless you have obtained a separate licensing agreement
// * ("Other License"), formally executed by you and The LSLEditor Group. Terms of
// * the GPL can be found in the gplv2.txt document.
// *
// ********
// * GPLv2 Header
// ********
// * LSLEditor, a External editor for the LSL Language.
// * Copyright (C) 2010 The LSLEditor Group.
//
// * This program is free software; you can redistribute it and/or
// * modify it under the terms of the GNU General Public License
// * as published by the Free Software Foundation; either version 2
// * of the License, or (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program; if not, write to the Free Software
// * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// ********
// *
// * The above copyright notice and this permission notice shall be included in all
// * copies or substantial portions of the Software.
// *
// ********
// */
using System;
using System.IO;
using System.Drawing;
using System.Xml;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace LSLEditor
{
public enum KeyWordTypeEnum : int
{
Unknown = 0,
Functions = 1,
Events = 2,
Constants = 3,
Class = 4,
Vars = 5,
Properties = 6
}
public struct KeyWordInfo
{
public KeyWordTypeEnum type;
public string name;
public Color color;
public KeyWordInfo(KeyWordTypeEnum type, string name, Color color)
{
this.type = type;
this.name = name;
this.color = color;
}
}
class KeyWords
{
private ArrayList m_RegexColorList;
private Regex m_regexSplitter;
private Hashtable m_KeyWordColorList;
private XmlDocument xml;
private void MakeSplitter(string strRegexSplitter)
{
m_regexSplitter = new Regex(
@"\s*(" + strRegexSplitter + @"|\w+|.)",
RegexOptions.IgnorePatternWhitespace
| RegexOptions.Compiled
);
}
private struct RegexColor
{
public Regex regex;
public Color color;
public RegexColor(string strRegex, Color color)
{
this.regex = new Regex(strRegex,
RegexOptions.IgnorePatternWhitespace
| RegexOptions.Compiled
);
this.color = color;
}
}
public KeyWords(string ColorScheme, XmlDocument xml)
{
this.m_RegexColorList = new ArrayList();
this.m_KeyWordColorList = new Hashtable();
this.xml = xml;
string strRegexSplitter = "";
foreach (XmlNode words in xml.SelectNodes("//Words"))
{
Color color = Color.FromArgb(int.Parse(words.Attributes[ColorScheme].InnerText.Replace("#", ""), System.Globalization.NumberStyles.HexNumber));
KeyWordTypeEnum type = KeyWordTypeEnum.Unknown;
if (words.Attributes["icon"] != null)
{
switch (words.Attributes["icon"].InnerText)
{
case "Functions":
type = KeyWordTypeEnum.Functions;
break;
case "Events":
type = KeyWordTypeEnum.Events;
break;
case "Constants":
type = KeyWordTypeEnum.Constants;
break;
case "Class":
type = KeyWordTypeEnum.Class;
break;
case "Vars":
type = KeyWordTypeEnum.Vars;
break;
case "Enum":
if (!Properties.Settings.Default.CodeCompletionAnimation)
continue;
type = KeyWordTypeEnum.Properties;
break;
default:
type = KeyWordTypeEnum.Unknown;
break;
}
}
foreach (XmlNode word in words.SelectNodes(".//Word"))
{
if (word.Attributes["name"].InnerText == "regex")
{
string strRegex = word.InnerText;
AddRegex(strRegex, color);
if (strRegexSplitter != "")
strRegexSplitter += "|";
strRegexSplitter += strRegex;
}
else
{
AddKeyword(type, word.Attributes["name"].InnerText, color);
}
}
}
MakeSplitter(strRegexSplitter);
}
private void AddRegex(string strRegex, Color color)
{
m_RegexColorList.Add(new RegexColor(strRegex, color));
}
private void AddKeyword(KeyWordTypeEnum type, string name, Color color)
{
m_KeyWordColorList.Add(name, new KeyWordInfo(type, name, color));
}
public Color GetColorFromRegex(string strKeyWord)
{
// specials
Color color = Color.Black;
foreach (RegexColor regexColor in m_RegexColorList)
{
Match mm = regexColor.regex.Match(strKeyWord);
if (mm.Success)
{
// must be exact match
if (mm.Index != 0)
continue;
color = regexColor.color;
break;
}
}
return color;
}
public KeyWordInfo GetKeyWordInfo(string strWord)
{
return (KeyWordInfo)this.m_KeyWordColorList[strWord];
}
public bool ContainsKeyWord(string strWord)
{
return m_KeyWordColorList.ContainsKey(strWord);
}
public Color GetColorFromKeyWordList(string strKeyWord)
{
if (ContainsKeyWord(strKeyWord))
return GetKeyWordInfo(strKeyWord).color;
else
return Color.Black;
}
public MatchCollection Matches(string strLine)
{
return m_regexSplitter.Matches(strLine);
}
public List<KeyWordInfo> KeyWordSearch(string strKeyWord, bool IsRegularExpression)
{
List<KeyWordInfo> list = new List<KeyWordInfo>();
string strLowerCaseKeyWord = strKeyWord.ToLower();
int intLen = strLowerCaseKeyWord.Length;
foreach (string strKey in m_KeyWordColorList.Keys)
{
if (IsRegularExpression)
{
if(new Regex("^"+strKeyWord+"$").Match(strKey).Success)
list.Add(GetKeyWordInfo(strKey));
}
else
{
if (strKey.Length < intLen)
continue;
if (strKey.Substring(0, intLen).ToLower() == strLowerCaseKeyWord)
list.Add(GetKeyWordInfo(strKey));
}
}
return list;
}
public string GetDescription(string strKeyWord)
{
if(ContainsKeyWord(strKeyWord))
{
XmlNode xmlNode = xml.SelectSingleNode("//Word[@name='"+strKeyWord+"']");
if(xmlNode!=null)
{
if (xmlNode.ChildNodes.Count == 0)
return "";
string strText = xmlNode.InnerXml;
if (strText == "")
return strKeyWord;
else
{
int intArgument = strText.IndexOf("<Argument");
if (intArgument > 0)
strText = strText.Substring(0, intArgument);
StringBuilder sb = new StringBuilder();
StringReader sr = new StringReader(strText);
while (true)
{
string strLine = sr.ReadLine();
if (strLine == null)
break;
sb.AppendLine(strLine.Trim());
}
return sb.ToString();
}
}
}
return "";
}
private string MakeArgumentBold(string strText, int intArgument)
{
Regex regex = new Regex(
@"(?<prefix>[^(]* \( )
(?:
(?<argument> [^,\)]*) (?"
+ @"<seperator>[\,\)])+
)*
(?<postfix>.*)
",
RegexOptions.IgnorePatternWhitespace);
Match match = regex.Match(strText);
StringBuilder sb = new StringBuilder();
sb.Append(match.Groups["prefix"].Value);
for (int intI = 0; intI < match.Groups["argument"].Captures.Count; intI++)
{
if (intI == intArgument)
{
sb.Append(@"<b><font color=""red"">");
sb.Append(match.Groups["argument"].Captures[intI].Value);
sb.Append("</font></b>");
}
else
{
sb.Append(match.Groups["argument"].Captures[intI].Value);
}
sb.Append(match.Groups["seperator"].Captures[intI].Value);
}
sb.Append(match.Groups["postfix"].Value);
sb.Append('\n');
return sb.ToString();
}
private string GetFirstLineOfKeyWord(string strWord, out XmlNode xmlNode)
{
xmlNode = null;
if (!ContainsKeyWord(strWord))
return "";
xmlNode = xml.SelectSingleNode("//Word[@name='" + strWord + "']");
if (xmlNode == null)
return "";
if (xmlNode.ChildNodes.Count == 0)
return "";
string strText = xmlNode.ChildNodes[0].InnerText;
if (strText == "")
return "";
strText = strText.TrimStart();
int intI = strText.IndexOf("\r");
if (intI > 0)
strText = strText.Substring(0, intI);
return strText;
}
public int GetNumberOfArguments(string strWord)
{
XmlNode xmlNode;
string strFirstLine = GetFirstLineOfKeyWord(strWord, out xmlNode);
if (strFirstLine == "")
return -1;
Regex regex = new Regex(
@"(?<prefix>[^(]* \( )
(?:
(?<argument> [^,\)]*) (?"
+ @"<seperator>[\,\)])+
)*
(?<postfix>.*)
",
RegexOptions.IgnorePatternWhitespace);
Match match = regex.Match(strFirstLine);
// nr not 1, return nr
int intNr = match.Groups["argument"].Captures.Count;
if(intNr != 1)
return intNr;
// nr = 1 can be void, returns also 0
if(match.Groups["argument"].Captures[0].Value == "void")
return 0;
// not void, return 1
return 1;
}
public string GetFunctionAndHiglightArgument(string strWord, int intArgument, out string strWild)
{
XmlNode xmlNode;
string strFirstLine = GetFirstLineOfKeyWord(strWord,out xmlNode);
strWild = "";
if (strFirstLine == "")
return "";
string strRichText = MakeArgumentBold(strFirstLine, intArgument);
if (xmlNode == null)
return strRichText;
XmlNodeList nodeList = xmlNode.SelectNodes("./Argument");
if (intArgument < nodeList.Count)
{
XmlNode xmlNodeArgument = nodeList[intArgument];
if(xmlNodeArgument.Attributes["wild"]!=null)
strWild = xmlNodeArgument.Attributes["wild"].Value;
string strName = xmlNodeArgument.Attributes["name"].Value;
string strDescription = "\n" + @"<b><font color=""red"">" + strName + ":</font></b>";
strRichText += strDescription + " " + xmlNodeArgument.InnerText + "\n";
}
return strRichText;
}
public string GetEvent(string strEventName)
{
string strReturn = strEventName + "(";
XmlNode xmlNode;
string strFirstLine = GetFirstLineOfKeyWord(strEventName, out xmlNode);
if (strFirstLine == "")
return strReturn;
return strFirstLine.Replace(";", "").Replace("void", "");
}
}
}

View file

@ -0,0 +1,43 @@
// /**
// ********
// *
// * ORIGIONAL CODE BASE IS Copyright (C) 2006-2010 by Alphons van der Heijden
// * The code was donated on 4/28/2010 by Alphons van der Heijden
// * To Brandon'Dimentox Travanti' Husbands & Malcolm J. Kudra which in turn Liscense under the GPLv2.
// * In agreement to Alphons van der Heijden wishes.
// *
// * The community would like to thank Alphons for all of his hard work, blood sweat and tears.
// * Without his work the community would be stuck with crappy editors.
// *
// * The source code in this file ("Source Code") is provided by The LSLEditor Group
// * to you under the terms of the GNU General Public License, version 2.0
// * ("GPL"), unless you have obtained a separate licensing agreement
// * ("Other License"), formally executed by you and The LSLEditor Group. Terms of
// * the GPL can be found in the gplv2.txt document.
// *
// ********
// * GPLv2 Header
// ********
// * LSLEditor, a External editor for the LSL Language.
// * Copyright (C) 2010 The LSLEditor Group.
//
// * This program is free software; you can redistribute it and/or
// * modify it under the terms of the GNU General Public License
// * as published by the Free Software Foundation; either version 2
// * of the License, or (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program; if not, write to the Free Software
// * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// ********
// *
// * The above copyright notice and this permission notice shall be included in all
// * copies or substantial portions of the Software.
// *
// ********
// */

37
trunk/Editor/Numbered.Designer.cs generated Normal file
View file

@ -0,0 +1,37 @@
namespace LSLEditor.Editor
{
partial class Numbered
{
/// <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 Component 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()
{
components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
}
#endregion
}
}

142
trunk/Editor/Numbered.cs Normal file
View file

@ -0,0 +1,142 @@
// /**
// ********
// *
// * ORIGIONAL CODE BASE IS Copyright (C) 2006-2010 by Alphons van der Heijden
// * The code was donated on 4/28/2010 by Alphons van der Heijden
// * To Brandon'Dimentox Travanti' Husbands & Malcolm J. Kudra which in turn Liscense under the GPLv2.
// * In agreement to Alphons van der Heijden wishes.
// *
// * The community would like to thank Alphons for all of his hard work, blood sweat and tears.
// * Without his work the community would be stuck with crappy editors.
// *
// * The source code in this file ("Source Code") is provided by The LSLEditor Group
// * to you under the terms of the GNU General Public License, version 2.0
// * ("GPL"), unless you have obtained a separate licensing agreement
// * ("Other License"), formally executed by you and The LSLEditor Group. Terms of
// * the GPL can be found in the gplv2.txt document.
// *
// ********
// * GPLv2 Header
// ********
// * LSLEditor, a External editor for the LSL Language.
// * Copyright (C) 2010 The LSLEditor Group.
//
// * This program is free software; you can redistribute it and/or
// * modify it under the terms of the GNU General Public License
// * as published by the Free Software Foundation; either version 2
// * of the License, or (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program; if not, write to the Free Software
// * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// ********
// *
// * The above copyright notice and this permission notice shall be included in all
// * copies or substantial portions of the Software.
// *
// ********
// */
using System;
using System.Drawing;
using System.Windows.Forms;
namespace LSLEditor.Editor
{
public partial class Numbered : UserControl
{
public RichTextBox richTextBox1;
private Brush brush;
public float LineHeight;
public Numbered()
{
InitializeComponent();
this.SetStyle(
ControlStyles.DoubleBuffer |
ControlStyles.UserPaint |
ControlStyles.AllPaintingInWmPaint,
true);
this.UpdateStyles();
brush = new SolidBrush(this.ForeColor);
LineHeight = 0.0F;
}
private void updateNumberLabel(PaintEventArgs e)
{
if (this.brush == null)
return;
if (this.ClientSize.Width <= 0 || this.ClientSize.Height <= 0)
return;
int delta = 0;
int firstLine = 0;
int lastLine = 10;
Font font = this.Font;
if (this.richTextBox1 == null)
{
LineHeight = 16.0F;
}
else
{
//we get index of first visible char and number of first visible line
Point pos = new Point(0, 0);
int firstIndex = this.richTextBox1.GetCharIndexFromPosition(pos);
firstLine = this.richTextBox1.GetLineFromCharIndex(firstIndex);
font = this.richTextBox1.Font;
if (LineHeight < 0.01)
{
if (this.richTextBox1.Lines.Length > 1)
{
Point pos1 = this.richTextBox1.GetPositionFromCharIndex(this.richTextBox1.GetFirstCharIndexFromLine(1));
LineHeight = pos1.Y;
}
}
lastLine = Math.Min(this.richTextBox1.Lines.Length, 2 + firstLine + (int)(this.richTextBox1.ClientRectangle.Height / LineHeight));
int intCharIndex = this.richTextBox1.GetCharIndexFromPosition(Point.Empty);
delta = 1 + this.richTextBox1.GetPositionFromCharIndex(intCharIndex).Y % font.Height;
}
// here we go
lastLine = Math.Max(lastLine, 1);
Graphics g = e.Graphics;
g.Clear(this.BackColor);
if(this.richTextBox1==null)
g.SetClip(new Rectangle(0, 0, this.Width, this.Height));
else
g.SetClip(new Rectangle(0, 0, this.Width, this.richTextBox1.ClientRectangle.Height));
for (int i = firstLine; i < lastLine; i++)
g.DrawString(string.Format("{0:0###}", i + 1), font, brush,
new PointF(0F, delta + (i - firstLine) * LineHeight) );
//g.DrawLine(new Pen(brush), backBuffer.Width - 1, 0, backBuffer.Width - 1, backBuffer.Height);
}
protected override void OnPaint(PaintEventArgs e)
{
updateNumberLabel(e);
}
protected override void OnPaintBackground(PaintEventArgs e)
{
//base.OnPaintBackground(e);
}
}
}

View file

@ -0,0 +1,83 @@
// /**
// ********
// *
// * ORIGIONAL CODE BASE IS Copyright (C) 2006-2010 by Alphons van der Heijden
// * The code was donated on 4/28/2010 by Alphons van der Heijden
// * To Brandon'Dimentox Travanti' Husbands & Malcolm J. Kudra which in turn Liscense under the GPLv2.
// * In agreement to Alphons van der Heijden wishes.
// *
// * The community would like to thank Alphons for all of his hard work, blood sweat and tears.
// * Without his work the community would be stuck with crappy editors.
// *
// * The source code in this file ("Source Code") is provided by The LSLEditor Group
// * to you under the terms of the GNU General Public License, version 2.0
// * ("GPL"), unless you have obtained a separate licensing agreement
// * ("Other License"), formally executed by you and The LSLEditor Group. Terms of
// * the GPL can be found in the gplv2.txt document.
// *
// ********
// * GPLv2 Header
// ********
// * LSLEditor, a External editor for the LSL Language.
// * Copyright (C) 2010 The LSLEditor Group.
//
// * This program is free software; you can redistribute it and/or
// * modify it under the terms of the GNU General Public License
// * as published by the Free Software Foundation; either version 2
// * of the License, or (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program; if not, write to the Free Software
// * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// ********
// *
// * The above copyright notice and this permission notice shall be included in all
// * copies or substantial portions of the Software.
// *
// ********
// */
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
namespace NumberedTextBox
{
public partial class NumberedTextBoxUC : UserControl
{
public NumberedTextBoxUC()
{
InitializeComponent();
this.numbered1.richTextBox1 = this.syntaxRichTextBox1;
this.syntaxRichTextBox1.OnPaintNumbers += new EventHandler(syntaxRichTextBox1_OnPaintNumbers);
this.FontChanged += new EventHandler(NumberedTextBoxUC_FontChanged);
}
void NumberedTextBoxUC_FontChanged(object sender, EventArgs e)
{
this.numbered1.LineHeight = 0.0F; // reset!!
RectangleF rect = LSLEditor.Helpers.Measure.MeasureDisplayString(this.syntaxRichTextBox1, "M", this.Font);
this.splitContainer1.SplitterDistance = (int)(4 * rect.Width + 5.0);
}
void syntaxRichTextBox1_OnPaintNumbers(object sender, EventArgs e)
{
this.numbered1.Invalidate();
}
public LSLEditor.SyntaxRichTextBox TextBox
{
get
{
return this.syntaxRichTextBox1;
}
}
}
}

106
trunk/Editor/NumberedTextBoxUC.designer.cs generated Normal file
View file

@ -0,0 +1,106 @@
namespace NumberedTextBox
{
partial class NumberedTextBoxUC
{
/// <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 Component 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.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.numbered1 = new LSLEditor.Editor.Numbered();
this.syntaxRichTextBox1 = new LSLEditor.SyntaxRichTextBox();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.SuspendLayout();
//
// splitContainer1
//
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
this.splitContainer1.IsSplitterFixed = true;
this.splitContainer1.Location = new System.Drawing.Point(0, 0);
this.splitContainer1.Name = "splitContainer1";
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.BackColor = System.Drawing.SystemColors.ActiveBorder;
this.splitContainer1.Panel1.Controls.Add(this.numbered1);
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.syntaxRichTextBox1);
this.splitContainer1.Size = new System.Drawing.Size(403, 267);
this.splitContainer1.SplitterDistance = 41;
this.splitContainer1.SplitterWidth = 1;
this.splitContainer1.TabIndex = 2;
this.splitContainer1.Text = "splitContainer1";
//
// numbered1
//
this.numbered1.BackColor = System.Drawing.SystemColors.ButtonFace;
this.numbered1.Dock = System.Windows.Forms.DockStyle.Fill;
this.numbered1.Location = new System.Drawing.Point(0, 0);
this.numbered1.Name = "numbered1";
this.numbered1.Size = new System.Drawing.Size(41, 267);
this.numbered1.TabIndex = 0;
//
// syntaxRichTextBox1
//
this.syntaxRichTextBox1.AcceptsTab = true;
this.syntaxRichTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.syntaxRichTextBox1.DetectUrls = false;
this.syntaxRichTextBox1.Dirty = true;
this.syntaxRichTextBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.syntaxRichTextBox1.Location = new System.Drawing.Point(0, 0);
this.syntaxRichTextBox1.Name = "syntaxRichTextBox1";
this.syntaxRichTextBox1.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.ForcedBoth;
this.syntaxRichTextBox1.Size = new System.Drawing.Size(361, 267);
this.syntaxRichTextBox1.TabIndex = 0;
this.syntaxRichTextBox1.Text = "";
this.syntaxRichTextBox1.ToolTipping = false;
this.syntaxRichTextBox1.WordWrap = false;
//
// NumberedTextBoxUC
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.splitContainer1);
this.Name = "NumberedTextBoxUC";
this.Size = new System.Drawing.Size(403, 267);
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel2.ResumeLayout(false);
this.splitContainer1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.SplitContainer splitContainer1;
private LSLEditor.Editor.Numbered numbered1;
private LSLEditor.SyntaxRichTextBox syntaxRichTextBox1;
}
}

View file

@ -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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

42
trunk/Editor/RichLabel.Designer.cs generated Normal file
View file

@ -0,0 +1,42 @@
namespace LSLEditor
{
partial class RichLabel
{
/// <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 Component 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.SuspendLayout();
//
// RichLabel
//
this.Name = "RichLabel";
this.ResumeLayout(false);
}
#endregion
}
}

272
trunk/Editor/RichLabel.cs Normal file
View file

@ -0,0 +1,272 @@
// /**
// ********
// *
// * ORIGIONAL CODE BASE IS Copyright (C) 2006-2010 by Alphons van der Heijden
// * The code was donated on 4/28/2010 by Alphons van der Heijden
// * To Brandon'Dimentox Travanti' Husbands & Malcolm J. Kudra which in turn Liscense under the GPLv2.
// * In agreement to Alphons van der Heijden wishes.
// *
// * The community would like to thank Alphons for all of his hard work, blood sweat and tears.
// * Without his work the community would be stuck with crappy editors.
// *
// * The source code in this file ("Source Code") is provided by The LSLEditor Group
// * to you under the terms of the GNU General Public License, version 2.0
// * ("GPL"), unless you have obtained a separate licensing agreement
// * ("Other License"), formally executed by you and The LSLEditor Group. Terms of
// * the GPL can be found in the gplv2.txt document.
// *
// ********
// * GPLv2 Header
// ********
// * LSLEditor, a External editor for the LSL Language.
// * Copyright (C) 2010 The LSLEditor Group.
//
// * This program is free software; you can redistribute it and/or
// * modify it under the terms of the GNU General Public License
// * as published by the Free Software Foundation; either version 2
// * of the License, or (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program; if not, write to the Free Software
// * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// ********
// *
// * The above copyright notice and this permission notice shall be included in all
// * copies or substantial portions of the Software.
// *
// ********
// */
using System;
using System.Drawing;
using System.Globalization;
using System.Windows.Forms;
using System.ComponentModel;
using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace LSLEditor
{
public partial class RichLabel : UserControl
{
private Regex m_regex;
public override string Text
{
get
{
return base.Text;
}
set
{
base.Text = value;
this.Invalidate();
}
}
public RichLabel()
{
InitializeComponent();
this.SetStyle(
ControlStyles.DoubleBuffer |
ControlStyles.UserPaint |
ControlStyles.AllPaintingInWmPaint,
true);
this.UpdateStyles();
this.Text = "richLabel1";
this.BackColor = Color.LightGoldenrodYellow;
this.m_regex = new Regex(@"
(?:
<(?:
(?<startTag>[^>/\s]*)
(?<attributes> [\s]+ (?<attName>[^=]*) = ""(?<attValue>[^""]*)"")*
)>
|
<[/]* (?<endTag>[^>\s/]*) [/]*>
|
(?<text>[^<]*)
)
",
RegexOptions.IgnorePatternWhitespace
| RegexOptions.Compiled);
//this.m_regex = new Regex(@"(?<text>\w*)");
}
private void SafePaint(PaintEventArgs e)
{
try
{
Graphics g = e.Graphics;
e.Graphics.Clear(this.BackColor);
Stack<String> fontFace = new Stack<String>();
Stack<Single> fontSize = new Stack<Single>();
Stack<Color> fontColor = new Stack<Color>();
Stack<FontStyle> fontStyle = new Stack<FontStyle>();
fontFace.Push(this.Font.Name);
fontSize.Push(this.Font.Size);
fontStyle.Push(this.Font.Style);
fontColor.Push(this.ForeColor);
float fltLineHeight = 0;
float fltLineHeightMax = 0;
float fltWidth = 0;
float fltHeight = 0;
PointF point = new PointF(this.Margin.Left, this.Margin.Top);
string strLines = this.Text.Replace("\r", "").Replace("\n", "<br>");
foreach (Match m in this.m_regex.Matches(strLines))
{
string strText = m.Groups["text"].Value.Replace("&lt;", "<").Replace("&gt;", ">");
switch (m.Groups["startTag"].Value)
{
case "font":
for (int intI = 0; intI < m.Groups["attName"].Captures.Count; intI++)
{
string strValue = m.Groups["attValue"].Captures[intI].Value;
switch (m.Groups["attName"].Captures[intI].Value)
{
case "color":
if (strValue.StartsWith("#"))
{
int intColor = 255;
int.TryParse(strValue.Substring(1), NumberStyles.HexNumber, null, out intColor);
fontColor.Push(Color.FromArgb(255, Color.FromArgb(intColor)));
}
else
{
fontColor.Push(Color.FromName(strValue));
}
break;
case "face":
fontFace.Push(strValue);
break;
case "size":
float fltSize = 10.0F;
float.TryParse(strValue, out fltSize);
fontSize.Push(fltSize);
break;
default:
break;
}
}
break;
case "b":
fontStyle.Push(fontStyle.Peek() | FontStyle.Bold);
break;
case "u":
fontStyle.Push(fontStyle.Peek() | FontStyle.Underline);
break;
case "i":
fontStyle.Push(fontStyle.Peek() | FontStyle.Italic);
break;
case "s":
fontStyle.Push(fontStyle.Peek() | FontStyle.Strikeout);
break;
case "br":
point = new PointF(this.Margin.Left, point.Y + fltLineHeightMax);
fltLineHeightMax = fltLineHeight;
break;
default:
break;
}
switch (m.Groups["endTag"].Value)
{
case "font":
if (fontColor.Count > 1)
fontColor.Pop();
if (fontSize.Count > 1)
fontSize.Pop();
if (fontFace.Count > 1)
fontFace.Pop();
break;
case "b":
case "u":
case "i":
case "s":
if (fontStyle.Count > 1)
fontStyle.Pop();
break;
case "br":
point = new PointF(this.Margin.Left, point.Y + fltLineHeightMax);
fltLineHeightMax = fltLineHeight;
break;
default:
break;
}
if (strText.Length == 0)
continue;
Font fontTmp = new Font(fontFace.Peek(), fontSize.Peek(), fontStyle.Peek());
Size rect = MeasureTextIncludingSpaces(g, strText, fontTmp); // TextRenderer.MeasureText(strText, fontTmp);
PointF pointToDraw = new PointF(point.X, point.Y);
point = new PointF(point.X + rect.Width, point.Y);
fltWidth = Math.Max(fltWidth, point.X);
fltHeight = Math.Max(fltHeight, point.Y + rect.Height);
fltLineHeight = rect.Height;
fltLineHeightMax = Math.Max(fltLineHeightMax, fltLineHeight);
Brush brush = new SolidBrush(fontColor.Peek());
g.DrawString(strText, fontTmp, brush, pointToDraw);
brush.Dispose();
fontTmp.Dispose();
}
int intWidth = (int)fltWidth + (Margin.Right <<1);
int intHeight = (int)fltHeight + Margin.Bottom;
this.Size = new Size(intWidth, intHeight);
//System.Drawing.Drawing2D.GraphicsPath path = Editor.RoundCorners.RoundedRectangle(new Rectangle(this.Location, this.Size), 10);
//g.DrawPath(new Pen(Color.Black,2F), path);
//this.Region = Editor.RoundCorners.RoundedRegion(this.Size, 4);
}
catch
{
}
}
public static SizeF MeasureTextVisible(Graphics graphics, string text, Font font)
{
StringFormat format = new StringFormat();
RectangleF rect = new RectangleF(0, 0, 4096, 1000);
CharacterRange[] ranges = { new CharacterRange(0, text.Length) };
format.SetMeasurableCharacterRanges(ranges);
Region[] regions = graphics.MeasureCharacterRanges(text, font, rect, format);
rect = regions[0].GetBounds(graphics);
return new SizeF(rect.Width, rect.Height);
}
public static Size MeasureTextIncludingSpaces(Graphics graphics, string text, Font font)
{
SizeF sizePostfix = MeasureTextVisible(graphics, "|", font);
SizeF size = MeasureTextVisible(graphics, text + "|", font);
return new Size((int)(size.Width - sizePostfix.Width + 1), (int)(size.Height + 1));
}
protected override void OnPaint(PaintEventArgs e)
{
SafePaint(e);
}
protected override void OnPaintBackground(PaintEventArgs e)
{
// base.OnPaintBackground(e);
}
}
}

120
trunk/Editor/RichLabel.resx Normal file
View file

@ -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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View file

@ -0,0 +1,189 @@
using System;
//Author: Arman Ghazanchyan
//Created date: 01/27/2007
//Last updated: 01/28/2007
using System.Drawing;
using System.Drawing.Drawing2D;
namespace LSLEditor.Editor
{
class RoundCorners
{
///<summary>
/// Rounds a rectangle corners' and returns the graphics path.
/// </summary>
/// <param name="rec">A rectangle whose corners should be rounded.</param>
/// <param name="r">The radius of the rounded corners. This value should be
/// bigger then 0 and less or equal to the (a half of the smallest value
/// of the rectangles width and height).</param>
/// <param name="exclude_TopLeft">A value that specifies if the top-left
/// corner of the rectangle should be rounded. If the value is True
/// then the corner is not rounded otherwise it is.</param>
/// <param name="exclude_TopRight">A value that specifies if the top-right
/// corner of the rectangle should be rounded. If the value is True
/// then the corner is not rounded otherwise it is.</param>
/// <param name="exclude_BottomRight">A value that specifies if the bottom-right
/// corner of the rectangle should be rounded. If the value is True
/// then the corner is not rounded otherwise it is.</param>
/// <param name="exclude_BottomLeft">A value that specifies if the bottom-left
/// corner of the rectangle should be rounded. If the value is True
/// then the corner is not rounded otherwise it is.</param>
public static GraphicsPath RoundedRectangle(Rectangle rec, int r)
{
return RoundedRectangle(rec,r,false,false,false,false);
}
public static GraphicsPath RoundedRectangle(Rectangle rec, int r,
bool exclude_TopLeft,
bool exclude_TopRight,
bool exclude_BottomRight,
bool exclude_BottomLeft)
{
GraphicsPath path = new GraphicsPath();
int s = r * 2;
//If 's' is less than or equal to zero,
//then return a simple rectangle.
if (s <= 0)
{
path.StartFigure();
path.AddLine(rec.Right, rec.Y, rec.Right, rec.Y);
path.AddLine(rec.Right, rec.Bottom, rec.Right, rec.Bottom);
path.AddLine(rec.X, rec.Bottom, rec.X, rec.Bottom);
path.AddLine(rec.X, rec.Y, rec.X, rec.Y);
path.CloseAllFigures();
return path;
}
//If 's' is bigger than the smallest value of the size,
//then assign the value to 's'.
if (rec.Height <= rec.Width)
{
if (s > rec.Height)
s = rec.Height;
}
else
{
if (s > rec.Width)
s = rec.Width;
}
path.StartFigure();
//Set top-right corner.
if (!exclude_TopRight)
path.AddArc(rec.Right - s, rec.Y, s, s, 270, 90);
else
path.AddLine(rec.Right, rec.Y, rec.Right, rec.Y);
//Set bottom-right corner.
if (!exclude_BottomRight)
path.AddArc(rec.Right - s, rec.Bottom - s, s, s, 0, 90);
else
path.AddLine(rec.Right, rec.Bottom, rec.Right, rec.Bottom);
//Set bottom-left corner.
if (!exclude_BottomLeft)
path.AddArc(rec.X, rec.Bottom - s, s, s, 90, 90);
else
path.AddLine(rec.X, rec.Bottom, rec.X, rec.Bottom);
//Set top-left corner.
if (!exclude_TopLeft)
path.AddArc(rec.X, rec.Y, s, s, 180, 90);
else
path.AddLine(rec.X, rec.Y, rec.X, rec.Y);
path.CloseAllFigures();
return path;
}
/// <summary>
/// Rounds the corners of the newly created rectangle-shape region and returns the region.
/// </summary>
/// <param name="rSize">The size of the region.</param>
/// <param name="r">The radius of the rounded corners. This value should be
/// bigger then 0 and less or equal to the (a half of the smallest value
/// of the regions width and height).</param>
/// <param name="exclude_TopLeft">A value that specifies if the top-left
/// corner of the region should be rounded. If the value is True
/// then the corner is not rounded otherwise it is.</param>
/// <param name="exclude_TopRight">A value that specifies if the top-right
/// corner of the region should be rounded. If the value is True
/// then the corner is not rounded otherwise it is.</param>
/// <param name="exclude_BottomRight">A value that specifies if the bottom-right
/// corner of the region should be rounded. If the value is True
/// then the corner is not rounded otherwise it is.</param>
/// <param name="exclude_BottomLeft">A value that specifies if the bottom-left
/// corner of the region should be rounded. If the value is True
/// then the corner is not rounded otherwise it is.</param>
public static Region RoundedRegion(Size rSize, int r)
{
return RoundedRegion(rSize, r, false, false, false, false);
}
public static Region RoundedRegion(Size rSize, int r,
bool exclude_TopLeft,
bool exclude_TopRight,
bool exclude_BottomRight,
bool exclude_BottomLeft)
{
int s = r * 2;
GraphicsPath path = new GraphicsPath();
//If 's' is less than or equal to zero,
//then return a simple rectangle.
if (s <= 0)
{
path.StartFigure();
path.AddLine(rSize.Width, 0, rSize.Width, 0);
path.AddLine(rSize.Width, rSize.Height, rSize.Width, rSize.Height);
path.AddLine(0, rSize.Height, 0, rSize.Height);
path.AddLine(0, 0, 0, 0);
path.CloseAllFigures();
return new Region(path);
}
//If 's' is bigger than the smallest value of the size,
//then assign the value to 's'.
if (rSize.Height < rSize.Width)
{
if (s > rSize.Height)
s = rSize.Height;
}
else
{
if (s > rSize.Width)
s = rSize.Width;
}
path.StartFigure();
//Set top-right corner.
if (!exclude_TopRight)
path.AddArc(rSize.Width - s, 0, s - 1, s - 1, 270, 90);
else
path.AddLine(rSize.Width, 0, rSize.Width, 0);
//Set bottom-right corner.
if (!exclude_BottomRight)
{
path.AddLine(rSize.Width, r, rSize.Width, rSize.Height - r);
path.AddArc(rSize.Width - s, rSize.Height - s, s - 1, s - 1, 0, 90);
}
else
path.AddLine(rSize.Width, rSize.Height, rSize.Width, rSize.Height);
//Set bottom-left corner.
if (!exclude_BottomLeft)
{
path.AddLine(rSize.Width - r, rSize.Height, r, rSize.Height);
path.AddArc(0, rSize.Height - s, s - 1, s - 1, 90, 90);
}
else
path.AddLine(0, rSize.Height, 0, rSize.Height);
//Set top-left corner.
if (!exclude_TopLeft)
path.AddArc(0, 0, s - 1, s - 1, 180, 90);
else
path.AddLine(0, 0, 0, 0);
path.CloseAllFigures();
return new Region(path);
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8" ?>
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<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" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</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>1.0.0.0</value>
</resheader>
<resheader name="Reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="Writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View file

@ -0,0 +1,162 @@
// /**
// ********
// *
// * ORIGIONAL CODE BASE IS Copyright (C) 2006-2010 by Alphons van der Heijden
// * The code was donated on 4/28/2010 by Alphons van der Heijden
// * To Brandon'Dimentox Travanti' Husbands & Malcolm J. Kudra which in turn Liscense under the GPLv2.
// * In agreement to Alphons van der Heijden wishes.
// *
// * The community would like to thank Alphons for all of his hard work, blood sweat and tears.
// * Without his work the community would be stuck with crappy editors.
// *
// * The source code in this file ("Source Code") is provided by The LSLEditor Group
// * to you under the terms of the GNU General Public License, version 2.0
// * ("GPL"), unless you have obtained a separate licensing agreement
// * ("Other License"), formally executed by you and The LSLEditor Group. Terms of
// * the GPL can be found in the gplv2.txt document.
// *
// ********
// * GPLv2 Header
// ********
// * LSLEditor, a External editor for the LSL Language.
// * Copyright (C) 2010 The LSLEditor Group.
//
// * This program is free software; you can redistribute it and/or
// * modify it under the terms of the GNU General Public License
// * as published by the Free Software Foundation; either version 2
// * of the License, or (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program; if not, write to the Free Software
// * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// ********
// *
// * The above copyright notice and this permission notice shall be included in all
// * copies or substantial portions of the Software.
// *
// ********
// */
using System;
using System.Drawing;
using System.ComponentModel;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace LSLEditor
{
public partial class TooltipWindow : Form
{
public string Wild;
public int XOffset = 0;
public override string Text
{
get
{
return base.Text;
}
set
{
base.Text = value;
this.richLabel1.Text = value;
}
}
public TooltipWindow(Form parent)
{
InitializeComponent();
this.Wild = "";
this.Owner = parent;
this.richLabel1.BorderStyle = BorderStyle.FixedSingle;
//this.richLabel1.BackColor = Color.LightGoldenrodYellow;
this.BackColor = Color.LightGoldenrodYellow;
//this.richLabel1.BorderStyle = BorderStyle.None;
this.richLabel1.Tag = "";
this.richLabel1.Text = "";
}
public void SetPosition(Rectangle rect, SyntaxRichTextBox syntaxRichTextBox)
{
//Rectangle rect = Screen.PrimaryScreen.WorkingArea;
Point p = syntaxRichTextBox.GetPositionFromCharIndex(syntaxRichTextBox.SelectionStart);
p = new Point(p.X - 20 + this.XOffset + 2 , p.Y + 2 + syntaxRichTextBox.LineHeight);
Rectangle client = Screen.PrimaryScreen.WorkingArea; // syntaxRichTextBox.ClientRectangle;
if (p.X < client.Left || p.Y < client.Top || p.X > client.Width || p.Y > client.Height)
{
this.Visible = false;
return;
}
Point screen = syntaxRichTextBox.PointToScreen(p);
//if ((screen.Y + this.Height) > rect.Height)
// screen = RichTextBox.PointToScreen(new Point(p.X - 20 + this.XOffset, p.Y - this.Height));
if (screen.Y > rect.Bottom)
{
this.Visible = false;
return;
//screen.Y = rect.Bottom;
}
if (screen.X > rect.Right)
{
this.Visible = false;
return;
//screen.X = rect.Right;
}
if (screen.X < rect.Left)
{
this.Visible = false;
return;
//screen.X = rect.Left;
}
if ((screen.Y) < rect.Top)
{
this.Visible = false;
return;
//screen.Y = rect.Top;
}
this.Location = screen;
}
public void SetPosition(SyntaxRichTextBox syntaxRichTextBox, Point p)
{
Rectangle rect = Screen.PrimaryScreen.WorkingArea;
Point screen = syntaxRichTextBox.PointToScreen(new Point(p.X - 20 , p.Y + syntaxRichTextBox.LineHeight));
if ((screen.Y + this.Height) > rect.Height)
screen = syntaxRichTextBox.PointToScreen(new Point(p.X - 20, p.Y - this.Height));
if ((screen.X + this.Width) > rect.Width)
screen.X = rect.Width - this.Width;
if (screen.X < rect.Left)
screen.X = rect.Left;
if (screen.Y < rect.Top)
screen.Y = rect.Top;
this.Location = screen;
}
private void richLabel1_Resize(object sender, EventArgs e)
{
this.Size = this.richLabel1.Size;
}
}
}

62
trunk/Editor/TooltipWindow.designer.cs generated Normal file
View file

@ -0,0 +1,62 @@
namespace LSLEditor
{
partial class TooltipWindow
{
/// <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.richLabel1 = new LSLEditor.RichLabel();
this.SuspendLayout();
//
// richLabel1
//
this.richLabel1.BackColor = System.Drawing.Color.LightGoldenrodYellow;
this.richLabel1.Location = new System.Drawing.Point(0, 0);
this.richLabel1.Name = "richLabel1";
this.richLabel1.Size = new System.Drawing.Size(52, 20);
this.richLabel1.TabIndex = 0;
this.richLabel1.Resize += new System.EventHandler(this.richLabel1_Resize);
//
// TooltipWindow
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(105, 42);
this.Controls.Add(this.richLabel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "TooltipWindow";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
this.Text = "GListBoxWindow";
this.ResumeLayout(false);
}
#endregion
private RichLabel richLabel1;
}
}

View file

@ -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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>