Commit for development environment setup

This commit is contained in:
2023-06-19 16:12:33 -04:00
parent be72063a3c
commit bbce2ad0a6
2209 changed files with 1171775 additions and 625 deletions

Binary file not shown.

View File

@@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestWndProc", "TestWndProc\TestWndProc.csproj", "{A672E7A2-94FF-4613-B6AC-52CC6F98EB29}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A672E7A2-94FF-4613-B6AC-52CC6F98EB29}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A672E7A2-94FF-4613-B6AC-52CC6F98EB29}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A672E7A2-94FF-4613-B6AC-52CC6F98EB29}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A672E7A2-94FF-4613-B6AC-52CC6F98EB29}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,414 @@
namespace TestWndProc
{
partial class MyPanel
{
/// <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.btnBoldOn = new System.Windows.Forms.Button();
this.btnBoldOff = new System.Windows.Forms.Button();
this.btnLinkOff = new System.Windows.Forms.Button();
this.btnLinkOn = new System.Windows.Forms.Button();
this.tbSelRTF = new System.Windows.Forms.TextBox();
this.lblFind = new System.Windows.Forms.Label();
this.nudStart = new System.Windows.Forms.NumericUpDown();
this.nudLength = new System.Windows.Forms.NumericUpDown();
this.dgv = new System.Windows.Forms.DataGridView();
this.btnFindAllLinks = new System.Windows.Forms.Button();
this.tbSelText = new System.Windows.Forms.TextBox();
this.btnUpdateSel = new System.Windows.Forms.Button();
this.cbProcess = new System.Windows.Forms.CheckBox();
this.lbTbSel = new System.Windows.Forms.Label();
this.btnRefreshText = new System.Windows.Forms.Button();
this.btnReplaceSelection = new System.Windows.Forms.Button();
this.lblWith = new System.Windows.Forms.Label();
this.tbWith = new System.Windows.Forms.TextBox();
this.tbSendKeys = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.lblRangeStatus = new System.Windows.Forms.Label();
this.btnPG = new System.Windows.Forms.Button();
this.tbRTF = new TestWndProc.MyTextBox(this.components);
this.myRTB1 = new TestWndProc.MyRTB(this.components);
this.btnSelHngIndent = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.nudStart)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nudLength)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.dgv)).BeginInit();
this.SuspendLayout();
//
// btnBoldOn
//
this.btnBoldOn.Location = new System.Drawing.Point(4, 16);
this.btnBoldOn.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.btnBoldOn.Name = "btnBoldOn";
this.btnBoldOn.Size = new System.Drawing.Size(81, 28);
this.btnBoldOn.TabIndex = 1;
this.btnBoldOn.Text = "Bold On";
this.btnBoldOn.UseVisualStyleBackColor = true;
this.btnBoldOn.Click += new System.EventHandler(this.btnBoldOn_Click);
//
// btnBoldOff
//
this.btnBoldOff.Location = new System.Drawing.Point(93, 16);
this.btnBoldOff.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.btnBoldOff.Name = "btnBoldOff";
this.btnBoldOff.Size = new System.Drawing.Size(83, 28);
this.btnBoldOff.TabIndex = 2;
this.btnBoldOff.Text = "Bold Off";
this.btnBoldOff.UseVisualStyleBackColor = true;
this.btnBoldOff.Click += new System.EventHandler(this.btnBoldOff_Click);
//
// btnLinkOff
//
this.btnLinkOff.Location = new System.Drawing.Point(269, 16);
this.btnLinkOff.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.btnLinkOff.Name = "btnLinkOff";
this.btnLinkOff.Size = new System.Drawing.Size(71, 28);
this.btnLinkOff.TabIndex = 5;
this.btnLinkOff.Text = "Link Off";
this.btnLinkOff.UseVisualStyleBackColor = true;
this.btnLinkOff.Click += new System.EventHandler(this.btnLinkOff_Click);
//
// btnLinkOn
//
this.btnLinkOn.Location = new System.Drawing.Point(184, 16);
this.btnLinkOn.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.btnLinkOn.Name = "btnLinkOn";
this.btnLinkOn.Size = new System.Drawing.Size(77, 28);
this.btnLinkOn.TabIndex = 4;
this.btnLinkOn.Text = "Link On";
this.btnLinkOn.UseVisualStyleBackColor = true;
this.btnLinkOn.Click += new System.EventHandler(this.btnLinkOn_Click);
//
// tbSelRTF
//
this.tbSelRTF.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tbSelRTF.Location = new System.Drawing.Point(4, 370);
this.tbSelRTF.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.tbSelRTF.Multiline = true;
this.tbSelRTF.Name = "tbSelRTF";
this.tbSelRTF.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.tbSelRTF.Size = new System.Drawing.Size(643, 47);
this.tbSelRTF.TabIndex = 8;
//
// lblFind
//
this.lblFind.AutoSize = true;
this.lblFind.Location = new System.Drawing.Point(344, 178);
this.lblFind.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lblFind.Name = "lblFind";
this.lblFind.Size = new System.Drawing.Size(50, 17);
this.lblFind.TabIndex = 11;
this.lblFind.Text = "Where";
//
// nudStart
//
this.nudStart.Location = new System.Drawing.Point(416, 176);
this.nudStart.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.nudStart.Maximum = new decimal(new int[] {
1000,
0,
0,
0});
this.nudStart.Name = "nudStart";
this.nudStart.Size = new System.Drawing.Size(57, 22);
this.nudStart.TabIndex = 14;
//
// nudLength
//
this.nudLength.Location = new System.Drawing.Point(481, 176);
this.nudLength.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.nudLength.Maximum = new decimal(new int[] {
1000,
0,
0,
0});
this.nudLength.Name = "nudLength";
this.nudLength.Size = new System.Drawing.Size(49, 22);
this.nudLength.TabIndex = 15;
//
// dgv
//
this.dgv.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.dgv.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgv.Location = new System.Drawing.Point(4, 481);
this.dgv.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.dgv.Name = "dgv";
this.dgv.RowTemplate.Height = 24;
this.dgv.Size = new System.Drawing.Size(644, 204);
this.dgv.TabIndex = 16;
this.dgv.SelectionChanged += new System.EventHandler(this.dgv_SelectionChanged);
//
// btnFindAllLinks
//
this.btnFindAllLinks.Location = new System.Drawing.Point(17, 174);
this.btnFindAllLinks.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.btnFindAllLinks.Name = "btnFindAllLinks";
this.btnFindAllLinks.Size = new System.Drawing.Size(101, 28);
this.btnFindAllLinks.TabIndex = 17;
this.btnFindAllLinks.Text = "Find All Links";
this.btnFindAllLinks.UseVisualStyleBackColor = true;
this.btnFindAllLinks.Click += new System.EventHandler(this.btnFindAllLinks_Click);
//
// tbSelText
//
this.tbSelText.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tbSelText.Location = new System.Drawing.Point(4, 426);
this.tbSelText.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.tbSelText.Multiline = true;
this.tbSelText.Name = "tbSelText";
this.tbSelText.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.tbSelText.Size = new System.Drawing.Size(643, 47);
this.tbSelText.TabIndex = 18;
//
// btnUpdateSel
//
this.btnUpdateSel.Location = new System.Drawing.Point(213, 174);
this.btnUpdateSel.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.btnUpdateSel.Name = "btnUpdateSel";
this.btnUpdateSel.Size = new System.Drawing.Size(127, 28);
this.btnUpdateSel.TabIndex = 19;
this.btnUpdateSel.Text = "Update Selection";
this.btnUpdateSel.UseVisualStyleBackColor = true;
this.btnUpdateSel.Click += new System.EventHandler(this.btnUpdateSel_Click);
//
// cbProcess
//
this.cbProcess.AutoSize = true;
this.cbProcess.Checked = true;
this.cbProcess.CheckState = System.Windows.Forms.CheckState.Checked;
this.cbProcess.Location = new System.Drawing.Point(125, 176);
this.cbProcess.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.cbProcess.Name = "cbProcess";
this.cbProcess.Size = new System.Drawing.Size(81, 21);
this.cbProcess.TabIndex = 20;
this.cbProcess.Text = "Process";
this.cbProcess.UseVisualStyleBackColor = true;
this.cbProcess.CheckedChanged += new System.EventHandler(this.cbProcess_CheckedChanged);
//
// lbTbSel
//
this.lbTbSel.AutoSize = true;
this.lbTbSel.Location = new System.Drawing.Point(539, 178);
this.lbTbSel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lbTbSel.Name = "lbTbSel";
this.lbTbSel.Size = new System.Drawing.Size(50, 17);
this.lbTbSel.TabIndex = 21;
this.lbTbSel.Text = "Where";
//
// btnRefreshText
//
this.btnRefreshText.Location = new System.Drawing.Point(347, 17);
this.btnRefreshText.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.btnRefreshText.Name = "btnRefreshText";
this.btnRefreshText.Size = new System.Drawing.Size(111, 26);
this.btnRefreshText.TabIndex = 23;
this.btnRefreshText.Text = "Refresh Text";
this.btnRefreshText.UseVisualStyleBackColor = true;
this.btnRefreshText.Click += new System.EventHandler(this.btnRefreshText_Click);
//
// btnReplaceSelection
//
this.btnReplaceSelection.Location = new System.Drawing.Point(17, 209);
this.btnReplaceSelection.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.btnReplaceSelection.Name = "btnReplaceSelection";
this.btnReplaceSelection.Size = new System.Drawing.Size(137, 28);
this.btnReplaceSelection.TabIndex = 25;
this.btnReplaceSelection.Text = "Replace Selection";
this.btnReplaceSelection.UseVisualStyleBackColor = true;
this.btnReplaceSelection.Click += new System.EventHandler(this.btnReplaceSelection_Click);
//
// lblWith
//
this.lblWith.AutoSize = true;
this.lblWith.Location = new System.Drawing.Point(163, 215);
this.lblWith.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lblWith.Name = "lblWith";
this.lblWith.Size = new System.Drawing.Size(36, 17);
this.lblWith.TabIndex = 26;
this.lblWith.Text = "With";
//
// tbWith
//
this.tbWith.Location = new System.Drawing.Point(207, 212);
this.tbWith.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.tbWith.Name = "tbWith";
this.tbWith.Size = new System.Drawing.Size(132, 22);
this.tbWith.TabIndex = 27;
this.tbWith.Text = "X";
//
// tbSendKeys
//
this.tbSendKeys.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tbSendKeys.Location = new System.Drawing.Point(429, 212);
this.tbSendKeys.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.tbSendKeys.Name = "tbSendKeys";
this.tbSendKeys.Size = new System.Drawing.Size(213, 22);
this.tbSendKeys.TabIndex = 29;
this.tbSendKeys.Text = "{BS}";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(348, 215);
this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(72, 17);
this.label1.TabIndex = 28;
this.label1.Text = "SendKeys";
//
// lblRangeStatus
//
this.lblRangeStatus.AutoSize = true;
this.lblRangeStatus.Location = new System.Drawing.Point(472, 18);
this.lblRangeStatus.Name = "lblRangeStatus";
this.lblRangeStatus.Size = new System.Drawing.Size(94, 17);
this.lblRangeStatus.TabIndex = 30;
this.lblRangeStatus.Text = "Range Status";
//
// btnPG
//
this.btnPG.Location = new System.Drawing.Point(572, 15);
this.btnPG.Name = "btnPG";
this.btnPG.Size = new System.Drawing.Size(39, 23);
this.btnPG.TabIndex = 31;
this.btnPG.Text = "PG";
this.btnPG.UseVisualStyleBackColor = true;
this.btnPG.Click += new System.EventHandler(this.btnPG_Click);
//
// tbRTF
//
this.tbRTF.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tbRTF.Location = new System.Drawing.Point(4, 244);
this.tbRTF.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.tbRTF.Multiline = true;
this.tbRTF.Name = "tbRTF";
this.tbRTF.Size = new System.Drawing.Size(643, 120);
this.tbRTF.TabIndex = 24;
this.tbRTF.SelectionChange += new System.EventHandler(this.tbRTF_SelectionChange);
this.tbRTF.TextChanged += new System.EventHandler(this.tbRTF_TextChanged);
//
// myRTB1
//
this.myRTB1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.myRTB1.HideSelection = false;
this.myRTB1.Location = new System.Drawing.Point(4, 52);
this.myRTB1.Margin = new System.Windows.Forms.Padding(4);
this.myRTB1.Name = "myRTB1";
this.myRTB1.ProcessKeystrokes = true;
this.myRTB1.RTBRangeStatus = TestWndProc.MyRTB.RangeStatus.NoContainedLinks;
this.myRTB1.ShowDebug = true;
this.myRTB1.Size = new System.Drawing.Size(643, 117);
this.myRTB1.TabIndex = 0;
this.myRTB1.Text = "";
this.myRTB1.Protected += new System.EventHandler(this.myRTB1_Protected);
//
// btnSelHngIndent
//
this.btnSelHngIndent.Location = new System.Drawing.Point(618, 15);
this.btnSelHngIndent.Name = "btnSelHngIndent";
this.btnSelHngIndent.Size = new System.Drawing.Size(39, 23);
this.btnSelHngIndent.TabIndex = 32;
this.btnSelHngIndent.Text = "SI";
this.btnSelHngIndent.UseVisualStyleBackColor = true;
this.btnSelHngIndent.Click += new System.EventHandler(this.btnSelHngIndent_Click);
//
// MyPanel
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.btnSelHngIndent);
this.Controls.Add(this.btnPG);
this.Controls.Add(this.lblRangeStatus);
this.Controls.Add(this.tbSendKeys);
this.Controls.Add(this.label1);
this.Controls.Add(this.tbWith);
this.Controls.Add(this.lblWith);
this.Controls.Add(this.btnReplaceSelection);
this.Controls.Add(this.tbRTF);
this.Controls.Add(this.btnRefreshText);
this.Controls.Add(this.lbTbSel);
this.Controls.Add(this.cbProcess);
this.Controls.Add(this.btnUpdateSel);
this.Controls.Add(this.tbSelText);
this.Controls.Add(this.btnFindAllLinks);
this.Controls.Add(this.dgv);
this.Controls.Add(this.nudLength);
this.Controls.Add(this.nudStart);
this.Controls.Add(this.lblFind);
this.Controls.Add(this.tbSelRTF);
this.Controls.Add(this.btnLinkOff);
this.Controls.Add(this.btnLinkOn);
this.Controls.Add(this.btnBoldOff);
this.Controls.Add(this.btnBoldOn);
this.Controls.Add(this.myRTB1);
this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.Name = "MyPanel";
this.Size = new System.Drawing.Size(660, 702);
((System.ComponentModel.ISupportInitialize)(this.nudStart)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nudLength)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dgv)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private MyRTB myRTB1;
private System.Windows.Forms.Button btnBoldOn;
private System.Windows.Forms.Button btnBoldOff;
private System.Windows.Forms.Button btnLinkOff;
private System.Windows.Forms.Button btnLinkOn;
private System.Windows.Forms.TextBox tbSelRTF;
private System.Windows.Forms.Label lblFind;
private System.Windows.Forms.NumericUpDown nudStart;
private System.Windows.Forms.NumericUpDown nudLength;
private System.Windows.Forms.DataGridView dgv;
private System.Windows.Forms.Button btnFindAllLinks;
private System.Windows.Forms.TextBox tbSelText;
private System.Windows.Forms.Button btnUpdateSel;
private System.Windows.Forms.CheckBox cbProcess;
private System.Windows.Forms.Label lbTbSel;
private System.Windows.Forms.Button btnRefreshText;
private MyTextBox tbRTF;
private System.Windows.Forms.Button btnReplaceSelection;
private System.Windows.Forms.Label lblWith;
private System.Windows.Forms.TextBox tbWith;
private System.Windows.Forms.TextBox tbSendKeys;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label lblRangeStatus;
private System.Windows.Forms.Button btnPG;
private System.Windows.Forms.Button btnSelHngIndent;
}
}

View File

@@ -0,0 +1,215 @@
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 System.Text.RegularExpressions;
namespace TestWndProc
{
public partial class MyPanel : UserControl
{
#region Constructors
public MyPanel()
{
InitializeComponent();
myRTB1.LinkLocationsChanged += new RTBEvent(myRTB1_LinkLocationsChanged);
myRTB1.RTBSelectionChanged += new RTBEvent(myRTB1_RTBSelectionChanged);
myRTB1.RTBTextChanged += new RTBEvent(myRTB1_RTBTextChanged);
myRTB1.RTBRangeStatusChanged += new RTBEvent(myRTB1_RTBRangeStatusChanged);
SetRtfString();
}
#endregion
#region Debug
private bool _ShowDebug = true;
public bool ShowDebug
{
get { return _ShowDebug; }
set { _ShowDebug = value; }
}
private void DebugPrint(string where, string format, params object[] myParams)
{
DebugPrint(where + string.Format(format, myParams));
}
private void DebugPrint(string format, params object[] myParams)
{
if (_ShowDebug)
Console.WriteLine(format, myParams);
}
#endregion
#region RTB Event Handlers
void myRTB1_RTBTextChanged(object sender, EventArgs args)
{
DebugPrint("<=====RTBTextChanged");
if (_TextChanging == false)
{
_TextChanging = true;
tbRTF.Text = myRTB1.Rtf;
_TextChanging = false;
}
}
void myRTB1_RTBRangeStatusChanged(object sender, EventArgs args)
{
DebugPrint("<=====RTBRangeStatusChanged");
lblRangeStatus.Text = myRTB1.RTBRangeStatus.ToString();
}
void myRTB1_RTBSelectionChanged(object sender, EventArgs args)
{
DebugPrint("<=====RTBSelectionChanged");
ShowSelection();
UpdateNudsFromSelection();
}
void myRTB1_LinkLocationsChanged(object sender, EventArgs args)
{
DebugPrint("<<LinkLocationsChanged");
dgv.DataSource = myRTB1.LinkLocations;
}
#endregion
#region Setup Text
private void btnRefreshText_Click(object sender, EventArgs e)
{
SetRtfString();
}
private void SetRtfString()
{
myRTB1.Rtf = @"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Arial;}}\r\n" +
@"\viewkind4\uc1\pard\sl-240\slmult0\f0\fs20 " +
@"\v <START]\v0 Link at start of box\v #Link data including URL\v0 \v [END>\v0 " +
@"Some text \v <START]\v0 Lonesome Link\v #Link data including URL\v0 \v [END>\v0 " +
@"Add some text before \v <START]\v0 First Link in between\v #Link data including URL\v0 \v [END>\v0 " +
@"\v <START]\v0 Second Link in between\v #Link data including URL\v0 \v [END>\v0 " +
@"\v <START]\v0 Third Link in between\v #Link data including URL\v0 \v [END>\v0 and some more text after " +
@"\v <START]\v0 Link at end of box\v #Link data including URL\v0 \v [END>\v0 " + @"\par}";
}
#endregion
#region Selection
private void ShowSelection()
{
lblFind.Text = string.Format("{0}-{1}", myRTB1.SelectionStart, myRTB1.SelectionStart + myRTB1.SelectionLength);
tbSelRTF.Text = myRTB1.SelectedRtf;
tbSelText.Text = myRTB1.SelectedText;
UpdateNudsFromSelection();
}
private void tbRTB_SelectionChanged(object sender, EventArgs e)
{
//lbTbSel.Text = string.Format("{0}, {1}", tbRTF.SelectionStart, tbRTF.SelectionLength);
}
private void tbRTF_SelectionChange(object sender, EventArgs e)
{
lbTbSel.Text = string.Format("{0}, {1}", tbRTF.SelectionStart, tbRTF.SelectionLength);
}
private void btnReplaceSelection_Click(object sender, EventArgs e)
{
myRTB1.SelectedText = tbWith.Text;
if (tbSendKeys.Text != "") SendKeys.Send(tbSendKeys.Text);
}
private void dgv_SelectionChanged(object sender, EventArgs e)
{
if (dgv.SelectedRows.Count == 1)
{
LinkLocation ll = myRTB1.LinkLocations[dgv.SelectedRows[0].Index];
myRTB1.SetSelection(ll);
}
}
#endregion
#region Numeric Up/Down
private void UpdateNudsFromSelection()
{
nudStart.Value = myRTB1.SelectionStart;
nudLength.Value = myRTB1.SelectionLength;
}
private void UpdateNuds(int start, int length)
{
nudStart.Value = start;
nudLength.Value = length;
}
private void UpdateSelectionFromNuds()
{
myRTB1.SetSelection((int)(nudStart.Value), (int)(nudLength.Value));
}
private void btnUpdateSel_Click(object sender, EventArgs e)
{
UpdateSelectionFromNuds();
myRTB1.Focus();
}
#endregion
#region Protection
private void myRTB1_Protected(object sender, EventArgs e)
{
MessageBox.Show("Cannot change protected text that way!");
}
private void btnProtectOn_Click(object sender, EventArgs e)
{
RTBAPI.Protect(myRTB1);
}
private void btnProtectOff_Click(object sender, EventArgs e)
{
RTBAPI.UnProtect(myRTB1);
}
#endregion
#region Button Handlers
private void btnBoldOn_Click(object sender, EventArgs e)
{
RTBAPI.ToggleBold(true, myRTB1, RTBAPI.RTBSelection.SCF_SELECTION);
}
private void btnBoldOff_Click(object sender, EventArgs e)
{
RTBAPI.ToggleBold(false, myRTB1, RTBAPI.RTBSelection.SCF_SELECTION);
}
private void btnLinkOn_Click(object sender, EventArgs e)
{
RTBAPI.Link(myRTB1);
}
private void btnLinkOff_Click(object sender, EventArgs e)
{
RTBAPI.UnLink(myRTB1);
}
private void btnFindAllLinks_Click(object sender, EventArgs e)
{
myRTB1.FindAllLinks();
}
#endregion
#region Text Change
private bool _TextChanging = false;
private void tbRTF_TextChanged(object sender, EventArgs e)
{
if (_TextChanging == false)
{
_TextChanging = true;
myRTB1.Rtf = tbRTF.Text;
_TextChanging = false;
}
}
#endregion
#region Process Check Box
private void cbProcess_CheckedChanged(object sender, EventArgs e)
{
myRTB1.ProcessKeystrokes = cbProcess.Checked;
}
#endregion
private void btnPG_Click(object sender, EventArgs e)
{
frmPG myFrmPG = new frmPG(myRTB1);
myFrmPG.Show();
}
int hngIndent = 25;
private void btnSelHngIndent_Click(object sender, EventArgs e)
{
//myRTB1.SelectionHangingIndent = hngIndent;
//hngIndent += 25;
myRTB1.SelectAll();
myRTB1.SelectionHangingIndent = 0;
int indchar = 0;
while ((indchar = myRTB1.Find("@", indchar, RichTextBoxFinds.None)) >= 0)
{
Point indent = myRTB1.GetPositionFromCharIndex(indchar);
myRTB1.SelectionHangingIndent = indent.X;
indchar++;
}
}
}
}

View File

@@ -0,0 +1,492 @@
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 System.Text.RegularExpressions;
namespace TestWndProc
{
public partial class MyPanel : UserControl
{
private bool _TextChanging=false;
private const int WM_NOTIFY = 0x4E;
public MyPanel()
{
InitializeComponent();
//RTBAPI.SetNotifyProtect(myRTB1);
//myRTB1.Rtf = @"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Arial;}}\r\n" +
// @"\viewkind4\uc1\pard\sl-240\slmult0\f0\fs20 " +
// @"\v <START]\v0 Not Protected Link\v #Link data including URL\v0 \v [END>\v0\par" +
// @"\v <START]\v0 30 gpm\v #Link Reference Object A.1[END>\v0\v <START]\v0 20 gpm\v #Link Reference Object A.2[END>\v0\par" +
// @"Not Protected\par " +
// @"Not Protected\par " +
// @"Not Protected\par " +
// @"Not Protected\par}";
// KBR's Testing for delete link basic cases (text before & after link):
//myRTB1.Rtf = @"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Arial;}}\r\n" +
// @"\viewkind4\uc1\pard\sl-240\slmult0\f0\fs20 " +
// @"Add some text before \v <START]\v0 Link at middle of box\v #Link data including URL\v0 \v [END>\v0 and some more text after}";
// KBR's Testing for delete link at beginning of box (BASIC CASE):
//myRTB1.Rtf = @"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Arial;}}\r\n" +
// @"\viewkind4\uc1\pard\sl-240\slmult0\f0\fs20 " +
// @"\v <START]\v0 Link at beginning of box\v #Link data including URL\v0 \v [END>\v0 and some more text after}";
// KBR's Testing for delete link with two links in a row:
myRTB1.Rtf = @"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Arial;}}\r\n" +
@"\viewkind4\uc1\pard\sl-240\slmult0\f0\fs20 " +
@"Add some text before \v <START]\v0 First Link in box\v #Link data including URL\v0 \v [END>\v0 "+
@"\v <START]\v0 Second Link in box\v #Link data including URL\v0 \v [END>\v0 and some more text after}";
// RHM's latest:
//myRTB1.Rtf = @"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Arial;}}\r\n" +
// @"\viewkind4\uc1\pard\sl-240\slmult0\f0\fs20 " +
// @"\v <START]\v0 Not Protected Link\v #Link data including URL\v0 \v [END>\v0\par" +
// @"\v <START]\v0 30 gpm\v #Link Reference Object A.1[END>\v0\v <START]\v0 20 gpm\v #Link Reference Object A.2[END>\v0\par" +
// @"Not Protected\par " +
// @"Make sure the flow is at \b least \v <START]\v0 40 GPM\v #Link data including URL\v0 \v [END>\v0 \b0 coming from the Aux Feed Pump\par " +
// @"Not Protected\par " +
// @"Not Protected\par}";
//myRTB1.Rtf = @"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Arial;}}{\colortbl{\red0\green0\blue0;\red255\green0\blue0}}\r\n" +
// @"\viewkind4\uc1\pard\sl-240\slmult0\f0\fs20 " +
// @"\cf1 Not Protected Link\v #Link data including URL\v0\par" +
// @"30 gpm\v #Link Reference Object A.1\v0 \cf1 20 gpm\v #Link Reference Object A.2\v0\par" +
// @"Not Protected\par " +
// @"Make sure the flow is at least \v <START]\v0 40 GPM\v #Link data including URL\v0 \v [END>\v0 coming from the Aux Feed Pump\par " +
// @"Not Protected\par " +
// @"Not Protected\par}";
//FindAllLinks();
this.myRTB1.SelectionChanged += new System.EventHandler(this.myRTB1_SelectionChanged);
}
private void myRTB1_Protected(object sender, EventArgs e)
{
MessageBox.Show("Cannot change protected text that way!");
}
private void btnBoldOn_Click(object sender, EventArgs e)
{
RTBAPI.ToggleBold(true, myRTB1, RTBAPI.RTBSelection.SCF_SELECTION);
}
private void btnBoldOff_Click(object sender, EventArgs e)
{
RTBAPI.ToggleBold(false, myRTB1, RTBAPI.RTBSelection.SCF_SELECTION);
}
private void myRTB1_TextChanged(object sender, EventArgs e)
{
if (_TextChanging == false)
{
_TextChanging = true;
tbRTF.Text = myRTB1.Rtf;
FindAllLinks();
ShowSelection();
_TextChanging = false;
}
}
private void ShowSelection()
{
lblFind.Text = string.Format("{0}-{1}", myRTB1.SelectionStart, myRTB1.SelectionStart + myRTB1.SelectionLength);
tbSelRTF.Text = myRTB1.SelectedRtf;
tbSelText.Text = myRTB1.SelectedText;
UpdateNudsFromSelection();
}
private void UpdateNudsFromSelection()
{
nudStart.Value = myRTB1.SelectionStart;
nudLength.Value = myRTB1.SelectionLength;
}
private void UpdateNuds(int start, int length)
{
nudStart.Value = start;
nudLength.Value = length;
}
private void btnLinkOn_Click(object sender, EventArgs e)
{
RTBAPI.Link(myRTB1);
}
private void btnLinkOff_Click(object sender, EventArgs e)
{
RTBAPI.UnLink(myRTB1);
}
private void btnProtectOn_Click(object sender, EventArgs e)
{
RTBAPI.Protect(myRTB1);
}
private void btnProtectOff_Click(object sender, EventArgs e)
{
RTBAPI.UnProtect(myRTB1);
}
private void SetSelection(int locStart, int locLength)
{
Application.DoEvents();
//myRTB1.SelectionStart = myRTB1.TextLength; // Pointing to the end forces the length to zero at the same time.
//myRTB1.SelectionStart = locStart;
//myRTB1.SelectionLength = locLength;
myRTB1.Select(locStart, locLength);
}
private void tbRTF_TextChanged(object sender, EventArgs e)
{
if (_TextChanging == false)
{
_TextChanging = true;
myRTB1.Rtf = tbRTF.Text;
_TextChanging = false;
}
}
private void UpdateSelectionFromNuds()
{
SetSelection((int)(nudStart.Value),(int)(nudLength.Value));
}
private void myRTB1_MouseUp(object sender, MouseEventArgs e)
{
_MouseDown = false;
HandleSelectionChange();
}
List<LinkLocation> _linkLocations;
private void btnFindAllLinks_Click(object sender, EventArgs e)
{
FindAllLinks();
}
private void FindAllLinks()
{
string str = myRTB1.Text;
_AdjustingSelection = true;
myRTB1.PushSelection();
_linkLocations = new List<LinkLocation>();
MatchCollection matches = Regex.Matches(str, "<START](.*?)[[]END>");
MatchCollection matchesRtf = Regex.Matches(myRTB1.Rtf, "<START](.*?)[[]END>");
for (int i = 0; i< matches.Count; i++) //each (Match match in matches)
{ //KBR
Match match = matches[i];
Match matchrtf = matchesRtf[i];
_linkLocations.Add(new LinkLocation(match.Index + 7, // If the [END> is immediately followed by <START] include it
match.Length - (((match.Index + match.Length + 7 <= str.Length) && (str.Substring(match.Index + match.Length, 7) == "<START]")) ? 0 : 7), match.Value, matchrtf.Index, matchrtf.Length));
} //KBR
foreach (LinkLocation ll in _linkLocations)
{
myRTB1.Select(ll.Start, ll.Length); // subtract off start token!
RTBAPI.CharFormatTwo charFormat = RTBAPI.GetCharFormat(myRTB1, RTBAPI.RTBSelection.SCF_SELECTION);
// 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(myRTB1, RTBAPI.RTBSelection.SCF_SELECTION, charFormat);
}
myRTB1.PopSelection();
LinkLocation llx = FindLinkLocation();
if (_CheckSelection)
{
if (llx != null) SetSelection(llx.End, 0);
_CheckSelection = false;
}
_AdjustingSelection = false;
myRTB1.Focus();
dgv.DataSource = _linkLocations;
}
private void dgv_SelectionChanged(object sender, EventArgs e)
{
if (dgv.SelectedRows.Count == 1)
{
LinkLocation ll = _linkLocations[dgv.SelectedRows[0].Index];
SetSelection(ll.Start,ll.Length);
}
}
bool _AdjustingSelection = false;
private void myRTB1_SelectionChanged(object sender, EventArgs e)
{
HandleSelectionChange();
}
private void HandleSelectionChange()
{
Console.WriteLine("CHECK MOUSE: Sel {0} Length {1}", myRTB1.SelectionStart, myRTB1.SelectionLength);
if (cbProcess.Checked)
{
// Can I limit cursor movement to the ranges of link locations
if (!_MouseDown && !_AdjustingSelection)
{
if (_linkLocations != null)
{
LinkLocation ll = FindLinkLocation();
//if (_CheckSelection)
//{
// //if (ll != null) SetSelection(ll.End, 0);
// _CheckSelection = false;
//}
LinkLocation llend = null;
if (myRTB1.SelectionLength!=0)
llend = FindLinkLocation(myRTB1.SelectionStart + myRTB1.SelectionLength-1);
if (ll != null)
{
Console.WriteLine("SELECTIONCHANGED: Sel {0}, Length {1}, Link Start {2}, Link Length {3}", myRTB1.SelectionStart, myRTB1.SelectionLength, ll.Start, ll.Length);
_AdjustingSelection = true;
if (myRTB1.SelectionStart == ll.Start && myRTB1.SelectionLength == 0)
{
// won't work between two links
SendKeys.Send("{LEFT}");
}
if (myRTB1.SelectionStart + myRTB1.SelectionLength > ll.End)
{
int end = myRTB1.SelectionStart + myRTB1.SelectionLength;
SetSelection(ll.Start, end - ll.Start);
}
else
{
SetSelection(ll.Start, ll.Length);
}
_AdjustingSelection = false;
}
else if (llend != null)
{
Console.WriteLine("LLEND: Sel {0}, Length {1}, Link Start {2}, Link Length {3}", myRTB1.SelectionStart, myRTB1.SelectionLength, llend.Start, llend.Length);
_AdjustingSelection = true;
SetSelection(myRTB1.SelectionStart, llend.End - myRTB1.SelectionStart);
_AdjustingSelection = false;
}
//else
//{
// if (myRTB1.SelectedText.EndsWith("<START]") && !myRTB1.SelectedText.EndsWith("[END><START]"))
// myRTB1.SelectionLength = myRTB1.SelectionLength - 7;
//}
}
}
}
ShowSelection();
UpdateNudsFromSelection();
}
private bool _CheckSelection = false;
int processingkeys = 0;
private void myRTB1_KeyDown(object sender, KeyEventArgs e)
{
if (processingkeys > 0)
Console.WriteLine("Key down: {0} processing keys = {1}", e.KeyCode, processingkeys);
if (!cbProcess.Checked) return;
//Console.WriteLine("{0}", e.KeyCode);
switch (e.KeyCode)
{
case Keys.Left:
LinkLocation ll = FindLinkSelected();
if (ll != null)
{
_AdjustingSelection = true;
Console.WriteLine("Adjusting SelectionStart {0} to {1}", myRTB1.SelectionStart, ll.Start - 7);
SetSelection(ll.Start - 7, 0);
_AdjustingSelection = false;
// Does not allow you to stop between two links that are right next to
// each other
if (myRTB1.SelectionStart != ll.Start - 7)
{
Console.WriteLine(" Didn't work - SelectionStart {0}", myRTB1.SelectionStart);
//ll = FindLinkLocation(myRTB1.SelectionStart);
//SetSelection(ll.Start, ll.Length);
SetSelection(ll.Start, 0);
}
e.SuppressKeyPress = true;
}
break;
case Keys.Back:
_CheckSelection = true;
break;
case Keys.Delete:
//if (myRTB1.SelectionLength == 0)
//{
// e.SuppressKeyPress = true;
// SendKeys.Send("{RIGHT}{BS}");
//} else
if (myRTB1.SelectedText.EndsWith(@"[END><START]"))
{
DoDeleteEndBetweenLinks();
e.SuppressKeyPress = true;
}
else
{
myRTB1.SelectedText = "X";
SendKeys.Send("{BS}");
e.SuppressKeyPress = true;
}
break;
}
}
private void DebugPrint(string where, string format, params object[] myParams)
{
Application.DoEvents();
Console.WriteLine(where + string.Format(format, myParams));
}
private void DebugSelection(string where)
{
DebugPrint(where, ": {0} {1} {2}", myRTB1.SelectionStart, myRTB1.SelectionLength, myRTB1.SelectedText);
}
private void RtbSendKeys(string keys)
{
SendKeys.Send(keys);
DebugSelection(keys);
}
private void DoDeleteEndBetweenLinks()
{
processingkeys++;
DebugSelection("Beginning");
int sstart = myRTB1.SelectionStart;
RtbSendKeys("{RIGHT} "); // open for space between links which separates END/START tokens
SetSelection(sstart, myRTB1.SelectionStart - sstart - 1); // 1 is accounting for typed space
DebugSelection("SetSelection");
RtbSendKeys("{DELETE}"); // deletes text including link
RtbSendKeys("{RIGHT}{BS}"); // deletes space that was added
processingkeys--;
}
private void DoDeleteStartBetweenLinks()
{
processingkeys++;
int slen = myRTB1.SelectionLength;
RtbSendKeys("{LEFT} ");
SetSelection(myRTB1.SelectionStart, slen + 7);
RtbSendKeys("{DELETE}");
RtbSendKeys("{BS}");
processingkeys--;
}
private LinkLocation FindLinkSelected()
{
if (_linkLocations == null) return null;
foreach (LinkLocation ll in _linkLocations)
if (ll.Start == myRTB1.SelectionStart && ll.Length == myRTB1.SelectionLength) return ll;
return null;
}
private LinkLocation FindLinkLocation()
{
return FindLinkLocation(myRTB1.SelectionStart);
}
private LinkLocation FindLinkLocation(int sel)
{
if (_linkLocations == null) return null;
int lastend = -1;
foreach (LinkLocation ll in _linkLocations)
{
// Moving right:
// if less than, allows stopping between two links
// if less than or equal, does not stop between two links
if (ll.Start < sel && ll.End > sel) return ll;
//if (ll.Start == lastend && ll.Start < sel && ll.End > sel) return ll;
if (ll.Start != lastend && ll.Start <= sel && ll.End > sel) return ll;
lastend = ll.End;
}
return null;
}
private bool _MouseDown = false;
private void myRTB1_MouseDown(object sender, MouseEventArgs e)
{
_MouseDown = true;
}
private void btnUpdateSel_Click(object sender, EventArgs e)
{
UpdateSelectionFromNuds();
myRTB1.Focus();
}
private void myRTB1_KeyPress(object sender, KeyPressEventArgs e)
{
Console.WriteLine("KeyPress: {0},{1}", e.KeyChar, (int)e.KeyChar);
if (e.KeyChar >= ' ')
{
LinkLocation ll = FindBetweenLinks();
if (ll != null&&myRTB1.SelectionLength==0)
{
myRTB1.Rtf = myRTB1.Rtf.Substring(0, ll.StartRtf) + @"\v0 " + e.KeyChar.ToString() + @"\v " + myRTB1.Rtf.Substring(ll.StartRtf);
e.Handled = true;
myRTB1.SelectionStart = ll.Start - 6; // account for <START] - 1 for the character typed
}
else if (ll != null)
{
DoDeleteStartBetweenLinks();
}
else if (myRTB1.SelectedText.EndsWith(@"[END><START]"))
{
DoDeleteEndBetweenLinks();
}
}
}
private LinkLocation FindBetweenLinks()
{
bool lastend = false;
foreach (LinkLocation ll in _linkLocations)
{
if (ll.End == myRTB1.SelectionStart) lastend = true;
if (ll.Start == myRTB1.SelectionStart && lastend) return ll;
}
return null;
}
private void tbRTB_SelectionChanged(object sender, EventArgs e)
{
//lbTbSel.Text = string.Format("{0}, {1}", tbRTF.SelectionStart, tbRTF.SelectionLength);
}
private void btnRefreshText_Click(object sender, EventArgs e)
{
myRTB1.Rtf = @"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Arial;}}\r\n" +
@"\viewkind4\uc1\pard\sl-240\slmult0\f0\fs20 " +
@"Add some text before \v <START]\v0 First Link in box\v #Link data including URL\v0 \v [END>\v0 " +
@"\v <START]\v0 Second Link in box\v #Link data including URL\v0 \v [END>\v0 and some more text after}";
}
private void tbRTF_SelectionChange(object sender, EventArgs e)
{
lbTbSel.Text = string.Format("{0}, {1}", tbRTF.SelectionStart, tbRTF.SelectionLength);
}
}
public class LinkLocation
{
private int _Start;
public int Start
{
get { return _Start; }
set { _Start = value; }
}
private int _Length;
public int Length
{
get { return _Length; }
set { _Length = value; }
}
public int End
{
get { return _Length + _Start; }
}
private int _StartRtf;
public int StartRtf
{
get { return _StartRtf; }
set { _StartRtf = value; }
}
private int _LengthRtf;
public int LengthRtf
{
get { return _LengthRtf; }
set { _LengthRtf = value; }
}
public int EndRtf
{
get { return _LengthRtf + _StartRtf; }
}
private string _Text;
public string Text
{
get { return _Text; }
set { _Text = value; }
}
public LinkLocation(int start, int length, string text, int startRtf, int lengthRtf)
{
_Start = start;
_Length = length;
_Text = text;
_StartRtf = startRtf;
_LengthRtf = lengthRtf;
}
}
}

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,36 @@
namespace TestWndProc
{
partial class MyRTB
{
/// <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,881 @@
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 System.Text.RegularExpressions;
namespace TestWndProc
{
public delegate void RTBEvent(object sender, EventArgs args);
public partial class MyRTB : RichTextBox
{
#region Events
public event RTBEvent RTBSelectionChanged;
private void OnRTBSelectionChanged(object sender, EventArgs args)
{
if (RTBSelectionChanged != null) RTBSelectionChanged(sender, args);
}
public event RTBEvent LinkLocationsChanged;
private void OnLinkLocationChanged(object sender, EventArgs args)
{
if(LinkLocationsChanged != null) LinkLocationsChanged(sender, args);
}
public event RTBEvent RTBRangeStatusChanged;
private void OnRTBRangeStatusChanged(object sender, EventArgs args)
{
if (RTBRangeStatusChanged != null) RTBRangeStatusChanged(sender, args);
}
/// <summary>
/// This event is not raised during all the in-between changes for link deletions
/// </summary>
public event RTBEvent RTBTextChanged;
private void OnRTBTextChanged(object sender, EventArgs args)
{
if (RTBTextChanged != null) RTBTextChanged(sender, args);
}
#endregion
#region public properties
private bool _ProcessKeystrokes = true;
public bool ProcessKeystrokes
{
get { return _ProcessKeystrokes; }
set { _ProcessKeystrokes = value; }
}
#endregion
#region CaretPosition
//[DllImport("user32")]
//private static extern IntPtr SendMessage(HandleRef hWnd, int msg, int wParam, int lParam);
[DllImport("user32")]
private static extern int GetCaretPos(ref Point lpPoint);
[DllImport("user32")]
private static extern bool SetCaretPos(int X, int Y);
//private int EM_LINEINDEX = 0xbb;
//private int EM_LINEFROMCHAR = 0xc9;
//private int EM_GETSEL = 0xb0;
/// <summary>
/// Gets the caret current (X, Y) position.
/// </summary>
/// <value>
/// Point struct
/// </value>
public Point CaretXYPosition
{
get
{
Point pt = Point.Empty;
// get a Point struct with the caret current (X, Y)
// position
GetCaretPos(ref pt);
// return the Point struct with the caret current
// (X, Y) position
return pt;
}
}
public int CaretIndex
{
get { return GetCharIndexFromPosition(CaretXYPosition); }
}
public void SetCaretPostoSelectionStart()
{
Point pt = GetPositionFromCharIndex(SelectionStart);
//bool result = SetCaretPos(pt.X,pt.Y);
bool result = SetCaretPos(-1, pt.Y);
DebugPrint("SetCaretPos({0},{1}) = {2}", pt.X, pt.Y, result);
}
#endregion
#region Constructors
public MyRTB()
{
InitializeComponent();
SetupEventHandlers();
}
public MyRTB(IContainer container)
{
container.Add(this);
InitializeComponent();
SetupEventHandlers();
}
private void SetupEventHandlers()
{
this.MouseDown += new MouseEventHandler(MyRTB_MouseDown);
this.MouseUp += new MouseEventHandler(MyRTB_MouseUp);
this.KeyDown += new KeyEventHandler(MyRTB_KeyDown);
this.KeyPress += new KeyPressEventHandler(MyRTB_KeyPress);
this.TextChanged += new EventHandler(MyRTB_TextChanged);
this.SelectionChanged += new EventHandler(MyRTB_SelectionChanged);
}
#endregion
#region Keyboard Handlers
void MyRTB_KeyPress(object sender, KeyPressEventArgs e)
{
DebugPrint("KeyPress: {0},{1}", e.KeyChar, (int)e.KeyChar);
if (e.KeyChar >= ' ')
{
LinkLocation ll = FindBetweenLinks();
if (ll != null && SelectionLength == 0) // SelectionLength = 0 means insert
{
InsertCharBetweenLinks(ll, e.KeyChar);
e.Handled = true;
}
else if (ll != null) // Otherwise it is an overstrike or a delete followed by inserting a character
{
DeleteStartBetweenLinks();
}
else if (SelectedText.EndsWith(@"[END><START]"))
{
DeleteEndBetweenLinks();
}
}
}
private bool _SendBackSpace = false;
void MyRTB_KeyDown(object sender, KeyEventArgs e)
{
if (_AdjustingSelection)
DebugPrint("======================>AdjustingSelection is true in Keydown");
if (_ProcessingKeys > 0)
DebugPrint("Key down: {0} Shift {1} processing keys = {2}", e.KeyCode, e.Shift, _ProcessingKeys);
if (!ProcessKeystrokes) return;
switch (e.KeyCode)
{
case Keys.Left:
DebugPrint("Key down: {0} Shift {1} processing keys = {2}", e.KeyCode, e.Shift, _ProcessingKeys);
DebugSelection("Left");
if (e.Shift) return;
LinkLocation ll = FindLinkSelected();
if (ll != null)
{
_AdjustingSelection = true;
if (ll.StartsBetween || ll.Start == 7)
SetSelection(ll.Start, 0);
else
SetSelection(ll.Start - 7, 0);
_AdjustingSelection = false;
e.SuppressKeyPress = true;
}
break;
case Keys.Back:
if (_SendBackSpace)
{
_SendBackSpace = false;
return;
}
_CheckSelection = true;
if (SelectionLength == 0)
{
foreach (LinkLocation lls in _linkLocations)
{
if (SelectionStart > lls.Start - 7 && SelectionStart <= lls.End)
{
//RtbSendKeys("{Left}");// This should select the ll
SetSelection(lls);
break;
}
}
}
if (SelectionLength > 0) HandleDeleteKeyWithSelectedText(e);
break;
case Keys.Delete:
if (SelectionLength == 0)
{
foreach (LinkLocation lls in _linkLocations)
{
if (SelectionStart >= lls.Start - 7 && SelectionStart < lls.End)
{
SetSelection(lls);// Select the link to the right
HandleDeleteKeyWithSelectedText(e);
e.SuppressKeyPress = true;
return;
}
}
if (SelectionStart != TextLength)
{
SelectionStart++;// A Delete can be accomplished with a right arrow followed by a backspace.
RtbSendKeys("{BS}"); // This is done due to a glitch in the RichTextBox that sometimes causes a beep rather than a delete
e.SuppressKeyPress = true;
}
}
else
HandleDeleteKeyWithSelectedText(e);
break;
}
}
#endregion
#region Mouse Handlers
void MyRTB_MouseUp(object sender, MouseEventArgs e)
{
_MouseDown = false;
HandleSelectionChange();
}
void MyRTB_MouseDown(object sender, MouseEventArgs e)
{
_MouseDown = true;
}
#endregion
#region Event Handlers
void MyRTB_SelectionChanged(object sender, EventArgs e)
{
HandleSelectionChange();
}
private bool _ProcessingDelete;
void MyRTB_TextChanged(object sender, EventArgs e)
{
if(!_IdentifyingLinks)
FindAllLinks();
if (!_ProcessingDelete && !_IdentifyingLinks)
{
OnRTBTextChanged(this, new EventArgs());
}
}
#endregion
#region SelectionStack
Stack<SelectionData> _SelectionStack = new Stack<SelectionData>();
public void PushSelection()
{
_SelectionStack.Push(new SelectionData(this));
}
public void PopSelection()
{
SelectionData selection = _SelectionStack.Pop();
Select(selection.SelectionStart, selection.SelectionLength);
}
public class SelectionData
{
int _SelectionStart;
public int SelectionStart
{
get { return _SelectionStart; }
set { _SelectionStart = value; }
}
int _SelectionLength;
public int SelectionLength
{
get { return _SelectionLength; }
set { _SelectionLength = value; }
}
public SelectionData(RichTextBox richTextBox)
{
_SelectionStart = richTextBox.SelectionStart;
_SelectionLength = richTextBox.SelectionLength;
}
}
#endregion
#region Link Support
bool _AdjustingSelection = false;
private bool _CheckSelection = false;
int _ProcessingKeys = 0;
private bool _MouseDown = false;
List<LinkLocation> _linkLocations;
public List<LinkLocation> LinkLocations
{
get { return _linkLocations; }
}
private int _FALLevel = 0;
private bool _IdentifyingLinks = false;
public void FindAllLinks()
{
if (_ProcessingDelete) return;
DebugPrint("FAL{0}vvvvvvvvvvvvvvvvvvvvvvvvv>>",++_FALLevel);
_AdjustingSelection = true;
PushSelection();
FindLinks();
IdentifyLinks();
PopSelection();
LinkLocation llx = FindLinkLocation();
if (_CheckSelection)
{
if (llx != null) SetSelection(llx.End, 0);
_CheckSelection = false;
}
_AdjustingSelection = false;
if(!_ProcessingDelete)
OnLinkLocationChanged(this, new EventArgs());
DebugPrint("FAL{0}^^^^^^^^^^^^^^^^^^^^^^^^^>>", _FALLevel--);
}
private void FindLinks()
{
string str = Text;
_linkLocations = new List<LinkLocation>();
MatchCollection matches = Regex.Matches(str, "<START](.*?)[[]END>");
MatchCollection matchesRtf = Regex.Matches(Rtf, "<START](.*?)[[]END>");
LinkLocation thisLink = null;
for (int i = 0; i < matches.Count; i++) //each (Match match in matches)
{ //KBR
Match match = matches[i];
Match matchrtf = matchesRtf[i];
thisLink = new LinkLocation(match.Index + 7, // If the [END> is immediately followed by <START] include it
match.Length - (((match.Index + match.Length + 7 <= str.Length) && (str.Substring(match.Index + match.Length, 7) == "<START]")) ? 0 : 7),
match.Value, matchrtf.Index, matchrtf.Length, thisLink);
_linkLocations.Add(thisLink);
} //KBR
}
private void IdentifyLinks()
{
_IdentifyingLinks = true;
foreach (LinkLocation ll in _linkLocations)
{
SetSelection(ll); // subtract off start token!
RTBAPI.CharFormatTwo charFormat = RTBAPI.GetCharFormat(this, RTBAPI.RTBSelection.SCF_SELECTION);
//charFormat.crBackColor = Color.Blue;
// 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(this, RTBAPI.RTBSelection.SCF_SELECTION, charFormat);
}
_IdentifyingLinks = false;
}
private LinkLocation FindBetweenLinks()
{
return FindBetweenLinks(SelectionStart);
}
private LinkLocation FindBetweenLinks(int start)
{
DebugPrint("FL----------------Between>");
foreach (LinkLocation ll in _linkLocations)
if (ll.Start == start && ll.StartsBetween)
return ll;
return null;
}
private LinkLocation FindLinkSelected()
{
DebugPrint("FL----------------Selected>");
if (_linkLocations == null) return null;
foreach (LinkLocation ll in _linkLocations)
if (ll.Start == SelectionStart && ll.Length == SelectionLength) return ll;
return null;
}
private LinkLocation FindLinkLocation()
{
return FindLinkLocation(SelectionStart);
}
private LinkLocation FindLinkLocation(int sel)
{
DebugPrint("FL----------------Location>");
if (_linkLocations == null) return null;
foreach (LinkLocation ll in _linkLocations)
{
// Moving right:
// if less than, allows stopping between two links
if (ll.Start < sel && ll.End > sel)
{
DebugPrint("Greater Than {0} {1} {2}", sel, ll.Start, ll.End);
return ll;
}
// if less than or equal, does not stop between two links
if ((!ll.StartsBetween) && ll.Start <= sel && ll.End > sel)
{
DebugPrint("Greater Than or Equal {0} {1} {2}", sel, ll.Start, ll.End);
return ll;
}
}
return null;
}
public void SetSelection(LinkLocation ll)
{
SetSelection(ll.Start, ll.Length);
}
public void SetSelection(int locStart, int locLength)
{
//Application.DoEvents(); // Not needed since SendKeys is always done last.
if(_IdentifyingLinks)
DebugPrint("SS------------------------> {0} {1}", locStart, locLength);
else
DebugPrint("SS========================> {0} {1}", locStart, locLength);
Select(locStart, locLength);
}
#endregion
#region Selection Handlers
private void HandleSelectionChange()
{
bool startingValue = _AdjustingSelection;
if (_IdentifyingLinks || _ProcessingDelete) return;
if (ProcessKeystrokes)
{
if (!_MouseDown && !_AdjustingSelection)
{
if (_linkLocations != null)
{
_AdjustingSelection = true;
LinkLocation ll = FindLinkLocation();
LinkLocation llend = null;
if (SelectionLength != 0)
llend = FindLinkLocation(SelectionStart + SelectionLength - 1);
if (ll != null)
{
if (SelectionStart == ll.Start && SelectionLength == 0)
{
if (SelectionStart >= 7)
{
DebugPrint("HSC===================>ll Insert: Sel {0}, Length {1}, Link Start {2}, Link Length {3}", SelectionStart, SelectionLength, ll.Start, ll.Length);
SelectionStart = ll.Start - 7;
}
}
else if (SelectionStart + SelectionLength > ll.End) // Beyond the end of the starting link
{
int end = SelectionStart + SelectionLength;
if (llend != null) end = llend.End; // If it extends into another link extend the end to the end of that link
DebugPrint("HSC===================>ll After: Sel {0}, Length {1}, Link Start {2}, Link Length {3}", SelectionStart, SelectionLength, ll.Start, ll.Length);
SetSelection(ll.Start, end - ll.Start);
}
else if (SelectionStart >= ll.Start || SelectionLength > 0)// Within the starting link
{
DebugPrint("HSC===================>ll: Sel {0}, Length {1}, Link Start {2}, Link Length {3}", SelectionStart, SelectionLength, ll.Start, ll.Length);
SetSelection(ll);
}
}
else if (llend != null)
{
DebugPrint("HSC===================>llend: Sel {0}, Length {1}, Link Start {2}, Link Length {3}", SelectionStart, SelectionLength, llend.Start, llend.Length);
// Check to see if the beginning starts before the <START] token. If it does, adjust the start
int newStart = SelectionStart + (SelectedText.StartsWith("<START]") ? 7 : 0);
SetSelection(newStart, llend.End - newStart);
}
else
{
if (SelectedText.EndsWith("<START]") && !SelectedText.EndsWith("[END><START]"))
{
DebugPrint("HSC===================>Removing ending <START] token");
SelectionLength = SelectionLength - 7;
}
if (SelectedText.StartsWith("<START]"))
{
DebugPrint("HSC===================>Removing starting <START] token");
SetSelection(SelectionStart + 7, SelectionLength - 7);
}
}
_AdjustingSelection = false;
}
}
}
if (startingValue != _AdjustingSelection)
DebugPrint("================> _AdjustingSelection problem");
DebugPrint("RS------ SelectionChange > {0}", FindRangeStatus());
OnRTBSelectionChanged(this, new EventArgs());
}
#endregion
#region Delete Handlers
private void HandleDeleteKeyWithSelectedText(KeyEventArgs e)
{
_ProcessingDelete = true;
FindRangeStatus();
DebugPrint("RS---------------- Delete > {0}", _RTBRangeStatus);
switch (_RTBRangeStatus)
{
case RangeStatus.NoContainedLinks:
case RangeStatus.Before_After:
case RangeStatus.Before_EndLink:
case RangeStatus.Before_EndBox:
default:
DeleteCurrentSelection();
e.SuppressKeyPress = true;
break;
case RangeStatus.Before_Between: //myRTB1.SelectedText.EndsWith(@"[END><START]")
DeleteEndBetweenLinks();
e.SuppressKeyPress = true;
break;
case RangeStatus.Between_EndBox:
case RangeStatus.Between_EndLink:
case RangeStatus.Between_After:
DeleteStartBetweenLinks();
e.SuppressKeyPress = true;
break;
case RangeStatus.Between_Between:
DeleteBetweenBetweenLinks();
e.SuppressKeyPress=true;
break;
case RangeStatus.StartLink_EndBox:
case RangeStatus.StartLink_EndLink:
case RangeStatus.StartLink_After:
ExpandSelectionToIncludeStart();
DeleteCurrentSelection();
e.SuppressKeyPress = true;
break;
case RangeStatus.StartLink_Between:
ExpandSelectionToIncludeStart();
DeleteEndBetweenLinks();
e.SuppressKeyPress = true;
break;
case RangeStatus.StartBox_EndLink:
case RangeStatus.StartBox_EndBox:
case RangeStatus.StartBox_After:
DeleteFromStartOfBox();
e.SuppressKeyPress = true;
break;
case RangeStatus.StartBox_Between:
DeleteFromStartOfBoxEndBetweenLinks();
e.SuppressKeyPress=true;
break;
// REMOVE THESE CASES OR PUT A MESSAGE OUT SAYING ERROR IN CODE - CASE
// NOT HANDLED
case RangeStatus.Before_StartLink:
case RangeStatus.Between_StartLink:
case RangeStatus.StartLink_StartLink:
case RangeStatus.StartBox_StartLink:
break;
}
_ProcessingDelete = false;
MyRTB_TextChanged(this, new EventArgs());
}
private void InsertCharBetweenLinks(LinkLocation ll)
{
InsertCharBetweenLinks(ll, ' ', false);
}
private void InsertCharBetweenLinks(LinkLocation ll, char charToAdd)
{
InsertCharBetweenLinks(ll, charToAdd, true);
}
/// <summary>
/// This inserts a space in between two links.
/// It actually inserts "\v0 {space}\v " between the END tag and the START tag
/// </summary>
/// <param name="ll"></param>
/// <param name="charToAdd"></param>
/// <param name="setSelect"></param>
private void InsertCharBetweenLinks(LinkLocation ll, char charToAdd, bool setSelect)
{
//_InsertingSpaceBetweenLinks = true;
DebugPrint("ICBLvvvvvvvvvvvvvvv>>>");
Rtf = Rtf.Substring(0, ll.StartRtf) + @"\v0 " + charToAdd.ToString() + @"\v " + Rtf.Substring(ll.StartRtf);
//_InsertingSpaceBetweenLinks = false;
if (setSelect)
SelectionStart = ll.Start - 6; // account for <START] - 1 for the character typed
DebugPrint("ICBL^^^^^^^^^^^^^^^>>>");
}
private void ExpandSelectionToIncludeStart()
{
//_AdjustingSelection = true;
SetSelection(SelectionStart - 7, SelectionLength + 7); // Expand selection to include start
//_AdjustingSelection = false;
}
private void DeleteBetweenBetweenLinks()
{
DebugSelection("DeleteBetweenBetweenLinks");
int selStart = SelectionStart - 7;
int selLength = SelectionLength + 2; // Include the two added spaces
InsertCharBetweenLinks(_RangeEndLink.NextLink); // Add a space at the end link
InsertCharBetweenLinks(_RangeStartLink); // Add a space a the start link
SetSelection(selStart, selLength);// Select everything including the spaces
DeleteCurrentSelection();// Delete Selection
}
/// <summary>
/// This is added to handle a glitch in richtextbox. Depending on
/// which direction that selection is made (left -> right or right -> left)
/// a replacement or delete may not work, you'll just get a 'beep'.
/// This approach consistently works.
/// </summary>
private void DeleteCurrentSelection()
{
DebugPrint("vvvvvvvvvvvvxxxxxxxxxxxx>");
DebugSelection("Before X");
SelectedText = "X"; // replace text with X
DebugSelection("After X");
DebugPrint("------------xxxxxxxxxxxx>");
_SendBackSpace = true;
RtbSendKeys("{BS}"); // remove X
Application.DoEvents();
DebugSelection("After BS");
DebugPrint("^^^^^^^^^^^^xxxxxxxxxxxx>");
}
private void DeleteSelection(int start, int length)
{
SetSelection(start, length);
DeleteCurrentSelection();
}
private void DeleteEndBetweenLinks()
{
_ProcessingKeys++;
DebugSelection("DeleteEndBetweenLinks");
int sstart = SelectionStart;
int slen = SelectionLength + 1 - 7;
// This puts a space at the link that starts at the end of the selection
InsertCharBetweenLinks(_RangeEndLink.NextLink);
//_AdjustingSelection = true;
DeleteSelection(sstart, slen);
//_AdjustingSelection = false;
_ProcessingKeys--;
}
private void DeleteStartBetweenLinks()
{
_ProcessingKeys++;
DebugSelection("DeleteStartBetweenLinks");
int slen = SelectionLength + 8;
int sstart = SelectionStart - 7;
//LinkLocation ll = FindBetweenLinks(SelectionStart);
InsertCharBetweenLinks(_RangeStartLink);
DeleteSelection(sstart, slen);
_ProcessingKeys--;
}
private void DeleteFromStartOfBox()
{
_ProcessingKeys++;
DebugSelection("DeleteFromStartOfBox");
int slen = SelectionLength;
SetSelection(0, 0);
//RtbSendKeys(" "); // open for space between links which separates END/START tokens
SelectedText = " ";
DeleteSelection(0, slen + 8);
_ProcessingKeys--;
}
private void DeleteFromStartOfBoxEndBetweenLinks()
{
_ProcessingKeys++;
DebugSelection("DeleteFromStartOfBoxEndBetweenLinks");
// This puts a space at the link that starts at the end of the selection
int sLen = SelectionStart + SelectionLength - 7 + 2;// -7 for <START] + 2 for the spaces that are added
//LinkLocation ll = FindBetweenLinks(SelectionStart + SelectionLength);
InsertCharBetweenLinks(_RangeEndLink.NextLink);
//RtbSendKeys("{RIGHT} "); // open for space between links which separates END/START tokens
//int sLen = myRTB1.SelectionStart;
SetSelection(0, 0);
//RtbSendKeys(" "); // open for space between links which separates END/START tokens
SelectedText = " "; // open for space between links which separates END/START tokens
DeleteSelection(0, sLen);
_ProcessingKeys--;
}
#endregion
#region Debug
private bool _ShowDebug = true;
public bool ShowDebug
{
get { return _ShowDebug; }
set { _ShowDebug = value; }
}
private void DebugPrint(string where, string format, params object[] myParams)
{
DebugPrint(where + string.Format(format, myParams));
}
private void DebugPrint(string format, params object[] myParams)
{
if(_ShowDebug)
Console.WriteLine(format, myParams);
}
private void DebugSelection(string where)
{
DebugPrint(where, ": {0} {1} '{2}'", SelectionStart, SelectionLength, SelectedText);
}
#endregion
#region SendKeys
private void RtbSendKeys(string keys)
{
Focus();
SendKeys.Send(keys); // With .Net Framework 3.0 this can be replaced with EditingCommands
// http://msdn.microsoft.com/en-us/library/ms771634.aspx
//DebugSelection(keys);
}
#endregion
#region EnumsSelectionRange
private enum StartStatus : int
{
Before = 100,
Between = 200,
StartLink = 300,
StartBox = 400
};
private enum EndStatus : int
{
After = 1,
Between = 2,
EndLink = 3,
EndBox = 4,
StartLink = 5
};
public enum RangeStatus : int
{
NoContainedLinks = 0,
Before_After = StartStatus.Before + EndStatus.After,
Before_Between = StartStatus.Before + EndStatus.Between,
Before_EndLink = StartStatus.Before + EndStatus.EndLink,
Before_EndBox = StartStatus.Before + EndStatus.EndBox,
Before_StartLink = StartStatus.Before + EndStatus.StartLink,
Between_After = StartStatus.Between + EndStatus.After,
Between_Between = StartStatus.Between + EndStatus.Between,
Between_EndLink = StartStatus.Between + EndStatus.EndLink,
Between_EndBox = StartStatus.Between + EndStatus.EndBox,
Between_StartLink = StartStatus.Between + EndStatus.StartLink,
StartLink_After = StartStatus.StartLink + EndStatus.After,
StartLink_Between = StartStatus.StartLink + EndStatus.Between,
StartLink_EndLink = StartStatus.StartLink + EndStatus.EndLink,
StartLink_EndBox = StartStatus.StartLink + EndStatus.EndBox,
StartLink_StartLink = StartStatus.StartLink + EndStatus.StartLink,
StartBox_After = StartStatus.StartBox + EndStatus.After,
StartBox_Between = StartStatus.StartBox + EndStatus.Between,
StartBox_EndLink = StartStatus.StartBox + EndStatus.EndLink,
StartBox_EndBox = StartStatus.StartBox + EndStatus.EndBox,
StartBox_StartLink = StartStatus.StartBox + EndStatus.StartLink
};
private RangeStatus _RTBRangeStatus;
public RangeStatus RTBRangeStatus
{
get { return _RTBRangeStatus; }
set
{
_RTBRangeStatus = value;
if(!_ProcessingDelete)OnRTBRangeStatusChanged(this, new EventArgs());
}
}
private LinkLocation _RangeStartLink = null;
private LinkLocation _RangeEndLink = null;
private RangeStatus FindRangeStatus()
{
_RangeStartLink = null;
_RangeEndLink = null;
if (_linkLocations == null || _linkLocations.Count == 0)
{
return RTBRangeStatus = RangeStatus.NoContainedLinks;
}
LinkLocation foundLink = null;
int start = SelectionStart;
int end = start + SelectionLength;
foreach (LinkLocation ll in _linkLocations)
{
if (foundLink == null && ((ll.Start >= start && ll.Start < end) || (ll.End >= start && ll.End < end)))
foundLink = ll;
if (_RangeStartLink == null && start >= ll.Start - 7 && start < ll.End)
_RangeStartLink = ll;
if (_RangeEndLink == null && end >= ll.Start && end <= ll.End)
_RangeEndLink = ll;
}
//DebugPrint("SelectionStart {0}, SelectionEnd {1}, TextLength {2}",
// SelectionStart, SelectionStart + SelectionLength,
// TextLength);
//if (startLink != null)
// startLink.Show("startLink");
//if (endLink != null)
// endLink.Show("endLink");
//if (foundLink != null)
// foundLink.Show("foundLink");
if (foundLink == null)
return RTBRangeStatus = RangeStatus.NoContainedLinks;
StartStatus myStartStatus = StartStatus.Before;
EndStatus myEndStatus = EndStatus.After;
if (_RangeStartLink != null)
{
if (_RangeStartLink.Start == 7)
myStartStatus = StartStatus.StartBox;
else if (_RangeStartLink.StartsBetween)
myStartStatus = StartStatus.Between;
else
myStartStatus = StartStatus.StartLink;
}
if (_RangeEndLink != null)
{
if (_RangeEndLink.End == TextLength)
myEndStatus = EndStatus.EndBox;
else if (_RangeEndLink.NextStart == _RangeEndLink.End)
myEndStatus = EndStatus.Between;
else if (end == _RangeEndLink.Start)
myEndStatus = EndStatus.StartLink; // Should not happen because of code in HandleSelectionChange
else //if (end == endLink.End)
myEndStatus = EndStatus.EndLink;
}
return RTBRangeStatus = (RangeStatus)((int)myStartStatus + (int)myEndStatus);
}
#endregion
}
#region LinkLocation
public class LinkLocation
{
private int _Start;
public int Start
{
get { return _Start; }
set { _Start = value; }
}
private int _Length;
public int Length
{
get { return _Length; }
set { _Length = value; }
}
public int End
{
get { return _Length + _Start; }
}
private int _StartRtf;
public int StartRtf
{
get { return _StartRtf; }
set { _StartRtf = value; }
}
private int _LengthRtf;
public int LengthRtf
{
get { return _LengthRtf; }
set { _LengthRtf = value; }
}
public int EndRtf
{
get { return _LengthRtf + _StartRtf; }
}
private string _Text;
public string Text
{
get { return _Text; }
set { _Text = value; }
}
private LinkLocation _PreviousLink = null;
public LinkLocation PreviousLink
{
get { return _PreviousLink; }
set
{
_PreviousLink = value;
value.NextLink = this;
}
}
private LinkLocation _NextLink = null;
public LinkLocation NextLink
{
get { return _NextLink; }
set { _NextLink = value; }
}
public int PreviousEnd
{
get { return PreviousLink == null ? -1 : PreviousLink.End; }
}
public bool StartsBetween
{
get { return PreviousEnd == Start; }
}
public int NextStart
{
get { return NextLink == null ? -1 : NextLink.Start; }
}
public bool EndsBetween
{
get { return NextStart == End; }
}
public LinkLocation(int start, int length, string text, int startRtf, int lengthRtf, LinkLocation previousLink)
{
_Start = start;
_Length = length;
_Text = text;
_StartRtf = startRtf;
_LengthRtf = lengthRtf;
if (previousLink != null) PreviousLink = previousLink;
}
public override string ToString()
{
return (string.Format("{0}, {1}", Start, End));
}
public void Show(string str)
{
if (PreviousLink != null)
Console.WriteLine("LinkLocation: {0}.PreviousLink {1}", str, PreviousLink);
Console.WriteLine("LinkLocation: {0} {1}", str, this);
if (NextLink != null)
Console.WriteLine("LinkLocation: {0}.NextLink {1}", str, NextLink);
}
}
#endregion
}

View File

@@ -0,0 +1,36 @@
namespace TestWndProc
{
partial class MyTextBox
{
/// <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,43 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Forms;
using System.Drawing;
using System.Data;
using System.Text;
using System.Runtime.InteropServices;
namespace TestWndProc
{
public partial class MyTextBox : TextBox
{
public event EventHandler SelectionChange;
public MyTextBox()
{
InitializeComponent();
}
public MyTextBox(IContainer container)
{
container.Add(this);
InitializeComponent();
}
private void OnSelectionChange()
{
if (SelectionChange != null)
SelectionChange(this, new EventArgs());
}
const int WM_IME_NOTIFY = 0x282;
const int IMN_SETCOMPOSITIONWINDOW = 11;
/// <summary>
/// Allow SelectionChange
/// </summary>
/// <param name="m"></param>
protected override void WndProc(ref Message m)
{
// Watch for SelectionChange Message
if (m.Msg == WM_IME_NOTIFY && m.WParam.ToInt32() == IMN_SETCOMPOSITIONWINDOW)
OnSelectionChange();
base.WndProc(ref m);
}
}
}

View File

@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace TestWndProc
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new frmWndProcTest());
}
}
}

View File

@@ -0,0 +1,33 @@
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("TestWndProc")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TestWndProc")]
[assembly: AssemblyCopyright("Copyright © 2009")]
[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("5f8a440e-83ef-405a-99b0-51d2cd0d1037")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,71 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.3074
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace TestWndProc.Properties
{
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TestWndProc.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}

View File

@@ -0,0 +1,117 @@
<?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.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: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" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</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" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</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,30 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.3074
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace TestWndProc.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}

View File

@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,113 @@
<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>{A672E7A2-94FF-4613-B6AC-52CC6F98EB29}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TestWndProc</RootNamespace>
<AssemblyName>TestWndProc</AssemblyName>
</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="System" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="frmPG.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="frmPG.Designer.cs">
<DependentUpon>frmPG.cs</DependentUpon>
</Compile>
<Compile Include="frmWndProcTest.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="frmWndProcTest.Designer.cs">
<DependentUpon>frmWndProcTest.cs</DependentUpon>
</Compile>
<Compile Include="MyPanel.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="MyPanel.Designer.cs">
<DependentUpon>MyPanel.cs</DependentUpon>
</Compile>
<Compile Include="MyRTB.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="MyRTB.Designer.cs">
<DependentUpon>MyRTB.cs</DependentUpon>
</Compile>
<Compile Include="MyTextBox.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="MyTextBox.designer.cs">
<DependentUpon>MyTextBox.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="frmPG.resx">
<SubType>Designer</SubType>
<DependentUpon>frmPG.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="frmWndProcTest.resx">
<SubType>Designer</SubType>
<DependentUpon>frmWndProcTest.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="MyPanel.resx">
<SubType>Designer</SubType>
<DependentUpon>MyPanel.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<Compile Include="RTBAPI.cs">
<SubType>Component</SubType>
</Compile>
</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,59 @@
namespace TestWndProc
{
partial class frmPG
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.pg = new System.Windows.Forms.PropertyGrid();
this.SuspendLayout();
//
// pg
//
this.pg.Dock = System.Windows.Forms.DockStyle.Fill;
this.pg.Location = new System.Drawing.Point(0, 0);
this.pg.Name = "pg";
this.pg.Size = new System.Drawing.Size(498, 382);
this.pg.TabIndex = 0;
//
// frmPG
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(498, 382);
this.Controls.Add(this.pg);
this.Name = "frmPG";
this.Text = "frmPG";
this.Load += new System.EventHandler(this.frmPG_Load);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.PropertyGrid pg;
}
}

