📄 mainwindow.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Drawing.Drawing2D;
using System.IO;
using System.Drawing.Imaging;
namespace GraphicalCS
{
/// <summary>
/// Summary description for MainWindow.
/// </summary>
public class MainWindow : System.Windows.Forms.Form
{
internal System.Windows.Forms.Button AddFilledRectangle;
internal System.Windows.Forms.Button AddHollowRectangle;
internal System.Windows.Forms.Button AddPoint;
internal System.Windows.Forms.PictureBox Drawing;
private System.Windows.Forms.Button AddLine;
internal System.Windows.Forms.Button AddHollowEllipse;
internal System.Windows.Forms.Button AddFilledEllipse;
private System.Windows.Forms.Button AddCircle;
private System.Windows.Forms.Button AddFillCircle;
private System.Windows.Forms.Button AddPath;
private System.Windows.Forms.Button btnEraser;
private System.Windows.Forms.GroupBox grpTool;
private System.Windows.Forms.MainMenu mainMenu;
private System.Windows.Forms.MenuItem menuFile;
private System.Windows.Forms.MenuItem menuNew;
private System.Windows.Forms.MenuItem menuOpen;
private System.Windows.Forms.MenuItem menuSave;
private System.Windows.Forms.MenuItem menuSaveAs;
private System.Windows.Forms.MenuItem menuItem5;
private System.Windows.Forms.MenuItem menuExit;
private System.Windows.Forms.MenuItem menuItemEs;
private System.Windows.Forms.MenuItem menuItemSize1;
private System.Windows.Forms.MenuItem menuItemmenuItemSize2;
private System.Windows.Forms.MenuItem menuItemSize3;
private System.Windows.Forms.ContextMenu cntMenu;
private System.Windows.Forms.Button btnText;
private System.Windows.Forms.MenuItem menuItemCA;
private System.Windows.Forms.Button btnCircleAt;
private System.Windows.Forms.StatusBar statusBar;
private System.Windows.Forms.StatusBarPanel statusBarImageType;
private System.Windows.Forms.StatusBarPanel statusBarPoint;
private System.Windows.Forms.SaveFileDialog saveFileDialog;
private System.Windows.Forms.OpenFileDialog openFileDialog;
private System.Windows.Forms.Button AddPolygon;
private System.Windows.Forms.MenuItem menuItemClose;
private System.Windows.Forms.Button Black;
private System.Windows.Forms.Button White;
private System.Windows.Forms.Button Red;
private System.Windows.Forms.Button blue;
private System.Windows.Forms.Button Yellow;
private System.Windows.Forms.Button Cyan;
private System.Windows.Forms.Button Magenta;
private System.Windows.Forms.Button LawnGreen;
private System.Windows.Forms.Button btnColor;
private System.Windows.Forms.Button MoreColor;
private System.Windows.Forms.GroupBox ColorBox;
private System.Windows.Forms.ColorDialog colorDialog;
private System.Windows.Forms.Button AddCurve;
private System.Windows.Forms.ContextMenu Curvecontext;
private System.Windows.Forms.MenuItem Curve;
private System.Windows.Forms.MenuItem ClosedCurve;
private System.Windows.Forms.MenuItem menuItemLw;
private System.Windows.Forms.MenuItem menuBeziers;
private System.Windows.Forms.MenuItem Example;
private System.Windows.Forms.MenuItem Advance;
private System.Windows.Forms.MenuItem FadeInOut;
private System.Windows.Forms.MenuItem GrayScale;
private System.Windows.Forms.MenuItem GrayScale1;
private System.Windows.Forms.MenuItem GrayScale2;
private System.Windows.Forms.MenuItem grayScale3;
private System.Windows.Forms.MenuItem GrayScale4;
private System.Windows.Forms.MenuItem Inverse;
private System.Windows.Forms.MenuItem Flashligt;
private System.Windows.Forms.MenuItem BlurAndSharpen;
private System.Windows.Forms.MenuItem menuItem1;
private System.Windows.Forms.MenuItem Report;
private System.Windows.Forms.MenuItem Help;
private System.Windows.Forms.MenuItem menuItem2;
private System.Windows.Forms.MenuItem About;
private System.Windows.Forms.Button btnPick;
private System.Windows.Forms.ToolBar toolBar;
private System.Windows.Forms.ImageList imageList;
private System.Windows.Forms.ToolBarButton Undo;
private System.Windows.Forms.ToolBarButton Redu;
private System.Windows.Forms.ContextMenu ToolContext;
private System.Windows.Forms.MenuItem Change;
private System.Windows.Forms.MenuItem NotChange;
private System.Windows.Forms.ContextMenu ToolContext2;
private System.Windows.Forms.MenuItem Change2;
private System.Windows.Forms.MenuItem NotChange2;
private System.ComponentModel.IContainer components;
/// <summary>
/// 图形枚举。
/// </summary>
public enum ImageType
{
Empty,
Point,
Line,
Rectangle,
FillRectangle,
Circle,
FillCircle,
Ellipse,
FillEllipse,
Path,
Eraser,
Text,
CircleAt,
Polygon,
Curve,
ClosedCurve,
Beziers,
Set,
Pick
}
public MainWindow()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
this.SetStyle(ControlStyles.DoubleBuffer | //双重缓冲
ControlStyles.UserPaint |
ControlStyles.AllPaintingInWmPaint,
true);
this.UpdateStyles();
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// 主体窗架生成
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(MainWindow));
this.AddFilledRectangle = new System.Windows.Forms.Button();
this.AddHollowRectangle = new System.Windows.Forms.Button();
this.AddPoint = new System.Windows.Forms.Button();
this.Drawing = new System.Windows.Forms.PictureBox();
this.cntMenu = new System.Windows.Forms.ContextMenu();
this.menuItemEs = new System.Windows.Forms.MenuItem();
this.menuItemSize1 = new System.Windows.Forms.MenuItem();
this.menuItemmenuItemSize2 = new System.Windows.Forms.MenuItem();
this.menuItemSize3 = new System.Windows.Forms.MenuItem();
this.menuItemCA = new System.Windows.Forms.MenuItem();
this.menuItemClose = new System.Windows.Forms.MenuItem();
this.menuItemLw = new System.Windows.Forms.MenuItem();
this.Advance = new System.Windows.Forms.MenuItem();
this.FadeInOut = new System.Windows.Forms.MenuItem();
this.GrayScale = new System.Windows.Forms.MenuItem();
this.GrayScale1 = new System.Windows.Forms.MenuItem();
this.GrayScale2 = new System.Windows.Forms.MenuItem();
this.grayScale3 = new System.Windows.Forms.MenuItem();
this.GrayScale4 = new System.Windows.Forms.MenuItem();
this.Inverse = new System.Windows.Forms.MenuItem();
this.Flashligt = new System.Windows.Forms.MenuItem();
this.BlurAndSharpen = new System.Windows.Forms.MenuItem();
this.AddHollowEllipse = new System.Windows.Forms.Button();
this.AddFilledEllipse = new System.Windows.Forms.Button();
this.AddLine = new System.Windows.Forms.Button();
this.AddCircle = new System.Windows.Forms.Button();
this.grpTool = new System.Windows.Forms.GroupBox();
this.AddCurve = new System.Windows.Forms.Button();
this.Curvecontext = new System.Windows.Forms.ContextMenu();
this.Curve = new System.Windows.Forms.MenuItem();
this.ClosedCurve = new System.Windows.Forms.MenuItem();
this.AddPolygon = new System.Windows.Forms.Button();
this.btnCircleAt = new System.Windows.Forms.Button();
this.btnEraser = new System.Windows.Forms.Button();
this.AddPath = new System.Windows.Forms.Button();
this.AddFillCircle = new System.Windows.Forms.Button();
this.btnText = new System.Windows.Forms.Button();
this.mainMenu = new System.Windows.Forms.MainMenu();
this.menuFile = new System.Windows.Forms.MenuItem();
this.menuNew = new System.Windows.Forms.MenuItem();
this.menuOpen = new System.Windows.Forms.MenuItem();
this.menuSave = new System.Windows.Forms.MenuItem();
this.menuSaveAs = new System.Windows.Forms.MenuItem();
this.menuItem5 = new System.Windows.Forms.MenuItem();
this.menuExit = new System.Windows.Forms.MenuItem();
this.Example = new System.Windows.Forms.MenuItem();
this.menuBeziers = new System.Windows.Forms.MenuItem();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.Report = new System.Windows.Forms.MenuItem();
this.Help = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.About = new System.Windows.Forms.MenuItem();
this.statusBar = new System.Windows.Forms.StatusBar();
this.statusBarImageType = new System.Windows.Forms.StatusBarPanel();
this.statusBarPoint = new System.Windows.Forms.StatusBarPanel();
this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
this.btnColor = new System.Windows.Forms.Button();
this.Magenta = new System.Windows.Forms.Button();
this.blue = new System.Windows.Forms.Button();
this.Red = new System.Windows.Forms.Button();
this.White = new System.Windows.Forms.Button();
this.Black = new System.Windows.Forms.Button();
this.Yellow = new System.Windows.Forms.Button();
this.LawnGreen = new System.Windows.Forms.Button();
this.Cyan = new System.Windows.Forms.Button();
this.MoreColor = new System.Windows.Forms.Button();
this.ColorBox = new System.Windows.Forms.GroupBox();
this.colorDialog = new System.Windows.Forms.ColorDialog();
this.btnPick = new System.Windows.Forms.Button();
this.toolBar = new System.Windows.Forms.ToolBar();
this.Undo = new System.Windows.Forms.ToolBarButton();
this.ToolContext = new System.Windows.Forms.ContextMenu();
this.Change = new System.Windows.Forms.MenuItem();
this.NotChange = new System.Windows.Forms.MenuItem();
this.Redu = new System.Windows.Forms.ToolBarButton();
this.ToolContext2 = new System.Windows.Forms.ContextMenu();
this.Change2 = new System.Windows.Forms.MenuItem();
this.NotChange2 = new System.Windows.Forms.MenuItem();
this.imageList = new System.Windows.Forms.ImageList(this.components);
this.grpTool.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.statusBarImageType)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.statusBarPoint)).BeginInit();
this.ColorBox.SuspendLayout();
this.SuspendLayout();
//
// AddFilledRectangle
//
this.AddFilledRectangle.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.AddFilledRectangle.BackColor = System.Drawing.SystemColors.ControlLightLight;
this.AddFilledRectangle.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("AddFilledRectangle.BackgroundImage")));
this.AddFilledRectangle.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.AddFilledRectangle.Image = ((System.Drawing.Image)(resources.GetObject("AddFilledRectangle.Image")));
this.AddFilledRectangle.Location = new System.Drawing.Point(48, 48);
this.AddFilledRectangle.Name = "AddFilledRectangle";
this.AddFilledRectangle.Size = new System.Drawing.Size(26, 26);
this.AddFilledRectangle.TabIndex = 17;
this.AddFilledRectangle.Click += new System.EventHandler(this.AddFilledRectangle_Click);
//
// AddHollowRectangle
//
this.AddHollowRectangle.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.AddHollowRectangle.BackColor = System.Drawing.SystemColors.ControlLightLight;
this.AddHollowRectangle.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("AddHollowRectangle.BackgroundImage")));
this.AddHollowRectangle.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.AddHollowRectangle.Image = ((System.Drawing.Image)(resources.GetObject("AddHollowRectangle.Image")));
this.AddHollowRectangle.Location = new System.Drawing.Point(8, 48);
this.AddHollowRectangle.Name = "AddHollowRectangle";
this.AddHollowRectangle.Size = new System.Drawing.Size(26, 26);
this.AddHollowRectangle.TabIndex = 16;
this.AddHollowRectangle.Click += new System.EventHandler(this.AddHollowRectangle_Click);
//
// AddPoint
//
this.AddPoint.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.AddPoint.BackColor = System.Drawing.SystemColors.ControlLightLight;
this.AddPoint.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("AddPoint.BackgroundImage")));
this.AddPoint.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.AddPoint.Location = new System.Drawing.Point(8, 16);
this.AddPoint.Name = "AddPoint";
this.AddPoint.Size = new System.Drawing.Size(26, 26);
this.AddPoint.TabIndex = 15;
this.AddPoint.Click += new System.EventHandler(this.AddPoint_Click);
//
// Drawing
//
this.Drawing.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.Drawing.BackColor = System.Drawing.SystemColors.ControlLightLight;
this.Drawing.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.Drawing.ContextMenu = this.cntMenu;
this.Drawing.Location = new System.Drawing.Point(8, 8);
this.Drawing.Name = "Drawing";
this.Drawing.Size = new System.Drawing.Size(567, 427);
this.Drawing.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.Drawing.TabIndex = 14;
this.Drawing.TabStop = false;
this.Drawing.Paint += new System.Windows.Forms.PaintEventHandler(this.Drawing_Paint);
this.Drawing.MouseEnter += new System.EventHandler(this.Drawing_MouseEnter);
this.Drawing.MouseUp += new System.Windows.Forms.MouseEventHandler(this.Drawing_MouseUp);
this.Drawing.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Drawing_MouseMove);
this.Drawing.MouseLeave += new System.EventHandler(this.Drawing_MouseLeave);
this.Drawing.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Drawing_MouseDown);
//
// cntMenu
//
this.cntMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItemEs,
this.menuItemCA,
this.menuItemClose,
this.menuItemLw,
this.Advance});
//
// menuItemEs
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -