This commit is contained in:
Jsj 2007-11-20 20:26:30 +00:00
parent 6e00716c47
commit be6a6eb47e
25 changed files with 6195 additions and 0 deletions

View File

@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Volian.Controls.Library
{
class AlphabeticalNumbering
{
//private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private static string Letter(int number)
{
char c = (char)(number + 64);
return c.ToString();
}
public static string Convert(int number)
{
string retval=string.Empty;
if (number > 26) retval += Letter((number-1) / 26);
retval += Letter(1 + ((number-1) % 26));
return retval;
}
//private static int[] _TestLetters = new int[] {
// 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,
// 52,53,78,79,104,105
// };
//public static void ShowLetters()
//{
// for (int i = 0; i < _TestLetters.Length; i++)
// {
// if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("{0},{1}", _TestLetters[i], Convert(_TestLetters[i]));
// }
//}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,115 @@
namespace Volian.Controls.Library
{
partial class DisplayItem
{
/// <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.components = new System.ComponentModel.Container();
this.lblTab = new System.Windows.Forms.Label();
this._DisplayRTB = new Volian.Controls.Library.DisplayRTB(this.components);
this.vlnExp = new Volian.Controls.Library.vlnExpander();
this.SuspendLayout();
//
// lblTab
//
this.lblTab.BackColor = System.Drawing.Color.Transparent;
this.lblTab.Location = new System.Drawing.Point(20, 0);
this.lblTab.Name = "lblTab";
this.lblTab.Size = new System.Drawing.Size(61, 23);
this.lblTab.TabIndex = 3;
this.lblTab.Visible = false;
this.lblTab.MouseDown += new System.Windows.Forms.MouseEventHandler(this.lblTab_MouseDown);
//
// _DisplayRTB
//
this._DisplayRTB.AdjustSize = new System.Drawing.Size(0, 0);
this._DisplayRTB.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this._DisplayRTB.BackColor = System.Drawing.Color.Linen;
this._DisplayRTB.BorderStyle = System.Windows.Forms.BorderStyle.None;
this._DisplayRTB.ContentsRectangle = new System.Drawing.Rectangle(0, 0, 0, 0);
this._DisplayRTB.EpMode = VEPROMS.CSLA.Library.E_EditPrintMode.EDIT;
this._DisplayRTB.Font = new System.Drawing.Font("Prestige Elite Tall", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(2)));
this._DisplayRTB.Location = new System.Drawing.Point(80, 0);
this._DisplayRTB.MyClassName = "RichEdit20W";
this._DisplayRTB.MyItem = null;
this._DisplayRTB.Name = "_DisplayRTB";
this._DisplayRTB.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.None;
this._DisplayRTB.Size = new System.Drawing.Size(234, 20);
this._DisplayRTB.TabIndex = 2;
this._DisplayRTB.Text = "";
this._DisplayRTB.VwMode = VEPROMS.CSLA.Library.E_ViewMode.EDIT;
this._DisplayRTB.Resize += new System.EventHandler(this.veRichTextBoxText_Resize);
this._DisplayRTB.Enter += new System.EventHandler(this.veRichTextBoxText_Enter);
this._DisplayRTB.LinkGoTo += new Volian.Controls.Library.DisplayRTBLinkEvent(this._DisplayRTB_LinkGoTo);
this._DisplayRTB.Leave += new System.EventHandler(this.veRichTextBoxText_Leave);
this._DisplayRTB.HeightChanged += new Volian.Controls.Library.DisplayRTBEvent(this.veRichTextBoxText_HeightChanged);
//
// vlnExp
//
this.vlnExp.BackColor = System.Drawing.Color.Transparent;
this.vlnExp.BorderColor = System.Drawing.Color.Silver;
this.vlnExp.Color1 = System.Drawing.Color.Aquamarine;
this.vlnExp.Color2 = System.Drawing.Color.Violet;
this.vlnExp.Expanded = false;
this.vlnExp.ForeColor = System.Drawing.SystemColors.ButtonHighlight;
this.vlnExp.GradientAngle = 45;
this.vlnExp.Location = new System.Drawing.Point(3, 3);
this.vlnExp.Name = "vlnExp";
this.vlnExp.PenWidth = 0;
this.vlnExp.Size = new System.Drawing.Size(14, 14);
this.vlnExp.Style = Volian.Controls.Library.ExpanderStyle.Round;
this.vlnExp.TabIndex = 0;
this.vlnExp.Trans1 = 128;
this.vlnExp.Trans2 = 128;
this.vlnExp.WidthFactor = 7;
this.vlnExp.BeforeExpand += new Volian.Controls.Library.vlnExpanderEvent(this.vlnExp_BeforeExpand);
this.vlnExp.BeforeColapse += new Volian.Controls.Library.vlnExpanderEvent(this.vlnExp_BeforeColapse);
this.vlnExp.AttachmentClick += new vlnExpanderEvent(vlnExp_AttachmentClick);
//
// DisplayItem
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.ButtonFace;
this.Controls.Add(this.lblTab);
this.Controls.Add(this._DisplayRTB);
this.Controls.Add(this.vlnExp);
this.Name = "DisplayItem";
this.Size = new System.Drawing.Size(314, 20);
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.lblTab_MouseDown);
this.Move += new System.EventHandler(this.vlnCSLARTB_Move);
this.Resize += new System.EventHandler(this.vlnCSLARTB_Resize);
this.ResumeLayout(false);
}
#endregion
private vlnExpander vlnExp;
private DisplayRTB _DisplayRTB;
private System.Windows.Forms.Label lblTab;
}
}

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,590 @@
using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Windows.Forms;
using VEPROMS.CSLA.Library;
using System.Drawing;
using System.Text.RegularExpressions;
namespace Volian.Controls.Library
{
public partial class DisplayPanel : Panel
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#region Events
public event DisplayPanelEvent ItemClick;
internal void OnItemClick(object sender, DisplayPanelEventArgs args)
{
if (ItemClick != null) ItemClick(sender, args);
}
public event DisplayPanelLinkEvent LinkClicked;
internal void OnLinkClicked(object sender, DisplayLinkEventArgs args)
{
if (LinkClicked != null) LinkClicked(sender, args);
else MessageBox.Show(args.LinkInfo.LinkText, "Unhandled Link Click", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
public event DisplayPanelAttachmentEvent AttachmentClicked;
internal void OnAttachmentClicked(object sender, DisplayPanelAttachmentEventArgs args)
{
if (AttachmentClicked != null) AttachmentClicked(sender, args);
else MessageBox.Show(args.MyDisplayItem.MyItem.MyContent.MyEntry.MyDocument.DocumentTitle, "Unhandled Attachment Click", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
#endregion
#region Constructors
public DisplayPanel()
{
InitializeComponent();
this.Paint += new PaintEventHandler(DisplayPanel_Paint);
this.DoubleClick += new EventHandler(DisplayPanel_DoubleClick);
this.AutoScroll = true;
}
void DisplayPanel_DoubleClick(object sender, EventArgs e)
{
ShowLines = !ShowLines;
Refresh();
}
private void VerticalLine(Graphics g, int x)
{
Pen bluePen = new Pen(Color.CornflowerBlue,1);
g.DrawLine(bluePen, x, 0, x, this.Height);
}
void DisplayPanel_Paint(object sender, PaintEventArgs e)
{
if (ShowLines)
{
//int fifth = Height / 5;
//Rectangle r1 = new Rectangle(0, 0, Width, Height - fifth);
////Brush b = new System.Drawing.Drawing2D.LinearGradientBrush(r1, Color.FromArgb(128, 0, 32), Color.FromArgb(96, 0, 16), 90);
//Brush b = new System.Drawing.Drawing2D.LinearGradientBrush(r1, Color.FromArgb(255,128, 0, 32), Color.FromArgb(255,96, 0, 16),System.Drawing.Drawing2D.LinearGradientMode.Vertical);
//e.Graphics.FillRectangle(b, r1);
//r1 = new Rectangle(0, Height - fifth, Width, fifth);
//b = new System.Drawing.Drawing2D.LinearGradientBrush(r1, Color.FromArgb(255,96, 0, 16), Color.FromArgb(255,128, 0, 32), 90);
//e.Graphics.FillRectangle(b, r1);
//VerticalLine(e.Graphics, 60);
//VerticalLine(e.Graphics, 102);
//VerticalLine(e.Graphics, 415);
}
}
public DisplayPanel(IContainer container)
{
container.Add(this);
InitializeComponent();
this.Paint += new PaintEventHandler(DisplayPanel_Paint);
this.BackColorChanged += new EventHandler(DisplayPanel_BackColorChanged);
this.DoubleClick += new EventHandler(DisplayPanel_DoubleClick);
this.AutoScroll = true;
}
void DisplayPanel_BackColorChanged(object sender, EventArgs e)
{
// Walk through controls & set colors
InactiveColor = PanelColor = BackColor;
foreach (Control ctrl in Controls)
{
if (ctrl.GetType().Name == "vlnCSLARTB")
{
DisplayItem rtb = (DisplayItem)ctrl;
rtb.BackColor = BackColor;
}
}
}
#endregion
#region Business
private StepSectionLayoutData _Layout; // Volian Property Snippet
private ItemInfo _MyItem;
public ItemInfo MyItem
{
get { return _MyItem; }
set
{
//// TIMING: vlnCSLARTB.TimeIt("pMyItem Start");
_MyItem = value;
if(value != null)
_Layout = _MyItem.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData;
//// TIMING: vlnCSLARTB.TimeIt("pMyItem Layout");
//this.Layout += new LayoutEventHandler(DisplayPanel_Layout);
//this.Scroll += new ScrollEventHandler(DisplayPanel_Scroll);
//// TIMING: vlnCSLARTB.TimeIt("pMyItem Scroll");
Controls.Clear();
ItemLookup = new Dictionary<int, DisplayItem>();
//// TIMING: vlnCSLARTB.TimeIt("pMyItem Clear");
//SuspendLayout();
DisplayItem vlnRTF = new DisplayItem(_MyItem, this, null, ChildRelation.None, false);
//ResumeLayout();
//// TIMING: vlnCSLARTB.TimeIt("pMyItem End");
}
}
private Dictionary<int, DisplayItem> _ItemLookup;
public Dictionary<int, DisplayItem> ItemLookup
{
get { return _ItemLookup; }
set { _ItemLookup = value; }
}
public void ExpandAsNeeded(ItemInfo item)
{
int id = item.ItemID;
if (ItemLookup.ContainsKey(id))
{
ItemLookup[id].AutoExpand();
}
else
{
ExpandAsNeeded((ItemInfo)item.ActiveParent);
if (!ItemLookup.ContainsKey(id)) // Expand Parent if not expanded
{
int parentId = ((ItemInfo)item.ActiveParent).ItemID;
ItemLookup[parentId].AutoExpand();
}
}
}
public void ItemSelect(ItemInfo item)
{
int id = item.ItemID;
ExpandAsNeeded(item);
ItemLookup[id].ItemSelect();
}
private int _Scrolling = 0; // Volian Property Snippet
public int Scrolling
{
get { return _Scrolling; }
set { _Scrolling = value; }
}
private DisplayPanelSettings _Settings; // Volian Property Snippet
public DisplayPanelSettings Settings
{
get
{
if (_Settings == null) _Settings = new DisplayPanelSettings(this);
return _Settings;
}
set { _Settings = value;}
}
//void DisplayPanel_Layout(object sender, LayoutEventArgs e)
// {
// //if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("layout {0} {1} {2} {3}", e.AffectedComponent.GetType().Name,e.AffectedControl.Name,e.AffectedProperty, sender.GetType().Name);
// }
//void DisplayPanel_Scroll(object sender, ScrollEventArgs e)
//{
// //if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("scroll {0} {1} {2} {3}", e.OldValue, e.NewValue, e.ScrollOrientation,sender.GetType().Name);
// Scrolling = false;
//}
//public void AdjustOutOfRangeControls(int yAdjust)
//{
// bool scrolling = Scrolling;
// Scrolling = true;
// foreach (Control control in Controls)
// if (control.GetType().Name == "vlnCSLARTB" && control.Top > Height)
// control.Top += yAdjust;
// Scrolling = scrolling;
//}
private int _MaxRNO = -1; // TODO: Need to calculate MaxRNO on a section basis rather than for a panel
public int MaxRNO
{
get
{
if(_MaxRNO == -1)
{
int pmode = Convert.ToInt32(_Layout.PMode) - 1;
_MaxRNO = Convert.ToInt32( _Layout.MaxRNOTable.Split(",".ToCharArray())[pmode]);
}
return _MaxRNO;
}
}
private Font _MyFont =null; // Volian Property Snippet
public Font MyFont
{
get { return _MyFont; }
set { _ProcFont = _SectFont = _StepFont = _MyFont = value; }
}
private Font _ProcFont =new Font("Arial",12,FontStyle.Bold); // Volian Property Snippet
public Font ProcFont
{
get { return _ProcFont; }
set { _ProcFont = value; }
}
private Font _SectFont = new Font("Arial", 10, FontStyle.Bold); // Volian Property Snippet
public Font SectFont
{
get { return _SectFont; }
set { _SectFont = value; }
}
private Font _StepFont = new Font("Arial", 10); // Volian Property Snippet
public Font StepFont
{
get { return _StepFont; }
set { _StepFont = value; }
}
private Color _ActiveColor =Color.SkyBlue; // Volian Property Snippet
public Color ActiveColor
{
get { return _ActiveColor; }
set { _ActiveColor = value; }
}
private Color _InactiveColor =Color.Linen; // Volian Property Snippet
public Color InactiveColor
{
get { return _InactiveColor; }
set { _InactiveColor = value; }
}
private Color _TabColor =Color.Beige; // Volian Property Snippet
public Color TabColor
{
get { return _TabColor; }
set { _TabColor = value; }
}
private Color _PanelColor =Color.LightGray; // Volian Property Snippet
public Color PanelColor
{
get { return _PanelColor; }
set { _PanelColor = value; }
}
private bool _ShowLines =true; // Volian Property Snippet
public bool ShowLines
{
get { return _ShowLines; }
set { _ShowLines = value; }
}
#endregion
#region DisplayConversions
private Graphics _MyGraphics = null;
public Graphics MyGraphics
{
get
{
if (_MyGraphics == null)
_MyGraphics = CreateGraphics();
return _MyGraphics;
}
}
private int _DPI =0; // Volian Property Snippet
public int DPI
{
get
{
if (_DPI == 0)
_DPI = Convert.ToInt32(MyGraphics.DpiX);
return _DPI;
}
}
public int ToDisplay(int value)
{
//return (DPI * value) / 864;
return (DPI * value) / 72;
}
public int ToDisplay(int? value)
{
return ToDisplay((int)value);
}
public int ToDisplay(string value)
{
return ToDisplay(Convert.ToInt32(value));
}
public int ToDisplay(string value,int i)
{
string s = value.Split(",".ToCharArray())[i];
return ToDisplay(s);
}
#endregion
#region Debug Methods
public void ListControls()
{
// Walk through the controls and find the next control for each
if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("'Item','Next'");
foreach (Control control in Controls)
if (control.GetType().Name == "vlnCSLARTB")
{
DisplayItem rtb = (DisplayItem)control;
DisplayItem nxt = rtb.NextItem;
if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("{0},{1}", rtb.MyID, nxt == null ? 0 : nxt.MyID);
}
}
#endregion
}
[TypeConverter(typeof(ExpandableObjectConverter))]
public partial class DisplayPanelSettings
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public DisplayPanelSettings(DisplayPanel panel)
{
_Panel = panel;
}
public DisplayPanelSettings()
{
}
private DisplayPanel _Panel;
[Browsable(false)]
public DisplayPanel Panel
{
get { return _Panel; }
set { _Panel = value; }
}
private float _CircleXOffset = -4;
[Category("Circle")]
[DisplayName("Circle Horizontal Offset")]
public float CircleXOffset
{
get { return _CircleXOffset; }
set { _CircleXOffset = value; if (_Panel != null) _Panel.Refresh(); }
}
private float _CircleYOffset = -13;
[Category("Circle")]
[DisplayName("Circle Vertical Offset")]
public float CircleYOffset
{
get { return _CircleYOffset; }
set { _CircleYOffset = value; if (_Panel != null) _Panel.Refresh(); }
}
private Font _CircleFont = new Font("Arial Unicode MS", 23); // Volian Property Snippet
[Category("Circle")]
[DisplayName("Circle Font")]
public Font CircleFont
{
get { return _CircleFont; }
set { _CircleFont = value; if(_Panel != null) _Panel.Refresh(); }
}
private Color _CircleColor = Color.Black;
[Category("Circle")]
[DisplayName("Circle Color")]
public Color CircleColor
{
get { return _CircleColor; }
set { _CircleColor = value; if (_Panel != null) _Panel.Refresh(); }
}
private int _CircleDiameter = 25;
[Category("Circle")]
[DisplayName("Circle Diameter")]
public int CircleDiameter
{
get { return _CircleDiameter; }
set { _CircleDiameter = value; if (_Panel != null) _Panel.Refresh(); }
}
private int _CircleWeight = 2;
[Category("Circle")]
[DisplayName("Circle Pen Weight")]
public int CircleWeight
{
get { return _CircleWeight; }
set { _CircleWeight = value; if (_Panel != null) _Panel.Refresh(); }
}
private float _NumberLocationX = 20F;
[Category("Number")]
[DisplayName("Number Location X")]
public float NumberLocationX
{
get { return _NumberLocationX; }
set { _NumberLocationX = value; if (_Panel != null) _Panel.Refresh(); }
}
private float _NumberLocationY = 4;
[Category("Number")]
[DisplayName("Number Location Y")]
public float NumberLocationY
{
get { return _NumberLocationY; }
set { _NumberLocationY = value; if (_Panel != null) _Panel.Refresh(); }
}
private SizeF _NumberSize = new SizeF(200F, 23F);
[Category("Number")]
[DisplayName("Number Size")]
public SizeF NumberSize
{
get { return _NumberSize; }
set { _NumberSize = value; if (_Panel != null) _Panel.Refresh(); }
}
private int _TableWidthAdjust = 4;
[Category("Table")]
[DisplayName("Table Width Adjust")]
public int TableWidthAdjust
{
get { return _TableWidthAdjust; }
set { _TableWidthAdjust = value; if (_Panel != null) _Panel.Refresh(); }
}
private int _CheckOffWeight = 1;
[Category("CheckOff")]
[DisplayName("CheckOff Pen Weight")]
public int CheckOffWeight
{
get { return _CheckOffWeight; }
set { _CheckOffWeight = value; if (_Panel != null) _Panel.Refresh(); }
}
private Color _CheckOffColor = Color.Black;
[Category("CheckOff")]
[DisplayName("CheckOff Color")]
public Color CheckOffColor
{
get { return _CheckOffColor; }
set { _CheckOffColor = value; if (_Panel != null) _Panel.Refresh(); }
}
private int _CheckOffSize =12;
[Category("CheckOff")]
[DisplayName("CheckOff Size")]
public int CheckOffSize
{
get { return _CheckOffSize; }
set { _CheckOffSize = value; if (_Panel != null) _Panel.Refresh(); }
}
private int _CheckOffX =0;
[Category("CheckOff")]
[DisplayName("CheckOff X")]
public int CheckOffX
{
get { return _CheckOffX; }
set { _CheckOffX = value; if (_Panel != null) _Panel.Refresh(); }
}
private int _CheckOffY =5; // Volian Property Snippet
[Category("CheckOff")]
[DisplayName("CheckOff Y")]
public int CheckOffY
{
get { return _CheckOffY; }
set { _CheckOffY = value; if (_Panel != null) _Panel.Refresh(); }
}
private int _ChangeBarWeight = 1;
[Category("ChangeBar")]
[DisplayName("ChangeBar Pen Weight")]
public int ChangeBarWeight
{
get { return _ChangeBarWeight; }
set { _ChangeBarWeight = value; if (_Panel != null) _Panel.Refresh(); }
}
private Color _ChangeBarColor = Color.Black;
[Category("ChangeBar")]
[DisplayName("ChangeBar Color")]
public Color ChangeBarColor
{
get { return _ChangeBarColor; }
set { _ChangeBarColor = value; if (_Panel != null) _Panel.Refresh(); }
}
}
public partial class DisplayPanelEventArgs
{
private DisplayItem _MyVlnCSLARTB; // Volian Property Snippet
public DisplayItem MyVlnCSLARTB
{
get { return _MyVlnCSLARTB; }
set { _MyVlnCSLARTB = value; }
}
private MouseEventArgs _MyMouseEventArgs; // Volian Property Snippet
public MouseEventArgs MyMouseEventArgs
{
get { return _MyMouseEventArgs; }
set { _MyMouseEventArgs = value; }
}
public DisplayPanelEventArgs(DisplayItem myVlnCSLARTB, MouseEventArgs myMouseEventArgs)
{
_MyVlnCSLARTB = myVlnCSLARTB;
_MyMouseEventArgs = myMouseEventArgs;
}
}
public partial class DisplayPanelAttachmentEventArgs
{
private DisplayItem _MyDisplayItem; // Volian Property Snippet
public DisplayItem MyDisplayItem
{
get { return _MyDisplayItem; }
set { _MyDisplayItem = value; }
}
public DisplayPanelAttachmentEventArgs(DisplayItem myDisplayItem)
{
_MyDisplayItem = myDisplayItem;
}
}
public partial class DisplayLinkEventArgs : EventArgs
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private DisplayItem _LinkedRTB; // Volian Property Snippet
public DisplayItem LinkedRTB
{
get { return _LinkedRTB; }
set { _LinkedRTB = value; }
}
private LinkClickedEventArgs _LinkInfo; // Volian Property Snippet
public LinkClickedEventArgs LinkInfo
{
get { return _LinkInfo; }
set { _LinkInfo = value; }
}
public DisplayLinkEventArgs(DisplayItem linkedRTB, LinkClickedEventArgs linkInfo)
{
LinkedRTB = linkedRTB;
LinkInfo = linkInfo;
//if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("\r\n LinkInfo '{0}'\r\n", linkInfo.LinkText);
}
private void ParseLink()
{
if (_Type == ParsedLinkType.NotParsed)
{
// First parse the string
Match m = Regex.Match(_LinkInfo.LinkText, ".*[#]Link:([A-Za-z]*):(.*)");
switch (m.Groups[1].Value)
{
case "ReferencedObject":
_Type = ParsedLinkType.ReferencedObject;
_RoUsageid = m.Groups[2].Value;
_Roid = m.Groups[3].Value;
break;
case "Transition":
case "TransitionRange":
_Type = (ParsedLinkType)Enum.Parse(_Type.GetType(), m.Groups[1].Value);
if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("Link String - '{0}'", m.Groups[2].Value);
int transitionID = Convert.ToInt32(m.Groups[2].Value.Split(" ".ToCharArray())[1]);
foreach (TransitionInfo ti in _LinkedRTB.MyItem.MyContent.ContentTransitions)
{
if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("Transition ID = '{0}'", ti.TransitionID);
if (ti.TransitionID == transitionID)
_MyTransition = ti;
}
break;
}
}
}
private TransitionInfo _MyTransition = null; // Volian Property Snippet
public TransitionInfo MyTransition
{
get { ParseLink(); return _MyTransition; }
}
public ItemInfo ItemTo
{
get { ParseLink(); return _MyTransition.MyItemToID; }
}
public ItemInfo ItemRange
{
get { ParseLink(); return _MyTransition.MyItemRangeID; }
}
private string _Roid = null; // TODO: need to return Referenced Object rather than just roid
public string Roid
{
get { ParseLink(); return _Roid; }
}
private string _RoUsageid = null; // TODO: need to return Referenced Object rather than just roid
public string RoUsageid
{
get { ParseLink(); return _RoUsageid; }
}
private ParsedLinkType _Type = ParsedLinkType.NotParsed; // Volian Property Snippet
public ParsedLinkType Type
{
get { ParseLink(); return _Type; }
}
}
#region enums
public enum ParsedLinkType : int
{
NotParsed = 0,
Transition = 1,
TransitionRange = 2,
ReferencedObject = 3
}
#endregion
public delegate void DisplayPanelEvent(object sender, DisplayPanelEventArgs args);
public delegate void DisplayPanelLinkEvent(object sender, DisplayLinkEventArgs args);
public delegate void DisplayPanelAttachmentEvent(object sender, DisplayPanelAttachmentEventArgs args);
public delegate void DisplayRTBLinkEvent(object sender, LinkClickedEventArgs e);
}

View File

@ -0,0 +1,36 @@
namespace Volian.Controls.Library
{
partial class DisplayPanel
{
/// <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
}
}

View File

@ -0,0 +1,665 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using VEPROMS.CSLA.Library;
namespace Volian.Controls.Library
{
public delegate void DisplayRTBEvent(object sender, EventArgs args);
public partial class DisplayRTB : RichTextBox
{
#region Properties and Variables
// use newer rich text box....
//[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
//static extern IntPtr LoadLibrary(string lpFileName);
//protected override CreateParams CreateParams
//{
// get
// {
// CreateParams prams = base.CreateParams;
// if (LoadLibrary("msftedit.dll") != IntPtr.Zero)
// {
// //prams.ExStyle |= 0x020; // transparent
// prams.ClassName = "RICHEDIT50W";
// }
// return prams;
// }
//}
private IContainer _Container = null;
private string _MyClassName=string.Empty;
public string MyClassName
{
get { if (_MyClassName == string.Empty)_MyClassName = CreateParams.ClassName; return _MyClassName; }
set { _MyClassName = value; }
}
private E_EditPrintMode _epMode = E_EditPrintMode.EDIT;
public E_EditPrintMode EpMode
{
get { return _epMode; }
set { _epMode = value; }
}
private E_ViewMode _vwMode = E_ViewMode.EDIT;
public E_ViewMode VwMode
{
get { return _vwMode; }
set { _vwMode = value; }
}
private ItemInfo _MyItem;
public ItemInfo MyItem
{
get { return _MyItem; }
set
{
_MyItem = value;
if (value != null)
{
DisplayText vlntxt = new DisplayText(_MyItem, EpMode, VwMode);
_origVlnText = vlntxt;
// TODO: RHM20071115 this.Font = _origVlnText.TextFont.WindowsFont;
AddRtfText(vlntxt);
ReadOnly = !(EpMode == E_EditPrintMode.EDIT && VwMode == E_ViewMode.EDIT);
RTBAPI.SetLineSpacing(this, RTBAPI.ParaSpacing.PFS_EXACT);
}
}
}
//public EnterKeyHandler EnterKeyPressed;
//protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
//{
// const int WM_KEYDOWN = 0x100;
// const int WM_SYSKEYDOWN = 0x104;
// if ((msg.Msg == WM_KEYDOWN) || (msg.Msg == WM_SYSKEYDOWN))
// {
// switch (keyData)
// {
// case Keys.Control | Keys.V:
// // check for valid data to be inserted:
// return base.ProcessCmdKey(ref msg, keyData);
// default:
// return base.ProcessCmdKey(ref msg, keyData);
// }
// }
// return base.ProcessCmdKey(ref msg, keyData);
//}
private Point ScrollPos
{
get { return RTBAPI.GetScrollLocation(this); }
set { RTBAPI.SetScrollLocation(this, value); }
}
private Rectangle _ContentsRectangle;
public Rectangle ContentsRectangle
{
get { return _ContentsRectangle; }
set
{
_ContentsRectangle = value;
AdjustSizeForContents();
}
}
public Size ContentsSize
{
get { return _ContentsRectangle.Size; }
}
private Size _AdjustSize; // if 0,0 puts text right next to bottom of box.
public Size AdjustSize
{
get { return _AdjustSize; }
set
{
_AdjustSize = value;
AdjustSizeForContents();
}
}
public System.Windows.Forms.AutoScaleMode AutoScaleMode;
private DisplayText _origVlnText;
private RichTextBox _rtbTemp = new RichTextBox();
private string _eLinkText;
#endregion
#region HeightSupport
public event DisplayRTBEvent HeightChanged;
private void OnHeightChanged(object sender, EventArgs args)
{
if (HeightChanged != null) HeightChanged(sender, args);
}
private void AdjustSizeForContents()
{
//Console.WriteLine("Size {0} Client {1} New {2}", Size, ClientRectangle, ContentsRectangle);
// I want the client size to match the new rectangle.
// First I need to determine the offset
Size offset = Size - ClientSize;
this.Size = ContentsSize + offset + AdjustSize;
OnHeightChanged(this, new EventArgs());
}
#endregion
#region Constructors
/// <summary>
/// vlnRichTextBox constructor:
/// Creates a RichTextBox with extra support for veproms editing/printing.
/// Arguments are:
/// string txtbxname - name to give box (is this needed)
/// ItemInfo itm - Item for which box is created
/// int x,y - starting position for box
/// int iwid - width of box
/// int tbindx - tab index
/// E_EditPrintMode ep_mode - edit or print.
/// E_ViewMode vw_mode - view or edit.
/// </summary>
public DisplayRTB(string txtbxname, ItemInfo itemInfo, int x, int y, int iwid, int tbindx, E_EditPrintMode epMode, E_ViewMode vwMode)
{
try
{
EpMode = epMode;
VwMode = vwMode;
DisplayText vlntxt = new DisplayText(itemInfo, epMode, vwMode);
_origVlnText = vlntxt;
InitializeComponent();
Location = new System.Drawing.Point(x, y);
Name = txtbxname;
DetectUrls = false;
// TODO: RHM20071115 Font = _origVlnText.TextFont.WindowsFont;
ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.None;
Width = iwid;
ContentsResized += new ContentsResizedEventHandler(vlnRichTextBox_ContentsResized);
AddRtfText(vlntxt);
//ContextMenuStrip = contextMenuStrip;
ReadOnly = !(epMode == E_EditPrintMode.EDIT && vwMode == E_ViewMode.EDIT);
RTBAPI.SetLineSpacing(this, RTBAPI.ParaSpacing.PFS_EXACT);
this.LinkClicked += new LinkClickedEventHandler(onLinkClicked);
this.KeyPress += new KeyPressEventHandler(onKeyPress);
this.KeyDown += new KeyEventHandler(onKeyDown);
this.Leave += new EventHandler(DisplayRTB_Leave);
}
catch (Exception ex)
{
Console.WriteLine("Error in creating vlnRichTextBox: " + ex.Message);
}
}
public DisplayRTB()
{
InitializeComponent();
SetUp();
}
public DisplayRTB(IContainer container)
{
container.Add(this);
InitializeComponent();
_Container = container;
SetUp();
}
private void SetUp()
{
BorderStyle = System.Windows.Forms.BorderStyle.None;
this.DetectUrls = true;
ContextMenuStrip = contextMenuStrip;
ContentsResized += new ContentsResizedEventHandler(vlnRichTextBox_ContentsResized);
this.LinkClicked += new LinkClickedEventHandler(onLinkClicked);
this.KeyPress += new KeyPressEventHandler(onKeyPress);
this.KeyDown += new KeyEventHandler(onKeyDown);
this.Leave += new EventHandler(DisplayRTB_Leave);
}
#endregion
#region ApplicationSupport
public void ToggleViewEdit()
{
ItemInfo tmp = MyItem;
MyItem = null;
ReadOnly = !ReadOnly;
EpMode = ReadOnly?E_EditPrintMode.PRINT:E_EditPrintMode.EDIT;
VwMode = ReadOnly?E_ViewMode.VIEW:E_ViewMode.EDIT;
Clear();
MyItem = tmp;
}
public void InsertRO(string value, string link)
{
AddRtfLink(value, link);
}
public void InsertTran(string value, string link)
{
AddRtfLink(value, link);
}
public void InsertSymbol(string symbol)
{
AddSymbol(symbol);
}
#endregion
#region SaveData
public void Save()
{
// TODO: RHM20071115 bool success = _origVlnText.Save((RichTextBox) this);
}
#endregion
#region AddRtfText
private void AddRtfText(DisplayText vlntext)
{
foreach (displayTextElement vte in vlntext.DisplayTextElementList)
{
if (vte.Type == E_TextElementType.TEXT)
AddRtf(vte);
else if (vte.Type == E_TextElementType.SYMBOL)
AddSymbol(vte);
else
AddRtfLink((displayLinkElement)vte);
}
}
private void AddRtf(displayTextElement vte)
{
SelectedRtf = @"{\rtf1{\fonttbl{\f0\fcharset2 "+this.Font.FontFamily.Name+@";}}\f0\fs" + this.Font.SizeInPoints*2 + " " + vte.Text + @"}}";
}
private void AddRtf(string str)
{
SelectedRtf = @"{\rtf1{\fonttbl{\f0\fcharset2 " + this.Font.FontFamily.Name + @";}}\f0\fs" + this.Font.SizeInPoints * 2 + " " + str + @"}}";
}
private void AddSymbol(displayTextElement vte)
{
SelectedRtf = @"{\rtf1{\fonttbl{\f0\fcharset0 Arial Unicode MS;}}\f0\fs" + this.Font.SizeInPoints * 2 + " " + vte.Text + @"}";
}
private void AddSymbol(string str)
{
SelectedRtf = @"{\rtf1{\fonttbl{\f0\fcharset0 Arial Unicode MS;}}\f0\fs" + this.Font.SizeInPoints * 2 + " " + /* ConvertUnicodeChar(str) */ str + @"}";
}
private void AddRtfLink(displayLinkElement vte)
{
if (CreateParams.ClassName == "RICHEDIT50W")
AddLink50(vte.Text, vte.Link);
else
AddLink20(vte.Text, vte.Link);
}
public void AddRtfLink(string linkUrl, string linkValue)
{
if (CreateParams.ClassName == "RICHEDIT50W")
AddLink50(linkUrl, linkValue);
else
AddLink20(linkUrl, linkValue);
}
private void AddLink20(string linkValue, string linkUrl)
{
this.DetectUrls = false;
RTBAPI.CharFormatTwo charFormat = RTBAPI.GetCharFormat(this, RTBAPI.RTBSelection.SCF_SELECTION);
int position = SelectionStart = this.TextLength;
SelectionLength = 0;
SelectedRtf = @"{\rtf1\ansi " + linkValue + @"\v " + linkUrl + @"\v0}";
Select(position, linkValue.Length + linkUrl.Length + 1);
// Protect the link text to avoid manual changes
charFormat.dwMask = RTBAPI.CharFormatMasks.CFM_LINK | RTBAPI.CharFormatMasks.CFM_PROTECTED;
charFormat.dwEffects = RTBAPI.CharFormatEffects.CFE_LINK | RTBAPI.CharFormatEffects.CFE_PROTECTED;
RTBAPI.SetCharFormat((RichTextBox)this, RTBAPI.RTBSelection.SCF_SELECTION, charFormat);
this.SelectionStart = this.TextLength;
this.SelectionLength = 0;
}
private void AddLink50(string linkValue, string linkUrl)
{
this.DetectUrls = false;
int position = SelectionStart = this.TextLength;
SelectionLength = 0;
SelectedRtf = string.Format(@"{{\rtf\field{{\*\fldinst{{HYPERLINK ""www.volian.com #{0}"" }}}}{{\fldrslt{{\cf2\ul {1}}}}}}}", linkUrl, linkValue);
this.SelectionStart = this.TextLength;
this.SelectionLength = 0;
}
#endregion
#region CalculateHeight
public int CalculateHeight()
{
if (this.CreateParams.ClassName == "RICHEDIT50W")
return CalculateHeight50();
else
return CalculateHeight20();
}
private int CalculateHeight20()
{
Application.DoEvents();
int yBottom = GetPositionFromCharIndex(TextLength).Y;
int yTop = GetPositionFromCharIndex(0).Y;
int heightFont = SelectionFont.Height;
int borderSize = this.Height - this.ClientSize.Height;
int heightNext = (yBottom - yTop) + heightFont + borderSize + 2;// 2 pixels - 1 at the top and 1 at the bottom
if (heightNext != Height)
{
Height = heightNext;
OnHeightChanged(this, new EventArgs());
ScrollPos = new Point(0, 0); // Scroll to make sure that the first line is displayed as the first line
}
return heightNext;
}
private int CalculateHeight50()
{
Application.DoEvents();
int heightFont = SelectionFont.Height;
int borderSize = this.Height - this.ClientSize.Height;
//for (int i = 235; i < TextLength; i++)
//{
// Console.WriteLine("{0}\t{1}\t{2}", i, GetLineFromCharIndex(i), GetPositionFromCharIndex(i));
//}
int heightNext = (1 + GetLineFromCharIndex(TextLength)) * heightFont + borderSize + 2;// 2 pixels - 1 at the top and 1 at the bottom
return heightNext;
}
#endregion
#region ColorSupport - Not currently used.
private void SetBackGroundColor(ItemInfo itemInfo)
{
string backcolor = null;
int type = (int)itemInfo.MyContent.Type;
FormatInfo formatinfo = itemInfo.ActiveFormat;
if (type == (int)E_FromType.Procedure)
backcolor = formatinfo.PlantFormat.FormatData.ProcData.BackColor;
else if (type == (int)E_FromType.Section)
backcolor = formatinfo.PlantFormat.FormatData.SectData.BackColor;
else
{
int typindx = (int)itemInfo.MyContent.Type - 20000; // what to do for other types rather than steps
backcolor = formatinfo.PlantFormat.FormatData.StepDataList[typindx].StepLayoutData.BackColor;
}
BackColor = Color.FromName(backcolor);
}
#endregion
#region EventSupport
private LinkClickedEventArgs _LinkClickedEventArgs;
public event DisplayRTBLinkEvent LinkGoTo;
private void OnLinkGoTo(object sender, LinkClickedEventArgs args)
{
_LinkClickedEventArgs = args;
Console.WriteLine("DisplayRTB " + _LinkClickedEventArgs.LinkText);
if (LinkGoTo != null) LinkGoTo(sender, args);
}
void DisplayRTB_Leave(object sender, EventArgs e)
{
// Save returns true if text was not changed or if change was saved successfully.
if (ReadOnly) return;
// TODO: RHM20071115 bool success = _origVlnText.Save((RichTextBox)this);
// TODO: RHM20071115 if (!success) Console.WriteLine("Failed to save text: {0}", this.Text);
}
private Point _savcurpos;
private void onLinkClicked(object sender, System.Windows.Forms.LinkClickedEventArgs e)
{
if (ReadOnly) return;
_LinkClickedEventArgs = e;
_eLinkText = e.LinkText;
_savcurpos = Cursor.Position;
if (e.LinkText.IndexOf("ReferencedObject") > -1)
this.contextMenuStripROs.Show(System.Windows.Forms.Cursor.Position);
else
this.contextMenuStripTrans.Show(System.Windows.Forms.Cursor.Position);
}
private void SelectLink(string LinkText)
{
Point cp = PointToClient(_savcurpos);
int index = GetCharIndexFromPosition(cp);
int iMax = index;
int iMin = index;
Select(index, 0);
while (SelectionProtected)
Select(--iMin, 0);
Select(iMin - 1, 1 + LinkText.Length);
SelectionProtected = false;
Select(iMin, LinkText.Length);
}
void vlnRichTextBox_ContentsResized(object sender, ContentsResizedEventArgs e)
{
ContentsRectangle = e.NewRectangle;
}
#region KeyboardHandling
private bool IsControlChar = false;
private void onKeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
if (e.Modifiers == Keys.Control)
{
IsControlChar = true;
switch (e.KeyCode)
{
case Keys.V:
string buff = Clipboard.GetText(TextDataFormat.UnicodeText);
// check if insertable?
Console.WriteLine(String.Format("in switch, keydata = {0}, keyvalue = {1}, buff = {2}", e.KeyData, e.KeyValue, buff));
break;
}
}
}
private void onKeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if (!ReadOnly)
{
// add the character with its font depending on the char....
if (!IsControlChar)
{
if (e.KeyChar == '\b') return; // return on backspace.
// check for symbol - how??
AddRtf(e.KeyChar.ToString());
}
IsControlChar = false;
}
e.Handled = true; // flag that it's been handled, otherwise, will get 2 chars.
}
#endregion
#endregion
#region Font with Styles
private void ToggleFontStyle(FontStyle style, bool att_on)
{
int start = SelectionStart;
int len = SelectionLength;
System.Drawing.Font currentFont;
FontStyle fs;
for (int i = 0; i < len; ++i)
{
Select(start + i, 1);
currentFont = SelectionFont;
fs = currentFont.Style;
//add or remove style
if (!att_on)fs = fs | style;
else fs = fs & ~style;
SelectionFont = new Font(
currentFont.FontFamily,
currentFont.Size,
fs
);
}
}
/// <summary>
/// Returns a Font with:
/// 1) The font applying to the entire selection, if none is the default font.
/// 2) The font size applying to the entire selection, if none is the size of the default font.
/// 3) A style containing the attributes that are common to the entire selection, default regular.
/// </summary>
///
public Font GetFontDetails()
{
//This method should handle cases that occur when multiple fonts/styles are selected
int start = SelectionStart;
int len = SelectionLength;
int TempStart = 0;
if (len <= 1)
{
// Return the selection or default font
if (SelectionFont != null)
return SelectionFont;
else
return Font; // should be default from format.
}
// Step through the selected text one char at a time
// after setting defaults from first char
_rtbTemp.Rtf = SelectedRtf;
//Turn everything on so we can turn it off one by one
FontStyle replystyle =
FontStyle.Bold | FontStyle.Italic | FontStyle.Underline;
// Set reply font, size and style to that of first char in selection.
_rtbTemp.Select(TempStart, 1);
string replyfont = _rtbTemp.SelectionFont.Name;
float replyfontsize = _rtbTemp.SelectionFont.Size;
replystyle = replystyle & _rtbTemp.SelectionFont.Style;
// Search the rest of the selection
for (int i = 1; i < len; ++i)
{
_rtbTemp.Select(TempStart + i, 1);
// Check reply for different style
replystyle = replystyle & _rtbTemp.SelectionFont.Style;
// Check font
if (replyfont != _rtbTemp.SelectionFont.FontFamily.Name)
replyfont = "";
// Check font size
if (replyfontsize != _rtbTemp.SelectionFont.Size)
replyfontsize = (float)0.0;
}
// Now set font and size if more than one font or font size was selected
if (replyfont == "")
replyfont = _rtbTemp.Font.FontFamily.Name;
if (replyfontsize == 0.0)
replyfontsize = _rtbTemp.Font.Size;
// generate reply font
Font reply
= new Font(replyfont, replyfontsize, replystyle);
return reply;
}
#endregion
#region Context Menu Strip
private void contextMenuStrip_Opening(object sender, CancelEventArgs e)
{
Font cfont = GetFontDetails();
menu_Bold.Checked = cfont.Bold;
menu_Underline.Checked = cfont.Underline;
menu_Italics.Checked = cfont.Italic;
menu_Superscript.Checked = RTBAPI.IsSuperScript(this);
menu_Subscript.Checked = RTBAPI.IsSubScript(this);
menu_Bold.Enabled = !ReadOnly;
menu_Underline.Enabled = !ReadOnly;
menu_Italics.Enabled = !ReadOnly;
menu_Superscript.Enabled = !ReadOnly;
menu_Subscript.Enabled = !ReadOnly;
menu_Undo.Enabled = !ReadOnly;
menu_Redo.Enabled = !ReadOnly;
menu_lowercase.Enabled = !ReadOnly;
menu_UPPERCASE.Enabled = !ReadOnly;
menu_TitleCase.Enabled = !ReadOnly;
menu_InsRO.Enabled = !ReadOnly;
menu_InsTran.Enabled = !ReadOnly;
menu_InsSym.Enabled = !ReadOnly;
menu_ToggleView.Enabled = true;
}
private void contextMenuStrip_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
try
{
Font cfont = GetFontDetails();
//if (e.ClickedItem.ToString() == "Paste") DoPaste();
if (e.ClickedItem.ToString() == "Underline") ToggleFontStyle(FontStyle.Underline, cfont.Underline);
else if (e.ClickedItem.ToString() == "Bold") ToggleFontStyle(FontStyle.Bold, cfont.Bold);
else if (e.ClickedItem.ToString() == "Italics") ToggleFontStyle(FontStyle.Italic, cfont.Italic);
else if (e.ClickedItem.ToString() == "Subscript")
RTBAPI.ToggleSubscript(!RTBAPI.IsSubScript(this), this, this.SelectionLength == 0 ? RTBAPI.RTBSelection.SCF_DEFAULT : RTBAPI.RTBSelection.SCF_SELECTION);
else if (e.ClickedItem.ToString() == "Superscript")
RTBAPI.ToggleSuperscript(!RTBAPI.IsSuperScript(this), this, this.SelectionLength == 0 ? RTBAPI.RTBSelection.SCF_DEFAULT : RTBAPI.RTBSelection.SCF_SELECTION);
else if (e.ClickedItem.ToString() == "Undo")
this.Undo();
else if (e.ClickedItem.ToString() == "Redo")
this.Redo();
else if (e.ClickedItem.ToString() == "lowercase")
SetSelectedCase('l');
else if (e.ClickedItem.ToString() == "UPPERCASE")
SetSelectedCase('U');
else if (e.ClickedItem.ToString() == "TitleCase")
SetSelectedCase('T');
else if (e.ClickedItem.ToString() == "Insert RO")
InsertRO("kbr ro", "0000000000000");
else if (e.ClickedItem.ToString() == "Insert Transition")
InsertTran("kbr Tran", "5 3 5");
else if (e.ClickedItem.ToString() == "Insert Symbol")
InsertSymbol(@"\u916?"); // hardcode for now, but should get value from dialog
else if (e.ClickedItem.ToString() == "Toggle View/Edit")
ToggleViewEdit();
//else if (e.ClickedItem.ToString() == "Find text") findit();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void SetSelectedCase(char type)
{
switch (type)
{
case 'l':
SelectedText = SelectedText.ToLower();
break;
case 'U':
SelectedText = SelectedText.ToUpper();
break;
case 'T':
SelectedText = SelectedText.Substring(0,1).ToUpper() + SelectedText.Substring(1, SelectedText.Length - 1).ToLower();
break;
}
}
private void DeleteTransition()
{
SelectLink(_eLinkText);
SelectedText = "";
}
private void ModifyTransition()
{
Console.WriteLine("Modify Transition");
}
private void contextMenuStripTrans_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
if (e.ClickedItem.ToString() == "Delete Transition") DeleteTransition();
else if (e.ClickedItem.ToString() == "Modify Transition") ModifyTransition();
else if (e.ClickedItem.ToString() == "Go To")
{
Console.WriteLine("DisplayRTB:contextMenu:Go TO");
OnLinkGoTo(sender, _LinkClickedEventArgs);
}
}
private void contextMenuStripTrans_Opening(object sender, CancelEventArgs e)
{
menu_GoToTrans.Enabled = true;
menu_DeleteTrans.Enabled = !ReadOnly;
menu_ModifyTrans.Enabled = !ReadOnly;
}
private void contextMenuStripROs_Opening(object sender, CancelEventArgs e)
{
menu_DeleteRO.Enabled = !ReadOnly;
menu_ModifyRO.Enabled = !ReadOnly;
}
private void DeleteRefObj()
{
SelectLink(_eLinkText);
SelectedText = "";
}
private void ModifyRefObj()
{
Console.WriteLine("ModifyRefObj");
}
private void contextMenuStripROs_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
if (e.ClickedItem.ToString() == "Delete RO") DeleteRefObj();
else if (e.ClickedItem.ToString() == "Modify RO") ModifyRefObj();
}
#endregion
}
}

