PanelBottomRight.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Drawing;
  4. using System.Windows.Forms;
  5. using PaintDotNet.Base.Functionodel;
  6. namespace PaintDotNet.CustomControl
  7. {
  8. /// <summary>
  9. /// 画板底部快捷栏 右侧的多图/多相封装
  10. /// </summary>
  11. public partial class PanelBottomRight : Panel
  12. {
  13. /// <summary>
  14. /// 从后往前播放模式
  15. /// </summary>
  16. public Button play1Button;
  17. /// <summary>
  18. /// 从前往后播放模式
  19. /// </summary>
  20. public Button play2Button;
  21. /// <summary>
  22. /// 循环播放模式
  23. /// </summary>
  24. public Button play3Button;
  25. /// <summary>
  26. /// 播放(暂停)
  27. /// </summary>
  28. public Button playOrPauseButton;
  29. /// <summary>
  30. /// 删除当前显示页
  31. /// </summary>
  32. public Button deleteButton;
  33. /// <summary>
  34. /// 修改播放时间间隔
  35. /// </summary>
  36. public Button editTimeButton;
  37. /// <summary>
  38. /// 播放滑动滚动条
  39. /// </summary>
  40. public TriangleTrackBar trackBar;
  41. /// <summary>
  42. /// 当前第几页,一共多少页
  43. /// </summary>
  44. public TextBox textBox;
  45. /// <summary>
  46. /// hint 提示信息
  47. /// </summary>
  48. public ToolTip toolTip;
  49. /// <summary>
  50. /// 位置
  51. /// </summary>
  52. public int locationX = 5;
  53. /// <summary>
  54. /// 左侧快捷工具的容器
  55. /// </summary>
  56. private Panel panelLeft;
  57. /// <summary>
  58. /// 显示多图/多相,ture为显示多图
  59. /// </summary>
  60. private bool showPictures = false;
  61. /// <summary>
  62. /// 目前被改成tab的菜单了
  63. /// </summary>
  64. public DocumentBottomStrip documentStrip;
  65. public bool ShowPictures
  66. {
  67. get
  68. {
  69. return this.showPictures;
  70. }
  71. set
  72. {
  73. this.showPictures = value;
  74. this.documentStrip.Visible = !this.showPictures;
  75. this.panelLeft.Visible = this.showPictures;
  76. }
  77. }
  78. /// <summary>
  79. /// 初始化方法
  80. /// </summary>
  81. public PanelBottomRight()
  82. {
  83. InitializeComponent();
  84. InitInternalControl();
  85. this.documentStrip = new DocumentBottomStrip();
  86. //
  87. // documentStrip
  88. //
  89. this.documentStrip.AutoSize = false;
  90. this.documentStrip.Name = "DocumentBottomStrip";
  91. this.documentStrip.TabIndex = 5;
  92. //设置是否多选模式
  93. this.documentStrip.AllowMultiChoise = true;// false;
  94. //this.documentStrip.DocumentListChanged += new EventHandler(DocumentStrip_DocumentListChanged);
  95. //this.documentStrip.DocumentClicked += DocumentStrip_DocumentClicked;
  96. this.documentStrip.ManagedFocus = false;// true;
  97. this.documentStrip.Location = new Point(0, 0);
  98. this.documentStrip.Size = new Size(200, 20);
  99. this.documentStrip.Dock = DockStyle.Fill;// Right;
  100. this.documentStrip.Visible = false;// !this.showPictures;
  101. this.Controls.Add(this.documentStrip);
  102. }
  103. /// <summary>
  104. /// 初始化多相UI
  105. /// </summary>
  106. /// <param name="PhaseModels"></param>
  107. public void AddPhase(List<PhaseModel> PhaseModels)
  108. {
  109. ClearPhase();
  110. if (PhaseModels!=null && PhaseModels.Count > 0)
  111. {
  112. for(int i=0; i< PhaseModels.Count; i++)
  113. {
  114. this.documentStrip.AddTextBox(PhaseModels[i].name, Color.FromArgb(PhaseModels[i].color), PhaseModels[i].choise);
  115. this.documentStrip.Items[i].CheckChanged += new EventHandler(this.Items_CheckChange);
  116. }
  117. }
  118. this.Refresh();
  119. }
  120. public void ClearPhase()
  121. {
  122. this.documentStrip.ClearTextBox();
  123. }
  124. public event EventHandler<EventArgs<int>> ItemCheckChanged;
  125. private void OnItemCheckChanged(int index)
  126. {
  127. if (ItemCheckChanged != null)
  128. {
  129. ItemCheckChanged(this, new EventArgs<int>(index));
  130. }
  131. }
  132. private void Items_CheckChange(object sender, EventArgs e)
  133. {
  134. IBottomNameStrip.Item item = (IBottomNameStrip.Item)sender;
  135. if (item != null)
  136. {
  137. int index = int.Parse(item.Tag.ToString());
  138. OnItemCheckChanged(index);
  139. }
  140. }
  141. /// <summary>
  142. /// 创建内部组件
  143. /// </summary>
  144. private void InitInternalControl()
  145. {
  146. //
  147. // 设置Panel属性
  148. //
  149. this.Cursor = Cursors.Default;
  150. //
  151. // 左侧panel属性
  152. //
  153. this.panelLeft = new Panel();
  154. this.panelLeft.Dock = DockStyle.Left;
  155. this.panelLeft.AutoSize = true;
  156. //
  157. // 播放滑动滚动条
  158. //
  159. //this.locationX += 20;
  160. this.trackBar = new TriangleTrackBar();
  161. this.trackBar.AutoSize = false;
  162. this.trackBar.Minimum = 1;
  163. this.trackBar.Name = "amountTrackBar";
  164. this.trackBar.Location = new Point(locationX, 0);
  165. this.trackBar.Size = new Size(175, 30);
  166. this.trackBar.Minimum = 1;
  167. this.trackBar.Maximum = 500;
  168. this.trackBar.Value = 150;
  169. this.trackBar.TrackBarScroll += new System.EventHandler(this.trackBar_Scroll);
  170. //this.trackBar.SmallChange = 1;
  171. //this.trackBar.TickStyle = TickStyle.None;
  172. ////this.trackBar.Value = 100;
  173. this.trackBar.trackBar1.Location = new System.Drawing.Point(10, 6);
  174. this.trackBar.trackBar1.Size = new System.Drawing.Size(155, 19);
  175. //
  176. // 当前第几页,一共多少页
  177. //
  178. this.locationX += 175;
  179. this.textBox = new TextBox();
  180. this.textBox.Enabled = false;
  181. this.textBox.TextAlign = HorizontalAlignment.Center;
  182. this.textBox.Size = new Size(60, 20);
  183. this.textBox.Location = new Point(locationX, 5);
  184. this.textBox.Text = "150/500";
  185. this.locationX += 60 + 5;// + 5;
  186. //
  187. // 从后往前播放
  188. //
  189. this.play1Button = new Button();
  190. this.play1Button.Location = new Point(locationX, 5);
  191. this.play1Button.Size = new Size(20, 20);
  192. this.play1Button.Image = PdnResources.GetImageResource("Icons.MultiFromAfterPlayIcon.png").Reference;
  193. this.play1Button.FlatStyle = FlatStyle.Flat;
  194. this.play1Button.FlatAppearance.BorderSize = 0;
  195. //
  196. // 从前往后播放
  197. //
  198. this.locationX += 20;
  199. this.play2Button = new Button();
  200. this.play2Button.Location = new Point(locationX, 5);
  201. this.play2Button.Size = new Size(20, 20);
  202. this.play2Button.Image = PdnResources.GetImageResource("Icons.MultiFromBehindPlayIcon.png").Reference;
  203. this.play2Button.FlatStyle = FlatStyle.Flat;
  204. this.play2Button.FlatAppearance.BorderSize = 0;
  205. //
  206. // 循环播放
  207. //
  208. this.locationX += 20;
  209. this.play3Button = new Button();
  210. this.play3Button.Location = new Point(locationX, 5);
  211. this.play3Button.Size = new Size(20, 20);
  212. this.play3Button.Image = PdnResources.GetImageResource("Icons.MultiCirclePlayIcon.png").Reference;
  213. this.play3Button.FlatStyle = FlatStyle.Flat;
  214. this.play3Button.FlatAppearance.BorderSize = 0;
  215. //
  216. // 播放(暂停) 备注:这里需要判断显示播放/暂停
  217. //
  218. this.locationX += 20;
  219. this.playOrPauseButton = new Button();
  220. this.playOrPauseButton.Location = new Point(locationX, 5);
  221. this.playOrPauseButton.Size = new Size(20, 20);
  222. this.playOrPauseButton.Image = PdnResources.GetImageResource("Icons.MultiNowPlayIcon.png").Reference;
  223. this.playOrPauseButton.FlatStyle = FlatStyle.Flat;
  224. this.playOrPauseButton.FlatAppearance.BorderSize = 0;
  225. //
  226. // 删除当前显示页
  227. //
  228. this.locationX += 20;
  229. this.deleteButton = new Button();
  230. this.deleteButton.Location = new Point(locationX, 5);
  231. this.deleteButton.Size = new Size(20, 20);
  232. this.deleteButton.Image = PdnResources.GetImageResource("Icons.MultiNowDeleteIcon.png").Reference;
  233. this.deleteButton.FlatStyle = FlatStyle.Flat;
  234. this.deleteButton.FlatAppearance.BorderSize = 0;
  235. //
  236. // 修改播放时间间隔
  237. //
  238. this.locationX += 20;
  239. this.editTimeButton = new Button();
  240. this.editTimeButton.Location = new Point(locationX, 5);
  241. this.editTimeButton.Size = new Size(20, 20);
  242. this.editTimeButton.Image = PdnResources.GetImageResource("Icons.MultiChangeTimeIcon.png").Reference;
  243. this.editTimeButton.FlatStyle = FlatStyle.Flat;
  244. this.editTimeButton.FlatAppearance.BorderSize = 0;
  245. ////
  246. //// 播放滑动滚动条
  247. ////
  248. this.locationX += 20;
  249. //this.trackBar = new TrackBar();
  250. //this.trackBar.AutoSize = false;
  251. //this.trackBar.Minimum = 1;
  252. //this.trackBar.Name = "amountTrackBar";
  253. //this.trackBar.Location = new Point(locationX, 5);
  254. //this.trackBar.Size = new Size(175, 20);
  255. //this.trackBar.SmallChange = 1;
  256. //this.trackBar.TickStyle = TickStyle.None;
  257. ////this.trackBar.Value = 100;
  258. ////
  259. //// 当前第几页,一共多少页
  260. ////
  261. //this.locationX += 175;
  262. //this.textBox = new TextBox();
  263. //this.textBox.Size = new Size(40, 20);
  264. //this.textBox.Location = new Point(locationX, 5);
  265. //this.locationX += 40;// + 5 + 5;
  266. //
  267. // 提示信息
  268. //
  269. this.toolTip = new ToolTip();
  270. this.toolTip.SetToolTip(this.play1Button, PdnResources.GetString("Menu.Playitbackwards.text"));
  271. this.toolTip.SetToolTip(this.play2Button, PdnResources.GetString("Menu.Playbackandforth.text"));
  272. this.toolTip.SetToolTip(this.play3Button, PdnResources.GetString("Menu.Loopfor.text"));
  273. this.toolTip.SetToolTip(this.playOrPauseButton, PdnResources.GetString("Menu.Playpause.text"));
  274. this.toolTip.SetToolTip(this.deleteButton, PdnResources.GetString("Menu.Deletethecurrentdisplaypage.text"));
  275. this.toolTip.SetToolTip(this.editTimeButton, PdnResources.GetString("Menu.Modifytheplaybackinterval.text"));
  276. this.panelLeft.Visible = false;// this.showPictures;
  277. this.panelLeft.Controls.Add(this.play1Button);
  278. this.panelLeft.Controls.Add(this.play2Button);
  279. this.panelLeft.Controls.Add(this.play3Button);
  280. this.panelLeft.Controls.Add(this.playOrPauseButton);
  281. this.panelLeft.Controls.Add(this.deleteButton);
  282. this.panelLeft.Controls.Add(this.editTimeButton);
  283. this.panelLeft.Controls.Add(this.trackBar);
  284. this.panelLeft.Controls.Add(this.textBox);
  285. this.Controls.Add(this.panelLeft);
  286. }
  287. /// <summary>
  288. /// 图片选择改变
  289. /// </summary>
  290. /// <param name="sender"></param>
  291. /// <param name="e"></param>
  292. private void trackBar_Scroll(object sender, EventArgs e)
  293. {
  294. this.textBox.Text = trackBar.Value + @"/" + trackBar.Maximum;
  295. }
  296. }
  297. }