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

Open
plarsen wants to merge 8 commits from C2022-003-Change-Textboxes-to-RTF-3 into Development
9 changed files with 151 additions and 202 deletions
Showing only changes of commit d4ecf28147 - Show all commits

View File

@@ -96,7 +96,7 @@ 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 C2025 - 003
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;
@@ -218,7 +218,7 @@ 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 C2025 - 003
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();

View File

@@ -302,7 +302,8 @@ using Org.Mentalis.Files;
using System.Runtime.InteropServices;
using System.Linq;
using System.Collections.Generic;
using Volian.Controls.Library;
//using Volian.Controls.Library;
Review

remove commented out code

remove commented out code
Review

Removed

Removed
using Volian.Base.Library;
using VEPROMS.CSLA.Library;
Review

Not seeing where this is needed - should this be here?

can't see needing CSLA as a dependency.

Not seeing where this is needed - should this be here? can't see needing CSLA as a dependency.
Review

Removed

Removed
using System.Xml;
using System.Drawing.Text;
@@ -310,11 +311,9 @@ using System.Drawing.Drawing2D;
using System.Text.RegularExpressions;
//using IniFileIO;
namespace ROEditor
{
/// <summary>
/// <summary>
Review

Not critical -- but just a side suggestion to make things easier for future possible changes ---- I would suggest reviewing this file and try to fix some of the spacing issues --- there are a lot of items showing as changes that are not actual changes (i.e. removed blank lines or added / removed spaces) -- this makes it difficult to tell what was / wasn't changed and more likely to miss something / make a mistake. It also means that all these items will show up in history as being changed by this project. This could make diagnosing future issues more difficult (i.e. something that may have always been a certain way may appear it was changed with this project.)

Not critical -- but just a side suggestion to make things easier for future possible changes ---- I would suggest reviewing this file and try to fix some of the spacing issues --- there are a lot of items showing as changes that are not actual changes (i.e. removed blank lines or added / removed spaces) -- this makes it difficult to tell what was / wasn't changed and more likely to miss something / make a mistake. It also means that all these items will show up in history as being changed by this project. This could make diagnosing future issues more difficult (i.e. something that may have always been a certain way may appear it was changed with this project.)
Review

OK I will remove added blank lines if I have time.

OK I will remove added blank lines if I have time.
/// Summary description for Form1.
/// </summary>
///
@@ -361,7 +360,7 @@ namespace ROEditor
private TreeNode LastSelectedNode;
private RichTextBox _CurrentTextBox; // currently selected TextBox field
public static string[] PCChildren; //C2021-026 list of Parent/Child Children
private StepTabRibbon _MyStepTabRibbon;
//private StepTabRibbon _MyStepTabRibbon;
public RichTextBox CurrentTextBox
{
@@ -369,6 +368,19 @@ namespace ROEditor
set { _CurrentTextBox = value; }
}
public static string _RO_IDEN;
public static string RO_IDEN
{
get
{
return _RO_IDEN;
}
set
{
_RO_IDEN = value;
}
}
public List<TreeNode> ROsSelectedforMultiMove { get; set; } //to allow multiple RO nodes to be selected
public bool ROCutWasSelected { get; set; } = false;
@@ -380,7 +392,6 @@ namespace ROEditor
private System.Windows.Forms.ListView roListView;
private System.Windows.Forms.ToolBar tbar;
//this.ribbonControl1 = new DevComponents.DotNetBar.RibbonControl();
private bool _duplicate_active;
private bool duplicate_active
{
@@ -409,10 +420,10 @@ namespace ROEditor
// Required for Windows Form Designer support
//
InitializeComponent();
getSymbols();
// B2019-082 set the date format on the VEPROMS.exe thread to U.S. for i/o of a date string
// this is to correct an issue for a UAE customer who could not open some procedures due to the desktop date setting using the "DD/MM/YYYY" instead of the "MM/DD/YYYY" format
// NOTE: not doing the "Using System.Threading;" statement at beginning of file because it conflicts with the declaration of the "Timer" variable
getSymbols(); // RO Editor add symbols C2022 - 003
// B2019-082 set the date format on the VEPROMS.exe thread to U.S. for i/o of a date string
// this is to correct an issue for a UAE customer who could not open some procedures due to the desktop date setting using the "DD/MM/YYYY" instead of the "MM/DD/YYYY" format
// NOTE: not doing the "Using System.Threading;" statement at beginning of file because it conflicts with the declaration of the "Timer" variable
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
// The data path the was passed in.
@@ -875,7 +886,7 @@ namespace ROEditor
// Should the save option be available?
// Just reflect the Save button state.
roTreeView.ContextMenu.MenuItems[6].Enabled = rbtnSave.Enabled; // RO Editor add symbols C2025 - 003
roTreeView.ContextMenu.MenuItems[6].Enabled = rbtnSave.Enabled; // RO Editor add symbols C2022 - 003
menuROSave.Enabled = rbtnSave.Enabled;
// Should the properties menu item be available?
@@ -954,7 +965,7 @@ namespace ROEditor
this.panel2.Controls.Remove(ctlXMLEdit2);
this.panel2.Visible = false;
rbtnSave.Enabled = false; // RO Editor add symbols C2025 - 003
rbtnSave.Enabled = false; // RO Editor add symbols C2022 - 003
menuROSave.Enabled = rbtnSave.Enabled;
rbtnRestore.Enabled = false;
rbtnSaveAs.Enabled = false;
@@ -993,6 +1004,7 @@ namespace ROEditor
this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
ctlXMLEdit2.TabIndex = 4;
ctlXMLEdit2.Tag = "";
/*
* Spin through all of the controls and assign an event handler
* for changed text so that when the user changes any of the RO Text,
@@ -1015,11 +1027,13 @@ namespace ROEditor
else
{
TmpInfo.TextChanged += new EventHandler(ctlXMLEdit2_TextChanged);
TmpInfo.Click += new EventHandler(ctlXMLEdit2_ClickControl);
TmpInfo.Click += new EventHandler(ctlXMLEdit2_ClickControl);
}
}
ctlXMLEdit2.EnableDisableSymbolsBtn += new ctlXMLEditLib.ctlXMLEdit.ctlXMLEditEvent(EnableDisableSymbolsBtn);
RO_IDEN = curelem.GetAccPageIDTemplate();
this.panel2.Controls.Add(ctlXMLEdit2);
rbtnCancel.Enabled = true; // RO Editor add symbols C2025 - 003
rbtnCancel.Enabled = true; // RO Editor add symbols C2022 - 003
rbtnSymbols.Enabled = true;
}
// C2021-026 Get a list of fields that are P/C enabled
@@ -1154,6 +1168,7 @@ namespace ROEditor
this.menuEditCopy.Enabled = true;
this.menuEditCut.Enabled = true;
}
object dataobj = System.Windows.Forms.Clipboard.GetDataObject();
if (dataobj != null)
this.menuEditPaste.Enabled = true;
@@ -1172,6 +1187,32 @@ namespace ROEditor
menuROSave.Enabled = rbtnSave.Enabled;
}
public void RTBSymbolsOnOff(string nm)
Review

It looks like this function isn't called by anything - we should remove code that isn't called.

It looks like this function isn't called by anything - we should remove code that isn't called.
Review

I removed function

I removed function
{
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)
{
if (args.DisplaySymBolBtn == false)
{
rbtnSymbols.Enabled = false;
}
else
{
rbtnSymbols.Enabled = true;
}
}
//EnableDisableSymbolsBtn(sender, new ctlXMLEditEventArgs(args.idName));
Review

Remove commented out code,

Remove commented out code,
Review

Removed commented out line.

Removed commented out line.
protected void ctlXMLEdit2_TextChanged(object sender, EventArgs e)
{
@@ -1293,8 +1334,8 @@ namespace ROEditor
this.imageListRoTree = new System.Windows.Forms.ImageList(this.components);
this.splitter1 = new System.Windows.Forms.Splitter();
this.ribbonControl1 = new DevComponents.DotNetBar.RibbonControl();
this.ribbonPanel1 = new DevComponents.DotNetBar.RibbonPanel(); // RO Editor add symbols C2025 - 003
this.ribbonBar1 = new DevComponents.DotNetBar.RibbonBar(); // RO Editor add symbols C2025 - 003
this.ribbonPanel1 = new DevComponents.DotNetBar.RibbonPanel(); // RO Editor add symbols C2022 - 003
this.ribbonBar1 = new DevComponents.DotNetBar.RibbonBar(); // RO Editor add symbols C2022 - 003
this.rbtnSave = new DevComponents.DotNetBar.ButtonItem();
this.rbtnCancel = new DevComponents.DotNetBar.ButtonItem();
this.rbtnRestore = new DevComponents.DotNetBar.ButtonItem();
@@ -1367,7 +1408,7 @@ namespace ROEditor
//
//
//
this.ribbonControl1.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square; // RO Editor add symbols C2025 - 003
this.ribbonControl1.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square; // RO Editor add symbols C2022 - 003
this.ribbonControl1.CaptionVisible = true;
this.ribbonControl1.Controls.Add(this.ribbonPanel1);
this.ribbonControl1.Dock = System.Windows.Forms.DockStyle.Top;
@@ -1407,7 +1448,7 @@ namespace ROEditor
//
// ribbonPanel1
//
this.ribbonPanel1.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; // RO Editor add symbols C2025 - 003
this.ribbonPanel1.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; // RO Editor add symbols C2022 - 003
this.ribbonPanel1.Controls.Add(this.ribbonBar1);
this.ribbonPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.ribbonPanel1.Location = new System.Drawing.Point(0, 0);
@@ -1927,104 +1968,7 @@ namespace ROEditor
}
//private void BuildSymbolGallery(SymbolList sl, DevComponents.DotNetBar.GalleryContainer gc1, DevComponents.DotNetBar.GalleryContainer gc2, DevComponents.DotNetBar.GalleryContainer gc3, DevComponents.DotNetBar.GalleryContainer gc4)
//{
// 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);
// }
//}
//private void btnSym_Click(object sender, EventArgs e)
//{
// DevComponents.DotNetBar.ButtonItem b = (DevComponents.DotNetBar.ButtonItem)sender;
// StartGridEditing(SelectionOption.Start); // If in a FlexGrid, start the editor for a cell
// _MyStepTabRibbon.MyStepRTB.InsertSymbol(Convert.ToInt32(b.Tag));
// //_MyStepTabRibbon.
//}
//private enum SelectionOption
//{
// Start,
// All,
// End
//}
//private void StartGridEditing(SelectionOption selOpt)
//{
// // Bug fix: B2012-203, B2012-204
// // Need to check if the selected table cell is in edit mode already.
// // if already in edit mode, we don't want to do the StartEditing code below, because it
// // will override the current cursor positioning and selection range.
// Control ctrl = FindActiveControl();
// if (ctrl == null) return; // B2018-008 If a null is returned, don't do anything
// if (ctrl is VlnFlexGrid)
// {
// // Selected table cell is not in edit mode. Go into edit mode and position acording
// // to the pass in selOpt.
// if (MyFlexGrid != null && MyFlexGrid.Editor == null)
// {
// MyFlexGrid.StartEditing();
// switch (selOpt)
// {
// case SelectionOption.Start:
// MyStepRTB.Select(0, 0);
// break;
// case SelectionOption.All:
// MyStepRTB.SelectAll();
// break;
// case SelectionOption.End:
// MyStepRTB.Select(MyStepRTB.TextLength, 0);
// break;
// default:
// MyStepRTB.Select(0, 0);
// break;
// }
// }
// }
//}
//private static DevComponents.DotNetBar.ButtonItem GetCMButton(Symbol sym)
//{
// DevComponents.DotNetBar.ButtonItem btnCM3 = new DevComponents.DotNetBar.ButtonItem();
// //btnCM3.Text = string.Format("{0}", (char)sym.Unicode);
// // to name button use unicode rather than desc, desc may have spaces or odd chars
// btnCM3.Name = "btnCM" + sym.Unicode.ToString();
// btnCM3.Tooltip = sym.Desc;
// btnCM3.Tag = string.Format(@"{0}", sym.Unicode);
// //btnCM3.FontBold = true;
// return btnCM3;
//}
//_MyStepTabRibbon.BuildSymbolGalleryForRO();
//part of CSM-C2024-027 / Part of 2024 PROMS Upgrades
//Paste Selected - will move individual ROs
@@ -2067,7 +2011,7 @@ namespace ROEditor
roTreeView_ClearAllMultiSelect();
rbtnRestore.Enabled = false; // RO Editor add symbols C2025 - 003
rbtnRestore.Enabled = false; // RO Editor add symbols C2022 - 003
rbtnSave.Enabled = false;
rbtnCancel.Enabled = true;
rbtnSaveAs.Enabled = false;
@@ -2925,29 +2869,6 @@ namespace ROEditor
}
/*
// Tool Bar Support
*/
private void tbar_OnClick(object obj, ToolBarButtonClickEventArgs tbbcea)
{
ToolBarButton tbb = tbbcea.Button;
// see which event should be called.
if (tbb.Text == "Cancel")
tbar_CancelClick();
else if (tbb.Text == "Save")
tbar_SaveClick();
else if (tbb.Text == "Save As")
tbar_SaveAsClick();
else if (tbb.Text == "Duplicate")
tbar_DuplicateClick();
else if (tbb.Text == "Restore")
tbar_RestoreClick();
else if (tbb.Text == "Zoom" || tbb.Text == "View Image")
ctlXMLEdit2.btnZoom_click(null, null);
}
private void tbar_RestoreClick()
{
ctlXMLEdit2.RestoreData();
@@ -3010,7 +2931,7 @@ namespace ROEditor
MessageBox.Show("The fields used for the \"Accessory Pages Access\" values must be unique. The fields used in these values can be found under \"Properties\" of an RO Group. Cannot save.", "Problem saving data");
return false;
}
myro.SetAttribute("AccPageID", myro.GetAccPageIDString(acctmpl));
myro.SetAttribute("AccPageID", myro.GetAccPageIDString(acctmpl));
}
}
else
@@ -3038,6 +2959,7 @@ namespace ROEditor
newt = new TreeNode(mnutitle, img, img);
newt.Tag = myro;
newt.Name = myro.GetAttribute("RecID");
newt.Text = Regex.Replace(newt.Text, @"\\u([0-9]{1,4})\?", m => Convert.ToChar(int.Parse(m.Groups[1].Value)).ToString()); // RO Editor add symbols C2022 - 003
TreeNewparent.Nodes.Add(newt);
}
}
@@ -3294,16 +3216,16 @@ namespace ROEditor
nd = curele.SelectSingleNode(nm);
if (nd == null) nd = curele.SelectSingleNode("*/" + nm);
if (nd == null)
nd = curele.GetCurrentOfMultiFields(curele, nm);
// if (nd==null)nd = curele.SelectSingleNode(nm+"a");
// if (nd==null)nd = curele.SelectSingleNode(nm+"b");
// if (nd==null)nd = curele.SelectSingleNode(nm+"c");
// if (nd==null)nd = curele.SelectSingleNode(nm+"d");
nd = curele.GetCurrentOfMultiFields(curele, nm); // RO Editor add symbols C2022 - 003
Review