View File

@ -0,0 +1,322 @@
namespace Volian.Controls.Library
{
partial class DisplayRTB
{
/// <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.components = new System.ComponentModel.Container();
this.contextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
this.menu_Bold = new System.Windows.Forms.ToolStripMenuItem();
this.menu_Underline = new System.Windows.Forms.ToolStripMenuItem();
this.menu_Italics = new System.Windows.Forms.ToolStripMenuItem();
this.menu_Superscript = new System.Windows.Forms.ToolStripMenuItem();
this.menu_Subscript = new System.Windows.Forms.ToolStripMenuItem();
this.menu_Undo = new System.Windows.Forms.ToolStripMenuItem();
this.menu_Redo = new System.Windows.Forms.ToolStripMenuItem();
this.menu_lowercase = new System.Windows.Forms.ToolStripMenuItem();
this.menu_UPPERCASE = new System.Windows.Forms.ToolStripMenuItem();
this.menu_TitleCase = new System.Windows.Forms.ToolStripMenuItem();
this.menu_InsRO = new System.Windows.Forms.ToolStripMenuItem();
this.menu_InsTran = new System.Windows.Forms.ToolStripMenuItem();
this.menu_InsSym = new System.Windows.Forms.ToolStripMenuItem();
this.menu_ToggleView = new System.Windows.Forms.ToolStripMenuItem();
this.contextMenuStripROs = new System.Windows.Forms.ContextMenuStrip(this.components);
this.menu_DeleteRO = new System.Windows.Forms.ToolStripMenuItem();
this.menu_ModifyRO = new System.Windows.Forms.ToolStripMenuItem();
this.contextMenuStripTrans = new System.Windows.Forms.ContextMenuStrip(this.components);
this.menu_DeleteTrans = new System.Windows.Forms.ToolStripMenuItem();
this.menu_ModifyTrans = new System.Windows.Forms.ToolStripMenuItem();
this.menu_GoToTrans = new System.Windows.Forms.ToolStripMenuItem();
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.toolStripFontAttributes = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripBold = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripUnderline = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripCase = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripMenuItem();
this.contextMenuStrip.SuspendLayout();
this.contextMenuStripROs.SuspendLayout();
this.contextMenuStripTrans.SuspendLayout();
this.contextMenuStrip1.SuspendLayout();
this.SuspendLayout();
//
// contextMenuStrip
//
this.contextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.menu_Bold,
this.menu_Underline,
this.menu_Italics,
this.menu_Superscript,
this.menu_Subscript,
this.menu_Undo,
this.menu_Redo,
this.menu_lowercase,
this.menu_UPPERCASE,
this.menu_TitleCase,
this.menu_InsRO,
this.menu_InsTran,
this.menu_InsSym,
this.menu_ToggleView});
this.contextMenuStrip.Name = "contextMenuStrip";
this.contextMenuStrip.Size = new System.Drawing.Size(165, 312);
this.contextMenuStrip.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStrip_Opening);
this.contextMenuStrip.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.contextMenuStrip_ItemClicked);
//
// menu_Bold
//
this.menu_Bold.Name = "menu_Bold";
this.menu_Bold.Size = new System.Drawing.Size(164, 22);
this.menu_Bold.Text = "Bold";
//
// menu_Underline
//
this.menu_Underline.Name = "menu_Underline";
this.menu_Underline.Size = new System.Drawing.Size(164, 22);
this.menu_Underline.Text = "Underline";
//
// menu_Italics
//
this.menu_Italics.Name = "menu_Italics";
this.menu_Italics.Size = new System.Drawing.Size(164, 22);
this.menu_Italics.Text = "Italics";
//
// menu_Superscript
//
this.menu_Superscript.Name = "menu_Superscript";
this.menu_Superscript.Size = new System.Drawing.Size(164, 22);
this.menu_Superscript.Text = "Superscript";
//
// menu_Subscript
//
this.menu_Subscript.Name = "menu_Subscript";
this.menu_Subscript.Size = new System.Drawing.Size(164, 22);
this.menu_Subscript.Text = "Subscript";
//
// menu_Undo
//
this.menu_Undo.Name = "menu_Undo";
this.menu_Undo.Size = new System.Drawing.Size(164, 22);
this.menu_Undo.Text = "Undo";
//
// menu_Redo
//
this.menu_Redo.Name = "menu_Redo";
this.menu_Redo.Size = new System.Drawing.Size(164, 22);
this.menu_Redo.Text = "Redo";
//
// menu_lowercase
//
this.menu_lowercase.Name = "menu_lowercase";
this.menu_lowercase.Size = new System.Drawing.Size(164, 22);
this.menu_lowercase.Text = "lowercase";
//
// menu_UPPERCASE
//
this.menu_UPPERCASE.Name = "menu_UPPERCASE";
this.menu_UPPERCASE.Size = new System.Drawing.Size(164, 22);
this.menu_UPPERCASE.Text = "UPPERCASE";
//
// menu_TitleCase
//
this.menu_TitleCase.Name = "menu_TitleCase";
this.menu_TitleCase.Size = new System.Drawing.Size(164, 22);
this.menu_TitleCase.Text = "TitleCase";
//
// menu_InsRO
//
this.menu_InsRO.Name = "menu_InsRO";
this.menu_InsRO.Size = new System.Drawing.Size(164, 22);
this.menu_InsRO.Text = "Insert RO";
//
// menu_InsTran
//
this.menu_InsTran.Name = "menu_InsTran";
this.menu_InsTran.Size = new System.Drawing.Size(164, 22);
this.menu_InsTran.Text = "Insert Transition";
//
// menu_InsSym
//
this.menu_InsSym.Name = "menu_InsSym";
this.menu_InsSym.Size = new System.Drawing.Size(164, 22);
this.menu_InsSym.Text = "Insert Symbol";
//
// menu_ToggleView
//
this.menu_ToggleView.Name = "menu_ToggleView";
this.menu_ToggleView.Size = new System.Drawing.Size(164, 22);
this.menu_ToggleView.Text = "Toggle View/Edit";
//
// contextMenuStripROs
//
this.contextMenuStripROs.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.menu_DeleteRO,
this.menu_ModifyRO});
this.contextMenuStripROs.Name = "contextMenuStripROs";
this.contextMenuStripROs.Size = new System.Drawing.Size(136, 48);
this.contextMenuStripROs.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStripROs_Opening);
this.contextMenuStripROs.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.contextMenuStripROs_ItemClicked);
//
// menu_DeleteRO
//
this.menu_DeleteRO.Name = "menu_DeleteRO";
this.menu_DeleteRO.Size = new System.Drawing.Size(135, 22);
this.menu_DeleteRO.Text = "Delete RO";
//
// menu_ModifyRO
//
this.menu_ModifyRO.Name = "menu_ModifyRO";
this.menu_ModifyRO.Size = new System.Drawing.Size(135, 22);
this.menu_ModifyRO.Text = "Modify RO";
//
// contextMenuStripTrans
//
this.contextMenuStripTrans.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.menu_DeleteTrans,
this.menu_ModifyTrans,
this.menu_GoToTrans});
this.contextMenuStripTrans.Name = "contextMenuStripTrans";
this.contextMenuStripTrans.Size = new System.Drawing.Size(168, 70);
this.contextMenuStripTrans.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStripTrans_Opening);
this.contextMenuStripTrans.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.contextMenuStripTrans_ItemClicked);
//
// menu_DeleteTrans
//
this.menu_DeleteTrans.Name = "menu_DeleteTrans";
this.menu_DeleteTrans.Size = new System.Drawing.Size(167, 22);
this.menu_DeleteTrans.Text = "Delete Transition";
//
// menu_ModifyTrans
//
this.menu_ModifyTrans.Name = "menu_ModifyTrans";
this.menu_ModifyTrans.Size = new System.Drawing.Size(167, 22);
this.menu_ModifyTrans.Text = "Modify Transition";
//
// menu_GoToTrans
//
this.menu_GoToTrans.Name = "menu_GoToTrans";
this.menu_GoToTrans.Size = new System.Drawing.Size(167, 22);
this.menu_GoToTrans.Text = "Go To";
//
// contextMenuStrip1
//
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripFontAttributes,
this.toolStripCase});
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(159, 48);
//
// toolStripFontAttributes
//
this.toolStripFontAttributes.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripBold,
this.toolStripUnderline});
this.toolStripFontAttributes.Name = "toolStripFontAttributes";
this.toolStripFontAttributes.Size = new System.Drawing.Size(158, 22);
this.toolStripFontAttributes.Text = "Font Attributes";
//
// toolStripBold
//
this.toolStripBold.Name = "toolStripBold";
this.toolStripBold.Size = new System.Drawing.Size(130, 22);
this.toolStripBold.Text = "Bold";
//
// toolStripUnderline
//
this.toolStripUnderline.Name = "toolStripUnderline";
this.toolStripUnderline.Size = new System.Drawing.Size(130, 22);
this.toolStripUnderline.Text = "Underline";
//
// toolStripCase
//
this.toolStripCase.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripMenuItem1,
this.toolStripMenuItem2,
this.toolStripMenuItem3});
this.toolStripCase.Name = "toolStripCase";
this.toolStripCase.Size = new System.Drawing.Size(158, 22);
this.toolStripCase.Text = "Case";
//
// toolStripMenuItem1
//
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
this.toolStripMenuItem1.Size = new System.Drawing.Size(143, 22);
this.toolStripMenuItem1.Text = "UPPERCASE";
//
// toolStripMenuItem2
//
this.toolStripMenuItem2.Name = "toolStripMenuItem2";
this.toolStripMenuItem2.Size = new System.Drawing.Size(143, 22);
this.toolStripMenuItem2.Text = "lowercase";
//
// toolStripMenuItem3
//
this.toolStripMenuItem3.Name = "toolStripMenuItem3";
this.toolStripMenuItem3.Size = new System.Drawing.Size(143, 22);
this.toolStripMenuItem3.Text = "Title Case";
this.contextMenuStrip.ResumeLayout(false);
this.contextMenuStripROs.ResumeLayout(false);
this.contextMenuStripTrans.ResumeLayout(false);
this.contextMenuStrip1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.ContextMenuStrip contextMenuStrip;
private System.Windows.Forms.ToolStripMenuItem menu_Bold;
private System.Windows.Forms.ToolStripMenuItem menu_Underline;
private System.Windows.Forms.ToolStripMenuItem menu_Italics;
private System.Windows.Forms.ToolStripMenuItem menu_Superscript;
private System.Windows.Forms.ToolStripMenuItem menu_Subscript;
private System.Windows.Forms.ToolStripMenuItem menu_Undo;
private System.Windows.Forms.ToolStripMenuItem menu_Redo;
private System.Windows.Forms.ToolStripMenuItem menu_lowercase;
private System.Windows.Forms.ToolStripMenuItem menu_UPPERCASE;
private System.Windows.Forms.ToolStripMenuItem menu_TitleCase;
private System.Windows.Forms.ToolStripMenuItem menu_InsRO;
private System.Windows.Forms.ToolStripMenuItem menu_InsTran;
private System.Windows.Forms.ToolStripMenuItem menu_InsSym;
private System.Windows.Forms.ToolStripMenuItem menu_ToggleView;
private System.Windows.Forms.ContextMenuStrip contextMenuStripROs;
private System.Windows.Forms.ToolStripMenuItem menu_DeleteRO;
private System.Windows.Forms.ToolStripMenuItem menu_ModifyRO;
private System.Windows.Forms.ContextMenuStrip contextMenuStripTrans;
private System.Windows.Forms.ToolStripMenuItem menu_DeleteTrans;
private System.Windows.Forms.ToolStripMenuItem menu_ModifyTrans;
private System.Windows.Forms.ToolStripMenuItem menu_GoToTrans;
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
private System.Windows.Forms.ToolStripMenuItem toolStripFontAttributes;
private System.Windows.Forms.ToolStripMenuItem toolStripBold;
private System.Windows.Forms.ToolStripMenuItem toolStripUnderline;
private System.Windows.Forms.ToolStripMenuItem toolStripCase;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem2;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem3;
}
}

View File

@ -0,0 +1,135 @@
<?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>
<metadata name="contextMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>27, 22</value>
</metadata>
<metadata name="contextMenuStripROs.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 91</value>
</metadata>
<metadata name="contextMenuStripTrans.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 54</value>
</metadata>
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>175, 91</value>
</metadata>
<metadata name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
</root>

View File

@ -0,0 +1,278 @@
using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Drawing;
using VEPROMS.CSLA.Library;
using System.Text.RegularExpressions;
using System.Reflection;
namespace Volian.Controls.Library
{
public enum LinkType : int
{
ReferencedObject = 21,
Transition = 9516,
TransitionRange = 9574
}
public partial class DisplayRTBSimple : RichTextBox, IDisplayRTB
{
#region Fields
private IContainer _Container = null;
private ItemInfo _MyItem;
private Size _AdjustSize;
private Rectangle _ContentsRectangle;
private E_EditPrintMode _EpMode;
private string _MyClassName;
private E_ViewMode _VwMode;
#endregion
#region RTB 4.1 Not being used
//[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
//static extern IntPtr LoadLibrary(string lpFileName);
//protected override CreateParams CreateParams
//{
// get
// {
// CreateParams prams = base.CreateParams;
// if (LoadLibrary("msftedit.dll") != IntPtr.Zero)
// {
// //prams.ExStyle |= 0x020; // transparent
// prams.ClassName = "RICHEDIT50W";
// }
// return prams;
// }
//}
//[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
//static extern IntPtr LoadLibrary(string lpFileName);
//protected override CreateParams CreateParams
//{
// get
// {
// CreateParams prams = base.CreateParams;
// if (LoadLibrary("riched20.dll") != IntPtr.Zero)
// {
// //prams.ExStyle |= 0x020; // transparent
// prams.ClassName = "RICHEDIT20W";
// }
// return prams;
// }
//}
#endregion
#region Events
public event DisplayRTBLinkEvent LinkGoTo;
private void OnLinkGoTo(object sender,LinkClickedEventArgs args)
{
if (LinkGoTo != null) LinkGoTo(sender, args);
}
/// <summary>
/// Occurs when a content or format change causes the box to get taller or shorter
/// </summary>
public event DisplayRTBEvent HeightChanged;
/// <summary>
/// Checks to see if the HeightChanged event is handled and launches it
/// </summary>
/// <param name="sender"></param>
/// <param name="args"></param>
private void OnHeightChanged(object sender, EventArgs args)
{
if (HeightChanged != null) HeightChanged(sender, args);
}
#endregion
#region Properties
/// <summary>
/// ItemInfo object associated with the control
/// </summary>
/// <param name="match"></param>
/// <returns></returns>
public ItemInfo MyItem
{
get { return _MyItem; }
set
{
_MyItem = value;
if (value != null)
{
//// TIMING: vlnCSLARTB.TimeIt("rtbMyItem Start");
//if (value.ItemID == 90)
// if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat(value.MyContent.Text);
string txt = _MyItem.MyContent.Text;
txt = txt.Replace("\n", "\r\n\\par ");
//txt = Regex.Replace(txt, "(.){([0-9]*){([0-9 ]*)}}",FixTransition);
//txt = Regex.Replace(txt, @"(.)\\v TRAN", FixTransition);
MatchCollection mc = Regex.Matches(txt, @"(.)\\v (TRAN|RO)\\v0 ([^\\]*)\\v ([^\\]*)\\v0");
//string[] parts = Regex.Split(txt, "(.){{(.*)}{(.*)}}");
if (mc.Count > 0)
{
int lastIndex = 0;
foreach (Match m in mc)
{
if(m.Index > lastIndex) AddRtf(txt.Substring(lastIndex,m.Index - lastIndex));
string linkUrl = "Link:" + ((LinkType)Convert.ToInt32(m.Groups[1].Value[0])).ToString() + ":" + m.Groups[4].Value;
string linkValue = (m.Groups[2].Value == "TRAN" ? FixTransition(m) : m.Groups[3].Value);
if (CreateParams.ClassName == "RICHEDIT50W")
AddLink50(linkUrl, linkValue);
else
AddLink20(linkUrl, linkValue);
//AddRtf(string.Format("{0} \\v RO - {1} \\v0",ROValue,ROID));
lastIndex = m.Index + m.Length;
}
AddRtf(txt.Substring(lastIndex, txt.Length - lastIndex));
}
else
{
AddRtf(txt);
}
//// TIMING: vlnCSLARTB.TimeIt("rtbMyItem End");
}
}
}
public Size AdjustSize
{
get { return _AdjustSize; }
set { _AdjustSize = value; }
}
public Rectangle ContentsRectangle
{
get { return _ContentsRectangle; }
set { _ContentsRectangle = value; }
}
public E_EditPrintMode EpMode
{
get { return _EpMode; }
set { _EpMode = value; }
}
public string MyClassName
{
get { return _MyClassName; }
set { _MyClassName = value; }
}
public E_ViewMode VwMode
{
get { return _VwMode; }
set { _VwMode = value; }
}
#endregion
#region Private Methods
private string FixTransition(Match match)
{
//int transitionID = Convert.ToInt32(match.Groups[2].Value);
int transitionID = Convert.ToInt32(match.Groups[4].Value.Split(" ".ToCharArray())[1]);
// Find the transition
foreach (TransitionInfo ti in _MyItem.MyContent.ContentTransitions)
{
if (ti.TransitionID == transitionID)
{
string path = ti.PathTo.Replace(" Section PROCEDURE STEPS ", ", ");
path = path.Replace(" Section PROCEDURE STEPS", "");
return path;
}
}
return match.Value;
}
/// <summary>
/// Adds the text and hypertext link and sets the style to link
/// </summary>
/// <param name="linkUrl">URL - Uniform Resource Locator (Address)</param>
/// <param name="linkValue">Text descibing location</param>
private void AddLink20(string linkUrl, string linkValue)
{
this.DetectUrls = false;
RTBAPI.CharFormatTwo charFormat = RTBAPI.GetCharFormat(this, RTBAPI.RTBSelection.SCF_SELECTION);
int position = SelectionStart = this.TextLength;
SelectionLength = 0;
SelectedRtf = @"{\rtf1\ansi " + linkValue + @"\v #" + linkUrl + @"\v0}";
Select(position, linkValue.Length + linkUrl.Length + 1);
// Protect the link text to avoid manual changes
charFormat.dwMask = RTBAPI.CharFormatMasks.CFM_LINK | RTBAPI.CharFormatMasks.CFM_PROTECTED;
charFormat.dwEffects = RTBAPI.CharFormatEffects.CFE_LINK | RTBAPI.CharFormatEffects.CFE_PROTECTED;
RTBAPI.SetCharFormat((RichTextBox)this, RTBAPI.RTBSelection.SCF_SELECTION, charFormat);
this.SelectionStart = this.TextLength;
this.SelectionLength = 0;
}
/// <summary>
/// Adds a hypertext link to the Rich Text
/// </summary>
/// <param name="linkUrl">URL - Uniform Resource Locator (Address)</param>
/// <param name="linkValue">Text descibing location</param>
private void AddLink50(string linkUrl, string linkValue)
{
this.DetectUrls = false;
int position = SelectionStart = this.TextLength;
SelectionLength = 0;
SelectedRtf = string.Format(@"{{\rtf\field{{\*\fldinst{{HYPERLINK ""www.volian.com #{0}"" }}}}{{\fldrslt{{\cf2\ul {1}}}}}}}", linkUrl, linkValue);
this.SelectionStart = this.TextLength;
this.SelectionLength = 0;
}
/// <summary>
/// Adds Rich Text
/// </summary>
/// <param name="rtf">this is any text and can include RTF commands or not</param>
private void AddRtf(string rtf)
{
this.SelectedRtf = @"{\rtf1 " + rtf + "}";
}
/// <summary>
/// Used by the constructors to do any standard configuration
/// </summary>
private void SetUp()
{
BorderStyle = System.Windows.Forms.BorderStyle.None;
this.DetectUrls = true;
//ContextMenuStrip = this.contextMenuStrip1;
//ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.None;
//this.TextChanged += new EventHandler(VERichTextBox_TextChanged);
this.ContentsResized += new ContentsResizedEventHandler(VERichTextBox_ContentsResized);
//if (Text != "") ResizeForText();
this.LinkClicked += new LinkClickedEventHandler(DisplayRTBSimple_LinkClicked);
}
void DisplayRTBSimple_LinkClicked(object sender, LinkClickedEventArgs e)
{
OnLinkGoTo(sender, e);
}
#endregion
#region Constructors
public DisplayRTBSimple()
{
InitializeComponent();
SetUp();
}
public DisplayRTBSimple(IContainer container)
{
container.Add(this);
InitializeComponent();
_Container = container;
SetUp();
}
#endregion
#region Event Handlers
void VERichTextBox_ContentsResized(object sender, ContentsResizedEventArgs e)
{
this.Height = e.NewRectangle.Height;
OnHeightChanged(sender, new EventArgs());
}
#endregion
}
[TypeConverter(typeof(ExpandableObjectConverter))]
public interface IDisplayRTB
{
event DisplayRTBEvent HeightChanged;
ItemInfo MyItem { get; }
Size AdjustSize { get; set; }
Rectangle ContentsRectangle { get; set; }
E_EditPrintMode EpMode { get; set; }
string MyClassName { get; set; }
E_ViewMode VwMode { get; set; }
// In addition to the HeightChanged event and the MyItem property
// the constructors below should be created
// public DisplayRTBSimple()
// public DisplayRTBSimple(IContainer container)
}
}

