From ea3770fcb83cfaa5a38fd11a1700b3dba696dea0 Mon Sep 17 00:00:00 2001 From: Rich Date: Fri, 27 Apr 2012 15:00:50 +0000 Subject: [PATCH] Added logic to allow the following edit features when not is edit mode: Copy, Cut (Select all text) Set Text to Bold, Italics, Underline, Subscript and Superscript (Select all text) Paste (Paste at End) Change Case (Select all text) Insert ROs and Transitions (Position at the beginning) Hardspaces, Indents and Symbols can be added (Position at the beginning) Connected Click event for Paste Step Text menu item --- .../Volian.Controls.Library/StepTabRibbon.cs | 53 +++++++++++++++++- .../StepTabRibbon.designer.cs | Bin 486928 -> 487090 bytes 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/PROMS/Volian.Controls.Library/StepTabRibbon.cs b/PROMS/Volian.Controls.Library/StepTabRibbon.cs index be9663d4..b92134d8 100644 --- a/PROMS/Volian.Controls.Library/StepTabRibbon.cs +++ b/PROMS/Volian.Controls.Library/StepTabRibbon.cs @@ -929,8 +929,42 @@ namespace Volian.Controls.Library 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 _MyStepRTB.InsertSymbol(Convert.ToInt32(b.Tag)); } + private enum SelectionOption + { + Start, + All, + End + } + /// + /// If in a FlexGrid, start the editor for a cell + /// + /// If false cursor will be placed at the begining + private void StartGridEditing(SelectionOption 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: + break; + MyStepRTB.Select(MyStepRTB.TextLength, 0); + default: + MyStepRTB.Select(0, 0); + break; + } + } + + } public void btnInsPgBrk_Click(object sender, EventArgs e) { rtabInsert.Select(); @@ -943,6 +977,7 @@ namespace Volian.Controls.Library } private void btnIndent_Click(object sender, EventArgs e) { + StartGridEditing(SelectionOption.Start); _MyStepRTB.InsertIndent(MyEditItem.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.IndentToken); } private void btnCMIndent_Click(object sender, EventArgs e) @@ -954,6 +989,7 @@ namespace Volian.Controls.Library private bool _PastePlainText = false; private void btnPaste_Click(object sender, EventArgs e) { + StartGridEditing(SelectionOption.End); IDataObject myDO = Clipboard.GetDataObject(); RichTextBox myRtb = _MyStepRTB; Control ctrl = FindActiveControl(); @@ -1027,6 +1063,7 @@ namespace Volian.Controls.Library } private void btnCut_Click(object sender, EventArgs e) { + StartGridEditing(SelectionOption.All); MoveSelectedToClipboard(true); } private void MoveSelectedToClipboard(bool isCut) @@ -1092,52 +1129,62 @@ namespace Volian.Controls.Library } private void btnCopy_Click(object sender, EventArgs e) { + StartGridEditing(SelectionOption.All); MoveSelectedToClipboard(false); } private void btnBold_Click(object sender, EventArgs e) { + StartGridEditing(SelectionOption.All); RTBAPI.ToggleBold(!RTBAPI.IsBold(_MyStepRTB), _MyStepRTB, _MyStepRTB.SelectionLength == 0 ? RTBAPI.RTBSelection.SCF_DEFAULT : RTBAPI.RTBSelection.SCF_SELECTION); btnCMBold.Checked = btnBold.Checked = RTBAPI.IsBold(_MyStepRTB); } private void btnItalics_Click(object sender, EventArgs e) { + StartGridEditing(SelectionOption.All); RTBAPI.ToggleItalic(!RTBAPI.IsItalic(_MyStepRTB), _MyStepRTB, _MyStepRTB.SelectionLength == 0 ? RTBAPI.RTBSelection.SCF_DEFAULT : RTBAPI.RTBSelection.SCF_SELECTION); btnCMItalics.Checked = btnItalics.Checked = RTBAPI.IsItalic(_MyStepRTB); } private void btnUnderline_Click(object sender, EventArgs e) { + StartGridEditing(SelectionOption.All); RTBAPI.ToggleUnderline(!RTBAPI.IsUnderline(_MyStepRTB), _MyStepRTB, _MyStepRTB.SelectionLength == 0 ? RTBAPI.RTBSelection.SCF_DEFAULT : RTBAPI.RTBSelection.SCF_SELECTION); btnCMUnderline.Checked = btnUnderline.Checked = RTBAPI.IsUnderline(_MyStepRTB); } private void btnSuperscript_Click(object sender, EventArgs e) { + StartGridEditing(SelectionOption.All); RTBAPI.ToggleSuperscript(!RTBAPI.IsSuperScript(_MyStepRTB), _MyStepRTB, _MyStepRTB.SelectionLength == 0 ? RTBAPI.RTBSelection.SCF_DEFAULT : RTBAPI.RTBSelection.SCF_SELECTION); btnCMSuperscript.Checked = btnSuperscript.Checked = RTBAPI.IsSuperScript(_MyStepRTB); } private void btnSubscript_Click(object sender, EventArgs e) { + StartGridEditing(SelectionOption.All); RTBAPI.ToggleSubscript(!RTBAPI.IsSubScript(_MyStepRTB), _MyStepRTB, _MyStepRTB.SelectionLength == 0 ? RTBAPI.RTBSelection.SCF_DEFAULT : RTBAPI.RTBSelection.SCF_SELECTION); btnCMSubscript.Checked = btnSubscript.Checked = RTBAPI.IsSubScript(_MyStepRTB); } private void btnUppercase_Click(object sender, EventArgs e) { + StartGridEditing(SelectionOption.All); _MyStepRTB.SetSelectedCase('U'); } private void btnLowercase_Click(object sender, EventArgs e) { + StartGridEditing(SelectionOption.All); _MyStepRTB.SetSelectedCase('l'); } private void btnTitleCase_Click(object sender, EventArgs e) { + StartGridEditing(SelectionOption.All); _MyStepRTB.SetSelectedCase('T'); } private void btnInsTrans_Click(object sender, EventArgs e) { + StartGridEditing(SelectionOption.Start); // see if user is positioned 'on' a transition within the rtb, if so do a modify, otherwise, // insert transition. StepTabPanel tmp = Parent as StepTabPanel; @@ -1146,11 +1193,13 @@ namespace Volian.Controls.Library private void btnInsHrdSpc_Click(object sender, EventArgs e) { + StartGridEditing(SelectionOption.Start); _MyStepRTB.InsertSymbol(@"\u160?"); } private void btnInsRO_Click(object sender, EventArgs e) { + StartGridEditing(SelectionOption.Start); // see if user is positioned 'on' an ReferencedObject within the rtb, if so do a modify, otherwise, // insert transition. StepTabPanel tmp = Parent as StepTabPanel; @@ -2127,7 +2176,8 @@ namespace Volian.Controls.Library // for paste, see if there is clipboard data, & if so, of a type we can use. IDataObject iData = Clipboard.GetDataObject(); // set to true if editing cell, otherwise false for grids - bool enable = (MyFlexGrid != null && MyFlexGrid.Editor != null); + //bool enable = (MyFlexGrid != null && MyFlexGrid.Editor != null); + bool enable = (MyFlexGrid != null); //btnPasteText.Enabled = btnPasteStepText.Enabled = btnPaste.Enabled = enable; btnPaste.Enabled = (iData.GetDataPresent(DataFormats.Text) || iData.GetDataPresent(DataFormats.Rtf)) && enable; btnCMPasteText.Enabled = btnPasteText.Enabled = iData.GetDataPresent(DataFormats.Text) && enable; @@ -2316,6 +2366,7 @@ namespace Volian.Controls.Library private void btnPasteText_Click(object sender, EventArgs e) { + StartGridEditing(SelectionOption.End); _PastePlainText = true; btnPaste_Click(sender, e); } diff --git a/PROMS/Volian.Controls.Library/StepTabRibbon.designer.cs b/PROMS/Volian.Controls.Library/StepTabRibbon.designer.cs index f6c7f1cfeb5c974b989167c9a62e2eadc5cd6004..6dde583ce022a969e56b0049b90bdec03fbd12e8 100644 GIT binary patch delta 65 zcmbPmM|RU)*@hOzEll@1rYBT0NlpLI&LlMbPZv|n^nWU>X44P+VC0(a(8R S#LPg<0>rG_c{R)$xJ`+gOO{pPc=vTx=tn_W(HywAZFdZu9J=BDF7VZ B6+!?2