Should these lines be removed?

if (nd==null) nd = curele.SelectSingleNode(nm+"a");
if (nd==null) nd = curele.SelectSingleNode(nm+"b");
if (nd==null) nd = curele.SelectSingleNode(nm+"c");
if (nd==null) nd = curele.SelectSingleNode(nm+"d");

Should these lines be removed? if (nd==null) nd = curele.SelectSingleNode(nm+"a"); if (nd==null) nd = curele.SelectSingleNode(nm+"b"); if (nd==null) nd = curele.SelectSingleNode(nm+"c"); if (nd==null) nd = curele.SelectSingleNode(nm+"d");
Review

These lines have been removed.

These lines have been removed.
string data;
if (nd == null)
data = " ";
else
{
data = nd.InnerText;
data = Regex.Replace(data, @"\\u([0-9]{1,4})\?", m => Convert.ToChar(int.Parse(m.Groups[1].Value)).ToString()); // RO Editor add symbols C2022 - 003
}
if (first == true)
{
item = new ListViewItem(data, ROIMAGE);
@@ -3380,12 +3302,7 @@ namespace ROEditor
roListView.Sort();
}
//private void roTreeView_AfterSelect_1(object sender, System.Windows.Forms.TreeViewEventArgs e)
//{
//}
public void getSymbols() // RO Editor add symbols C2025 - 003
public void getSymbols() // RO Editor add symbols C2022 - 003
{
Dictionary<int, string> ROSymbols = buildsymbols();
@@ -3410,7 +3327,7 @@ namespace ROEditor
}
}
private Dictionary<int, string> buildsymbols() // RO Editor add symbols C2025 - 003
private Dictionary<int, string> buildsymbols() // RO Editor add symbols C2022 - 003
{
Dictionary<int, string> symbols1 = new Dictionary<int, string>()
{
@@ -3613,7 +3530,7 @@ namespace ROEditor
}
private void rbtnSave_Click(object sender, EventArgs e) // RO Editor add symbols C2025 - 003
private void rbtnSave_Click(object sender, EventArgs e) // RO Editor add symbols C2022 - 003
{
tbar_SaveClick();
}
@@ -3644,7 +3561,7 @@ namespace ROEditor
ctlXMLEdit2.btnZoom_click(null, null);
}
private void rbtnSymbols_Click(object sender, EventArgs e) // RO Editor add symbols C2025 - 003
private void rbtnSymbols_Click(object sender, EventArgs e) // RO Editor add symbols C2022 - 003
{
DevComponents.DotNetBar.ButtonItem b = (DevComponents.DotNetBar.ButtonItem)sender;
ctlXMLEdit2.TextBoxFocus.InsertSymbol(Convert.ToInt32(b.Tag));

View File

@@ -136,10 +136,6 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\Volian.Base.Library\bin\Debug\Volian.Base.Library.dll</HintPath>
</Reference>
<Reference Include="Volian.Controls.Library, Version=1.0.9399.43177, Culture=neutral, processorArchitecture=AMD64">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\Volian.Controls.Library\bin\Debug\Volian.Controls.Library.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="AboutROEditor.cs">

View File

@@ -1910,7 +1910,7 @@ namespace RODBInterface
string Info = DBE.GetString(3);
//B2022-043 &pos; was missing the ;
Info = Info.Replace("&apos;", "\'"); // B2021-071: crash when getting/saving field names
Info = Regex.Replace(Info, @"\\u([0-9]{1,4})\?", m => Convert.ToChar(int.Parse(m.Groups[1].Value)).ToString()); // RO Editor add symbols C2025 - 003
Info = Regex.Replace(Info, @"\\u([0-9]{1,4})\?", m => Convert.ToChar(int.Parse(m.Groups[1].Value)).ToString()); // RO Editor add symbols C2022 - 003
node.SetAttribute("HasChild", "True");
@@ -1975,7 +1975,7 @@ namespace RODBInterface
elem.SetAttribute("RecID", RecID);
elem.SetAttribute("ParentID", node.GetAttribute("RecID"));
elem.SetAttribute("Table", node.GetAttribute("Table"));
AccPageID = Regex.Replace(AccPageID, @"\\u([0-9]{1,4})\?", m => Convert.ToChar(int.Parse(m.Groups[1].Value)).ToString()); // RO Editor add symbols C2025 - 003
AccPageID = Regex.Replace(AccPageID, @"\\u([0-9]{1,4})\?", m => Convert.ToChar(int.Parse(m.Groups[1].Value)).ToString()); // RO Editor add symbols C2022 - 003
elem.SetAttribute("AccPageID", AccPageID);
}
}
@@ -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 C2025 - 003
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
Review

Where is tmp2 used?

I am seeing this added but doing see a usage later in the file.

Running Regex's take up resources so should only be done if necessary.

Where is tmp2 used? I am seeing this added but doing see a usage later in the file. Running Regex's take up resources so should only be done if necessary.
Review

I removed the line. It might have been a left over from something I was trying.

I removed the line. It might have been a left over from something I was trying.
string wraccid = null;
if (ro.HasAttribute("AccPageID"))
{

View File

@@ -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 C2025 - 003
private System.Windows.Forms.RichTextBox tbZoom; // RO Editor add symbols C2022 - 003
/// <summary>
/// Required designer variable.
/// </summary>
@@ -88,7 +88,7 @@ namespace ctlXMLEditLib
/// </summary>
private void InitializeComponent()
{
this.tbZoom = new System.Windows.Forms.RichTextBox(); // RO Editor add symbols C2025 - 003
this.tbZoom = new System.Windows.Forms.RichTextBox(); // RO Editor add symbols C2022 - 003
this.btnSave = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.SuspendLayout();
@@ -99,7 +99,7 @@ namespace ctlXMLEditLib
this.tbZoom.Location = new System.Drawing.Point(24, 16);
this.tbZoom.Multiline = true;
this.tbZoom.Name = "tbZoom";
this.tbZoom.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Vertical; // RO Editor add symbols C2025 - 003
this.tbZoom.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Vertical; // RO Editor add symbols C2022 - 003
this.tbZoom.Size = new System.Drawing.Size(576, 392);
this.tbZoom.TabIndex = 0;
//

View File

@@ -204,7 +204,7 @@ using System.Windows;
using System.Text.RegularExpressions;
using Volian.Base.Library;
using System.Linq;
//using IniFileIO;
@@ -225,6 +225,7 @@ namespace ctlXMLEditLib
///
///
/// </summary>
public class ctlXMLEdit : System.Windows.Forms.UserControl
{
/// <summary>
@@ -269,6 +270,19 @@ namespace ctlXMLEditLib
private GroupBox pcGrpBox = null;
/** end C2021-026 **/
public string _RO_IDEN;
public string RO_IDEN
{
get
{
return _RO_IDEN;
}
set
{
_RO_IDEN = value;
}
}
// use this struct to define attributes for the text box fields, storing
// the pattern, radio button association, required field flag, etc.
struct TextBoxAttrTag
@@ -315,7 +329,7 @@ namespace ctlXMLEditLib
public string GetParentHTId { get { return parenthtid; } }
public void SetParentHTId(string id) { this.parenthtid = id; }
}
private RichTextBox _TextBoxFocus; // RO Editor add symbols C2025 - 003
private RichTextBox _TextBoxFocus; // RO Editor add symbols C2022 - 003
public RichTextBox TextBoxFocus
{
get { return _TextBoxFocus; }
@@ -329,6 +343,7 @@ namespace ctlXMLEditLib
public ctlXMLEdit(VlnXmlElement myelem, XmlSchema myschema, ArrayList reqfields, ArrayList fldsWithApplic, string [] pckids)
{
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();
FieldsWithApplic = fldsWithApplic;
PCChildren = pckids; //C2021-026 list of Parent/Child children
@@ -373,11 +388,12 @@ namespace ctlXMLEditLib
// Set required fields based on list. (can add message later).
SetRequiredFields(reqfields);
dosaveflag=true;
RO_IDEN = myelem.GetAccPageIDTemplate();
}
// 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 C2025 - 003
private void DoSet(RichTextBox hwnd, string msg) // RO Editor add symbols C2022 - 003
{
if (hwnd == null) return;
if (hwnd.Tag != null)
@@ -680,6 +696,7 @@ namespace ctlXMLEditLib
// true if success, false if fail.
// Note that the Parent and Child XML node variables below are not coding for Parent/Child Applicabily Fields
public bool SaveData()
{
if (mysavexml)
{
@@ -688,7 +705,7 @@ namespace ctlXMLEditLib
string imgdate;
//go thru the hash table to get textboxes. Find the ones that have text.
foreach (string str in myHT.Keys) // RO Editor add symbols C2025 - 003
foreach (string str in myHT.Keys) // RO Editor add symbols C2022 - 003
{
object o = myHT[str];
hwnd = (RichTextBox) o;
@@ -704,7 +721,7 @@ namespace ctlXMLEditLib
//Str = @"\u" + ((int)chr); //.ToString("X4");
Str = $"\\u{(int)chr}?";
result1 = result1 + Str;
}
else
@@ -714,22 +731,6 @@ namespace ctlXMLEditLib
}
var pattern = @"\\u([0-9]{1,4})\?"; // RO Editor add symbols C2025 - 003
var results = Regex.Matches(hwnd.Text, pattern);
string num1;
int num2;
foreach (Match result in results)
{
num1 = (result.Groups[1].Value);
string resultString = Regex.Match(num1, @"\d+").Value;
string resultString1 = string.Format("{0:x}", resultString);
num2 = int.Parse(resultString, System.Globalization.NumberStyles.HexNumber);
}
hwnd.Text = result1;
@@ -849,7 +850,7 @@ namespace ctlXMLEditLib
return (false);
}
// RO Editor add symbols C2025 - 003
// RO Editor add symbols C2022 - 003
Review

see notes below. It looks like these sreg variables are never used.

i.e. they are only called in StaticStripRtfCommands - which is never called.

we should avoid regexs that are never used as they take up resources.

see notes below. It looks like these sreg variables are never used. i.e. they are only called in StaticStripRtfCommands - which is never called. we should avoid regexs that are never used as they take up resources.
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
@@ -905,7 +906,7 @@ namespace ctlXMLEditLib
return retval;
}
// RO Editor add symbols C2025 - 003
// RO Editor add symbols C2022 - 003
public static string RTFConvertedSymbolsToUnicode(string str)
Review

Maybe I am missing something, but it looks like the only place this is called from is StaticStripRtfCommands - which is never called --- so this code will never be called / executed?

Maybe I am missing something, but it looks like the only place this is called from is StaticStripRtfCommands - which is never called --- so this code will never be called / executed?
{
string rtnStr = str;
@@ -1385,7 +1386,16 @@ namespace ctlXMLEditLib
{
}
public delegate void ctlXMLEditEvent(object sender, ctlXMLEditEventArgs args); // RO Editor add symbols C2022 - 003 for turning off symbols btn for RO ID field.
public event ctlXMLEditEvent EnableDisableSymbolsBtn;
private void OnEnableDisableSymbolsBtn(ctlXMLEditEventArgs args)
{
if (EnableDisableSymbolsBtn != null)
EnableDisableSymbolsBtn(this, args);
}
// when data in a text box has changed, flag it (except for when this
// happens during loading of original data). This flag will be used
// later to know whether to save data.
@@ -1619,7 +1629,20 @@ namespace ctlXMLEditLib
else
zoomtextbox = null;
TextBoxFocus = textbox;
TextBoxFocus = textbox;
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));
}
}
private void textbox_Validating(object sender, System.ComponentModel.CancelEventArgs e)
@@ -1653,10 +1676,7 @@ namespace ctlXMLEditLib
btnZoom_click(null, null);
}
}
public void btnSymbols_click(object sender, System.EventArgs e)
{
}
public void btnZoom_click(object sender, System.EventArgs e)
{
//TextBox tb = (TextBox) sender;
@@ -2084,7 +2104,7 @@ namespace ctlXMLEditLib
* and overload a couple of it's functions in order to use it.
* - called in CalculatePromsDate() above.
*/
public class ThisTimeZone : TimeZone
public class ThisTimeZone : TimeZone
{
private TimeZone curTZ;
public TimeSpan SpanTZ;
@@ -2125,7 +2145,22 @@ namespace ctlXMLEditLib
return curTZ.GetDaylightChanges(year);
}
}
public static class RichTextBoxExtensions // RO Editor add symbols C2025 - 003
public class ctlXMLEditEventArgs : EventArgs // RO Editor add symbols C2022 - 003 for turning off symbols btn for RO ID.
{
public ctlXMLEditEventArgs() {; }
public ctlXMLEditEventArgs(bool DisplaySymBolBtn)
{
_DisplaySymBolBtn = DisplaySymBolBtn;
}
private bool _DisplaySymBolBtn;
public bool DisplaySymBolBtn
{
get { return _DisplaySymBolBtn; }
set { _DisplaySymBolBtn = value; }
}
}
public static class RichTextBoxExtensions // RO Editor add symbols C2022 - 003
Review

