using PaintDotNet.SystemLayer; using System; using System.Drawing; using System.Drawing.Drawing2D; using System.Windows.Forms; namespace PaintDotNet.CustomControl { /// /// 公共的快捷栏 /// 给各个弹窗用 /// public class ArtworkControlButtons : ScrollPanel { /// /// 放大按钮 /// public Button zoomInButton; /// /// 缩小按钮 /// public Button zoomOutButton; /// /// 合适大小 /// public Button zoomToWindowButton; /// /// 实际大小 /// public Button actualSizeButton; /// /// 指针模式 /// public Button pointerButton; /// /// 移动模式 /// public Button mobileModeButton; /// /// 向上移动 /// public Button moveUpButton; /// /// 向下移动 /// public Button moveDownButton; /// /// 向左移动 /// public Button moveLeftButton; /// /// 向右移动 /// public Button moveRightButton; /// /// 向左旋转 /// public Button turnLeftButton; /// /// 向右旋转 /// public Button turnRightButton; /// /// 透明度的TrackBar /// public TrackBar trackBar; /// /// 透明度的数值 /// public TextBox textBox; /// /// 位置 /// public int locationX = 5; /// /// 左侧快捷工具的容器 /// private Panel panelLeft; /// /// hint 提示信息 /// public ToolTip toolTip; public ArtworkControlButtons() { InitializeComponent(); InitInternalControl(); } /// /// 创建内部组件 /// private void InitInternalControl() { // // 设置Panel属性 // this.Cursor = Cursors.Default; // // 左侧panel属性 // this.panelLeft = new Panel(); this.panelLeft.Dock = DockStyle.Left; this.panelLeft.AutoSize = true; // // 放大按钮 // this.zoomInButton = new Button(); this.zoomInButton.Location = new Point(locationX, 5); this.zoomInButton.Size = new Size(20, 20); this.zoomInButton.Image = PdnResources.GetImageResource("Icons.MenuViewZoomInIcon.png").Reference; this.zoomInButton.FlatStyle = FlatStyle.Flat; this.zoomInButton.FlatAppearance.BorderSize = 0; // // 缩小按钮 // this.locationX += 20; this.zoomOutButton = new Button(); this.zoomOutButton.Location = new Point(locationX, 5); this.zoomOutButton.Size = new Size(20, 20); this.zoomOutButton.Image = PdnResources.GetImageResource("Icons.MenuViewZoomOutIcon.png").Reference; this.zoomOutButton.FlatStyle = FlatStyle.Flat; this.zoomOutButton.FlatAppearance.BorderSize = 0; // // 合适大小 // this.locationX += 20; this.zoomToWindowButton = new Button(); this.zoomToWindowButton.Location = new Point(locationX, 5); this.zoomToWindowButton.Size = new Size(20, 20); this.zoomToWindowButton.Image = PdnResources.GetImageResource("Icons.MenuViewZoomToWindowIcon.png").Reference; this.zoomToWindowButton.FlatStyle = FlatStyle.Flat; this.zoomToWindowButton.FlatAppearance.BorderSize = 0; // // 实际大小 // this.locationX += 20; this.actualSizeButton = new Button(); this.actualSizeButton.Location = new Point(locationX, 5); this.actualSizeButton.Size = new Size(20, 20); this.actualSizeButton.Image = PdnResources.GetImageResource("Icons.MenuViewActualSizeIcon.png").Reference; this.actualSizeButton.FlatStyle = FlatStyle.Flat; this.actualSizeButton.FlatAppearance.BorderSize = 0; // // 指针模式 // this.locationX += 20; this.pointerButton = new Button(); this.pointerButton.Location = new Point(locationX, 5); this.pointerButton.Size = new Size(20, 20); this.pointerButton.Image = PdnResources.GetImageResource("Icons.MoveSelectionToolIcon.png").Reference; this.pointerButton.FlatStyle = FlatStyle.Flat; this.pointerButton.FlatAppearance.BorderSize = 0; // // 移动模式 // this.locationX += 20; this.mobileModeButton = new Button(); this.mobileModeButton.Location = new Point(locationX, 5); this.mobileModeButton.Size = new Size(20, 20); this.mobileModeButton.Image = PdnResources.GetImageResource("Icons.PanToolIcon.png").Reference; this.mobileModeButton.FlatStyle = FlatStyle.Flat; this.mobileModeButton.FlatAppearance.BorderSize = 0; // // 向上移动 // this.locationX += 20; this.moveUpButton = new Button(); this.moveUpButton.Location = new Point(locationX, 5); this.moveUpButton.Size = new Size(20, 20); this.moveUpButton.Image = PdnResources.GetImageResource("Icons.MenuLayersMoveLayerUpIcon.png").Reference; this.moveUpButton.FlatStyle = FlatStyle.Flat; this.moveUpButton.FlatAppearance.BorderSize = 0; // // 向下移动 // this.locationX += 20; this.moveDownButton = new Button(); this.moveDownButton.Location = new Point(locationX, 5); this.moveDownButton.Size = new Size(20, 20); this.moveDownButton.Image = PdnResources.GetImageResource("Icons.MenuLayersMoveLayerDownIcon.png").Reference; this.moveDownButton.FlatStyle = FlatStyle.Flat; this.moveDownButton.FlatAppearance.BorderSize = 0; // // 向左移动 // this.locationX += 20; this.moveLeftButton = new Button(); this.moveLeftButton.Location = new Point(locationX, 5); this.moveLeftButton.Size = new Size(20, 20); this.moveLeftButton.Image = PdnResources.GetImageResource("Icons.MenuEditUndoIcon.png").Reference; this.moveLeftButton.FlatStyle = FlatStyle.Flat; this.moveLeftButton.FlatAppearance.BorderSize = 0; // // 向右移动 // this.locationX += 20; this.moveRightButton = new Button(); this.moveRightButton.Location = new Point(locationX, 5); this.moveRightButton.Size = new Size(20, 20); this.moveRightButton.Image = PdnResources.GetImageResource("Icons.MenuEditRedoIcon.png").Reference; this.moveRightButton.FlatStyle = FlatStyle.Flat; this.moveRightButton.FlatAppearance.BorderSize = 0; // // 向左旋转 // this.locationX += 20; this.turnLeftButton = new Button(); this.turnLeftButton.Location = new Point(locationX, 5); this.turnLeftButton.Size = new Size(20, 20); this.turnLeftButton.Image = PdnResources.GetImageResource("Icons.MenuEditUndoIcon.png").Reference; this.turnLeftButton.FlatStyle = FlatStyle.Flat; this.turnLeftButton.FlatAppearance.BorderSize = 0; this.turnLeftButton.Visible = false; // // 向右旋转 // this.locationX += 20; this.turnRightButton = new Button(); this.turnRightButton.Location = new Point(locationX, 5); this.turnRightButton.Size = new Size(20, 20); this.turnRightButton.Image = PdnResources.GetImageResource("Icons.MenuEditRedoIcon.png").Reference; this.turnRightButton.FlatStyle = FlatStyle.Flat; this.turnRightButton.FlatAppearance.BorderSize = 0; this.turnRightButton.Visible = false; // // 放大缩小的TrackBar // this.locationX += 20; this.trackBar = new TrackBar(); this.trackBar.AutoSize = false; this.trackBar.Minimum = 1; this.trackBar.Name = "amountTrackBar"; this.trackBar.Location = new Point(locationX, 5); this.trackBar.Size = new Size(175, 20); this.trackBar.SmallChange = 1; this.trackBar.TickStyle = TickStyle.None; this.trackBar.Visible = false; // // 放大缩小的百分比 // this.locationX += 175; this.textBox = new TextBox(); this.textBox.Size = new Size(40, 20); this.textBox.Location = new Point(locationX, 5); this.textBox.Visible = false; // // 提示信息 // this.toolTip = new ToolTip(); this.toolTip.SetToolTip(this.zoomInButton, PdnResources.GetString("Menu.Edit.ZoomIn.Text")); this.toolTip.SetToolTip(this.zoomOutButton, PdnResources.GetString("CommonAction.ZoomOut")); this.toolTip.SetToolTip(this.pointerButton, PdnResources.GetString("Menu.Pointertothemodel.text")); this.toolTip.SetToolTip(this.mobileModeButton, PdnResources.GetString("Menu.Mobilemodel.text")); this.toolTip.SetToolTip(this.zoomToWindowButton, PdnResources.GetString("Menu.Edit.ZoomToWindow.Text")); this.toolTip.SetToolTip(this.actualSizeButton, PdnResources.GetString("Menu.Edit.ActualSize.Text")); this.toolTip.SetToolTip(this.moveUpButton, PdnResources.GetString("Menu.LabelAction.MoveUpAction.Text")); this.toolTip.SetToolTip(this.moveDownButton, PdnResources.GetString("Menu.LabelAction.MoveDownAction.Text")); this.toolTip.SetToolTip(this.moveLeftButton, PdnResources.GetString("Menu.Movetotheleft.text")); this.toolTip.SetToolTip(this.moveRightButton, PdnResources.GetString("Menu.Totheright.text")); this.toolTip.SetToolTip(this.turnLeftButton, PdnResources.GetString("Menu.Rotatetotheleft.text")); this.toolTip.SetToolTip(this.turnRightButton, PdnResources.GetString("Menu.Spintotheright.text")); this.panelLeft.Controls.Add(this.zoomInButton); this.panelLeft.Controls.Add(this.zoomOutButton); this.panelLeft.Controls.Add(this.zoomToWindowButton); this.panelLeft.Controls.Add(this.actualSizeButton); this.panelLeft.Controls.Add(this.pointerButton); this.panelLeft.Controls.Add(this.mobileModeButton); this.panelLeft.Controls.Add(this.moveUpButton); this.panelLeft.Controls.Add(this.moveDownButton); this.panelLeft.Controls.Add(this.moveLeftButton); this.panelLeft.Controls.Add(this.moveRightButton); this.panelLeft.Controls.Add(this.turnLeftButton); this.panelLeft.Controls.Add(this.turnRightButton); this.panelLeft.Controls.Add(this.trackBar); this.panelLeft.Controls.Add(this.textBox); this.Controls.Add(this.panelLeft); } public void HideZoomToWindowAndActualSize() { this.zoomToWindowButton.Visible = false; this.actualSizeButton.Visible = false; this.pointerButton.Location = new Point(this.pointerButton.Location.X - 40, this.pointerButton.Location.Y); this.mobileModeButton.Location = new Point(this.mobileModeButton.Location.X - 40, this.mobileModeButton.Location.Y); } public void HideMovingDirection() { this.Width -= 80; this.moveUpButton.Visible = false; this.moveDownButton.Visible = false; this.moveLeftButton.Visible = false; this.moveRightButton.Visible = false; this.turnLeftButton.Location = new Point(this.turnLeftButton.Location.X - 80, this.turnLeftButton.Location.Y); this.turnRightButton.Location = new Point(this.turnRightButton.Location.X - 80, this.turnRightButton.Location.Y); } public void WithTrackBar() { this.Width -= 40; this.zoomToWindowButton.Visible = false; this.actualSizeButton.Visible = false; this.trackBar.Visible = true; this.pointerButton.Location = new Point(this.pointerButton.Location.X - 40, this.pointerButton.Location.Y); this.mobileModeButton.Location = new Point(this.mobileModeButton.Location.X - 40, this.mobileModeButton.Location.Y); } #region 设计器 /// /// 必需的设计器变量。 /// private System.ComponentModel.IContainer components = null; /// /// 清理所有正在使用的资源。 /// /// 如果应释放托管资源,为 true;否则为 false。 protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region 组件设计器生成的代码 /// /// 设计器支持所需的方法 - 不要修改 /// 使用代码编辑器修改此方法的内容。 /// private void InitializeComponent() { components = new System.ComponentModel.Container(); } #endregion #endregion } }