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

This commit is contained in:
2026-01-28 14:47:00 -05:00
parent 0ae45eb918
commit 77c6298067
9 changed files with 295 additions and 20 deletions

View File

@@ -96,10 +96,11 @@ namespace ROEditor
private System.Windows.Forms.Label lblW2;
private System.Windows.Forms.Label lblW3;
private System.Windows.Forms.Label lblW4;
ctlXMLEditLib.roRichTextBox tbSingleTxtWid; // RO Editor add symbols C2022 - 003
ctlXMLEditLib.roRichTextBox tbVariableTxtWid;
ctlXMLEditLib.roRichTextBox tbTableWid;
ctlXMLEditLib.roRichTextBox tbXYPlotWid;
private System.Windows.Forms.TextBox tbSingleTxtWid;
private System.Windows.Forms.TextBox tbVariableTxtWid;
private System.Windows.Forms.TextBox tbTableWid;
private System.Windows.Forms.TextBox tbXYPlotWid;
private System.Windows.Forms.Button btnOK;
private System.Windows.Forms.Button btnCancel;
/// <summary>
@@ -218,10 +219,11 @@ 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 ctlXMLEditLib.roRichTextBox(); // RO Editor add symbols C2022 - 003
this.tbTableWid = new ctlXMLEditLib.roRichTextBox();
this.tbVariableTxtWid = new ctlXMLEditLib.roRichTextBox ();
this.tbSingleTxtWid = new ctlXMLEditLib.roRichTextBox();
this.tbXYPlotWid = new System.Windows.Forms.TextBox();
this.tbTableWid = new System.Windows.Forms.TextBox();
this.tbVariableTxtWid = new System.Windows.Forms.TextBox();
this.tbSingleTxtWid = new System.Windows.Forms.TextBox();
this.lblW4 = new System.Windows.Forms.Label();
this.lblW3 = new System.Windows.Forms.Label();
this.lblW2 = new System.Windows.Forms.Label();
@@ -280,6 +282,7 @@ namespace ROEditor
this.tbXYPlotWid.Size = new System.Drawing.Size(40, 22);
this.tbXYPlotWid.TabIndex = 11;
this.tbXYPlotWid.Text = "";
this.tbXYPlotWid.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtBox_KeyDown);
//
// tbTableWid
//
@@ -288,6 +291,7 @@ namespace ROEditor
this.tbTableWid.Size = new System.Drawing.Size(40, 22);
this.tbTableWid.TabIndex = 10;
this.tbTableWid.Text = "";
this.tbTableWid.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtBox_KeyDown);
//
// tbVariableTxtWid
//
@@ -296,6 +300,7 @@ namespace ROEditor
this.tbVariableTxtWid.Size = new System.Drawing.Size(40, 22);
this.tbVariableTxtWid.TabIndex = 9;
this.tbVariableTxtWid.Text = "";
this.tbVariableTxtWid.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtBox_KeyDown);
//
// tbSingleTxtWid
//
@@ -304,6 +309,7 @@ namespace ROEditor
this.tbSingleTxtWid.Size = new System.Drawing.Size(40, 22);
this.tbSingleTxtWid.TabIndex = 8;
this.tbSingleTxtWid.Text = "";
this.tbSingleTxtWid.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtBox_KeyDown);
//
// lblW4
//
@@ -586,5 +592,33 @@ namespace ROEditor
this.Close();
}
private void txtBox_KeyDown(object sender, KeyEventArgs e)
{
bool symFlg = false;
if (Clipboard.GetDataObject().GetDataPresent(DataFormats.Text))
{
string clpBrd = Clipboard.GetText();
char[] chrAry = clpBrd.ToCharArray();
foreach (int chr in chrAry)
{
if (chr > 166)
{
symFlg = true;
break;
}
else
{
symFlg = false;
}
}
if (symFlg == true)
{
MessageBox.Show("Symbols are not allowed in the field. Clipbroad: '" + clpBrd + "'");
Clipboard.Clear();
}
}
}
}
}

View File

@@ -316,6 +316,32 @@ namespace ROEditor
}
base.Dispose( disposing );
}
private void txtBox_KeyDown(object sender, KeyEventArgs e)
{
bool symFlg = false;
if (Clipboard.GetDataObject().GetDataPresent(DataFormats.Text))
{
string clpBrd = Clipboard.GetText();
char[] chrAry = clpBrd.ToCharArray();
foreach (int chr in chrAry)
{
if (chr > 166)
{
symFlg = true;
break;
}
else
{
symFlg = false;
}
}
if (symFlg == true)
{
MessageBox.Show("Symbols are not allowed in the field. Clipbroad: '" + clpBrd + "'");
Clipboard.Clear();
}
}
}
#region Windows Form Designer generated code
/// <summary>
@@ -357,6 +383,7 @@ namespace ROEditor
this.tbFieldName.Size = new System.Drawing.Size(320, 22);
this.tbFieldName.TabIndex = 2;
this.tbFieldName.Text = "";
this.tbFieldName.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtBox_KeyDown);
//
// tbWidth
//
@@ -365,6 +392,7 @@ namespace ROEditor
this.tbWidth.Size = new System.Drawing.Size(32, 22);
this.tbWidth.TabIndex = 3;
this.tbWidth.Text = "";
this.tbWidth.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtBox_KeyDown);
//
// btnOK
//
@@ -402,6 +430,7 @@ namespace ROEditor
this.tbPattern.TabIndex = 7;
this.tbPattern.Text = "";
this.tbPattern.Visible = false;
this.tbPattern.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtBox_KeyDown);
//
// FieldTextFrm
//

View File

@@ -277,6 +277,32 @@ namespace ROEditor
this.Close();
}
private void txtBox_KeyDown(object sender, KeyEventArgs e)
{
bool symFlg = false;
if (Clipboard.GetDataObject().GetDataPresent(DataFormats.Text))
{
string clpBrd = Clipboard.GetText();
char[] chrAry = clpBrd.ToCharArray();
foreach (int chr in chrAry)
{
if (chr > 166)
{
symFlg = true;
break;
}
else
{
symFlg = false;
}
}
if (symFlg == true)
{
MessageBox.Show("Symbols are not allowed in the field. Clipbroad: '" + clpBrd + "'");
Clipboard.Clear();
}
}
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
@@ -315,6 +341,7 @@ namespace ROEditor
this.tbFieldName.Size = new System.Drawing.Size(368, 22);
this.tbFieldName.TabIndex = 1;
this.tbFieldName.Text = "";
this.tbFieldName.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtBox_KeyDown);
//
// gbFldType
//

View File

@@ -155,6 +155,7 @@ namespace ROEditor
this.tbGroup.Size = new System.Drawing.Size(248, 22);
this.tbGroup.TabIndex = 8;
this.tbGroup.Text = "";
this.tbGroup.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtBox_KeyDown);
//
// lblGroup
//
@@ -421,5 +422,31 @@ namespace ROEditor
GroupDefFrm grdef = new GroupDefFrm(nelem,myrodb,nelem.InnerText,dbtype);
grdef.ShowDialog();
}
private void txtBox_KeyDown(object sender, KeyEventArgs e)
{
bool symFlg = false;
if (Clipboard.GetDataObject().GetDataPresent(DataFormats.Text))
{
string clpBrd = Clipboard.GetText();
char[] chrAry = clpBrd.ToCharArray();
foreach (int chr in chrAry)
{
if (chr > 166)
{
symFlg = true;
break;
}
else
{
symFlg = false;
}
}
if (symFlg == true)
{
MessageBox.Show("Symbols are not allowed in the field. Clipbroad: '" + clpBrd + "'");
Clipboard.Clear();
}
}
}
}
}

View File

@@ -1311,6 +1311,32 @@ namespace ROEditor
}
}
}
private void txtBox_KeyDown(object sender, KeyEventArgs e)
{
bool symFlg = false;
if (Clipboard.GetDataObject().GetDataPresent(DataFormats.Text))
{
string clpBrd = Clipboard.GetText();
char[] chrAry = clpBrd.ToCharArray();
foreach (int chr in chrAry)
{
if (chr > 166)
{
symFlg = true;
break;
}
else
{
symFlg = false;
}
}
if (symFlg == true)
{
MessageBox.Show("Symbols are not allowed in the field. Clipbroad: '" + clpBrd + "'");
Clipboard.Clear();
}
}
}
#region Windows Form Designer generated code
/// <summary>
@@ -1375,6 +1401,7 @@ namespace ROEditor
this.tbRetVal.Size = new System.Drawing.Size(464, 22);
this.tbRetVal.TabIndex = 4;
this.tbRetVal.Text = "textBox1";
this.tbRetVal.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtBox_KeyDown);
//
// tbMenuVal
//
@@ -1383,6 +1410,7 @@ namespace ROEditor
this.tbMenuVal.Size = new System.Drawing.Size(464, 22);
this.tbMenuVal.TabIndex = 5;
this.tbMenuVal.Text = "textBox1";
this.tbMenuVal.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtBox_KeyDown);
//
// lblGroupText
//

View File

@@ -399,7 +399,6 @@ namespace ROEditor
}
}
private const int ROGROUPIMAGE = 0;
private System.Windows.Forms.Panel panel2;
private const int ROIMAGE = 1;
@@ -1101,7 +1100,7 @@ namespace ROEditor
rbtnSaveAs.Enabled = false;
rbtnDuplicate.Enabled = true;
rbtnZoom.Enabled = false;
rbtnSymbols.Enabled = true; // test
rbtnSymbols.Enabled = true;
ctlXMLEdit2.Focus();
}
protected void roTreeView_OnDoubleClick(object sender, System.EventArgs e)

View File

@@ -203,6 +203,7 @@ using Org.Mentalis.Files;
using System.Windows;
using System.Text.RegularExpressions;
using System.Linq;
using Volian.Base.Library;
@@ -685,9 +686,6 @@ namespace ctlXMLEditLib
}
}
// SaveData saves the data in the element which had been sent to the control. Return
// true if success, false if fail.
// Note that the Parent and Child XML node variables below are not coding for Parent/Child Applicabily Fields
@@ -1502,12 +1500,10 @@ namespace ctlXMLEditLib
string RO_IDENDITY = RO_IDEN.Substring(1, RO_IDEN.Length - 2); // RO Editor add symbols C2022 - 003 for turning off symbols btn for RO ID.
if (textbox.Name == RO_IDENDITY)
{
//ROEditor.rbtnSymbols.Enabled = false;
OnEnableDisableSymbolsBtn(new ctlXMLEditEventArgs(DisplaySymBolBtn:false));
}
else
{
//ROEditor.rbtnSymbols.Enabled = true;
OnEnableDisableSymbolsBtn(new ctlXMLEditEventArgs(DisplaySymBolBtn:true));
}
@@ -1543,6 +1539,14 @@ namespace ctlXMLEditLib
}
btnZoom_click(null, null);
}
if (Clipboard.GetDataObject().GetDataPresent(DataFormats.Text))
{
if (((kea.Modifiers & Keys.ControlKey) == Keys.ControlKey) && kea.KeyCode == Keys.V)
{
roRichTextBox o = (roRichTextBox)objSender;
o.rchtxtBox_KeyDown(objSender, RO_IDEN);
}
}
}
public void btnZoom_click(object sender, System.EventArgs e)
@@ -2012,6 +2016,36 @@ namespace ctlXMLEditLib
return curTZ.GetDaylightChanges(year);
}
}
//private static void AddFontTable(StringBuilder selectedRtfSB, Font myFont, bool isFixed)
//{
// StringBuilder sbbeg = new StringBuilder();
// StringBuilder sbend = new StringBuilder();
// if (myFont.Bold)
// {
// sbbeg.Append(@"\b");
// sbend.Append(@"\b0");
// }
// if (myFont.Underline)
// {
// sbbeg.Append(@"\ul");
// sbend.Insert(0, @"\ulnone");
// }
// if (myFont.Italic)
// {
// sbbeg.Append(@"\i");
// sbend.Insert(0, @"\i0");
// }
// selectedRtfSB.Append(@"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset2 " + myFont.FontFamily.Name + @";}"); //}\f0\fs" + this.Font.SizeInPoints * 2 + @" " + myDisplayTextElement.Text + @"}}";
// if (!isFixed)
// selectedRtfSB.Append(@"{\f1\fnil\fcharset0 " + Volian.Base.Library.vlnFont.ProportionalSymbolFont + @";}}{\colortbl ;\red255\green0\blue0;\red0\green0\blue255;}"); // C2017-036 get best available proportional font for symbols - B2025-039 add Blue for Colored Replace Words
// else
// selectedRtfSB.Append(@"{\f1\fnil\fcharset0 FreeMono;}}{\colortbl ;\red255\green0\blue0;\red0\green0\blue255;}"); // FreeMono is now used for the edit screen only. VESymbFix and Consolas are used for printing
// selectedRtfSB.Append("\r\n");
// // use styles to construct rtf commands to insert into next line (where \b, etc is)
// // B2015-134 Hanging Indent with Hard Returns was not being saved- removed \sl-240\slmult0
// selectedRtfSB.Append(@"\viewkind4\uc1\pard" + sbbeg.ToString() + @"\fs" + Convert.ToInt32(myFont.SizeInPoints * 2).ToString() + @" "); // \f0\fs" + this.Font.SizeInPoints * 2 + @" " + myDisplayTextElement.Text + @"}";
// //selectedRtfSB.Append(@"\viewkind4\uc1\pard\sl-240\slmult0" + sbbeg.ToString() + @"\fs" + Convert.ToInt32(myFont.SizeInPoints * 2).ToString() + @" "); // \f0\fs" + this.Font.SizeInPoints * 2 + @" " + myDisplayTextElement.Text + @"}";
//}
public class ctlXMLEditEventArgs : EventArgs // RO Editor add symbols C2022 - 003 for turning off symbols btn for RO ID.
{
public ctlXMLEditEventArgs() {; }

View File

@@ -126,6 +126,9 @@
<Reference Include="System.Xml">
<Name>System.XML</Name>
</Reference>
<Reference Include="Volian.Base.Library">
<HintPath>..\..\..\Volian.Base.Library\bin\Debug\Volian.Base.Library.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs">

View File

@@ -7,6 +7,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Volian.Base.Library;
namespace ctlXMLEditLib
{
@@ -16,16 +17,109 @@ namespace ctlXMLEditLib
{
InitializeComponent();
}
private string _RtfPrefix; // contains Font table and styles (bold/underline/italics) for rtb from step style
public string RtfPrefixForSymbols
{
get
{
//B2020-100 RHM Use SelectionFont rather than the font from the format file.
StringBuilder selectedRtfSB = new StringBuilder();
AddFontTable(selectedRtfSB, FormatFont, true);
_RtfPrefix = selectedRtfSB.ToString();
return _RtfPrefix + @"\f1\fs" + 10 * 2 + " ";
}
}
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);
Select(position, -1);
Select(position + 1, 0);
}
public void rchtxtBox_KeyDown(object sender,string RO_IDEN) // C2022-003 code used to prevent a symbol from being inserted into RO ID.
{
bool symFlg = false;
roRichTextBox o = (roRichTextBox)sender;
if (o.Name == RO_IDEN)
{
if (Clipboard.GetDataObject().GetDataPresent(DataFormats.Text))
{
string clpBrd = Clipboard.GetText();
char[] chrAry = clpBrd.ToCharArray();
foreach (int chr in chrAry)
{
if (chr > 166)
{
symFlg = true;
break;
}
else
{
symFlg = false;
}
}
if (symFlg == true)
{
MessageBox.Show("Symbols are not allowed in the field. Clipbroad: '" + clpBrd + "'");
Clipboard.Clear();
}
}
}
}
private static void AddFontTable(StringBuilder selectedRtfSB, Font myFont, bool isFixed)
{
StringBuilder sbbeg = new StringBuilder();
StringBuilder sbend = new StringBuilder();
if (myFont.Bold)
{
sbbeg.Append(@"\b");
sbend.Append(@"\b0");
}
if (myFont.Underline)
{
sbbeg.Append(@"\ul");
sbend.Insert(0, @"\ulnone");
}
if (myFont.Italic)
{
sbbeg.Append(@"\i");
sbend.Insert(0, @"\i0");
}
selectedRtfSB.Append(@"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset2 " + myFont.FontFamily.Name + @";}");
if (!isFixed)
selectedRtfSB.Append(@"{\f1\fnil\fcharset0 " + Volian.Base.Library.vlnFont.ProportionalSymbolFont + @";}}{\colortbl ;\red255\green0\blue0;\red0\green0\blue255;}"); // C2017-036 get best available proportional font for symbols - B2025-039 add Blue for Colored Replace Words
else
selectedRtfSB.Append(@"{\f1\fnil\fcharset0 FreeMono;}}{\colortbl ;\red255\green0\blue0;\red0\green0\blue255;}"); // FreeMono is now used for the edit screen only. VESymbFix and Consolas are used for printing
selectedRtfSB.Append("\r\n");
// use styles to construct rtf commands to insert into next line (where \b, etc is)
// B2015-134 Hanging Indent with Hard Returns was not being saved- removed \sl-240\slmult0
selectedRtfSB.Append(@"\viewkind4\uc1\pard" + sbbeg.ToString() + @"\fs" + Convert.ToInt32(myFont.SizeInPoints * 2).ToString() + @" ");
}
private Font _FormatFont;
public Font FormatFont
{
get
{
if (_FormatFont == null)
{
Font formatFont;
formatFont = Font;
_FormatFont = formatFont;
}
// We found that the characters in the Letter Gothic font do not all use the same spacing.
// Also, the character spacing is even more different between screen resolutions.
// But the Letter Gothic font will print just fine.
// We also found that the Letter Gothic Tall font works just fine on the screen, the only difference
// is that the characters are a little bit taller.
// So we decided to use the Letter Gothic Tall font for the screen display any time that Letter Gothic is used.
if (_FormatFont.Name.ToUpper().Equals("LETTER GOTHIC"))
_FormatFont = new Font("Letter Gothic Tall", _FormatFont.Size, _FormatFont.Style);
return _FormatFont;
}
set { _FormatFont = value; }
}
}
}