CommonControlButtons.cs 14 KB

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