PageRenderTime 52ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/beta-1.0.2/Client/Setup/ChangeVersionDialog.cs

#
C# | 211 lines | 157 code | 28 blank | 26 comment | 4 complexity | 6ff0e1a7213ab195fb05ceb339d64077 MD5 | raw file
Possible License(s): CC-BY-SA-3.0
  1. //-----------------------------------------------------------------------
  2. // <copyright>
  3. // Copyright (C) Ruslan Yakushev for the PHP Manager for IIS project.
  4. //
  5. // This file is subject to the terms and conditions of the Microsoft Public License (MS-PL).
  6. // See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL for more details.
  7. // </copyright>
  8. //-----------------------------------------------------------------------
  9. //#define VSDesigner
  10. using System;
  11. using System.Collections;
  12. using System.Windows.Forms;
  13. using Microsoft.Web.Management.Client.Win32;
  14. namespace Web.Management.PHP.Setup
  15. {
  16. internal sealed class ChangeVersionDialog :
  17. #if VSDesigner
  18. Form
  19. #else
  20. TaskForm
  21. #endif
  22. {
  23. private PHPModule _module;
  24. private bool _canAccept;
  25. private ManagementPanel _contentPanel;
  26. private Label _selectVersionLabel;
  27. private ComboBox _versionComboBox;
  28. /// <summary>
  29. /// Required designer variable.
  30. /// </summary>
  31. private System.ComponentModel.IContainer components = null;
  32. public ChangeVersionDialog(PHPModule module) : base(module)
  33. {
  34. _module = module;
  35. InitializeComponent();
  36. InitializeUI();
  37. try
  38. {
  39. ArrayList versions = _module.Proxy.GetAllPHPVersions();
  40. foreach (string[] version in versions)
  41. {
  42. _versionComboBox.Items.Add(new PHPVersion(version[0], version[1], version[2]));
  43. }
  44. _versionComboBox.DisplayMember = "Version";
  45. _versionComboBox.SelectedIndex = 0;
  46. if (_versionComboBox.Items.Count > 0)
  47. {
  48. _canAccept = true;
  49. UpdateTaskForm();
  50. }
  51. }
  52. catch (Exception ex)
  53. {
  54. DisplayErrorMessage(ex, Resources.ResourceManager);
  55. }
  56. }
  57. protected override bool CanAccept
  58. {
  59. get
  60. {
  61. return _canAccept;
  62. }
  63. }
  64. protected override bool CanShowHelp
  65. {
  66. get
  67. {
  68. return true;
  69. }
  70. }
  71. /// <summary>
  72. /// Clean up any resources being used.
  73. /// </summary>
  74. /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
  75. protected override void Dispose(bool disposing)
  76. {
  77. if (disposing && (components != null))
  78. {
  79. components.Dispose();
  80. }
  81. base.Dispose(disposing);
  82. }
  83. private void InitializeComponent()
  84. {
  85. this._selectVersionLabel = new System.Windows.Forms.Label();
  86. this._versionComboBox = new System.Windows.Forms.ComboBox();
  87. this.SuspendLayout();
  88. //
  89. // _selectVersionLabel
  90. //
  91. this._selectVersionLabel.AutoSize = true;
  92. this._selectVersionLabel.Location = new System.Drawing.Point(0, 13);
  93. this._selectVersionLabel.Name = "_selectVersionLabel";
  94. this._selectVersionLabel.Size = new System.Drawing.Size(102, 13);
  95. this._selectVersionLabel.TabIndex = 0;
  96. this._selectVersionLabel.Text = "Select PHP version:";
  97. //
  98. // _versionComboBox
  99. //
  100. this._versionComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  101. this._versionComboBox.FormattingEnabled = true;
  102. this._versionComboBox.Location = new System.Drawing.Point(3, 30);
  103. this._versionComboBox.Name = "_versionComboBox";
  104. this._versionComboBox.Size = new System.Drawing.Size(326, 21);
  105. this._versionComboBox.TabIndex = 1;
  106. //
  107. // ChangeVersionDialog
  108. //
  109. this.ClientSize = new System.Drawing.Size(364, 142);
  110. this.Controls.Add(this._versionComboBox);
  111. this.Controls.Add(this._selectVersionLabel);
  112. this.Name = "ChangeVersionDialog";
  113. this.ResumeLayout(false);
  114. this.PerformLayout();
  115. }
  116. private void InitializeUI()
  117. {
  118. _contentPanel = new ManagementPanel();
  119. _contentPanel.SuspendLayout();
  120. this._contentPanel.Location = new System.Drawing.Point(0, 0);
  121. this._contentPanel.Dock = DockStyle.Fill;
  122. this._contentPanel.Controls.Add(_selectVersionLabel);
  123. this._contentPanel.Controls.Add(_versionComboBox);
  124. this._contentPanel.ResumeLayout(false);
  125. this._contentPanel.PerformLayout();
  126. this.Text = Resources.ChangeVersionDialogTitle;
  127. SetContent(_contentPanel);
  128. UpdateTaskForm();
  129. }
  130. protected override void OnAccept()
  131. {
  132. PHPVersion selectedItem = (PHPVersion)_versionComboBox.SelectedItem;
  133. try
  134. {
  135. _module.Proxy.SelectPHPVersion(selectedItem.Name);
  136. DialogResult = DialogResult.OK;
  137. }
  138. catch (Exception ex)
  139. {
  140. DisplayErrorMessage(ex, Resources.ResourceManager);
  141. }
  142. Close();
  143. }
  144. protected override void ShowHelp()
  145. {
  146. Helper.Browse(Globals.ChangeVersionOnlineHelp);
  147. }
  148. // Used internally for the select version combo box
  149. private class PHPVersion
  150. {
  151. private string _name;
  152. private string _scriptProcessor;
  153. private string _version;
  154. public PHPVersion(string name, string scriptProcessor, string version)
  155. {
  156. _name = name;
  157. _scriptProcessor = scriptProcessor;
  158. _version = version;
  159. }
  160. public string Name
  161. {
  162. get
  163. {
  164. return _name;
  165. }
  166. }
  167. public string ScriptProcessor
  168. {
  169. get
  170. {
  171. return _scriptProcessor;
  172. }
  173. }
  174. public string Version
  175. {
  176. get
  177. {
  178. return _version + " (" + _scriptProcessor + ")";
  179. }
  180. }
  181. }
  182. }
  183. }