diff --git a/PROMS/Volian.Controls.Library/DSOTabPanel.cs b/PROMS/Volian.Controls.Library/DSOTabPanel.cs index c76f6368..63d0b182 100644 --- a/PROMS/Volian.Controls.Library/DSOTabPanel.cs +++ b/PROMS/Volian.Controls.Library/DSOTabPanel.cs @@ -19,6 +19,11 @@ namespace Volian.Controls.Library private static int _Count = 0; private DocumentInfo _MyDocument; private int _MyCount; + public static int Count + { + get { return _Count; } + set { _Count = value; } + } private DisplayTabItem _TabItem; public DisplayTabItem TabItem { @@ -32,13 +37,11 @@ namespace Volian.Controls.Library SetupDSOTabPanel(); _MyDocument = documentInfo; SetupDSO(); - } - -private void SetupDSOTabPanel() -{ + private void SetupDSOTabPanel() + { Dock = System.Windows.Forms.DockStyle.Fill; -} + } public DocumentInfo DocumentInfo { get { return _MyDocument; } @@ -63,38 +66,30 @@ private void SetupDSOTabPanel() _MyCount = _Count; this._MyDSOFramer = new AxDSOFramer.AxFramerControl(); ((System.ComponentModel.ISupportInitialize)(this._MyDSOFramer)).BeginInit(); - //this.SuspendLayout(); this.Controls.Add(this._MyDSOFramer); this.components.Add(this._MyDSOFramer); this._MyDSOFramer.Dock = System.Windows.Forms.DockStyle.Fill; - //this._MyDSOFramer.Enabled = true; - //this._MyDSOFramer.Location = new System.Drawing.Point(0, 0); - //this._MyDSOFramer.Name = "_DSOFramer"; //System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(WordDSOTab)); //this._DSOFramer.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("_FC.OcxState"))); - //this._MyDSOFramer.Size = new System.Drawing.Size(657, 453); - //this._MyDSOFramer.TabIndex = 0; ((System.ComponentModel.ISupportInitialize)(this._MyDSOFramer)).EndInit(); - //this.ResumeLayout(false); - this._MyDSOFramer.EventsEnabled = true; this._MyDSOFramer.Open(DSOFile.MyFile.FullName); this._MyDSOFramer.Menubar = false; this._MyDSOFramer.Titlebar = false; - //this._DSOFramer.FrameHookPolicy = DSOFramer.dsoFrameHookPolicy.dsoSetOnFirstOpen; - if (_MyCount < 20) - this._MyDSOFramer.FrameHookPolicy = DSOFramer.dsoFrameHookPolicy.dsoResetNow; - this._MyDSOFramer.Invalidated += new InvalidateEventHandler(_DSOFramer_Invalidated); + //if (_MyCount < 20) + // this._MyDSOFramer.FrameHookPolicy = DSOFramer.dsoFrameHookPolicy.dsoResetNow; this._MyDSOFramer.BeforeDocumentClosed += new AxDSOFramer._DFramerCtlEvents_BeforeDocumentClosedEventHandler(_MyDSOFramer_BeforeDocumentClosed); - //this.Resize += new EventHandler(DSOTabPage_Resize); + this._MyDSOFramer.OnSaveCompleted += new AxDSOFramer._DFramerCtlEvents_OnSaveCompletedEventHandler(_MyDSOFramer_OnSaveCompleted); this.Enter += new EventHandler(DSOTabPanel_Enter); } + void _MyDSOFramer_OnSaveCompleted(object sender, AxDSOFramer._DFramerCtlEvents_OnSaveCompletedEvent e) + { + DSOFile.SaveFile(); + } void _MyDSOFramer_BeforeDocumentClosed(object sender, AxDSOFramer._DFramerCtlEvents_BeforeDocumentClosedEvent e) { try { SaveDirty(); - //if(SaveDirty()) e.cancel = true; - //throw new System.Data.DataException(); } catch (Exception ex) { @@ -105,8 +100,9 @@ private void SetupDSOTabPanel() { try { + _MyDSOFramer.EventsEnabled = true; _MyDSOFramer.FrameHookPolicy = DSOFramer.dsoFrameHookPolicy.dsoResetNow; - _MyDSOFramer.Focus(); + _MyTabControl.OnItemSelectedChanged(this, null); } catch (Exception ex) { @@ -133,7 +129,7 @@ private void SetupDSOTabPanel() if (_MyDSOFramer.IsDirty) { // TODO: Should be based upon Item rather than Document. - if (MessageBox.Show("Save changes to " + this.Name, "Document has Changed", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + if (MessageBox.Show("Save changes to " + _TabItem.MyItem.TabTitle + "\r\n" + _TabItem.MyItem.TabToolTip, "Document has Changed", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) return SaveDSO(); return false; } @@ -145,6 +141,7 @@ private void SetupDSOTabPanel() } public bool CloseDSO(bool force) { + _MyLog.Debug("CloseDSO"); bool result = true; try { @@ -153,6 +150,7 @@ private void SetupDSOTabPanel() components.Remove(_MyDSOFramer); _MyDSOFramer.Dispose(); _MyDSOFramer = null; + _Count--; } catch (Exception ex) { @@ -161,16 +159,6 @@ private void SetupDSOTabPanel() } return result; } - void _DSOFramer_Invalidated(object sender, InvalidateEventArgs e) - { - //ConsoleWriteLine("_DSOFramer_Invalidated"); - if (_MyCount >= 20) - _MyDSOFramer.Activate(); - } - //void DSOTabPage_Resize(object sender, EventArgs e) - //{ - // //_DSOFramer.Refresh(); - //} public void Activate() { try @@ -178,7 +166,6 @@ private void SetupDSOTabPanel() this._MyDSOFramer.Activate(); if (_MyCount < 20) this._MyDSOFramer.FrameHookPolicy = DSOFramer.dsoFrameHookPolicy.dsoResetNow; - //this._DSOFramer.FrameHookPolicy = DSOFramer.dsoFrameHookPolicy.dsoSetOnFirstOpen; } catch (Exception ex) { diff --git a/PROMS/Volian.Controls.Library/DisplayItem.cs b/PROMS/Volian.Controls.Library/DisplayItem.cs index 93779a80..607219c3 100644 --- a/PROMS/Volian.Controls.Library/DisplayItem.cs +++ b/PROMS/Volian.Controls.Library/DisplayItem.cs @@ -28,32 +28,14 @@ namespace Volian.Controls.Library Done = 16 } #endregion - //public delegate void vlnCSLARTBLinkEvent(object sender, vlnCSLARTBLinkEventArgs args); public partial class DisplayItem : UserControl { private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); #region Events - //public event vlnCSLARTBLinkEvent LinkClicked; - //private void OnLinkClicked(object sender, vlnCSLARTBLinkEventArgs args) - //{ - // if (LinkClicked != null) LinkClicked(sender, args); - // else MessageBox.Show(args.LinkInfo.LinkText, "Unhandled Link Click", MessageBoxButtons.OK, MessageBoxIcon.Information); - //} - //public event vlnCSLARTBEvent BeforeExpand; - //private void OnBeforeExpand(object sender, EventArgs args) - //{ - // if (BeforeExpand != null) BeforeExpand(sender, args); - //} - //public event vlnCSLARTBEvent BeforeColapse; - //private void OnBeforeColapse(object sender, EventArgs args) - //{ - // if (BeforeColapse != null) BeforeColapse(sender, args); - //} #endregion #region Private Fields private bool _ChildrenLoaded=false; private StepSectionLayoutData _Layout; - //private FormatInfo _ActiveFormat; private DisplayPanel _Panel; private ChildRelation _Relation; private bool _Loading = true; @@ -72,14 +54,10 @@ namespace Volian.Controls.Library { _MyItem = value; int typ = (int) value.MyContent.Type; - //TimeIt("f"); - //TabFormat = TemporaryFormat.TabFormat(this); - //TimeIt("g"); if (typ >= 20000) { int stepType = typ % 10000; _StepData = value.ActiveFormat.PlantFormat.FormatData.StepDataList[stepType]; - //_StepData = _ActiveFormat.PlantFormat.FormatData.StepDataList[stepType]; } if (value.MyContent.Type == 20001) Circle = true; @@ -87,14 +65,6 @@ namespace Volian.Controls.Library CheckOff = true; if ((value.ItemID % 25) == 0) ChangeBar = true; - //if (value != null) - //{ - // this.veRichTextBoxText.MyItem = value; - // //this.veRichTextBoxText.Text = _MyItem.MyContent.Text; - // //this.lblTab.Text = _MyItem.MyContent.Type < 20000 ? _MyItem.MyContent.Number : _MyItem.Ordinal.ToString(); - // //this.lblTab.Text = _MyItem.ItemID.ToString(); - // SetTab(); - //} } } private void SetText() @@ -102,7 +72,6 @@ namespace Volian.Controls.Library if (_MyItem != null) this._DisplayRTB.MyItem = _MyItem; } - //private static int _ColS = 8 * 120;//TODO: _layout.ColS private static int __WidthAdjust = 3; private DisplayItem _MyParent = null; public DisplayItem MyParent @@ -113,14 +82,9 @@ namespace Volian.Controls.Library _MyParent = value; if (_MyParent != null) { - //this.BackColor = Color.Red; - //TabFormat = TemporaryFormat.TabFormat(this); switch (_Relation) { case ChildRelation.None: // Same as after - //Location = new Point(_MyParent.Left + 20, _MyParent.Bottom); - //Width = _MyParent.Width - 20; - //break; case ChildRelation.After: // The size depends upon the parent type int iType = (int)_MyParent._Type; @@ -132,7 +96,6 @@ namespace Volian.Controls.Library ItemWidth = _Panel.ToDisplay(_Layout.ColT) + _Panel.ToDisplay(_Layout.WidT); break; case 1: - //ItemWidth = _Panel.ToDisplay(_ColS) + _Panel.ToDisplay(_layout.WidSTableEdit, Convert.ToInt32(_layout.PMode)-1); ItemLocation = new Point(_MyParent.ItemLocation.X + 20, _MyParent.Bottom); int borderWidth = _DisplayRTB.Width - _DisplayRTB.ClientRectangle.Width; TextWidth = __WidthAdjust + borderWidth + _Panel.ToDisplay(_Layout.WidSTableEdit, Convert.ToInt32(_Layout.PMode) - 1); @@ -143,7 +106,6 @@ namespace Volian.Controls.Library { _DisplayRTB.Font = _StepData.Font.WindowsFont; ItemWidth = (int)TableWidth(_DisplayRTB.Font, _MyItem.MyContent.Text); - //ItemLocation = new Point(_MyParent.TextLeft, _MyParent.Bottom); ItemLocation = new Point(50, _MyParent.Bottom); ItemLocation = TableLocation(_MyParent, _Layout, ItemWidth); } @@ -165,7 +127,6 @@ namespace Volian.Controls.Library else { TextLocation = new Point(_MyParent.TextLeft, _MyParent.BottomMost.Bottom); - //ItemLocation = new Point(_MyParent.ItemLeft, _MyParent.BottomMost.Bottom); } // Same size as the Parent TabFormat = ""; @@ -178,10 +139,8 @@ namespace Volian.Controls.Library _Panel.Scrolling--; // Could be a Caution or Note - Need to get WidT Width = _Panel.ToDisplay(_Layout.WidT); - //Width = _MyParent.Width - 20; break; } - //veRichTextBoxText.ResizeForText(); } } } @@ -194,8 +153,6 @@ namespace Volian.Controls.Library foreach (string line in lines) { string line2 = Regex.Replace(line, @"\\.*? ", ""); // Remove RTF Commands - //if (line != line2) - // if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("'{0}' <> '{1}'", line, line2); SizeF siz = g.MeasureString(line2, fnt,pnt,StringFormat.GenericTypographic) ; if (siz.Width+ _Panel.Settings.TableWidthAdjust > max) max = siz.Width + _Panel.Settings.TableWidthAdjust; } @@ -234,7 +191,6 @@ namespace Volian.Controls.Library get { return Width - lblTab.Left; } set { - //if(_MyLog.IsDebugEnabled)_MyLog.Debug("ItemWidth"); Width = value + lblTab.Left; } } @@ -243,7 +199,6 @@ namespace Volian.Controls.Library get { return _DisplayRTB.Width; } set { - //if(_MyLog.IsDebugEnabled)_MyLog.Debug("TextWidth"); Width = value + lblTab.Left + lblTab.Width; } } @@ -256,7 +211,7 @@ namespace Volian.Controls.Library { get { return Left + _DisplayRTB.Left; } } - private string _TabFormat ; // Volian Property Snippet + private string _TabFormat ; public string TabFormat { get { return _TabFormat; } @@ -294,12 +249,10 @@ namespace Volian.Controls.Library break; } lblTab.Text = tabString; - //lblTab.Visible = (tabString != ""); lblTab.Width = tabString.Length * 8; _DisplayRTB.Left = lblTab.Left + lblTab.Width;// +2; _DisplayRTB.Width = Width - _DisplayRTB.Left; // TODO: Performance - SetToolTip(); - //// TIMING: vlnCSLARTB.TimeIt("TabFormat Done"); } } } @@ -358,7 +311,6 @@ namespace Volian.Controls.Library } } } - //private delegate vlnCSLARTB FindNext(); public DisplayItem TopMost { get @@ -384,7 +336,6 @@ namespace Volian.Controls.Library if ((Expanding != ExpandingStatus.No || Expanded) & _After != null) tmpa = _After[_After.Count - 1].BottomMost; if (tmpr == null) return tmpa; - //if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("Left {0}, Right {1}", tmpa.Bottom, tmpr.Bottom); if (tmpa.Bottom >= tmpr.Bottom) return tmpa; return tmpr; @@ -442,7 +393,6 @@ namespace Volian.Controls.Library { get { return _MyItem == null ? 0 : _MyItem.ItemID; } } - //private bool ShowMoves = false; private bool _Moving = false; // Volian Property Snippet public bool Moving { @@ -478,6 +428,7 @@ namespace Volian.Controls.Library this.Paint += new PaintEventHandler(vlnCSLARTB_Paint); this.BackColorChanged += new EventHandler(vlnCSLARTB_BackColorChanged); _DisplayRTB.Enter += new EventHandler(_DisplayRTB_Enter); + _DisplayRTB.MouseClick += new MouseEventHandler(_DisplayRTB_MouseClick); if (item != null) { _Type = (int)item.MyContent.Type; @@ -504,21 +455,16 @@ namespace Volian.Controls.Library if(item != null)panel.ItemLookup.Add(item.ItemID, this); _Relation = relationType; if(parent != null)RNOLevel = parent.RNOLevel; - //List siblings; - //TimeIt("d"); if (item != null) { - //FormatInfo fi = item.ActiveFormat; //// TIMING: vlnCSLARTB.TimeIt("CSLARTB before _Layout"); _Layout = item.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData; //// TIMING: vlnCSLARTB.TimeIt("CSLARTB _Layout"); - //_layout = item.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData; if (parent != null) SeqLevel = parent.SeqLevel + ((relationType == ChildRelation.After || relationType == ChildRelation.Before) && TemporaryFormat.IsSequential(item) ? 1 : 0); //// TIMING: vlnCSLARTB.TimeIt("CSLARTB seqLevel"); MyItem = item; } - //TabFormat = TemporaryFormat.TabFormat(item,SeqLevel); //// TIMING: vlnCSLARTB.TimeIt("CSLARTB MyItem"); switch (relationType) { @@ -537,7 +483,6 @@ namespace Volian.Controls.Library } if (item != null) { - //MyItem = item; if (relationType == ChildRelation.None) { if (_Type == 0 && _Layout != null) @@ -545,16 +490,10 @@ namespace Volian.Controls.Library Width = _Panel.ToDisplay(_Layout.WidT); } } - //if (item != null) - //{ - // //int iType = ((int)item.MyContent.Type) / 10000; - //} } //// TIMING: vlnCSLARTB.TimeIt("CSLARTB Parent"); SetText(); //// TIMING: vlnCSLARTB.TimeIt("CSLARTB SetText"); - //MyItem = item; - //TabFormat = TemporaryFormat.TabFormat(this); if (item != null) { Name = string.Format("Item-{0}", item.ItemID); @@ -562,7 +501,6 @@ namespace Volian.Controls.Library switch (_Type / 10000) { case 1: - //CanExpand = (item.MyContent.ContentPartCount != 0); CanExpand = true; vlnExp.Attachment = (item.MyContent.ContentPartCount == 0); break; @@ -573,7 +511,6 @@ namespace Volian.Controls.Library CanExpand = false; break; } - //CanExpand = (item.MyContent.ContentPartCount != 0); if(expand && (item.MyContent.ContentPartCount != 0)) // If it should expand and it can expand Expand(true); else @@ -582,15 +519,16 @@ namespace Volian.Controls.Library Expand(true); else // otherwise only expand one level Expand(false); - //BringToFront(); } //// TIMING: vlnCSLARTB.TimeIt("CSLARTB before Controls Add"); panel.Controls.Add(this); _Loading = false; - //TabFormat = " "; //// TIMING: vlnCSLARTB.TimeIt("CSLARTB Controls Add"); } - + void _DisplayRTB_MouseClick(object sender, MouseEventArgs e) + { + _DisplayRTB.Select(); + } void _DisplayRTB_Enter(object sender, EventArgs e) { _Panel._ItemSelected = _MyItem; @@ -635,14 +573,12 @@ namespace Volian.Controls.Library private void vlnCSLARTB_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; - //g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; g.DrawString(lblTab.Text, _DisplayRTB.Font, Brushes.Black ,new RectangleF(new PointF(_Panel.Settings.NumberLocationX,_Panel.Settings.NumberLocationY),_Panel.Settings.NumberSize), StringFormat.GenericDefault); if (Circle) { Pen penC = new Pen(_Panel.Settings.CircleColor, _Panel.Settings.CircleWeight); g.DrawArc(penC, lblTab.Left + 1, 0, _Panel.Settings.CircleDiameter, _Panel.Settings.CircleDiameter, 0F, 360F); - //g.DrawString("\u20DE", _Panel.Settings.CircleFont, bluPen.Brush, lblTab.Left + _Panel.Settings.CircleXOffset, _Panel.Settings.CircleYOffset); } if (CheckOff) { @@ -692,19 +628,6 @@ namespace Volian.Controls.Library public void AddChildBefore(ItemInfo item,bool expand) { DisplayItem child = new DisplayItem(item, _Panel,this, ChildRelation.Before,expand); - //if (_Before == null) - //{ - // _Before = new List(); - // _Before.Add(child); - // child.MyParent = this; - //} - //else - //{ - // vlnCSLARTB lastChild = LastChild(_Before); - // _Before.Add(child); - // child.Previous = lastChild; - //} - //_Before.Add(child); } public void AddChildBefore(ItemInfoList itemList, bool expand) { @@ -715,17 +638,6 @@ namespace Volian.Controls.Library public void AddChildRNO(ItemInfo item,bool expand) { DisplayItem child = new DisplayItem(item, _Panel,this, ChildRelation.RNO,expand); - //if (_RNO == null) - //{ - // _RNO = new List(); - // _RNO.Add(child); - // child.MyParent = this; - //} - //else - //{ - // child.Previous = LastChild(_RNO); - // _RNO.Add(child); - //} } public void AddChildRNO(ItemInfoList itemList,bool expand) { @@ -737,18 +649,6 @@ namespace Volian.Controls.Library { DisplayItem child = new DisplayItem(item, _Panel, this, ChildRelation.After,expand); child.RNOLevel = this.RNOLevel; - //if (_After == null) - //{ - // _After = new List(); - // _After.Add(child); - // child.MyParent = this; - //} - //else - //{ - // vlnCSLARTB lastChild=LastChild(_After); - // _After.Add(child); - // child.Previous = lastChild; - //} } public void AddChildAfter(ItemInfoList itemList,bool expand) { @@ -877,9 +777,6 @@ namespace Volian.Controls.Library AddChildAfter(MyItem.Steps, expand); AddChildAfter(MyItem.Tables, expand); AddChildRNO(MyItem.RNOs, expand); - //if (args.Mode == vlnExpanderMode.ExpandAll) - // ExpandChildren(args); - //_Panel.ResumeLayout(); if (!vlnExp.Expanded) vlnExp.ShowExpanded(); } @@ -895,7 +792,6 @@ namespace Volian.Controls.Library if (!_Loading && Expanding == ExpandingStatus.No) Expand(_Type >= 20000); Cursor.Current = tmp; - //Expand(args.Mode == vlnExpanderMode.ExpandAll); } private void ExpandChildren(List children) { @@ -922,8 +818,6 @@ namespace Volian.Controls.Library { get { - //if (this.MyID == _WatchFor) - // if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("{0}", _WatchFor); DisplayItem tmp = this; if (tmp.Next == null && FirstSibling._Relation == ChildRelation.Before) return UpOne; @@ -937,7 +831,6 @@ namespace Volian.Controls.Library if (tmp.Expanding == ExpandingStatus.Expanding || tmp.Moving) // Parent Expanding or Moving - Wait return null; DisplayItem btm = tmp.BottomMost; - //if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("'BottomMost',{0},'{1}'", btm.MyID, btm.MyText); if (this != btm) { if (tmp.Next != null && tmp.Next.TopMost.Top != btm.Bottom) @@ -951,7 +844,6 @@ namespace Volian.Controls.Library } if (tmp != null) return tmp.Next.TopMost;// if no _After - check to see if there is a Next - //if (tmp != null) return tmp.Next;// if no _After - check to see if there is a Next return null; } } @@ -965,122 +857,38 @@ namespace Volian.Controls.Library return null; } } - //static int _WatchFor = 333; private void AdjustLocation() { - //if (this.MyID == _WatchFor) - // if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("{0}",_WatchFor); DisplayItem tmp = NextItem; if (tmp == null) return; - //if(tmp.Top > _Panel.Height && Bottom > _Panel.Height){ - // if(Bottom - tmp.Top != 0) - // _Panel.AdjustOutOfRangeControls(Bottom - tmp.Top); - // return; - //} if (tmp != null && !tmp.Moving && tmp.Top != Bottom ) { - //if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("'Adjust Location',{0},'Move',{1}", MyID, tmp.MyID); - //tmp.TopMost.Top = Bottom; _Panel.Scrolling++; tmp.Top = Bottom; _Panel.Scrolling--; } } - //private void SetToolTip() - //{ - // toolTip1.SetToolTip(veRichTextBoxText, - // string.Format("ID={0}, ItemLeft={1}, ItemWidth={2}, TextWidth={3}, Width={4}",MyID,ItemLeft,ItemWidth,TextWidth,Width)); - //} - //private static double Seconds() - //{ - // DateTime t = DateTime.Now; - // return ((t.Hour * 60.0) + t.Minute) * 60.0 + t.Second + (t.Millisecond / 1000.0); - //} - //private static DateTime tLast = DateTime.Now; - //private static Dictionary dicTiming = new Dictionary(); - //public static void TimeIt(string p) - //{ - // DateTime tNow = DateTime.Now; - // if (!dicTiming.ContainsKey(p)) dicTiming[p] = 0; - // dicTiming[p] += (tNow.Ticks - tLast.Ticks); - // //if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("\t{0}\t{1:0.000}", p, tNow - tLast); - // tLast = tNow; - //} - //public static void TimeItList() - //{ - // //string sep = "\r\n"; - // long total = 0; - // foreach (string s in dicTiming.Keys) - // { - // //if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("{0}\"{1}\"",sep, s); - // total += dicTiming[s]; - // //sep = "\t"; - // } - // //sep = "\r\n"; - // foreach (string s in dicTiming.Keys) - // { - // //if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("{0}{1}", sep, (dicTiming[s]*100)/total ); - // //sep = "\t"; - // long i = (dicTiming[s]*10000)/total; - // if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("\"{0}\"\t{1}\t{2}\t\"{3}\"", s, dicTiming[s], ((float)i) / 100, "".PadRight((int)(i / 100), 'X')); - // } - - // //if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("\r\n{0:0.000}", tNow - tLast); - //} - //public static void TimeItSetup() - //{ - // dicTiming = new Dictionary(); - // DateTime tNow = DateTime.Now; - // // Reset all Counts - // //if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("{0:0.000}", tNow - tLast); - // tLast = tNow; - //} public IDisplayRTB TextBox { get { return (IDisplayRTB)_DisplayRTB; } } private void vlnCSLARTB_Resize(object sender, EventArgs e) { - //return; - //TimeIt("ResizeStart"); if (_MyItem == null) return; - //if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("'Resize',{0},{1},{2},{3},{4}", MyID, Top, Left, Height, Width); - //SetToolTip(); AdjustLocation(); - //TimeIt("ResizeEnd"); } private void vlnCSLARTB_Move(object sender, EventArgs e) { - //return; if (_Panel.Scrolling == 0) return; - //_MyLog.DebugFormat("'Move',{0},{1},{2},{3},{4}", MyID, Top, Left, Height, Width); if (_MyItem == null) return; - //if (_Panel.Scrolling) return; if (Expanding == ExpandingStatus.Expanding) return; _Moving = true; - //if (_Panel.Automatic == false) return; DisplayItem tmp = (DisplayItem)sender; if (tmp._Previous == null && tmp._MyParent == null) { - //_Panel.Scrolling = true; return; } - //if (ShowMoves) - //if (MyID == 367) - //{ - // if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat(",{0},{1},{2},{3},'{4}'", MyID, tmp.MyID, Top, Left, e.GetType().Name); - // //ShowMoves = true; - //} - //SetToolTip(); AdjustLocation(); - //if (_After != null) - //{ - // if (_After[0].TopMost.Top != Bottom) - // { - // if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("'Adjust After',{0},'{1}'", MyID, MyText); - // _After[0].TopMost.Top = Bottom; - // } - //} if (_RNO != null) { if (_RNO[0].TopMost.Top != Top) @@ -1105,11 +913,6 @@ namespace Volian.Controls.Library _Moving = false; BottomMost.AdjustLocation(); } - //private void veRichTextBoxText_LinkClicked(object sender, LinkClickedEventArgs e) - //{ - // //MessageBox.Show(e.LinkText); - // _Panel.OnLinkClicked(sender, new DisplayLinkEventArgs(this, e)); - //} void _DisplayRTB_LinkGoTo(object sender, System.Windows.Forms.LinkClickedEventArgs e) { _MyLog.DebugFormat("_DisplayRTB_LinkGoTo " + e.LinkText); @@ -1127,9 +930,5 @@ namespace Volian.Controls.Library { _DisplayRTB.BackColor = _Panel.InactiveColor; } - private void veRichTextBoxText_Resize(object sender, EventArgs e) - { - //if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("'Resize Text',{0},{1},{2},{3},{4}", MyID, Top, Left, Height, Width); - } } } diff --git a/PROMS/Volian.Controls.Library/DisplayItem.designer.cs b/PROMS/Volian.Controls.Library/DisplayItem.designer.cs index 03dbeb78..eee0ec8c 100644 --- a/PROMS/Volian.Controls.Library/DisplayItem.designer.cs +++ b/PROMS/Volian.Controls.Library/DisplayItem.designer.cs @@ -61,7 +61,6 @@ namespace Volian.Controls.Library this._DisplayRTB.TabIndex = 2; this._DisplayRTB.Text = ""; this._DisplayRTB.VwMode = VEPROMS.CSLA.Library.E_ViewMode.EDIT; - this._DisplayRTB.Resize += new System.EventHandler(this.veRichTextBoxText_Resize); this._DisplayRTB.Enter += new System.EventHandler(this.veRichTextBoxText_Enter); this._DisplayRTB.LinkGoTo += new Volian.Controls.Library.DisplayRTBLinkEvent(this._DisplayRTB_LinkGoTo); this._DisplayRTB.Leave += new System.EventHandler(this.veRichTextBoxText_Leave); diff --git a/PROMS/Volian.Controls.Library/DisplayTabControl.cs b/PROMS/Volian.Controls.Library/DisplayTabControl.cs index 4225dec4..14d2d7bf 100644 --- a/PROMS/Volian.Controls.Library/DisplayTabControl.cs +++ b/PROMS/Volian.Controls.Library/DisplayTabControl.cs @@ -36,22 +36,14 @@ namespace Volian.Controls.Library Dock = DockStyle.Fill; dotNetBarManager1.Style = DevComponents.DotNetBar.eDotNetBarStyle.Office2007; _MyPages = new Dictionary(); - //dotNetBarManager1.DockTabClosing += new DevComponents.DotNetBar.DockTabClosingEventHandler(dotNetBarManager1_DockTabClosing); - //_MyBar.DockTabControl.CloseButtonOnTabsAlwaysDisplayed = true; SetupBar(_MyBar); dotNetBarManager1.BarTearOff += new EventHandler(dotNetBarManager1_BarTearOff); } void dotNetBarManager1_BarTearOff(object sender, EventArgs e) { Bar myBar = sender as Bar; - //SetupBar(myBar); myBar.Enter += new EventHandler(myBar_Enter); } - //private void ShowPG(object myObject) - //{ - //frmPropGridTest tmp = new frmPropGridTest(myObject); - //tmp.Show(); - //} private void SetupBar(Bar myBar) { if (myBar.DockTabControl != null) @@ -60,31 +52,39 @@ namespace Volian.Controls.Library myBar.DockTabControl.CloseButtonVisible = false; myBar.DockTabControl.CloseButtonPosition = DevComponents.DotNetBar.eTabCloseButtonPosition.Right; myBar.DockTabControl.Width = ClientRectangle.Width; - //ShowPG(myBar); - //ShowPG(myBar.DockTabControl); } myBar.DockTabClosing += new DockTabClosingEventHandler(myBar_DockTabClosing); if (!myBar.Visible) myBar.Visible = true; myBar.RecalcLayout(); } - void myBar_Enter(object sender, EventArgs e) { Bar myBar = sender as Bar; myBar.Enter -= new EventHandler(myBar_Enter); SetupBar(sender as Bar); } - void myBar_DockTabClosing(object sender, DockTabClosingEventArgs e) { e.RemoveDockTab = true; _RemovedItems.Add((DisplayTabItem)e.DockContainerItem); - //RemoveItem((DisplayTabItem)e.DockContainerItem); + DisplayTabItem myTabItem = e.DockContainerItem as DisplayTabItem; + if (myTabItem != null) + { + if (myTabItem.MyDSOTabPanel != null) + { + myTabItem.MyDSOTabPanel.CloseDSO(); + } + } if (((Bar)sender).Items.Count == 1)// Remove bar if last item is closed... { - dotNetBarManager1.Bars.Remove((Bar)sender); - ActivateRemainingTab(); + Bar bar = sender as Bar; + if (bar != null) + { + if(dotNetBarManager1.Bars.Contains(bar.Name)) + dotNetBarManager1.Bars.Remove(bar); + ActivateRemainingTab(); + } } } private void ActivateRemainingTab() @@ -93,39 +93,16 @@ namespace Volian.Controls.Library { if (myBar.DockSide == eDockSide.Document && myBar.Visible) { - myBar.SelectedDockContainerItem.Selected = true; + if (myBar.SelectedDockContainerItem != null) + { + myBar.SelectedDockContainerItem.Selected = true; + } } } // No Document Tabs Remaining - need to raise OnItemSelectedChanged OnItemSelectedChanged(this, null); } - private Bar GetFirstDocumentBar() - { - foreach (Bar b in dotNetBarManager1.Bars) - { - if (b.DockSide == eDockSide.Document && b.Visible) - return b; - } - - // If no documents bars found, create new one - //_UniqueBarCount++; - Bar bar = BarUtilities.CreateDocumentBar(); - //bar.DockTabClosing += new DockTabClosingEventHandler(DocumentBar_DockTabClosing); - //bar.Name = "barDocuments" + m_UniqueBarCount.ToString(); - fillDocDockSite.GetDocumentUIManager().Dock(bar); - SetupBar(bar); - return bar; - } - - - //void dotNetBarManager1_DockTabClosing(object sender, DevComponents.DotNetBar.DockTabClosingEventArgs e) - //{ - // e.RemoveDockTab = true; - // _RemovedItems.Add((DisplayTabItem)e.DockContainerItem); - // //RemoveItem((DisplayTabItem)e.DockContainerItem); - // if (((Bar)sender).Items.Count == 1) // Remove bar if last item is closed... - // dotNetBarManager1.Bars.Remove((Bar)sender); - //} + private int _UniqueBarCount; public DevComponents.DotNetBar.Bar MyBar { get { return _MyBar; } @@ -136,16 +113,19 @@ namespace Volian.Controls.Library set { if (value != null) + { + value.Focus(); value.Selected = true; + } } } public DisplayTabItem OpenItem(ItemInfo myItem) { while (_RemovedItems.Count > 0) { - DisplayTabItem tabItem = _RemovedItems[0]; + DisplayTabItem myTabItem = _RemovedItems[0]; _RemovedItems.RemoveAt(0); - RemoveItem(tabItem); + RemoveItem(myTabItem); } _MyBar = GetParentBar(myItem); if (myItem.MyContent.MyEntry == null) @@ -153,7 +133,6 @@ namespace Volian.Controls.Library else return OpenDSOTabPage(myItem); } - private Bar GetParentBar(ItemInfo myItem) { Bar myBar = null; @@ -161,23 +140,23 @@ namespace Volian.Controls.Library { if (b.DockSide == eDockSide.Document && b.Visible) { - myBar = b; - foreach (object itm in myBar.Items) + if(myBar == null)myBar = b; + foreach (object itm in b.Items) { DisplayTabItem myTabItem = itm as DisplayTabItem; if (myTabItem != null && myTabItem.MyTabPanel != null) if (myTabItem.MyTabPanel.MyItem.ItemID == myItem.MyProcedure.ItemID) - return myBar; + return b; } } } if (myBar == null) { // If no documents bars found, create new one - //_UniqueBarCount++; + _UniqueBarCount++; myBar = BarUtilities.CreateDocumentBar(); - //bar.DockTabClosing += new DockTabClosingEventHandler(DocumentBar_DockTabClosing); - //bar.Name = "barDocuments" + m_UniqueBarCount.ToString(); + myBar.DockTabClosing +=new DockTabClosingEventHandler(myBar_DockTabClosing); + myBar.Name = "barDocuments" + _UniqueBarCount.ToString(); fillDocDockSite.GetDocumentUIManager().Dock(myBar); SetupBar(myBar); } @@ -192,15 +171,14 @@ namespace Volian.Controls.Library { pg = _MyPages[key]; pg.Selected = true; - //SelectedTab = pg; + SelectedTab = pg; } else { pg = new DisplayTabItem(this.components, this, proc, key); // Open a new Procedure Tab - //_MyBar.Items.Add(pg); _MyPages.Add(key, pg); pg.Selected = true; - //SelectedTab = pg; + SelectedTab = pg; pg.MyTabPanel.MyItem = proc; } Application.DoEvents(); @@ -216,8 +194,10 @@ namespace Volian.Controls.Library { _MyPages.Remove(myItem.MyKey); // Can I dispose the Panel - myItem.MyTabPanel.Dispose(); - //myItem.Name = null; + if(myItem.MyTabPanel!=null) + myItem.MyTabPanel.Dispose(); + if (myItem.MyDSOTabPanel != null) + myItem.MyDSOTabPanel.CloseDSO(); components.Remove(myItem); myItem.Dispose(); } @@ -230,6 +210,11 @@ namespace Volian.Controls.Library pg = _MyPages[key]; else { + if (DSOTabPanel.Count > 18) + { + MessageBox.Show("Too many Word Documents Open. Please close one of the Documents before attempting to open another"); + return null; + } pg = new DisplayTabItem(this.components, this, myItem,key); // Open a new Procedure Tab _MyPages.Add(key, pg); } diff --git a/PROMS/Volian.Controls.Library/DisplayTabItem.cs b/PROMS/Volian.Controls.Library/DisplayTabItem.cs index ca77fa37..e77e9108 100644 --- a/PROMS/Volian.Controls.Library/DisplayTabItem.cs +++ b/PROMS/Volian.Controls.Library/DisplayTabItem.cs @@ -12,6 +12,12 @@ namespace Volian.Controls.Library { private DisplayTabControl _MyTabControl; private ItemInfo _MyItem; + + public ItemInfo MyItem + { + get { return _MyItem; } + set { _MyItem = value; } + } private DisplayTabPanel _MyTabPanel; private string _MyKey; public string MyKey @@ -24,6 +30,11 @@ namespace Volian.Controls.Library set { _MyTabPanel = value; } } private DSOTabPanel _MyDSOTabPanel; + public DSOTabPanel MyDSOTabPanel + { + get { return _MyDSOTabPanel; } + set { _MyDSOTabPanel = value; } + } public ItemInfo ItemSelected { get { return _MyTabPanel.ItemSelected; } @@ -41,9 +52,7 @@ namespace Volian.Controls.Library SetupDisplayPanel(); else SetupDSOPanel(); - this.Disposed+=new EventHandler(DisplayTabItem_Disposed); - //_MyTabPanel.HandleDestroyed += new EventHandler(_MyTabPanel_HandleDestroyed); - //_MyTabPanel.Disposed += new EventHandler(_MyTabPanel_Disposed); + Name = string.Format("DisplayTabItem {0}", myItem.ItemID); } void DisplayTabItem_Click(object sender, EventArgs e) { @@ -54,18 +63,6 @@ namespace Volian.Controls.Library if(myTabPanel == null) return; _MyTabControl.OnItemSelectedChanged(this,new DisplayPanelEventArgs(MyTabPanel.SelectedItem,null)); } - //void _MyTabPanel_Disposed(object sender, EventArgs e) - //{ - // Console.WriteLine("_MyTabPanel_Disposed"); - //} - //void _MyTabPanel_HandleDestroyed(object sender, EventArgs e) - //{ - // Console.WriteLine("_MyTabPanel_HandleDestroyed"); - //} - void DisplayTabItem_Disposed(object sender, EventArgs e) - { - Console.WriteLine("DisplayTabItem_Disposed"); - } private void SetupDisplayPanel() { ((System.ComponentModel.ISupportInitialize)(_MyTabControl.MyBar)).BeginInit(); @@ -81,14 +78,12 @@ namespace Volian.Controls.Library // _MyTabControl.Controls.Add(_MyTabPanel); _MyTabControl.MyBar.Items.Add(this); - // TODO: Cleanup _MyTabControl.Tabs.Add(this); // // tabPanel // _MyTabPanel.TabItem = this; ((System.ComponentModel.ISupportInitialize)(_MyTabControl.MyBar)).EndInit(); _MyTabControl.MyBar.ResumeLayout(false); - //_MyTabPanel.MyItem = _MyItem; } private void SetupDSOPanel() { @@ -110,7 +105,6 @@ namespace Volian.Controls.Library // _MyTabControl.SelectedTab = this; _MyDSOTabPanel.TabItem = this; - //_MyTabControl.SetToolTip(this, "Header", "Footer", "Body"); } } }