View File

@ -0,0 +1,36 @@
namespace Volian.Controls.Library
{
partial class DisplayRTBSimple
{
/// <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
}
}

View File

@ -0,0 +1,280 @@
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
using System.Drawing.Design;
using System.Windows.Forms.Design;
namespace Volian.Controls.Library
{
public class FlagCheckedListBox : CheckedListBox
{
private System.ComponentModel.Container components = null;
public FlagCheckedListBox()
{
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();
// TODO: Add any initialization after the InitForm call
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (components != null)
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
private void InitializeComponent()
{
//
// FlaggedCheckedListBox
//
this.CheckOnClick = true;
}
#endregion
// Adds an integer value and its associated description
public FlagCheckedListBoxItem Add(uint v, string c)
{
FlagCheckedListBoxItem item = new FlagCheckedListBoxItem(v, c);
Items.Add(item);
return item;
}
public FlagCheckedListBoxItem Add(FlagCheckedListBoxItem item)
{
Items.Add(item);
return item;
}
protected override void OnItemCheck(ItemCheckEventArgs e)
{
base.OnItemCheck(e);
if (isUpdatingCheckStates)
return;
// Get the checked/unchecked item
FlagCheckedListBoxItem item = Items[e.Index] as FlagCheckedListBoxItem;
// Update other items
UpdateCheckedItems(item, e.NewValue);
}
// Checks/Unchecks items depending on the give bitvalue
protected void UpdateCheckedItems(uint value)
{
isUpdatingCheckStates = true;
// Iterate over all items
for (int i = 0; i < Items.Count; i++)
{
FlagCheckedListBoxItem item = Items[i] as FlagCheckedListBoxItem;
if (item.value == 0)
{
SetItemChecked(i, value == 0);
}
else
{
// If the bit for the current item is on in the bitvalue, check it
if ((item.value & value) == item.value && item.value != 0)
SetItemChecked(i, true);
// Otherwise uncheck it
else
SetItemChecked(i, false);
}
}
isUpdatingCheckStates = false;
}
// Updates items in the checklistbox
// composite = The item that was checked/unchecked
// cs = The check state of that item
protected void UpdateCheckedItems(FlagCheckedListBoxItem composite, CheckState cs)
{
// If the value of the item is 0, call directly.
if (composite.value == 0)
UpdateCheckedItems(0);
// Get the total value of all checked items
uint sum = 0;
for (int i = 0; i < Items.Count; i++)
{
FlagCheckedListBoxItem item = Items[i] as FlagCheckedListBoxItem;
// If item is checked, add its value to the sum.
if (GetItemChecked(i))
sum |= item.value;
}
// If the item has been unchecked, remove its bits from the sum
if (cs == CheckState.Unchecked)
sum = sum & (~composite.value);
// If the item has been checked, combine its bits with the sum
else
sum |= composite.value;
// Update all items in the checklistbox based on the final bit value
UpdateCheckedItems(sum);
}
private bool isUpdatingCheckStates = false;
// Gets the current bit value corresponding to all checked items
public uint GetCurrentValue()
{
uint sum = 0;
for (int i = 0; i < Items.Count; i++)
{
FlagCheckedListBoxItem item = Items[i] as FlagCheckedListBoxItem;
if (GetItemChecked(i))
sum |= item.value;
}
return sum;
}
Type enumType;
Enum enumValue;
// Adds items to the checklistbox based on the members of the enum
private void FillEnumMembers()
{
foreach (string name in Enum.GetNames(enumType))
{
object val = Enum.Parse(enumType, name);
uint intVal = (uint)Convert.ChangeType(val, typeof(uint));
Add(intVal, name);
}
}
// Checks/unchecks items based on the current value of the enum variable
private void ApplyEnumValue()
{
uint intVal = (uint)Convert.ChangeType(enumValue, typeof(uint));
UpdateCheckedItems(intVal);
}
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]
public Enum EnumValue
{
get
{
object e = Enum.ToObject(enumType, GetCurrentValue());
return (Enum)e;
}
set
{
Items.Clear();
enumValue = value; // Store the current enum value
enumType = value.GetType(); // Store enum type
FillEnumMembers(); // Add items for enum members
ApplyEnumValue(); // Check/uncheck items depending on enum value
}
}
}
// Represents an item in the checklistbox
public class FlagCheckedListBoxItem
{
public FlagCheckedListBoxItem(uint v, string c)
{
value = v;
caption = c;
}
public override string ToString()
{
return caption;
}
// Returns true if the value corresponds to a single bit being set
public bool IsFlag
{
get
{
return ((value & (value - 1)) == 0);
}
}
// Returns true if this value is a member of the composite bit value
public bool IsMemberFlag(FlagCheckedListBoxItem composite)
{
return (IsFlag && ((value & composite.value) == value));
}
public uint value;
public string caption;
}
// UITypeEditor for flag enums
public class FlagEnumUIEditor : UITypeEditor
{
// The checklistbox
private FlagCheckedListBox flagEnumCB;
public FlagEnumUIEditor()
{
flagEnumCB = new FlagCheckedListBox();
flagEnumCB.BorderStyle = BorderStyle.None;
}
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
{
if (context != null
&& context.Instance != null
&& provider != null)
{
IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
if (edSvc != null)
{
Enum e = (Enum)Convert.ChangeType(value, context.PropertyDescriptor.PropertyType);
flagEnumCB.EnumValue = e;
edSvc.DropDownControl(flagEnumCB);
return flagEnumCB.EnumValue;
}
}
return null;
}
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
{
return UITypeEditorEditStyle.DropDown;
}
}
}

View File

