From 9cc6174ad1da0855bc1704f3a86e5a7bc81790e9 Mon Sep 17 00:00:00 2001 From: Rich Date: Tue, 25 May 2010 16:12:51 +0000 Subject: [PATCH] Changed CheckOffs Made DisplayText more generic Added comments - Added parameter to DisplayText - Removed specific OutlineTable --- PROMS/Volian.Controls.Library/DisplayTags.cs | 16 ++-- PROMS/Volian.Controls.Library/DisplayText.cs | 83 +++++++++++++------- PROMS/Volian.Controls.Library/StepItem.cs | 7 +- PROMS/Volian.Controls.Library/StepRTB.cs | 19 +++-- 4 files changed, 76 insertions(+), 49 deletions(-) diff --git a/PROMS/Volian.Controls.Library/DisplayTags.cs b/PROMS/Volian.Controls.Library/DisplayTags.cs index 74a4e102..b0fb0b12 100644 --- a/PROMS/Volian.Controls.Library/DisplayTags.cs +++ b/PROMS/Volian.Controls.Library/DisplayTags.cs @@ -121,14 +121,14 @@ namespace Volian.Controls.Library cbCAS.Checked = sc.Step_CAS; } - if (!(fmtdata.ProcData.CheckOffData.CheckOffList == null) && !(fmtdata.ProcData.CheckOffData.CheckOffList.Count == 0)) - { - foreach (CheckOff co in fmtdata.ProcData.CheckOffData.CheckOffList) - { - cmbCheckoff.Items.Add(co.RightCheckOffPrompt); - } - if (sc.Step_CheckOffIndex != -1) cmbCheckoff.SelectedIndex = sc.Step_CheckOffIndex; - } + //if (!(fmtdata.ProcData.CheckOffData.CheckOffList == null) && !(fmtdata.ProcData.CheckOffData.CheckOffList.Count == 0)) + //{ + // foreach (CheckOff co in fmtdata.ProcData.CheckOffData.CheckOffList) + // { + // cmbCheckoff.Items.Add(co.RightCheckOffPrompt); + // } + // if (sc.Step_CheckOffIndex != -1) cmbCheckoff.SelectedIndex = sc.Step_CheckOffIndex; + //} // change bar setting depends on whether step has changed (dts) as compared to date/time off the // procedure that it's in. diff --git a/PROMS/Volian.Controls.Library/DisplayText.cs b/PROMS/Volian.Controls.Library/DisplayText.cs index d5022a6f..679c3794 100644 --- a/PROMS/Volian.Controls.Library/DisplayText.cs +++ b/PROMS/Volian.Controls.Library/DisplayText.cs @@ -109,22 +109,63 @@ namespace Volian.Controls.Library /// bool noEdit - flags whether to edit or not (used to set data in /// rtb as resolved replacewords for non-active rtb. /// E_FieldToEdit fieldToEdit - identifies the field to edit (number or text) + /// bool colorLinks - whether to add color to links /// - public DisplayText(ItemInfo itemInfo, E_EditPrintMode epMode, E_ViewMode vwMode, bool noEdit,E_FieldToEdit fieldToEdit) + public DisplayText(ItemInfo itemInfo, E_EditPrintMode epMode, E_ViewMode vwMode, bool noEdit,E_FieldToEdit fieldToEdit, bool colorLinks) { _FieldToEdit = fieldToEdit; _MyItemInfo = itemInfo; OriginalText = InfoText; TextFont = itemInfo.GetItemFont();//GetItemFont(); string text = InfoText; - + _MyFormat = itemInfo.ActiveFormat; + + bool tableShouldBeOutlined = (epMode == E_EditPrintMode.Print || vwMode == E_ViewMode.View || noEdit) && + (_FieldToEdit == E_FieldToEdit.StepText || _FieldToEdit == E_FieldToEdit.Text) && + (!itemInfo.IsSection && !itemInfo.IsProcedure) && (itemInfo.IsTable || itemInfo.IsFigure); + bool wordsShouldBeReplaced = epMode == E_EditPrintMode.Print || vwMode == E_ViewMode.View || noEdit; + bool numbersShouldBeFormated = (!_MyFormat.PlantFormat.FormatData.SectData.StepSectionData.FortranFormatNumbers && (epMode == E_EditPrintMode.Print || vwMode == E_ViewMode.View || noEdit)); + int typ = ((int)itemInfo.MyContent.Type) % 10000; + bool tableHasBorder = tableShouldBeOutlined ? itemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList[typ].Type.IndexOf(@"Borderless") < 0 : false; + + text = CreateRtf(colorLinks, text, tableShouldBeOutlined, wordsShouldBeReplaced, numbersShouldBeFormated, tableHasBorder); + StartText = text; + } + public DisplayText(string text, VE_Font vFont, bool colorLinks) + { + TextFont = vFont; + StartText = CreateRtf(colorLinks, text, false, false, false, false); + } + private string CreateRtf(bool colorLinks, string text, bool tableShouldBeOutlined, bool wordsShouldBeReplaced, bool numbersShouldBeFormated, bool tableHasBorder) + { + // add colors around links: + if (colorLinks) + { + text = Regex.Replace(text, @"( 0 && MyID > 2111) // Console.WriteLine("Setting MyParent: \r\n\tParent {0},{1} \r\n\tTopMostItem {2},{3} \r\n\tNext {4}, {5}", _MyParentStepItem.MyID, _MyParentStepItem // ,_MyParentStepItem.TopMostStepItem.MyID,_MyParentStepItem.TopMostStepItem @@ -1849,7 +1849,8 @@ namespace Volian.Controls.Library } foreach (string line in lines) { - string line2 = (addBorder ? "--" : "") + Regex.Replace(line, @"\\.*? ", ""); // Remove RTF Commands - Really should not be any + //string line2 = (addBorder ? "--" : "") + Regex.Replace(line, @"\\.*? ", ""); // Remove RTF Commands - Really should not be any + string line2 = Regex.Replace(line, @"\\.*? ", ""); // Remove RTF Commands - Really should not be any //line2 = line2.Replace(@"\u8209?", "-"); //line2 = line2.Replace("",""); diff --git a/PROMS/Volian.Controls.Library/StepRTB.cs b/PROMS/Volian.Controls.Library/StepRTB.cs index 958aa45c..1a2d921c 100644 --- a/PROMS/Volian.Controls.Library/StepRTB.cs +++ b/PROMS/Volian.Controls.Library/StepRTB.cs @@ -68,7 +68,6 @@ namespace Volian.Controls.Library } #endregion #region Properties and Variables - private static FontFamily _MyFontFamily = null; public static FontFamily MyFontFamily { @@ -196,7 +195,7 @@ namespace Volian.Controls.Library } _InitializingRTB = true; _SelectedRtfSB.Remove(0, _SelectedRtfSB.Length); - DisplayText vlntxt = new DisplayText(_MyItemInfo, EpMode, VwMode, !edit, FieldToEdit); + DisplayText vlntxt = new DisplayText(_MyItemInfo, EpMode, VwMode, !edit, FieldToEdit, true); //if (_origDisplayText != null && vlntxt.StartText == _origDisplayText.StartText) //{ // ReadOnly = !(EpMode == E_EditPrintMode.Edit && VwMode == E_ViewMode.Edit); @@ -243,9 +242,14 @@ namespace Volian.Controls.Library RemoveEventHandlers(); if ((!_MyItemInfo.IsSection && !_MyItemInfo.IsProcedure) && (_MyItemInfo.IsTable || _MyItemInfo.IsFigure)) { - int typ = ((int)_MyItemInfo.MyContent.Type) % 10000; - OutlineTable(_MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList[typ].Type.IndexOf(@"Borderless")<0); - FindAllLinks(); + int newwidth = (int)_MyStepItem.TableWidth(Font, Text, true); + if (_MyStepItem.ItemWidth != newwidth) + { + _MyStepItem.ItemWidth = newwidth; + } + // int typ = ((int)_MyItemInfo.MyContent.Type) % 10000; + // OutlineTable(_MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList[typ].Type.IndexOf(@"Borderless")<0); + // FindAllLinks(); } SelectAll(); if (SelectionHangingIndent !=0) SelectionHangingIndent = 0; @@ -396,7 +400,7 @@ namespace Volian.Controls.Library this.KeyUp += new KeyEventHandler(StepRTB_KeyUp); this.TextChanged += new EventHandler(StepRTB_TextChanged); this.MouseUp += new MouseEventHandler(StepRTB_MouseUp); - this.MouseDown += new MouseEventHandler(StepRTB_MouseDown); + this.MouseDown += new MouseEventHandler(StepRTB_MouseDown); this.MouseLeave += new EventHandler(StepRTB_MouseLeave); this.SelectionChanged +=new EventHandler(StepRTB_SelectionChanged); this.ContextMenuStripChanged += new EventHandler(StepRTB_ContextMenuStripChanged); @@ -425,7 +429,6 @@ namespace Volian.Controls.Library Console.WriteLine("{0} - {1}", ex.GetType().Name, ex.Message); } } - private void SetUpStepRTB() { C1SpellChecker2.SetActiveSpellChecking(this, true); @@ -472,7 +475,7 @@ namespace Volian.Controls.Library _MouseDown = false; //Console.WriteLine("^^^^^^^^^^ StepRTB Mouse Up id= {0}", MyItemInfo.ItemID); - if (this.Focused) // Only HandleSelectionChange if this control has focus. + if(this.Focused) // Only HandleSelectionChange if this control has focus. { HandleSelectionChange(); // save our context menu to add to the spell checker's context menu