From ee9acb929db9ce3306bafe13a68229156526e5fd Mon Sep 17 00:00:00 2001 From: Rich Date: Tue, 26 Feb 2008 16:20:00 +0000 Subject: [PATCH] Fix problem with Item Selected. Fixes problem so that Item selected stays selected even if it is not active. Also, makes DSOFramer properly select the related tab when it becomes active. --- PROMS/Volian.Controls.Library/DSOTabPanel.cs | 23 +++++++++++ PROMS/Volian.Controls.Library/DisplayItem.cs | 39 +++++++++--------- .../DisplayItem.designer.cs | 3 +- PROMS/Volian.Controls.Library/DisplayPanel.cs | 41 +++++++++++++------ .../DisplayPanel.designer.cs | 1 + PROMS/Volian.Controls.Library/DisplayRTB.cs | 24 ++++++----- 6 files changed, 88 insertions(+), 43 deletions(-) diff --git a/PROMS/Volian.Controls.Library/DSOTabPanel.cs b/PROMS/Volian.Controls.Library/DSOTabPanel.cs index 5d4a72da..5b706844 100644 --- a/PROMS/Volian.Controls.Library/DSOTabPanel.cs +++ b/PROMS/Volian.Controls.Library/DSOTabPanel.cs @@ -16,6 +16,7 @@ namespace Volian.Controls.Library private DisplayTabControl _MyTabControl; private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private AxDSOFramer.AxFramerControl _MyDSOFramer; + private TransPanel _MyTransPanel; private static int _Count = 0; private DocumentInfo _MyDocument; private int _MyCount; @@ -67,10 +68,21 @@ namespace Volian.Controls.Library { _Count++; _MyCount = _Count; + this._MyTransPanel = new TransPanel(); this._MyDSOFramer = new AxDSOFramer.AxFramerControl(); ((System.ComponentModel.ISupportInitialize)(this._MyDSOFramer)).BeginInit(); this.Controls.Add(this._MyDSOFramer); + this.Controls.Add(this._MyTransPanel); this.components.Add(this._MyDSOFramer); + this.components.Add(this._MyTransPanel); + this._MyTransPanel.Dock = System.Windows.Forms.DockStyle.Fill; + this._MyTransPanel.Font = new System.Drawing.Font("Tahoma", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this._MyTransPanel.ForeColor = System.Drawing.Color.Brown; + //this._MyTransPanel.Location = new System.Drawing.Point(0, 0); + //this._MyTransPanel.Name = "transPanel1"; + //this._MyTransPanel.Size = new System.Drawing.Size(370, 423); + //this._MyTransPanel.TabIndex = 1; + this._MyTransPanel.Click += new EventHandler(_MyTransPanel_Click); this._MyDSOFramer.Dock = System.Windows.Forms.DockStyle.Fill; //System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(WordDSOTab)); //this._DSOFramer.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("_FC.OcxState"))); @@ -82,7 +94,17 @@ namespace Volian.Controls.Library // this._MyDSOFramer.FrameHookPolicy = DSOFramer.dsoFrameHookPolicy.dsoResetNow; this._MyDSOFramer.BeforeDocumentClosed += new AxDSOFramer._DFramerCtlEvents_BeforeDocumentClosedEventHandler(_MyDSOFramer_BeforeDocumentClosed); this._MyDSOFramer.OnSaveCompleted += new AxDSOFramer._DFramerCtlEvents_OnSaveCompletedEventHandler(_MyDSOFramer_OnSaveCompleted); + //this._MyDSOFramer.OnActivationChange += new AxDSOFramer._DFramerCtlEvents_OnActivationChangeEventHandler(_MyDSOFramer_OnActivationChange); this.Enter += new EventHandler(DSOTabPanel_Enter); + this.Leave += new EventHandler(DSOTabPanel_Leave); + } + void DSOTabPanel_Leave(object sender, EventArgs e) + { + _MyTransPanel.BringToFront(); + } + void _MyTransPanel_Click(object sender, EventArgs e) + { + this.Select(); } void _MyDSOFramer_OnSaveCompleted(object sender, AxDSOFramer._DFramerCtlEvents_OnSaveCompletedEvent e) { @@ -101,6 +123,7 @@ namespace Volian.Controls.Library } void DSOTabPanel_Enter(object sender, EventArgs e) { + _MyTransPanel.SendToBack(); try { _MyDSOFramer.EventsEnabled = true; diff --git a/PROMS/Volian.Controls.Library/DisplayItem.cs b/PROMS/Volian.Controls.Library/DisplayItem.cs index 14c994f0..dd2847cc 100644 --- a/PROMS/Volian.Controls.Library/DisplayItem.cs +++ b/PROMS/Volian.Controls.Library/DisplayItem.cs @@ -433,8 +433,8 @@ namespace Volian.Controls.Library this.BackColorChanged += new EventHandler(vlnCSLARTB_BackColorChanged); //_DisplayRTB.Enter += new EventHandler(_DisplayRTB_Enter); //_DisplayRTB.Leave += new EventHandler(_DisplayRTB_Leave); - _DisplayRTB.GotFocus += new EventHandler(_DisplayRTB_GotFocus); - _DisplayRTB.LostFocus += new EventHandler(_DisplayRTB_LostFocus); + //_DisplayRTB.GotFocus += new EventHandler(_DisplayRTB_GotFocus); + //_DisplayRTB.LostFocus += new EventHandler(_DisplayRTB_LostFocus); _DisplayRTB.MouseClick += new MouseEventHandler(_DisplayRTB_MouseClick); if (item != null) { @@ -541,16 +541,16 @@ namespace Volian.Controls.Library // _Panel._ItemSelected = _MyItem; // _Panel.OnItemSelectedChanged(sender, new DisplayPanelEventArgs(this, null)); //} - void _DisplayRTB_LostFocus(object sender, EventArgs e) - { - _Panel._ItemSelected = null; - _Panel.OnItemSelectedChanged(sender, null); - } - void _DisplayRTB_GotFocus(object sender, EventArgs e) - { - _Panel._ItemSelected = _MyItem; - _Panel.OnItemSelectedChanged(sender, new DisplayPanelEventArgs(this, null)); - } + //void _DisplayRTB_LostFocus(object sender, EventArgs e) + //{ + // //_Panel.ItemSelected = null; + // //_Panel.OnItemSelectedChanged(sender, null); + //} + //void _DisplayRTB_GotFocus(object sender, EventArgs e) + //{ + // _Panel.ItemSelected = _MyItem; + // //_Panel.OnItemSelectedChanged(sender, new DisplayPanelEventArgs(this, null)); + //} //void _DisplayRTB_Leave(object sender, EventArgs e) //{ // _Panel._ItemSelected = null; @@ -938,7 +938,7 @@ namespace Volian.Controls.Library _Moving = false; BottomMost.AdjustLocation(); } - void _DisplayRTB_LinkGoTo(object sender, System.Windows.Forms.LinkClickedEventArgs e) + private void _DisplayRTB_LinkGoTo(object sender, System.Windows.Forms.LinkClickedEventArgs e) { _MyLog.DebugFormat("_DisplayRTB_LinkGoTo " + e.LinkText); _Panel.OnLinkClicked(sender, new DisplayLinkEventArgs(this, e)); @@ -947,14 +947,15 @@ namespace Volian.Controls.Library { _Panel.OnItemClick(this, new DisplayPanelEventArgs(this, e)); } - private void veRichTextBoxText_Enter(object sender, EventArgs e) + private void _DisplayRTB_Enter(object sender, EventArgs e) { - _DisplayRTB.BackColor = _Panel.ActiveColor; - } - private void veRichTextBoxText_Leave(object sender, EventArgs e) - { - _DisplayRTB.BackColor = _Panel.InactiveColor; + _Panel.DisplayRTB = _DisplayRTB; + _Panel.ItemSelected = _MyItem; } + //private void veRichTextBoxText_Leave(object sender, EventArgs e) + //{ + + //} private void _DisplayRTB_LinkModifyTran(object sender, LinkClickedEventArgs e) { diff --git a/PROMS/Volian.Controls.Library/DisplayItem.designer.cs b/PROMS/Volian.Controls.Library/DisplayItem.designer.cs index e235cda7..a5aebb0e 100644 --- a/PROMS/Volian.Controls.Library/DisplayItem.designer.cs +++ b/PROMS/Volian.Controls.Library/DisplayItem.designer.cs @@ -61,9 +61,8 @@ namespace Volian.Controls.Library this._DisplayRTB.TabIndex = 2; this._DisplayRTB.Text = ""; this._DisplayRTB.VwMode = VEPROMS.CSLA.Library.E_ViewMode.Edit; - this._DisplayRTB.Enter += new System.EventHandler(this.veRichTextBoxText_Enter); + this._DisplayRTB.Enter += new System.EventHandler(this._DisplayRTB_Enter); this._DisplayRTB.LinkGoTo += new Volian.Controls.Library.DisplayRTBLinkEvent(this._DisplayRTB_LinkGoTo); - this._DisplayRTB.Leave += new System.EventHandler(this.veRichTextBoxText_Leave); this._DisplayRTB.HeightChanged += new Volian.Controls.Library.DisplayRTBEvent(this.veRichTextBoxText_HeightChanged); this._DisplayRTB.LinkModifyTran += new Volian.Controls.Library.DisplayRTBLinkEvent(this._DisplayRTB_LinkModifyTran); // diff --git a/PROMS/Volian.Controls.Library/DisplayPanel.cs b/PROMS/Volian.Controls.Library/DisplayPanel.cs index aca4546c..5a2e83fa 100644 --- a/PROMS/Volian.Controls.Library/DisplayPanel.cs +++ b/PROMS/Volian.Controls.Library/DisplayPanel.cs @@ -156,11 +156,28 @@ namespace Volian.Controls.Library ExpandAsNeeded(item); ItemLookup[id].ItemSelect(); } - private ItemInfo _LastItemSelected; - internal ItemInfo LastItemSelected + private DisplayRTB _DisplayRTB = null; + public DisplayRTB DisplayRTB { - get { return _LastItemSelected; } + get { return _DisplayRTB; } + set + { + if (_DisplayRTB == value) return; // Same - No Change + if (_DisplayRTB != null) + { + _DisplayRTB.BackColor = InactiveColor; + _DisplayRTB.SaveText(); // Save any changes to the text + } + _DisplayRTB = value; + _DisplayRTB.BackColor = ActiveColor; + } } + + //private ItemInfo _LastItemSelected; + //internal ItemInfo LastItemSelected + //{ + // get { return _LastItemSelected; } + //} internal ItemInfo _ItemSelected; public ItemInfo ItemSelected { @@ -168,12 +185,12 @@ namespace Volian.Controls.Library set { _ItemSelected = value; - if (value == null) - { - OnItemSelectedChanged(this, null); - return; - } - _LastItemSelected = value; + //if (value == null) + //{ + // OnItemSelectedChanged(this, null); + // return; + //} + //_LastItemSelected = value; int id = value.ItemID; ExpandAsNeeded(value); ItemLookup[id].ItemSelect(); @@ -182,12 +199,12 @@ namespace Volian.Controls.Library } public DisplayItem DisplayItemSelected { - get { return (_ItemSelected != null)?ItemLookup[_ItemSelected.ItemID]:null; } + get { return (_ItemSelected != null) ? ItemLookup[_ItemSelected.ItemID] : null; } } public void ItemShow() { - if (_LastItemSelected != null) - ItemLookup[_LastItemSelected.ItemID].ItemShow(); + if (_ItemSelected != null) + ItemLookup[_ItemSelected.ItemID].ItemShow(); } private int _Scrolling = 0; // Volian Property Snippet public int Scrolling diff --git a/PROMS/Volian.Controls.Library/DisplayPanel.designer.cs b/PROMS/Volian.Controls.Library/DisplayPanel.designer.cs index 49b07baf..1abab71a 100644 --- a/PROMS/Volian.Controls.Library/DisplayPanel.designer.cs +++ b/PROMS/Volian.Controls.Library/DisplayPanel.designer.cs @@ -15,6 +15,7 @@ namespace Volian.Controls.Library { if (disposing && (components != null)) { + if (_DisplayRTB != null) _DisplayRTB.SaveText(); components.Dispose(); } base.Dispose(disposing); diff --git a/PROMS/Volian.Controls.Library/DisplayRTB.cs b/PROMS/Volian.Controls.Library/DisplayRTB.cs index fe395900..46975a6f 100644 --- a/PROMS/Volian.Controls.Library/DisplayRTB.cs +++ b/PROMS/Volian.Controls.Library/DisplayRTB.cs @@ -173,7 +173,7 @@ namespace Volian.Controls.Library this.LinkClicked += new LinkClickedEventHandler(onLinkClicked); this.KeyPress += new KeyPressEventHandler(onKeyPress); this.KeyDown += new KeyEventHandler(onKeyDown); - this.Leave += new EventHandler(DisplayRTB_Leave); + //this.Leave += new EventHandler(DisplayRTB_Leave); } catch (Exception ex) { @@ -201,7 +201,7 @@ namespace Volian.Controls.Library this.LinkClicked += new LinkClickedEventHandler(onLinkClicked); this.KeyPress += new KeyPressEventHandler(onKeyPress); this.KeyDown += new KeyEventHandler(onKeyDown); - this.Leave += new EventHandler(DisplayRTB_Leave); + //this.Leave += new EventHandler(DisplayRTB_Leave); } #endregion #region ApplicationSupport @@ -377,15 +377,19 @@ namespace Volian.Controls.Library _LinkClickedEventArgs = args; if (LinkModifyTran != null) LinkModifyTran(sender, args); } - void DisplayRTB_Leave(object sender, EventArgs e) - { - // Save returns true if text was not changed or if change was saved successfully. - if (ReadOnly) return; - // if selecting another rtb, save. If selecting the info panel don't because - // we're still on a valid item.?? + //void DisplayRTB_Leave(object sender, EventArgs e) + //{ + // // Save returns true if text was not changed or if change was saved successfully. + // if (ReadOnly) return; + // // if selecting another rtb, save. If selecting the info panel don't because + // // we're still on a valid item.?? - // RHM?? why commented out. bool success = _origVlnText.Save((RichTextBox)this); - // RHM?? why commented out.if (!success) Console.WriteLine("Failed to save text: {0}", this.Text); + //} + public void SaveText() + { + if (ReadOnly) return; + bool success = _origVlnText.Save((RichTextBox)this); + if (!success) Console.WriteLine("Failed to save text: {0}", this.Text); } private Point _savcurpos; private void onLinkClicked(object sender, System.Windows.Forms.LinkClickedEventArgs e)