123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253 |
- using PaintDotNet.SystemLayer;
- using System;
- using System.Drawing;
- using System.Drawing.Drawing2D;
- using System.Windows.Forms;
- namespace PaintDotNet.CustomControl
- {
- /// <summary>
- /// 公共的快捷栏
- /// 给各个弹窗用
- /// </summary>
- public class GeneralAnalysisCommonControlButtons : ScrollPanel
- {
- /// <summary>
- /// 放大按钮
- /// </summary>
- public Button zoomInButton;
- /// <summary>
- /// 缩小按钮
- /// </summary>
- public Button zoomOutButton;
- /// <summary>
- /// 合适大小
- /// </summary>
- public Button zoomToWindowButton;
- /// <summary>
- /// 实际大小
- /// </summary>
- public Button actualSizeButton;
- /// <summary>
- /// 指针模式
- /// </summary>
- public Button pointerButton;
- /// <summary>
- /// 移动模式
- /// </summary>
- public Button mobileModeButton;
- /// <summary>
- /// 透明度的TrackBar
- /// </summary>
- public TrackBar trackBar;
- public Label trackLabel;
- /// <summary>
- /// 透明度的数值
- /// </summary>
- public TextBox textBox;
- public Label demoLabel;
- /// <summary>
- /// 位置
- /// </summary>
- public int locationX = 5;
- /// <summary>
- /// 左侧快捷工具的容器
- /// </summary>
- private Panel panelLeft;
- /// <summary>
- /// hint 提示信息
- /// </summary>
- public ToolTip toolTip;
- public GeneralAnalysisCommonControlButtons()
- {
- InitializeComponent();
- InitInternalControl();
- }
- /// <summary>
- /// 创建内部组件
- /// </summary>
- 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;
- //
- // 放大缩小的TrackBar
- //
- this.locationX += 20;
- this.trackLabel = new Label();
- this.trackLabel.Location = new Point(locationX, 5);
- this.trackLabel.Size = new Size(80, 20);
- this.trackLabel.Visible = false;
- this.locationX += 80;
- 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.zoomToWindowButton, PdnResources.GetString("Menu.Edit.ZoomToWindow.Text"));
- this.toolTip.SetToolTip(this.actualSizeButton, PdnResources.GetString("Menu.Edit.ActualSize.Text"));
- this.toolTip.SetToolTip(this.pointerButton, PdnResources.GetString("Menu.Pointertothemodel.text"));
- this.toolTip.SetToolTip(this.mobileModeButton, PdnResources.GetString("Menu.Mobilemodel.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.trackLabel);
- 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 WithTrackBar()
- {
- 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);
- this.trackLabel.Visible = true;
- }
- #region 设计器
- /// <summary>
- /// 必需的设计器变量。
- /// </summary>
- private System.ComponentModel.IContainer components = null;
- /// <summary>
- /// 清理所有正在使用的资源。
- /// </summary>
- /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
- #region 组件设计器生成的代码
- /// <summary>
- /// 设计器支持所需的方法 - 不要修改
- /// 使用代码编辑器修改此方法的内容。
- /// </summary>
- private void InitializeComponent()
- {
- components = new System.ComponentModel.Container();
- }
- #endregion
- #endregion
- }
- }
|