Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace MonoMac.Views.Bootstrap
- {
- public class BootstrapView : NSWindow, IBootstrapView
- {
- public BootstrapView ()
- {
- Initialize ();
- }
- #region Initialization
- /// <summary>
- /// Show this instance.
- /// </summary>
- public void Show()
- {
- MakeKeyAndOrderFront(this);
- if (StartBootstrap != null) {
- StartBootstrap ();
- }
- }
- /// <summary>
- /// Initializes the view and it's controls.
- /// </summary>
- private void Initialize()
- {
- // Initialize window.
- InitializeWindow();
- // Initialize controls.
- InitializeControls();
- // Centers the window.
- Center();
- }
- /// <summary>
- /// Initializes the window.
- /// </summary>
- private void InitializeWindow ()
- {
- StyleMask = NSWindowStyle.Titled;
- SetContentSize (new SizeF (505, 54));
- }
- /// <summary>
- /// Initializes the controls.
- /// </summary>
- private void InitializeControls()
- {
- var padding = 10;
- // Progress Message
- uxProgressMessage = Controls.CreateLabel ("%uxProgressMessage%", 16);
- this.AddControl (uxProgressMessage, padding + 32, padding + 8);
- // Progress Spinner
- uxProgress = Controls.CreateProgressSpinner (18, 18);
- this.AddControl (uxProgress, padding + 8, padding + 8);
- // Quit Button
- uxQuit = Controls.CreateButton ("Afsluiten");
- uxQuit.Activated += uxQuit_Activated;
- this.AddControl (uxQuit, (int)(ContentView.Frame.Width - padding - uxQuit.Frame.Width), padding + 5);
- }
- private NSTextField uxProgressMessage;
- private NSProgressIndicator uxProgress;
- private NSButton uxQuit;
- #endregion
- #region IBootstrapView
- public event QuitApplicationEventHandler QuitApplication;
- private void uxQuit_Activated(object sender, EventArgs e)
- {
- if (QuitApplication != null) {
- QuitApplication (this, new ActionEventArgs(() => NSApplication.SharedApplication.Terminate(this)));
- }
- }
- public event StartBootstrapEventHandler StartBootstrap;
- public event ShowDebugInfoEventHandler ShowDebugInfo;
- public ProgressInfo Progress {
- set {
- uxProgressMessage.StringValue = value.Message;
- uxProgressMessage.SizeToFit ();
- if (!value.IsIndeterminate) {
- uxProgress.Indeterminate = false;
- uxProgress.MinValue = value.Range.Minimum;
- uxProgress.MaxValue = value.Range.Maximum;
- uxProgress.DoubleValue = value.Progress;
- }
- }
- }
- #endregion
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement