C2025-022-Remove-UCF-2

This commit is contained in:
2025-08-28 15:24:28 -04:00
parent 525173bc9f
commit 8abe57552c
12 changed files with 116 additions and 767 deletions

View File

@@ -101,12 +101,6 @@
<Compile Include="FrmPopupStatusMessage.Designer.cs">
<DependentUpon>FrmPopupStatusMessage.cs</DependentUpon>
</Compile>
<Compile Include="frmRtfEdit.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="frmRtfEdit.Designer.cs">
<DependentUpon>frmRtfEdit.cs</DependentUpon>
</Compile>
<Compile Include="GenericSerializer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="PropGridCollEditor.cs" />
@@ -126,9 +120,6 @@
<EmbeddedResource Include="FrmPopupStatusMessage.resx">
<DependentUpon>FrmPopupStatusMessage.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="frmRtfEdit.resx">
<DependentUpon>frmRtfEdit.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View File

@@ -1,179 +0,0 @@
namespace Volian.Base.Library
{
partial class frmRtfEdit
{
/// <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.btnOK = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.rtfBox = new System.Windows.Forms.RichTextBox();
this.btnBold = new DevComponents.DotNetBar.ButtonX();
this.btnItalics = new DevComponents.DotNetBar.ButtonX();
this.btnUnderline = new DevComponents.DotNetBar.ButtonX();
this.btnSubscript = new DevComponents.DotNetBar.ButtonX();
this.btnSuperscript = new DevComponents.DotNetBar.ButtonX();
this.btnHardspace = new DevComponents.DotNetBar.ButtonX();
this.SuspendLayout();
//
// btnOK
//
this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK;
this.btnOK.Location = new System.Drawing.Point(38, 144);
this.btnOK.Name = "btnOK";
this.btnOK.Size = new System.Drawing.Size(75, 23);
this.btnOK.TabIndex = 3;
this.btnOK.Text = "OK";
this.btnOK.UseVisualStyleBackColor = true;
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
//
// btnCancel
//
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnCancel.Location = new System.Drawing.Point(143, 144);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(75, 23);
this.btnCancel.TabIndex = 4;
this.btnCancel.Text = "Cancel";
this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// rtfBox
//
this.rtfBox.Location = new System.Drawing.Point(38, 73);
this.rtfBox.Name = "rtfBox";
this.rtfBox.Size = new System.Drawing.Size(214, 50);
this.rtfBox.TabIndex = 5;
this.rtfBox.Text = "";
this.rtfBox.SelectionChanged += new System.EventHandler(this.rtfBox_SelectionChanged);
//
// btnBold
//
this.btnBold.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
this.btnBold.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
this.btnBold.Location = new System.Drawing.Point(12, 12);
this.btnBold.Name = "btnBold";
this.btnBold.Size = new System.Drawing.Size(31, 24);
this.btnBold.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
this.btnBold.TabIndex = 6;
this.btnBold.Text = "B";
this.btnBold.Click += new System.EventHandler(this.btnBold_Click);
//
// btnItalics
//
this.btnItalics.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
this.btnItalics.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
this.btnItalics.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.8F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnItalics.Location = new System.Drawing.Point(43, 12);
this.btnItalics.Name = "btnItalics";
this.btnItalics.Size = new System.Drawing.Size(31, 24);
this.btnItalics.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
this.btnItalics.TabIndex = 7;
this.btnItalics.Text = "I";
this.btnItalics.Click += new System.EventHandler(this.btnItalics_Click);
//
// btnUnderline
//
this.btnUnderline.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
this.btnUnderline.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
this.btnUnderline.Location = new System.Drawing.Point(74, 12);
this.btnUnderline.Name = "btnUnderline";
this.btnUnderline.Size = new System.Drawing.Size(31, 24);
this.btnUnderline.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
this.btnUnderline.TabIndex = 8;
this.btnUnderline.Text = "U";
this.btnUnderline.Click += new System.EventHandler(this.btnUnderline_Click);
//
// btnSubscript
//
this.btnSubscript.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
this.btnSubscript.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
this.btnSubscript.Location = new System.Drawing.Point(12, 42);
this.btnSubscript.Name = "btnSubscript";
this.btnSubscript.Size = new System.Drawing.Size(75, 23);
this.btnSubscript.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
this.btnSubscript.TabIndex = 9;
this.btnSubscript.Text = "Subscript";
this.btnSubscript.Click += new System.EventHandler(this.btnSubscript_Click);
//
// btnSuperscript
//
this.btnSuperscript.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
this.btnSuperscript.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
this.btnSuperscript.Location = new System.Drawing.Point(90, 42);
this.btnSuperscript.Name = "btnSuperscript";
this.btnSuperscript.Size = new System.Drawing.Size(75, 23);
this.btnSuperscript.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
this.btnSuperscript.TabIndex = 10;
this.btnSuperscript.Text = "Superscript";
this.btnSuperscript.Click += new System.EventHandler(this.btnSuperscript_Click);
//
// btnHardspace
//
this.btnHardspace.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
this.btnHardspace.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
this.btnHardspace.Location = new System.Drawing.Point(150, 10);
this.btnHardspace.Name = "btnHardspace";
this.btnHardspace.Size = new System.Drawing.Size(37, 26);
this.btnHardspace.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
this.btnHardspace.TabIndex = 11;
this.btnHardspace.Text = "HS";
this.btnHardspace.Click += new System.EventHandler(this.btnHardspace_Click);
//
// frmRtfEdit
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(282, 198);
this.Controls.Add(this.btnHardspace);
this.Controls.Add(this.btnSuperscript);
this.Controls.Add(this.btnSubscript);
this.Controls.Add(this.btnUnderline);
this.Controls.Add(this.btnItalics);
this.Controls.Add(this.btnBold);
this.Controls.Add(this.rtfBox);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnOK);
this.Name = "frmRtfEdit";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Rich Text Edit";
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button btnOK;
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.RichTextBox rtfBox;
private DevComponents.DotNetBar.ButtonX btnBold;
private DevComponents.DotNetBar.ButtonX btnItalics;
private DevComponents.DotNetBar.ButtonX btnUnderline;
private DevComponents.DotNetBar.ButtonX btnSubscript;
private DevComponents.DotNetBar.ButtonX btnSuperscript;
private DevComponents.DotNetBar.ButtonX btnHardspace;
}
}

View File

@@ -1,199 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;
using DevComponents.DotNetBar;
namespace Volian.Base.Library
{
// this is the form used in the UCF (User Control of Format) feature that displays text and allows the user to modify it to
// add/remove various text attributes: Underline, bold, italics, super/sub script & Hard space.
public partial class frmRtfEdit : Form
{
public frmRtfEdit()
{
InitializeComponent();
}
private static Regex regHyphen = new Regex(@"(?<!\\)(\\u8208\?|\\u8210\?|\\u8211\?|\\u8212\?|\\u8213\?|\\_|\\endash|\\emdash)");
// Value is used by the UITypeEditor, RtfEditor, to set/return the text that is being edited.
public string Value
{
get
{
string rtbString = regHyphen.Replace(RtfToDbText(rtfBox.Rtf).Replace("<BackSlash>", "\\\\"), @"\u8209?");
int indx = rtbString.IndexOf('-');
while (indx > -1)
{
if (indx > 2)
{
if (rtbString[indx - 1] != 'i' || rtbString[indx - 2] != 'f' || rtbString[indx - 3] != '\\')
{
rtbString = rtbString.Remove(indx, 1);
rtbString = rtbString.Insert(indx, @"\u8209?");
}
if (indx + 1 > rtbString.Length) indx = -1;
else indx = rtbString.IndexOf('-', indx + 1);
}
}
return rtbString;
}
set
{
string makeRtf = @"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Microsoft Sans Serif;}}\viewkind4\uc1\pard\f0\fs16 " + value + @"\par}";
makeRtf = makeRtf.Replace(@"\xa0", "'");
rtfBox.Rtf = makeRtf;
}
}
// when saving text, keep all of the necessary rtf commands that are used to define the text attributes. The rest are removed
public static string StaticReplaceRTFClause(Match m)
{
try
{
string token = m.Groups[1].Value;
switch (token[1])
{
case '\\':
return token;
case 'u':
if (Regex.IsMatch(token, @"^\\u[0-9]+$"))
return token; // Special Charcaters
if (Regex.IsMatch(token, @"^\\ulnone ?$"))
return token;
if (Regex.IsMatch(token, @"^\\ul.*$"))
return token; // Underline
if (Regex.IsMatch(token, @"^\\up[0-9] ?$"))
return token; // shift up (superscript)
break;
case 'd':
if (Regex.IsMatch(token, @"^\\dn[0-9] ?$"))
return token; // shift down (subscript)
break;
case '\'': // Special Character
return token;
case 'b': // Bold
return token;
case 'i': // Italics
return token;
case '{': // look for escape for curly braces:
return token;
case '}':
return token;
case 'l':
if (Regex.IsMatch(token, @"^\\line ?$")) return token;
if (Regex.IsMatch(token, @"^\\li[-0-9]+ ?$")) return token; // line indent
break;
case 'f':
if (Regex.IsMatch(token, @"^\\fi[-0-9]+ ?$")) return token; // first line indent
break;
case 'p':
if (Regex.IsMatch(token, @"^\\par ?$")) return @"{\par}";
break;
}
}
catch (Exception ex)
{
Console.WriteLine("StaticReplaceRTFClause {0} - {1}", ex.GetType().Name, ex.Message);
}
return "";//Strip All
}
// remove all of the rtf commands that are not needed to define the attributes of text that are supported:
private static Regex reg1 = new Regex(@"\\par\r\n(?!\\)");
private static Regex reg2 = new Regex(@"[\r\n]", RegexOptions.Singleline); // Strip Carriage Returns and Newlines
private static Regex reg3 = new Regex(@"^\{(.*)\}$", RegexOptions.Singleline); // Strip Opening and Closing Braces
private static Regex reg4 = new Regex(@"\{[^{]*?\}", RegexOptions.Singleline); // Strip Clauses - remove anything from curly braces
private static Regex reg5 = new Regex(@"\{[^{]*?\}", RegexOptions.Singleline); // Strip Clauses - remove anything from curly braces
private static Regex reg6 = new Regex(@"(\\[^' \\?\r\n\t]+)(?=\\)"); // add space after token if followed by token
private static Regex reg7 = new Regex(@"(\\[^' \\?\r\n\t]+ )"); // take backslash xyz and evaluates them
private static Regex reg8 = new Regex(@"(\\[^' \\?\r\n\t]+) (?=\\)"); // remove space between tokens
private static Regex reg9 = new Regex(@"(\\[^' \\?\r\n\t]+) (?=\r\n)"); // remove space before /r/n
private static Regex reg10 = new Regex(@"(\\[0-9a-z]+)$"); // end of text attribute needs a 'space'
private string RtfToDbText(string rtf)
{
// replace \{ & \} with (![ & (!] respectively and then redo at end. The curly braces
// are rtf so were getting removed and/or not handled correctly.
string retval = rtf.Replace(@"\{", @" (![");
retval = retval.Replace(@"\}", @" (!]");
// remove carriage return/newlines after \par commands (these are introduced by rtb
// for hard returns, goes into rtb as \par and comes out as \par\r\n):
retval = reg1.Replace(retval, "\\par ");
retval = retval.Replace("\\v0\r\n", "\\v0 "); // Replace Carriage Return and Newline after comment
retval = reg2.Replace(retval, ""); // Strip Carriage Returns and Newlines
retval = reg3.Replace(retval, "$1"); // Strip Opening and Closing Braces
retval = reg4.Replace(retval, ""); // Strip Clauses - remove anything from curly braces
retval = reg5.Replace(retval, ""); // Strip Clauses - remove anything from curly braces
retval = reg6.Replace(retval, "$1 "); // add space after token if followed by token
retval = reg7.Replace(retval, new MatchEvaluator(StaticReplaceRTFClause)); // take backslash xyz and evaluates them
retval = reg8.Replace(retval, "$1"); // remove space between tokens
retval = reg9.Replace(retval, "$1"); // remove space before /r/n
if (retval.EndsWith(@"{\par}")) retval = retval.Remove(retval.Length - 6, 6);
retval = reg10.Replace(retval, "$1 ");
// remove \r\n at end of string if the string has 2 or more characters
if (retval.EndsWith("\r\n")) retval = retval.Remove(retval.Length - 2, 2);
if (retval.Length == 0) return "";
if (retval.EndsWith(@"\v")) retval = retval.Remove(retval.Length - 2, 2);
retval = retval.Replace(@" (![", @"\{");
retval = retval.Replace(@" (!]", @"\}");
retval = retval.Replace("`",@"\xA0");
return retval;
}
private void btnBold_Click(object sender, EventArgs e)
{
RTBAPI.ToggleBold(!RTBAPI.IsBold(rtfBox), rtfBox, rtfBox.SelectionLength == 0 ? RTBAPI.RTBSelection.SCF_DEFAULT : RTBAPI.RTBSelection.SCF_SELECTION);
btnBold.Checked = RTBAPI.IsBold(rtfBox);
}
private void btnItalics_Click(object sender, EventArgs e)
{
RTBAPI.ToggleItalic(!RTBAPI.IsItalic(rtfBox), rtfBox, rtfBox.SelectionLength == 0 ? RTBAPI.RTBSelection.SCF_DEFAULT : RTBAPI.RTBSelection.SCF_SELECTION);
btnItalics.Checked = RTBAPI.IsItalic(rtfBox);
}
private void btnUnderline_Click(object sender, EventArgs e)
{
RTBAPI.ToggleUnderline(!RTBAPI.IsUnderline(rtfBox), rtfBox, rtfBox.SelectionLength == 0 ? RTBAPI.RTBSelection.SCF_DEFAULT : RTBAPI.RTBSelection.SCF_SELECTION);
btnUnderline.Checked = RTBAPI.IsUnderline(rtfBox);
}
private void btnSubscript_Click(object sender, EventArgs e)
{
RTBAPI.ToggleSubscript(!RTBAPI.IsSubScript(rtfBox), rtfBox, rtfBox.SelectionLength == 0 ? RTBAPI.RTBSelection.SCF_DEFAULT : RTBAPI.RTBSelection.SCF_SELECTION);
btnSubscript.Checked = RTBAPI.IsSubScript(rtfBox);
}
private void btnSuperscript_Click(object sender, EventArgs e)
{
RTBAPI.ToggleSuperscript(!RTBAPI.IsSuperScript(rtfBox), rtfBox, rtfBox.SelectionLength == 0 ? RTBAPI.RTBSelection.SCF_DEFAULT : RTBAPI.RTBSelection.SCF_SELECTION);
btnSuperscript.Checked = RTBAPI.IsSuperScript(rtfBox);
}
private void btnOK_Click(object sender, EventArgs e)
{
}
private void btnCancel_Click(object sender, EventArgs e)
{
}
private void rtfBox_SelectionChanged(object sender, EventArgs e)
{
btnBold.Checked = RTBAPI.IsBold(rtfBox);
btnItalics.Checked = RTBAPI.IsItalic(rtfBox);
btnUnderline.Checked = RTBAPI.IsUnderline(rtfBox);
}
private void btnHardspace_Click(object sender, EventArgs e)
{
AddText("`");
}
private void AddText(string str)
{
// See comments in AddRtf(string str) to explain the font style setting
RTBAPI.E_FontStyle fs = RTBAPI.GetFontStyle(rtfBox);
int positionStart = rtfBox.SelectionStart;
rtfBox.SelectedText = str;
int positionAfter = rtfBox.SelectionStart;
rtfBox.Select(positionStart, positionAfter - positionStart);
RTBAPI.SetFontStyle(rtfBox, fs);
rtfBox.Select(positionAfter, 0);
}
}
}

View File

@@ -1,120 +0,0 @@
<?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>