using PaintDotNet.CustomControl;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace PaintDotNet
{
internal class ImagePreviewDialog : PdnBaseForm
{
private AppWorkspace appWorkspace;
///
/// 图像面板
///
private DocumentWorkspaceWindow documentWorkspace;
///
/// 公共按钮
///
private CommonControlButtons commonControlButtons;
///
/// 底部图标栏
///
private Panel panel;
public ImagePreviewDialog(Image image, AppWorkspace appWorkspace)
{
this.appWorkspace = appWorkspace;
InitializeComponent();
this.documentWorkspace = new DocumentWorkspaceWindow(this.appWorkspace);
//
//DocumentWorkspaceWindow
//
this.documentWorkspace.Location = new System.Drawing.Point(0, 0);
this.documentWorkspace.Dock = DockStyle.Fill;
this.documentWorkspace.HookMouseEvents();
this.documentWorkspace.AuxiliaryLineEnabled = false;
this.documentWorkspace.RulersEnabled = false;
this.Controls.Add(this.documentWorkspace);
this.Text = PdnResources.GetString("Menu.Previewpicture.Text");
this.documentWorkspace.Document = Document.FromImage(image);
this.commonControlButtons.Location = new Point((this.Width - this.commonControlButtons.Width) / 2, 0);
this.Resize += new EventHandler(this.Resize_Event);
InitCommonButtonEvent();
}
private void InitCommonButtonEvent()
{
this.commonControlButtons.zoomInButton.Click += new EventHandler(zoomInButton_Click);
this.commonControlButtons.zoomOutButton.Click += new EventHandler(zoomOutButton_Click);
this.commonControlButtons.zoomToWindowButton.Click += new EventHandler(zoomToWindowButton_Click);
this.commonControlButtons.actualSizeButton.Click += new EventHandler(actualSizeButton_Click);
this.commonControlButtons.pointerButton.Click += new EventHandler(pointerButton_Click);
this.commonControlButtons.mobileModeButton.Click += new EventHandler(mobileModeButton_Click);
}
private void zoomInButton_Click(object sender, EventArgs e)
{
this.documentWorkspace.ZoomIn();
}
private void zoomOutButton_Click(object sender, EventArgs e)
{
this.documentWorkspace.ZoomOut();
}
private void zoomToWindowButton_Click(object sender, EventArgs e)
{
this.documentWorkspace.ZoomBasis = ZoomBasis.FitToWindow;
}
private void actualSizeButton_Click(object sender, EventArgs e)
{
this.documentWorkspace.ZoomBasis = ZoomBasis.ScaleFactor;
this.documentWorkspace.ScaleFactor = ScaleFactor.OneToOne;
}
private void pointerButton_Click(object sender, EventArgs e)
{
this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.Pointer;
}
private void mobileModeButton_Click(object sender, EventArgs e)
{
this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.MoveMode;
}
private void Resize_Event(object sender, EventArgs e)
{
this.commonControlButtons.Location = new Point((this.panel.Width - this.commonControlButtons.Width) / 2, 0);
//this.commonControlButtons.Left = (this.panel.Width - this.commonControlButtons.Width) / 2;
}
private void InitializeComponent()
{
this.SuspendLayout();
//
//底部panel
//
this.panel = new Panel();
this.panel.Height = 30;
this.panel.Dock = DockStyle.Bottom;
//
//初始化操作按钮
//
this.commonControlButtons = new CommonControlButtons();
this.commonControlButtons.Height = 30;
this.commonControlButtons.Width = 100;
this.commonControlButtons.HideZoomToWindowAndActualSize();
this.panel.Controls.Add(commonControlButtons);
this.Controls.Add(this.panel);
this.ClientSize = new System.Drawing.Size(907, 546);
this.Name = "ImagePreviewDialog";
this.ResumeLayout(false);
}
}
}