Search

Static Debug Window

//code section
///Static Debug Window reflection 
     
    using System.Text; 
    using System.Windows.Forms; 
    using System.Drawing; 
    using System; 
    using System.Collections.Generic; 
    using System.ComponentModel; 
    using System.Data; 
     
    namespace IndiLogiX 
    { 
     public static class _Debug 
     { 
     static int indx; //Line numbers 
     
     static Form fdebug = new Form(); 
     static RichTextBox rtext = new RichTextBox(); 
     static Font fn = new Font("Lucida Console", 10); 
     // PROPS 
     public struct ConFig 
     { 
     private static Color backColor = Color.Black; 
     private static Color foreColor = Color.LightBlue; 
     //private static Boolean MultiLine = true; 
     private static DockStyle docking = DockStyle.Fill; 
     private static Boolean read_only = true; 
     private static Boolean enabled = false; 
     private static Boolean bullet = true; 
     private static int indent = 8; 
     private static Boolean detectURL = true; 
     private static float opacity = 0.85F; 
     private static Boolean showInTaskbar = true; 
     private static Boolean topMost = true; 
     private static Boolean details = true; 
     
     public static Color BackColor 
     { get { return backColor; } set { backColor = value; } } 
     
     public static Color ForeColor 
     { get { return foreColor; } set { foreColor = value; } } 
     
     public static Boolean Readonly 
     { get { return read_only; } set { read_only = value; } } 
     
     public static Boolean Enabled 
     { get { return enabled; } set { enabled = value; } } 
     
     public static Boolean Bullet 
     { get { return bullet; } set { bullet = value; } } 
     
     public static int Indent 
     { get { return indent; } set { indent = value; } } 
     
     public static Boolean DetectURL 
     { get { return detectURL; } set { detectURL = value; } } 
     
     public static float Opacity 
     { get { return opacity; } set { opacity = value; } } 
     
     public static Boolean ShowInTaskbar 
     { get { return showInTaskbar; } set { showInTaskbar = value; } } 
     
     //public static 
     //{ get { return detectURL; } set { detectURL = value; } } 
     
     public static Boolean TopMostWindow 
     {get { return topMost; } set { topMost = value; }} 
     
     static public bool Details 
     {get { return details; } set { details = value; }} 
     
     static public DockStyle Docking 
     { get { return docking; } set { docking = value; } } 
     } 
     //} 
     //static public bool details; 
     
     
     
    //        static string rheader = @"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0 Arial;}} 
    //{\colortbl ;\red255\green255\blue255;\red255\green0\blue0;\red0\green255\blue0;\red0\green0\blue255;\red0\green255\blue255;\red255\green0\blue255;\red255\green100\blue0;} 
    //{\*\generator Msftedit 5.41.15.1515;}\viewkind4\uc1\pard\f0\fs20"; 
     
     public static void BUG(Exception e) 
     { 
     MessageBox.Show(e.Message + "\nSOURCE: [" + e.Source + "]\nTARGET: " + e.TargetSite + "\nSTACKTRACE: " + e.StackTrace + "\nDATA: [ " + e.Data +" ]", "XXX ERROR XXX", MessageBoxButtons.OK, MessageBoxIcon.Error); 
     } 
     
     
     public static void Create() 
     { 
     //frtb.Top = 11; 
     //frtb.Left = 1; 
     //frtb.Width = 200; 
     //frtb.Height = 200; 
     rtext.BackColor = Color.White; 
     rtext.ForeColor = Color.Black; 
     rtext.Multiline = true; 
     rtext.ScrollBars = RichTextBoxScrollBars.Both; 
     rtext.BorderStyle = BorderStyle.None; 
     rtext.Parent = fdebug; 
     rtext.Dock = DockStyle.Fill; 
     rtext.Font = fn; 
     rtext.ReadOnly = true; 
     rtext.Cursor = Cursors.Arrow; 
     //frtb.Enabled = false; 
     //rtext.SelectionBullet = true; 
     //rtext.SelectionIndent = 8; 
     rtext.DetectUrls = true; 
     rtext.Name = "frtb"; 
     //rtext.Text = "Debug Output"; 
    //            rtext.Rtf = @"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0 Arial;}} 
    //{\colortbl ;\red255\green255\blue255;\red255\green0\blue0;\red0\green255\blue0;\red0\green0\blue255;\red0\green255\blue255;\red255\green0\blue255;\red255\green100\blue0;} 
    //{\*\generator Msftedit 5.41.15.1515;}\viewkind4\uc1\pard\f0\fs20 black\par 
    // 
    //"; 
     
     
     fdebug.Controls.Add(rtext); 
     
     fdebug.BackColor = Color.Black; 
     fdebug.Opacity = 0.85; 
     fdebug.Text = ":: DEBUG ::"; 
     fdebug.ShowInTaskbar = true; 
     fdebug.StartPosition = FormStartPosition.CenterScreen; 
     fdebug.WindowState = FormWindowState.Normal; 
     fdebug.Width = 500; 
     fdebug.TopMost = ConFig.TopMostWindow; 
     fdebug.Show(); 
     
     } 
     
     
     public static void Print(Object data) 
     { 
     Create(); 
     string tag = "\n" + indx.ToString() + " > #"+ data + " ##"+ data.ToString()  +"##: \n"; 
     //rtext.AppendText(tag + data); 
     indx++; 
     
     tag += "[ " + data.GetType().Name.ToString() + "] "; 
     tag += "{Namespace: " + data.GetType().Namespace + "}"; 
     tag += "[SystemType: " + data.GetType().UnderlyingSystemType.ToString() + "]"; 
     if (data.GetType().IsClass) 
     tag += "{Class}"; 
     if (data.GetType().IsAbstract) 
     tag += "(Abstract)"; 
     if (data.GetType().IsAnsiClass) 
     tag += "(AnsiClass)"; 
     if (data.GetType().IsPublic) 
     tag += "(Public)"; 
     if (data.GetType().IsSealed) 
     tag += "(Sealed)"; 
     if (data.GetType().IsAutoClass) 
     tag += "(AutoClass)"; 
     
     if (data.GetType().IsInterface) 
     tag += "(Interface)"; 
     
     if (data.GetType().IsPointer) 
     tag += "(Pointer)"; 
     if (data.GetType().IsArray) 
     tag += "(Array)"; 
     if (data.GetType().IsEnum) 
     tag += "(Enum)"; 
     
     if (data.GetType().IsAutoLayout) 
     tag += "(AutoLayout)"; 
     if (data.GetType().IsByRef) 
     tag += "(ByRef)"; 
     if (data.GetType().IsNotPublic) 
     tag += "(NotPublic)"; 
     //rtext.SelectionBullet = true; 
     
     
     if (ConFig.Details==true) 
     { 
     
     tag += "\n[RuntimeTypeHandle: " + data.GetType().TypeHandle.Value.ToString() + "]\n"; 
     
     
     if (data.GetType().IsCOMObject) 
     tag += "(COMobject)"; 
     if (data.GetType().IsContextful) 
     tag += "(Contextful)"; 
     
     if (data.GetType().IsExplicitLayout) 
     tag += "(ExplicitLayout)"; 
     if (data.GetType().IsGenericParameter) 
     tag += "(Genericparameter)"; 
     if (data.GetType().IsGenericType) 
     tag += "(GenericType)"; 
     if (data.GetType().IsGenericTypeDefinition) 
     tag += "(GenericTypeDefination)"; 
     if (data.GetType().IsImport) 
     tag += "(Import)"; 
     
     if (data.GetType().IsLayoutSequential) 
     tag += "(LayoutSequential)"; 
     if (data.GetType().IsMarshalByRef) 
     tag += "(MarshalByRef)"; 
     if (data.GetType().IsNested) 
     tag += "(Nested)"; 
     if (data.GetType().IsNestedAssembly) 
     tag += "(NestedAssembly)"; 
     if (data.GetType().IsNestedFamANDAssem) 
     tag += "(NestedFamANDAssem)"; 
     if (data.GetType().IsNestedFamily) 
     tag += "(NestedFamily)"; 
     if (data.GetType().IsNestedFamORAssem) 
     tag += "(NestedFamORAssem)"; 
     if (data.GetType().IsNestedPrivate) 
     tag += "(NestedPrivate)"; 
     if (data.GetType().IsNestedPublic) 
     tag += "(NestedPublic)"; 
     
     
     if (data.GetType().IsPrimitive) 
     tag += "(Primitive)"; 
     
     if (data.GetType().IsSerializable) 
     tag += "(Serializable)"; 
     if (data.GetType().IsSpecialName) 
     tag += "(SpecialName)"; 
     if (data.GetType().IsUnicodeClass) 
     tag += "(UnicodeClass)"; 
     if (data.GetType().IsValueType) 
     tag += "(ValueType)"; 
     if (data.GetType().IsVisible) 
     tag += "(Visible)"; 
     //if (data.GetType().MemberType) 
     tag += "\n(MemberType: " + data.GetType().MemberType.ToString() + ")"; 
     //if (data.GetType().MetadataToken) 
     tag += "(MetadataToken: " + data.GetType().MetadataToken.ToString() + ")"; 
     //if (data.GetType().Module) 
     tag += "\n[Module:" + data.GetType().Module.ToString() + ")"; 
     //if (data.GetType().ReflectedType) 
     tag += "\n[Module.FullyQualifiedName: " + data.GetType().Module.FullyQualifiedName.ToString() + "]"; 
     tag += "\n  [MDStreamVersion: " + data.GetType().Module.MDStreamVersion.ToString() + "]"; 
     tag += "\n  [MetadaataToken: " + data.GetType().Module.MetadataToken.ToString() + "]"; 
     tag += "\n  [ModuleHandle: " + data.GetType().Module.ModuleHandle.ToString() + "]"; 
     tag += "\n  [ModuleVersionID: " + data.GetType().Module.ModuleVersionId.ToString() + "]"; 
     tag += "\n  [Name: " + data.GetType().Module.Name.ToString() + "]"; 
     tag += "\n  [ScopeName: " + data.GetType().Module.ScopeName.ToString() + "]\n"; 
     } 
     
     
     rtext.AppendText(""+tag); 
     
     
     } 
     
     } 
    }