CommonControlButtons.cs 8.9 KB

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