@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Volian.Controls.Library")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Volian Enterprises, Inc.")]
[assembly: AssemblyProduct("Volian.Controls.Library")]
[assembly: AssemblyCopyright("Copyright © Volian Enterprises, Inc. 2007")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("92d604d4-a2f9-49e6-af01-c77673f24954")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,922 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.Runtime.InteropServices;
using System.ComponentModel;
namespace Volian.Controls.Library
{
public static class RTBAPI
{
#region SendMessage
[DllImport("user32.dll", SetLastError = true)]
private static extern int SendMessage(HandleRef hWndlock, Messages wMsg, Int32 wParam, ref Point pt);
[DllImport("user32.dll", SetLastError = true)]
private static extern int SendMessage(HandleRef hWndlock, Messages wMsg, Int32 wParam, int lParam);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern int SendMessage(HandleRef hWndlock, Messages wMsg, RTBSelection wParam, ref CharFormat2 cf2);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern int SendMessage(HandleRef hWndlock, Messages wMsg, int wParam, ref ParaFormat2 pf2);
#region RTB Messages
// EM_AUTOURLDETECT - An EM_AUTOURLDETECT message enables or disables automatic detection of URLs by a rich edit control.
// EM_CANPASTE - The EM_CANPASTE message determines whether a rich edit control can paste a specified clipboard format.
// EM_CANREDO - The EM_CANREDO message determines whether there are any actions in the control redo queue.
// EM_DISPLAYBAND - The EM_DISPLAYBAND message displays a portion of the contents of a rich edit control, as previously formatted for a device using the EM_FORMATRANGE message.
// EM_EXGETSEL - The EM_EXGETSEL message retrieves the starting and ending character positions of the selection in a rich edit control.
// EM_EXLIMITTEXT - The EM_EXLIMITTEXT message sets an upper limit to the amount of text the user can type or paste into a rich edit control.
// EM_EXLINEFROMCHAR - The EM_EXLINEFROMCHAR message determines which line contains the specified character in a rich edit control.
// EM_EXSETSEL - The EM_EXSETSEL message selects a range of characters or COM objects in a Rich Edit control.
// EM_FINDTEXT - The EM_FINDTEXT message finds text within a rich edit control.
// EM_FINDTEXTEX - The EM_FINDTEXTEX message finds text within a rich edit control.
// EM_FINDTEXTEXW - The EM_FINDTEXTEXW message finds Unicode text within a rich edit control.
// EM_FINDTEXTW - The EM_FINDTEXTW message finds Unicode text within a rich edit control.
// EM_FINDWORDBREAK - The EM_FINDWORDBREAK message finds the next word break before or after the specified character position or retrieves information about the character at that position.
// EM_FORMATRANGE - The EM_FORMATRANGE message formats a range of text in a rich edit control for a specific device.
// EM_GETAUTOURLDETECT - The EM_GETAUTOURLDETECT message indicates whether the auto URL detection is turned on in the rich edit control.
// EM_GETBIDIOPTIONS - The EM_GETBIDIOPTIONS message indicates the current state of the bidirectional options in the rich edit control.
// EM_GETCHARFORMAT - The EM_GETCHARFORMAT message determines the character formatting in a rich edit control.
// EM_GETCTFMODEBIAS - An application sends a EM_GETCTFMODEBIAS message to get the Text Services Framework mode bias values for a Rich Edit control.
// EM_GETCTFOPENSTATUS - An application sends an EM_GETCTFOPENSTATUS message to determine if the Text Services Framework (TSF) keyboard is open or closed.
// EM_GETEDITSTYLE - The EM_GETEDITSTYLE message retrieves the current edit style flags.
// EM_GETEVENTMASK - The EM_GETEVENTMASK message retrieves the event mask for a rich edit control. The event mask specifies which notification messages the control sends to its parent window.
// EM_GETHYPHENATEINFO - An application sends an EM_GETHYPHENATEINFO message to get information about hyphenation for a Rich Edit control.
// EM_GETIMECOLOR - The EM_GETIMECOLOR message retrieves the Input Method Editor (IME) composition color. This message is available only in Asian-language versions of the operating system.
// EM_GETIMECOMPMODE - An application sends an EM_GETIMECOMPMODE message to get the current IME mode for a rich edit control.
// EM_GETIMECOMPTEXT - An application sends an EM_GETIMECOMPTEXT message to get the IME composition text.
// EM_GETIMEMODEBIAS - An application sends an EM_GETIMEMODEBIAS message to get the IME mode bias for a Rich Edit control.
// EM_GETIMEOPTIONS - The EM_GETIMEOPTIONS message retrieves the current IME options. This message is available only in Asian-language versions of the operating system.
// EM_GETIMEPROPERTY - An application sends a EM_GETIMEPROPERTY message to get the property and capabilities of the IME associated with the current input locale.
// EM_GETLANGOPTIONS - An application sends an EM_GETLANGOPTIONS message to get a rich edit control's option settings for IME and Asian language support.
// EM_GETOLEINTERFACE - The EM_GETOLEINTERFACE message retrieves an IRichEditOle object that a client can use to access a rich edit control's COM functionality.
// EM_GETOPTIONS - The EM_GETOPTIONS message retrieves rich edit control options.
// EM_GETPAGEROTATE - Deprecated. An application sends an EM_GETPAGEROTATE message to get the text layout for a Rich Edit control.
// EM_GETPARAFORMAT - The EM_GETPARAFORMAT message retrieves the paragraph formatting of the current selection in a rich edit control.
// EM_GETPUNCTUATION - The EM_GETPUNCTUATION message gets the current punctuation characters for the rich edit control. This message is available only in Asian-language versions of the operating system.
// EM_GETREDONAME - An application sends an EM_GETREDONAME message to a rich edit control to retrieve the type of the next action, if any, in the control's redo queue.
// EM_GETSCROLLPOS - An application sends an EM_GETSCROLLPOS message to obtain the current scroll position of the edit control.
// EM_GETSELTEXT - The EM_GETSELTEXT message retrieves the currently selected text in a rich edit control.
// EM_GETTEXTEX - The EM_GETTEXTEX message allows you to get all of the text from the rich edit control in any particular code base you want.
// EM_GETTEXTLENGTHEX - The EM_GETTEXTLENGTHEX message calculates text length in various ways. It is usually called before creating a buffer to receive the text from the control.
// EM_GETTEXTMODE - An application sends an EM_GETTEXTMODE message to get the current text mode and undo level of a rich edit control.
// EM_GETTEXTRANGE - The EM_GETTEXTRANGE message retrieves a specified range of characters from a rich edit control.
// EM_GETTYPOGRAPHYOPTIONS - The EM_GETTYPOGRAPHYOPTIONS message returns the current state of the typography options of a rich edit control.
// EM_GETUNDONAME - Rich Edit 2.0 and later: An application sends an EM_GETUNDONAME message to a rich edit control to retrieve the type of the next undo action, if any.
// EM_GETWORDBREAKPROCEX - The EM_GETWORDBREAKPROCEX message retrieves the address of the currently registered extended word-break procedure.
// EM_GETWORDWRAPMODE - The EM_GETWORDWRAPMODE message gets the current word wrap and word-break options for the rich edit control. This message is available only in Asian-language versions of the operating system.
// EM_GETZOOM - The EM_GETZOOM message gets the current zoom ratio, which is always between 1/64 and 64.
// EM_HIDESELECTION - The EM_HIDESELECTION message hides or shows the selection in a rich edit control.
// EM_ISIME - An application sends a EM_ISIME message to determine if current input locale is an East Asian locale.
// EM_PASTESPECIAL - The EM_PASTESPECIAL message pastes a specific clipboard format in a rich edit control.
// EM_RECONVERSION - The EM_RECONVERSION message invokes the IME reconversion dialog box.
// EM_REDO - Send an EM_REDO message to a rich edit control to redo the next action in the control's redo queue.
// EM_REQUESTRESIZE - The EM_REQUESTRESIZE message forces a rich edit control to send an EN_REQUESTRESIZE notification message to its parent window.
// EM_SELECTIONTYPE - The EM_SELECTIONTYPE message determines the selection type for a rich edit control.
// EM_SETBIDIOPTIONS - The EM_SETBIDIOPTIONS message sets the current state of the bidirectional options in the rich edit control.
// EM_SETBKGNDCOLOR - The EM_SETBKGNDCOLOR message sets the background color for a rich edit control.
// EM_SETCHARFORMAT - The EM_SETCHARFORMAT message sets character formatting in a rich edit control.
// EM_SETCTFMODEBIAS - An application sends an EM_SETCTFMODEBIAS message to set the Text Services Framework (TSF) mode bias for a Rich Edit control.
// EM_SETCTFOPENSTATUS - An application sends an EM_SETCTFOPENSTATUS message to open or close the Text Services Framework (TSF) keyboard.
// EM_SETEDITSTYLE - The EM_SETEDITSTYLE message sets the current edit style flags.
// EM_SETEVENTMASK - The EM_SETEVENTMASK message sets the event mask for a rich edit control. The event mask specifies which notification messages the control sends to its parent window.
// EM_SETFONTSIZE - The EM_SETFONTSIZE message sets the font size for the selected text.
// EM_SETHYPHENATEINFO - An application sends an EM_SETHYPHENATEINFO message to set the way a Rich Edit control does hyphenation.
// EM_SETIMECOLOR - The EM_SETIMECOLOR message sets the IME composition color. This message is available only in Asian-language versions of the operating system.
// EM_SETIMEMODEBIAS - An application sends an EM_SETIMEMODEBIAS message to set the IME mode bias for a Rich Edit control.
// EM_SETIMEOPTIONS - The EM_SETIMEOPTIONS message sets the IME options. This message is available only in Asian-language versions of the operating system.
// EM_SETLANGOPTIONS - An application sends an EM_SETLANGOPTIONS message to set options for IME and Asian language support in a rich edit control.
// EM_SETOLECALLBACK - The EM_SETOLECALLBACK message gives a rich edit control an IRichEditOleCallback object that the control uses to get OLE-related resources and information from the client.
// EM_SETOPTIONS - The EM_SETOPTIONS message sets the options for a rich edit control.
// EM_SETPAGEROTATE - Deprecated. An application sends an EM_SETPAGEROTATE message to set the text layout for a Rich Edit control.
// EM_SETPALETTE - An application sends an EM_SETPALETTE message to change the palette that rich edit uses for its display window.
// EM_SETPARAFORMAT - The EM_SETPARAFORMAT message sets the paragraph formatting for the current selection in a rich edit control.
// EM_SETPUNCTUATION - The EM_SETPUNCTUATION message sets the punctuation characters for a rich edit control. This message is available only in Asian-language versions of the operating system.
// EM_SETSCROLLPOS - An application sends an EM_SETSCROLLPOS message to tell the rich edit control to scroll to a particular point.
// EM_SETTARGETDEVICE - The EM_SETTARGETDEVICE message sets the target device and line width used for "what you see is what you get" (WYSIWYG) formatting in a rich edit control.
// EM_SETTEXTEX - The EM_SETTEXTEX message combines the functionality of WM_SETTEXT and EM_REPLACESEL and adds the ability to set text using a code page and to use either rich text or plain text.
// EM_SETTEXTMODE - An application sends an EM_SETTEXTMODE message to set the text mode or undo level of a rich edit control. The message fails if the control contains any text.
// EM_SETTYPOGRAPHYOPTIONS - The EM_SETTYPOGRAPHYOPTIONS message sets the current state of the typography options of a rich edit control.
// EM_SETUNDOLIMIT - An application sends an EM_SETUNDOLIMIT message to a rich edit control to set the maximum number of actions that can stored in the undo queue.
// EM_SETWORDBREAKPROCEX - The EM_SETWORDBREAKPROCEX message sets the extended word-break procedure.
// EM_SETWORDWRAPMODE - The EM_SETWORDWRAPMODE message sets the word-wrapping and word-breaking options for the rich edit control. This message is available only in Asian-language versions of the operating system.
// EM_SETZOOM - The EM_SETZOOM message sets the zoom ratio anywhere between 1/64 and 64.
// EM_SHOWSCROLLBAR - The EM_SHOWSCROLLBAR message shows or hides one of the scroll bars in the Text Host window.
// EM_STOPGROUPTYPING - An application sends an EM_STOPGROUPTYPING message to a rich edit control to stop the control from collecting additional typing actions into the current undo action. The control stores the next typing action, if any, into a new action in the undo queue.
// EM_STREAMIN - The EM_STREAMIN message replaces the contents of a rich edit control with a stream of data provided by an application defined
// EM_STREAMOUT - The EM_STREAMOUT message causes a rich edit control to pass its contents to an application
#endregion
#endregion
#region Constants
//const int ECOOP_XOR = 0x0004;
//const int ECO_AUTOWORDSELECTION = 0x00000001;
const int WM_USER = 0x0400;
#endregion
#region Enums
public enum Messages : int
{
EM_AUTOURLDETECT = WM_USER + 91,
EM_CANPASTE = WM_USER + 50,
EM_CANREDO = WM_USER + 85,
EM_DISPLAYBAND = WM_USER + 51,
EM_EXGETSEL = WM_USER + 52,
EM_EXLIMITTEXT = WM_USER + 53,
EM_EXLINEFROMCHAR = WM_USER + 54,
EM_EXSETSEL = WM_USER + 55,
EM_FINDTEXT = WM_USER + 56,
EM_FINDTEXTEX = WM_USER + 79,
EM_FINDTEXTEXW = WM_USER + 124,
EM_FINDTEXTW = WM_USER + 123,
EM_FINDWORDBREAK = WM_USER + 76,
EM_FORMATRANGE = WM_USER + 57,
EM_GETAUTOURLDETECT = WM_USER + 92,
EM_GETBIDIOPTIONS = WM_USER + 201,
EM_GETCHARFORMAT = WM_USER + 58,
EM_GETCTFMODEBIAS = WM_USER + 237,
EM_GETCTFOPENSTATUS = WM_USER + 240,
EM_GETEDITSTYLE = WM_USER + 205,
EM_GETEVENTMASK = WM_USER + 59,
EM_GETHYPHENATEINFO = WM_USER + 230,
EM_GETIMECOLOR = WM_USER + 105,
EM_GETIMECOMPMODE = WM_USER + 122,
EM_GETIMECOMPTEXT = WM_USER + 242,
EM_GETIMEMODEBIAS = WM_USER + 127,
EM_GETIMEOPTIONS = WM_USER + 107,
EM_GETIMEPROPERTY = WM_USER + 244,
EM_GETLANGOPTIONS = WM_USER + 121,
EM_GETOLEINTERFACE = WM_USER + 60,
EM_GETOPTIONS = WM_USER + 78,
EM_GETPAGEROTATE = WM_USER + 235,
EM_GETPARAFORMAT = WM_USER + 61,
EM_GETPUNCTUATION = WM_USER + 101,
EM_GETREDONAME = WM_USER + 87,
EM_GETSCROLLPOS = WM_USER + 221,
EM_GETSELTEXT = WM_USER + 62,
EM_GETTEXTEX = WM_USER + 94,
EM_GETTEXTLENGTHEX = WM_USER + 95,
EM_GETTEXTMODE = WM_USER + 90,
EM_GETTEXTRANGE = WM_USER + 75,
EM_GETTYPOGRAPHYOPTIONS = WM_USER + 203,
EM_GETUNDONAME = WM_USER + 86,
EM_GETWORDBREAKPROCEX = WM_USER + 80,
EM_GETWORDWRAPMODE = WM_USER + 103,
EM_GETZOOM = WM_USER + 224,
EM_HIDESELECTION = WM_USER + 63,
EM_ISIME = WM_USER + 243,
EM_PASTESPECIAL = WM_USER + 64,
EM_RECONVERSION = WM_USER + 125,
EM_REDO = WM_USER + 84,
EM_REQUESTRESIZE = WM_USER + 65,
EM_SELECTIONTYPE = WM_USER + 66,
EM_SETBIDIOPTIONS = WM_USER + 200,
EM_SETBKGNDCOLOR = WM_USER + 67,
EM_SETCHARFORMAT = WM_USER + 68,
EM_SETCTFMODEBIAS = WM_USER + 238,
EM_SETCTFOPENSTATUS = WM_USER + 241,
EM_SETEDITSTYLE = WM_USER + 204,
EM_SETEVENTMASK = WM_USER + 69,
EM_SETFONTSIZE = WM_USER + 223,
EM_SETHYPHENATEINFO = WM_USER + 231,
EM_SETIMECOLOR = WM_USER + 104,
EM_SETIMEMODEBIAS = WM_USER + 126,
EM_SETIMEOPTIONS = WM_USER + 106,
EM_SETLANGOPTIONS = WM_USER + 120,
EM_SETOLECALLBACK = WM_USER + 70,
EM_SETOPTIONS = WM_USER + 77,
EM_SETPAGEROTATE = WM_USER + 236,
EM_SETPALETTE = WM_USER + 93,
EM_SETPARAFORMAT = WM_USER + 71,
EM_SETPUNCTUATION = WM_USER + 100,
EM_SETSCROLLPOS = WM_USER + 222,
EM_SETTARGETDEVICE = WM_USER + 72,
EM_SETTEXTEX = WM_USER + 97,
EM_SETTEXTMODE = WM_USER + 89,
EM_SETTYPOGRAPHYOPTIONS = WM_USER + 202,
EM_SETUNDOLIMIT = WM_USER + 82,
EM_SETWORDBREAKPROCEX = WM_USER + 81,
EM_SETWORDWRAPMODE = WM_USER + 102,
EM_SETZOOM = WM_USER + 225,
EM_SHOWSCROLLBAR = WM_USER + 96,
EM_STOPGROUPTYPING = WM_USER + 88,
EM_STREAMIN = WM_USER + 73,
EM_STREAMOUT = WM_USER + 74
};
[Flags]
public enum LanguageOptions : int // Options for EM_SETLANGOPTIONS and EM_GETLANGOPTIONS
{
IMF_AUTOKEYBOARD = 0x0001,
IMF_AUTOFONT = 0x0002,
IMF_IMECANCELCOMPLETE = 0x0004, // high completes the comp string when aborting, low cancels.
IMF_IMEALWAYSSENDNOTIFY = 0x0008
}
public enum TimeCompMode : int // Values for EM_GETIMECOMPMODE
{
ICM_NOTOPEN = 0x0000,
ICM_LEVEL3 = 0x0001,
ICM_LEVEL2 = 0x0002,
ICM_LEVEL2_5 = 0x0003,
ICM_LEVEL2_SUI = 0x0004
}
[Flags]
public enum EditControlOptions : int // Edit control options
{
ECO_AUTOWORDSELECTION = 0x00000001,
ECO_AUTOVSCROLL = 0x00000040,
ECO_AUTOHSCROLL = 0x00000080,
ECO_NOHIDESEL = 0x00000100,
ECO_READONLY = 0x00000800,
ECO_WANTRETURN = 0x00001000,
ECO_SAVESEL = 0x00008000,
ECO_SELECTIONBAR = 0x01000000,
ECO_VERTICAL = 0x00400000, // FE specific
}
public enum EcoOperations : int // ECO operations
{
ECOOP_SET = 0x0001,
ECOOP_OR = 0x0002,
ECOOP_AND = 0x0003,
ECOOP_XOR = 0x0004
}
public enum WordBreakFunctionActions : int // new word break function actions
{
WB_CLASSIFY = 3,
WB_MOVEWORDLEFT = 4,
WB_MOVEWORDRIGHT = 5,
WB_LEFTBREAK = 6,
WB_RIGHTBREAK = 7
}
//#define PC_FOLLOWING 1
//#define PC_LEADING 2
//#define PC_OVERFLOW 3
//#define PC_DELIMITER 4
//#define WBF_WORDWRAP 0x010
//#define WBF_WORDBREAK 0x020
//#define WBF_OVERFLOW 0x040
//#define WBF_LEVEL1 0x080
//#define WBF_LEVEL2 0x100
//#define WBF_CUSTOM 0x200
/* Word break flags (used with WB_CLASSIFY) */
//#define WBF_CLASS ((BYTE) 0x0F)
//#define WBF_ISWHITE ((BYTE) 0x10)
//#define WBF_BREAKLINE ((BYTE) 0x20)
//#define WBF_BREAKAFTER ((BYTE) 0x40)
///* Far East specific flags */
//#define IMF_FORCENONE 0x0001
//#define IMF_FORCEENABLE 0x0002
//#define IMF_FORCEDISABLE 0x0004
//#define IMF_CLOSESTATUSWINDOW 0x0008
//#define IMF_VERTICAL 0x0020
//#define IMF_FORCEACTIVE 0x0040
//#define IMF_FORCEINACTIVE 0x0080
//#define IMF_FORCEREMEMBER 0x0100
//#define IMF_MULTIPLEEDIT 0x0400
public enum RTBSelection : int
{
SCF_DEFAULT = 0x0000,
SCF_SELECTION = 0x0001,
SCF_WORD = 0x0002,
SCF_ALL = 0x0004,
SCF_USEUIRULES = 0x0008
}
[Flags]
public enum CharFormatMasks : uint
{
CFM_NONE = 0,
CFM_BOLD = 0x00000001,
CFM_ITALIC = 0x00000002,
CFM_UNDERLINE = 0x00000004,
CFM_STRIKEOUT = 0x00000008,
CFM_PROTECTED = 0x00000010,
CFM_LINK = 0x00000020, // Exchange hyperlink extension
CFM_SIZE = 0x80000000,
CFM_COLOR = 0x40000000,
CFM_FACE = 0x20000000,
CFM_OFFSET = 0x10000000,
CFM_CHARSET = 0x08000000,
CFM_SMALLCAPS = 0x0040,
CFM_ALLCAPS = 0x0080,
CFM_HIDDEN = 0x0100,
CFM_OUTLINE = 0x0200,
CFM_SHADOW = 0x0400,
CFM_EMBOSS = 0x0800,
CFM_IMPRINT = 0x1000,
CFM_DISABLED = 0x2000,
CFM_REVISED = 0x4000,
CFM_BACKCOLOR = 0x04000000,
CFM_LCID = 0x02000000,
CFM_UNDERLINETYPE = 0x00800000,
CFM_WEIGHT = 0x00400000,
CFM_SPACING = 0x00200000,
CFM_KERNING = 0x00100000,
CFM_STYLE = 0x00080000,
CFM_ANIMATION = 0x00040000,
CFM_REVAUTHOR = 0x00008000,
CFM_SUBSCRIPT = 0x00010000,
CFM_SUPERSCRIPT = 0x00020000
// CFM_SUBorSUPERSCRIPT = 0x00030000
}
[Flags]
public enum CharFormatEffects : uint
{
CFE_NONE = 0,
CFE_BOLD = 0x0001,
CFE_ITALIC = 0x0002,
CFE_UNDERLINE = 0x0004,
CFE_STRIKEOUT = 0x0008,
CFE_PROTECTED = 0x0010,
CFE_LINK = 0x0020,
CFE_AUTOBACKCOLOR = 0x04000000, // NOTE: this corresponds to CFM_BACKCOLOR, which controls it
CFE_AUTOCOLOR = 0x40000000, // NOTE: this corresponds to CFM_COLOR, which controls it
CFE_SUBSCRIPT = 0x00010000, // Superscript and subscript are
CFE_SUPERSCRIPT = 0x00020000, // mutually exclusive
CFE_SMALLCAPS = 0x0040,
CFE_ALLCAPS = 0x0080,
CFE_HIDDEN = 0x0100,
CFE_OUTLINE = 0x0200,
CFE_SHADOW = 0x0400,
CFE_EMBOSS = 0x0800,
CFE_IMPRINT = 0x1000,
CFE_DISABLED = 0x2000,
CFE_REVISED = 0x4000
}
public enum CharUnderline : byte
{
CFU_UNDERLINENONE = 0,
CFU_UNDERLINE = 1,
CFU_UNDERLINEWORD = 2, // displayed as ordinary underline
CFU_UNDERLINEDOUBLE = 3, // displayed as ordinary underline
CFU_UNDERLINEDOTTED = 4,
CFU_UNDERLINEDASH = 5,
CFU_UNDERLINEDASHDOT = 6,
CFU_UNDERLINEDASHDOTDOT = 7,
CFU_UNDERLINEWAVE = 8,
CFU_UNDERLINETHICK = 9,
CFU_INVERT = 0xFE // For IME composition fake a selection.
}
[Flags]
public enum ParaFormatMasks : uint
{
PFM_NONE = 0,
PFM_STARTINDENT = 0x00000001,
PFM_RIGHTINDENT = 0x00000002,
PFM_OFFSET = 0x00000004,
PFM_ALIGNMENT = 0x00000008,
PFM_TABSTOPS = 0x00000010,
PFM_NUMBERING = 0x00000020,
PFM_SPACEBEFORE = 0x00000040,
PFM_SPACEAFTER = 0x00000080,
PFM_LINESPACING = 0x00000100,
PFM_RESERVED = 0x00000200,
PFM_STYLE = 0x00000400,
PFM_BORDER = 0x00000800,
PFM_SHADING = 0x00001000,
PFM_NUMBERINGSTYLE = 0x00002000,
PFM_NUMBERINGTAB = 0x00004000,
PFM_NUMBERINGSTART = 0x00008000,
// PFM_DIR = 0x00010000,
PFM_RTLPARA = 0x00010000,
PFM_KEEP = 0x00020000,
PFM_KEEPNEXT = 0x00040000,
PFM_PAGEBREAKBEFORE = 0x00080000,
PFM_NOLINENUMBER = 0x00100000,
PFM_NOWIDOWCONTROL = 0x00200000,
PFM_DONOTHYPHEN = 0x00400000,
PFM_SIDEBYSIDE = 0x00800000,
PFM_TABLEROWDELIMITER = 0x10000000,
PFM_TEXTWRAPPINGBREAK = 0x20000000,
PFM_TABLE = 0x40000000,
PFM_OFFSETINDENT = 0x80000000
}
public enum ParaFormatEffects : ushort
{
PFE_RTLPARA = 0x0001,
PFE_KEEP = 0x0002,
PFE_KEEPNEXT = 0x0004,
PFE_PAGEBREAKBEFORE = 0x0008,
PFE_NOLINENUMBER = 0x0010,
PFE_NOWIDOWCONTROL = 0x0020,
PFE_DONOTHYPHEN = 0x0040,
PFE_SIDEBYSIDE = 0x0080,
PFE_TABLEROW = 0xc000, /* These 3 options are mutually */
PFE_TABLECELLEND = 0x8000, /* exclusive and each imply */
PFE_TABLECELL = 0x4000, /* that para is part of a table*/
}
public enum ParaAlignment : ushort
{
PFA_LEFT = 1,
PFA_RIGHT = 2,
PFA_CENTER = 3,
PFA_JUSTIFY = 4,
PFA_FULL_INTERWORD = 5
}
public enum ParaNumbering : ushort
{
PFN_NONE = 0,
PFN_BULLET = 1,
PFN_ARABIC = 2,
PFN_LOWER = 3,
PFN_UPPER = 4,
PFN_LOWERROMAN = 5,
PFN_UPPERROMAN = 6,
PFN_UNI = 7
}
public enum ParaSpacing : byte
{
PFS_SINGLE = 0,
PFS_ONEANDONEHALF = 1,
PFS_DOUBLE = 2,
PFS_EXACTSINGLEMIN = 3,
PFS_EXACT = 4,
PFS_EXACT20 = 5
}
#endregion
#region Structures
//struct CharRange
//{
// public int cpMin;
// public int cpMax;
//}
[StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Auto)]
public struct CharFormat2
{
public int cbSize;
public uint dwMask;
public uint dwEffects;
public int yHeight;
public int yOffset;
public int crTextColor;
public byte bCharSet;
public byte bPitchAndFamily;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
public string szFaceName;
public short wWeight;
public short sSpacing;
public int crBackColor;
public int lcid;
public int dwReserved;
public short sStyle;
public short wKerning;
public byte bUnderlineType;
public byte bAnimation;
public byte bRevAuthor;
public byte bReserved1;
}
public class CharFormatTwo
{
public CharFormatTwo(CharFormat2 cf)
{
_CharFormat2 = cf;
}
private CharFormat2 _CharFormat2;
[Browsable(false)]
public CharFormat2 CharFormat2
{
get { return _CharFormat2; }
}
[Browsable(false)]
public int cbSize
{
get { return _CharFormat2.cbSize; }
set { _CharFormat2.cbSize = value; }
}
[Editor(typeof(FlagEnumUIEditor), typeof(System.Drawing.Design.UITypeEditor))]
public CharFormatMasks dwMask
{
get { return (CharFormatMasks)_CharFormat2.dwMask; }
set { _CharFormat2.dwMask = (uint)value; }
}
[Editor(typeof(FlagEnumUIEditor), typeof(System.Drawing.Design.UITypeEditor))]
public CharFormatEffects dwEffects
{
get { return (CharFormatEffects)_CharFormat2.dwEffects; }
set { _CharFormat2.dwEffects = (uint)value; }
}
public int yHeight
{
get { return _CharFormat2.yHeight; }
set { _CharFormat2.yHeight = value; }
}
public int yOffset
{
get { return _CharFormat2.yOffset; }
set { _CharFormat2.yOffset = value; }
}
private Color Int2Color(int color)
{
return Color.FromArgb(color % 256, (color / 256) % 256, color / (256 * 256));
}
private int Color2Int(Color color)
{
return color.R + (color.G * 256) + (color.B * 256 * 256);
}
public Color crTextColor
{
get { return Int2Color(_CharFormat2.crTextColor); }
set { _CharFormat2.crTextColor = Color2Int(value); }
}
public byte bCharSet
{
get { return _CharFormat2.bCharSet; }
set { _CharFormat2.bCharSet = value; }
}
public byte bPitchAndFamily
{
get { return _CharFormat2.bPitchAndFamily; }
set { _CharFormat2.bPitchAndFamily = value; }
}
public string szFaceName
{
get { return _CharFormat2.szFaceName; }
set { _CharFormat2.szFaceName = value; }
}
public short wWeight
{
get { return _CharFormat2.wWeight; }
set { _CharFormat2.wWeight = value; }
}
public short sSpacing
{
get { return _CharFormat2.sSpacing; }
set { _CharFormat2.sSpacing = value; }
}
public Color crBackColor
{
get { return Int2Color(_CharFormat2.crBackColor); }
set { _CharFormat2.crBackColor = Color2Int(value); }
}
public int lcid
{
get { return _CharFormat2.lcid; }
set { _CharFormat2.lcid = value; }
}
public int dwReserved
{
get { return _CharFormat2.dwReserved; }
set { _CharFormat2.dwReserved = value; }
}
public short sStyle
{
get { return _CharFormat2.sStyle; }
set { _CharFormat2.sStyle = value; }
}
public short wKerning
{
get { return _CharFormat2.wKerning; }
set { _CharFormat2.wKerning = value; }
}
public CharUnderline bUnderlineType
{
get { return (CharUnderline)_CharFormat2.bUnderlineType; }
set { _CharFormat2.bUnderlineType = (byte)value; }
}
public byte bAnimation
{
get { return _CharFormat2.bAnimation; }
set { _CharFormat2.bAnimation = value; }
}
public byte bRevAuthor
{
get { return _CharFormat2.bRevAuthor; }
set { _CharFormat2.bRevAuthor = value; }
}
public byte bReserved1
{
get { return _CharFormat2.bReserved1; }
set { _CharFormat2.bReserved1 = value; }
}
}
[StructLayout(LayoutKind.Sequential, Pack = 4)]
public struct ParaFormat2
{
public int cbSize;
public int dwMask;
public ushort wNumbering;
public short wEffects;
public int dxStartIndent;
public int dxRightIndent;
public int dxOffset;
public short wAlignment;
public short cTabCount;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public int[] rgxTabs;
public int dySpaceBefore;
public int dySpaceAfter;
public int dyLineSpacing;
public short sStyle;
public byte bLineSpacingRule;
public byte bOutlineLevel;
public short wShadingWeight;
public short wShadingStyle;
public short wNumberingStart;
public short wNumberingStyle;
public short wNumberingTab;
public short wBorderSpace;
public short wBorderWidth;
public short wBorders;
}
public class ParaFormatTwo
{
private ParaFormat2 _ParaFormat2;
public ParaFormatTwo(ParaFormat2 pf)
{
_ParaFormat2 = pf;
}
public ParaFormat2 ParaFormat2
{
get { return _ParaFormat2; }
}
public int cbSize
{
get { return _ParaFormat2.cbSize; }
set { _ParaFormat2.cbSize = value; }
}
[Editor(typeof(FlagEnumUIEditor), typeof(System.Drawing.Design.UITypeEditor))]
public ParaFormatMasks dwMask
{
get { return (ParaFormatMasks)_ParaFormat2.dwMask; }
set { _ParaFormat2.dwMask = (int)value; }
}
public ParaNumbering wNumbering
{
get { return (ParaNumbering)_ParaFormat2.wNumbering; }
set { _ParaFormat2.wNumbering = (ushort)value; }
}
public ParaFormatEffects wEffects
{
get { return (ParaFormatEffects)_ParaFormat2.wEffects; }
set { _ParaFormat2.wEffects = (short)value; }
}
public int dxStartIndent
{
get { return _ParaFormat2.dxStartIndent; }
set { _ParaFormat2.dxStartIndent = value; }
}
public int dxRightIndent
{
get { return _ParaFormat2.dxRightIndent; }
set { _ParaFormat2.dxRightIndent = value; }
}
public int dxOffset
{
get { return _ParaFormat2.dxOffset; }
set { _ParaFormat2.dxOffset = value; }
}
public ParaAlignment wAlignment
{
get { return (ParaAlignment)_ParaFormat2.wAlignment; }
set { _ParaFormat2.wAlignment = (short)value; }
}
public short cTabCount
{
get { return _ParaFormat2.cTabCount; }
set { _ParaFormat2.cTabCount = value; }
}
public int[] rgxTabs
{
get { return _ParaFormat2.rgxTabs; }
set { _ParaFormat2.rgxTabs = value; }
}
public int dySpaceBefore
{
get { return _ParaFormat2.dySpaceBefore; }
set { _ParaFormat2.dySpaceBefore = value; }
}
public int dySpaceAfter
{
get { return _ParaFormat2.dySpaceAfter; }
set { _ParaFormat2.dySpaceAfter = value; }
}
public int dyLineSpacing
{
get { return _ParaFormat2.dyLineSpacing; }
set { _ParaFormat2.dyLineSpacing = value; }
}
public short sStyle
{
get { return _ParaFormat2.sStyle; }
set { _ParaFormat2.sStyle = value; }
}
public ParaSpacing bLineSpacingRule
{
get { return (ParaSpacing)_ParaFormat2.bLineSpacingRule; }
set { _ParaFormat2.bLineSpacingRule = (byte)value; }
}
public byte bOutlineLevel
{
get { return _ParaFormat2.bOutlineLevel; }
set { _ParaFormat2.bOutlineLevel = value; }
}
public short wShadingWeight
{
get { return _ParaFormat2.wShadingWeight; }
set { _ParaFormat2.wShadingWeight = value; }
}
public short wShadingStyle
{
get { return _ParaFormat2.wShadingStyle; }
set { _ParaFormat2.wShadingStyle = value; }
}
public short wNumberingStart
{
get { return _ParaFormat2.wNumberingStart; }
set { _ParaFormat2.wNumberingStart = value; }
}
public short wNumberingStyle
{
get { return _ParaFormat2.wNumberingStyle; }
set { _ParaFormat2.wNumberingStyle = value; }
}
public short wNumberingTab
{
get { return _ParaFormat2.wNumberingTab; }
set { _ParaFormat2.wNumberingTab = value; }
}
public short wBorderSpace
{
get { return _ParaFormat2.wBorderSpace; }
set { _ParaFormat2.wBorderSpace = value; }
}
public short wBorderWidth
{
get { return _ParaFormat2.wBorderWidth; }
set { _ParaFormat2.wBorderWidth = value; }
}
public short wBorders
{
get { return _ParaFormat2.wBorders; }
set { _ParaFormat2.wBorders = value; }
}
}
#endregion
#region Static Methods
public static void SetScrollLocation(RichTextBox richTextBox, Point point)
{
if (SendMessage(new HandleRef(richTextBox, richTextBox.Handle), Messages.EM_SETSCROLLPOS, 0, ref point) == 0)
throw new Win32Exception();
}
public static Point GetScrollLocation(RichTextBox richTextBox)
{
Point pt = new Point();
if (SendMessage(new HandleRef(richTextBox, richTextBox.Handle), Messages.EM_GETSCROLLPOS, 0, ref pt) == 0)
throw new Win32Exception();
return pt;
}
public static void SetBackgroundColor(RichTextBox richTextBox, Color color)
{
int clr = color.R + (color.G * 256) + (color.B * 256 * 256);
if (SendMessage(new HandleRef(richTextBox, richTextBox.Handle), Messages.EM_SETBKGNDCOLOR, 0, clr) == 0)
throw new Win32Exception();
}
public static void SetAuto(RichTextBox richTextBox)
{
if (SendMessage(new HandleRef(richTextBox, richTextBox.Handle), Messages.EM_SETOPTIONS, (int)EcoOperations.ECOOP_XOR, (int)EditControlOptions.ECO_AUTOWORDSELECTION) == 0)
throw new Win32Exception();
}
public static ParaFormatTwo GetParaFormat(RichTextBox richTextBox)
{
ParaFormat2 pf = new ParaFormat2();
pf.cbSize = Marshal.SizeOf(pf);
if (SendMessage(new HandleRef(richTextBox, richTextBox.Handle), Messages.EM_GETPARAFORMAT, 0, ref pf) == 0)
throw new Win32Exception();
return new ParaFormatTwo(pf);
}
public static void SetParaFormat(RichTextBox richTextBox, ParaFormatTwo pft)
{
ParaFormat2 pf2 = pft.ParaFormat2;
if (SendMessage(new HandleRef(richTextBox, richTextBox.Handle), Messages.EM_SETPARAFORMAT, 0, ref pf2) == 0)
{
//if(Marshal.GetLastWin32Error()!=0)
throw new Win32Exception();
}
}
public static CharFormatTwo GetCharFormat(RichTextBox richTextBox, RTBSelection selection)
{
CharFormat2 cf = new CharFormat2();
cf.cbSize = Marshal.SizeOf(cf);
if (SendMessage(new HandleRef(richTextBox, richTextBox.Handle), Messages.EM_GETCHARFORMAT, selection, ref cf) == 0)
throw new Win32Exception();
return new CharFormatTwo(cf);
}
public static void SetCharFormat(RichTextBox richTextBox, RTBSelection selection, CharFormatTwo cft)
{
CharFormat2 cf2 = cft.CharFormat2;
if (SendMessage(new HandleRef(richTextBox, richTextBox.Handle), Messages.EM_SETCHARFORMAT, selection, ref cf2) == 0)
throw new Win32Exception();
}
public static void SetHighlightColor(RichTextBox richTextBox, RTBSelection selection, Color color)
{
CharFormatTwo cft = GetCharFormat(richTextBox, selection);
cft.crBackColor = color;
cft.dwEffects = 0;
cft.dwMask = 0;
cft.dwMask |= CharFormatMasks.CFM_BACKCOLOR;
SetCharFormat(richTextBox, selection, cft);
}
public static void SetLineSpacing(RichTextBox richTextBox, ParaSpacing type)
{
ParaFormatTwo pft = GetParaFormat(richTextBox);
pft.bLineSpacingRule = type; // For now: RTBAPI.ParaSpacing.PFS_EXACT;
pft.dwMask = 0;
pft.dwMask |= ParaFormatMasks.PFM_LINESPACING;
pft.dwMask |= ParaFormatMasks.PFM_SPACEAFTER;
// get the monitor's resolution in DPI and use it to set the linespacing value for
// the richtextbox. Note that without this, the Arial Unicode font made the appearance of
// almost double linespacing. Using PFS_Exact makes it appear as regular single spacing.
Graphics g = richTextBox.CreateGraphics();
int dpi = Convert.ToInt32((g.DpiX + g.DpiY) / 2);
g.Dispose();
// dyLineSpacing is Spacing between lines. the PFS_EXACT sets line spacing as the spacing from one
//line to the next, in twips - thus the 1440.
pft.dyLineSpacing = Convert.ToInt32(.5 + richTextBox.SelectionFont.GetHeight(dpi)) * 1440 / dpi;
SetParaFormat(richTextBox, pft);
}
public static bool IsSuperScript(RichTextBox richTextBox)
{
CharFormatTwo cft = GetCharFormat(richTextBox, RTBSelection.SCF_SELECTION);
return ((cft.dwEffects & CharFormatEffects.CFE_SUPERSCRIPT) == CharFormatEffects.CFE_SUPERSCRIPT);
}
public static bool IsSubScript(RichTextBox richTextBox)
{
CharFormatTwo cft = GetCharFormat(richTextBox, RTBSelection.SCF_SELECTION);
return ((cft.dwEffects & CharFormatEffects.CFE_SUBSCRIPT) == CharFormatEffects.CFE_SUBSCRIPT);
}
public static void ToggleSubscript(bool bSet, RichTextBox richTextBox, RTBSelection selection)
{
CharFormatTwo cft = GetCharFormat(richTextBox, selection); // RTBSelection.SCF_SELECTION);
if (bSet)
{
cft.dwEffects |= CharFormatEffects.CFE_SUBSCRIPT;
cft.dwMask |= CharFormatMasks.CFM_SUBSCRIPT;
}
else
{
cft.dwEffects &= ~RTBAPI.CharFormatEffects.CFE_SUBSCRIPT;
}
SetCharFormat(richTextBox, selection, cft);
}
public static void ToggleSuperscript(bool bSet, RichTextBox richTextBox, RTBSelection selection)
{
CharFormatTwo cft = RTBAPI.GetCharFormat(richTextBox, selection); // RTBAPI.RTBSelection.SCF_SELECTION);
if (bSet)
{
cft.dwEffects |= RTBAPI.CharFormatEffects.CFE_SUPERSCRIPT;
cft.dwMask |= RTBAPI.CharFormatMasks.CFM_SUPERSCRIPT;
}
else
{
cft.dwEffects &= ~RTBAPI.CharFormatEffects.CFE_SUPERSCRIPT;
}
SetCharFormat(richTextBox, selection, cft);
}
public static bool IsLink(RichTextBox richTextBox)
{
CharFormatTwo cft = GetCharFormat(richTextBox, RTBSelection.SCF_SELECTION);
return ((cft.dwEffects & CharFormatEffects.CFE_PROTECTED) == CharFormatEffects.CFE_PROTECTED);
}
public static void UnProtect(RichTextBox richTextBox) //, string type, string text, string link)
{
//richTextBox.DetectUrls = false;
CharFormatTwo cft = GetCharFormat(richTextBox, RTBAPI.RTBSelection.SCF_SELECTION); ;
//int position = richTextBox.SelectionStart = richTextBox.TextLength;
//richTextBox.SelectionLength = 0;
//richTextBox.SelectedRtf = @"{\rtf1\ansi " + text + @"\v #" + link + @"\v0}";
//richTextBox.SelectedRtf = "{" + string.Format(@"\rtf1\ansi\protect\v {0}\v0 {1}\v #{2}", type, text, link) + "}";
//richTextBox.Select(position, type.Length + text.Length + link.Length + 1);
cft.dwMask = RTBAPI.CharFormatMasks.CFM_PROTECTED;
cft.dwEffects = 0;
// The lines below can be used to allow link text to be edited
//charFormat.dwMask = RTBAPI.CharFormatMasks.CFM_LINK;
//charFormat.dwEffects = RTBAPI.CharFormatEffects.CFE_LINK;
SetCharFormat(richTextBox, RTBSelection.SCF_SELECTION, cft);
//rtbRTF.SetSelectionLink(true);
//richTextBox.SelectionStart = richTextBox.TextLength;
//richTextBox.SelectionLength = 0;
}
public static void SetLink(RichTextBox richTextBox, string type, string text, string link)
{
richTextBox.DetectUrls = false;
CharFormatTwo cft = GetCharFormat(richTextBox, RTBAPI.RTBSelection.SCF_SELECTION); ;
int position = richTextBox.SelectionStart = richTextBox.TextLength;
richTextBox.SelectionLength = 0;
//richTextBox.SelectedRtf = @"{\rtf1\ansi " + text + @"\v #" + link + @"\v0}";
richTextBox.SelectedRtf = "{" + string.Format(@"\rtf1\ansi\protect\v {0}\v0 {1}\v #{2}", type, text, link) + "}";
richTextBox.Select(position, type.Length + text.Length + link.Length + 1);
cft.dwMask = RTBAPI.CharFormatMasks.CFM_LINK | RTBAPI.CharFormatMasks.CFM_PROTECTED;
cft.dwEffects = RTBAPI.CharFormatEffects.CFE_LINK | RTBAPI.CharFormatEffects.CFE_PROTECTED;
// The lines below can be used to allow link text to be edited
//charFormat.dwMask = RTBAPI.CharFormatMasks.CFM_LINK;
//charFormat.dwEffects = RTBAPI.CharFormatEffects.CFE_LINK;
SetCharFormat(richTextBox, RTBSelection.SCF_SELECTION, cft);
//rtbRTF.SetSelectionLink(true);
richTextBox.SelectionStart = richTextBox.TextLength;
richTextBox.SelectionLength = 0;
}
#endregion
}
}

