From a68a7cd8ec90218d223f583d3d6b1e42e9426c21 Mon Sep 17 00:00:00 2001 From: Kathy Date: Tue, 8 Feb 2011 11:34:11 +0000 Subject: [PATCH] --- PROMS/Volian.Controls.Library/StepTabPanel.cs | 28 +- .../Volian.Controls.Library/StepTabRibbon.cs | 291 +++++------ .../StepTabRibbon.designer.cs | Bin 376866 -> 376958 bytes PROMS/Volian.Controls.Library/VlnFlexGrid.cs | 477 +++++++++++++++++- .../Volian.Controls.Library/VlnSpellCheck.cs | 16 +- 5 files changed, 603 insertions(+), 209 deletions(-) diff --git a/PROMS/Volian.Controls.Library/StepTabPanel.cs b/PROMS/Volian.Controls.Library/StepTabPanel.cs index e4a42a5d..afb4627e 100644 --- a/PROMS/Volian.Controls.Library/StepTabPanel.cs +++ b/PROMS/Volian.Controls.Library/StepTabPanel.cs @@ -57,12 +57,11 @@ namespace Volian.Controls.Library set { _MyStepPanel.SelectedItemInfo = value; } } /// - /// Currently Selected RTBItem + /// Currently Selected EditItem /// - public RTBItem SelectedRTBItem + public EditItem SelectedEditItem { - //get { return _MyStepPanel._LookupRTBItems[_MyStepPanel.SelectedItemInfo.ItemID]; } - get { return _MyStepPanel.SelectedRTBItem; } + get { return _MyStepPanel.SelectedEditItem; } } /// /// Procedure ItemInfo @@ -81,7 +80,7 @@ namespace Volian.Controls.Library public void FindSearchString() { // convert the '-' to the unicode non-breaking dash (\u8209? or \u2011 hex) - SelectedRTBItem.MyStepRTB.Find(SearchString.Replace('-','\u2011')); + SelectedEditItem.MyStepRTB.Find(SearchString.Replace('-','\u2011')); } #endregion #region Contructors @@ -105,7 +104,7 @@ namespace Volian.Controls.Library _MyStepTabRibbon.Location = new System.Drawing.Point(0, 0); _MyStepTabRibbon.Name = "displayTabRibbon1"; //_MyTabRibbon.MyDisplayRTB = null; - _MyStepTabRibbon.MyRTBItem = null; + _MyStepTabRibbon.MyEditItem = null; this.Controls.Add(_MyStepTabRibbon); _MyStepTabRibbon.Expanded = _MyDisplayTabControl.RibbonExpanded; } @@ -139,7 +138,7 @@ namespace Volian.Controls.Library _MyStepPanel.ItemClick +=new Volian.Controls.Library.StepPanelEvent(_MyStepPanel_ItemClick); _MyStepPanel.AttachmentClicked += new Volian.Controls.Library.StepPanelAttachmentEvent(_MyStepPanel_AttachmentClicked); _MyStepPanel.ItemSelectedChanged += new ItemSelectedChangedEvent(_MyStepPanel_ItemSelectedChanged); - _MyStepPanel.ModeChange += new Volian.Controls.Library.StepPanelModeChangeEvent(_MyStepPanel_ModeChange); + //_MyStepPanel.ModeChange += new Volian.Controls.Library.StepPanelModeChangeEvent(_MyStepPanel_ModeChange); _MyStepPanel.TabDisplay += new Volian.Controls.Library.StepPanelTabDisplayEvent(_MyStepPanel_TabDisplay); _MyStepPanel.WordSectionClose += new StepPanelWordSectionCloseEvent(_MyStepPanel_WordSectionClose); _MyStepPanel.WordSectionDeleted += new StepPanelWordSectionDeletedEvent(_MyStepPanel_WordSectionDeleted); @@ -222,15 +221,14 @@ namespace Volian.Controls.Library /// void _MyStepPanel_ItemSelectedChanged(object sender, ItemSelectedChangedEventArgs args) { - //_MyTabRibbon.MyDisplayRTB = args.MyDisplayItem.MyDisplayRTB; - _MyStepTabRibbon.MyRTBItem = args.MyRTBItem; + _MyStepTabRibbon.MyEditItem = args.MyEditItem; _MyDisplayTabControl.OnItemSelectedChanged(sender, args); } // Occurs when the Mode Changes - void _MyStepPanel_ModeChange(object sender, StepRTBModeChangeEventArgs args) - { - _MyDisplayTabControl.OnModeChange(sender, args); - } + //void _MyStepPanel_ModeChange(object sender, StepRTBModeChangeEventArgs args) + //{ + // _MyDisplayTabControl.OnModeChange(sender, args); + //} /// /// Occurs when the user clicks on the Attachment Expander @@ -241,8 +239,8 @@ namespace Volian.Controls.Library void _MyStepPanel_AttachmentClicked(object sender, StepPanelAttachmentEventArgs args) { if (curDSOItem != null) return; - curDSOItem = args.MyRTBItem.MyItemInfo; - _MyDisplayTabControl.OpenItem(args.MyRTBItem.MyItemInfo); + curDSOItem = args.MyEditItem.MyItemInfo; + _MyDisplayTabControl.OpenItem(args.MyEditItem.MyItemInfo); curDSOItem = null; } /// diff --git a/PROMS/Volian.Controls.Library/StepTabRibbon.cs b/PROMS/Volian.Controls.Library/StepTabRibbon.cs index d7ca55b9..c310b324 100644 --- a/PROMS/Volian.Controls.Library/StepTabRibbon.cs +++ b/PROMS/Volian.Controls.Library/StepTabRibbon.cs @@ -15,13 +15,21 @@ namespace Volian.Controls.Library public partial class StepTabRibbon : UserControl { #region Properties - private RTBItem _MyRTBItem; - public RTBItem MyRTBItem + private VlnFlexGrid MyFlexGrid { - get { return _MyRTBItem; } + get + { + if (MyEditItem is GridItem) return (MyEditItem as GridItem).MyFlexGrid; + return null; + } + } + private EditItem _MyEditItem; + public EditItem MyEditItem + { + get { return _MyEditItem; } set { - _MyRTBItem = value; + _MyEditItem = value; if (value != null) { MyStepRTB = value.MyStepRTB; @@ -34,9 +42,9 @@ namespace Volian.Controls.Library get { if (_MyDVI != null) return _MyDVI; - if (_MyRTBItem != null) + if (_MyEditItem != null) { - ItemInfo procInfo = _MyRTBItem.MyItemInfo.MyProcedure as ItemInfo; + ItemInfo procInfo = _MyEditItem.MyItemInfo.MyProcedure as ItemInfo; if (procInfo == null) return null; _MyDVI = procInfo.ActiveParent as DocVersionInfo; return _MyDVI; @@ -91,7 +99,7 @@ namespace Volian.Controls.Library //_MyStepRTB.MouseUp += new MouseEventHandler(_MyStepRTB_MouseUp); //+= new MouseEventHandler(MyStepRTB_SelectionChanged); //_MyStepRTB.KeyUp += new KeyEventHandler(_MyStepRTB_KeyUp); //+= new KeyEventHandler(MyStepRTB_SelectionChanged); _MyStepRTB.SelectionChanged += new EventHandler(_MyStepRTB_SelectionChanged); - _MyStepRTB.ModeChange += new StepRTBModeChangeEvent(_MyStepRTB_ModeChange); + //_MyStepRTB.ModeChange += new StepRTBModeChangeEvent(_MyStepRTB_ModeChange); _MyStepRTB.Leave += new EventHandler(MyStepRTB_Leave); _MyStepRTB.LinkChanged += new StepRTBLinkEvent(_MyStepRTB_LinkChanged); // Add symbols into the tab ribbon based on format selection. For now, only add symbols once @@ -160,10 +168,10 @@ namespace Volian.Controls.Library } } - void _MyStepRTB_ModeChange(object sender, StepRTBModeChangeEventArgs args) - { - SetButtonAndMenuEnabling(true); - } + //void _MyStepRTB_ModeChange(object sender, StepRTBModeChangeEventArgs args) + //{ + // SetButtonAndMenuEnabling(true); + //} #endregion #region Constructor public StepTabRibbon() @@ -234,12 +242,12 @@ namespace Volian.Controls.Library // if from type == 0, we've inserted a hls. // if inserting from section, insert first child // else do a after from current HLS - if not at HLS, go up parents until find it. - if (fromtype == 0 && !_MyRTBItem.MyItemInfo.IsStepSection) + if (fromtype == 0 && !_MyEditItem.MyItemInfo.IsStepSection) { - RTBItem hlsRTBItem = _MyRTBItem; - while (!hlsRTBItem.MyItemInfo.IsHigh) - hlsRTBItem = hlsRTBItem.ActiveParent; - hlsRTBItem.AddSiblingAfter((int ?)contenttype,true); + EditItem hlsEditItem = _MyEditItem; + while (!hlsEditItem.MyItemInfo.IsHigh) + hlsEditItem = hlsEditItem.ActiveParent; + hlsEditItem.AddSiblingAfter((int ?)contenttype,true); } else { @@ -252,7 +260,7 @@ namespace Volian.Controls.Library // addchild = false; //} //if (addchild) - _MyRTBItem.AddChild((E_FromType)fromtype, contenttype); + _MyEditItem.AddChild((E_FromType)fromtype, contenttype); } } // Future Table Grid? @@ -272,12 +280,12 @@ namespace Volian.Controls.Library } private void btnInsBefore_Click(object sender, EventArgs e) { - _MyRTBItem.AddSiblingBefore(); + _MyEditItem.AddSiblingBefore(); } private void btnInsAfter_Click(object sender, EventArgs e) { - _MyRTBItem.AddSiblingAfter(); + _MyEditItem.AddSiblingAfter(); } /// /// Using style for step type, enable/disable formatting buttons @@ -316,16 +324,16 @@ namespace Volian.Controls.Library btnIndent.Enabled = setting; btnDelelete.Enabled = btnDelStep.Enabled = setting; btnSpell.Enabled = setting; - //rtabTableGridTools.Visible = setting; + rtabTableGridTools.Visible = setting; } private void SetButtonAndMenuEnabling(bool docontextmenus) { if (_MyStepRTB.FieldToEdit != E_FieldToEdit.StepText) return; // No need to change menu that does not get used if (_MyStepRTB == null) return; - DocVersionInfo dvi = MyRTBItem.MyItemInfo.MyProcedure.ActiveParent as DocVersionInfo; + DocVersionInfo dvi = MyEditItem.MyItemInfo.MyProcedure.ActiveParent as DocVersionInfo; if (dvi == null) return; - if (dvi.VersionType > 127 || MyRTBItem.MyStepPanel.PanelViewEditMode == E_ViewMode.View) + if (dvi.VersionType > 127 || MyEditItem.MyStepPanel.VwMode == E_ViewMode.View) { SetButtonMenuEnabledDisabledOnSelection(false); } @@ -404,12 +412,12 @@ namespace Volian.Controls.Library } private void SetStepButtonAndMenuEnabling(bool docontextmenus) { - if (MyRTBItem == null) return; - DocVersionInfo dvi = MyRTBItem.MyItemInfo.MyProcedure.ActiveParent as DocVersionInfo; + if (MyEditItem == null) return; + DocVersionInfo dvi = MyEditItem.MyItemInfo.MyProcedure.ActiveParent as DocVersionInfo; if (dvi == null) return; if (dvi.VersionType > 127) btnCMEditMode1.Enabled = btnEditMode.Enabled = false; // in approved - if (dvi.VersionType > 127 || MyRTBItem.MyStepPanel.PanelViewEditMode == E_ViewMode.View) + if (dvi.VersionType > 127 || MyEditItem.MyStepPanel.VwMode == E_ViewMode.View) { SetButtonMenuEnabledDisabledOnStepType(false); return; @@ -422,13 +430,15 @@ namespace Volian.Controls.Library btnInsPgBrk.Checked = cfg == null ? false : cfg.Step_ManualPagebreak; } btnInsPgBrk.Enabled = MyItemInfo.IsHigh; - btnEditMode.Checked = btnCMEditMode1.Checked = MyRTBItem.MyStepPanel.PanelViewEditMode != E_ViewMode.View; + btnEditMode.Checked = btnCMEditMode1.Checked = MyEditItem.MyStepPanel.VwMode == E_ViewMode.View; // if on procedure, 'Delete' buttons should be disabled. btnDelelete.Enabled = btnDelStep.Enabled = ! MyItemInfo.IsProcedure; btnCpyStp.Enabled = !MyItemInfo.IsProcedure; - //if (rtabTableGridTools.Visible && rtabTableGridTools.Checked && !MyItemInfo.IsTable) - // rtabHome.Select(); - //rtabTableGridTools.Visible = MyItemInfo.IsTable; // turn on/off Table Design (Grid) ribbon tab grouping + if (!(MyEditItem is GridItem) && rtabTableGridTools.Checked) + { + rtabHome.Select(); + } + rtabTableGridTools.Visible = MyEditItem is GridItem; // turn on/off Table Design (Grid) ribbon tab grouping // if on procedure or section, 'change type' & 'insert' buttons should be disabled. if (MyItemInfo.IsProcedure || MyItemInfo.IsSection) @@ -491,7 +501,7 @@ namespace Volian.Controls.Library // if (rno is enabled, set the tag: if (btnInsRNO.Enabled) - btnInsRNO.Tag = string.Format("{0} {1}", (int)E_FromTypes.RNOs, MyRTBItem.MyItemInfo.ActiveFormat.PlantFormat.FormatData.GetIndexFromType("RNOType")); + btnInsRNO.Tag = string.Format("{0} {1}", (int)E_FromTypes.RNOs, MyEditItem.MyItemInfo.ActiveFormat.PlantFormat.FormatData.GetIndexFromType("RNOType")); // add subitems depending on whether parent type is enabled: if (btnInsHLS.Enabled) GalleryForSubTypes(MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList.HLS, sd, btnInsHLS, 0, btnCMInsHLS, docontextmenus); @@ -640,11 +650,11 @@ namespace Volian.Controls.Library } private void btnIndent_Click(object sender, EventArgs e) { - _MyStepRTB.InsertIndent(); + _MyStepRTB.InsertIndent(MyEditItem.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.IndentToken); } private void btnCMIndent_Click(object sender, EventArgs e) { - _MyStepRTB.InsertIndent(); + _MyStepRTB.InsertIndent(MyEditItem.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.IndentToken); } #endregion #region Home Tab @@ -725,7 +735,7 @@ namespace Volian.Controls.Library // see if user is positioned 'on' a transition within the rtb, if so do a modify, otherwise, // insert transition. StepTabPanel tmp = Parent as StepTabPanel; - tmp.MyDisplayTabControl.OnLinkModifyTran(this, new StepPanelLinkEventArgs(_MyRTBItem, MyStepRTB.MyLinkText)); + tmp.MyDisplayTabControl.OnLinkModifyTran(this, new StepPanelLinkEventArgs(MyStepRTB.MyLinkText)); } private void btnInsHrdSpc_Click(object sender, EventArgs e) @@ -738,7 +748,7 @@ namespace Volian.Controls.Library // see if user is positioned 'on' an ReferencedObject within the rtb, if so do a modify, otherwise, // insert transition. StepTabPanel tmp = Parent as StepTabPanel; - tmp.MyDisplayTabControl.OnLinkModifyRO(this, new StepPanelLinkEventArgs(_MyRTBItem, MyStepRTB.MyLinkText)); + tmp.MyDisplayTabControl.OnLinkModifyRO(this, new StepPanelLinkEventArgs(MyStepRTB.MyLinkText)); } private void btnRedo_Click(object sender, EventArgs e) @@ -769,7 +779,7 @@ namespace Volian.Controls.Library // a referenced object, bring up ReferencedObject Editor (for now, just put up a message box. if (_MyStepRTB.MyLinkText.IndexOf("Transition") > -1) { - _MyRTBItem.MyStepPanel.OnLinkClicked(sender, new StepPanelLinkEventArgs(_MyRTBItem, _MyStepRTB.MyLinkText)); + _MyEditItem.MyStepPanel.OnLinkClicked(sender, new StepPanelLinkEventArgs(_MyStepRTB.MyLinkText)); } else { @@ -787,7 +797,7 @@ namespace Volian.Controls.Library private void btnChgTyp_Click(object sender, EventArgs e) { StepPanelTabDisplayEventArgs args = new StepPanelTabDisplayEventArgs("Change Step Type"); - MyRTBItem.MyStepPanel.OnTabDisplay(sender, args); + MyEditItem.MyStepPanel.OnTabDisplay(sender, args); } #endregion #region RHM debug @@ -834,8 +844,12 @@ namespace Volian.Controls.Library //#endif private void btnToggleEditView_Click(object sender, EventArgs e) { - MyStepRTB.ToggleEditView(); + MyEditItem.MyStepPanel.VwMode = MyEditItem.MyStepPanel.VwMode == E_ViewMode.Edit ? E_ViewMode.View : E_ViewMode.Edit; + MyEditItem.ToggleEditView(MyEditItem.MyStepPanel.VwMode); + SetButtonAndMenuEnabling(true); SetStepButtonAndMenuEnabling(true); + MyEditItem.MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnModeChange(this, new StepRTBModeChangeEventArgs(MyEditItem.MyStepPanel.VwMode)); + btnEditMode.Checked = btnCMEditMode1.Checked = MyEditItem.MyStepPanel.VwMode == E_ViewMode.View; } #endregion @@ -895,7 +909,7 @@ namespace Volian.Controls.Library { ROFst newrofst = ROFstInfo.UpdateRoFst(roFstInfo.MyRODb, dv.DocVersionAssociations[0], dv, roFstInfo); StepPanelTabDisplayEventArgs args = new StepPanelTabDisplayEventArgs("DisplayROUpdateROFST"); - MyRTBItem.MyStepPanel.OnTabDisplay(sender, args); + MyEditItem.MyStepPanel.OnTabDisplay(sender, args); btnUpdROVal.Enabled = false; } Cursor = Cursors.Default; @@ -951,31 +965,31 @@ namespace Volian.Controls.Library private void btnBookmarks_Click(object sender, EventArgs e) { StepPanelTabDisplayEventArgs args = new StepPanelTabDisplayEventArgs("Bookmarks"); - MyRTBItem.MyStepPanel.OnTabDisplay(sender, args); + MyEditItem.MyStepPanel.OnTabDisplay(sender, args); } private void btnSearch_Click(object sender, EventArgs e) { StepPanelTabDisplayEventArgs args = new StepPanelTabDisplayEventArgs("Global Search"); - MyRTBItem.MyStepPanel.OnTabDisplay(sender, args); + MyEditItem.MyStepPanel.OnTabDisplay(sender, args); } private void btnLibDocs_Click(object sender, EventArgs e) { StepPanelTabDisplayEventArgs args = new StepPanelTabDisplayEventArgs("LibDocs"); - MyRTBItem.MyStepPanel.OnTabDisplay(sender, args); + MyEditItem.MyStepPanel.OnTabDisplay(sender, args); } public void btnAnnots_Click(object sender, EventArgs e) { StepPanelTabDisplayEventArgs args = new StepPanelTabDisplayEventArgs("Annots"); - MyRTBItem.MyStepPanel.OnTabDisplay(sender, args); + MyEditItem.MyStepPanel.OnTabDisplay(sender, args); } public void btnDelStep_Click(object sender, EventArgs e) { bool surpressMessageBox = (e == null); - SectionInfo si = MyRTBItem.MyItemInfo as SectionInfo; + SectionInfo si = MyEditItem.MyItemInfo as SectionInfo; if (si != null) { string msg = si.HasChildren ? "Are you sure you want to delete this section and its steps?" : "Are you sure you want to delete this section?"; @@ -986,18 +1000,18 @@ namespace Volian.Controls.Library if (!si.IsStepSection) { WordSectionEventArgs args = new WordSectionEventArgs(si); - MyRTBItem.MyStepPanel.OnWordSectionClose(sender, args); + MyEditItem.MyStepPanel.OnWordSectionClose(sender, args); } - MyRTBItem.RemoveItem(); + MyEditItem.RemoveItem(); if (!si.IsStepSection) { WordSectionEventArgs args = new WordSectionEventArgs(si); - MyRTBItem.MyStepPanel.OnWordSectionDeleted(sender, args); + MyEditItem.MyStepPanel.OnWordSectionDeleted(sender, args); } } return; } - StepInfo stpi = MyRTBItem.MyItemInfo as StepInfo; + StepInfo stpi = MyEditItem.MyItemInfo as StepInfo; if (stpi == null) // not sure that it will every get here! { MessageBox.Show("Unknown type, cannot delete!"); @@ -1008,10 +1022,10 @@ namespace Volian.Controls.Library string msgs = stpi.HasChildren ? "Are you sure you want to delete this step and its substeps?" : "Are you sure you want to delete this step?"; DialogResult results = MessageBox.Show(msgs, "Verify Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (results == DialogResult.Yes) - MyRTBItem.RemoveItem(); + MyEditItem.RemoveItem(); } else - MyRTBItem.RemoveItem(); + MyEditItem.RemoveItem(); } private void btnCMIns_PopupClose(object sender, EventArgs e) @@ -1019,7 +1033,7 @@ namespace Volian.Controls.Library _ContextMenuBar.SetContextMenuEx(_MyStepRTB, _DefaultContextMenu); } - public void ShortCutContextMenu(string menuName) + public void SetShortCutContextMenu(string menuName) { bool displayMenu = false; E_AccStep? actable = 0; @@ -1075,13 +1089,13 @@ namespace Volian.Controls.Library { //MessageBox.Show("Functionality not available.", "Spell Check"); StepPanelTabDisplayEventArgs args = new StepPanelTabDisplayEventArgs("SpellChecker"); - MyRTBItem.MyStepPanel.OnTabDisplay(sender, args); + MyEditItem.MyStepPanel.OnTabDisplay(sender, args); } //private FindReplace dlgFindReplace = null; private void btnFindRplDlg_Click(object sender, EventArgs e) { StepPanelTabDisplayEventArgs args = new StepPanelTabDisplayEventArgs("FndRpl"); - MyRTBItem.MyStepPanel.OnTabDisplay(sender, args); + MyEditItem.MyStepPanel.OnTabDisplay(sender, args); } private void InsertSiblingBeforeOrAfter(string b4aftr) @@ -1094,11 +1108,11 @@ namespace Volian.Controls.Library { case "after": if ((actable & E_AccStep.AddingNext) > 0) - MyRTBItem.AddSiblingAfter(); + MyEditItem.AddSiblingAfter(); break; case "before": if ((actable & E_AccStep.AddingPrev) > 0) - MyRTBItem.AddSiblingBefore(); + MyEditItem.AddSiblingBefore(); break; } } @@ -1127,8 +1141,8 @@ namespace Volian.Controls.Library if (!deletedHLS) { if (deletedSubStep) - ShortCutContextMenu("InsHLS"); - else if (MyRTBItem.MyRNORTBItems != null && MyRTBItem.MyRNORTBItems.Count > 0) + SetShortCutContextMenu("InsHLS"); + else if (MyEditItem.MyRNOEditItems != null && MyEditItem.MyRNOEditItems.Count > 0) MyStepRTB.StepRTB_ArrowPressed(E_ArrowKeys.CtrlRight); // jump to RNO else if (deletedRNO) { @@ -1148,14 +1162,14 @@ namespace Volian.Controls.Library MyStepRTB.StepRTB_ArrowPressed(E_ArrowKeys.CtrlLeft); if (MyItemInfo.IsHigh) { - if (MyRTBItem != null && MyRTBItem.NextDownRTBItem != null &&MyRTBItem.NextDownRTBItem.MyItemInfo.MyParent.Equals(MyRTBItem.MyItemInfo)) + if (MyEditItem != null && MyEditItem.NextDownEditItem != null && MyEditItem.NextDownEditItem.MyItemInfo.MyParent.Equals(MyEditItem.MyItemInfo)) //if (MyRTBItem.NextDownRTBItem.MyItemInfo.MyParent.ItemID == MyRTBItem.MyItemInfo.ItemID) //.Equals(MyRTBItem.MyItemInfo)) { MyStepRTB.StepRTB_ArrowPressed(E_ArrowKeys.CtrlDown); InsertSiblingBeforeOrAfter("before"); } else - ShortCutContextMenu("InsSubStps"); + SetShortCutContextMenu("InsSubStps"); } else InsertSiblingBeforeOrAfter("after"); @@ -1175,11 +1189,11 @@ namespace Volian.Controls.Library if (deletedSubStep) { MyStepRTB.StepRTB_ArrowPressed(E_ArrowKeys.CtrlUp); // jump to HLS - ShortCutContextMenu("InsHLS"); // prompt for new HLS + SetShortCutContextMenu("InsHLS"); // prompt for new HLS } else if (deletedRNO || MyItemInfo.IsEquipmentList) InsertSiblingBeforeOrAfter("after"); - else if (MyRTBItem.MyRNORTBItems != null && MyRTBItem.MyRNORTBItems.Count > 0) + else if (MyEditItem.MyRNOEditItems != null && MyEditItem.MyRNOEditItems.Count > 0) MyStepRTB.StepRTB_ArrowPressed(E_ArrowKeys.CtrlRight); // jump to RNO else if (MyItemInfo.ColumnMode > 0) @@ -1209,7 +1223,7 @@ namespace Volian.Controls.Library { MyStepRTB.StepRTB_ArrowPressed(E_ArrowKeys.CtrlUp); if (MyItemInfo.IsHigh) - ShortCutContextMenu("InsHLS"); + SetShortCutContextMenu("InsHLS"); else InsertSiblingBeforeOrAfter("after"); } @@ -1217,29 +1231,29 @@ namespace Volian.Controls.Library private void AddSubStep() { - RTBItem nextDownRTBItem = MyRTBItem.NextDownRTBItem; + EditItem nextDownEditItem = MyEditItem.NextDownEditItem; bool skipTable = false; // If the step has a table, move past it before adding a substep - if (nextDownRTBItem != null && nextDownRTBItem.MyItemInfo.MyParent.ItemID == MyRTBItem.MyID && - nextDownRTBItem.MyItemInfo.IsTablePart) + if (nextDownEditItem != null && nextDownEditItem.MyItemInfo.MyParent.ItemID == MyEditItem.MyID && + nextDownEditItem.MyItemInfo.IsTablePart) { - nextDownRTBItem = nextDownRTBItem.NextDownRTBItem; + nextDownEditItem = nextDownEditItem.NextDownEditItem; skipTable = true; } - if (nextDownRTBItem != null && nextDownRTBItem.MyItemInfo.MyParent.ItemID == MyRTBItem.MyID) + if (nextDownEditItem != null && nextDownEditItem.MyItemInfo.MyParent.ItemID == MyEditItem.MyID) { MyStepRTB.StepRTB_ArrowPressed(E_ArrowKeys.CtrlDown); if(skipTable) MyStepRTB.StepRTB_ArrowPressed(E_ArrowKeys.CtrlDown); InsertSiblingBeforeOrAfter("before"); } else - ShortCutContextMenu("InsSubStps"); + SetShortCutContextMenu("InsSubStps"); } private void CreateNewRNO() { if (btnInsRNO.SubItems.Count > 1) - ShortCutContextMenu("InsRNO"); + SetShortCutContextMenu("InsRNO"); else btnInsRNO.RaiseClick(); } @@ -1247,7 +1261,7 @@ namespace Volian.Controls.Library private void CreateNewNote() { if (btnInsNote.SubItems.Count > 1) - ShortCutContextMenu("InsNote"); + SetShortCutContextMenu("InsNote"); else btnInsNote.RaiseClick(); } @@ -1255,13 +1269,13 @@ namespace Volian.Controls.Library { StepTabPanel tmp = Parent as StepTabPanel; if (tmp.MyDisplayTabControl.MyCopyStep == null) return; - MyRTBItem.PasteSiblingAfter(tmp.MyDisplayTabControl.MyCopyStep.ItemID); + MyEditItem.PasteSiblingAfter(tmp.MyDisplayTabControl.MyCopyStep.ItemID); } private void btnPasteBefore_Click(object sender, EventArgs e) { StepTabPanel tmp = Parent as StepTabPanel; if (tmp.MyDisplayTabControl.MyCopyStep == null) return; - MyRTBItem.PasteSiblingBefore(tmp.MyDisplayTabControl.MyCopyStep.ItemID); + MyEditItem.PasteSiblingBefore(tmp.MyDisplayTabControl.MyCopyStep.ItemID); } private void btnStepPaste_Click(object sender, EventArgs e) { @@ -1276,7 +1290,7 @@ namespace Volian.Controls.Library public void DoCopyStep() { // highlight selected step(s) and prompt to see if selection is what user wants: - MyRTBItem.HighlightBackColor(); + MyEditItem.IdentifyChildren(true); DialogResult dr = MessageBox.Show("Step as Marked?", "Identify Step To Be Copied", MessageBoxButtons.YesNo); if (dr == DialogResult.Yes) { @@ -1285,16 +1299,16 @@ namespace Volian.Controls.Library btnStepPaste.Enabled = true; SetPasteButtonEnabled(); } - MyRTBItem.SetBackColor(); + MyEditItem.IdentifyChildren(false); } private void btnPasteReplace_Click(object sender, EventArgs e) { StepTabPanel tmp = Parent as StepTabPanel; if (tmp.MyDisplayTabControl.MyCopyStep==null) return; - RTBItem oldRTBItem = MyRTBItem; - MyRTBItem = MyRTBItem.PasteReplace(tmp.MyDisplayTabControl.MyCopyStep.ItemID); - if (MyRTBItem.MyItemInfo.ItemID != oldRTBItem.MyItemInfo.ItemID) oldRTBItem.Dispose(); + EditItem oldEditItem = MyEditItem; + MyEditItem = MyEditItem.PasteReplace(tmp.MyDisplayTabControl.MyCopyStep.ItemID); + if (MyEditItem.MyItemInfo.ItemID != oldEditItem.MyItemInfo.ItemID) oldEditItem.Dispose(); } private void btnPdfCreate_Click(object sender, EventArgs e) @@ -1353,260 +1367,221 @@ namespace Volian.Controls.Library #region Table Grid Copy/Paste private void btnTblDgnCopyRow_Click(object sender, EventArgs e) { - VlnFlexGrid grd = new VlnFlexGrid(); // = rbtDefaultTable.Checked ? vlnFlexGrid2 : vlnFlexGrid3; - grd.ClipBoardCopyRow(); + MyFlexGrid.ClipBoardCopyRow(); } private void btnTblDgnCopyColumn_Click(object sender, EventArgs e) { - VlnFlexGrid grd = new VlnFlexGrid(); // = rbtDefaultTable.Checked ? vlnFlexGrid2 : vlnFlexGrid3; - grd.ClipBoardCopyColumn(); + MyFlexGrid.ClipBoardCopyColumn(); } private void btnTblDgnCopySelection_Click(object sender, EventArgs e) { - VlnFlexGrid grd = new VlnFlexGrid(); // = rbtDefaultTable.Checked ? vlnFlexGrid2 : vlnFlexGrid3; - grd.ClipBoardCopySelection(); + MyFlexGrid.ClipBoardCopySelection(); } private void btnTblDgnPasteRowBefore_Click(object sender, EventArgs e) { // create new rows before current position and copy clipboard data - VlnFlexGrid grd = new VlnFlexGrid(); // = rbtDefaultTable.Checked ? vlnFlexGrid2 : vlnFlexGrid3; - grd.ClipBoardPasteRows(VlnFlexGrid.enmPastePos.Before); + MyFlexGrid.ClipBoardPasteRows(VlnFlexGrid.enmPastePos.Before); } private void btnTblDgnPasteRowAfter_Click(object sender, EventArgs e) { // create new rows after current position and copy clipboard data - VlnFlexGrid grd = new VlnFlexGrid(); // = rbtDefaultTable.Checked ? vlnFlexGrid2 : vlnFlexGrid3; - grd.ClipBoardPasteRows(VlnFlexGrid.enmPastePos.After); + MyFlexGrid.ClipBoardPasteRows(VlnFlexGrid.enmPastePos.After); } private void btnTblDgnPasteReplaceRow_Click(object sender, EventArgs e) { // replace rows with current clipboard data starting as current row - VlnFlexGrid grd = new VlnFlexGrid(); // = rbtDefaultTable.Checked ? vlnFlexGrid2 : vlnFlexGrid3; - grd.ClipBoardPasteRows(VlnFlexGrid.enmPastePos.Replace); + MyFlexGrid.ClipBoardPasteRows(VlnFlexGrid.enmPastePos.Replace); } private void btnTblDgnPasteColumnBefore_Click(object sender, EventArgs e) { - VlnFlexGrid grd = new VlnFlexGrid(); // = rbtDefaultTable.Checked ? vlnFlexGrid2 : vlnFlexGrid3; - grd.ClipBoardPasteColumns(VlnFlexGrid.enmPastePos.Before); + MyFlexGrid.ClipBoardPasteColumns(VlnFlexGrid.enmPastePos.Before); } private void btnTblDgnPasteColumnAfter_Click(object sender, EventArgs e) { - VlnFlexGrid grd = new VlnFlexGrid(); // = rbtDefaultTable.Checked ? vlnFlexGrid2 : vlnFlexGrid3; - grd.ClipBoardPasteColumns(VlnFlexGrid.enmPastePos.After); + MyFlexGrid.ClipBoardPasteColumns(VlnFlexGrid.enmPastePos.After); } private void btnTblDgnPasteColumnReplace_Click(object sender, EventArgs e) { - VlnFlexGrid grd = new VlnFlexGrid(); //= rbtDefaultTable.Checked ? vlnFlexGrid2 : vlnFlexGrid3; - grd.ClipBoardPasteColumns(VlnFlexGrid.enmPastePos.Replace); + MyFlexGrid.ClipBoardPasteColumns(VlnFlexGrid.enmPastePos.Replace); } private void btnTblDgnPasteIntoSelection_Click(object sender, EventArgs e) { - VlnFlexGrid grd = new VlnFlexGrid(); // = rbtDefaultTable.Checked ? vlnFlexGrid2 : vlnFlexGrid3; - grd.ClipBoardPasteIntoSelection(); + MyFlexGrid.ClipBoardPasteIntoSelection(); } private void btnTblDgnClear_Click(object sender, EventArgs e) { - VlnFlexGrid grd = new VlnFlexGrid(); // = rbtDefaultTable.Checked ? vlnFlexGrid2 : vlnFlexGrid3; - grd.ClearSelectedCellText(); + MyFlexGrid.ClearSelectedCellText(); } #endregion #region Table Grid Delete private void btnTblDgnDeleteRow_Click(object sender, EventArgs e) { - VlnFlexGrid grd = new VlnFlexGrid(); //= rbtDefaultTable.Checked ? vlnFlexGrid2 : vlnFlexGrid3; - grd.RemoveSelectedRow(); + MyFlexGrid.RemoveSelectedRow(); } private void btnTblDgnDeleteColumn_Click(object sender, EventArgs e) { - VlnFlexGrid grd = new VlnFlexGrid(); // = rbtDefaultTable.Checked ? vlnFlexGrid2 : vlnFlexGrid3; - grd.RemoveSelectedColumn(); + MyFlexGrid.RemoveSelectedColumn(); } private void btnTblDgnDeleteSelected_Click(object sender, EventArgs e) { - VlnFlexGrid grd = new VlnFlexGrid(); // = rbtDefaultTable.Checked ? vlnFlexGrid2 : vlnFlexGrid3; - grd.RemoveSelectedCells(); + MyFlexGrid.RemoveSelectedCells(); } #endregion #region Table Grid Cell Style private void cpHighlight_SelectedColorChanged(object sender, EventArgs e) { - VlnFlexGrid grd = new VlnFlexGrid(); string strColor = string.Format("{0}, {1}, {2};", cpTblDgnHighlight.SelectedColor.R, cpTblDgnHighlight.SelectedColor.G, cpTblDgnHighlight.SelectedColor.B); - grd.ChangeBackgroundColor(strColor); + MyFlexGrid.ChangeBackgroundColor(strColor); } private void btnTblDgnAlignLeft_Click(object sender, EventArgs e) { - VlnFlexGrid grd = new VlnFlexGrid(); ; // = rbtDefaultTable.Checked ? vlnFlexGrid2 : vlnFlexGrid3; - grd.RTFTextAlignment(grd.Selection, HorizontalAlignment.Left); + MyFlexGrid.RTFTextAlignment(MyFlexGrid.Selection, HorizontalAlignment.Left); } private void btnTblDgnAlignCentered_Click(object sender, EventArgs e) { - VlnFlexGrid grd = new VlnFlexGrid(); ; // = rbtDefaultTable.Checked ? vlnFlexGrid2 : vlnFlexGrid3; - grd.RTFTextAlignment(grd.Selection, HorizontalAlignment.Center); + MyFlexGrid.RTFTextAlignment(MyFlexGrid.Selection, HorizontalAlignment.Center); } private void btnTblDgnAlignRight_Click(object sender, EventArgs e) { - VlnFlexGrid grd = new VlnFlexGrid(); ; // = rbtDefaultTable.Checked ? vlnFlexGrid2 : vlnFlexGrid3; - grd.RTFTextAlignment(grd.Selection, HorizontalAlignment.Right); + MyFlexGrid.RTFTextAlignment(MyFlexGrid.Selection, HorizontalAlignment.Right); } #endregion #region Table Grid Merge/Split private void btnTblDgnSplitCells_ToRows_Click(object sender, EventArgs e) { - VlnFlexGrid grd = new VlnFlexGrid(); // = rbtDefaultTable.Checked ? vlnFlexGrid2 : vlnFlexGrid3; //GetActiveGrid(); - grd.SplitSelection(false); + MyFlexGrid.SplitSelection(false); } #endregion private void btnTblDgnSplitCellsToCols_Click(object sender, EventArgs e) { - VlnFlexGrid grd = new VlnFlexGrid(); // = rbtDefaultTable.Checked ? vlnFlexGrid2 : vlnFlexGrid3; //GetActiveGrid(); - grd.SplitSelection(true); + MyFlexGrid.SplitSelection(true); } private void btnTblDgnMergeCells_Click(object sender, EventArgs e) { - VlnFlexGrid grd = new VlnFlexGrid(); // = rbtDefaultTable.Checked ? vlnFlexGrid2 : vlnFlexGrid3; //GetActiveGrid(); - grd.MergeSelection(); + MyFlexGrid.MergeSelection(); } #endregion #region Table Grid Design private void btnTblDgnInsertRowBefore_Click(object sender, EventArgs e) { - VlnFlexGrid grd = new VlnFlexGrid(); // = rbtDefaultTable.Checked ? vlnFlexGrid2 : vlnFlexGrid3; - grd.InsertRowBefore(); + MyFlexGrid.InsertRowBefore(); } private void btnTblDgnInsertRowAfter_Click(object sender, EventArgs e) { - VlnFlexGrid grd = new VlnFlexGrid(); // = rbtDefaultTable.Checked ? vlnFlexGrid2 : vlnFlexGrid3; - grd.InsertRowAfter(); + MyFlexGrid.InsertRowAfter(); } private void btnTblDgnInsertColumnBefore_Click(object sender, EventArgs e) { - VlnFlexGrid grd = new VlnFlexGrid(); // = rbtDefaultTable.Checked ? vlnFlexGrid2 : vlnFlexGrid3; - grd.InsertColumnBefore(); + MyFlexGrid.InsertColumnBefore(); } private void btnTblDgnInsertColumnAfter_Click(object sender, EventArgs e) { - VlnFlexGrid grd = new VlnFlexGrid(); // = rbtDefaultTable.Checked ? vlnFlexGrid2 : vlnFlexGrid3; - grd.InsertColumnAfter(); + MyFlexGrid.InsertColumnAfter(); } private void btnTblDgnAdjustSize_Click(object sender, EventArgs e) { - VlnFlexGrid grd = new VlnFlexGrid();// rbtDefaultTable.Checked ? vlnFlexGrid2 : vlnFlexGrid3; - if (grd.Cols.Fixed == 0) + if (MyFlexGrid.Cols.Fixed == 0) { // set all the rows and columns to Fixed so that user can adjust the row/column size - grd.Cols.Fixed = grd.Cols.Count; - grd.Rows.Fixed = grd.Rows.Count; + MyFlexGrid.Cols.Fixed = MyFlexGrid.Cols.Count; + MyFlexGrid.Rows.Fixed = MyFlexGrid.Rows.Count; } else { // set grid back to "normal" mode - grd.Cols.Fixed = 0; - grd.Rows.Fixed = 0; + MyFlexGrid.Cols.Fixed = 0; + MyFlexGrid.Rows.Fixed = 0; } } #endregion #region Table Grid Border private void btnTblDgnTableBorderNone_Click(object sender, EventArgs e) { - VlnFlexGrid grd = new VlnFlexGrid(); // = rbtDefaultTable.Checked ? vlnFlexGrid2 : vlnFlexGrid3; - grd.SetTableBorder(C1.Win.C1FlexGrid.Util.BaseControls.BorderStyleEnum.None); + MyFlexGrid.SetTableBorder(C1.Win.C1FlexGrid.Util.BaseControls.BorderStyleEnum.None); } private void btnTblDgnTableBorderFixedSingle_Click(object sender, EventArgs e) { - VlnFlexGrid grd = new VlnFlexGrid(); // = rbtDefaultTable.Checked ? vlnFlexGrid2 : vlnFlexGrid3; - grd.SetTableBorder(C1.Win.C1FlexGrid.Util.BaseControls.BorderStyleEnum.FixedSingle); + MyFlexGrid.SetTableBorder(C1.Win.C1FlexGrid.Util.BaseControls.BorderStyleEnum.FixedSingle); } private void btnTblDgnTableBorderFixed3D_Click(object sender, EventArgs e) { - VlnFlexGrid grd = new VlnFlexGrid(); // = rbtDefaultTable.Checked ? vlnFlexGrid2 : vlnFlexGrid3; - grd.SetTableBorder(C1.Win.C1FlexGrid.Util.BaseControls.BorderStyleEnum.Fixed3D); + MyFlexGrid.SetTableBorder(C1.Win.C1FlexGrid.Util.BaseControls.BorderStyleEnum.Fixed3D); } private void btnTblDgnTableBorderLight3D_Click(object sender, EventArgs e) { - VlnFlexGrid grd = new VlnFlexGrid(); // = rbtDefaultTable.Checked ? vlnFlexGrid2 : vlnFlexGrid3; - grd.SetTableBorder(C1.Win.C1FlexGrid.Util.BaseControls.BorderStyleEnum.Light3D); + MyFlexGrid.SetTableBorder(C1.Win.C1FlexGrid.Util.BaseControls.BorderStyleEnum.Light3D); } private void btnTblDgnTableBorderXPThemes_Click(object sender, EventArgs e) { - VlnFlexGrid grd = new VlnFlexGrid(); // = rbtDefaultTable.Checked ? vlnFlexGrid2 : vlnFlexGrid3; - grd.SetTableBorder(C1.Win.C1FlexGrid.Util.BaseControls.BorderStyleEnum.XpThemes); + MyFlexGrid.SetTableBorder(C1.Win.C1FlexGrid.Util.BaseControls.BorderStyleEnum.XpThemes); } #endregion #region Table Grid Grid Style private void btnTblDgnGridStyleNone_Click(object sender, EventArgs e) { - VlnFlexGrid grd = new VlnFlexGrid();//rbtDefaultTable.Checked ? vlnFlexGrid2 : vlnFlexGrid3; - grd.ChangeCellBorder(grd.Selection, C1.Win.C1FlexGrid.BorderStyleEnum.None); + MyFlexGrid.ChangeCellBorder(MyFlexGrid.Selection, C1.Win.C1FlexGrid.BorderStyleEnum.None); } private void btnTblDgnGridStyleFlat_Click(object sender, EventArgs e) { - VlnFlexGrid grd = new VlnFlexGrid(); // = rbtDefaultTable.Checked ? vlnFlexGrid2 : vlnFlexGrid3; - grd.ChangeCellBorder(grd.Selection, C1.Win.C1FlexGrid.BorderStyleEnum.Flat); + MyFlexGrid.ChangeCellBorder(MyFlexGrid.Selection, C1.Win.C1FlexGrid.BorderStyleEnum.Flat); } private void btnTblDgnGridStyleDouble_Click(object sender, EventArgs e) { - VlnFlexGrid grd = new VlnFlexGrid(); // = rbtDefaultTable.Checked ? vlnFlexGrid2 : vlnFlexGrid3; - grd.ChangeCellBorder(grd.Selection, C1.Win.C1FlexGrid.BorderStyleEnum.Double); + MyFlexGrid.ChangeCellBorder(MyFlexGrid.Selection, C1.Win.C1FlexGrid.BorderStyleEnum.Double); } private void btnTblDgnGridStyleRaised_Click(object sender, EventArgs e) { - VlnFlexGrid grd = new VlnFlexGrid(); // = rbtDefaultTable.Checked ? vlnFlexGrid2 : vlnFlexGrid3; - grd.ChangeCellBorder(grd.Selection, C1.Win.C1FlexGrid.BorderStyleEnum.Raised); + MyFlexGrid.ChangeCellBorder(MyFlexGrid.Selection, C1.Win.C1FlexGrid.BorderStyleEnum.Raised); } private void btnTblDgnGridStyleInset_Click(object sender, EventArgs e) { - VlnFlexGrid grd = new VlnFlexGrid(); // = rbtDefaultTable.Checked ? vlnFlexGrid2 : vlnFlexGrid3; - grd.ChangeCellBorder(grd.Selection, C1.Win.C1FlexGrid.BorderStyleEnum.Inset); + MyFlexGrid.ChangeCellBorder(MyFlexGrid.Selection, C1.Win.C1FlexGrid.BorderStyleEnum.Inset); } private void btnTblDgnGridStyleGroove_Click(object sender, EventArgs e) { - VlnFlexGrid grd = new VlnFlexGrid(); // = rbtDefaultTable.Checked ? vlnFlexGrid2 : vlnFlexGrid3; - grd.ChangeCellBorder(grd.Selection, C1.Win.C1FlexGrid.BorderStyleEnum.Groove); + MyFlexGrid.ChangeCellBorder(MyFlexGrid.Selection, C1.Win.C1FlexGrid.BorderStyleEnum.Groove); } private void btnTblDgnGridStyleFillet_Click(object sender, EventArgs e) { - VlnFlexGrid grd = new VlnFlexGrid(); // = rbtDefaultTable.Checked ? vlnFlexGrid2 : vlnFlexGrid3; - grd.ChangeCellBorder(grd.Selection, C1.Win.C1FlexGrid.BorderStyleEnum.Fillet); + MyFlexGrid.ChangeCellBorder(MyFlexGrid.Selection, C1.Win.C1FlexGrid.BorderStyleEnum.Fillet); } private void btnTblDgnGridStyleDotted_Click(object sender, EventArgs e) { - VlnFlexGrid grd = new VlnFlexGrid(); ; // = rbtDefaultTable.Checked ? vlnFlexGrid2 : vlnFlexGrid3; - grd.ChangeCellBorder(grd.Selection, C1.Win.C1FlexGrid.BorderStyleEnum.Dotted); + MyFlexGrid.ChangeCellBorder(MyFlexGrid.Selection, C1.Win.C1FlexGrid.BorderStyleEnum.Dotted); } #endregion diff --git a/PROMS/Volian.Controls.Library/StepTabRibbon.designer.cs b/PROMS/Volian.Controls.Library/StepTabRibbon.designer.cs index f2505a4da35867105811c631890881addf622a25..b1103fbe632d03ccd0d3072b2dd7c97eeecd3348 100644 GIT binary patch delta 742 zcmX|9OK4L;6n*c`q>XKTK4VSd!kETdL&&0n&7$-pZIF@{jiq!UB@G1^LMhQjb)izI z6@^fOqqz$knEosl7omYniBgJ-x{*+%Rt*Y4qzgY7yKo}}=j8=?n|sdOGxxkRcVWs= zo^qspof!TI4J;oCWq7a0iuy8GGcDcC6k9KnhD^SH?=XgEK*!{Oslam*k!OCXwNhx-Q)Q0y^tUwIhEf=auK$adVjH z>|x5wxYvev?n*X0=gZ_$l$xIS!dS%)+vj5yH%wa$u=2d0ZOosW4lat|q8cu;P;Ud; zPt%rU0i5Vsh9yI7!(suNk?(;fLIs#0n4XbXo@nCRXLzIH*OWSBm~x_aAI?@PF;Rq_ zdJI1Tx1rRLzEEegKVigSa30()OLd%*$zx`Z?jSatERk6>DzW1tYbVW%ZD2V%xA@dvrv(u8b%X z%CK@(xuV>VwZwSMqc&mm1FVbH0is(>$8rZW@#7N7Rr8WhR?W+(Rw6^B9(Qx92NRcN zV|&?q)`sdKdQju>pS1dRo$!`6VT46i0O+V#?)$znwZj*3av;Gjp!{U6%j-a9!gJMj6@}f z6v;@QheTqlJ$TU69Hs;cJxLL%5d=X*1A3?hrS+iHYH)TNbC_YiH*enizHeSFX`fEo zi@pd}%+y+{#J|XFF>b=j2C*ZxWR)C!(cfq}PJ6gP^inatN!Zm5$QBXr={Y zyQm4P9%^A_Zxky7ipC0wURHQyBxVwWc-KqS(sJU1(L`gJycc7?$qrV_4eI4JHZKmM zvW-Ra-cmVFslkS6Gr`Psc8kHwhv&DN({d+UeB7NHnc*Wda;%D7CTit-fgW*l*DrF1 z$cORGMcJv#;6la=S@z>x0M6j>CQ;G$msoghlXPwazjT1j1)Nv_XywP7V0t^Qt;ol+ z4gm`eD4TID4i*SVA-wK_5YM@R%2-^NEtuN_R$TH@4|6Saq3f&MVZ73I!o0b~C5=iK zq)XDIG$u`mbp=m(A&god%raj@<%JZvN9!!HdV{p%`wfydoZx@bB-kLVdxO>6Vv9Wx zB6P?F{Mg)}UYQ~`{yj@p?c)AZ8+Bvysfbvgkx7T_=hv1<%F{?Lu98-M=o|Ub#0K&z zU+e>_{HIarhj#wc4`tDu3%7VPgrzV$dZGu1!=Uo}Ly&ORL;JaJ3{G~}ksFH>!m#31 zm_4h9aQzkZ^Ym+Y+a`zk_-9z?!E?K*iC^~6+;hV|uDzq4as7`~^oNvyF%38sR7MPq XIIN$n!vk diff --git a/PROMS/Volian.Controls.Library/VlnFlexGrid.cs b/PROMS/Volian.Controls.Library/VlnFlexGrid.cs index 10b05e42..e4318fa9 100644 --- a/PROMS/Volian.Controls.Library/VlnFlexGrid.cs +++ b/PROMS/Volian.Controls.Library/VlnFlexGrid.cs @@ -8,17 +8,48 @@ using System.Windows.Forms; using System.Drawing; using System.Runtime.InteropServices; using Volian.Controls.Library; +using VEPROMS.CSLA.Library; using C1.Win.C1FlexGrid; namespace Volian.Controls.Library { + public delegate void VlnFlexGridEvent(object sender, EventArgs args); + public delegate void VlnFlexGridCursorMovementEvent(object sender, VlnFlexGridCursorMovementEventArgs args); public partial class VlnFlexGrid : C1.Win.C1FlexGrid.C1FlexGrid { + public event VlnFlexGridEvent OpenAnnotations; + public void OnOpenAnnotations(object sender, EventArgs args) + { + if (OpenAnnotations != null) OpenAnnotations(sender, args); + } + public event VlnFlexGridCursorMovementEvent CursorMovement; + internal void OnCursorMovement(object sender, VlnFlexGridCursorMovementEventArgs args) + { + if (CursorMovement != null) CursorMovement(sender, args); + } private TableCellEditor _tableCellEditor; - private TableClipBoardFuncts _clpbrdCpyPste; - private int _minSplitColWidth = 10; - private int _minSplitRowHeight = 20; + public TableCellEditor TableCellEditor + { + get { return _tableCellEditor; } + set { _tableCellEditor = value; } + } + private TableClipBoardFuncts _clpbrdCpyPste; + private int _minColSplitWidth = 10; + //private int _minRowSplitHeight = 23; + + //private int _minSplitColWidth = 10; + //private int _minSplitRowHeight = 20; + private E_ViewMode _vwMode = E_ViewMode.Edit; + public E_ViewMode VwMode + { + get { return _vwMode; } + set + { + _vwMode = value; + AllowEditing = _vwMode == E_ViewMode.Edit; + } + } #region Grid Initialize public VlnFlexGrid() @@ -33,14 +64,118 @@ namespace Volian.Controls.Library SetupGrid(rows, cols); } - public VlnFlexGrid(IContainer container) - { - container.Add(this); - - InitializeComponent(); - _tableCellEditor = new TableCellEditor(this); + public VlnFlexGrid(IContainer container) + { + container.Add(this); + InitializeComponent(); + SetupGrid(1, 1); } + //public VlnFlexGrid(IContainer container) + //{ + // container.Add(this); + + // InitializeComponent(); + // _tableCellEditor = new TableCellEditor(this); + // _tableCellEditor.ContentsResized += new ContentsResizedEventHandler(_tableCellEditor_ContentsResized); + //} + + void _tableCellEditor_ContentsResized(object sender, ContentsResizedEventArgs e) + { + if (_tableCellEditor._initializingEdit) return; + CellRange cr = GetMergedRange(Row, Col); + int oH = cr.UserData == null? 0 : (int)cr.UserData; + int nH = _tableCellEditor.ContentsRectangle.Height; + int Hadj = (nH - oH); + cr.UserData = _tableCellEditor.ContentsRectangle.Height; + int cellHeight = GetCellHeight(Row,Col); + int cellheightNLines = cellHeight / (Rows.DefaultSize - 3); + int nHNLines = nH / (Rows.DefaultSize - 3); + if (Hadj != 0) + { + int curHeight = (Rows[Row].Height == -1) ? Rows.DefaultSize : Rows[Row].Height; + //if (Hadj > 0 && cellHeight <= oH) + if (Hadj > 0 && cellheightNLines < nHNLines) + curHeight += (Rows.DefaultSize - 3); + if (Hadj < 0 && CanReduceRow()) + curHeight -= (Rows.DefaultSize-3); + Rows[Row].Height = curHeight; + AdjustGridControlSize(); + } + //cr.UserData = _tableCellEditor.ContentsRectangle.Height; + //int mh = GetMaxRowHeight(); + ////Rows[Row].Height = mh + 2; + //int h = 0; + //if (cr.r1 == cr.r2 && cr.c1 == cr.c2) + // h = Rows[Row].Height - 2; + //else + //{ + // for (int r = cr.r1; r <= cr.r2; r++) + // h += Rows[r].Height - 2; + //} + //Rows[Row].Height += (mh - h); + ////AdjustGridControlSize(); + } + private int GetCellHeight(int row, int col) + { + int height = 0; + CellRange cr = GetMergedRange(row, col); + for (int r = cr.r1; r <= cr.r2; r++) + { + height += (Rows[r].Height == -1) ? Rows.DefaultSize -3 : Rows[r].Height - 3; + } + return height; + } + private bool CanReduceRow() + { + int curRowHeight = (Rows[Row].Height == -1) ? Rows.DefaultSize - 3 : Rows[Row].Height -3; + int curRowHeightNLines = curRowHeight / (Rows.DefaultSize - 3); + bool bReduce = (curRowHeight > (Rows.DefaultSize - 3)); + if (bReduce) + { + for (int c = 0; c < Cols.Count; c++) + { + CellRange cr = GetMergedRange(Row, c); + if (Row >= cr.r1 && Row <= cr.r2) + { + int mergeCellHeightNLines = GetCellHeight(Row, c) / (Rows.DefaultSize - 3); + //int ud = (cr.UserData == null) ? 0 : (int)cr.UserData; + //if ((c != Col) && curRowHeight <= ud && ud >= mergeCellHeight) + // bReduce = false; + int ud = ((cr.UserData == null) ? 0 : (int)cr.UserData) / (Rows.DefaultSize - 3); + if ((c != Col) && curRowHeightNLines <= ud && ud >= mergeCellHeightNLines) + bReduce = false; + } + } + } + return bReduce; + } + //private int GetMaxRowHeight() + //{ + // int maxRTFHeight = _minRowSplitHeight; //Rows.DefaultSize;// the smallest a row can be + // Console.WriteLine("================================================================="); + // for (int c = 0; c < Cols.Count; c++) + // { + // CellRange cr = GetMergedRange(Row, c);//GetCellRange(Row, c); + // maxRTFHeight = Math.Max(maxRTFHeight, (int)cr.UserData); + // if (c==0) + // Console.WriteLine("Height in Row[{0}] = {1}", Row, Rows[Row].Height); + // Console.WriteLine("UserData Cell[{0},{1}] = {2}", Row, c, cr.UserData); + // } + // return maxRTFHeight; + //} + + //private bool IsInMergeRange(int row, int col) + //{ + // //foreach (CellRange cr in this.MergedRanges) + // //{ + // // if (cr.Contains(row, col)) + // // return true; // in a merged range + // //} + // CellRange cr = GetMergedRange(row, col); + // return (cr.r1 == row && cr.c1 == col); + //} + private void SetupGrid(int numrows, int numcols) //C1FlexGrid NewGrid() { // setup the default size of each cell in the table/grid @@ -70,25 +205,109 @@ namespace Volian.Controls.Library this.Styles.Highlight.BackColor = Color.LightCyan; this.Styles.Highlight.ForeColor = Color.Black; this.Styles.Focus.BackColor = Color.LightCyan; - this.HighLight = HighLightEnum.Always; + this.HighLight = HighLightEnum.WithFocus; this.AllowMerging = C1.Win.C1FlexGrid.AllowMergingEnum.Custom; this.AllowResizing = C1.Win.C1FlexGrid.AllowResizingEnum.Both; + _tableCellEditor = new TableCellEditor(this); + _tableCellEditor.ContentsResized += new ContentsResizedEventHandler(_tableCellEditor_ContentsResized); _clpbrdCpyPste = new TableClipBoardFuncts(); //this.Enter += new System.EventHandler(this.Grid_Enter); this.AfterResizeRow += new C1.Win.C1FlexGrid.RowColEventHandler(this.Grid_AfterResize); this.StartEdit += new C1.Win.C1FlexGrid.RowColEventHandler(this._StartEdit); this.AfterEdit += new C1.Win.C1FlexGrid.RowColEventHandler(this._AfterEdit); + //this.LeaveEdit += new RowColEventHandler(VlnFlexGrid_LeaveEdit); this.AfterScroll += new C1.Win.C1FlexGrid.RangeEventHandler(this._AfterScroll); this.AfterResizeColumn += new C1.Win.C1FlexGrid.RowColEventHandler(this.Grid_AfterResize); this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this._KeyPress); this.OwnerDrawCell += new OwnerDrawCellEventHandler(this.Grid_OwnerDrawCell); + this.LeaveCell += new EventHandler(VlnFlexGrid_LeaveCell); + //this.ValidateEdit += new ValidateEditEventHandler(VlnFlexGrid_ValidateEdit); + this.KeyDown += new KeyEventHandler(VlnFlexGrid_KeyDown); + this.KeyUp +=new KeyEventHandler(VlnFlexGrid_KeyUp); + this.SelChange += new EventHandler(VlnFlexGrid_SelChange); + TableCellEditor.EditMode = TableCellEditor.Visible; // need to comment out for compile for only jsj - 07FEB2011 } + void VlnFlexGrid_SelChange(object sender, EventArgs e) + { + // Possibilities + // Selection is a single cell + // It is part of a range + // It is + //Console.WriteLine("Where Am I {0} {1} {2}", Selection, GetMergedRange(Row, Col), Selection.Equals(GetMergedRange(Row, Col))); + } + void VlnFlexGrid_KeyUp(object sender, KeyEventArgs e) + { + if (e.Control) + { + if (e.Alt) + { + switch (e.KeyCode) + { + case Keys.M: + OnOpenAnnotations(this, new EventArgs()); + e.Handled = true; + break; + default: + break; + } + } + } + } + void VlnFlexGrid_KeyDown(object sender, KeyEventArgs e) + { + + switch (e.KeyCode) + { + case Keys.Left: + if (e.Shift) return; + _tableCellEditor.StepRTB_ArrowPressed(e.Control ? E_ArrowKeys.CtrlLeft : E_ArrowKeys.Left); + e.Handled = true; + break; + case Keys.Up: + if (e.Shift) return; + _tableCellEditor.StepRTB_ArrowPressed(e.Control ? E_ArrowKeys.CtrlUp : E_ArrowKeys.Up); + e.Handled = true; + break; + case Keys.Right: + if (e.Shift) return; + _tableCellEditor.StepRTB_ArrowPressed(e.Control ? E_ArrowKeys.CtrlRight : E_ArrowKeys.Right); + e.Handled = true; + break; + case Keys.Down: + if (e.Shift) return; + _tableCellEditor.StepRTB_ArrowPressed(e.Control ? E_ArrowKeys.CtrlDown : E_ArrowKeys.Down); + e.Handled = true; + break; + } + } + + void VlnFlexGrid_LeaveCell(object sender, EventArgs e) + { + //CellStyle csd = this.CursorCell.StyleDisplay; + //CellStyle cs = this.GetCellRange(Row, Col).Style; + //if (cs != null) + //{ + // Console.WriteLine("LeaveCell Style = {0}", cs.Name); + // Console.WriteLine("LeaveCell StyleDisplay = {0}", csd.Name); + // cs.ForeColor = Color.Black; + //} + CellStyle cs = this.Styles["Focus"]; + cs.ForeColor = Color.Black; + cs = this.Styles["Highlight"]; + cs.ForeColor = Color.Black; + } + + //void VlnFlexGrid_LeaveEdit(object sender, RowColEventArgs e) + //{ + // //Console.WriteLine("LeaveEdit Style = {0}", this.GetCellRange(e.Row, e.Col).Style.Name); + // this.GetCellRange(e.Row, e.Col).Style.ForeColor = Color.Black; + //} private void Grid_OwnerDrawCell(object sender, C1.Win.C1FlexGrid.OwnerDrawCellEventArgs e) { @@ -109,10 +328,14 @@ namespace Volian.Controls.Library // draw the RTF text if (e.Bounds.Width > 0 && e.Bounds.Height > 0) { + _rtf.Width = Cols[e.Col].Width; _rtf.Rtf = rtfText; _rtf.ForeColor = e.Style.ForeColor; _rtf.BackColor = e.Style.BackColor; _rtf.Render(e.Graphics, e.Bounds); + //CellRange cr = GetCellRange(e.Row, e.Col); + //Console.WriteLine("ownerDraw UserData [{0},{1}] = {2}", cr.r1, cr.c1, _rtf.ContentsRectangle.Height); + //cr.UserData = _rtf.ContentsRectangle.Height; } // and draw border last @@ -195,6 +418,64 @@ namespace Volian.Controls.Library } } + public void VerticalCenterText() + { + StepRTB myStepRTB = new StepRTB(); + CellRange selRange = this.Selection; + for (int r = selRange.r1; r <= selRange.r2; r++) + for (int c = selRange.c1; c <= selRange.c2; c++) + { + CellRange mr = this.GetMergedRange(r, c); + if (mr.r1 == r) + { + int editHeight = (int)mr.UserData; + int cellHeight = GetCellHeight(mr.r1, mr.c1); + if (editHeight < cellHeight) + { + myStepRTB.Rtf = (string)mr.Data; + RTBAPI.SetSpaceBefore(myStepRTB, (cellHeight - editHeight) / 2); + PutCellRTFString(mr.r1, mr.c1, myStepRTB.Rtf); + } + } + } + } + public void VerticalTopText() + { + StepRTB myStepRTB = new StepRTB(); + CellRange selRange = this.Selection; + for (int r = selRange.r1; r <= selRange.r2; r++) + for (int c = selRange.c1; c <= selRange.c2; c++) + { + CellRange mr = this.GetMergedRange(r, c); + if (mr.r1 == r) + { + myStepRTB.Rtf = (string)mr.Data; + RTBAPI.SetSpaceBefore(myStepRTB, 0); + PutCellRTFString(mr.r1, mr.c1, myStepRTB.Rtf); + } + } + } + public void VerticalBottomText() + { + StepRTB myStepRTB = new StepRTB(); + CellRange selRange = this.Selection; + for (int r = selRange.r1; r <= selRange.r2; r++) + for (int c = selRange.c1; c <= selRange.c2; c++) + { + CellRange mr = this.GetMergedRange(r, c); + if (mr.r1 == r) + { + int editHeight = (int)mr.UserData; + int cellHeight = GetCellHeight(mr.r1, mr.c1); + if (editHeight < cellHeight) + { + myStepRTB.Rtf = (string)mr.Data; + RTBAPI.SetSpaceBefore(myStepRTB, (cellHeight - editHeight)); + PutCellRTFString(mr.r1, mr.c1, myStepRTB.Rtf); + } + } + } + } //public void SetupCellStyles() //{ @@ -245,6 +526,7 @@ namespace Volian.Controls.Library int height = 0; foreach (C1.Win.C1FlexGrid.Row row in this.Rows) + //height += (row.Height >= 0) ? row.Height : this.Rows.DefaultSize + 2; height += (row.Height >= 0) ? row.Height : this.Rows.DefaultSize; this.Size = new Size(wid + difW, height + difH); @@ -293,6 +575,8 @@ namespace Volian.Controls.Library this[r, c] = trtb.Rtf; // save the cleaned up and processed cell text as RTF this.Select(r, c, false); + CellRange sel = this.Selection; + //sel.UserData = trtb.ContentsRectangle.Height; // Now see the the selected row,col is in the defined merge ranges bool mrgrows = false; @@ -315,23 +599,53 @@ namespace Volian.Controls.Library if (!mrgrows) { // add adjustment for grid and cell borders - int newheight = trtb.Height + 2;// (int)numGridLineBorderAdj.Value; + int newheight = trtb.Height + 3; //Console.WriteLine("{0} {1} {2} '{3}'", r, c, newheight,trtb.Text); if (newheight > this.Rows[r].Height) + { + //Console.WriteLine("1 Row {0} Old Height = {1}, New Height = {2}", r, Rows[r].Height, newheight); this.Rows[r].Height = newheight; + } } - // IF the column of the selected sell is NOT in merged range + // IF the column of the selected cell is NOT in merged range // then go ahead and adjust the column width (if needed) if (!mrgcols) { // add adjustment for grid and cell borders - int newwidth = trtb.Width + 2;//(int)numGridLineBorderAdj.Value; + int newwidth = trtb.Width + 2; if (newwidth > this.Cols[c].Width || AllowWidthShrink || r == 0) this.Cols[c].Width = newwidth; } } + if (mrgrows && tstr != null) + { + CellRange cr = GetMergedRange(r, c); + //Console.WriteLine("grid[{0},{1}] merge = {2}", r, c,cr); + if (cr.r1 == r && cr.c1 == c) + { + // if in merged rows, then make sure the cell's height is large enough + string[] strary = tstr.Split("\n".ToCharArray()); + // count number of lines of text + int nlines = strary.Length; + // count number of rows in merge range + int nrows = (cr.r2 - cr.r1) + 1; + //Console.WriteLine("2 Row {0} Height = {1}", cr.r1, Rows[cr.r1].Height); + while (nlines > nrows) + { + // add length to first row in merged range + int h = this.Rows[cr.r1].Height; + int defH = Rows.DefaultSize - 3; + //h = (h == -1) ? _minRowHeight * 2 : h + _minRowHeight; + h = (h == -1) ? (defH * 2) + 3 : h + defH; + //h = (h == -1) ? (Rows.DefaultSize + 2) * 2 : h + Rows.DefaultSize + 2; + //Console.WriteLine("3 Row {0} Old Height = {1}, New Height = {2}", cr.r1, Rows[cr.r1].Height, h); + this.Rows[cr.r1].Height = h; + nrows++; + } + } + } } private void Grid_AfterResize(object sender, C1.Win.C1FlexGrid.RowColEventArgs e) @@ -350,11 +664,14 @@ namespace Volian.Controls.Library // - adjust the grid dimensions based on the cell info. for (int r = 0; r < this.Rows.Count; r++) { - this.Rows[r].Height = 20;//10; + this.Rows[r].Height = Rows.DefaultSize;//_minRowHeight;//20;//10; for (int c = 0; c < this.Cols.Count; c++) this.AdjustGridHeightWidth(r, c); } + //this.Refresh(); + //Application.DoEvents(); this.AdjustGridControlSize(); + SetupCellUserData(); } private bool RemoveBoldUlineItalicChars(string str) @@ -442,6 +759,13 @@ namespace Volian.Controls.Library private void _StartEdit(object sender, C1.Win.C1FlexGrid.RowColEventArgs e) { // start editing the cell with the custom editor + //CellStyle cs = this.Styles["Focus"]; + ////CellStyle cs=this.GetCellRange(e.Row, e.Col).StyleNew; + ////cs.Name = string.Format("R{0}C{1}", e.Row, e.Col); + //cs.ForeColor = Color.White; + //cs = this.Styles["Highlight"]; + //cs.ForeColor = Color.LightCyan; + ////Console.WriteLine("Style = {0}",cs.Name); _tableCellEditor.StartEditing(e.Row, e.Col); e.Cancel = true; } @@ -449,6 +773,8 @@ namespace Volian.Controls.Library // after edit handler (built-in editors) private void _AfterEdit(object sender, C1.Win.C1FlexGrid.RowColEventArgs e) { + //Console.WriteLine("Style = {0}", this.GetCellRange(e.Row, e.Col).Style.Name); + this.GetCellRange(e.Row, e.Col).Style.ForeColor = Color.Black; this.AdjustGridControlSize(); } @@ -499,6 +825,24 @@ namespace Volian.Controls.Library if (dr == DialogResult.Yes) cr.Clear(ClearFlags.Content); } + public void SetupCellUserData() + { + for (int r = 0; r < Rows.Count; r++) + for (int c = 0; c < Cols.Count; c++) + { + string rtfText = GetDataDisplay(r, c); + if (rtfText.StartsWith(@"{\rtf")) + { + RTF _rtf = new RTF(); + _rtf.Width = Cols[c].Width; + _rtf.Rtf = rtfText; + CellRange cr = GetCellRange(r, c); + cr.UserData = _rtf.ContentsRectangle.Height; + //Console.WriteLine("ownerDraw UserData [{0},{1}] = {2}", cr.r1, cr.c1, _rtf.ContentsRectangle.Height); + } + } + } + #endregion //Cell Text #region Merged / Split Range @@ -550,7 +894,7 @@ namespace Volian.Controls.Library for (int c = cr.c1; c <= cr.c2; c++) { int recWidth = this.GetCellRect(cr.r1, c).Width; - this.Cols[c].Width = Math.Max(recWidth / 2, _minSplitColWidth); + this.Cols[c].Width = Math.Max(recWidth / 2, _minColSplitWidth); //Console.WriteLine("Cell[{0},{1}].Width = {2}", cr.r1, c, recWidth); } } @@ -586,7 +930,8 @@ namespace Volian.Controls.Library for (int r = cr.r1; r <= cr.r2; r++) { int recHeight = this.GetCellRect(r, cr.c1).Height; - this.Rows[r].Height = Math.Max(recHeight / 2, _minSplitRowHeight); + this.Rows[r].Height = Math.Max(recHeight / 2, Rows.DefaultSize); + //this.Rows[r].Height = Math.Max(recHeight / 2, _minRowSplitHeight); //Console.WriteLine("Cell[{0},{1}].Height = {2}", r, cr.c1, recHeight); } @@ -838,7 +1183,8 @@ namespace Volian.Controls.Library int newrow = this.GetRowInsertPosition(true); this.Rows.Insert(newrow); // set new row Height to same heidht as row from where it was inserted - this.Rows[newrow].Height = this.Rows[newrow+1].Height; + this.Rows[newrow].Height = (Rows[newrow + 1].Height == -1) ? Rows.DefaultSize : Rows[newrow + 1].Height; + //this.Rows[newrow].Height = this.Rows[newrow + 1].Height; this.AdjustMergedRows(newrow, true, false); this.AdjustGridControlSize(); } @@ -851,7 +1197,8 @@ namespace Volian.Controls.Library else this.Rows.Insert(rowidx + 1); // set new row Height to same heidht as row from where it was inserted - this.Rows[rowidx + 1].Height = this.Rows[rowidx].Height; + this.Rows[rowidx + 1].Height = (Rows[rowidx].Height == -1) ? Rows.DefaultSize : Rows[rowidx].Height; + //this.Rows[rowidx + 1].Height = this.Rows[rowidx].Height; this.AdjustMergedRows(rowidx + 1, false, false); this.AdjustGridControlSize(); } @@ -1460,7 +1807,44 @@ namespace Volian.Controls.Library } } } + for (int c = 0; c <= maxCol; c++) + for (int r = 0; r <= maxRow; r++) + { + if (this[r, c] != null) + { + string cellstr = this[r, c].ToString(); + this[r, c] = cellstr.TrimEnd(" \r\n\t".ToCharArray()); + CellRange cr = this.GetMergedRange(r, c); + if (cr.r1 != cr.r2) + TrimMergedRangeCellText(cr); + } + } + } + private void TrimMergedRangeCellText(CellRange cr) + { + // count number of newlines + string cellstr = this[cr.r1, cr.c1].ToString(); + string[] strary = cellstr.Split("\n".ToCharArray()); + int nlines = strary.Length; + // count number of rows in merge range + int nrows = (cr.r2 - cr.r1) + 1; + // if nlines > rows then trim blank lines from top + bool bNeedToTrim = (nlines > nrows); + string jstr = ""; + foreach (string tmpstr in strary) + { + int tlen = tmpstr.Trim().Length; + if (!bNeedToTrim || tlen > 0) + { + if (jstr.Length > 0) jstr += "\n"; + jstr += tmpstr; + } + else nlines--; + bNeedToTrim = (tlen == 0 && nlines > nrows); + } + this[cr.r1, cr.c1] = jstr; } + #endregion //Import / Export Grid #region Bug Work Around @@ -1628,15 +2012,17 @@ namespace Volian.Controls.Library private int _row, _col; private char _pendingKey; private bool _cancel; + public bool _initializingEdit; // constructor: attach to owner grid public TableCellEditor(VlnFlexGrid owner) { Visible = false; AutoSize = false; - BackColor = Color.Beige; + BackColor = Color.SkyBlue; BorderStyle = BorderStyle.None; + _initializingEdit = false; _pendingKey = (char)0; _cancel = false; _owner = owner; @@ -1650,10 +2036,11 @@ namespace Volian.Controls.Library // start editing: move to cell and activate public void StartEditing(int row, int col) { + _initializingEdit = true; // save coordinates of cell being edited _row = row; _col = col; - this.Clear(); + //this.Clear(); //jsj // assume we'll save the edits _cancel = false; // move editor over the current cell @@ -1685,6 +2072,7 @@ namespace Volian.Controls.Library // and get the focus Select(); + _initializingEdit = false; } void TableCellEditor_CursorKeyPress(object sender, KeyEventArgs args) @@ -1696,7 +2084,7 @@ namespace Volian.Controls.Library { int row = _owner.Selection.r1; int col = _owner.Selection.c1; - CellRange cr = _owner.Selection; + CellRange cr = _owner.GetMergedRange(row, col); //Console.WriteLine("keystroke {0} selection {1},{2}", args.Key, row, col); //vlnStackTrace.ShowStack("keystroke {0} selection {1},{2}", args.Key, row, col); _owner.Select(); @@ -1704,8 +2092,8 @@ namespace Volian.Controls.Library // if so, use the merged range instead of the selected range // so that we can jump to the top/bottom/left/right of the range // before attempting the move to the next grid cell. - int idx = _owner.MergedRanges.IndexOf(row, col); - if (idx > -1) cr = _owner.MergedRanges[idx]; + //int idx = _owner.MergedRanges.IndexOf(row, col); + //if (idx > -1) cr = _owner.MergedRanges[idx]; switch (args.Key) { @@ -1713,31 +2101,51 @@ namespace Volian.Controls.Library case VEPROMS.CSLA.Library.E_ArrowKeys.Down: row = cr.r2; if (row < _owner.Rows.Count - 1) - _owner.Select(row + 1, col); + _owner.Select(_owner.GetMergedRange(row + 1, col)); + else + _owner.OnCursorMovement(this, new VlnFlexGridCursorMovementEventArgs(args.Key)); break; case VEPROMS.CSLA.Library.E_ArrowKeys.CtrlLeft: case VEPROMS.CSLA.Library.E_ArrowKeys.Left: col = cr.c1; if (col > 0) - _owner.Select(row, col - 1); + _owner.Select(_owner.GetMergedRange(row, col - 1)); + else if(row > 0) + _owner.Select(_owner.GetMergedRange(row - 1, _owner.Cols.Count - 1)); + else + _owner.OnCursorMovement(this, new VlnFlexGridCursorMovementEventArgs(args.Key)); break; case VEPROMS.CSLA.Library.E_ArrowKeys.CtrlRight: case VEPROMS.CSLA.Library.E_ArrowKeys.Right: col = cr.c2; if (col < _owner.Cols.Count - 1) - _owner.Select(row, col + 1); + _owner.Select(_owner.GetMergedRange(row, col + 1)); + else if (cr.r2 < _owner.Rows.Count - 1) + { + CellRange crDest = _owner.GetMergedRange(cr.r2 + 1, 0); + if (cr.r2 < crDest.r1) // It will move to the correct place + _owner.Select(crDest); + else if (crDest.r2 < _owner.Rows.Count) + _owner.Select(_owner.GetMergedRange(crDest.r2 + 1, 0)); + else + _owner.OnCursorMovement(this, new VlnFlexGridCursorMovementEventArgs(args.Key)); + } + else + _owner.OnCursorMovement(this, new VlnFlexGridCursorMovementEventArgs(args.Key)); break; case VEPROMS.CSLA.Library.E_ArrowKeys.CtrlUp: case VEPROMS.CSLA.Library.E_ArrowKeys.Up: row = cr.r1; if (row > 0) - _owner.Select(row - 1, col); + _owner.Select(_owner.GetMergedRange(row - 1, col)); + else + _owner.OnCursorMovement(this, new VlnFlexGridCursorMovementEventArgs(args.Key)); break; default: break; } //Console.WriteLine("selection {0}", _owner.Selection); - _owner.Focus(); // focus was jumping out of the grid this keeps it in. + //_owner.Focus(); // focus was jumping out of the grid this keeps it in. } // after edit handler (custom editor) @@ -2004,4 +2412,17 @@ namespace Volian.Controls.Library } #endregion // TableClipBoardFuncts Class + public class VlnFlexGridCursorMovementEventArgs + { + private E_ArrowKeys _Key; + public E_ArrowKeys Key + { + get { return _Key; } + set { _Key = value; } + } + public VlnFlexGridCursorMovementEventArgs(E_ArrowKeys key) + { + _Key = key; + } + } } diff --git a/PROMS/Volian.Controls.Library/VlnSpellCheck.cs b/PROMS/Volian.Controls.Library/VlnSpellCheck.cs index b1356995..4b5496e8 100644 --- a/PROMS/Volian.Controls.Library/VlnSpellCheck.cs +++ b/PROMS/Volian.Controls.Library/VlnSpellCheck.cs @@ -7,13 +7,13 @@ namespace Volian.Controls.Library { public class VlnSpellCheck { - private RTBItem _MyRTBItem; - public RTBItem MyRTBItem + private EditItem _MyEditItem; + public EditItem MyEditItem { - get { return _MyRTBItem; } + get { return _MyEditItem; } set { - _MyRTBItem = value; + _MyEditItem = value; } } @@ -24,14 +24,14 @@ namespace Volian.Controls.Library public void DoSpellCheck() { - while (MyRTBItem.MyStepRTB.SpellCheckNext()) + while (MyEditItem.SpellCheckNext()) { - ItemInfo next = MyRTBItem.MyItemInfo.SearchNext; + ItemInfo next = MyEditItem.MyItemInfo.SearchNext; if (next.IsSection) return; // spell check only current section - MyRTBItem.MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OpenItem(next); + MyEditItem.MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OpenItem(next); } - MyRTBItem.MyStepRTB.Focus(); + MyEditItem.SetFocus(); } }