From 4109bb7bfe04cc34d57a538bda5f0f44bb457b9e Mon Sep 17 00:00:00 2001 From: Rich Date: Fri, 9 Oct 2015 18:43:14 +0000 Subject: [PATCH] This is a limitation of the Microsoft RichTextBox. I discovered that the character \u1? appeared to function as a hardspace. This is only used when the text is displayed and not when it is edited, so, you need to move off the window to see the effect. --- PROMS/Volian.Controls.Library/StepRTB.cs | 26 +++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/PROMS/Volian.Controls.Library/StepRTB.cs b/PROMS/Volian.Controls.Library/StepRTB.cs index b65a00f5..0edaed0b 100644 --- a/PROMS/Volian.Controls.Library/StepRTB.cs +++ b/PROMS/Volian.Controls.Library/StepRTB.cs @@ -455,7 +455,7 @@ namespace Volian.Controls.Library if (!readOnlyStep) { StepConfig sc = new StepConfig(MyItemInfo.MyContent.Config); - if (sc.Step_BackgroundToSource != null || sc.Step_DeviationToSource != null) + if (IsDerived(sc)) readOnlyStep = true; } ReadOnly = readOnlyStep || VwMode == E_ViewMode.View || ActiveMode == false; @@ -521,11 +521,35 @@ namespace Volian.Controls.Library } } } + // This is to fix an issue with Hard Spaces. To Summarize: + // The Microsoft RichTextBox has a problem with hardspaces, that they don't work between numbers and lettters + // This is the majority of cases for PROMS including ROs (Sepoint Number and Units) and transtions (Step ###) + // As I investigated this further I found that if you pass a rtf unicode value for a hard space (\u160?) to + // the RichTextBox, the RichTextBox will return an ASCII representation (\'A0). If you pass an ASCII representation + // the RichTextBox will return a space. + // Alternatively, If you pass a unicode representation of zero (\u0?) it acts like a hard space and returns an ASCII + // representation (\'00). If you pass in the ASCII representation, it truncates the text. + // The following two lines replace hard spaces (ASCII) with the UNICODE represntation of Zero. + // Lastly, If you pass a unicode representation of one (\u1?) it acts like a hard space and returns an ASCII + // representation (\'01). If you pass in the ASCII representation, it keeps the ASCII representation. + // The following two lines replace hard spaces (ASCII) with the UNICODE represntation of Zero. + // Other characters which behave like hard spaces are 28-31 and 128-159. + if (!activeMode && Rtf.Contains(@"\'a0")) + Rtf = Rtf.Replace(@"\'a0", @"\u1?"); OrigRTF = Rtf; _InitializingRTB = false; AdjustSizeForContents(!ActiveMode); } + + private bool IsDerived(StepConfig sc) + { + foreach (EnhancedDocument ed in sc.MyEnhancedDocuments) + if (ed.Type == "Source") +// if (ed.Type == 0) //New Design + return true; + return false; + } private bool _ProcessKeystrokes = true; public bool ProcessKeystrokes {