Advertisement
GlobalAccessSoftware

YesNoAlwaysForm.cs

Nov 7th, 2017
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.85 KB | None | 0 0
  1.  
  2.  
  3. //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
  4. // YesNoAlwaysForm.cs v1.0.2.21 03-Nov
  5. //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
  6. // Created by Jp Edwards as Shareware
  7. // and as a Fresher Course in Windows
  8. // Forms Apps, OOP and C#.NET
  9. //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
  10. // This is an Early Version meant to
  11. // inspire freshers to dive right in
  12. // and away from mere console Apps, etc.
  13. // I've left many many things for you to
  14. // code and experiment with. Just beware
  15. // of the standard license and rights.
  16. // i.e. Share your improvements!
  17. // Ask questions, Collaborate!
  18. //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
  19. // ReUsable YesNoAlways Form w/CheckBox.
  20. // Pass in string Infotext & see below.
  21. //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
  22. // YesNoAlways Status Legend:
  23. // 1 = Yes, 2 = No,
  24. // 3 = Yes as Pref. 4 = No as Pref.
  25. //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
  26. // v1.0.2.26 19-Nov-17 More Flexible.
  27. //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
  28.  
  29. using System;
  30. using System.Windows.Forms;
  31. using ShowMeEditorStandAloneVersion.Properties;
  32. using SMS = ShowMeEditorStandAloneVersion
  33.   .Properties.Settings;
  34.  
  35. namespace ShowMeEditorStandAloneVersion
  36. {
  37.   public partial class YesNoAlwaysForm : Form
  38.   {
  39.     // Private Fields
  40.     private readonly string _txt, _ttl;
  41.  
  42.     // Public Auto Properties
  43.     public bool HideAlways { get; set; }
  44.     public int Status { get; private set; }
  45.     public System.Drawing.Point Local { get; set; }
  46.  
  47.     // Overloaded Constructors JIC
  48.     public YesNoAlwaysForm()
  49.     { InitializeComponent(); }
  50.  
  51.     // TextBox String only Version.
  52.     public YesNoAlwaysForm(string text)
  53.     {
  54.       if (!string.IsNullOrEmpty(text))
  55.         _txt = text;
  56.       InitializeComponent();
  57.     }
  58.  
  59.     // Text AND Title Version.
  60.     public YesNoAlwaysForm
  61.       (string text, string title)
  62.     {
  63.       if (!string.IsNullOrEmpty( text))
  64.         _txt = text;
  65.       if (!string.IsNullOrEmpty(title))
  66.         _ttl = title;
  67.       InitializeComponent();
  68.     }
  69.  
  70.     private void YnaFormLoading
  71.       (object sender, EventArgs e)
  72.     {
  73.       if (!string.IsNullOrEmpty(_ttl))
  74.         Text = _ttl;
  75.       if (!string.IsNullOrEmpty(_txt))
  76.         InfoTextBox.Text = _txt;
  77.       if (HideAlways)
  78.       {
  79.         //label1.Hide();
  80.         label1.Text = Resources.YNA_AYS;
  81.         PreferenceCheckBox.Hide();
  82.       }
  83.       Location = Local;
  84.     }
  85.  
  86.     private void
  87.       YesButtonClick(object sender, EventArgs e)
  88.     {
  89.       Status = 1;
  90.       CheckCheckBox();
  91.     }
  92.  
  93.     private void
  94.       NoButtonClick(object sender, EventArgs e)
  95.     {
  96.       Status = 2;
  97.       CheckCheckBox();
  98.     }
  99.  
  100.     private void CheckCheckBox()
  101.     {
  102.       if (PreferenceCheckBox.Checked)
  103.         Status += 2;
  104.       Local = Location;
  105.       Close();
  106.     }
  107.     // YesNoAlways Status Legend:
  108.     // 1 = Yes, 2 = No,
  109.     // 3 = Yes as Pref. 4 = No as Pref.
  110.   }
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement