C2022-003-Change-Textboxes-to-RTF-3

This commit is contained in:
2026-01-13 11:46:47 -05:00
parent 5e7d2431b3
commit f8865206e9
7 changed files with 135 additions and 57 deletions

View File

@@ -96,10 +96,10 @@ namespace ROEditor
private System.Windows.Forms.Label lblW2; private System.Windows.Forms.Label lblW2;
private System.Windows.Forms.Label lblW3; private System.Windows.Forms.Label lblW3;
private System.Windows.Forms.Label lblW4; private System.Windows.Forms.Label lblW4;
private System.Windows.Forms.RichTextBox tbSingleTxtWid; // RO Editor add symbols C2022 - 003 ctlXMLEditLib.roRichTextBox tbSingleTxtWid; // RO Editor add symbols C2022 - 003
private System.Windows.Forms.RichTextBox tbVariableTxtWid; ctlXMLEditLib.roRichTextBox tbVariableTxtWid;
private System.Windows.Forms.RichTextBox tbTableWid; ctlXMLEditLib.roRichTextBox tbTableWid;
private System.Windows.Forms.RichTextBox tbXYPlotWid; ctlXMLEditLib.roRichTextBox tbXYPlotWid;
private System.Windows.Forms.Button btnOK; private System.Windows.Forms.Button btnOK;
private System.Windows.Forms.Button btnCancel; private System.Windows.Forms.Button btnCancel;
/// <summary> /// <summary>
@@ -218,10 +218,10 @@ namespace ROEditor
this.lblFieldName = new System.Windows.Forms.Label(); this.lblFieldName = new System.Windows.Forms.Label();
this.tbFieldName = new System.Windows.Forms.TextBox(); this.tbFieldName = new System.Windows.Forms.TextBox();
this.gbAlternatives = new System.Windows.Forms.GroupBox(); this.gbAlternatives = new System.Windows.Forms.GroupBox();
this.tbXYPlotWid = new System.Windows.Forms.RichTextBox(); // RO Editor add symbols C2022 - 003 this.tbXYPlotWid = new ctlXMLEditLib.roRichTextBox(); // RO Editor add symbols C2022 - 003
this.tbTableWid = new System.Windows.Forms.RichTextBox(); this.tbTableWid = new ctlXMLEditLib.roRichTextBox();
this.tbVariableTxtWid = new System.Windows.Forms.RichTextBox(); this.tbVariableTxtWid = new ctlXMLEditLib.roRichTextBox ();
this.tbSingleTxtWid = new System.Windows.Forms.RichTextBox(); this.tbSingleTxtWid = new ctlXMLEditLib.roRichTextBox();
this.lblW4 = new System.Windows.Forms.Label(); this.lblW4 = new System.Windows.Forms.Label();
this.lblW3 = new System.Windows.Forms.Label(); this.lblW3 = new System.Windows.Forms.Label();
this.lblW2 = new System.Windows.Forms.Label(); this.lblW2 = new System.Windows.Forms.Label();

View File

@@ -354,11 +354,11 @@ namespace ROEditor
private System.Windows.Forms.MenuItem menuEditDelete; private System.Windows.Forms.MenuItem menuEditDelete;
private System.Windows.Forms.MenuItem menuEditSelAll; private System.Windows.Forms.MenuItem menuEditSelAll;
private TreeNode LastSelectedNode; private TreeNode LastSelectedNode;
private RichTextBox _CurrentTextBox; // currently selected TextBox field private roRichTextBox _CurrentTextBox; // currently selected TextBox field
public static string[] PCChildren; //C2021-026 list of Parent/Child Children public static string[] PCChildren; //C2021-026 list of Parent/Child Children
//private StepTabRibbon _MyStepTabRibbon; //private StepTabRibbon _MyStepTabRibbon;
public RichTextBox CurrentTextBox public roRichTextBox CurrentTextBox
{ {
get { return _CurrentTextBox; } get { return _CurrentTextBox; }
set { _CurrentTextBox = value; } set { _CurrentTextBox = value; }
@@ -1124,14 +1124,14 @@ namespace ROEditor
protected void ctlXMLEdit2_ClickControl(object sender, EventArgs e) protected void ctlXMLEdit2_ClickControl(object sender, EventArgs e)
{ {
RichTextBox tmpTxtbx = new RichTextBox(); roRichTextBox tmpTxtbx = new roRichTextBox();
CurrentTextBox = null; CurrentTextBox = null;
roTreeView_ResetEditMenu(); roTreeView_ResetEditMenu();
if (sender.GetType() == tmpTxtbx.GetType()) if (sender.GetType() == tmpTxtbx.GetType())
{ {
tmpTxtbx = (RichTextBox)sender; tmpTxtbx = (roRichTextBox)sender;
CurrentTextBox = tmpTxtbx; // the text box currently selected CurrentTextBox = tmpTxtbx; // the text box currently selected
if (CurrentTextBox.Multiline) if (CurrentTextBox.Multiline)

View File

@@ -39,7 +39,7 @@ namespace ctlXMLEditLib
{ {
private System.Windows.Forms.Button btnSave; private System.Windows.Forms.Button btnSave;
private System.Windows.Forms.Button btnCancel; private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.RichTextBox tbZoom; // RO Editor add symbols C2022 - 003 private ctlXMLEditLib.roRichTextBox tbZoom; // RO Editor add symbols C2022 - 003
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
/// </summary> /// </summary>
@@ -88,7 +88,7 @@ namespace ctlXMLEditLib
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.tbZoom = new System.Windows.Forms.RichTextBox(); // RO Editor add symbols C2022 - 003 this.tbZoom = new ctlXMLEditLib.roRichTextBox(); // RO Editor add symbols C2022 - 003
this.btnSave = new System.Windows.Forms.Button(); this.btnSave = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button(); this.btnCancel = new System.Windows.Forms.Button();
this.SuspendLayout(); this.SuspendLayout();

View File

@@ -241,12 +241,12 @@ namespace ctlXMLEditLib
private bool dosaveflag; private bool dosaveflag;
private VlnXmlElement editelem; private VlnXmlElement editelem;
private XmlDocument editdoc; private XmlDocument editdoc;
private RichTextBox zoomtextbox; private roRichTextBox zoomtextbox;
// the following is used for handling images. Note that if we want to have more // the following is used for handling images. Note that if we want to have more
// than one image defined in an ro, this should be become a list. // than one image defined in an ro, this should be become a list.
private RichTextBox GraphicsFiletextbox; private roRichTextBox GraphicsFiletextbox;
private RichTextBox GraphicsWdtextbox; private roRichTextBox GraphicsWdtextbox;
private RichTextBox GraphicsHttextbox; private roRichTextBox GraphicsHttextbox;
private System.Windows.Forms.Button btnFindFile; private System.Windows.Forms.Button btnFindFile;
private string GraphicsText; private string GraphicsText;
private ToolTip zmtooltip; private ToolTip zmtooltip;
@@ -328,8 +328,8 @@ namespace ctlXMLEditLib
public string GetParentHTId { get { return parenthtid; } } public string GetParentHTId { get { return parenthtid; } }
public void SetParentHTId(string id) { this.parenthtid = id; } public void SetParentHTId(string id) { this.parenthtid = id; }
} }
private RichTextBox _TextBoxFocus; // RO Editor add symbols C2022 - 003 private roRichTextBox _TextBoxFocus; // RO Editor add symbols C2022 - 003
public RichTextBox TextBoxFocus public roRichTextBox TextBoxFocus
{ {
get { return _TextBoxFocus; } get { return _TextBoxFocus; }
set set
@@ -390,7 +390,7 @@ namespace ctlXMLEditLib
// set the required fields tag on those fields which are included in the passed // set the required fields tag on those fields which are included in the passed
// in required fields list. // in required fields list.
private void DoSet(RichTextBox hwnd, string msg) // RO Editor add symbols C2022 - 003 private void DoSet(roRichTextBox hwnd, string msg) // RO Editor add symbols C2022 - 003
{ {
if (hwnd == null) return; if (hwnd == null) return;
if (hwnd.Tag != null) if (hwnd.Tag != null)
@@ -405,7 +405,7 @@ namespace ctlXMLEditLib
private void SetRequiredFields(ArrayList reqfields) private void SetRequiredFields(ArrayList reqfields)
{ {
Object o; Object o;
RichTextBox hwnd; roRichTextBox hwnd;
string field, msg; string field, msg;
int indx; int indx;
foreach (string strfld in reqfields) foreach (string strfld in reqfields)
@@ -424,15 +424,15 @@ namespace ctlXMLEditLib
o = myHT[field+"a"]; o = myHT[field+"a"];
if (o != null) // set all combo types required, the checker if (o != null) // set all combo types required, the checker
{ {
DoSet((RichTextBox)o,msg); DoSet((roRichTextBox)o,msg);
DoSet((RichTextBox)myHT[field+"b"],msg); DoSet((roRichTextBox)myHT[field+"b"],msg);
DoSet((RichTextBox)myHT[field+"c"],msg); DoSet((roRichTextBox)myHT[field+"c"],msg);
DoSet((RichTextBox)myHT[field+"d"],msg); DoSet((roRichTextBox)myHT[field+"d"],msg);
} }
} }
else if (o != null) else if (o != null)
{ {
hwnd = (RichTextBox) o; hwnd = (roRichTextBox) o;
if (hwnd.Tag != null) if (hwnd.Tag != null)
{ {
TextBoxAttrTag tag = (TextBoxAttrTag) hwnd.Tag; TextBoxAttrTag tag = (TextBoxAttrTag) hwnd.Tag;
@@ -446,7 +446,7 @@ namespace ctlXMLEditLib
// C2021-026 If this is a Parent/Child field that has no value saved in the database // C2021-026 If this is a Parent/Child field that has no value saved in the database
// then use the parent's value and display it as grey colored text. // then use the parent's value and display it as grey colored text.
private void GetDefaultParentValue(RichTextBox tb, XmlNode node, string chldName) private void GetDefaultParentValue(roRichTextBox tb, XmlNode node, string chldName)
{ {
XmlNode parentNode = null; XmlNode parentNode = null;
// PCChildren contains a list strings reprenting the Children setup in the current Working Draft Parent/Child property // PCChildren contains a list strings reprenting the Children setup in the current Working Draft Parent/Child property
@@ -490,13 +490,13 @@ namespace ctlXMLEditLib
private void DisplayFieldContents(XmlNode node) private void DisplayFieldContents(XmlNode node)
{ {
Object o; Object o;
RichTextBox hwnd; roRichTextBox hwnd;
XmlNode nd; XmlNode nd;
// if we have an image, check it for validity, i.e. file exists, etc.?? // if we have an image, check it for validity, i.e. file exists, etc.??
foreach (string str in myHT.Keys) foreach (string str in myHT.Keys)
{ {
o = myHT[str]; o = myHT[str];
hwnd = (RichTextBox)o; hwnd = (roRichTextBox)o;
nd = node.SelectSingleNode(str); nd = node.SelectSingleNode(str);
// if not found with just the string, search the tree. // if not found with just the string, search the tree.
if (nd==null)nd = node.SelectSingleNode("*/"+str); if (nd==null)nd = node.SelectSingleNode("*/"+str);
@@ -575,7 +575,7 @@ namespace ctlXMLEditLib
// height/width data of the image. // height/width data of the image.
if (GraphicsFiletextbox != null && GraphicsFiletextbox.Text != "") UpdateHtWd(); if (GraphicsFiletextbox != null && GraphicsFiletextbox.Text != "") UpdateHtWd();
} }
public RichTextBox GetGraphicsFiletextbox() public roRichTextBox GetGraphicsFiletextbox()
{ {
return GraphicsFiletextbox; return GraphicsFiletextbox;
} }
@@ -614,13 +614,13 @@ namespace ctlXMLEditLib
{ {
dosaveflag=false; dosaveflag=false;
mysavexml=false; mysavexml=false;
RichTextBox hwnd; roRichTextBox hwnd;
// first, clear out all of the text boxes. // first, clear out all of the text boxes.
foreach (string str in myHT.Keys) foreach (string str in myHT.Keys)
{ {
object o = myHT[str]; object o = myHT[str];
hwnd = (RichTextBox) o; hwnd = (roRichTextBox) o;
hwnd.Text = ""; hwnd.Text = "";
TextBoxAttrTag tag = (TextBoxAttrTag) hwnd.Tag; TextBoxAttrTag tag = (TextBoxAttrTag) hwnd.Tag;
RadioButton radio; RadioButton radio;
@@ -652,7 +652,7 @@ namespace ctlXMLEditLib
// to the parent's value, then clear the child's textbox so that nothing is saved // to the parent's value, then clear the child's textbox so that nothing is saved
// to the database. This allow us to know that a specific value was not set // to the database. This allow us to know that a specific value was not set
// for this Parent/Child child // for this Parent/Child child
private void RemovePCChildTextIfSameAsParent(XmlNode node, RichTextBox tb, string chldName) private void RemovePCChildTextIfSameAsParent(XmlNode node, roRichTextBox tb, string chldName)
{ {
XmlNode parentNode = null; XmlNode parentNode = null;
// if this is a child node get the parent's value // if this is a child node get the parent's value
@@ -696,7 +696,7 @@ namespace ctlXMLEditLib
{ {
if (mysavexml) if (mysavexml)
{ {
RichTextBox hwnd; roRichTextBox hwnd;
TextBoxAttrTag tag; TextBoxAttrTag tag;
string imgdate; string imgdate;
@@ -704,7 +704,7 @@ namespace ctlXMLEditLib
foreach (string str in myHT.Keys) // RO Editor add symbols C2022 - 003 foreach (string str in myHT.Keys) // RO Editor add symbols C2022 - 003
{ {
object o = myHT[str]; object o = myHT[str];
hwnd = (RichTextBox) o; hwnd = (roRichTextBox) o;
StringBuilder result1 = new StringBuilder(); StringBuilder result1 = new StringBuilder();
char[] chrAry = hwnd.Text.ToCharArray(); char[] chrAry = hwnd.Text.ToCharArray();
@@ -908,7 +908,7 @@ namespace ctlXMLEditLib
// 'normalizedString') or a multiline text box(type is 'string'). Also, a radio // 'normalizedString') or a multiline text box(type is 'string'). Also, a radio
// button is passed in if this was called to handle an element within a combo type. // button is passed in if this was called to handle an element within a combo type.
// This button is saved for a given text box so that initialization of these combo types can occur. // This button is saved for a given text box so that initialization of these combo types can occur.
private string DisplayXmlSchemaSimpleType(XmlSchemaSimpleType simpleType, RichTextBox mytextbox, RadioButton radio, private string DisplayXmlSchemaSimpleType(XmlSchemaSimpleType simpleType, roRichTextBox mytextbox, RadioButton radio,
bool img, string imgname) bool img, string imgname)
{ {
// set up for text box tag, which stores whether field is required and // set up for text box tag, which stores whether field is required and
@@ -1050,7 +1050,7 @@ namespace ctlXMLEditLib
radio.CheckedChanged += new System.EventHandler(this.radiocheckchg); radio.CheckedChanged += new System.EventHandler(this.radiocheckchg);
gbox.Controls.Add(radio); gbox.Controls.Add(radio);
RichTextBox tb = new RichTextBox(); roRichTextBox tb = new roRichTextBox();
Size size3 = tb.Size; Size size3 = tb.Size;
tb.Location = new Point(boxx+20, y+25); tb.Location = new Point(boxx+20, y+25);
if (!first) tb.Visible = false; if (!first) tb.Visible = false;
@@ -1203,8 +1203,8 @@ namespace ctlXMLEditLib
} }
else else
{ {
RichTextBox mytextbox; roRichTextBox mytextbox;
mytextbox = new RichTextBox(); mytextbox = new roRichTextBox();
Size size3 = mytextbox.Size; Size size3 = mytextbox.Size;
mytextbox.Location = new Point(screenx+indent, screeny); mytextbox.Location = new Point(screenx+indent, screeny);
string tFieldName = (pcChildIdx == 0) ? CvtUserFldToFld(element.Name) : CvtUserFldToFld(pcChildFldName); string tFieldName = (pcChildIdx == 0) ? CvtUserFldToFld(element.Name) : CvtUserFldToFld(pcChildFldName);
@@ -1333,7 +1333,7 @@ namespace ctlXMLEditLib
private void radiocheckchg(object sender, System.EventArgs e) private void radiocheckchg(object sender, System.EventArgs e)
{ {
RadioButton btnsel = (RadioButton) sender; RadioButton btnsel = (RadioButton) sender;
RichTextBox assocbox; roRichTextBox assocbox;
string btntext, str; string btntext, str;
if(dosaveflag)mysavexml = true; if(dosaveflag)mysavexml = true;
@@ -1346,7 +1346,7 @@ namespace ctlXMLEditLib
str = btnsel.Name.Replace(btntext,""); str = btnsel.Name.Replace(btntext,"");
object o = myHT[str]; object o = myHT[str];
if (o == null) return; if (o == null) return;
assocbox = (RichTextBox) o; assocbox = (roRichTextBox) o;
// make the text box visible if checked, otherwise, invisible // make the text box visible if checked, otherwise, invisible
assocbox.Visible = btnsel.Checked; assocbox.Visible = btnsel.Checked;
// C2021-026 show or hide the Parent/Child appicability group box // C2021-026 show or hide the Parent/Child appicability group box
@@ -1460,7 +1460,7 @@ namespace ctlXMLEditLib
// The following can be used to validate the text, i.e. check the text against // The following can be used to validate the text, i.e. check the text against
// the pattern. this needs written yet (5/16/02) // the pattern. this needs written yet (5/16/02)
private void MyValidatingCode(RichTextBox tb) private void MyValidatingCode(roRichTextBox tb)
{ {
//get the text box's tag which contains a flag for whether this is required & //get the text box's tag which contains a flag for whether this is required &
//if it has a pattern. If it has a pattern, validate the field against the pattern. //if it has a pattern. If it has a pattern, validate the field against the pattern.
@@ -1491,7 +1491,7 @@ namespace ctlXMLEditLib
// save which box we're on, for zoom processing. // save which box we're on, for zoom processing.
private void currentTextBox(object sender, System.EventArgs e) private void currentTextBox(object sender, System.EventArgs e)
{ {
RichTextBox textbox = (RichTextBox) sender; roRichTextBox textbox = (roRichTextBox) sender;
if (textbox.Multiline == true || textbox == GraphicsFiletextbox) if (textbox.Multiline == true || textbox == GraphicsFiletextbox)
zoomtextbox = textbox; zoomtextbox = textbox;
else else
@@ -1517,7 +1517,7 @@ namespace ctlXMLEditLib
{ {
try try
{ {
MyValidatingCode((RichTextBox) sender); MyValidatingCode((roRichTextBox) sender);
} }
catch(Exception ex) catch(Exception ex)
@@ -2028,18 +2028,19 @@ namespace ctlXMLEditLib
set { _DisplaySymBolBtn = value; } set { _DisplaySymBolBtn = value; }
} }
} }
public static class RichTextBoxExtensions // RO Editor add symbols C2022 - 003 //public static class RichTextBoxExtensions // RO Editor add symbols C2022 - 003
{ //{
public static void InsertSymbol(this RichTextBox richTextBox, int symbcode) // public static void InsertSymbol(this RichTextBox richTextBox, int symbcode)
{ // {
int position = richTextBox.SelectionStart; // int position = richTextBox.SelectionStart;
string sym = string.Format(symbcode < 256 ? "\'{0:X2}" : @"\u{0}", symbcode); // string sym = string.Format(symbcode < 256 ? "\'{0:X2}" : @"\u{0}", symbcode);
string RtfPrefixForSymbols = @"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset2 FreeMono; } {\f1\fnil\fcharset0 FreeMono; } } {\colortbl;\red255\green0\blue0;\red0\green0\blue255; } \viewkind4\uc1\pard\fs24 \f1\fs24 "; // string RtfPrefixForSymbols = @"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset2 FreeMono; } {\f1\fnil\fcharset0 FreeMono; } } {\colortbl;\red255\green0\blue0;\red0\green0\blue255; } \viewkind4\uc1\pard\fs24 \f1\fs24 ";
richTextBox.SelectedRtf = RtfPrefixForSymbols + sym + @"}"; // richTextBox.SelectedRtf = RtfPrefixForSymbols + sym + @"}";
richTextBox.SelectedRtf = @"{\rtf1\ansi\ansicpg1252\deff0\deflang1033\uc1 }"; // richTextBox.SelectedRtf = @"{\rtf1\ansi\ansicpg1252\deff0\deflang1033\uc1 }";
richTextBox.Select(position, 0); // richTextBox.Select(position, 0);
} // }
} //}
//roRichTextBox.InsertSymbol();
public enum E_FontStyle : byte public enum E_FontStyle : byte

View File

@@ -137,6 +137,12 @@
<Compile Include="ImageDialog.cs"> <Compile Include="ImageDialog.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
<Compile Include="roRichTextBox.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="roRichTextBox.Designer.cs">
<DependentUpon>roRichTextBox.cs</DependentUpon>
</Compile>
<Compile Include="ZoomDialog.cs"> <Compile Include="ZoomDialog.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>

View File

@@ -0,0 +1,40 @@

namespace ctlXMLEditLib
{
partial class roRichTextBox
{
/// <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>
System.Windows.Forms.AutoScaleMode AutoScaleMode;
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
}
#endregion
}
}

View File

@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ctlXMLEditLib
{
public partial class roRichTextBox : RichTextBox // C2022-003 Symbols in RO Editor. Customized RichTextBox for RO Editor.
{
public roRichTextBox()
{
InitializeComponent();
}
public void InsertSymbol( int symbcode)
{
int position = this.SelectionStart;
string sym = string.Format(symbcode < 256 ? "\'{0:X2}" : @"\u{0}", symbcode);
string RtfPrefixForSymbols = @"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset2 FreeMono; } {\f1\fnil\fcharset0 FreeMono; } } {\colortbl;\red255\green0\blue0;\red0\green0\blue255; } \viewkind4\uc1\pard\fs24 \f1\fs24 ";
this.SelectedRtf = RtfPrefixForSymbols + sym + @"}";
this.SelectedRtf = @"{\rtf1\ansi\ansicpg1252\deff0\deflang1033\uc1 }";
this.Select(position, 0); this.SelectedRtf = @"{\rtf1\ansi\ansicpg1252\deff0\deflang1033\uc1 }";
this.Select(position, 0);
}
}
}