From 271c1ce923a25470d0a572038e391ea5d4dfc0eb Mon Sep 17 00:00:00 2001 From: John Date: Tue, 26 Apr 2011 20:01:48 +0000 Subject: [PATCH] --- PROMS/Volian.Controls.Library/EditItem.cs | 2 +- PROMS/Volian.Controls.Library/GridItem.cs | 9 +++-- PROMS/Volian.Controls.Library/StepPanel.cs | 6 +++- PROMS/Volian.Controls.Library/VlnFlexGrid.cs | 36 ++++++++++++++++++++ 4 files changed, 48 insertions(+), 5 deletions(-) diff --git a/PROMS/Volian.Controls.Library/EditItem.cs b/PROMS/Volian.Controls.Library/EditItem.cs index 1980670e..a5375a0f 100644 --- a/PROMS/Volian.Controls.Library/EditItem.cs +++ b/PROMS/Volian.Controls.Library/EditItem.cs @@ -1927,7 +1927,7 @@ namespace Volian.Controls.Library } protected void SetupEditItem(ItemInfo itemInfo, StepPanel myStepPanel, EditItem myParentEditItem, ChildRelation myChildRelation, bool expand, EditItem nextEditItem) { - if (itemInfo.ItemID == 10366) Console.WriteLine("Here"); + //if (itemInfo.ItemID == 10366) Console.WriteLine("Here"); //if (itemInfo.ItemID == 225) _MyStepRTB.Resize += new EventHandler(_MyStepRTB_Resize); //_MyStepRTB.MyRTBItem = this; //// TIMING: DisplayItem.TimeIt("CSLARTB InitComp"); diff --git a/PROMS/Volian.Controls.Library/GridItem.cs b/PROMS/Volian.Controls.Library/GridItem.cs index 348a03c7..3f9b9a93 100644 --- a/PROMS/Volian.Controls.Library/GridItem.cs +++ b/PROMS/Volian.Controls.Library/GridItem.cs @@ -46,6 +46,7 @@ namespace Volian.Controls.Library } void MyFlexGrid_Resize(object sender, EventArgs e) { + if (MyFlexGrid.ReadingXml) return; this.Size = new Size(MyFlexGrid.Width + GridMargin, MyFlexGrid.Height + GridMargin); AdjustTableWidthAndLocation(); AdjustLocation(); @@ -202,10 +203,11 @@ namespace Volian.Controls.Library private string _OrigRtf; // used to store original rtf to allow for 'escape' key restore void MyFlexGrid_SelChange(object sender, EventArgs e) { - if (Initializing) return; + //if (Initializing) return; //Volian.Base.Library.vlnStackTrace.ShowStackLocal("MyFlexGrid_SelChange {0}",MyFlexGrid.Selection); RTBLastFocus = false; MyStepRTB.Visible = false; // Hide the editor if the Selection Changes + if (Initializing) return; if (MyFlexGrid.Selection.IsSingleCell && MyFlexGrid.Row >= 0 && MyFlexGrid.Col >= 0) { object obj = MyFlexGrid[MyFlexGrid.Row, MyFlexGrid.Col]; @@ -334,6 +336,7 @@ namespace Volian.Controls.Library } public override void RefreshContent() { + _ActiveMode = MyFlexGrid.ContainsFocus; using (Grid myGrid = MyItemInfo.MyContent.MyGrid.Get()) { MyItemInfo.MyContent.MyGrid.ResetContent(myGrid); @@ -562,8 +565,8 @@ namespace Volian.Controls.Library { Focus(); MyFlexGrid.Focus(); - if (!MyFlexGrid.IsRoTable) // Table ROs are none editable - don't select a table cell - MyFlexGrid.Select(0, 0); + //if (!MyFlexGrid.IsRoTable) // Table ROs are none editable - don't select a table cell + // MyFlexGrid.Select(0, 0); } else { diff --git a/PROMS/Volian.Controls.Library/StepPanel.cs b/PROMS/Volian.Controls.Library/StepPanel.cs index b922252f..d47d21ec 100644 --- a/PROMS/Volian.Controls.Library/StepPanel.cs +++ b/PROMS/Volian.Controls.Library/StepPanel.cs @@ -438,7 +438,8 @@ namespace Volian.Controls.Library else { lastEI.SaveContents(); - lastEI.RefreshDisplay(false); + if (!(lastEI.MyItemInfo.IsTable)) + lastEI.RefreshDisplay(false); } } _SelectedEditItem = value; @@ -446,7 +447,10 @@ namespace Volian.Controls.Library { _SelectedEditItem.RefreshDisplay(true); if (_SelectedItemInfo.ItemID != value.MyItemInfo.ItemID) + { + ExpandAsNeeded(value.MyItemInfo); SelectedItemInfo = value.MyItemInfo; + } } if (lastEI != null) lastEI.IdentifyMe(false); diff --git a/PROMS/Volian.Controls.Library/VlnFlexGrid.cs b/PROMS/Volian.Controls.Library/VlnFlexGrid.cs index b2b0530a..fd172a77 100644 --- a/PROMS/Volian.Controls.Library/VlnFlexGrid.cs +++ b/PROMS/Volian.Controls.Library/VlnFlexGrid.cs @@ -524,6 +524,12 @@ namespace Volian.Controls.Library CellRange cr = GetMergedRange(row, col); return (cr.r1 == row && cr.c1 == col); } + private bool _ReadingXml = false; + + public bool ReadingXml + { + get { return _ReadingXml; } + } private static Regex _ReplaceVESymbFix = new Regex(@"({\\f[0-9]+[^ ]* )(VESymbFix)(;})"); private static Regex _ReplaceArialUnicodeMS = new Regex(@"({\\f[0-9]+[^ ]* )(Arial Unicode MS)(;})"); private static Regex _ReplaceTextFont = new Regex(@"({\\f[0-9]+[^ ]* )(?((?!VESymbFix)(?!Arial Unicode MS))([^;]*)|(!!!!))(;})"); @@ -555,12 +561,17 @@ namespace Volian.Controls.Library } Clear(); MergedRanges.Clear(); + _ReadingXml = true; + //Console.WriteLine("LoadGrid - Before ReadXML"); using (StringReader sr = new StringReader(str)) { ReadXml(sr); this.BorderStyle = C1.Win.C1FlexGrid.Util.BaseControls.BorderStyleEnum.None; sr.Close(); } + //Console.WriteLine("LoadGrid - After ReadXML"); + _ReadingXml = false; + Select(-1, -1); // this keeps the cell from being selected when the grid is first displayed Visible = true; } @@ -617,8 +628,33 @@ namespace Volian.Controls.Library this.KeyDown += new KeyEventHandler(VlnFlexGrid_KeyDown); this.KeyUp +=new KeyEventHandler(VlnFlexGrid_KeyUp); TableCellEditor.EditMode = TableCellEditor.Visible; // need to comment out for compile for only jsj - 07FEB2011 + this.MouseDown += new MouseEventHandler(VlnFlexGrid_MouseDown); } + void VlnFlexGrid_MouseDown(object sender, MouseEventArgs e) + { + int left = 0; + int top = 0; + int col = 0; + int row = 0; + while (e.X > left && col < Cols.Count) + { + left += Cols[col].Width > 0 ? Cols[col].Width : Cols.DefaultSize; + col++; + } + while (e.Y > top && row < Rows.Count) + { + top += Rows[row].Height > 0 ? Rows[row].Height : Rows.DefaultSize; + row++; + } + col--; + row--; + //Console.WriteLine("Mousedown Row, Col [{0},{1}]", row, col); + Select(row, col); + } + + + void _tableCellEditor_HeightChanged(object sender, EventArgs args) { if (_tableCellEditor._initializingEdit || !_tableCellEditor.Visible) return;