|
//
// ___ _____ ___ ___ __ __
// / __|_ _/ _ \| _ \ \/ |
// \__ \ | || (_) | / |\/| |
// |___/ |_| \___/|_|_\_| |_|
//
// Storm.TextEditor.dll
// ��������������������
// Storm.TabControl.dll was created under the LGPL
// license. Some of the code was created from scratch,
// some was not. Code not created from scratch was
// based on the DotNetFireball framework and evolved
// from that.
//
// What I mostly did in this library was that I
// cleaned up the code, structured it, documentated
// it and added new features.
//
// Although it might not sound like it, it was very
// hard and took a long (pretty much a shitload)
// time. Why? Well, this was* some of the crappiest,
// most unstructured, undocumentated, ugly code I've
// ever seen. It would actually have taken me less
// time to create it from scratch, but I figured that
// out too late. Figuring out what the code actually
// did and then documentating it was (mostly) a
// day-long process. Well, I hope you enjoy some of
// my hard work. /rant
//
// Of course some/most of it is made from scratch by me.
// *Yes, was. It isn't now. :) Some of the naming
// conventions might still seem a little bit off though.
//
// What is Storm?
// ��������������
// Storm is a set of dynamic link libraries used in
// Theodor "Vestras" Storm Kristensen's application
// "Moonlite".
//
//
// Thanks:
// �������
// - The DotNetFireball team for creating and publishing
// DotNetFireball which I based some of my code on.
//
//
// Copyright (c) Theodor "Vestras" Storm Kristensen 2009
// �����������������������������������������������������
//
namespace Storm.TextEditor.Parsing.Classes
{
using System;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Drawing.Design;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Design;
using System.Diagnostics.SymbolStore;
using System.IO;
using System.Reflection;
using System.Resources;
using System.Text;
using System.Windows.Forms;
using Storm.TextEditor;
using Storm.TextEditor.Controls;
using Storm.TextEditor.Controls.Core;
using Storm.TextEditor.Controls.Core.Globalization;
using Storm.TextEditor.Controls.Core.Timers;
using Storm.TextEditor.Controls.IntelliMouse;
using Storm.TextEditor.Document;
using Storm.TextEditor.Document.Exporters;
using Storm.TextEditor.Forms;
using Storm.TextEditor.Interacting;
using Storm.TextEditor.Painting;
using Storm.TextEditor.Parsing;
using Storm.TextEditor.Parsing.Base;
using Storm.TextEditor.Parsing.Classes;
using Storm.TextEditor.Parsing.Language;
using Storm.TextEditor.Preset;
using Storm.TextEditor.Preset.Painting;
using Storm.TextEditor.Preset.TextDraw;
using Storm.TextEditor.Printing;
using Storm.TextEditor.Utilities;
using Storm.TextEditor.Win32;
/// <summary>
/// TextStyles are used to describe the apperance of text.
/// </summary>
[Editor(typeof (TextStyleUIEditor), typeof (UITypeEditor))]
public class TextStyle : ICloneable
{
#region Members
/// <summary>
/// Gets or sets the name of the style.
/// </summary>
public string Name = null;
private bool _bold;
private bool _italic;
private bool _underline;
private Color _foreColor = Color.Black;
private Color _backColor = Color.Transparent;
public event EventHandler Change = null;
#endregion
#region EventHandlers
protected virtual void OnChange()
{
if (Change != null)
Change(this, EventArgs.Empty);
}
#endregion
#region Properties
/// <summary>
/// Gets or sets if the style uses a bold font.
/// </summary>
[Category("Font")]
[Description("Gets or Sets if the style uses a BOLD font")]
public bool Bold
{
get { return _bold; }
set
{
_bold = value;
OnChange();
}
}
/// <summary>
/// Gets or sets if the style uses an italic font.
/// </summary>
[Category("Font")]
[Description("Gets or Sets if the style uses an ITALIC font")]
public bool Italic
{
get { return _italic; }
set
{
_italic = value;
OnChange();
}
}
/// <summary>
/// Gets or sets if the style uses an underlined font.
/// </summary>
[Category("Font")]
[Description("Gets or Sets if the style uses an UNDERLINED font")]
public bool Underline
{
get { return _underline; }
set
{
_underline = value;
OnChange();
}
}
/// <summary>
/// Gets or sets the foreground color of the style.
/// </summary>
[Category("Color")]
[Description("Gets or Sets the fore color of the style")]
public Color ForeColor
{
get { return _foreColor; }
set
{
_foreColor = value;
OnChange();
}
}
/// <summary>
/// Gets or sets the background color of the style.
/// </summary>
[Category("Color")]
[Description("Gets or Sets the background color of the style")]
public Color BackColor
{
get { return _backColor; }
set
{
_backColor = value;
OnChange();
}
}
/// <summary>
/// Gets whether no color have been assigned to the BackColor.
/// </summary>
[Browsable(false)]
public bool Transparent
{ get { return (BackColor.A == 0); } }
#endregion
/// <summary>
/// Initializes the TextStyle.
/// </summary>
public TextStyle()
{
ForeColor = Color.Black;
BackColor = Color.Transparent;
}
public override string ToString()
{
if (Name == null)
return "TextStyle";
return Name;
}
#region ICloneable Members
public object Clone()
{
TextStyle ts = new TextStyle();
ts.BackColor = BackColor;
ts.Bold = Bold;
ts.ForeColor = ForeColor;
ts.Italic = Italic;
ts.Underline = Underline;
ts.Name = Name;
return ts;
}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.