A new class like this or extending an existing class should be in it's own cs file so it can be found easily. --- also, otherwise it may be difficult to tell when it will work or not.

A new class like this or extending an existing class should be in it's own cs file so it can be found easily. --- also, otherwise it may be difficult to tell when it will work or not.
{
public static void InsertSymbol(this RichTextBox richTextBox, int symbcode)
{
@@ -2134,8 +2169,9 @@ namespace ctlXMLEditLib
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, 1);
richTextBox.Select(position + 1, 0);
richTextBox.Select(position, 0);
//richTextBox.Select(position, 1); //left here for reference
Review

Remove commented out code

Remove commented out code
//richTextBox.Select(position + 1, 0);
//TextPointer caretPos = rtb.CaretPosition;
//if (symbcode < 256)

View File

@@ -2154,12 +2154,12 @@ namespace VEPROMS.CSLA.Library
if (string.IsNullOrEmpty(s2))
return s2;
var pattern = @"\\u([0-9]{1,4})\?"; // RO Editor add symbols C2025 - 003
var pattern = @"\\u([0-9]{1,4})\?"; // RO Editor add symbols C2022 - 003
if (Regex.IsMatch(s2, pattern))
s2 = s2.Replace(@"\u160?", "<HSP>"); // convert hard spaces bug fix: B2016-206
if (!Regex.IsMatch(s2, pattern)) // RO Editor add symbols C2025 - 003
if (!Regex.IsMatch(s2, pattern)) // RO Editor add symbols C2022 - 003
Review

Not if sure this makes sense --- will this ever get executed?

what if you have something that contains both special characters and a backslash in the text?

Not if sure this makes sense --- will this ever get executed? what if you have something that contains both special characters and a backslash in the text?
Review

It is needed. If a special letter (Unicode) comes through this code it will mess-up one way or another. Maybe it needs to be refined to handle the special char and a separate back slash.

It is needed. If a special letter (Unicode) comes through this code it will mess-up one way or another. Maybe it needs to be refined to handle the special char and a separate back slash.
Review

I would say that is the case --- if there are are matches on the backslash not followed by a "u" those need to be replaced.

Likely would have to get matches and then loop through those specific matches doing a replace on those,

I would say that is the case --- if there are are matches on the backslash not followed by a "u" those need to be replaced. Likely would have to get matches and then loop through those specific matches doing a replace on those,
{
s2 = s2.Replace(@"\", @"\u9586?"); // convert backslashes to a backslash symbol
}

View File

@@ -774,7 +774,7 @@ namespace Volian.Controls.Library
tmp = new TreeNode(roc.title);
tmp.Tag = roc;
if (tmp.Text.IndexOf("\\u") > -1) // RO Editor add symbols C2025 - 003
if (tmp.Text.IndexOf("\\u") > -1) // RO Editor add symbols C2022 - 003
{
tmp.Text = Regex.Replace(tmp.Text, @"\\u([0-9]{1,4})\?", m => Convert.ToChar(int.Parse(m.Groups[1].Value)).ToString());
}

View File

@@ -1401,7 +1401,7 @@ namespace Volian.Controls.Library
int position = SelectionStart;
SelectionLength = 0;
var pattern = @"\\u([0-9]{1,4})\?"; // RO Editor add symbols C2025 - 003
var pattern = @"\\u([0-9]{1,4})\?"; // RO Editor add symbols C2022 - 003
foreach (Match match in Regex.Matches(linkValue, pattern, RegexOptions.IgnoreCase))
{
linkValue = linkValue.Replace(match.Value, "\\f1 " + match.Value + " \\f0");