View File

@ -0,0 +1,36 @@
namespace Volian.Controls.Library
{
partial class RichTextBox41
{
/// <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
}
}

View File

@ -0,0 +1,45 @@
using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Drawing;
using VEPROMS.CSLA.Library;
using System.Text.RegularExpressions;
namespace Volian.Controls.Library
{
public partial class RichTextBox41 : RichTextBox
{
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
static extern IntPtr LoadLibrary(string lpFileName);
protected override CreateParams CreateParams
{
get
{
CreateParams prams = base.CreateParams;
if (LoadLibrary("msftedit.dll") != IntPtr.Zero)
{
//prams.ExStyle |= 0x020; // transparent
prams.ClassName = "RICHEDIT50W";
}
return prams;
}
}
public RichTextBox41()
{
InitializeComponent();
}
public RichTextBox41(IContainer container)
{
container.Add(this);
InitializeComponent();
}
}
}

View File

@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Volian.Controls.Library
{
public static class RomanNumeral
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private enum RomanOffset : int
{
Hundreds = 2,
Tens = 4,
Units = 6
}
private static string _Romans = "MDCLXVI";
private static string RomanPart(RomanOffset offset, int value)
{
int iFive = value / 5;
int iUnits = value % 5;
int iFour = iUnits / 4;
return _Romans.Substring(((int)offset), iFour) +
_Romans.Substring(((int)offset) - iFive - iFour, iFive | iFour) +
"".PadRight(iUnits % 4, _Romans[((int)offset)]);
}
public static string Convert(int number)
{
int thousands = number / 1000;
int hundreds = (number % 1000) / 100;
int tens = (number % 100) / 10;
int units = number % 10;
return "".PadRight(thousands, _Romans[0]) +
RomanPart(RomanOffset.Hundreds, hundreds) +
RomanPart(RomanOffset.Tens, tens) +
RomanPart(RomanOffset.Units, units);
}
// private static int[] _TestRomans = new int[] {
// 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,25,30,40,50,60,69,70,80,90,99,
// 100,200,400,500,600,666,700,800,900,1000,1444,1666,1945,1997,1999,2000,2007,3000
// };
// public static void ShowRomans()
// {
// for (int i = 0; i < _TestRomans.Length; i++)
// {
// if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("{0},{1}", _TestRomans[i], Convert(_TestRomans[i]));
// }
// //if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("{0},{1}", 4, Convert(4));
// //if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("{0},{1}", 5, Convert(5));
// //if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("{0},{1}", 6, Convert(6));
// //if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("{0},{1}", 8, Convert(8));
// //if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("{0},{1}", 9, Convert(9));
// }
}
}

