source: trunk/eraser/Eraser.BlackBox/BlackBoxNotifier.cs @ 2960

Revision 2958, 2.6 KB checked in by gtrant, 5 days ago (diff)

Updated Copyright to 2014
Updated versions to 6.2
Fix for date stamp on erased artefacts

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Rev URL
Line 
1/*
2 * $Id$
3 * Copyright 2008-2014 The Eraser Project
4 * Original Author: Joel Low <lowjoel@users.sourceforge.net>
5 * Modified By:
6 *
7 * This file is part of Eraser.
8 *
9 * Eraser is free software: you can redistribute it and/or modify it under the
10 * terms of the GNU General Public License as published by the Free Software
11 * Foundation, either version 3 of the License, or (at your option) any later
12 * version.
13 *
14 * Eraser is distributed in the hope that it will be useful, but WITHOUT ANY
15 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17 *
18 * A copy of the GNU General Public License can be found at
19 * <http://www.gnu.org/licenses/>.
20 */
21
22using System;
23using System.Collections.Generic;
24using System.Linq;
25using System.Text;
26
27using System.Windows.Forms;
28
29using Eraser.Plugins.ExtensionPoints;
30using Eraser.Util;
31
32namespace Eraser.BlackBox
33{
34    /// <summary>
35    /// Notifier plugin that will tell the user when there are pending reports for
36    /// upload.
37    /// </summary>
38    class BlackBoxNotifier : INotifier
39    {
40        #region INotifier Members
41
42        public INotificationSink Sink
43        {
44            set
45            {
46                sink = value;
47                ShowNotification();
48            }
49        }
50       
51        private INotificationSink sink;
52
53        public void Clicked(object sender, EventArgs e)
54        {
55            OnClick(sender, e);
56        }
57
58        public void Closed(object sender, EventArgs e)
59        {
60        }
61
62        public void Shown(object sender, EventArgs e)
63        {
64        }
65
66        #endregion
67
68        #region IRegisterable Members
69
70        public Guid Guid
71        {
72            get { return new Guid("74C96E7D-570D-420A-A1EE-0CFCB0C46CCF"); }
73        }
74
75        #endregion
76
77        /// <summary>
78        /// Shows the notification to the user.
79        /// </summary>
80        private void ShowNotification()
81        {
82            if (sink == null || HasShown)
83                return;
84
85            HasShown = true;
86            sink.ShowNotification(this, 0, System.Windows.Forms.ToolTipIcon.Info,
87                S._("Eraser BlackBox: Crash Reports Collected"),
88                S._("There are crash reports which have yet to be submitted. Click on this " +
89                    "balloon to see the list of reports."));
90        }
91
92        /// <summary>
93        /// Called when the user clicks on the balloon.
94        /// </summary>
95        /// <param name="sender"></param>
96        /// <param name="e"></param>
97        private void OnClick(object sender, EventArgs e)
98        {
99            BlackBoxMainForm form = BlackBoxMainForm.Get();
100            Form owner = null;
101            if (Application.OpenForms.Count > 0)
102                owner = Application.OpenForms[0];
103
104            if (owner == null)
105            {
106                form.ShowInTaskbar = true;
107                form.Show();
108            }
109            else
110            {
111                form.ShowDialog(owner);
112            }
113        }
114
115        /// <summary>
116        /// Instance member to only show the notification once.
117        /// </summary>
118        private bool HasShown;
119    }
120}
Note: See TracBrowser for help on using the repository browser.