TestAppForm.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. using System;
  2. using System.Drawing;
  3. using System.Collections;
  4. using System.ComponentModel;
  5. using System.Windows.Forms;
  6. using System.Data;
  7. using System.IO;
  8. using PhysFS_NET;
  9. namespace TestApp
  10. {
  11. /// <summary>
  12. /// Summary description for Form1.
  13. /// </summary>
  14. public class TestAppForm : System.Windows.Forms.Form
  15. {
  16. private System.Windows.Forms.Label label2;
  17. private System.Windows.Forms.Button RefreshCDsButton;
  18. private System.Windows.Forms.ListBox CDDrivesList;
  19. private System.Windows.Forms.ListBox SearchPathList;
  20. private System.Windows.Forms.Label label1;
  21. private System.Windows.Forms.TextBox EnumFilesPath;
  22. private System.Windows.Forms.ListBox EnumList;
  23. private System.Windows.Forms.Label label3;
  24. private System.Windows.Forms.TextBox NewSearchPathText;
  25. private System.Windows.Forms.Button AddSearchPathButton;
  26. private System.Windows.Forms.Button RemovePathButton;
  27. private System.Windows.Forms.Button RefreshEnumList;
  28. private System.Windows.Forms.Button RefreshSearchPathButton;
  29. /// <summary>
  30. /// Required designer variable.
  31. /// </summary>
  32. private System.ComponentModel.Container components = null;
  33. public TestAppForm()
  34. {
  35. //
  36. // Required for Windows Form Designer support
  37. //
  38. InitializeComponent();
  39. //
  40. // TODO: Add any constructor code after InitializeComponent call
  41. //
  42. }
  43. /// <summary>
  44. /// Clean up any resources being used.
  45. /// </summary>
  46. protected override void Dispose( bool disposing )
  47. {
  48. if( disposing )
  49. {
  50. if (components != null)
  51. {
  52. components.Dispose();
  53. }
  54. }
  55. base.Dispose( disposing );
  56. }
  57. #region Windows Form Designer generated code
  58. /// <summary>
  59. /// Required method for Designer support - do not modify
  60. /// the contents of this method with the code editor.
  61. /// </summary>
  62. private void InitializeComponent()
  63. {
  64. this.label2 = new System.Windows.Forms.Label();
  65. this.RefreshCDsButton = new System.Windows.Forms.Button();
  66. this.CDDrivesList = new System.Windows.Forms.ListBox();
  67. this.SearchPathList = new System.Windows.Forms.ListBox();
  68. this.label1 = new System.Windows.Forms.Label();
  69. this.EnumFilesPath = new System.Windows.Forms.TextBox();
  70. this.EnumList = new System.Windows.Forms.ListBox();
  71. this.label3 = new System.Windows.Forms.Label();
  72. this.RefreshEnumList = new System.Windows.Forms.Button();
  73. this.NewSearchPathText = new System.Windows.Forms.TextBox();
  74. this.AddSearchPathButton = new System.Windows.Forms.Button();
  75. this.RemovePathButton = new System.Windows.Forms.Button();
  76. this.RefreshSearchPathButton = new System.Windows.Forms.Button();
  77. this.SuspendLayout();
  78. //
  79. // label2
  80. //
  81. this.label2.Location = new System.Drawing.Point(8, 8);
  82. this.label2.Name = "label2";
  83. this.label2.Size = new System.Drawing.Size(136, 16);
  84. this.label2.TabIndex = 2;
  85. this.label2.Text = "Available CD-ROM Drives";
  86. //
  87. // RefreshCDsButton
  88. //
  89. this.RefreshCDsButton.Location = new System.Drawing.Point(8, 152);
  90. this.RefreshCDsButton.Name = "RefreshCDsButton";
  91. this.RefreshCDsButton.Size = new System.Drawing.Size(72, 24);
  92. this.RefreshCDsButton.TabIndex = 4;
  93. this.RefreshCDsButton.Text = "Refresh";
  94. this.RefreshCDsButton.Click += new System.EventHandler(this.RefreshCDsButton_Click);
  95. //
  96. // CDDrivesList
  97. //
  98. this.CDDrivesList.Location = new System.Drawing.Point(8, 24);
  99. this.CDDrivesList.Name = "CDDrivesList";
  100. this.CDDrivesList.Size = new System.Drawing.Size(136, 121);
  101. this.CDDrivesList.TabIndex = 7;
  102. //
  103. // SearchPathList
  104. //
  105. this.SearchPathList.Location = new System.Drawing.Point(152, 24);
  106. this.SearchPathList.Name = "SearchPathList";
  107. this.SearchPathList.Size = new System.Drawing.Size(248, 95);
  108. this.SearchPathList.TabIndex = 8;
  109. //
  110. // label1
  111. //
  112. this.label1.Location = new System.Drawing.Point(152, 8);
  113. this.label1.Name = "label1";
  114. this.label1.Size = new System.Drawing.Size(136, 16);
  115. this.label1.TabIndex = 10;
  116. this.label1.Text = "Search Path";
  117. //
  118. // EnumFilesPath
  119. //
  120. this.EnumFilesPath.Location = new System.Drawing.Point(408, 128);
  121. this.EnumFilesPath.Name = "EnumFilesPath";
  122. this.EnumFilesPath.Size = new System.Drawing.Size(208, 20);
  123. this.EnumFilesPath.TabIndex = 11;
  124. this.EnumFilesPath.Text = "";
  125. //
  126. // EnumList
  127. //
  128. this.EnumList.Location = new System.Drawing.Point(408, 24);
  129. this.EnumList.Name = "EnumList";
  130. this.EnumList.Size = new System.Drawing.Size(208, 95);
  131. this.EnumList.TabIndex = 12;
  132. //
  133. // label3
  134. //
  135. this.label3.Location = new System.Drawing.Point(408, 8);
  136. this.label3.Name = "label3";
  137. this.label3.Size = new System.Drawing.Size(136, 16);
  138. this.label3.TabIndex = 13;
  139. this.label3.Text = "Enumerate Files";
  140. //
  141. // RefreshEnumList
  142. //
  143. this.RefreshEnumList.Location = new System.Drawing.Point(544, 152);
  144. this.RefreshEnumList.Name = "RefreshEnumList";
  145. this.RefreshEnumList.Size = new System.Drawing.Size(72, 24);
  146. this.RefreshEnumList.TabIndex = 14;
  147. this.RefreshEnumList.Text = "Refresh";
  148. this.RefreshEnumList.Click += new System.EventHandler(this.RefreshEnumList_Click);
  149. //
  150. // NewSearchPathText
  151. //
  152. this.NewSearchPathText.Location = new System.Drawing.Point(152, 128);
  153. this.NewSearchPathText.Name = "NewSearchPathText";
  154. this.NewSearchPathText.Size = new System.Drawing.Size(248, 20);
  155. this.NewSearchPathText.TabIndex = 15;
  156. this.NewSearchPathText.Text = "";
  157. //
  158. // AddSearchPathButton
  159. //
  160. this.AddSearchPathButton.Location = new System.Drawing.Point(152, 152);
  161. this.AddSearchPathButton.Name = "AddSearchPathButton";
  162. this.AddSearchPathButton.Size = new System.Drawing.Size(72, 24);
  163. this.AddSearchPathButton.TabIndex = 9;
  164. this.AddSearchPathButton.Text = "Add Path";
  165. this.AddSearchPathButton.Click += new System.EventHandler(this.AddSearchPathButton_Click);
  166. //
  167. // RemovePathButton
  168. //
  169. this.RemovePathButton.Location = new System.Drawing.Point(232, 152);
  170. this.RemovePathButton.Name = "RemovePathButton";
  171. this.RemovePathButton.Size = new System.Drawing.Size(88, 24);
  172. this.RemovePathButton.TabIndex = 16;
  173. this.RemovePathButton.Text = "Remove Path";
  174. this.RemovePathButton.Click += new System.EventHandler(this.RemovePathButton_Click);
  175. //
  176. // RefreshSearchPathButton
  177. //
  178. this.RefreshSearchPathButton.Location = new System.Drawing.Point(328, 152);
  179. this.RefreshSearchPathButton.Name = "RefreshSearchPathButton";
  180. this.RefreshSearchPathButton.Size = new System.Drawing.Size(72, 24);
  181. this.RefreshSearchPathButton.TabIndex = 17;
  182. this.RefreshSearchPathButton.Text = "Refresh";
  183. this.RefreshSearchPathButton.Click += new System.EventHandler(this.RefreshSearchPathButton_Click);
  184. //
  185. // TestAppForm
  186. //
  187. this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
  188. this.ClientSize = new System.Drawing.Size(624, 309);
  189. this.Controls.AddRange(new System.Windows.Forms.Control[] {
  190. this.RefreshSearchPathButton,
  191. this.RemovePathButton,
  192. this.NewSearchPathText,
  193. this.RefreshEnumList,
  194. this.label3,
  195. this.EnumList,
  196. this.EnumFilesPath,
  197. this.label1,
  198. this.SearchPathList,
  199. this.CDDrivesList,
  200. this.RefreshCDsButton,
  201. this.label2,
  202. this.AddSearchPathButton});
  203. this.Name = "TestAppForm";
  204. this.Text = "PhysFS Test Application";
  205. this.Load += new System.EventHandler(this.TestAppForm_Load);
  206. this.ResumeLayout(false);
  207. }
  208. #endregion
  209. /// <summary>
  210. /// The main entry point for the application.
  211. /// </summary>
  212. [STAThread]
  213. static void Main()
  214. {
  215. Application.Run(new TestAppForm());
  216. }
  217. private void TestAppForm_Load(object sender, System.EventArgs e)
  218. {
  219. }
  220. private void RefreshCDsButton_Click(object sender, System.EventArgs e)
  221. {
  222. // Clear ths listbox if it contains any items
  223. CDDrivesList.Items.Clear();
  224. // Add the items to the list
  225. CDDrivesList.Items.AddRange(PhysFS.GetCDROMDrives());
  226. }
  227. private void RefreshSearchPathButton_Click(object sender, System.EventArgs e)
  228. {
  229. // Clear ths listbox if it contains any items
  230. SearchPathList.Items.Clear();
  231. // Add the items to the list
  232. SearchPathList.Items.AddRange(PhysFS.GetSearchPath());
  233. }
  234. private void AddSearchPathButton_Click(object sender, System.EventArgs e)
  235. {
  236. // Add search path
  237. PhysFS.AddToSearchPath(NewSearchPathText.Text, false);
  238. // Clear ths listbox if it contains any items
  239. SearchPathList.Items.Clear();
  240. // Add the items to the list
  241. SearchPathList.Items.AddRange(PhysFS.GetSearchPath());
  242. }
  243. private void RemovePathButton_Click(object sender, System.EventArgs e)
  244. {
  245. if(SearchPathList.SelectedItem != null)
  246. {
  247. PhysFS.RemoveFromSearchPath(SearchPathList.SelectedItem.ToString());
  248. // Clear ths listbox if it contains any items
  249. SearchPathList.Items.Clear();
  250. // Add the items to the list
  251. SearchPathList.Items.AddRange(PhysFS.GetSearchPath());
  252. }
  253. }
  254. private void RefreshEnumList_Click(object sender, System.EventArgs e)
  255. {
  256. EnumList.Items.Clear();
  257. EnumList.Items.AddRange(PhysFS.EnumerateFiles(EnumFilesPath.Text));
  258. }
  259. }
  260. }