using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Text; using System.Text.RegularExpressions; using System.Windows.Forms; using System.Xml; using VEPROMS.CSLA.Library; using Volian.Base.Library; using C1.Win.C1FlexGrid; namespace Volian.Controls.Library { public partial class GridItem : EditItem { /* * TODO: (2/16/11) * 1) KBR Need to include/handle StepRTB/EditItem Events: Add for grid items, the events that * are handled by StepRTB/EditItem. Should these be abstract events within EditItem so * that it 'tells' you which events you need. * May Need yet: * OnOpenContextMenu (grid and/or rtb) * OnSetMenu?? - related to context menu * 2) KBR ContextMenu for table. May want it to function in a similar way to spellcheck, with * the contentmenu to support table options and a last item that supports existing * contextmenu * 3) When data migration of tables, need to include the font if there is a symbol. Move * AddFontTable from StepRTB.cs to a place accessible, such as volian.base. And then * in data migration, will need to know if a font is fixed. * 4) KBR Paste step crashes. Look at when doing insert. */ #region Fields public VlnFlexGrid MyFlexGrid { get { return _MyFlexGrid; } set { _MyFlexGrid = value; } } private int _GridMargin = 11; /// /// Margin between the EditItem and the VlnFlexGrid. Appears on the Right. /// Will allow space to draw a Change Bar on the right side of the EditItem. /// public int GridMargin { get { return _GridMargin; } set { _GridMargin = value; } } #endregion #region Event Handlers /// /// Raises an ItemClick event when the user clicks on the Tab /// /// /// private void lblTab_MouseDown(object sender, MouseEventArgs e) { MyStepPanel.OnItemClick(this, new StepPanelEventArgs(this, e)); } void MyFlexGrid_Resize(object sender, EventArgs e) { if (MyItemInfo != null && MyItemInfo.ItemID == 14) { //Console.WriteLine("{0},{1},{2}", MyFlexGrid.Height, MyStepRTB.ContentsRectangle.Height,MyFlexGrid.Rows[0].Height); if (MyFlexGrid.Height < MyStepRTB.ContentsRectangle.Height) MyFlexGrid.Height = 4 + MyStepRTB.ContentsRectangle.Height; } this.Size = new Size(MyFlexGrid.Width + GridMargin, MyFlexGrid.Height + GridMargin); AdjustTableWidthAndLocation(); AdjustLocation(); } void MyFlexGrid_Enter(object sender, EventArgs e) { if (MyStepPanel.DisplayItemChanging) return; MyStepRTB.MyItemInfo = MyItemInfo; // should be in vlnFlexGrid MyStepPanel.SelectedEditItem = this; } void MyFlexGrid_KeyDown(object sender, KeyEventArgs e) { switch (e.KeyCode) { case Keys.Left: if (e.Shift) return; MyStepRTB.StepRTB_ArrowPressed(e.Control ? E_ArrowKeys.CtrlLeft : E_ArrowKeys.Left); e.Handled = true; break; case Keys.Up: if (e.Shift) return; MyStepRTB.StepRTB_ArrowPressed(e.Control ? E_ArrowKeys.CtrlUp : E_ArrowKeys.Up); e.Handled = true; break; case Keys.Right: if (e.Shift) return; MyStepRTB.StepRTB_ArrowPressed(e.Control ? E_ArrowKeys.CtrlRight : E_ArrowKeys.Right); e.Handled = true; break; case Keys.Down: if (e.Shift) return; MyStepRTB.StepRTB_ArrowPressed(e.Control ? E_ArrowKeys.CtrlDown : E_ArrowKeys.Down); e.Handled = true; break; case Keys.F5: if (e.Shift) { e.Handled = true; if (!CheckClipboard()) return; // check if 'clipboard' contains a step. SetMenu("StepPaste"); } else if (!e.Control && !e.Alt) { e.Handled = true; CopyStep(); } break; } } void SetMenu(string contentMenu) { if (contentMenu == null) MyStepPanel.MyStepTabPanel.MyStepTabRibbon.ClearContextMenu(); else if (contentMenu == "OpenContextMenu") MyStepPanel.MyStepTabPanel.MyStepTabRibbon.SetContextMenu(); else MyStepPanel.MyStepTabPanel.MyStepTabRibbon.SetShortCutContextMenu(contentMenu); } void MyFlexGrid_CursorMovement(object sender, VlnFlexGridCursorMovementEventArgs args) { MyStepPanel.CursorMovement(this,new Point(0,0), args.Key); } void MyStepRTB_LinkModifyTran(object sender, StepPanelLinkEventArgs args) { MyStepPanel.OnLinkModifyTran(sender, args); } void MyStepRTB_LinkModifyRO(object sender, StepPanelLinkEventArgs args) { MyStepPanel.OnLinkModifyRO(sender, args); } void MyStepRTB_LinkGoTo(object sender, StepPanelLinkEventArgs args) { MyStepPanel.OnLinkClicked(sender, args); } void MyStepRTB_CursorKeyPress(object sender, KeyEventArgs args) { MyStepPanel.StepCursorKeys(this, args); } void MyStepRTB_AdjustTableWidth(object sender, StepRTBTableWidthEventArgs args) { //if ((!_MyItemInfo.IsSection && !_MyItemInfo.IsProcedure) && (_MyItemInfo.IsTable || _MyItemInfo.IsFigure)) if (args.EditMode) { int colR = MyStepPanel.ToDisplay(MyStepSectionLayoutData.ColRTable, MyItemInfo.ColumnMode); int widS = /* _WidthAdjust + borderWidth + */ MyStepPanel.ToDisplay(MyStepSectionLayoutData.WidSTableEdit, MyItemInfo.ColumnMode); int wNew = 70 + widS + colR * MyItemInfo.ColumnMode; if (wNew > ItemWidth) { ItemWidth = wNew; ItemLocation = TableLocation(MyParentEditItem, MyStepSectionLayoutData, wNew); } } else { int newwidth = MyFlexGrid.Width; if (ItemWidth != newwidth) { ItemWidth = newwidth; ItemLocation = TableLocation(MyParentEditItem, MyStepSectionLayoutData, newwidth); } } } bool MyStepRTB_IsNotCurrentSelection(object sender, EventArgs args) { return MyStepPanel.SelectedEditItem != this; } void MyStepRTB_OpenAnnotations(object sender, EventArgs args) { OpenAnnotations(); } void MyFlexGrid_OpenAnnotations(object sender, EventArgs args) { OpenAnnotations(); } void MyStepRTB_DoMouseWheel(object sender, MouseEventArgs args) { DoMouseWheel(args); } void MyStepRTB_DoSaveContents(object sender, EventArgs args) { if (MyFlexGrid.Row >= 0 && MyFlexGrid.Col >= 0) // Only if a Cell is Selected MyFlexGrid[MyFlexGrid.Row, MyFlexGrid.Col] = MyStepRTB.Rtf = MyStepRTB.DoNewLinkInGridCell(); SaveContents(); } void MyStepRTB_VisibleChanged(object sender, EventArgs e) { MyStepRTB.EditMode = MyStepRTB.Visible; //Console.WriteLine("GridItem: EditMode = {0}", MyStepRTB.EditMode); } void MyStepRTB_ReturnToEditor(object sender, EventArgs args) { MyFlexGrid.Focus(); MyFlexGrid.StartEditing(); } void MyFlexGrid_Click(object sender, EventArgs e) { MyFlexGrid.Focus(); } void MyStepRTB_EditModeChanged(object sender, EventArgs args) { AdjustColorsForEditMode(); } private void AdjustColorsForEditMode() { if (MyStepRTB.EditMode) { MyFlexGrid.Styles["Focus"].ForeColor = MyFlexGrid.Styles["Focus"].BackColor = MyFlexGrid.Styles["Highlight"].ForeColor = MyFlexGrid.Styles["Highlight"].BackColor = Color.SkyBlue; } else { MyFlexGrid.Styles["Focus"].ForeColor = MyFlexGrid.Styles["Highlight"].ForeColor = Color.Black; MyFlexGrid.Styles["Focus"].BackColor = MyFlexGrid.Styles["Highlight"].BackColor = Color.LightCyan; } } private string _OrigRtf; // used to store original rtf to allow for 'escape' key restore void MyFlexGrid_SelChange(object sender, EventArgs e) { RTBLastFocus = false; MyStepRTB.Visible = false; // Hide the editor if the Selection Changes if (MyFlexGrid.Selection.IsSingleCell && MyFlexGrid.Row >= 0 && MyFlexGrid.Col >= 0) { object obj = MyFlexGrid[MyFlexGrid.Row, MyFlexGrid.Col]; _OrigRtf = obj == null ? string.Empty : obj.ToString(); } } void MyStepRTB_KeyDown(object sender, KeyEventArgs e) { if (!e.Control && !e.Shift && !e.Alt && e.KeyCode == Keys.Escape && MyStepRTB.EditMode) { MyStepRTB.Rtf = _OrigRtf; MyFlexGrid.Select(MyFlexGrid.Selection); } } #endregion // Event Handlers #region Constructors public GridItem() { InitializeComponent(); } public GridItem(ItemInfo itemInfo, StepPanel myStepPanel, EditItem myParentEditItem, ChildRelation myChildRelation, bool expand) { InitializeComponent(); SetupEventHandlers(); SetupEditItem(itemInfo, myStepPanel, myParentEditItem, myChildRelation, expand, null); //RefreshDisplay(true); //TODO: is the argument true? } public GridItem(ItemInfo itemInfo, StepPanel myStepPanel, EditItem myParentEditItem, ChildRelation myChildRelation, bool expand, EditItem nextEditItem) { InitializeComponent(); SetupEventHandlers(); SetupEditItem(itemInfo, myStepPanel, myParentEditItem, myChildRelation, expand, nextEditItem); //RefreshDisplay(true); //TODO: is the argument true? } private void SetupEventHandlers() { this.MyFlexGrid.Resize += new EventHandler(MyFlexGrid_Resize); this.MyFlexGrid.Enter += new EventHandler(MyFlexGrid_Enter); this.MyFlexGrid.CursorMovement += new VlnFlexGridCursorMovementEvent(MyFlexGrid_CursorMovement); this.MyFlexGrid.OpenAnnotations += new VlnFlexGridEvent(MyFlexGrid_OpenAnnotations); this.MyFlexGrid.KeyDown +=new KeyEventHandler(MyFlexGrid_KeyDown); this.MyStepRTB.LinkGoTo += new StepRTBLinkEvent(MyStepRTB_LinkGoTo); this.MyStepRTB.LinkModifyRO += new StepRTBLinkEvent(MyStepRTB_LinkModifyRO); this.MyStepRTB.LinkModifyTran += new StepRTBLinkEvent(MyStepRTB_LinkModifyTran); this.MyStepRTB.CursorKeyPress += new StepRTBCursorKeysEvent(MyStepRTB_CursorKeyPress); this.MyStepRTB.AdjustTableWidth += new StepRTBTableWidthEvent(MyStepRTB_AdjustTableWidth); this.MyStepRTB.IsNotCurrentSelection += new StepRTBBooleanEvent(MyStepRTB_IsNotCurrentSelection); this.MyStepRTB.OpenAnnotations += new StepRTBEvent(MyStepRTB_OpenAnnotations); this.MyStepRTB.DoMouseWheel += new StepRTBMouseEvent(MyStepRTB_DoMouseWheel); this.MyStepRTB.DoSaveContents += new StepRTBEvent(MyStepRTB_DoSaveContents); this.MyStepRTB.VisibleChanged += new EventHandler(MyStepRTB_VisibleChanged); this.MyStepRTB.ReturnToEditor += new StepRTBEvent(MyStepRTB_ReturnToEditor); this.MyFlexGrid.Click += new EventHandler(MyFlexGrid_Click); this.MyStepRTB.EditModeChanged += new StepRTBEvent(MyStepRTB_EditModeChanged); this.MyStepRTB.KeyDown += new KeyEventHandler(MyStepRTB_KeyDown); this.MyFlexGrid.SelChange += new EventHandler(MyFlexGrid_SelChange); this.MyStepRTB.GotFocus += new EventHandler(MyStepRTB_GotFocus); } void MyStepRTB_GotFocus(object sender, EventArgs e) { RTBLastFocus = true; } #endregion #region Override Method and Properties public override int BorderWidth { get { return (MyFlexGrid.Width - MyFlexGrid.ClientRectangle.Width); } } public override Point ContentLocation { get { return new Point(Location.X + MyFlexGrid.Left, Location.Y); } set { Location = new Point(value.X - MyFlexGrid.Left, value.Y); } } public override string TabFormat { get { return _TabFormat; } set { _TabFormat = value; } } public override void AdjustTableWidthAndLocation() { //_MyStepRTB.Font = MyStepData.Font.WindowsFont; //ItemWidth = (int)GetTableWidth(MyStepRTB.Font, MyItemInfo.MyContent.Text, true); //ItemWidth = MyFlexGrid.Width; ItemLocation = new Point(50, _MyParentEditItem.Bottom); ItemLocation = TableLocation(_MyParentEditItem, MyStepSectionLayoutData, ItemWidth); } public override void SetToolTip(string tip) { DevComponents.DotNetBar.SuperTooltipInfo tpi = new DevComponents.DotNetBar.SuperTooltipInfo("", "", tip, null, null, DevComponents.DotNetBar.eTooltipColor.Lemon); _MyToolTip.MinimumTooltipSize = new Size(0, 24); _MyToolTip.TooltipDuration = 3; _MyToolTip.SetSuperTooltip(MyStepRTB, tpi); } public override void RefreshContent() { using (Grid myGrid = MyItemInfo.MyContent.MyGrid.Get()) { MyItemInfo.MyContent.MyGrid.ResetContent(myGrid); } RefreshDisplay(_ActiveMode); IdentifyMe(false); } public override int TableWidth { get { return 0; } } // DONE public override int ItemLeft { get { return Left + lblTab.Left; } set { Left = value - lblTab.Left; } } public override int ContentLeft { get { return Left + MyFlexGrid.Left; } } public override int ContentWidth { get { return MyFlexGrid.Width; } set { Width = value + lblTab.Left + lblTab.Width; } } public override Point ItemLocation { get { return new Point(Location.X + lblTab.Left, Location.Y); } set { Location = new Point(value.X - lblTab.Left, value.Y); } } public override int ItemWidth { get { return Width - lblTab.Left; } set { Width = GridMargin + value + lblTab.Left; } } public override void RefreshOrdinal() { TabFormat = null; // Reset Tab } public override bool Expanded { get {return !Colapsing;} set {;} // Tables are always expanded. } public override void RefreshTab() { TabFormat = null;} public override void SetFocus() { MyFlexGrid.Focus();} public override void SaveContents() { List RtfRoUsageList = new List(); List RtfTransList = new List(); int r = 0; int c = 0; int w = MyFlexGrid.Cols.Count; int h = MyFlexGrid.Rows.Count; while (r < h) { CellRange cr = MyFlexGrid.GetMergedRange(r, c); if (cr.r1 == r && cr.c1 == c) { // see if there are any links and save these so that any deleted ROs or transitions in the // steprtb can have associated usages/transitions records removed from the database. string lookFor = string.Format(@""); MatchCollection matches = Regex.Matches((string)MyFlexGrid[r, c], lookFor); for (int i = matches.Count - 1; i >= 0; i--) { Match m = matches[i]; if (m != null && m.Groups.Count > 6 && m.Groups[6].ToString() == "ReferencedObject") { Regex regRefObj = new Regex(@"\#Link\:ReferencedObject\:([0-9]*) ([0-9a-zA-Z]*) ([0-9]*)", RegexOptions.Singleline); Match myMatch = regRefObj.Match(m.Value); if (myMatch.Success) { int usgid = int.Parse(myMatch.Groups[1].Value); RtfRoUsageList.Add(usgid); } } if (m != null && m.Groups.Count > 6 && m.Groups[6].ToString().StartsWith("Transition")) { Regex regRefObj = new Regex(@"\#Link\:Transition[a-zA-Z]*\:([0-9]*) ([0-9]*) ([0-9]*)", RegexOptions.Singleline); Match myMatch = regRefObj.Match(m.Value); if (myMatch.Success) { int tid = int.Parse(myMatch.Groups[2].Value); RtfTransList.Add(tid); } } } } c = c + 1; if (c == w) { c = 0; r = r + 1; } } // compare ro usages & transitions from database and list from grid contents // if in both lists, don't do anything // if only in database list, delete usage. // never will have condition where it is not in database list, but is in steprtb text list (this // case is handled when ro is inserted. if (MyItemInfo.MyContent.ContentRoUsages != null) { List delRoUsgs = new List(); foreach (RoUsageInfo ru in MyItemInfo.MyContent.ContentRoUsages) if (!RtfRoUsageList.Contains(ru.ROUsageID)) delRoUsgs.Add(ru.ROUsageID); foreach (int dRU in delRoUsgs) RoUsage.Delete(dRU); } if (MyItemInfo.MyContent.ContentTransitions != null) { List delTrans = new List(); foreach (TransitionInfo ti in MyItemInfo.MyContent.ContentTransitions) if (!RtfTransList.Contains(ti.TransitionID)) delTrans.Add(ti.TransitionID); foreach (int dt in delTrans) Transition.Delete(dt); } // now save the resulting Xml text, and the searchable text. bool success = FinishSave(MyFlexGrid.GetSearchableText()); if (success) { MyStepRTB.FindAllLinks(); MyStepRTB.OrigRTF = MyStepRTB.Rtf; MyStepRTB.ClearUndo(); } } private bool FinishSave(string searchableText) { string xml = MyFlexGrid.GetXMLData(); using (Item itm = MyItemInfo.Get()) { itm.MyContent.MyGrid.Data = xml; itm.MyContent.Text = searchableText; // what about the 'config' for ro tables. itm.Save(); MyItemInfo.MyContent.MyGrid.ResetContent(itm.MyContent.MyGrid); } return true; } public override bool CanExpand { get { return false; } set { ;} } public override void HandleResize() { ;} // DONE public override void MatchExpanded() { ;} // DONE public override void ItemSelect() { // Was getting an Error that _MyStepRTB was Disposed RHM 20101217 if (!MyFlexGrid.Disposing) { Focus(); MyFlexGrid.Focus(); MyFlexGrid.Select(0, 0); } else { _MyLog.WarnFormat("Attempt to give Focus to Disposed Object {0}", MyID); } ScrollToCenter(); } public override void ItemShow() { MyFlexGrid.Focus(); ScrollToCenter(); } public override StepRTB MyStepRTB { get { return MyFlexGrid.TableCellEditor; } } public override DialogResult ReplaceText(string rpltxt, string fndstr, bool caseSensitive, bool matchWholeWord, bool reverse, bool prompt, IWin32Window fndrpldlg) { int r = MyFlexGrid.Row; int c = MyFlexGrid.Col; if (!reverse) { int w = MyFlexGrid.Cols.Count; int h = MyFlexGrid.Rows.Count; while (r < h) { CellRange cr = MyFlexGrid.GetMergedRange(r, c); if (cr.r1 == r && cr.c1 == c) { int ss = MyStepRTB.SelectionStart; int sl = MyStepRTB.SelectionLength; MyFlexGrid.StartEditing(); MyStepRTB.Select(ss, sl); // need to reset selection because startediting positions to end. string oldRtf = MyStepRTB.Rtf; DialogResult dr = MyStepRTB.ReplaceText(rpltxt, fndstr, caseSensitive, matchWholeWord, reverse, prompt, fndrpldlg); if (oldRtf != MyStepRTB.Rtf) MyFlexGrid[r, c] = MyStepRTB.Rtf; if (dr == DialogResult.Yes || dr == DialogResult.Cancel) return dr; } c = c + 1; if (c == w) { c = 0; r = r + 1; } if (r < h) { MyFlexGrid.Select(r, c); MyStepRTB.Select(0, 0); } } } else // reverse { while (r >= 0) { CellRange cr = MyFlexGrid.GetMergedRange(r, c); if (cr.r1 == r && cr.c1 == c) { int ss = MyStepRTB.SelectionStart; int sl = MyStepRTB.SelectionLength; MyFlexGrid.StartEditing(); MyStepRTB.Select(ss, sl); string oldRtf = MyStepRTB.Rtf; DialogResult dr = MyStepRTB.ReplaceText(rpltxt, fndstr, caseSensitive, matchWholeWord, reverse, prompt, fndrpldlg); if (oldRtf != MyStepRTB.Rtf) MyFlexGrid[r, c] = MyStepRTB.Rtf; if (dr == DialogResult.Yes || dr == DialogResult.Cancel) return dr; } c = c - 1; if (c < 0) { c = MyFlexGrid.Cols.Count - 1; r = r - 1; } cr = MyFlexGrid.GetMergedRange(r, c); if (r >= 0 && cr.r1 == r && cr.c1 == c) { MyFlexGrid.Select(r, c); MyFlexGrid.StartEditing(); MyStepRTB.Select(MyStepRTB.Text.Length, 0); } } } return DialogResult.No; } public override bool FindText(string str, bool caseSensitive, bool matchWholeWord, bool reverse) { int r = MyFlexGrid.Row; int c = MyFlexGrid.Col; if (!reverse) { int w = MyFlexGrid.Cols.Count; int h = MyFlexGrid.Rows.Count; while (r < h) { CellRange cr = MyFlexGrid.GetMergedRange(r, c); if (cr.r1 == r && cr.c1 == c) { int ss = MyStepRTB.SelectionStart + MyStepRTB.SelectionLength; MyFlexGrid.StartEditing(); MyStepRTB.Select(ss, 0); // need to reset selection because startediting positions to end. bool scn = MyStepRTB.FindText(str, caseSensitive, matchWholeWord, reverse); if (scn) return true; } c = c + 1; if (c == w) { c = 0; r = r + 1; } if (r < h) { MyFlexGrid.Select(r, c); MyStepRTB.Select(0, 0); } } } else { while (r >= 0) { CellRange cr = MyFlexGrid.GetMergedRange(r, c); if (cr.r1 == r && cr.c1 == c) { int ss = MyStepRTB.SelectionStart; MyFlexGrid.StartEditing(); MyStepRTB.Select(ss, 0); bool scn = MyStepRTB.FindText(str, caseSensitive, matchWholeWord, reverse); if (scn) return true; } c = c - 1; if (c < 0) { c = MyFlexGrid.Cols.Count - 1; r = r - 1; } cr = MyFlexGrid.GetMergedRange(r, c); if (r >= 0 && cr.r1 == r && cr.c1 == c) { MyFlexGrid.Select(r, c); MyFlexGrid.StartEditing(); MyStepRTB.Select(MyStepRTB.Text.Length, 0); } } } return false; } public override void PositionToEnd() { int r = MyFlexGrid.Rows.Count - 1; int c = MyFlexGrid.Cols.Count - 1; MyFlexGrid.Select(r, c); while (r >= 0) { CellRange cr = MyFlexGrid.GetMergedRange(r, c); if (cr.r1 == r && cr.c1 == c) { MyFlexGrid.StartEditing(); return; } c = c - 1; if (c < 0) { c = MyFlexGrid.Cols.Count - 1; r = r - 1; } if (r >= 0) { MyFlexGrid.Select(r, c); MyStepRTB.Select(MyStepRTB.Text.Length, 0); } } } public override string SelectedTextForFind { get { StepRTB srtb = MyStepRTB; if (srtb.SelectionLength > 0) { if (srtb.IsSelectionLinked(srtb.SelectionStart, srtb.SelectionLength)) return srtb.SelectedText.Substring(0, srtb.SelectedText.IndexOf("#Link")); else return srtb.SelectedText; } return null; } } public override bool SpellCheckNext() { int r = MyFlexGrid.Row; int c = MyFlexGrid.Col; int w = MyFlexGrid.Cols.Count; int h = MyFlexGrid.Rows.Count; while (r < h) { CellRange cr = MyFlexGrid.GetMergedRange(r, c); if (cr.r1 == r && cr.c1 == c) { MyFlexGrid.Select(r, c); MyFlexGrid.StartEditing(); string oldRtf = MyStepRTB.Rtf; bool scn = MyStepRTB.SpellCheckNext(); if (oldRtf != MyStepRTB.Rtf) MyFlexGrid[r, c] = MyStepRTB.Rtf; if (!scn) return false; } c = c + 1; if (c == w) { c = 0; r = r + 1; } } return true; } public override void IdentifyMe(bool highlight) { if (highlight) { //for (int r = 0; r < MyFlexGrid.Rows.Count; r++) // for (int c = 0; c < MyFlexGrid.Cols.Count; c++) // { // CellStyle cs = MyFlexGrid.GetCellStyle(r, c); // CellRange cr = MyFlexGrid.GetCellRange(r, c); // Console.WriteLine("Style[{0},{1}] = '{2}' {3} '{4}'", r,c,cs.Name,cs.BackColor,cr.StyleNew.Name); // } MyFlexGrid.Styles["Alternate"].BackColor = MyFlexGrid.Styles["Normal"].BackColor = Color.Gray; } else { if (MyFlexGrid.Focused) // If active Set BackColor to the active color SetActive(); else // Otherwise Set the BackColor to either the InactiveColor or the AnnotationColor { MyFlexGrid.Styles["Alternate"].BackColor = MyFlexGrid.Styles["Normal"].BackColor = MyItemInfo.ItemAnnotationCount == 0 ? MyStepPanel.InactiveColor : MyStepPanel.AnnotationColor; // Turn-off Size adjustment MyFlexGrid.Cols.Fixed = 0; MyFlexGrid.Rows.Fixed = 0; } } } public override void SetActive() { AdjustColorsForEditMode(); } private bool _Empty = false; public override bool Empty { get { return _Empty; } set { _Empty = value; } } private bool _ActiveMode = false; public override void RefreshDisplay(bool activeMode) { _ActiveMode = activeMode; XmlDocument xd = new XmlDocument(); xd.LoadXml(MyItemInfo.MyContent.MyGrid.Data.Replace("Courier New", "Times New Roman")); //xd.LoadXml(MyItemInfo.MyContent.MyGrid.Data); MyFlexGrid.Clear(); MyFlexGrid.MergedRanges.Clear(); MyFlexGrid.ReadXml(xd); MyFlexGrid.AdjustGridControlSize(); // When a grid is read from XML, all of the styles are updated to the values in the XML. // Thus any specific settings need to be set after the grid is read. MyFlexGrid.Styles["Highlight"].BackColor = Color.LightCyan; MyFlexGrid.Styles["Focus"].BackColor = Color.LightCyan; MyFlexGrid.HighLight = activeMode ? C1.Win.C1FlexGrid.HighLightEnum.Always : C1.Win.C1FlexGrid.HighLightEnum.WithFocus; MyFlexGrid.VwMode = MyStepPanel.VwMode; } public override void ToggleEditView(E_ViewMode vwMode) { /* * TODO: * 1) SaveContents */ RefreshDisplay(false); MyFlexGrid.VwMode = vwMode; } public override int TabLeft { get { return lblTab.Left; } set { lblTab.Left = value; } } public override Font TabFont { get { return lblTab.Font; } set { lblTab.Font = value; } } public override string TabText { get { return lblTab.Text; } } public override Point TabLocation { get { return lblTab.Location; } } public override Font ContentFont { get { return MyFlexGrid.Font; } set { MyFlexGrid.Font = value; } } // TODO how do we know what font tables are in? public override float ContentTop { get { return MyFlexGrid.Top; } } public override void SetupHeader(ItemInfo itemInfo) { ;} // tables do not have headers public override void ShowExpanded() {;} public override void SetText() { RefreshDisplay(false); IdentifyMe(false); } public override void SetExpandAndExpander(ItemInfo itemInfo) { CanExpand = false; } // can't expand a table #endregion } }