Click here to Skip to main content
15,910,603 members
Home / Discussions / C#
   

C#

 
AnswerRe: fed up with microsoft unnecessary technologies Pin
Pete O'Hanlon13-Aug-08 10:16
mvePete O'Hanlon13-Aug-08 10:16 
GeneralRe: fed up with microsoft unnecessary technologies Pin
Mogaambo13-Aug-08 10:38
Mogaambo13-Aug-08 10:38 
GeneralRe: fed up with microsoft unnecessary technologies Pin
Pete O'Hanlon13-Aug-08 10:57
mvePete O'Hanlon13-Aug-08 10:57 
AnswerRe: fed up with microsoft unnecessary technologies Pin
teejayem13-Aug-08 12:45
teejayem13-Aug-08 12:45 
Question[Solved]Getting a list of installed fonts. [modified] Pin
Jordanwb13-Aug-08 9:29
Jordanwb13-Aug-08 9:29 
AnswerRe: Getting a list of installed fonts. Pin
Manas Bhardwaj13-Aug-08 9:46
professionalManas Bhardwaj13-Aug-08 9:46 
GeneralRe: Getting a list of installed fonts. Pin
Jordanwb13-Aug-08 9:48
Jordanwb13-Aug-08 9:48 
QuestionAccess Mainframe From C# Pin
Kevin Marois13-Aug-08 8:47
professionalKevin Marois13-Aug-08 8:47 
AnswerRe: Access Mainframe From C# Pin
User 665813-Aug-08 10:27
User 665813-Aug-08 10:27 
GeneralRe: Access Mainframe From C# Pin
Kevin Marois13-Aug-08 10:39
professionalKevin Marois13-Aug-08 10:39 
GeneralRe: Access Mainframe From C# Pin
User 665814-Aug-08 10:53
User 665814-Aug-08 10:53 
QuestionRemoving flash during resize Pin
AndrusM13-Aug-08 7:50
AndrusM13-Aug-08 7:50 
AnswerRe: Removing flash during resize Pin
Jordanwb13-Aug-08 9:30
Jordanwb13-Aug-08 9:30 
GeneralRe: Removing flash during resize Pin
AndrusM13-Aug-08 23:47
AndrusM13-Aug-08 23:47 
QuestionDevelopment Strategy Pin
BlitzPackage13-Aug-08 6:44
BlitzPackage13-Aug-08 6:44 
AnswerRe: Development Strategy Pin
PIEBALDconsult13-Aug-08 7:57
mvePIEBALDconsult13-Aug-08 7:57 
AnswerRe: Development Strategy Pin
Kevin Marois13-Aug-08 8:02
professionalKevin Marois13-Aug-08 8:02 
AnswerRe: Development Strategy Pin
Manas Bhardwaj13-Aug-08 8:05
professionalManas Bhardwaj13-Aug-08 8:05 
AnswerRe: Development Strategy Pin
BlitzPackage13-Aug-08 8:53
BlitzPackage13-Aug-08 8:53 
GeneralRe: Development Strategy Pin
PIEBALDconsult13-Aug-08 9:37
mvePIEBALDconsult13-Aug-08 9:37 
QuestionHow do I have a class globally accessible throughout an entire project/application Pin
tkrn13-Aug-08 6:21
tkrn13-Aug-08 6:21 
I am trying to create a Log Console that will be a hidden form that will called up when LogConsole.Show() is issued, and write to the Data Grid that is not bound by using the methods as defined. I never done anything like that and I need direction.

Take a look at the code below to get a feel for what i am trying to do.


namespace System.Diagnostics
{
    public class LogConsole
    {
        public static readonly LogConsole Instance = new LogConsole();
        private LogConsoleWrapper LogConsoleForm = new LogConsoleWrapper();

        public void Show()
        {
            LogConsoleForm.Show();
        }

        public void Hide()
        {
            LogConsoleForm.Hide();
        }

        public void Focus()
        {
            LogConsoleForm.Focus();
        }

        public void WriteLine(string message)
        {
            LogConsoleForm.Write(message);
        }

        public void WriteLine(string message, bool error)
        {
            LogConsoleForm.Write(message, error);
        }

        public void WriteLine(string message, Exception ex)
        {
            LogConsoleForm.Write(message, (Exception)ex);
        }
    }

    public class LogConsoleWrapper : System.Windows.Forms.Form
    {
        /// <summary>
		/// Required designer variable.
		/// </summary>
		/// 
		private System.ComponentModel.Container components = null;

        static string sSource = "PIMSLite2008 Log Console";
        static string sLog = "Application";

        public LogConsoleWrapper()
		{
			InitializeComponent();

            if (!EventLog.SourceExists(sSource))
                EventLog.CreateEventSource(sSource, sLog);

            clock.Start();
            lblUser.Text = System.Environment.UserName.ToString().ToUpper();
		}

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// 
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region User Defined Code

        private void clock_Tick(object sender, EventArgs e)
        {
            lblDate.Text = DateTime.Now.ToShortDateString();
            lblTime.Text = DateTime.Now.ToLongTimeString();
        }

        public void Write(string message)
        {
            string[] tmp = new string[3];

            tmp[0] = DateTime.Now.ToLongTimeString() + " " + DateTime.Now.ToShortDateString();

            tmp[1] = "N/A";

            tmp[2] = message;

            dgLog.Rows.Add(tmp);
        }

        public void Write(string message, bool error)
        {
            string[] tmp = new string[3];

            tmp[0] = DateTime.Now.ToLongTimeString() + " " + DateTime.Now.ToShortDateString();

            if (error == true)
            {
                tmp[1] = "Error";
            }
            else
            {
                tmp[1] = "Information";
            }

            tmp[2] = message;

            dgLog.Rows.Add(tmp);
        }

        public void Write(string message, Exception ex)
        {
            string[] tmp = new string[3];

            tmp[0] = DateTime.Now.ToLongTimeString() + " " + DateTime.Now.ToShortDateString();
            tmp[1] = "Error";
            tmp[2] = message;

            dgLog.Rows.Add(tmp);

            string errorMessage = "USER: " + System.Environment.UserName + "\r\n" + new String('-', 100) + "\r\nFUNCTION: " + System.Reflection.MethodBase.GetCurrentMethod().ToString() + "\r\n" + new String('-', 100) + "\r\nSOURCE: \r\n" + ex.Source + "\r\n" + new String('-', 100) + "\r\nMESSAGE: \r\n" + ex.Message + "\r\n" + new String('-', 100) + "\r\nCUSTOM MESSAGE:\r\n" + message + "\r\n" + new String('-', 100) + "\r\nSTACK TRACE: \r\n" + ex.StackTrace;
            EventLog.WriteEntry(sSource, errorMessage, System.Diagnostics.EventLogEntryType.Error);
        }

        #endregion

AnswerRe: How do I have a class globally accessible throughout an entire project/application Pin
BlitzPackage13-Aug-08 6:40
BlitzPackage13-Aug-08 6:40 
AnswerRe: How do I have a class globally accessible throughout an entire project/application Pin
Mark Salsbery13-Aug-08 6:51
Mark Salsbery13-Aug-08 6:51 
GeneralRe: How do I have a class globally accessible throughout an entire project/application Pin
BlitzPackage13-Aug-08 8:30
BlitzPackage13-Aug-08 8:30 
GeneralRe: How do I have a class globally accessible throughout an entire project/application Pin
Mark Salsbery13-Aug-08 8:39
Mark Salsbery13-Aug-08 8:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.