PageRenderTime 41ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/CmsCheckin/StartUp.cs

https://bitbucket.org/mahalowe/bvcms
C# | 152 lines | 144 code | 8 blank | 0 comment | 12 complexity | 0bddaf85af0c1222070e1f186be3450a MD5 | raw file
Possible License(s): CC-BY-SA-3.0, Apache-2.0, BSD-3-Clause, LGPL-2.1, MPL-2.0-no-copyleft-exception, AGPL-3.0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.Net;
  10. using System.Xml.Linq;
  11. using System.Drawing.Printing;
  12. using System.Xml.Serialization;
  13. using System.IO;
  14. namespace CmsCheckin
  15. {
  16. public partial class StartUp : Form
  17. {
  18. public XDocument campuses { get; set; }
  19. public int CampusId
  20. {
  21. get
  22. {
  23. var c = cbCampusId.SelectedItem as Campus;
  24. if (c != null)
  25. return c.Id;
  26. return 0;
  27. }
  28. }
  29. public string AdminPassword
  30. {
  31. get
  32. {
  33. var c = cbCampusId.SelectedItem as Campus;
  34. if (c != null)
  35. return c.password;
  36. return "kio.";
  37. }
  38. }
  39. public int DayOfWeek
  40. {
  41. get
  42. {
  43. var d = cbDayOfWeek.SelectedItem as DayOfWeek;
  44. return d.Day;
  45. }
  46. }
  47. public StartUp()
  48. {
  49. InitializeComponent();
  50. cbDayOfWeek.Items.Add(new DayOfWeek { Day = 0, Text = "Sunday" });
  51. cbDayOfWeek.Items.Add(new DayOfWeek { Day = 1, Text = "Monday" });
  52. cbDayOfWeek.Items.Add(new DayOfWeek { Day = 2, Text = "Tuesday" });
  53. cbDayOfWeek.Items.Add(new DayOfWeek { Day = 3, Text = "Wednesday" });
  54. cbDayOfWeek.Items.Add(new DayOfWeek { Day = 4, Text = "Thursday" });
  55. cbDayOfWeek.Items.Add(new DayOfWeek { Day = 5, Text = "Friday" });
  56. cbDayOfWeek.Items.Add(new DayOfWeek { Day = 6, Text = "Saturday" });
  57. cbDayOfWeek.SelectedIndex = (int)DateTime.Now.DayOfWeek;
  58. }
  59. private void button1_Click(object sender, EventArgs e)
  60. {
  61. if (cbCampusId.Items.Count > 0)
  62. Settings1.Default.Campus = ((Campus)(cbCampusId.SelectedItem)).Name;
  63. Settings1.Default.AskChurch = AskChurch.Checked;
  64. Settings1.Default.AskChurchName = AskChurchName.Checked;
  65. Settings1.Default.AskEmFriend = AskEmFriend.Checked;
  66. Settings1.Default.AskGrade = AskGrade.Checked;
  67. Settings1.Default.KioskName = KioskName.Text;
  68. Settings1.Default.LateMinutes = LateMinutes.Text.ToInt();
  69. Settings1.Default.LeadHours = LeadHours.Text.ToInt();
  70. Settings1.Default.LateMinutes = LateMinutes.Text.ToInt();
  71. Settings1.Default.DisableJoin = DisableJoin.Checked;
  72. Settings1.Default.ExtraBlankLabel = ExtraBlankLabel.Checked;
  73. Settings1.Default.OldLabels = OldLabels.Checked;
  74. Settings1.Default.Save();
  75. if (OldLabels.Checked) Program.UseNewLabels = false;
  76. else Program.UseNewLabels = true;
  77. this.Hide();
  78. }
  79. private void StartUp_Load(object sender, EventArgs e)
  80. {
  81. #if DEBUG
  82. cbDayOfWeek.SelectedIndex = 0;
  83. HideCursor.Checked = false;
  84. #endif
  85. foreach (var i in campuses.Descendants("campus"))
  86. cbCampusId.Items.Add(new Campus
  87. {
  88. Id = int.Parse(i.Attribute("id").Value),
  89. Name = i.Attribute("name").Value,
  90. password = i.Attribute("password").Value
  91. });
  92. if (cbCampusId.Items.Count > 0)
  93. cbCampusId.SelectedIndex = 0;
  94. var ii = cbCampusId.FindStringExact(Settings1.Default.Campus);
  95. if (ii >= 0)
  96. cbCampusId.SelectedIndex = ii;
  97. ii = LeadHours.FindStringExact(Settings1.Default.LeadHours.ToString());
  98. if (ii >= 0)
  99. LeadHours.SelectedIndex = ii;
  100. ii = LateMinutes.FindStringExact(Settings1.Default.LateMinutes.ToString());
  101. if (ii >= 0)
  102. LateMinutes.SelectedIndex = ii;
  103. AskEmFriend.Checked = Settings1.Default.AskEmFriend;
  104. AskGrade.Checked = Settings1.Default.AskGrade;
  105. AskChurch.Checked = Settings1.Default.AskChurch;
  106. AskChurchName.Checked = Settings1.Default.AskChurchName;
  107. KioskName.Text = Settings1.Default.KioskName;
  108. DisableJoin.Checked = Settings1.Default.DisableJoin;
  109. ExtraBlankLabel.Checked = Settings1.Default.ExtraBlankLabel;
  110. OldLabels.Checked = Settings1.Default.OldLabels;
  111. }
  112. private void OldLabels_CheckedChanged(object sender, EventArgs e)
  113. {
  114. if (OldLabels.Checked)
  115. {
  116. ExtraBlankLabel.Checked = false;
  117. ExtraBlankLabel.Enabled = false;
  118. }
  119. else
  120. {
  121. ExtraBlankLabel.Enabled = true;
  122. }
  123. }
  124. }
  125. class DayOfWeek
  126. {
  127. public string Text { get; set; }
  128. public int Day { get; set; }
  129. public override string ToString()
  130. {
  131. return Text;
  132. }
  133. }
  134. class Campus
  135. {
  136. public string Name { get; set; }
  137. public int Id { get; set; }
  138. public string password { get; set; }
  139. public override string ToString()
  140. {
  141. return Name;
  142. }
  143. }
  144. }