ControlCreator.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. using System;
  2. using System.Windows.Forms;
  3. namespace OmxPlayerGui
  4. {
  5. public static class ControlCreator
  6. {
  7. public static void Add(this Control.ControlCollection collection,out TextBox box,string id, string text, int left, int top, int width, int height)
  8. {
  9. box = new TextBox();
  10. box.Text = text;
  11. AddControl (collection,box,id,left,top,width,height);
  12. return;
  13. }
  14. public static void Add (this Control.ControlCollection collection,out ContextMenu menu, string id)
  15. {
  16. menu = new ContextMenu ();
  17. menu.Name = id;
  18. }
  19. public static void Add(this Control.ControlCollection collection,out ContextMenu menu,string id, MenuItem[] menuitems)
  20. {
  21. menu = new ContextMenu (menuitems);
  22. menu.Name = id;
  23. return;
  24. }
  25. public static void Add(this Control.ControlCollection collection,out TreeView box
  26. , string id, int left, int top, int width, int height)
  27. {
  28. box = new TreeView();
  29. AddControl(collection,box,id,left,top,width,height);
  30. return;
  31. }
  32. public static void Add(this Control.ControlCollection collection,out GroupBox box,string id, string text, int left, int top, int width, int height)
  33. {
  34. box = new GroupBox();
  35. box.Text = text;
  36. AddControl (collection,box,id,left,top,width,height);
  37. return;
  38. }
  39. public static void Add(this Control.ControlCollection collection,out Button box,string id, string text, int left, int top, int width, int height)
  40. {
  41. box = new Button();
  42. box.Text = text;
  43. AddControl (collection,box,id,left,top,width,height);
  44. return;
  45. }
  46. public static void Add(this Control.ControlCollection collection,out Label box,string id, string text, int left, int top, int width, int height)
  47. {
  48. box = new Label();
  49. box.Text = text;
  50. AddControl (collection,box,id,left,top,width,height);
  51. return;
  52. }
  53. public static void Add(this Control.ControlCollection collection,out CheckBox box,string id, string text, int left, int top, int width, int height)
  54. {
  55. box = new CheckBox();
  56. box.Text = text;
  57. AddControl (collection,box,id,left,top,width,height);
  58. return;
  59. }
  60. public static void Add(this Control.ControlCollection collection,out ListBox box,string id, int left, int top, int width, int height)
  61. {
  62. box = new ListBox();
  63. AddControl (collection,box,id,left,top,width,height);
  64. return;
  65. }
  66. public static void Add(this Control.ControlCollection collection,out CheckedListBox box,string id, int left, int top, int width, int height)
  67. {
  68. box = new CheckedListBox();
  69. AddControl (collection,box,id,left,top,width,height);
  70. return;
  71. }
  72. public static void Add(this Control.ControlCollection collection,out DataGrid box,string id, int left, int top, int width, int height)
  73. {
  74. box = new DataGrid();
  75. AddControl (collection,box,id,left,top,width,height);
  76. return;
  77. }
  78. public static void Add(this Control.ControlCollection collection,out DataGridView box,string id, int left, int top, int width, int height)
  79. {
  80. box = new DataGridView();
  81. AddControl (collection,box,id,left,top,width,height);
  82. return;
  83. }
  84. private static void AddControl(Control.ControlCollection collection,Control box,string id, int left, int top, int width, int height)
  85. {
  86. box.Name = id;
  87. box.Left = left;
  88. box.Top = top;
  89. box.Width = width;
  90. box.Height = height;
  91. collection.Add(box);
  92. return;
  93. }
  94. }
  95. }