From f8865206e9ae3dabb91e2bb3ee26ef97f9db9ffe Mon Sep 17 00:00:00 2001 From: Paul Larsen Date: Tue, 13 Jan 2026 11:46:47 -0500 Subject: [PATCH] C2022-003-Change-Textboxes-to-RTF-3 --- .../Exe/RefObj/ROEditor/FieldCombFrm.cs | 16 ++-- .../Exe/RefObj/ROEditor/ROEditor.cs | 8 +- .../LibSource/ctlXMLEditLib/ZoomDialog.cs | 4 +- .../LibSource/ctlXMLEditLib/ctlXMLEdit.cs | 87 ++++++++++--------- .../ctlXMLEditLib/ctlXMLEditLib.csproj | 6 ++ .../ctlXMLEditLib/roRichTextBox.Designer.cs | 40 +++++++++ .../LibSource/ctlXMLEditLib/roRichTextBox.cs | 31 +++++++ 7 files changed, 135 insertions(+), 57 deletions(-) create mode 100644 PROMS/ReferencedObjects/LibSource/ctlXMLEditLib/roRichTextBox.Designer.cs create mode 100644 PROMS/ReferencedObjects/LibSource/ctlXMLEditLib/roRichTextBox.cs diff --git a/PROMS/ReferencedObjects/Exe/RefObj/ROEditor/FieldCombFrm.cs b/PROMS/ReferencedObjects/Exe/RefObj/ROEditor/FieldCombFrm.cs index 46c6652d..b9ca735a 100644 --- a/PROMS/ReferencedObjects/Exe/RefObj/ROEditor/FieldCombFrm.cs +++ b/PROMS/ReferencedObjects/Exe/RefObj/ROEditor/FieldCombFrm.cs @@ -96,10 +96,10 @@ namespace ROEditor private System.Windows.Forms.Label lblW2; private System.Windows.Forms.Label lblW3; private System.Windows.Forms.Label lblW4; - private System.Windows.Forms.RichTextBox tbSingleTxtWid; // RO Editor add symbols C2022 - 003 - private System.Windows.Forms.RichTextBox tbVariableTxtWid; - private System.Windows.Forms.RichTextBox tbTableWid; - private System.Windows.Forms.RichTextBox tbXYPlotWid; + ctlXMLEditLib.roRichTextBox tbSingleTxtWid; // RO Editor add symbols C2022 - 003 + ctlXMLEditLib.roRichTextBox tbVariableTxtWid; + ctlXMLEditLib.roRichTextBox tbTableWid; + ctlXMLEditLib.roRichTextBox tbXYPlotWid; private System.Windows.Forms.Button btnOK; private System.Windows.Forms.Button btnCancel; /// @@ -218,10 +218,10 @@ namespace ROEditor this.lblFieldName = new System.Windows.Forms.Label(); this.tbFieldName = new System.Windows.Forms.TextBox(); this.gbAlternatives = new System.Windows.Forms.GroupBox(); - this.tbXYPlotWid = new System.Windows.Forms.RichTextBox(); // RO Editor add symbols C2022 - 003 - this.tbTableWid = new System.Windows.Forms.RichTextBox(); - this.tbVariableTxtWid = new System.Windows.Forms.RichTextBox(); - this.tbSingleTxtWid = new System.Windows.Forms.RichTextBox(); + this.tbXYPlotWid = new ctlXMLEditLib.roRichTextBox(); // RO Editor add symbols C2022 - 003 + this.tbTableWid = new ctlXMLEditLib.roRichTextBox(); + this.tbVariableTxtWid = new ctlXMLEditLib.roRichTextBox (); + this.tbSingleTxtWid = new ctlXMLEditLib.roRichTextBox(); this.lblW4 = new System.Windows.Forms.Label(); this.lblW3 = new System.Windows.Forms.Label(); this.lblW2 = new System.Windows.Forms.Label(); diff --git a/PROMS/ReferencedObjects/Exe/RefObj/ROEditor/ROEditor.cs b/PROMS/ReferencedObjects/Exe/RefObj/ROEditor/ROEditor.cs index c8aed690..e669537d 100644 --- a/PROMS/ReferencedObjects/Exe/RefObj/ROEditor/ROEditor.cs +++ b/PROMS/ReferencedObjects/Exe/RefObj/ROEditor/ROEditor.cs @@ -354,11 +354,11 @@ namespace ROEditor private System.Windows.Forms.MenuItem menuEditDelete; private System.Windows.Forms.MenuItem menuEditSelAll; 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 //private StepTabRibbon _MyStepTabRibbon; - public RichTextBox CurrentTextBox + public roRichTextBox CurrentTextBox { get { return _CurrentTextBox; } set { _CurrentTextBox = value; } @@ -1124,14 +1124,14 @@ namespace ROEditor protected void ctlXMLEdit2_ClickControl(object sender, EventArgs e) { - RichTextBox tmpTxtbx = new RichTextBox(); + roRichTextBox tmpTxtbx = new roRichTextBox(); CurrentTextBox = null; roTreeView_ResetEditMenu(); if (sender.GetType() == tmpTxtbx.GetType()) { - tmpTxtbx = (RichTextBox)sender; + tmpTxtbx = (roRichTextBox)sender; CurrentTextBox = tmpTxtbx; // the text box currently selected if (CurrentTextBox.Multiline) diff --git a/PROMS/ReferencedObjects/LibSource/ctlXMLEditLib/ZoomDialog.cs b/PROMS/ReferencedObjects/LibSource/ctlXMLEditLib/ZoomDialog.cs index 4939f420..d9fb9d7c 100644 --- a/PROMS/ReferencedObjects/LibSource/ctlXMLEditLib/ZoomDialog.cs +++ b/PROMS/ReferencedObjects/LibSource/ctlXMLEditLib/ZoomDialog.cs @@ -39,7 +39,7 @@ namespace ctlXMLEditLib { private System.Windows.Forms.Button btnSave; 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 /// /// Required designer variable. /// @@ -88,7 +88,7 @@ namespace ctlXMLEditLib /// 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.btnCancel = new System.Windows.Forms.Button(); this.SuspendLayout(); diff --git a/PROMS/ReferencedObjects/LibSource/ctlXMLEditLib/ctlXMLEdit.cs b/PROMS/ReferencedObjects/LibSource/ctlXMLEditLib/ctlXMLEdit.cs index 3938d121..875bdf19 100644 --- a/PROMS/ReferencedObjects/LibSource/ctlXMLEditLib/ctlXMLEdit.cs +++ b/PROMS/ReferencedObjects/LibSource/ctlXMLEditLib/ctlXMLEdit.cs @@ -241,12 +241,12 @@ namespace ctlXMLEditLib private bool dosaveflag; private VlnXmlElement editelem; private XmlDocument editdoc; - private RichTextBox zoomtextbox; + private roRichTextBox zoomtextbox; // 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. - private RichTextBox GraphicsFiletextbox; - private RichTextBox GraphicsWdtextbox; - private RichTextBox GraphicsHttextbox; + private roRichTextBox GraphicsFiletextbox; + private roRichTextBox GraphicsWdtextbox; + private roRichTextBox GraphicsHttextbox; private System.Windows.Forms.Button btnFindFile; private string GraphicsText; private ToolTip zmtooltip; @@ -328,8 +328,8 @@ namespace ctlXMLEditLib public string GetParentHTId { get { return parenthtid; } } public void SetParentHTId(string id) { this.parenthtid = id; } } - private RichTextBox _TextBoxFocus; // RO Editor add symbols C2022 - 003 - public RichTextBox TextBoxFocus + private roRichTextBox _TextBoxFocus; // RO Editor add symbols C2022 - 003 + public roRichTextBox TextBoxFocus { get { return _TextBoxFocus; } set @@ -390,7 +390,7 @@ namespace ctlXMLEditLib // set the required fields tag on those fields which are included in the passed // 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.Tag != null) @@ -405,7 +405,7 @@ namespace ctlXMLEditLib private void SetRequiredFields(ArrayList reqfields) { Object o; - RichTextBox hwnd; + roRichTextBox hwnd; string field, msg; int indx; foreach (string strfld in reqfields) @@ -424,15 +424,15 @@ namespace ctlXMLEditLib o = myHT[field+"a"]; if (o != null) // set all combo types required, the checker { - DoSet((RichTextBox)o,msg); - DoSet((RichTextBox)myHT[field+"b"],msg); - DoSet((RichTextBox)myHT[field+"c"],msg); - DoSet((RichTextBox)myHT[field+"d"],msg); + DoSet((roRichTextBox)o,msg); + DoSet((roRichTextBox)myHT[field+"b"],msg); + DoSet((roRichTextBox)myHT[field+"c"],msg); + DoSet((roRichTextBox)myHT[field+"d"],msg); } } else if (o != null) { - hwnd = (RichTextBox) o; + hwnd = (roRichTextBox) o; if (hwnd.Tag != null) { 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 // 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; // 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) { Object o; - RichTextBox hwnd; + roRichTextBox hwnd; XmlNode nd; // if we have an image, check it for validity, i.e. file exists, etc.?? foreach (string str in myHT.Keys) { o = myHT[str]; - hwnd = (RichTextBox)o; + hwnd = (roRichTextBox)o; nd = node.SelectSingleNode(str); // if not found with just the string, search the tree. if (nd==null)nd = node.SelectSingleNode("*/"+str); @@ -575,7 +575,7 @@ namespace ctlXMLEditLib // height/width data of the image. if (GraphicsFiletextbox != null && GraphicsFiletextbox.Text != "") UpdateHtWd(); } - public RichTextBox GetGraphicsFiletextbox() + public roRichTextBox GetGraphicsFiletextbox() { return GraphicsFiletextbox; } @@ -614,13 +614,13 @@ namespace ctlXMLEditLib { dosaveflag=false; mysavexml=false; - RichTextBox hwnd; + roRichTextBox hwnd; // first, clear out all of the text boxes. foreach (string str in myHT.Keys) { object o = myHT[str]; - hwnd = (RichTextBox) o; + hwnd = (roRichTextBox) o; hwnd.Text = ""; TextBoxAttrTag tag = (TextBoxAttrTag) hwnd.Tag; 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 database. This allow us to know that a specific value was not set // 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; // if this is a child node get the parent's value @@ -696,7 +696,7 @@ namespace ctlXMLEditLib { if (mysavexml) { - RichTextBox hwnd; + roRichTextBox hwnd; TextBoxAttrTag tag; string imgdate; @@ -704,7 +704,7 @@ namespace ctlXMLEditLib foreach (string str in myHT.Keys) // RO Editor add symbols C2022 - 003 { object o = myHT[str]; - hwnd = (RichTextBox) o; + hwnd = (roRichTextBox) o; StringBuilder result1 = new StringBuilder(); char[] chrAry = hwnd.Text.ToCharArray(); @@ -908,7 +908,7 @@ namespace ctlXMLEditLib // '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. // 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) { // 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); gbox.Controls.Add(radio); - RichTextBox tb = new RichTextBox(); + roRichTextBox tb = new roRichTextBox(); Size size3 = tb.Size; tb.Location = new Point(boxx+20, y+25); if (!first) tb.Visible = false; @@ -1203,8 +1203,8 @@ namespace ctlXMLEditLib } else { - RichTextBox mytextbox; - mytextbox = new RichTextBox(); + roRichTextBox mytextbox; + mytextbox = new roRichTextBox(); Size size3 = mytextbox.Size; mytextbox.Location = new Point(screenx+indent, screeny); string tFieldName = (pcChildIdx == 0) ? CvtUserFldToFld(element.Name) : CvtUserFldToFld(pcChildFldName); @@ -1333,7 +1333,7 @@ namespace ctlXMLEditLib private void radiocheckchg(object sender, System.EventArgs e) { RadioButton btnsel = (RadioButton) sender; - RichTextBox assocbox; + roRichTextBox assocbox; string btntext, str; if(dosaveflag)mysavexml = true; @@ -1346,7 +1346,7 @@ namespace ctlXMLEditLib str = btnsel.Name.Replace(btntext,""); object o = myHT[str]; if (o == null) return; - assocbox = (RichTextBox) o; + assocbox = (roRichTextBox) o; // make the text box visible if checked, otherwise, invisible assocbox.Visible = btnsel.Checked; // 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 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 & //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. private void currentTextBox(object sender, System.EventArgs e) { - RichTextBox textbox = (RichTextBox) sender; + roRichTextBox textbox = (roRichTextBox) sender; if (textbox.Multiline == true || textbox == GraphicsFiletextbox) zoomtextbox = textbox; else @@ -1517,7 +1517,7 @@ namespace ctlXMLEditLib { try { - MyValidatingCode((RichTextBox) sender); + MyValidatingCode((roRichTextBox) sender); } catch(Exception ex) @@ -2028,18 +2028,19 @@ namespace ctlXMLEditLib set { _DisplaySymBolBtn = value; } } } - public static class RichTextBoxExtensions // RO Editor add symbols C2022 - 003 - { - public static void InsertSymbol(this RichTextBox richTextBox, int symbcode) - { - int position = richTextBox.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 "; - richTextBox.SelectedRtf = RtfPrefixForSymbols + sym + @"}"; - richTextBox.SelectedRtf = @"{\rtf1\ansi\ansicpg1252\deff0\deflang1033\uc1 }"; - richTextBox.Select(position, 0); - } - } + //public static class RichTextBoxExtensions // RO Editor add symbols C2022 - 003 + //{ + // public static void InsertSymbol(this RichTextBox richTextBox, int symbcode) + // { + // int position = richTextBox.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 "; + // richTextBox.SelectedRtf = RtfPrefixForSymbols + sym + @"}"; + // richTextBox.SelectedRtf = @"{\rtf1\ansi\ansicpg1252\deff0\deflang1033\uc1 }"; + // richTextBox.Select(position, 0); + // } + //} + //roRichTextBox.InsertSymbol(); public enum E_FontStyle : byte diff --git a/PROMS/ReferencedObjects/LibSource/ctlXMLEditLib/ctlXMLEditLib.csproj b/PROMS/ReferencedObjects/LibSource/ctlXMLEditLib/ctlXMLEditLib.csproj index 2c914674..9a26067f 100644 --- a/PROMS/ReferencedObjects/LibSource/ctlXMLEditLib/ctlXMLEditLib.csproj +++ b/PROMS/ReferencedObjects/LibSource/ctlXMLEditLib/ctlXMLEditLib.csproj @@ -137,6 +137,12 @@ Form + + Component + + + roRichTextBox.cs + Form diff --git a/PROMS/ReferencedObjects/LibSource/ctlXMLEditLib/roRichTextBox.Designer.cs b/PROMS/ReferencedObjects/LibSource/ctlXMLEditLib/roRichTextBox.Designer.cs new file mode 100644 index 00000000..6626c0a2 --- /dev/null +++ b/PROMS/ReferencedObjects/LibSource/ctlXMLEditLib/roRichTextBox.Designer.cs @@ -0,0 +1,40 @@ + +namespace ctlXMLEditLib +{ + partial class roRichTextBox + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + System.Windows.Forms.AutoScaleMode AutoScaleMode; + private void InitializeComponent() + { + + components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + } + + #endregion + } +} diff --git a/PROMS/ReferencedObjects/LibSource/ctlXMLEditLib/roRichTextBox.cs b/PROMS/ReferencedObjects/LibSource/ctlXMLEditLib/roRichTextBox.cs new file mode 100644 index 00000000..3dd4c892 --- /dev/null +++ b/PROMS/ReferencedObjects/LibSource/ctlXMLEditLib/roRichTextBox.cs @@ -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); + } + } +}