View File

@ -0,0 +1,125 @@
using System;
using System.Collections.Generic;
using System.Text;
using VEPROMS.CSLA.Library;
namespace Volian.Controls.Library
{
class TemporaryFormat
{
private static string[] _TabFormats = new string[] {
"<seq>",// 0 //STANDARD
" <number> ",// 1 //HIGH
"[<number>] ",// 2 //IMMEDIATE
"o ",// 3 //AND
"o ",// 4 //OR
"CAUTION ",// 5 //CAUTION
"NOTE ",// 6 //NOTE
"",// 7 //TABLE
" <number>* ",// 8 //CONTINUOUS
"",// 9 //AERTABLE
"o ",// 10 //EQUIPMENTLIST
"",// 11 //TITLE
"",// 12 //PAGENUMBER
"o ",// 13 //EQUIPMENTWBLANK
"",// 14 //PROCNUMBER
"",// 15 //REVNUMBER
"",// 16 //ACCPAGES
"",// 17 //LOSSOFAC
"o ",// 18 //EXPLICITAND
"CAUTION ",// 19 //CAUTION1
"CAUTION ",// 20 //CAUTION2
"NOTE ",// 21 //NOTE1
"NOTE ",// 22 //NOTE2
"",// 23 //PARAGRAPH
"",// 24 //DEFAULT
"NOTE ",// 25 //NOTE3
"CAUTION ",// 26 //CAUTION3
"NOTE ",// 27 //NOTE4
"CAUTION ",// 28 //CAUTION4
"o ",// 29 //EQUIPMENTOPT
"o ",// 30 //EQUIPMENTOPTWBLANK
"NOTE ",// 31 //NOTE5
"",// 32 //BORDERLESSAERTABLE
"",// 33 //BORDERLESSTABLE
"o ",// 34 //IMPLICITOR
"",// 35 //FIGURE
"",// 36 //AERFIGURE
"",// 37 //BORDERLESSFIGURE
"",// 38 //BORDERLESSAERFIGURE
"",// 39 //RNOTYPE
" <number>! ",// 40 //HIGH5
"",// 41 //TITLEWITHTEXTRIGHT
"",// 42 //TITLEWITHTEXTBELOW
"",// 43 //CONTACSEQUENTIAL
"o ",// 44 //CONTACAND
"o ",// 45 //CONTACOR
"" // 46 //CONTACPARAGRAPH
};
private static string[] SeqTabFormat = new string[] {
"<number>. ",
"<alpha>. ",
"<number>) ",
"<alpha>) "
};
public static string TabFormat(DisplayItem myVlnCSLARTB)
{
string format = string.Empty;
if (myVlnCSLARTB.MyItem != null)
{
int typ = (int)myVlnCSLARTB.MyItem.MyContent.Type;
if (typ >= 20000)
{
if (myVlnCSLARTB.RNOLevel > 0 && IsRNO(myVlnCSLARTB.MyItem)) return "";
// Step 1: Get TabFormat from Format
format = _TabFormats[typ % 10000];
if (format == "<seq>")
{
format = SeqTabFormat[myVlnCSLARTB.SeqLevel % SeqTabFormat.Length];
}
}
}
return format;
}
public static string TabFormat(ItemInfo item, int seqLevel)
{
string format = string.Empty;
if (item != null)
{
if (IsRNO(item)) return "";
if ((item.MyContent.Type / 10000) == 2)
{
// Step 1: Get TabFormat from Format
format = _TabFormats[((int)item.MyContent.Type) % 10000];
if (format == "<seq>")
{
format = SeqTabFormat[seqLevel];
}
}
}
return format;
}
// TODO: Move these to ItemExt.cs as properties
public static bool IsHigh(ItemInfo item)
{
// check to see if ActiveParent is a section
if(item.MyContent.Type / 10000 != 2)return false;
ItemInfo parent = (ItemInfo)item.ActiveParent;
if ((parent.MyContent.Type / 10000) == 1)
return true;
return false;
}
public static bool IsSequential(ItemInfo item)
{
//if (IsHigh(item)) return true;
if (((item.MyContent.Type / 10000) == 2) && ((((int)item.MyContent.Type) % 10000) == 0)) return true;
return false;
}
public static bool IsRNO(ItemInfo item)
{
if(item != null)
return ((item.ItemPartCount > 0) && (item.ItemParts[0].PartType == E_FromType.RNO));
return false;
}
}
}

View File

@ -0,0 +1,134 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{8556527C-6615-487F-8AF7-22EBC3EF0268}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Volian.Controls.Library</RootNamespace>
<AssemblyName>Volian.Controls.Library</AssemblyName>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Csla, Version=2.1.4.0, Culture=neutral, PublicKeyToken=93be5fdc093e4c30, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>F:\CSLA\csla20cs-2.1.4-070223\csla20cs\csla20cs\Csla\bin\Debug\Csla.dll</HintPath>
</Reference>
<Reference Include="DevComponents.DotNetBar2, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7eb7c3a35b91de04, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Program Files\DotNetBar\DevComponents.DotNetBar2.dll</HintPath>
</Reference>
<Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>F:\Log4Net\log4net-1.2.10\bin\net\2.0\debug\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.configuration" />
<Reference Include="System.Data" />
<Reference Include="System.Design" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="VEPROMS.CSLA.Library, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\VEPROMS.CSLA.Library\bin\Debug\VEPROMS.CSLA.Library.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="AlphabeticalNumbering.cs" />
<Compile Include="DisplayItem.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="DisplayItem.designer.cs">
<DependentUpon>DisplayItem.cs</DependentUpon>
</Compile>
<Compile Include="DisplayPanel.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="DisplayPanel.designer.cs">
<DependentUpon>DisplayPanel.cs</DependentUpon>
</Compile>
<Compile Include="DisplayRTBSimple.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="DisplayRTBSimple.designer.cs">
<DependentUpon>DisplayRTBSimple.cs</DependentUpon>
</Compile>
<Compile Include="FlagEnumEditor.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RichTextBox41.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="RichTextBox41.Designer.cs">
<DependentUpon>RichTextBox41.cs</DependentUpon>
</Compile>
<Compile Include="RomanNumeral.cs" />
<Compile Include="RTBAPI.cs" />
<Compile Include="TemporaryFormat.cs" />
<Compile Include="vlnExpander.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="vlnExpander.designer.cs">
<DependentUpon>vlnExpander.cs</DependentUpon>
</Compile>
<Compile Include="DisplayRTB.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="DisplayRTB.designer.cs">
<DependentUpon>DisplayRTB.cs</DependentUpon>
</Compile>
<Compile Include="vlnTreeView.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="vlnTreeView.Designer.cs">
<DependentUpon>vlnTreeView.cs</DependentUpon>
</Compile>
<Service Include="{94E38DFF-614B-4cbd-B67C-F211BB35CE8B}" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="DisplayItem.resx">
<DependentUpon>DisplayItem.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="vlnExpander.resx">
<DependentUpon>vlnExpander.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="DisplayRTB.resx">
<DependentUpon>DisplayRTB.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -0,0 +1,10 @@
""
{
"FILE_VERSION" = "9237"
"ENLISTMENT_CHOICE" = "NEVER"
"PROJECT_FILE_RELATIVE_PATH" = ""
"NUMBER_OF_EXCLUDED_FILES" = "0"
"ORIGINAL_PROJECT_FILE_PATH" = ""
"NUMBER_OF_NESTED_PROJECTS" = "0"
"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER"
}

View File

@ -0,0 +1,221 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
namespace Volian.Controls.Library
{
public enum ExpanderStyle : int
{
Square, Round
}
public delegate void vlnExpanderEvent(object sender, vlnExpanderEventArgs args);
public partial class vlnExpander : UserControl
{
#region Events
public event vlnExpanderEvent BeforeExpand;
private void OnBeforeExpand(object sender, vlnExpanderEventArgs args)
{
if (BeforeExpand != null) BeforeExpand(sender, args);
}
public event vlnExpanderEvent BeforeColapse;
private void OnBeforeColapse(object sender, vlnExpanderEventArgs args)
{
if (BeforeColapse != null) BeforeColapse(sender, args);
}
public event vlnExpanderEvent AttachmentClick;
private void OnAttachmentClick(object sender, vlnExpanderEventArgs args)
{
if (AttachmentClick != null) AttachmentClick(sender, args);
}
#endregion
public vlnExpander()
{
InitializeComponent();
}
private bool _Expanded;
public bool Expanded
{
get { return _Expanded; }
set
{
if (value) OnBeforeExpand(this, new vlnExpanderEventArgs());
else OnBeforeColapse(this, new vlnExpanderEventArgs());
_Expanded = value;
this.Refresh();
}
}
public void ShowExpanded()
{
_Expanded = true;
this.Refresh();
}
private int _Trans1 = 128;
public int Trans1
{
get { return _Trans1; }
set
{
_Trans1 = value;
this.Refresh();
}
}
private int _Trans2 = 128;
public int Trans2
{
get { return _Trans2; }
set
{
_Trans2 = value; this.Refresh();
}
}
private Color _Color1 = Color.Aquamarine;
public Color Color1
{
get { return _Color1; }
set
{
_Color1 = value; this.Refresh();
}
}
private Color _Color2 = Color.Violet;
public Color Color2
{
get { return _Color2; }
set
{
_Color2 = value; this.Refresh();
}
}
private int _PenWidth = 0;
public int PenWidth
{
get { return _PenWidth; }
set { _PenWidth = value; this.Refresh(); }
}
private int _WidthFactor=7;
public int WidthFactor
{
get { return _WidthFactor; }
set { _WidthFactor = value; this.Refresh(); }
}
private Color _BorderColor=Color.Silver;
public Color BorderColor
{
get { return _BorderColor; }
set { _BorderColor = value; this.Refresh(); }
}
private int _GradientAngle=45;
public int GradientAngle
{
get { return _GradientAngle; }
set { _GradientAngle = value; this.Refresh(); }
}
private bool _Attachment = false;
public bool Attachment
{
get { return _Attachment; }
set { _Attachment = value; this.Refresh(); }
}
private ExpanderStyle _Style = ExpanderStyle.Square;
public ExpanderStyle Style
{
get { return _Style; }
set { _Style = value; this.Refresh(); }
}
private void vlnExpander_Paint(object sender, PaintEventArgs e)
{
Color c1 = Color.FromArgb(_Trans1, _Color1);
Color c2 = Color.FromArgb(_Trans2, _Color2);
Brush b = new System.Drawing.Drawing2D.LinearGradientBrush(ClientRectangle, c1, c2, _GradientAngle);
//Brush b2 = new System.Drawing.Drawing2D.LinearGradientBrush(ClientRectangle, c2, c2, _GradientAngle);
Pen p = new Pen(ForeColor);
Brush b2 = p.Brush;
float smallest = this.Width;
if (this.Height < this.Width) smallest = this.Height;
float weight = (smallest - 1) / 12;
float radius = (smallest - 1) / 2;
float diameter = 2 * radius;
if (this.Height <= diameter) diameter = this.Height - 1;
e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
p = new Pen(_BorderColor, _PenWidth);
int penWidth = ClientRectangle.Width / _WidthFactor;
switch (_Style)
{
case ExpanderStyle.Round:
//e.Graphics.FillEllipse(Brushes.Gray, 0F, 0F, diameter, diameter);
//e.Graphics.DrawRectangle(p, new Rectangle(0, 0, leg * 2 + penWidth * 3, leg * 2 + penWidth * 3));
// Draw a white cross-hair
//e.Graphics.FillRectangle(Brushes.White, 2 * weight , radius - weight, diameter - 4 * weight, weight * 2);
//e.Graphics.FillRectangle(Brushes.White, radius - weight, 2 * weight, weight * 2, diameter - 4 * weight);
if(!Attachment) e.Graphics.FillEllipse(b, 0F, 0F, diameter, diameter);
DrawInterior(e, b, b2, weight, radius, diameter);
e.Graphics.DrawEllipse(p, 0, 0, diameter, diameter);
p.Dispose();
b.Dispose();
b2.Dispose();
break;
case ExpanderStyle.Square:
//c1 = Color.FromArgb(_Trans1, _Color1);
//c2 = Color.FromArgb(_Trans2, _Color2);
//b = new System.Drawing.Drawing2D.LinearGradientBrush(ClientRectangle, c1, c2, _GradientAngle);
int leg = ((ClientRectangle.Width - 3 * penWidth) / 2) - 1;
if (!Attachment) e.Graphics.FillRectangle(b, new Rectangle(0, 0, leg * 2 + penWidth * 3, leg * 2 + penWidth * 3));
int center = leg + penWidth;
int limit = 2 * (penWidth + leg);
p = new Pen(_BorderColor, _PenWidth);
e.Graphics.DrawRectangle(p, new Rectangle(0, 0, leg * 2 + penWidth * 3, leg * 2 + penWidth * 3));
//b = new SolidBrush(this.ForeColor);
DrawInterior(e, b, b2, weight, radius, diameter);
//e.Graphics.FillRectangle(b, new Rectangle(penWidth, center, leg * 2 + penWidth, penWidth));
//if (!_Expanded) e.Graphics.FillRectangle(b, new Rectangle(center, penWidth, penWidth, leg * 2 + penWidth));
////pe.Graphics.DrawLine(p, new Point(penWidth, center), new Point(limit, center));
////if (!Expanded) pe.Graphics.DrawLine(p, new Point(center, penWidth), new Point(center, limit));
p.Dispose();
b.Dispose();
break;
}
}
private void DrawInterior(PaintEventArgs e, Brush bBackground, Brush bForeground, float weight, float radius, float diameter)
{
if (Attachment)
{
PointF[] myArrow = new PointF[7];
myArrow[0] = new PointF(7 * weight, 3 * weight);
myArrow[1] = new PointF(11 * weight, 6 * weight);
myArrow[2] = new PointF(7 * weight, 9 * weight);
myArrow[3] = new PointF(7 * weight, 7 * weight);
myArrow[4] = new PointF(2 * weight, 7 * weight);
myArrow[5] = new PointF(2 * weight, 5 * weight);
myArrow[6] = new PointF(7 * weight, 5 * weight);
e.Graphics.FillPolygon(bBackground, myArrow);
}
else
{
e.Graphics.FillRectangle(bForeground, 2 * weight, radius - weight, diameter - 4 * weight, weight * 2);
if (!_Expanded) e.Graphics.FillRectangle(bForeground, radius - weight, 2 * weight, weight * 2, diameter - 4 * weight);
}
}
private void vlnExpander_Resize(object sender, EventArgs e)
{
this.Width = this.Height;
this.Refresh();
}
private void vlnExpander_MouseDown(object sender, MouseEventArgs e)
{
if (Attachment)
OnAttachmentClick(sender, new vlnExpanderEventArgs());
else
Expanded = !Expanded;
}
}
public partial class vlnExpanderEventArgs : EventArgs
{
public vlnExpanderEventArgs()
{ ;}
}
}

View File

@ -0,0 +1,78 @@
namespace Volian.Controls.Library
{
partial class vlnExpander
{
/// <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.components = new System.ComponentModel.Container();
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.expandToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.expandAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.contextMenuStrip1.SuspendLayout();
this.SuspendLayout();
//
// contextMenuStrip1
//
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.expandToolStripMenuItem,
this.expandAllToolStripMenuItem});
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(136, 48);
//
// expandToolStripMenuItem
//
this.expandToolStripMenuItem.Name = "expandToolStripMenuItem";
this.expandToolStripMenuItem.Size = new System.Drawing.Size(135, 22);
this.expandToolStripMenuItem.Text = "Expand";
//
// expandAllToolStripMenuItem
//
this.expandAllToolStripMenuItem.Name = "expandAllToolStripMenuItem";
this.expandAllToolStripMenuItem.Size = new System.Drawing.Size(135, 22);
this.expandAllToolStripMenuItem.Text = "Expand All";
//
// vlnExpander
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Name = "vlnExpander";
this.Size = new System.Drawing.Size(85, 77);
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.vlnExpander_MouseDown);
this.Resize += new System.EventHandler(this.vlnExpander_Resize);
this.Paint += new System.Windows.Forms.PaintEventHandler(this.vlnExpander_Paint);
this.contextMenuStrip1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
private System.Windows.Forms.ToolStripMenuItem expandToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem expandAllToolStripMenuItem;
}
}

View File

@ -0,0 +1,123 @@
<?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>
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@ -0,0 +1,36 @@
namespace Volian.Controls.Library
{
partial class vlnTreeView
{
/// <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
}
}

View File

