ArtworkControlButtons.cs 14 KB

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