diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs index 5ab58a73..f946c5f7 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs @@ -112,15 +112,43 @@ namespace VEPROMS.CSLA.Library } } } + private bool _Created = false; + private int _Unique = 0; + private string Unique + { + get + { + string retval = ""; + if (_Unique != 0) retval = "_" + _Unique.ToString(); + _Unique++; + return retval; + } + } private void CreateFile() { - if (_MyDocument == null) return; - _MyFile = new FileInfo(string.Format(@"{0}\tmp_{1}." + Extension , TemporaryFolder, MyDocument.DocID)); - FileStream fs = _MyFile.Create(); - fs.Write(MyDocument.DocContent, 0, MyDocument.DocContent.Length); - fs.Close(); - _MyFile.CreationTime = _MyDocument.DTS; - _MyFile.LastWriteTime = _MyDocument.DTS; + while (!_Created) + CreateTemporaryFile(); + } + + private void CreateTemporaryFile() + { + try + { + if (_MyDocument != null) + { + _MyFile = new FileInfo(string.Format(@"{0}\tmp_{1}{2}.{3}", TemporaryFolder, MyDocument.DocID, Unique, Extension)); + FileStream fs = _MyFile.Create(); + fs.Write(MyDocument.DocContent, 0, MyDocument.DocContent.Length); + fs.Close(); + _MyFile.CreationTime = _MyDocument.DTS; + _MyFile.LastWriteTime = _MyDocument.DTS; + _Created = true; + } + } + catch (Exception ex) + { + Console.WriteLine(ex.Message); + } } public void SaveFile() { diff --git a/PROMS/Volian.Controls.Library/DSOTabPanel.cs b/PROMS/Volian.Controls.Library/DSOTabPanel.cs index 47a1c394..5d4a72da 100644 --- a/PROMS/Volian.Controls.Library/DSOTabPanel.cs +++ b/PROMS/Volian.Controls.Library/DSOTabPanel.cs @@ -30,6 +30,7 @@ namespace Volian.Controls.Library get { return _TabItem; } set { _TabItem = value; } } + //private frmPG _frm = null; public DSOTabPanel(DocumentInfo documentInfo, DisplayTabControl myTabControl) { _MyTabControl = myTabControl; @@ -37,6 +38,8 @@ namespace Volian.Controls.Library SetupDSOTabPanel(); _MyDocument = documentInfo; SetupDSO(); + //_frm = new frmPG(_MyDSOFramer); + //_frm.Show(); } private void SetupDSOTabPanel() { @@ -98,15 +101,15 @@ namespace Volian.Controls.Library } void DSOTabPanel_Enter(object sender, EventArgs e) { - //try - //{ - // _MyDSOFramer.EventsEnabled = true; - // _MyDSOFramer.FrameHookPolicy = DSOFramer.dsoFrameHookPolicy.dsoResetNow; - //} - //catch (Exception ex) - //{ - // if (_MyLog.IsErrorEnabled) _MyLog.ErrorFormat("DSOTabPage_Enter", ex); - //} + try + { + _MyDSOFramer.EventsEnabled = true; + _MyDSOFramer.FrameHookPolicy = DSOFramer.dsoFrameHookPolicy.dsoResetNow; + } + catch (Exception ex) + { + if (_MyLog.IsErrorEnabled) _MyLog.ErrorFormat("DSOTabPage_Enter", ex); + } _MyTabControl.OnItemSelectedChanged(this, null); _MyDSOFramer.Focus(); } diff --git a/PROMS/Volian.Controls.Library/DisplayItem.cs b/PROMS/Volian.Controls.Library/DisplayItem.cs index 834233fe..14c994f0 100644 --- a/PROMS/Volian.Controls.Library/DisplayItem.cs +++ b/PROMS/Volian.Controls.Library/DisplayItem.cs @@ -431,7 +431,10 @@ namespace Volian.Controls.Library _DisplayRTB.Top = 3; this.Paint += new PaintEventHandler(vlnCSLARTB_Paint); this.BackColorChanged += new EventHandler(vlnCSLARTB_BackColorChanged); - _DisplayRTB.Enter += new EventHandler(_DisplayRTB_Enter); + //_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.MouseClick += new MouseEventHandler(_DisplayRTB_MouseClick); if (item != null) { @@ -533,11 +536,26 @@ namespace Volian.Controls.Library { _DisplayRTB.Select(); } - void _DisplayRTB_Enter(object sender, EventArgs e) + //void _DisplayRTB_Enter(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; + // _Panel.OnItemSelectedChanged(sender, null); + //} public void AutoExpand() { Expand(_Type >= 20000); @@ -573,6 +591,9 @@ namespace Volian.Controls.Library public void ItemShow() { _DisplayRTB.Focus(); + int scrollValue = _Panel.VerticalScroll.Value + (Top - (_Panel.Height / 2)); // calculate scroll center for the item + if(scrollValue > _Panel.VerticalScroll.Minimum && scrollValue <= _Panel.VerticalScroll.Maximum) // If it isn't within range + _Panel.VerticalScroll.Value = scrollValue; // Center the item } private void vlnCSLARTB_Paint(object sender, PaintEventArgs e) { diff --git a/PROMS/Volian.Controls.Library/DisplayPanel.cs b/PROMS/Volian.Controls.Library/DisplayPanel.cs index c0bd476f..aca4546c 100644 --- a/PROMS/Volian.Controls.Library/DisplayPanel.cs +++ b/PROMS/Volian.Controls.Library/DisplayPanel.cs @@ -156,16 +156,28 @@ namespace Volian.Controls.Library ExpandAsNeeded(item); ItemLookup[id].ItemSelect(); } + private ItemInfo _LastItemSelected; + internal ItemInfo LastItemSelected + { + get { return _LastItemSelected; } + } internal ItemInfo _ItemSelected; public ItemInfo ItemSelected { get { return _ItemSelected; } set { + _ItemSelected = value; + if (value == null) + { + OnItemSelectedChanged(this, null); + return; + } + _LastItemSelected = value; int id = value.ItemID; ExpandAsNeeded(value); - _ItemSelected = value; ItemLookup[id].ItemSelect(); + OnItemSelectedChanged(this, new DisplayPanelEventArgs(ItemLookup[id], null)); } } public DisplayItem DisplayItemSelected @@ -174,8 +186,8 @@ namespace Volian.Controls.Library } public void ItemShow() { - if (_ItemSelected != null) - ItemLookup[_ItemSelected.ItemID].ItemShow(); + if (_LastItemSelected != null) + ItemLookup[_LastItemSelected.ItemID].ItemShow(); } private int _Scrolling = 0; // Volian Property Snippet public int Scrolling diff --git a/PROMS/Volian.Controls.Library/DisplayTabPanel.cs b/PROMS/Volian.Controls.Library/DisplayTabPanel.cs index 01802f36..5ae77b28 100644 --- a/PROMS/Volian.Controls.Library/DisplayTabPanel.cs +++ b/PROMS/Volian.Controls.Library/DisplayTabPanel.cs @@ -63,7 +63,8 @@ namespace Volian.Controls.Library } void DisplayTabPanel_Enter(object sender, EventArgs e) { - if (ItemSelected != null) _MyPanel.ItemShow(); + //if (ItemSelected != null) + _MyPanel.ItemShow(); } private void SetupDisplayPanel() {