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

This commit is contained in:
2025-12-24 14:20:31 -05:00
parent d4ecf28147
commit 72c2bd90e4
10 changed files with 8 additions and 329 deletions

View File

@@ -302,14 +302,10 @@ using Org.Mentalis.Files;
using System.Runtime.InteropServices;
using System.Linq;
using System.Collections.Generic;
//using Volian.Controls.Library;
using Volian.Base.Library;
using VEPROMS.CSLA.Library;
using System.Xml;
using System.Drawing.Text;
using System.Drawing.Drawing2D;
using System.Text.RegularExpressions;
//using IniFileIO;
namespace ROEditor
{
@@ -1187,18 +1183,6 @@ namespace ROEditor
menuROSave.Enabled = rbtnSave.Enabled;
}
public void RTBSymbolsOnOff(string nm)
{
string RO_IDENDITY = RO_IDEN.Substring(1, RO_IDEN.Length - 2);
if (this.CurrentTextBox.Name == RO_IDENDITY)
{
rbtnSymbols.Enabled = false;
}
else
{
rbtnSymbols.Enabled = true;
}
}
public void EnableDisableSymbolsBtn(object sender, ctlXMLEditEventArgs args)
{
@@ -1212,8 +1196,6 @@ namespace ROEditor
}
}
//EnableDisableSymbolsBtn(sender, new ctlXMLEditEventArgs(args.idName));
protected void ctlXMLEdit2_TextChanged(object sender, EventArgs e)
{
if (CurrentTextBox != null)
@@ -1378,10 +1360,6 @@ namespace ROEditor
this.tbar = new System.Windows.Forms.ToolBar();
this.imageListToolBar = new System.Windows.Forms.ImageList(this.components);
this.lblDuplicateRO = new System.Windows.Forms.Label();
this.galleryContainerSymbolsCM = new DevComponents.DotNetBar.GalleryContainer();
this.galleryContainerSymbolsCM3 = new DevComponents.DotNetBar.GalleryContainer();
this.galleryContainerSymbolsGrid = new DevComponents.DotNetBar.GalleryContainer();
this.galleryContainerSymbolsCM4 = new DevComponents.DotNetBar.GalleryContainer();
this.ribbonControl1.SuspendLayout();
this.ribbonPanel1.SuspendLayout();
this.panel1.SuspendLayout();
@@ -1835,84 +1813,11 @@ namespace ROEditor
this.lblDuplicateRO.Text = "Working With Duplicate RO";
this.lblDuplicateRO.Visible = false;
//
// galleryContainerSymbolsCM
//
//
//
//
this.galleryContainerSymbolsCM.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
this.galleryContainerSymbolsCM.DefaultSize = new System.Drawing.Size(156, 95);
this.galleryContainerSymbolsCM.EnableGalleryPopup = false;
this.galleryContainerSymbolsCM.GlobalName = "SymbolGallery";
this.galleryContainerSymbolsCM.MinimumSize = new System.Drawing.Size(150, 95);
this.galleryContainerSymbolsCM.Name = "galleryContainerSymbolsCM";
this.galleryContainerSymbolsCM.Text = "galleryContainer1";
//
//
//
this.galleryContainerSymbolsCM.TitleMouseOverStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
//
//
//
this.galleryContainerSymbolsCM.TitleStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
//
// galleryContainerSymbolsCM3
//
//
//
//
this.galleryContainerSymbolsCM3.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
this.galleryContainerSymbolsCM3.DefaultSize = new System.Drawing.Size(156, 95);
this.galleryContainerSymbolsCM3.EnableGalleryPopup = false;
this.galleryContainerSymbolsCM3.MinimumSize = new System.Drawing.Size(150, 95);
this.galleryContainerSymbolsCM3.Name = "galleryContainerSymbolsCM3";
this.galleryContainerSymbolsCM3.Text = "galleryContainer1";
//
//
//
this.galleryContainerSymbolsCM3.TitleMouseOverStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
//
//
//
this.galleryContainerSymbolsCM3.TitleStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
//
// galleryContainerSymbolsGrid
//
//
//
//
this.galleryContainerSymbolsGrid.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
this.galleryContainerSymbolsGrid.DefaultSize = new System.Drawing.Size(156, 95);
this.galleryContainerSymbolsGrid.EnableGalleryPopup = false;
this.galleryContainerSymbolsGrid.GlobalName = "SymbolGallery";
this.galleryContainerSymbolsGrid.MinimumSize = new System.Drawing.Size(150, 95);
this.galleryContainerSymbolsGrid.Name = "galleryContainerSymbolsGrid";
this.galleryContainerSymbolsGrid.Text = "galleryContainer1";
//
//
//
this.galleryContainerSymbolsGrid.TitleMouseOverStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
//
//
//
this.galleryContainerSymbolsGrid.TitleStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
//
// galleryContainerSymbolsCM4
//
//
//
//
this.galleryContainerSymbolsCM4.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
this.galleryContainerSymbolsCM4.MinimumSize = new System.Drawing.Size(58, 58);
this.galleryContainerSymbolsCM4.Name = "galleryContainerSymbolsCM4";
//
//
//
this.galleryContainerSymbolsCM4.TitleMouseOverStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
//
//
//
this.galleryContainerSymbolsCM4.TitleStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
//
// Form1
//
@@ -1947,11 +1852,7 @@ namespace ROEditor
private DevComponents.DotNetBar.ButtonItem rbtnZoom;
private DevComponents.DotNetBar.ButtonItem rbtnSymbols;
private DevComponents.DotNetBar.ButtonItem rbtnSave;
private DevComponents.DotNetBar.GalleryContainer galleryContainerSymbolsCM;
private DevComponents.DotNetBar.GalleryContainer galleryContainerSymbols;
private DevComponents.DotNetBar.GalleryContainer galleryContainerSymbolsCM3;
private DevComponents.DotNetBar.GalleryContainer galleryContainerSymbolsGrid;
private DevComponents.DotNetBar.GalleryContainer galleryContainerSymbolsCM4;
private DevComponents.DotNetBar.GalleryContainer galSymbols;
@@ -3312,7 +3213,6 @@ namespace ROEditor
DevComponents.DotNetBar.ButtonItem btn = new DevComponents.DotNetBar.ButtonItem();
btn.Image = symCharBtmp;
//btnCM.Text = string.Format("{0}", SymbolNode.SelectSingleNode("unicode").InnerText);
btn.Text = string.Format("{0}", ROSymbol.Key);
// to name button use unicode rather than desc, desc may have spaces or odd chars
@@ -3323,7 +3223,6 @@ namespace ROEditor
btn.FontBold = true;
btn.Click += new System.EventHandler(rbtnSymbols_Click);
galleryContainerSymbols.SubItems.Add(btn);
////galleryContainerSymbols
}
}
@@ -3453,7 +3352,6 @@ namespace ROEditor
// later on, we could add logic to use either FreeMono or Arial Unicode MS based on the format being used
// but for now, we are going to use FreeMono to create the symbol list
Font objFont = new Font("FreeMono", 18, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
//Font objFont = new Font("Arial Unicode MS", 18, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
// Create a graphics object to measure the text's width and height.
Graphics objGraphics = Graphics.FromImage(objBmpImage);
@@ -3473,24 +3371,11 @@ namespace ROEditor
objGraphics.SmoothingMode = SmoothingMode.AntiAlias;
objGraphics.TextContrast = 0;
objGraphics.TextRenderingHint = TextRenderingHint.AntiAlias;
//objGraphics.DrawString(txt, objFont, new SolidBrush(Color.FromArgb(102, 102, 102)), 0, 0);
objGraphics.DrawString(txt, objFont, new SolidBrush(Color.Black), 0, 0);
objGraphics.Flush();
return (objBmpImage);
}
private void btnSym_Click(object sender, EventArgs e)
{
DevComponents.DotNetBar.ButtonItem b = (DevComponents.DotNetBar.ButtonItem)sender;
//if (cbxTextSearchAnnotation.Focused)
//{
// cbxTextSearchAnnotation.SelectedText = (string)b.Text;
//}
//else if (cbxTextSearchText.Focused)
//{
// cbxTextSearchText.SelectedText = (string)b.Text;
//}
}
// This class is used to sort by the selected list view column
public class MyListViewComparer : IComparer
{

View File

@@ -128,14 +128,6 @@
<Reference Include="System.Xml">
<Name>System.XML</Name>
</Reference>
<Reference Include="VEPROMS.CSLA.Library, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\VEPROMS.CSLA.Library\bin\Debug\VEPROMS.CSLA.Library.dll</HintPath>
</Reference>
<Reference Include="Volian.Base.Library, Version=1.0.0.0, Culture=neutral, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\Volian.Base.Library\bin\Debug\Volian.Base.Library.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="AboutROEditor.cs">

View File

@@ -101,7 +101,6 @@ using System.Runtime.InteropServices;
using VlnStatus;
using System.Collections.Specialized;
using ROFST_FILE;
using Volian.Base.Library;
//using VlnProfiler; //don't forget to add VlnProfiler to the reference list

View File

@@ -42,8 +42,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CmpRpt", "..\CmpRpt\CmpRpt.
{3A4A3543-2D44-11D6-8452-00A0CC271352} = {3A4A3543-2D44-11D6-8452-00A0CC271352}
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D9093FAB-448E-47C7-961B-92B18D85CAF7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU

View File

@@ -2186,7 +2186,7 @@ namespace RODBInterface
parent.SetAttribute("ChildLoaded", "True");
}
string xmlstr = GenerateXmlString(ro, false);
string tmp2 = Regex.Replace(xmlstr, @"\\u([0-9]{1,4})\?", m => Convert.ToChar(int.Parse(m.Groups[1].Value)).ToString()); // RO Editor add symbols C2022 - 003
string wraccid = null;
if (ro.HasAttribute("AccPageID"))
{

View File

@@ -111,9 +111,6 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="ctlXMLEditLib">
<HintPath>..\..\..\VEPROMS User Interface\bin\Debug\ctlXMLEditLib.dll</HintPath>
</Reference>
<Reference Include="System">
<Name>System</Name>
</Reference>

View File

@@ -202,7 +202,6 @@ using RODBInterface;
using Org.Mentalis.Files;
using System.Windows;
using System.Text.RegularExpressions;
using Volian.Base.Library;
using System.Linq;
@@ -336,8 +335,6 @@ namespace ctlXMLEditLib
set
{
_TextBoxFocus = value;
// C2015-017 hide the label indicating user is working with a duplicate of an exiting RO
//lblDuplicateRO.Visible = value;
}
}
public ctlXMLEdit(VlnXmlElement myelem, XmlSchema myschema, ArrayList reqfields, ArrayList fldsWithApplic, string [] pckids)
@@ -509,7 +506,6 @@ namespace ctlXMLEditLib
{
hwnd.Text = Regex.Replace(nd.InnerText, @"\\u([0-9]{1,4})\?", m => Convert.ToChar(int.Parse(m.Groups[1].Value)).ToString()); // set the field's text from XML
//hwnd.Text = nd.InnerText; // set the field's text from XML
Size size = hwnd.Size;
// check if this window has a button name as part of its tag. If
@@ -717,11 +713,7 @@ namespace ctlXMLEditLib
{
if (chr > 166)
{
//Str = @"\u" + ((int)chr).ToString("X4");
//Str = @"\u" + ((int)chr); //.ToString("X4");
Str = $"\\u{(int)chr}?";
Str = $"\\u{(int)chr}?";
result1 = result1 + Str;
}
else
@@ -850,124 +842,6 @@ namespace ctlXMLEditLib
return (false);
}
// RO Editor add symbols C2022 - 003
private static Regex sreg1 = new Regex(@"\\par\r\n(?!\\)");
private static Regex sreg2 = new Regex(@"[\r\n]", RegexOptions.Singleline); // Strip Carriage Returns and Newlines
private static Regex sreg3 = new Regex(@"^\{(.*)\}$", RegexOptions.Singleline); // Strip Opening and Closing Braces
private static Regex sreg4 = new Regex(@"\{[^{]*?\}", RegexOptions.Singleline); // Strip Clauses - remove anything from curly braces
private static Regex sreg5 = new Regex(@"\{[^{]*?\}", RegexOptions.Singleline); // Strip Clauses - remove anything from curly braces
private static Regex sreg6 = new Regex(@"(\\[^' \\?\r\n\t]+)(?=\\)"); // add space after token if followed by token
private static Regex sreg7 = new Regex(@"(\\[^ \\?\r\n\t]+ )"); // take backslash xyz and evaluates them
private static Regex sreg8 = new Regex(@"(\\[^ \\?\r\n\t]+) (?=\\)"); // remove space between tokens
private static Regex sreg9 = new Regex(@"(\\[^ \\?\r\n\t]+) (?=\r\n)"); // remove space before /r/n
public static string StaticStripRtfCommands(string rtf, bool fromTable)
{
// 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(@"\}", @" (!]");
// For hardspaces, the windows richtextbox does some 'quirky' things:
// A unicode representation of \u160? is sent INTO the rtb. Coming out,
// that \u160? was translated to a \~ (by the underlying windows rtb).
// Note that if the \~ is sent to the rtb, it is treated as a regular space,
// i.e. no longer a hardspace, and actually is converted to a regular space.
// SO, on the way out, convert any \~ to \u160?
retval = RTFConvertedSymbolsToUnicode(retval);
// 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 = sreg1.Replace(retval, "\\par ");
retval = retval.Replace("\\v0\r\n", "\\v0 "); // Replace Carriage Return and Newline after comment
retval = sreg2.Replace(retval, ""); // Strip Carriage Returns and Newlines
retval = sreg3.Replace(retval, "$1"); // Strip Opening and Closing Braces
retval = sreg4.Replace(retval, ""); // Strip Clauses - remove anything from curly braces
retval = sreg5.Replace(retval, ""); // Strip Clauses - remove anything from curly braces
retval = sreg6.Replace(retval, "$1 "); // add space after token if followed by token
retval = sreg7.Replace(retval, new MatchEvaluator(StaticReplaceRTFClause)); // take backslash xyz and evaluates them
retval = sreg8.Replace(retval, "$1"); // remove space between tokens
retval = sreg9.Replace(retval, "$1"); // remove space before /r/n
// remove \r\n at end of string if the string has 2 or more characters
if (retval.Length > 1 && retval.Substring(retval.Length - 2, 2) == "\r\n") retval = retval.Remove(retval.Length - 2, 2);
if (retval.Length == 0) return "";
if (retval.Length > 1 && retval.Substring(retval.Length - 2, 2) == @"\v") retval = retval.Remove(retval.Length - 2, 2);
retval = retval.Replace(@" (![", @"\{");
retval = retval.Replace(@" (!]", @"\}");
retval = retval.TrimEnd(' ');
// the indent character was translated in the richtextbox, change it back:
if (retval.IndexOf(@"\'05") > -1) retval = retval.Replace(@"\'05", "\x05");
return retval;
}
// RO Editor add symbols C2022 - 003
public static string RTFConvertedSymbolsToUnicode(string str)
{
string rtnStr = str;
// convert \~ to a hard spece. RTF is automatically converting \u160? to \~ but will then convert
// the \~ to a regular space!
rtnStr = rtnStr.Replace(@"\~", @"\u160?");
rtnStr = rtnStr.Replace(@"\'a0", @"\u160?");
// convert \'99 to \u8482? this is for the trade mark symbol. RTF is automatically
// converting the unicode \u8482? to \'99, but once this is done, PROMS StepRTB (edit windows) does not show it
rtnStr = rtnStr.Replace(@"\'99", @"\u8482?");
// convert \'ae to \u174? this is for the registered symbol. RTF converts the unicode character to \'ae
rtnStr = rtnStr.Replace(@"\'ae", @"\u174?");
// convert \'a9 to \u169? this is for the copyright symbol. RTF converts the unicode character to \'a9
rtnStr = rtnStr.Replace(@"\'a9", @"\u169?");
return rtnStr;
}
public static string StaticReplaceRTFClause(Match m)
{
try
{
string token = m.Groups[1].Value;
switch (token[1])
{
case '_': // B2020-100 New Non-Breaking Hyphen
return token.Trim();
case '\\':
return token;
case '\'': // Special Character
return token;
case '{': // look for escape for curly braces:
return token;
case '}':
return token;
case 'v': // save link hidden info
if (token == "\\viewkind4 ") break;
if (Regex.IsMatch(token, @"^\\v0? ?$"))
return token; // comment part of link
// If possible show what procedure was being processed.
break;
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
// C2020-001: only keep the font size rtf if in a table.
//if (_fromTable && Regex.IsMatch(token, @"^\\fs[-0-9]+ ?$")) return token; // font size
break;
case 'p':
if (Regex.IsMatch(token, @"^\\par ?$")) return "\r\n";
break;
}
}
catch (Exception ex)
{
Console.WriteLine("StaticReplaceRTFClause {0} - {1}", ex.GetType().Name, ex.Message);
}
return "";//Strip All
}
#region Component Designer generated code
/// <summary>
@@ -1072,8 +946,7 @@ namespace ctlXMLEditLib
Size size = GraphicsHttextbox.Size;
mytextbox.LostFocus += new System.EventHandler(this.GraphicsHt_lostfocus);
//mytextbox.
}
if (getannot.IndexOf("Character")>=0)
{
@@ -2170,14 +2043,6 @@ namespace ctlXMLEditLib
richTextBox.SelectedRtf = RtfPrefixForSymbols + sym + @"}";
richTextBox.SelectedRtf = @"{\rtf1\ansi\ansicpg1252\deff0\deflang1033\uc1 }";
richTextBox.Select(position, 0);
//richTextBox.Select(position, 1); //left here for reference
//richTextBox.Select(position + 1, 0);
//TextPointer caretPos = rtb.CaretPosition;
//if (symbcode < 256)
// AddText(((char)symbcode).ToString());
//else
// AddSymbol(sym); // Adds font commands around symbol, needed for higher codes
}
}

