Stack Trace Class.

Fixing logic between ItemSelected and DisplayRTB
This commit is contained in:
Rich 2008-02-28 16:44:37 +00:00
parent a39536739b
commit 0437f76f3a
3 changed files with 48 additions and 26 deletions

View File

@ -167,23 +167,12 @@ namespace Volian.Controls.Library
if (_DisplayRTB != null)
{
_DisplayRTB.BackColor = InactiveColor;
_DisplayRTB.SaveText(); // Save any changes to the text
//_DisplayRTB.SaveText(); // Save any changes to the text
}
_DisplayRTB = value;
_ItemSelected = value.MyItem;
//AddExpandItem(_ItemSelected);
ExpandAsNeeded(_ItemSelected);
OnItemSelectedChanged(this, new DisplayPanelEventArgs(ItemLookup[_ItemSelected.ItemID], null));
// Show StackTrace
//Console.WriteLine("_DisplayRTB = {0}", _DisplayRTB.MyItem.ItemID);
//StackTrace st = new StackTrace(true);
//StackFrame[] sfs = st.GetFrames();
//int ii = 1;
//foreach (StackFrame sf in sfs)
//{
// if (ii < 50 && sf.GetFileLineNumber() != 0)
// Console.WriteLine("{0}{1}", "".PadLeft(ii++ * 2), sf);
//}
_DisplayRTB = value;
if (_ItemSelected.ItemID != value.MyItem.ItemID)
ItemSelected = value.MyItem;
//vlnStackTrace.ShowStack("_DisplayRTB = {0}", _DisplayRTB.MyItem.ItemID);// Show StackTrace
}
}
internal ItemInfo _ItemSelected;
@ -196,17 +185,9 @@ namespace Volian.Controls.Library
int id = value.ItemID;
ExpandAsNeeded(value);
DisplayItem itm = ItemLookup[id];
_DisplayRTB = itm.MyDisplayRTB;// This keeps the code above from repeating
itm.ItemSelect();
OnItemSelectedChanged(this, new DisplayPanelEventArgs(itm, null));
//StackTrace st = new StackTrace(true);
//StackFrame[] sfs = st.GetFrames();
//int ii = 1;
//foreach (StackFrame sf in sfs)
//{
// if (ii < 50 && sf.GetFileLineNumber() != 0)
// Console.WriteLine("{0}{1}", "".PadLeft(ii++ * 2), sf);
//}
//vlnStackTrace.ShowStack("_ItemSelected = {0}", _ItemSelected.ItemID);// Show StackTrace
}
}
public DisplayItem DisplayItemSelected

View File

@ -15,7 +15,7 @@ namespace Volian.Controls.Library
{
if (disposing && (components != null))
{
if (_DisplayRTB != null) _DisplayRTB.SaveText();
//if (_DisplayRTB != null) _DisplayRTB.SaveText();
components.Dispose();
}
base.Dispose(disposing);

View File

@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
namespace Volian.Controls.Library
{
public static class vlnStackTrace
{
public static string GetStack(string str, params object[] objects)
{
return string.Format(str, objects) + StackToString();
}
public static void ShowStack(string str, params object[] objects)
{
Console.WriteLine(string.Format(str, objects) + StackToString());
}
public static string GetStack()
{
return StackToString();
}
public static void ShowStack()
{
Console.WriteLine(StackToString());
}
private static string StackToString()
{
StringBuilder sb = new StringBuilder();
StackTrace st = new StackTrace(true);
StackFrame[] sfs = st.GetFrames();
int ii = 0;
foreach (StackFrame sf in sfs)
{
if (ii < 2) ii++;
else if (sf.GetFileLineNumber() != 0)
sb.Append(string.Format("\r\n{0}{1}", "".PadLeft(ii++ * 2), sf.ToString().TrimEnd(" \r\n".ToCharArray())));
}
return sb.ToString();
}
}
}