Statistics
| Branch: | Revision:

root / trunk / NetSparkle / NetSparkleMainWindows.cs @ 049333d2

History | View | Annotate | Download (1.5 kB)

1
using System;
2
using System.Collections.Generic;
3
using System.ComponentModel;
4
using System.Data;
5
using System.Drawing;
6
using System.Linq;
7
using System.Reflection;
8
using System.Text;
9
using System.Windows.Forms;
10
using System.IO;
11
using log4net;
12

    
13
namespace AppLimit.NetSparkle
14
{
15
    public partial class NetSparkleMainWindows : Form, IDisposable
16
    {
17
        private static readonly ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
18

    
19
        public NetSparkleMainWindows()
20
        {
21
            // init ui
22
            InitializeComponent();
23

    
24
        }
25

    
26
        public void Report(String message)
27
        {
28
            if (lstActions.InvokeRequired)
29
                lstActions.Invoke(new Action<String>(Report), message);
30
            else
31
            {
32
                // build the message 
33
                DateTime c = DateTime.Now;
34
                String msg = "[" + c.ToLongTimeString() + "." + c.Millisecond + "] " + message;
35

    
36
                // report to file
37
                ReportToFile(msg);
38

    
39
                // report the message into ui
40
                lstActions.Items.Add(msg);
41
            }
42
        }
43

    
44
        private void ReportToFile(String msg)
45
        {
46
            try
47
            {
48
                Log.Info(msg);
49
            } catch(Exception)
50
            {
51

    
52
            }
53
        }
54

    
55
        #region IDisposable Members
56

    
57
        void IDisposable.Dispose()
58
        {
59

    
60
            // close the base
61
            base.Dispose();
62
        }
63

    
64
        #endregion
65
    }
66
}