Fixed ItemSelected so that Comment works properly.

Added code back in so that Word displays properly.
Allow the same document to be opened after Word hang
This commit is contained in:
Rich 2008-02-08 10:31:30 +00:00
parent 52a735e08c
commit 3c79833edf
5 changed files with 87 additions and 22 deletions

View File

@ -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));
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()
{

View File

@ -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();
}

View File

@ -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)
{

View File

@ -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

View File

@ -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()
{