ArtworkControlButtons.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  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 ArtworkControlButtons : 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. /// 向上移动
  40. /// </summary>
  41. public Button moveUpButton;
  42. /// <summary>
  43. /// 向下移动
  44. /// </summary>
  45. public Button moveDownButton;
  46. /// <summary>
  47. /// 向左移动
  48. /// </summary>
  49. public Button moveLeftButton;
  50. /// <summary>
  51. /// 向右移动
  52. /// </summary>
  53. public Button moveRightButton;
  54. /// <summary>
  55. /// 向左旋转
  56. /// </summary>
  57. public Button turnLeftButton;
  58. /// <summary>
  59. /// 向右旋转
  60. /// </summary>
  61. public Button turnRightButton;
  62. /// <summary>
  63. /// 透明度的TrackBar
  64. /// </summary>
  65. public TrackBar trackBar;
  66. /// <summary>
  67. /// 透明度的数值
  68. /// </summary>
  69. public TextBox textBox;
  70. /// <summary>
  71. /// 位置
  72. /// </summary>
  73. public int locationX = 5;
  74. /// <summary>
  75. /// 左侧快捷工具的容器
  76. /// </summary>
  77. private Panel panelLeft;
  78. /// <summary>
  79. /// hint 提示信息
  80. /// </summary>
  81. public ToolTip toolTip;
  82. public ArtworkControlButtons()
  83. {
  84. InitializeComponent();
  85. InitInternalControl();
  86. }
  87. /// <summary>
  88. /// 创建内部组件
  89. /// </summary>
  90. private void InitInternalControl()
  91. {
  92. //
  93. // 设置Panel属性
  94. //
  95. this.Cursor = Cursors.Default;
  96. //
  97. // 左侧panel属性
  98. //
  99. this.panelLeft = new Panel();
  100. this.panelLeft.Dock = DockStyle.Left;
  101. this.panelLeft.AutoSize = true;
  102. //
  103. // 放大按钮
  104. //
  105. this.zoomInButton = new Button();
  106. this.zoomInButton.Location = new Point(locationX, 5);
  107. this.zoomInButton.Size = new Size(20, 20);
  108. this.zoomInButton.Image = PdnResources.GetImageResource("Icons.MenuViewZoomInIcon.png").Reference;
  109. this.zoomInButton.FlatStyle = FlatStyle.Flat;
  110. this.zoomInButton.FlatAppearance.BorderSize = 0;
  111. //
  112. // 缩小按钮
  113. //
  114. this.locationX += 20;
  115. this.zoomOutButton = new Button();
  116. this.zoomOutButton.Location = new Point(locationX, 5);
  117. this.zoomOutButton.Size = new Size(20, 20);
  118. this.zoomOutButton.Image = PdnResources.GetImageResource("Icons.MenuViewZoomOutIcon.png").Reference;
  119. this.zoomOutButton.FlatStyle = FlatStyle.Flat;
  120. this.zoomOutButton.FlatAppearance.BorderSize = 0;
  121. //
  122. // 合适大小
  123. //
  124. this.locationX += 20;
  125. this.zoomToWindowButton = new Button();
  126. this.zoomToWindowButton.Location = new Point(locationX, 5);
  127. this.zoomToWindowButton.Size = new Size(20, 20);
  128. this.zoomToWindowButton.Image = PdnResources.GetImageResource("Icons.MenuViewZoomToWindowIcon.png").Reference;
  129. this.zoomToWindowButton.FlatStyle = FlatStyle.Flat;
  130. this.zoomToWindowButton.FlatAppearance.BorderSize = 0;
  131. //
  132. // 实际大小
  133. //
  134. this.locationX += 20;
  135. this.actualSizeButton = new Button();
  136. this.actualSizeButton.Location = new Point(locationX, 5);
  137. this.actualSizeButton.Size = new Size(20, 20);
  138. this.actualSizeButton.Image = PdnResources.GetImageResource("Icons.MenuViewActualSizeIcon.png").Reference;
  139. this.actualSizeButton.FlatStyle = FlatStyle.Flat;
  140. this.actualSizeButton.FlatAppearance.BorderSize = 0;
  141. //
  142. // 指针模式
  143. //
  144. this.locationX += 20;
  145. this.pointerButton = new Button();
  146. this.pointerButton.Location = new Point(locationX, 5);
  147. this.pointerButton.Size = new Size(20, 20);
  148. this.pointerButton.Image = PdnResources.GetImageResource("Icons.MoveSelectionToolIcon.png").Reference;
  149. this.pointerButton.FlatStyle = FlatStyle.Flat;
  150. this.pointerButton.FlatAppearance.BorderSize = 0;
  151. //
  152. // 移动模式
  153. //
  154. this.locationX += 20;
  155. this.mobileModeButton = new Button();
  156. this.mobileModeButton.Location = new Point(locationX, 5);
  157. this.mobileModeButton.Size = new Size(20, 20);
  158. this.mobileModeButton.Image = PdnResources.GetImageResource("Icons.PanToolIcon.png").Reference;
  159. this.mobileModeButton.FlatStyle = FlatStyle.Flat;
  160. this.mobileModeButton.FlatAppearance.BorderSize = 0;
  161. //
  162. // 向上移动
  163. //
  164. this.locationX += 20;
  165. this.moveUpButton = new Button();
  166. this.moveUpButton.Location = new Point(locationX, 5);
  167. this.moveUpButton.Size = new Size(20, 20);
  168. this.moveUpButton.Image = PdnResources.GetImageResource("Icons.MenuLayersMoveLayerUpIcon.png").Reference;
  169. this.moveUpButton.FlatStyle = FlatStyle.Flat;
  170. this.moveUpButton.FlatAppearance.BorderSize = 0;
  171. //
  172. // 向下移动
  173. //
  174. this.locationX += 20;
  175. this.moveDownButton = new Button();
  176. this.moveDownButton.Location = new Point(locationX, 5);
  177. this.moveDownButton.Size = new Size(20, 20);
  178. this.moveDownButton.Image = PdnResources.GetImageResource("Icons.MenuLayersMoveLayerDownIcon.png").Reference;
  179. this.moveDownButton.FlatStyle = FlatStyle.Flat;
  180. this.moveDownButton.FlatAppearance.BorderSize = 0;
  181. //
  182. // 向左移动
  183. //
  184. this.locationX += 20;
  185. this.moveLeftButton = new Button();
  186. this.moveLeftButton.Location = new Point(locationX, 5);
  187. this.moveLeftButton.Size = new Size(20, 20);
  188. this.moveLeftButton.Image = PdnResources.GetImageResource("Icons.MenuEditUndoIcon.png").Reference;
  189. this.moveLeftButton.FlatStyle = FlatStyle.Flat;
  190. this.moveLeftButton.FlatAppearance.BorderSize = 0;
  191. //
  192. // 向右移动
  193. //
  194. this.locationX += 20;
  195. this.moveRightButton = new Button();
  196. this.moveRightButton.Location = new Point(locationX, 5);
  197. this.moveRightButton.Size = new Size(20, 20);
  198. this.moveRightButton.Image = PdnResources.GetImageResource("Icons.MenuEditRedoIcon.png").Reference;
  199. this.moveRightButton.FlatStyle = FlatStyle.Flat;
  200. this.moveRightButton.FlatAppearance.BorderSize = 0;
  201. //
  202. // 向左旋转
  203. //
  204. this.locationX += 20;
  205. this.turnLeftButton = new Button();
  206. this.turnLeftButton.Location = new Point(locationX, 5);
  207. this.turnLeftButton.Size = new Size(20, 20);
  208. this.turnLeftButton.Image = PdnResources.GetImageResource("Icons.MenuEditUndoIcon.png").Reference;
  209. this.turnLeftButton.FlatStyle = FlatStyle.Flat;
  210. this.turnLeftButton.FlatAppearance.BorderSize = 0;
  211. this.turnLeftButton.Visible = false;
  212. //
  213. // 向右旋转
  214. //
  215. this.locationX += 20;
  216. this.turnRightButton = new Button();
  217. this.turnRightButton.Location = new Point(locationX, 5);
  218. this.turnRightButton.Size = new Size(20, 20);
  219. this.turnRightButton.Image = PdnResources.GetImageResource("Icons.MenuEditRedoIcon.png").Reference;
  220. this.turnRightButton.FlatStyle = FlatStyle.Flat;
  221. this.turnRightButton.FlatAppearance.BorderSize = 0;
  222. this.turnRightButton.Visible = false;
  223. //
  224. // 放大缩小的TrackBar
  225. //
  226. this.locationX += 20;
  227. this.trackBar = new TrackBar();
  228. this.trackBar.AutoSize = false;
  229. this.trackBar.Minimum = 1;
  230. this.trackBar.Name = "amountTrackBar";
  231. this.trackBar.Location = new Point(locationX, 5);
  232. this.trackBar.Size = new Size(175, 20);
  233. this.trackBar.SmallChange = 1;
  234. this.trackBar.TickStyle = TickStyle.None;
  235. this.trackBar.Visible = false;
  236. //
  237. // 放大缩小的百分比
  238. //
  239. this.locationX += 175;
  240. this.textBox = new TextBox();
  241. this.textBox.Size = new Size(40, 20);
  242. this.textBox.Location = new Point(locationX, 5);
  243. this.textBox.Visible = false;
  244. //
  245. // 提示信息
  246. //
  247. this.toolTip = new ToolTip();
  248. this.toolTip.SetToolTip(this.zoomInButton, PdnResources.GetString("Menu.Edit.ZoomIn.Text"));
  249. this.toolTip.SetToolTip(this.zoomOutButton, PdnResources.GetString("CommonAction.ZoomOut"));
  250. this.toolTip.SetToolTip(this.pointerButton, PdnResources.GetString("Menu.Pointertothemodel.text"));
  251. this.toolTip.SetToolTip(this.mobileModeButton, PdnResources.GetString("Menu.Mobilemodel.text"));
  252. this.toolTip.SetToolTip(this.zoomToWindowButton, PdnResources.GetString("Menu.Edit.ZoomToWindow.Text"));
  253. this.toolTip.SetToolTip(this.actualSizeButton, PdnResources.GetString("Menu.Edit.ActualSize.Text"));
  254. this.toolTip.SetToolTip(this.moveUpButton, PdnResources.GetString("Menu.LabelAction.MoveUpAction.Text"));
  255. this.toolTip.SetToolTip(this.moveDownButton, PdnResources.GetString("Menu.LabelAction.MoveDownAction.Text"));
  256. this.toolTip.SetToolTip(this.moveLeftButton, PdnResources.GetString("Menu.Movetotheleft.text"));
  257. this.toolTip.SetToolTip(this.moveRightButton, PdnResources.GetString("Menu.Totheright.text"));
  258. this.toolTip.SetToolTip(this.turnLeftButton, PdnResources.GetString("Menu.Rotatetotheleft.text"));
  259. this.toolTip.SetToolTip(this.turnRightButton, PdnResources.GetString("Menu.Spintotheright.text"));
  260. this.panelLeft.Controls.Add(this.zoomInButton);
  261. this.panelLeft.Controls.Add(this.zoomOutButton);
  262. this.panelLeft.Controls.Add(this.zoomToWindowButton);
  263. this.panelLeft.Controls.Add(this.actualSizeButton);
  264. this.panelLeft.Controls.Add(this.pointerButton);
  265. this.panelLeft.Controls.Add(this.mobileModeButton);
  266. this.panelLeft.Controls.Add(this.moveUpButton);
  267. this.panelLeft.Controls.Add(this.moveDownButton);
  268. this.panelLeft.Controls.Add(this.moveLeftButton);
  269. this.panelLeft.Controls.Add(this.moveRightButton);
  270. this.panelLeft.Controls.Add(this.turnLeftButton);
  271. this.panelLeft.Controls.Add(this.turnRightButton);
  272. this.panelLeft.Controls.Add(this.trackBar);
  273. this.panelLeft.Controls.Add(this.textBox);
  274. this.Controls.Add(this.panelLeft);
  275. }
  276. public void HideZoomToWindowAndActualSize()
  277. {
  278. this.zoomToWindowButton.Visible = false;
  279. this.actualSizeButton.Visible = false;
  280. this.pointerButton.Location = new Point(this.pointerButton.Location.X - 40, this.pointerButton.Location.Y);
  281. this.mobileModeButton.Location = new Point(this.mobileModeButton.Location.X - 40, this.mobileModeButton.Location.Y);
  282. }
  283. public void HideMovingDirection()
  284. {
  285. this.Width -= 80;
  286. this.moveUpButton.Visible = false;
  287. this.moveDownButton.Visible = false;
  288. this.moveLeftButton.Visible = false;
  289. this.moveRightButton.Visible = false;
  290. this.turnLeftButton.Location = new Point(this.turnLeftButton.Location.X - 80, this.turnLeftButton.Location.Y);
  291. this.turnRightButton.Location = new Point(this.turnRightButton.Location.X - 80, this.turnRightButton.Location.Y);
  292. }
  293. public void WithTrackBar()
  294. {
  295. this.Width -= 40;
  296. this.zoomToWindowButton.Visible = false;
  297. this.actualSizeButton.Visible = false;
  298. this.trackBar.Visible = true;
  299. this.pointerButton.Location = new Point(this.pointerButton.Location.X - 40, this.pointerButton.Location.Y);
  300. this.mobileModeButton.Location = new Point(this.mobileModeButton.Location.X - 40, this.mobileModeButton.Location.Y);
  301. }
  302. #region 设计器
  303. /// <summary>
  304. /// 必需的设计器变量。
  305. /// </summary>
  306. private System.ComponentModel.IContainer components = null;
  307. /// <summary>
  308. /// 清理所有正在使用的资源。
  309. /// </summary>
  310. /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
  311. protected override void Dispose(bool disposing)
  312. {
  313. if (disposing && (components != null))
  314. {
  315. components.Dispose();
  316. }
  317. base.Dispose(disposing);
  318. }
  319. #region 组件设计器生成的代码
  320. /// <summary>
  321. /// 设计器支持所需的方法 - 不要修改
  322. /// 使用代码编辑器修改此方法的内容。
  323. /// </summary>
  324. private void InitializeComponent()
  325. {
  326. components = new System.ComponentModel.Container();
  327. }
  328. #endregion
  329. #endregion
  330. }
  331. }