ImagePreviewDialog.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. using Resources;
  2. using SmartCoalApplication.Base.Enum;
  3. using SmartCoalApplication.Core;
  4. using SmartCoalApplication.Core.CustomControl;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.ComponentModel;
  8. using System.Data;
  9. using System.Drawing;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. using System.Windows.Forms;
  14. namespace SmartCoalApplication.File.BatchSaveComponet
  15. {
  16. internal class ImagePreviewDialog : PdnBaseForm
  17. {
  18. private AppWorkspace appWorkspace;
  19. /// <summary>
  20. /// 图像面板
  21. /// </summary>
  22. private DocumentWorkspaceWindow documentWorkspace;
  23. /// <summary>
  24. /// 公共按钮
  25. /// </summary>
  26. private CommonControlButtons commonControlButtons;
  27. /// <summary>
  28. /// 底部图标栏
  29. /// </summary>
  30. private Panel panel;
  31. public ImagePreviewDialog(Image image, AppWorkspace appWorkspace)
  32. {
  33. this.appWorkspace = appWorkspace;
  34. InitializeComponent();
  35. this.documentWorkspace = new DocumentWorkspaceWindow(this.appWorkspace);
  36. //
  37. //DocumentWorkspaceWindow
  38. //
  39. this.documentWorkspace.Location = new System.Drawing.Point(0, 0);
  40. this.documentWorkspace.Dock = DockStyle.Fill;
  41. this.documentWorkspace.HookMouseEvents();
  42. this.documentWorkspace.RulersEnabled = false;
  43. this.Controls.Add(this.documentWorkspace);
  44. this.Text = PdnResources.GetString("Menu.Previewpicture.Text");
  45. this.documentWorkspace.Document = Document.FromImage(image);
  46. this.commonControlButtons.Location = new Point((this.Width - this.commonControlButtons.Width) / 2, 0);
  47. this.Resize += new EventHandler(this.Resize_Event);
  48. InitCommonButtonEvent();
  49. }
  50. private void InitCommonButtonEvent()
  51. {
  52. this.commonControlButtons.zoomInButton.Click += new EventHandler(zoomInButton_Click);
  53. this.commonControlButtons.zoomOutButton.Click += new EventHandler(zoomOutButton_Click);
  54. this.commonControlButtons.zoomToWindowButton.Click += new EventHandler(zoomToWindowButton_Click);
  55. this.commonControlButtons.actualSizeButton.Click += new EventHandler(actualSizeButton_Click);
  56. this.commonControlButtons.pointerButton.Click += new EventHandler(pointerButton_Click);
  57. this.commonControlButtons.mobileModeButton.Click += new EventHandler(mobileModeButton_Click);
  58. }
  59. private void zoomInButton_Click(object sender, EventArgs e)
  60. {
  61. this.documentWorkspace.ZoomIn();
  62. }
  63. private void zoomOutButton_Click(object sender, EventArgs e)
  64. {
  65. this.documentWorkspace.ZoomOut();
  66. }
  67. private void zoomToWindowButton_Click(object sender, EventArgs e)
  68. {
  69. this.documentWorkspace.ZoomBasis = ZoomBasis.FitToWindow;
  70. }
  71. private void actualSizeButton_Click(object sender, EventArgs e)
  72. {
  73. this.documentWorkspace.ZoomBasis = ZoomBasis.ScaleFactor;
  74. this.documentWorkspace.ScaleFactor = ScaleFactor.OneToOne;
  75. }
  76. private void pointerButton_Click(object sender, EventArgs e)
  77. {
  78. //this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.Pointer;
  79. }
  80. private void mobileModeButton_Click(object sender, EventArgs e)
  81. {
  82. //this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.MoveMode;
  83. }
  84. private void Resize_Event(object sender, EventArgs e)
  85. {
  86. this.commonControlButtons.Location = new Point((this.panel.Width - this.commonControlButtons.Width) / 2, 0);
  87. //this.commonControlButtons.Left = (this.panel.Width - this.commonControlButtons.Width) / 2;
  88. }
  89. private void InitializeComponent()
  90. {
  91. this.SuspendLayout();
  92. //
  93. //底部panel
  94. //
  95. this.panel = new Panel();
  96. this.panel.Height = 30;
  97. this.panel.Dock = DockStyle.Bottom;
  98. //
  99. //初始化操作按钮
  100. //
  101. this.commonControlButtons = new CommonControlButtons();
  102. this.commonControlButtons.Height = 30;
  103. this.commonControlButtons.Width = 100;
  104. this.commonControlButtons.HideZoomToWindowAndActualSize();
  105. this.panel.Controls.Add(commonControlButtons);
  106. this.Controls.Add(this.panel);
  107. this.ClientSize = new System.Drawing.Size(907, 546);
  108. this.Name = "ImagePreviewDialog";
  109. this.ResumeLayout(false);
  110. }
  111. }
  112. }