10
10
namespace MonoDevelop.Ide.Gui.Dialogs {
12
public class SplashScreenForm : Gtk.Window, IProgressMonitor, IDisposable
12
public class SplashScreenForm : Window, IProgressMonitor, IDisposable
14
ConsoleProgressMonitor monitor = new ConsoleProgressMonitor ();
14
16
const int SplashFontSize = 10;
15
const string SplashFontFamily = "sans-serif";
17
static SplashScreenForm splashScreen;
18
static ProgressBar progress;
20
ProgressTracker tracker = new ProgressTracker ();
17
const string SplashFontFamily = "sans-serif";
22
static Gtk.Label label;
23
20
bool showVersionInfo;
25
public static SplashScreenForm SplashScreen {
27
if (splashScreen == null)
28
splashScreen = new SplashScreenForm();
33
22
//this is a popup so it behaves like other splashes on Windows, i.e. doesn't show up as a second window in the taskbar.
34
public SplashScreenForm () : base (Gtk.WindowType.Popup)
23
public SplashScreenForm () : base (WindowType.Popup)
36
25
AppPaintable = true;
37
26
this.Decorated = false;
38
27
this.WindowPosition = WindowPosition.Center;
39
28
this.TypeHint = Gdk.WindowTypeHint.Splashscreen;
40
29
this.showVersionInfo = BrandingService.GetBool ("SplashScreen", "ShowVersionInfo") ?? true;
42
using (var stream = BrandingService.GetStream ("SplashScreen.png", true))
43
bitmap = new Gdk.Pixbuf (stream);
44
} catch (Exception e) {
45
LoggingService.LogError ("Can't load splash screen pixbuf 'SplashScreen.png'.", e);
47
progress = new ProgressBar();
48
progress.Fraction = 0.00;
49
progress.HeightRequest = 6;
52
vbox.BorderWidth = 12;
53
label = new Gtk.Label ();
54
label.UseMarkup = true;
56
vbox.PackEnd (progress, false, true, 0);
57
vbox.PackEnd (label, false, true, 3);
60
this.Resize (bitmap.Width, bitmap.Height);
30
using (var stream = BrandingService.GetStream ("SplashScreen.png", true))
31
bitmap = new Gdk.Pixbuf (stream);
32
this.Resize (bitmap.Width, bitmap.Height);
63
35
protected override void OnDestroyed ()
164
136
c.Color = new Cairo.Color (161 / 255.0, 40 / 255.0, 48 / 255.0);
168
public static void SetProgress (double Percentage)
170
progress.Fraction = Percentage;
174
public void SetMessage (string Message)
176
if (bitmap == null) {
177
label.Text = Message;
179
label.Markup = "<span size='small' foreground='white'>" + Message + "</span>";
184
140
static void RunMainLoop ()
189
145
void IProgressMonitor.BeginTask (string name, int totalWork)
191
tracker.BeginTask (name, totalWork);
192
SetMessage (tracker.CurrentTask);
147
monitor.BeginTask (name, totalWork);
195
151
void IProgressMonitor.BeginStepTask (string name, int totalWork, int stepSize)
197
tracker.BeginStepTask (name, totalWork, stepSize);
198
SetMessage (tracker.CurrentTask);
153
monitor.BeginStepTask (name, totalWork, stepSize);
201
157
void IProgressMonitor.EndTask ()
204
SetProgress (tracker.GlobalWork);
205
SetMessage (tracker.CurrentTask);
208
163
void IProgressMonitor.Step (int work)
211
SetProgress (tracker.GlobalWork);
214
169
TextWriter IProgressMonitor.Log {
215
get { return Console.Out; }
170
get { return monitor.Log; }
218
173
void IProgressMonitor.ReportWarning (string message)
175
monitor.ReportWarning (message);
222
178
void IProgressMonitor.ReportSuccess (string message)
180
monitor.ReportSuccess (message);
226
183
void IProgressMonitor.ReportError (string message, Exception exception)
185
monitor.ReportError (message, exception);
230
188
bool IProgressMonitor.IsCancelRequested {
239
197
// The returned IAsyncOperation object must be thread safe
240
198
IAsyncOperation IProgressMonitor.AsyncOperation {
199
get { return monitor.AsyncOperation; }
244
202
object IProgressMonitor.SyncRoot {
203
get { return monitor.SyncRoot; }
248
206
void IDisposable.Dispose ()