ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/EmuXPortal/branches/mono/EmuXPortal/UI/SplashLoader.cs
Revision: 482
Committed: Sat Nov 21 04:19:04 2020 UTC (20 months, 3 weeks ago) by william
File size: 2520 byte(s)
Log Message:
wip for speeding up control rendering

File Contents

# Content
1 #define HAVE_X11_BORDERSTYLE_ERROR // indicates that there is an error with Control.set_InternalBorderStyle resulting in an X11 Error BadWindow (invalid Window parameter)
2 //#define DISABLE_CURSOR_HIDE // when this is present, the cursor will not be hidden
3 using System;
4 using System.Windows.Forms;
5 using EmuXPortal.Api;
6 using System.Drawing;
7 using Enterprise.Logging;
8 using Utilities.TransparentControls;
9
10 namespace EmuXPortal.UI
11 {
12 public class SplashLoader : Form
13 {
14 const float PROGRESS_BAR_FONT_SIZE = 24;
15 private CustomProgressBar progress_bar;
16 private AbortEvent abort_event;
17 private Timer timer;
18 public SplashLoader (AbortEvent abort_event)
19 {
20 InitializeComponent();
21 this.abort_event = abort_event;
22 timer.Start();
23 }
24 private void InitializeComponent ()
25 {
26
27 progress_bar = new CustomProgressBar();
28 timer = new Timer();
29 this.SuspendLayout();
30 //
31 // progress_bar
32 //
33 progress_bar.Dock = DockStyle.Top;
34 progress_bar.ProgressColor = Color.Lime;
35 progress_bar.Font = new Font(this.Font.FontFamily, PROGRESS_BAR_FONT_SIZE);
36 this.Controls.Add(progress_bar);
37 //
38 // timer
39 //
40 timer.Interval = 2500;
41 timer.Tick += Timer_Tick;
42 //
43 // this
44 //
45 this.BackColor = Color.Black;
46 this.ForeColor = Color.Lime;
47 this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
48 this.Load += SplashLoader_Load;
49 this.Shown += SplashLoader_Shown;
50 gLog.ReportProgressEvent += SplashLoader_ReportProgress;
51 this.ResumeLayout(false);
52 }
53
54 void Timer_Tick (object sender, EventArgs e)
55 {
56 if (this.abort_event != null && this.abort_event.Invoke ()) {
57 timer.Stop();
58 this.Close();
59 }
60 }
61 private Font ResizeFont(Font font, float size)
62 {
63 return new Font(font.FontFamily, size);
64 }
65
66 private void SplashLoader_ReportProgress (object sender, ReportProgressEventArgs e)
67 {
68
69 int progress = e.Progress;
70 string message = e.UserState == null ? "" : e.UserState.ToString ();
71 progress_bar.Message = message;
72 progress_bar.Value = progress;
73 }
74 private void SplashLoader_Load (object sender, EventArgs e)
75 {
76 Config.InitializePresentationForm(this);
77 progress_bar.Margin = new System.Windows.Forms.Padding (0);
78 progress_bar.Size = new Size (this.Width - 25, 100);
79
80 }
81 private void SplashLoader_Shown(object sender, EventArgs e)
82 {
83 #if !DISABLE_CURSOR_HIDE
84 Cursor.Hide();
85 #else
86 Cursor.Show();
87 #endif
88 }
89 }
90 }
91