View File

@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace TestWndProc
{
public partial class frmPG : Form
{
private Object _MyObject = null;
public Object MyObject
{
get { return _MyObject; }
set { _MyObject = value; pg.SelectedObject = _MyObject; }
}
public frmPG(Object myObject)
{
InitializeComponent();
_MyObject=myObject;
}
private void frmPG_Load(object sender, EventArgs e)
{
MyObject = _MyObject;
}
}
}

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,74 @@
namespace TestWndProc
{
partial class frmWndProcTest
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.myPanel1 = new TestWndProc.MyPanel();
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.SuspendLayout();
//
// myPanel1
//
this.myPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.myPanel1.Location = new System.Drawing.Point(0, 0);
this.myPanel1.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5);
this.myPanel1.Name = "myPanel1";
this.myPanel1.ShowDebug = true;
this.myPanel1.Size = new System.Drawing.Size(650, 594);
this.myPanel1.TabIndex = 0;
//
// richTextBox1
//
this.richTextBox1.Location = new System.Drawing.Point(9, 487);
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.Size = new System.Drawing.Size(471, 84);
this.richTextBox1.TabIndex = 1;
this.richTextBox1.Text = "";
//
// frmWndProcTest
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(650, 594);
this.Controls.Add(this.richTextBox1);
this.Controls.Add(this.myPanel1);
this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.Name = "frmWndProcTest";
this.Text = "WndProcTest";
this.ResumeLayout(false);
}
#endregion
private MyPanel myPanel1;
private System.Windows.Forms.RichTextBox richTextBox1;
}
}

View File

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace TestWndProc
{
public partial class frmWndProcTest : Form
{
public frmWndProcTest()
{
InitializeComponent();
richTextBox1.Text = "I am going to type some text that should wrap. I am going to type some text that should wrap. I am going to type some text that should wrap. I am going to type some text that should wrap.";
}
}
}

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>