View File

@@ -126,10 +126,6 @@
<Reference Include="System.Xml">
<Name>System.XML</Name>
</Reference>
<Reference Include="Volian.Base.Library, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Volian.Base.Library\bin\Debug\Volian.Base.Library.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs">

View File

@@ -13,7 +13,6 @@ using System.Windows.Forms;
using VEPROMS.CSLA.Library;
using Volian.Base.Library;
using XYPlots;
using static System.Net.Mime.MediaTypeNames;
namespace Volian.Controls.Library
{

View File

@@ -724,58 +724,6 @@ namespace Volian.Controls.Library
}
}
public DevComponents.DotNetBar.GalleryContainer BuildSymbolGalleryForRO()
{
// sl, galleryContainerSymbolsCM, galleryContainerSymbolsCM3, galleryContainerSymbolsGrid, galleryContainerSymbolsCM4
DevComponents.DotNetBar.GalleryContainer gc1 = galleryContainerSymbolsCM;
DevComponents.DotNetBar.GalleryContainer gc2 = galleryContainerSymbolsCM3;
DevComponents.DotNetBar.GalleryContainer gc3 = galleryContainerSymbolsGrid;
DevComponents.DotNetBar.GalleryContainer gc4 = galleryContainerSymbolsCM4;
FormatInfo fmt = FormatInfo.Get(1);
SymbolList sl = fmt.PlantFormat.FormatData.SymbolList;
if (sl == null || sl.Count <= 0)
{
FlexibleMessageBox.Show("No symbols are available, check with administrator");
//return DevComponents.DotNetBar.GalleryContainer;
}
foreach (Symbol sym in sl)
{
// get an image of the symbol character
// found the we cannot change the font being used for the button text
Bitmap symCharBtmp = createTextBitmap((char)sym.Unicode);
DevComponents.DotNetBar.ButtonItem btn = new DevComponents.DotNetBar.ButtonItem();
btn.Image = symCharBtmp;
//btn.Text = string.Format("{0}", (char)sym.Unicode);
// to name button use unicode rather than desc, desc may have spaces or odd chars
btn.Name = "btn" + sym.Unicode.ToString();
btn.Tooltip = sym.Desc;
btn.Tag = string.Format(@"{0}", sym.Unicode);
//btn.FontBold = true;
btn.Click += new System.EventHandler(btnSym_Click);
galleryContainerSymbols.SubItems.Add(btn);
DevComponents.DotNetBar.ButtonItem btnCM1 = GetCMButton(sym);
btnCM1.Image = symCharBtmp;
btnCM1.Click += new System.EventHandler(btnSym_Click);
gc1.SubItems.Add(btnCM1);
DevComponents.DotNetBar.ButtonItem btnCM2 = GetCMButton(sym);
btnCM2.Image = symCharBtmp;
btnCM2.Click += new System.EventHandler(btnSym_Click);
gc2.SubItems.Add(btnCM2);
DevComponents.DotNetBar.ButtonItem btnCM3 = GetCMButton(sym);
btnCM3.Image = symCharBtmp;
btnCM3.Click += new System.EventHandler(btnSym_Click);
gc3.SubItems.Add(btnCM3);
DevComponents.DotNetBar.ButtonItem btnCM4 = GetCMButton(sym);
btnCM4.Image = symCharBtmp;
btnCM4.Click += new System.EventHandler(btnSym_Click);
gc4.SubItems.Add(btnCM4);
}
return galleryContainerSymbols;
}
private void SetBtnInsSupInfoVisible()
{
if (MyItemInfo == null) return;