@ -0,0 +1,633 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices; // For DragHelper
using System.Reflection;
using VEPROMS.CSLA.Library;
namespace Volian.Controls.Library
{
public delegate void vlnTreeViewEvent(object sender, vlnTreeEventArgs args);
public delegate bool vlnTreeViewBoolEvent(object sender, vlnTreeEventArgs args);
public delegate TreeNode vlnTreeViewTreeNodeEvent(object sender, vlnTreeEventArgs args);
//public delegate void vlnTreeViewDDEvent(object sender, System.Windows.Forms.DragEventArgs args);
public partial class vlnTreeEventArgs
{
#region Business Methods
private TreeNode _Node;
public TreeNode Node
{
get { return _Node; }
set { _Node = value; }
}
private TreeNode _Destination=null;
public TreeNode Destination
{
get { return _Destination; }
set { _Destination = value; }
}
private int _Index;
public int Index
{
get { return _Index; }
set { _Index = value; }
}
#endregion
#region Factory Methods
private vlnTreeEventArgs() { ;}
public vlnTreeEventArgs(TreeNode node)
{
_Node = node;
}
public vlnTreeEventArgs(TreeNode node, TreeNode destination, int index)
{
_Node = node;
_Destination = destination;
_Index = index;
}
#endregion
}
public partial class vlnTreeView : TreeView
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#region Events
public event vlnTreeViewEvent NodeDragDrop;
private void OnNodeDragDrop(object sender, vlnTreeEventArgs args)
{
if (NodeDragDrop != null) NodeDragDrop(sender, args);
}
public event vlnTreeViewEvent NodeMove;
private void OnNodeMove(object sender, vlnTreeEventArgs args)
{
if (NodeMove != null) NodeMove(sender, args);
}
public event vlnTreeViewEvent NodeCopy;
private void OnNodeCopy(object sender, vlnTreeEventArgs args)
{
if (NodeCopy != null) NodeCopy(sender, args);
}
public event vlnTreeViewBoolEvent NodeDelete;
private bool OnNodeDelete(object sender, vlnTreeEventArgs args)
{
bool result = true;
if (NodeDelete != null) result = NodeDelete(sender, args);
return result;
}
public event vlnTreeViewTreeNodeEvent NodeNew;
private TreeNode OnNodeNew(object sender, vlnTreeEventArgs args)
{
if (NodeNew != null) return NodeNew(sender, args);
else return new TreeNode("New Item");
}
public event vlnTreeViewEvent NodeProperties;
private void OnNodeProperties(object sender, vlnTreeEventArgs args)
{
if (NodeProperties != null) NodeProperties(sender, args);
}
public event vlnTreeViewEvent NodeSelectionChange;
private void OnNodeSelectionChange(object sender, vlnTreeEventArgs args)
{
if (NodeSelectionChange != null) NodeSelectionChange(sender, args);
}
#endregion
#region Business Methods
ImageList _dragImageList = new ImageList();
#endregion
#region Constructors
public vlnTreeView()
{
InitializeComponent();
this.AllowDrop = true;
DragHelper.InitCommonControls();
this.ItemDrag += new ItemDragEventHandler(tv_ItemDrag);
this.DragDrop += new DragEventHandler(tv_DragDrop);
this.DragEnter += new DragEventHandler(tv_DragEnter);
this.DragLeave += new EventHandler(tv_DragLeave);
this.DragOver += new DragEventHandler(tv_DragOver);
this.MouseDown += new MouseEventHandler(tv_MouseDown);
base.AfterSelect += new TreeViewEventHandler(tv_AfterSelect);
}
private void tv_AfterSelect(object sender, TreeViewEventArgs e)
{
OnNodeSelectionChange(sender, new vlnTreeEventArgs(e.Node));
}
void tv_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
TreeNode tn = this.GetNodeAt(new Point(e.X, e.Y));
if (tn != null)
{
this.SelectedNode = tn;
Application.DoEvents();
// Display Menu
ToolStripMenuItem mi = new ToolStripMenuItem();
ContextMenu cm = new ContextMenu();
cm.MenuItems.Add("New...",new EventHandler(mi_Click));
cm.MenuItems.Add("Cut", new EventHandler(mi_Click));
cm.MenuItems.Add("Copy", new EventHandler(mi_Click));
cm.MenuItems.Add("Paste", new EventHandler(mi_Click));
cm.MenuItems.Add("Delete", new EventHandler(mi_Click));
cm.MenuItems.Add("Properties...", new EventHandler(mi_Click));
cm.Show(this, new Point(e.X, e.Y));
}
}
}
void mi_Click(object sender, EventArgs e)
{
MenuItem mi = (MenuItem)sender;
switch (mi.Text)
{
case "New..."://Add a new child node at the current location
// Should Give the option to the controling code to Add a New Node
SelectedNode.Expand();
TreeNode tn = OnNodeNew(this, new vlnTreeEventArgs(SelectedNode));
if (tn != null)
{
SelectedNode.Nodes.Add(tn);
if (LabelEdit)
tn.BeginEdit();
else
SelectedNode = tn;
}
break;
case "Cut"://Cut the selected node
// Cut to Clipboard
break;
case "Copy"://Copy the selected node
// Add to Clipboard
break;
case "Paste"://Paste the clipboard node
// this is either a copy or a move depending upon where it came from
// if it is from a cut then when the paste is done it should be set to a copy
break;
case "Delete"://Delete the selected node
if(OnNodeDelete(this, new vlnTreeEventArgs(SelectedNode)))
SelectedNode.Remove();
break;
case "Properties..."://Show the properties for the selected node
OnNodeProperties(this,new vlnTreeEventArgs(SelectedNode));
break;
default:
MessageBox.Show(string.Format("Unrecognized Menu Item '{0}'", mi.Text));
break;
}
}
#endregion
#region Cursor
private bool SetupDragCursor(ImageList il, TreeNode tn)
{
// Reset image list used for drag image
il.Images.Clear();
int howBig = tn.Bounds.Size.Width + this.Indent;
if (howBig > 256) howBig = 256;
il.ImageSize = new Size(howBig, tn.Bounds.Height);
// Create new bitmap
// This bitmap will contain the tree node image to be dragged
Bitmap bmp = new Bitmap(tn.Bounds.Width + this.Indent, tn.Bounds.Height);
// Get graphics from bitmap
Graphics gfx = Graphics.FromImage(bmp);
// Draw node icon into the bitmap
if (this.ImageList != null) gfx.DrawImage(this.ImageList.Images[0], 0, 0);
// Draw node label into bitmap
gfx.DrawString(tn.Text, this.Font, new SolidBrush(this.ForeColor),
// new SolidBrush(Color.Blue),
(float)this.Indent, 1.0f);
// Add bitmap to imagelist
_dragImageList.Images.Add(bmp);
// Get mouse position in client coordinates
Point p = this.PointToClient(Control.MousePosition);
// Compute delta between mouse position and node bounds
int dx = p.X + this.Indent - tn.Bounds.Left;
int dy = p.Y - tn.Bounds.Top;
// Begin dragging image
return DragHelper.ImageList_BeginDrag(_dragImageList.Handle, 0, dx, dy);
}
private void tv_ItemDrag(object sender, System.Windows.Forms.ItemDragEventArgs e)
{
// Get drag node and select it
try
{
TreeNode dragNode = (TreeNode)e.Item;
Type t = dragNode.GetType();
if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("Item Drag {0} - {1}", t.FullName, t.BaseType.FullName);
Type t2 = Type.GetType(t.FullName);
if(t2 != null)
if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("Item Drag {0} - {1}", t2.FullName, t2.BaseType.FullName);
this.SelectedNode = dragNode;
if (SetupDragCursor(_dragImageList, dragNode))
{
this.DoDragDrop(dragNode, DragDropEffects.Move | DragDropEffects.Copy);// Begin dragging
DragHelper.ImageList_EndDrag();// End dragging image
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("tv_ItemDrag", ex);
}
}
#endregion
public enum DropPosition : int
{
Child = 0, Before = 1, After = 2
}
private class DropLocation
{
#region Business Methods
private TreeNode _dropNode;
public TreeNode DropNode
{
get { return _dropNode; }
set { _dropNode = value; }
}
private int _index;
public int Index
{
get { return _index; }
set { _index = value; }
}
private DropPosition _position;
public DropPosition Position
{
get { return _position; }
set { _position = value; }
}
DateTime _lastScroll;
public DateTime LastScroll
{
get { return _lastScroll; }
}
private string _location = string.Empty;
#endregion
#region Constructors
public DropLocation(TreeView tv, System.Windows.Forms.DragEventArgs e, DateTime lastScroll)
{
_lastScroll = lastScroll;
_dropNode = tv.GetNodeAt(tv.PointToClient(new Point(e.X, e.Y)));
if (_dropNode == null) return;
int OffsetY = tv.PointToClient(Cursor.Position).Y - _dropNode.Bounds.Top;
if (OffsetY < _dropNode.Bounds.Height / 3) // First Third - Before
{
_index = _dropNode.Index;
_dropNode = _dropNode.Parent;
_position = DropPosition.Before;
_location = string.Format("Before1 {0}[{1}] y={2}", _dropNode.Text, _index, OffsetY);
}
else if ((OffsetY / 2) < _dropNode.Bounds.Height / 3) // Second Third - Child
{
_location = string.Format("Child {0} y={1}", _dropNode.Text, OffsetY);
_position = DropPosition.Child;
_index = 0;
if (_dropNode.Parent == null)
{
if(_MyLog.IsInfoEnabled)_MyLog.Info("Root Node");
}
}
else // Last Third - After Now I need to check the X value
{
if (_dropNode.NextVisibleNode !=null && _dropNode.Nodes.Count > 0)// Has Children - Insert first child
{
// _dropNode = _dropNode.Nodes[0];
_index = 0;
_position = DropPosition.Before;
_location = string.Format("Before2 {0}[{1}] y={2}", _dropNode.Text, _index, OffsetY);
}
else // No Children - Insert Next at various levels
{
Point pt = tv.PointToClient(new Point(e.X, e.Y));
TreeNode nextParent = _dropNode.NextNode;
if (nextParent != null) nextParent = nextParent.Parent;
do
{
_index = _dropNode.Index;
_dropNode = _dropNode.Parent;
} while (pt.X < _dropNode.Bounds.X && _dropNode != nextParent);
_location = string.Format("After {0}[{1}] y={2}", _dropNode.Text, _index, OffsetY);
_position = DropPosition.After;
}
}
LimitMoves(e);
}
public void LimitMoves(DragEventArgs e)
{
if ((e.KeyState & 8) == 0)
{
//TreeNode dragNode = (TreeNode)e.Data.GetData("System.Windows.Forms.TreeNode");
//TreeNode dragNode = (TreeNode)e.Data.GetData("TreeTest.FolderTreeNode");
TreeNode dragNode = vlnTreeView.GetTreeNodeFromData(e.Data);
switch (_position)
{
case DropPosition.Before:
if (dragNode == _dropNode.Nodes[_index] || dragNode == _dropNode.Nodes[_index].PrevNode)
{
// if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("Before {0} {1} {2} {3} {4}", dragNode.Text ,_position.ToString() , _dropNode.Nodes[_index].Text
// ,_dropNode.Nodes[_index].PrevNode,_dropNode.Nodes[_index].NextNode);
_dropNode = null;
}
break;
case DropPosition.Child:
if (dragNode.Parent == _dropNode)
{
// if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("Child {0} {1} {2} {3} {4} {5}", dragNode.Text ,_position.ToString() , _dropNode.Nodes[_index].Text
// ,_dropNode.Nodes[_index].PrevNode,_dropNode.Nodes[_index].NextNode,DateTime.Now);
_dropNode = null;
}
break;
case DropPosition.After:
if (dragNode == _dropNode.Nodes[_index] || dragNode == _dropNode.Nodes[_index].NextNode)
{
// if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("After {0} {1} {2} {3} {4}", dragNode.Text ,_position.ToString() , _dropNode.Nodes[_index].Text
// ,_dropNode.Nodes[_index].PrevNode,_dropNode.Nodes[_index].NextNode);
_dropNode = null;
}
break;
}
}
}
#endregion
public override string ToString()
{
return string.Format("{0}[{1}].{2}", _dropNode.Text, _index, _position.ToString());
}
#region Drawing
private void TreeNodeTriangle(Graphics g)
{
Rectangle r = _dropNode.Bounds;
int RightPos = r.Right + 6;
Point[] RightTriangle = new Point[]{
new Point(RightPos, r.Y ),
new Point(RightPos - (r.Height / 2), r.Y + (r.Height / 2)),
new Point(RightPos, r.Y + r.Height),
new Point(RightPos - (r.Height / 3), r.Y + (r.Height / 2))
};
g.FillPolygon(System.Drawing.Brushes.Black, RightTriangle);
}
private void InsertPointer(TreeNode tn, Graphics g)
{
TreeView tv = _dropNode.TreeView;
Rectangle r2 = _dropNode.Nodes[_index].Bounds;
Rectangle r3 = tn.Bounds;
int y = (_position == DropPosition.Before ? r2.Y : r3.Bottom);
int x = r2.Left;
if (y == 0)
{
return;
}
// if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("Line at {0} Node {1}[{2}] {3}", _location, _dropNode.Text, _index, _position.ToString());
Color lc = (_position == DropPosition.After ? Color.Red : Color.Blue);
Brush lb = (_position == DropPosition.After ? Brushes.Red : Brushes.Blue);
Point[] RightTriangle;
if (_position == DropPosition.After)
{
RightTriangle = new Point[]{
new Point(x, y ),
new Point(x+4, y+4),
new Point(x+8, y)};
}
else
{
RightTriangle = new Point[]{
new Point(x, y),
new Point(x+4, y-4),
new Point(x+8, y)};
}
g.DrawLine(new System.Drawing.Pen(lc, 2), new Point(r2.Left, y), new Point(tv.Width - 8, y));
g.FillPolygon(lb, RightTriangle);
}
public void ShowLocation(System.Windows.Forms.DragEventArgs e, bool ScrollOnly)
{
//if (e.Effect == DragDropEffects.None) return;
if (_dropNode != null)
{
// if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("ShowLocation1 {0} {1}", e.Effect.ToString(), DateTime.Now.Millisecond);
DragHelper.ImageList_DragShowNolock(false);
TreeView tv = _dropNode.TreeView;
TreeNode tmp = tv.GetNodeAt(tv.PointToClient(new Point(e.X, e.Y)));
// if (!ScrollOnly)
// {
if (ScrollTreeView(tmp) || !ScrollOnly)
{
if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("ShowLocation2 {0} {1}", e.Effect.ToString(), DateTime.Now.Millisecond);
tv.Refresh();
if (e.Effect != DragDropEffects.None)
{
//tv.SelectedNode = dropNode;
Graphics g = tv.CreateGraphics();
TreeNodeTriangle(g);
if (_position != DropPosition.Child)InsertPointer(tmp, g);
}
}
// }
// else ScrollTreeView(tmp);
DragHelper.ImageList_DragShowNolock(true);
}
}
#endregion
public void ShowLocation()
{
if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("{0}[{1}] {2}", _dropNode.Text, _index, _position.ToString());
}
#region AutoScroll
private bool ScrollTreeView(TreeNode tn)
{
bool retval = false;
TimeSpan ts = new TimeSpan(DateTime.Now.Ticks - _lastScroll.Ticks);
if (ts.Milliseconds > 100)// This controls the scroll speed
{
int top = tn.Bounds.Top;
_lastScroll = DateTime.Now;
if (tn.TreeView.ClientSize.Height < tn.Bounds.Bottom) tn.EnsureVisible();// Make sure that the current node is visible
if (tn.NextVisibleNode != null && tn.TreeView.ClientSize.Height < tn.NextVisibleNode.Bounds.Bottom)
tn.NextVisibleNode.EnsureVisible();// Make sure that the next node is visible
else
if (tn.PrevVisibleNode != null && tn.PrevVisibleNode.PrevVisibleNode != null && tn.PrevVisibleNode.PrevVisibleNode.IsVisible == false)
tn.PrevVisibleNode.PrevVisibleNode.EnsureVisible();// Make sure that the previous node is visible }
else
if (tn.PrevVisibleNode != null && tn.PrevVisibleNode.IsVisible == false)
tn.PrevVisibleNode.EnsureVisible();// Make sure that the previous node is visible
retval = (top != tn.Bounds.Top);
// if (retval) if(_MyLog.IsInfoEnabled)_MyLog.Info("Scroll");
}
return retval;
}
#endregion
public bool Equals(DropLocation dl)
{
return (dl != null && _lastScroll.Equals(dl.LastScroll) && _dropNode.Equals(dl.DropNode) &&
_position.Equals(dl.Position));
}
}
private DropLocation _LastDropLocation = null;
private void tv_DragOver(object sender, System.Windows.Forms.DragEventArgs e)
{
try
{
TreeNode dragNode = GetTreeNodeFromData(e.Data);
// Compute drag position and move image
Point formP = this.FindForm().PointToClient(new Point(e.X, e.Y));
DragHelper.ImageList_DragMove(formP.X - this.Left, formP.Y - this.Top);
DropLocation dl = new DropLocation(this, e, _LastDropLocation == null ? DateTime.Now : _LastDropLocation.LastScroll);
string s = string.Empty;
if (dl.DropNode == null)
{
e.Effect = DragDropEffects.None;
}
else
{
DragDropEffects ee = e.Effect;
if ((e.KeyState & 8) == 8)
ee = DragDropEffects.Copy; // Copy it
else
ee = DragDropEffects.Move; // Move it
if (IsChild(dragNode, dl.DropNode))
ee = DragDropEffects.None; // Don't copy or move to a child node
if (e.Effect != ee) e.Effect = ee;
dl.ShowLocation(e, dl.Equals(_LastDropLocation));
_LastDropLocation = dl;
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("tv_DragOver", ex);
}
}
private static TreeNode GetTreeNodeFromData(IDataObject datobj)
{
foreach (string s in datobj.GetFormats())
{
try
{
return (TreeNode)datobj.GetData(s);
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("GetTreeNodeFromData", ex);
}
}
return null;
}
private void tv_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
{
try
{
TreeNode dragNode = GetTreeNodeFromData(e.Data);
DragHelper.ImageList_DragLeave(this.Handle);
int index = _LastDropLocation.Index + (_LastDropLocation.Position == DropPosition.After ? 1 : 0);
if (dragNode.Parent == _LastDropLocation.DropNode && dragNode.Index <= _LastDropLocation.Index) index--;
if (e.Effect == DragDropEffects.Move)// If Move Remove drag node from parent
dragNode.Remove();
else
dragNode = Clone(dragNode);
_LastDropLocation.DropNode.Nodes.Insert(index, dragNode);
this.SelectedNode = dragNode;
OnNodeDragDrop(sender, new vlnTreeEventArgs(dragNode, _LastDropLocation.DropNode,index));
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("tv_DragDrop", ex);
}
}
private void DumpMembers(object o)
{
Type t = o.GetType();
if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("\r\n\r\nMembers for type {0}", t.ToString());
MemberInfo[] mis = t.GetMembers();
int i = 0;
foreach (MemberInfo mi in mis)
{
i++;
try
{
if(mi.MemberType != MemberTypes.Method)
if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("{0} {1} {2}", i, mi.Name, mi.MemberType);
// if (fi.Name == "TreeView")
// fi.SetValue(o, null);
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("DumpMembers", ex);
}
}
}
private TreeNode Clone(TreeNode tn)
{
TreeNode tmp = (TreeNode)tn.Clone();
ExpandMatch(tmp,tn);
return tmp;
}
private void tv_DragDropOld(object sender, System.Windows.Forms.DragEventArgs e)
{
TreeNode dragNode = (TreeNode)e.Data.GetData("System.Windows.Forms.TreeNode");// Get the drag node
DragHelper.ImageList_DragLeave(this.Handle);
TreeNode cloneNode = (TreeNode)dragNode.Clone();// copy the source node
ExpandMatch(cloneNode, dragNode);
_LastDropLocation.DropNode.Nodes.Insert(_LastDropLocation.Index + (_LastDropLocation.Position == DropPosition.After ? 1 : 0), cloneNode);
if (e.Effect == DragDropEffects.Move)// If Move Remove drag node from parent
dragNode.Remove();
this.SelectedNode = cloneNode;
}
private void tv_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)
{
DragHelper.ImageList_DragEnter(this.Handle, e.X - this.Left, e.Y - this.Top);
}
private void tv_DragLeave(object sender, System.EventArgs e)
{
DragHelper.ImageList_DragLeave(this.Handle);
this.Refresh();
}
private void ExpandMatch(TreeNode tn1, TreeNode tn2)
{
if (tn2.IsExpanded) tn1.Expand();
foreach (TreeNode tc in tn2.Nodes) ExpandMatch(tn1.Nodes[tc.Index], tc);
}
private bool IsChild(TreeNode parent, TreeNode child)
{
if (parent.Equals(child)) return true;// Check against self
foreach (TreeNode tc in parent.Nodes) if (IsChild(tc, child)) return true;//Check all children
return false;// Must not be a child at this level
}
}
public class DragHelper
{
[DllImport("comctl32.dll")]
public static extern bool InitCommonControls();
[DllImport("comctl32.dll", CharSet = CharSet.Auto)]
public static extern bool ImageList_BeginDrag(IntPtr himlTrack, int
iTrack, int dxHotspot, int dyHotspot);
[DllImport("comctl32.dll", CharSet = CharSet.Auto)]
public static extern bool ImageList_DragMove(int x, int y);
[DllImport("comctl32.dll", CharSet = CharSet.Auto)]
public static extern void ImageList_EndDrag();
[DllImport("comctl32.dll", CharSet = CharSet.Auto)]
public static extern bool ImageList_DragEnter(IntPtr hwndLock, int x, int y);
[DllImport("comctl32.dll", CharSet = CharSet.Auto)]
public static extern bool ImageList_DragLeave(IntPtr hwndLock);
[DllImport("comctl32.dll", CharSet = CharSet.Auto)]
public static extern bool ImageList_DragShowNolock(bool fShow);
static DragHelper()
{
InitCommonControls();
}
}
}