GeneralAnalysisCommonControlButtons.cs 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. using PaintDotNet.SystemLayer;
  2. using System;
  3. using System.Drawing;
  4. using System.Drawing.Drawing2D;
  5. using System.Windows.Forms;
  6. namespace PaintDotNet.CustomControl
  7. {
  8. /// <summary>
  9. /// 公共的快捷栏
  10. /// 给各个弹窗用
  11. /// </summary>
  12. public class GeneralAnalysisCommonControlButtons : ScrollPanel
  13. {
  14. /// <summary>
  15. /// 放大按钮
  16. /// </summary>
  17. public Button zoomInButton;
  18. /// <summary>
  19. /// 缩小按钮
  20. /// </summary>
  21. public Button zoomOutButton;
  22. /// <summary>
  23. /// 合适大小
  24. /// </summary>
  25. public Button zoomToWindowButton;
  26. /// <summary>
  27. /// 实际大小
  28. /// </summary>
  29. public Button actualSizeButton;
  30. /// <summary>
  31. /// 指针模式
  32. /// </summary>
  33. public Button pointerButton;
  34. /// <summary>
  35. /// 移动模式
  36. /// </summary>
  37. public Button mobileModeButton;
  38. /// <summary>
  39. /// 透明度的TrackBar
  40. /// </summary>
  41. public TrackBar trackBar;
  42. public Label trackLabel;
  43. /// <summary>
  44. /// 透明度的数值
  45. /// </summary>
  46. public TextBox textBox;
  47. public Label demoLabel;
  48. /// <summary>
  49. /// 位置
  50. /// </summary>
  51. public int locationX = 5;
  52. /// <summary>
  53. /// 左侧快捷工具的容器
  54. /// </summary>
  55. private Panel panelLeft;
  56. /// <summary>
  57. /// hint 提示信息
  58. /// </summary>
  59. public ToolTip toolTip;
  60. public GeneralAnalysisCommonControlButtons()
  61. {
  62. InitializeComponent();
  63. InitInternalControl();
  64. }
  65. /// <summary>
  66. /// 创建内部组件
  67. /// </summary>
  68. private void InitInternalControl()
  69. {
  70. //
  71. // 设置Panel属性
  72. //
  73. this.Cursor = Cursors.Default;
  74. //
  75. // 左侧panel属性
  76. //
  77. this.panelLeft = new Panel();
  78. this.panelLeft.Dock = DockStyle.Left;
  79. this.panelLeft.AutoSize = true;
  80. //
  81. // 放大按钮
  82. //
  83. this.zoomInButton = new Button();
  84. this.zoomInButton.Location = new Point(locationX, 5);
  85. this.zoomInButton.Size = new Size(20, 20);
  86. this.zoomInButton.Image = PdnResources.GetImageResource("Icons.MenuViewZoomInIcon.png").Reference;
  87. this.zoomInButton.FlatStyle = FlatStyle.Flat;
  88. this.zoomInButton.FlatAppearance.BorderSize = 0;
  89. //
  90. // 缩小按钮
  91. //
  92. this.locationX += 20;
  93. this.zoomOutButton = new Button();
  94. this.zoomOutButton.Location = new Point(locationX, 5);
  95. this.zoomOutButton.Size = new Size(20, 20);
  96. this.zoomOutButton.Image = PdnResources.GetImageResource("Icons.MenuViewZoomOutIcon.png").Reference;
  97. this.zoomOutButton.FlatStyle = FlatStyle.Flat;
  98. this.zoomOutButton.FlatAppearance.BorderSize = 0;
  99. //
  100. // 合适大小
  101. //
  102. this.locationX += 20;
  103. this.zoomToWindowButton = new Button();
  104. this.zoomToWindowButton.Location = new Point(locationX, 5);
  105. this.zoomToWindowButton.Size = new Size(20, 20);
  106. this.zoomToWindowButton.Image = PdnResources.GetImageResource("Icons.MenuViewZoomToWindowIcon.png").Reference;
  107. this.zoomToWindowButton.FlatStyle = FlatStyle.Flat;
  108. this.zoomToWindowButton.FlatAppearance.BorderSize = 0;
  109. //
  110. // 实际大小
  111. //
  112. this.locationX += 20;
  113. this.actualSizeButton = new Button();
  114. this.actualSizeButton.Location = new Point(locationX, 5);
  115. this.actualSizeButton.Size = new Size(20, 20);
  116. this.actualSizeButton.Image = PdnResources.GetImageResource("Icons.MenuViewActualSizeIcon.png").Reference;
  117. this.actualSizeButton.FlatStyle = FlatStyle.Flat;
  118. this.actualSizeButton.FlatAppearance.BorderSize = 0;
  119. //
  120. // 指针模式
  121. //
  122. this.locationX += 20;
  123. this.pointerButton = new Button();
  124. this.pointerButton.Location = new Point(locationX, 5);
  125. this.pointerButton.Size = new Size(20, 20);
  126. this.pointerButton.Image = PdnResources.GetImageResource("Icons.MoveSelectionToolIcon.png").Reference;
  127. this.pointerButton.FlatStyle = FlatStyle.Flat;
  128. this.pointerButton.FlatAppearance.BorderSize = 0;
  129. //
  130. // 移动模式
  131. //
  132. this.locationX += 20;
  133. this.mobileModeButton = new Button();
  134. this.mobileModeButton.Location = new Point(locationX, 5);
  135. this.mobileModeButton.Size = new Size(20, 20);
  136. this.mobileModeButton.Image = PdnResources.GetImageResource("Icons.PanToolIcon.png").Reference;
  137. this.mobileModeButton.FlatStyle = FlatStyle.Flat;
  138. this.mobileModeButton.FlatAppearance.BorderSize = 0;
  139. //
  140. // 放大缩小的TrackBar
  141. //
  142. this.locationX += 20;
  143. this.trackLabel = new Label();
  144. this.trackLabel.Location = new Point(locationX, 5);
  145. this.trackLabel.Size = new Size(80, 20);
  146. this.trackLabel.Visible = false;
  147. this.locationX += 80;
  148. this.trackBar = new TrackBar();
  149. this.trackBar.AutoSize = false;
  150. this.trackBar.Minimum = 1;
  151. this.trackBar.Name = "amountTrackBar";
  152. this.trackBar.Location = new Point(locationX, 5);
  153. this.trackBar.Size = new Size(175, 20);
  154. this.trackBar.SmallChange = 1;
  155. this.trackBar.TickStyle = TickStyle.None;
  156. this.trackBar.Visible = false;
  157. //
  158. // 放大缩小的百分比
  159. //
  160. this.locationX += 175;
  161. this.textBox = new TextBox();
  162. this.textBox.Size = new Size(40, 20);
  163. this.textBox.Location = new Point(locationX, 5);
  164. this.textBox.Visible = false;
  165. //
  166. // 提示信息
  167. //
  168. this.toolTip = new ToolTip();
  169. this.toolTip.SetToolTip(this.zoomInButton, PdnResources.GetString("Menu.Edit.ZoomIn.Text"));
  170. this.toolTip.SetToolTip(this.zoomOutButton, PdnResources.GetString("CommonAction.ZoomOut"));
  171. this.toolTip.SetToolTip(this.zoomToWindowButton, PdnResources.GetString("Menu.Edit.ZoomToWindow.Text"));
  172. this.toolTip.SetToolTip(this.actualSizeButton, PdnResources.GetString("Menu.Edit.ActualSize.Text"));
  173. this.toolTip.SetToolTip(this.pointerButton, PdnResources.GetString("Menu.Pointertothemodel.text"));
  174. this.toolTip.SetToolTip(this.mobileModeButton, PdnResources.GetString("Menu.Mobilemodel.text"));
  175. this.panelLeft.Controls.Add(this.zoomInButton);
  176. this.panelLeft.Controls.Add(this.zoomOutButton);
  177. this.panelLeft.Controls.Add(this.zoomToWindowButton);
  178. this.panelLeft.Controls.Add(this.actualSizeButton);
  179. this.panelLeft.Controls.Add(this.pointerButton);
  180. this.panelLeft.Controls.Add(this.mobileModeButton);
  181. this.panelLeft.Controls.Add(this.trackLabel);
  182. this.panelLeft.Controls.Add(this.trackBar);
  183. this.panelLeft.Controls.Add(this.textBox);
  184. this.Controls.Add(this.panelLeft);
  185. }
  186. public void HideZoomToWindowAndActualSize()
  187. {
  188. this.zoomToWindowButton.Visible = false;
  189. this.actualSizeButton.Visible = false;
  190. this.pointerButton.Location = new Point(this.pointerButton.Location.X - 40, this.pointerButton.Location.Y);
  191. this.mobileModeButton.Location = new Point(this.mobileModeButton.Location.X - 40, this.mobileModeButton.Location.Y);
  192. }
  193. public void WithTrackBar()
  194. {
  195. this.zoomToWindowButton.Visible = false;
  196. this.actualSizeButton.Visible = false;
  197. this.trackBar.Visible = true;
  198. this.pointerButton.Location = new Point(this.pointerButton.Location.X - 40, this.pointerButton.Location.Y);
  199. this.mobileModeButton.Location = new Point(this.mobileModeButton.Location.X - 40, this.mobileModeButton.Location.Y);
  200. this.trackLabel.Visible = true;
  201. }
  202. #region 设计器
  203. /// <summary>
  204. /// 必需的设计器变量。
  205. /// </summary>
  206. private System.ComponentModel.IContainer components = null;
  207. /// <summary>
  208. /// 清理所有正在使用的资源。
  209. /// </summary>
  210. /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
  211. protected override void Dispose(bool disposing)
  212. {
  213. if (disposing && (components != null))
  214. {
  215. components.Dispose();
  216. }
  217. base.Dispose(disposing);
  218. }
  219. #region 组件设计器生成的代码
  220. /// <summary>
  221. /// 设计器支持所需的方法 - 不要修改
  222. /// 使用代码编辑器修改此方法的内容。
  223. /// </summary>
  224. private void InitializeComponent()
  225. {
  226. components = new System.ComponentModel.Container();
  227. }
  228. #endregion
  229. #endregion
  230. }
  231. }