Beispiel #1
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            EventLogMonitor eventLogMonitor = new EventLogMonitor("Enter Log Name Here", this.notificationManager, this.settingsManager);

            this.EventLogMonitors.Insert(0, eventLogMonitor);
            this.lstEventLogMonitors.SelectedItem = eventLogMonitor;
        }
Beispiel #2
0
 private void eventLogger_EntryWritten(object sender, EntryWrittenEventArgs e)
 {
     try
     {
         EventLogEntry entry        = e.Entry;
         string[]      eventLogName = new string[] { "New ", this.EventLogName, " ", e.Entry.EntryType.ToString(), " Logged!" };
         string        str          = string.Concat(eventLogName);
         string        str1         = e.Entry.EntryType.ToString();
         string        str2         = str1;
         if (str1 != null)
         {
             if (str2 == "Information")
             {
                 if (this.RaiseMessages)
                 {
                     this._notificationManager.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => this._notificationManager.Notify(str, entry.Message, entry.TimeGenerated.ToShortTimeString(), false, (Notifications.NotificationType)Enum.Parse(typeof(Notifications.NotificationType), "Information"), this.EventLogName)));
                 }
             }
             else if (str2 != "Warning")
             {
                 if (str2 == "Error")
                 {
                     if (this.RaiseErrors)
                     {
                         this._notificationManager.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => this._notificationManager.Notify(str, entry.Message, entry.TimeGenerated.ToShortTimeString(), false, (Notifications.NotificationType)Enum.Parse(typeof(Notifications.NotificationType), "Error"), this.EventLogName)));
                     }
                 }
             }
             else if (this.RaiseWarnings)
             {
                 this._notificationManager.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => this._notificationManager.Notify(str, entry.Message, entry.TimeGenerated.ToShortTimeString(), false, (Notifications.NotificationType)Enum.Parse(typeof(Notifications.NotificationType), "Warning"), this.EventLogName)));
             }
         }
         if (this.EventLogged != null)
         {
             this.EventLogged(this, null);
         }
         EventLogMonitor eventsLogged = this;
         eventsLogged.EventsLogged = eventsLogged.EventsLogged + 1;
         this.LastEventTimeStamp   = DateTime.Now.ToLongTimeString();
         this.OnPropertyChanged("EventLogged");
     }
     catch (Exception exception1)
     {
         Exception exception = exception1;
         // TODO Add proper logging back
         //GUErrorManager.Instance.LogError(string.Concat("Error creating event log notification! Error: ", exception.ToString()));
     }
 }
Beispiel #3
0
        public MainWindow()
        {
            this.InitializeComponent();
            this.settingsManager     = new SettingsManager("EventNotifier.exe.config");
            this.notificationManager = new Notifications();
            this.notificationManager.Show();
            this.NotificationScale    = Convert.ToDouble(this.settingsManager.GetValue("NotificationScale", "1"));
            this.NotificationDuration = Convert.ToInt32(this.settingsManager.GetValue("NotificationDuration", "7"));
            this.notificationManager.NotificationDuration = (long)this.NotificationDuration;
            this._eventLogMonitorList = this.settingsManager.GetValue("EventLogMonitorList", "Miner");
            this.EventLogMonitors     = new ObservableCollection <EventLogMonitor>();
            string[] strArrays = this._eventLogMonitorList.Split(new char[] { ',' });
            for (int i = 0; i < (int)strArrays.Length; i++)
            {
                string str = strArrays[i];
                if (str != "")
                {
                    EventLogMonitor eventLogMonitor = new EventLogMonitor(str, this.notificationManager, this.settingsManager);
                    eventLogMonitor.InitializeMonitor();
                    this.EventLogMonitors.Add(eventLogMonitor);
                }
            }
            this.icon = new System.Windows.Forms.NotifyIcon()
            {
                Icon    = new Icon(Assembly.GetExecutingAssembly().GetManifestResourceStream("EventNotifier.Images.TrayInformation.ico")),
                Visible = true
            };

            this.icon.Click += new EventHandler((object sender, EventArgs args) => {
                if (base.Visibility == Visibility.Visible)
                {
                    base.Hide();
                    return;
                }
                base.Activate();
                base.Show();
            });

            base.Loaded      += new RoutedEventHandler(this.MainWindow_Loaded);
            base.Activated   += new EventHandler(this.MainWindow_Activated);
            base.Closing     += new CancelEventHandler(this.MainWindow_Closing);
            base.Deactivated += new EventHandler(this.MainWindow_Deactivated);
            base.Show();
        }