Advertisement
Guest User

Passive MVP -WinForms Code Example

a guest
Jan 30th, 2015
352
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.21 KB | None | 0 0
  1. namespace Winforms.Views.Bootstrap
  2. {
  3.     public partial class BootstrapView : Form, IBootstrapView
  4.     {
  5.         public BootstrapView()
  6.         {
  7.             InitializeComponent();
  8.         }        
  9.  
  10.         #region IBootstrapView
  11.         public event QuitApplicationEventHandler QuitApplication;
  12.         private void uxQuit_Click(object sender, EventArgs e)
  13.         {
  14.             if (QuitApplication != null) {
  15.                 QuitApplication(this, ActionEventArgs.Empty);
  16.             }
  17.         }
  18.  
  19.         public event StartBootstrapEventHandler StartBootstrap;
  20.         private bool _startBootstrapCalled = false;
  21.         private void BootstrapView_Activated(object sender, EventArgs e)
  22.         {
  23.             if (StartBootstrap != null && !_startBootstrapCalled) {
  24.                 _startBootstrapCalled = true;
  25.                 StartBootstrap();
  26.             }
  27.         }
  28.  
  29.         public string Title
  30.         {
  31.             set { this.Text = value; }
  32.         }
  33.         public ProgressInfo Progress
  34.         {
  35.             set {
  36.                 uxProgressMessage.Text = value.Message;
  37.                 if (value.IsIndeterminate) {
  38.                     uxProgress.Style = ProgressBarStyle.Marquee;
  39.                 } else {
  40.                     uxProgress.Style = ProgressBarStyle.Continuous;
  41.                     uxProgress.Minimum = value.Range.Minimum;
  42.                     uxProgress.Maximum = value.Range.Maximum;
  43.                     uxProgress.Value = value.Progress;
  44.                 }
  45.             }
  46.         }
  47.         #endregion              
  48.     }
  49.  
  50.  
  51.     partial class BootstrapView
  52.     {
  53.         /// <summary>
  54.         /// Required designer variable.
  55.         /// </summary>
  56.         private System.ComponentModel.IContainer components = null;
  57.  
  58.         /// <summary>
  59.         /// Clean up any resources being used.
  60.         /// </summary>
  61.         /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
  62.         protected override void Dispose(bool disposing)
  63.         {
  64.             if (disposing && (components != null)) {
  65.                 components.Dispose();
  66.             }
  67.             base.Dispose(disposing);
  68.         }
  69.  
  70.         #region Windows Form Designer generated code
  71.  
  72.         /// <summary>
  73.         /// Required method for Designer support - do not modify
  74.         /// the contents of this method with the code editor.
  75.         /// </summary>
  76.         private void InitializeComponent()
  77.         {
  78.             this.uxQuit = new System.Windows.Forms.Button();
  79.             this.uxProgress = new System.Windows.Forms.ProgressBar();
  80.             this.uxProgressMessage = new System.Windows.Forms.Label();
  81.             this.SuspendLayout();
  82.             //
  83.             // uxQuit
  84.             //
  85.             this.uxQuit.Location = new System.Drawing.Point(402, 44);
  86.             this.uxQuit.Name = "uxQuit";
  87.             this.uxQuit.Size = new System.Drawing.Size(75, 23);
  88.             this.uxQuit.TabIndex = 0;
  89.             this.uxQuit.Text = "Afsluiten";
  90.             this.uxQuit.UseVisualStyleBackColor = true;
  91.             this.uxQuit.Click += new System.EventHandler(this.uxQuit_Click);
  92.             //
  93.             // uxProgress
  94.             //
  95.             this.uxProgress.Location = new System.Drawing.Point(12, 44);
  96.             this.uxProgress.Name = "uxProgress";
  97.             this.uxProgress.Size = new System.Drawing.Size(384, 23);
  98.             this.uxProgress.Style = System.Windows.Forms.ProgressBarStyle.Marquee;
  99.             this.uxProgress.TabIndex = 1;
  100.             //
  101.             // uxProgressMessage
  102.             //
  103.             this.uxProgressMessage.AutoSize = true;
  104.             this.uxProgressMessage.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
  105.             this.uxProgressMessage.Location = new System.Drawing.Point(12, 21);
  106.             this.uxProgressMessage.Name = "uxProgressMessage";
  107.             this.uxProgressMessage.Size = new System.Drawing.Size(157, 16);
  108.             this.uxProgressMessage.TabIndex = 2;
  109.             this.uxProgressMessage.Text = "%uxProgressMessage%";
  110.             //
  111.             // BootstrapView
  112.             //
  113.             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
  114.             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  115.             this.ClientSize = new System.Drawing.Size(489, 79);
  116.             this.ControlBox = false;
  117.             this.Controls.Add(this.uxProgressMessage);
  118.             this.Controls.Add(this.uxProgress);
  119.             this.Controls.Add(this.uxQuit);
  120.             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
  121.             this.Name = "BootstrapView";
  122.             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
  123.             this.Text = "%BootstrapView%";
  124.             this.Activated += new System.EventHandler(this.BootstrapView_Activated);
  125.             this.ResumeLayout(false);
  126.             this.PerformLayout();
  127.  
  128.         }
  129.  
  130.         #endregion
  131.  
  132.         private System.Windows.Forms.Button uxQuit;
  133.         private System.Windows.Forms.ProgressBar uxProgress;
  134.         private System.Windows.Forms.Label uxProgressMessage;
  135.     }
  136. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement