📄 form1.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.Threading;
namespace 表达式图像程序
{
public class Form : System.Windows.Forms.Form
{
/**********往下为自定义变量,结构,数组**********/
public Graphics graphicsObject;
//定义存放运算符(包括:'+','-',...,'sin',...,'arcsin',...,'(',...等)及其特性的数据结构
public struct opTable //定义存放运算符及其优先级和单双目的结构
{
public string op; //用于存放运算符 op为oprater的简写
public int code; //用存放运算符的优先级
public char grade; //用于判断存放的运算符是单目还是双目
}
public opTable[] opchTbl=new opTable[19]; //用于存放制定好的运算符及其特性(优先级和单双目)的运算符表,其初始化在方法Initialize()中
public opTable[] operateStack=new opTable[30]; //用于存放从键盘扫描的运算符的栈
//定义优先级列表 1,2,3,4,5,6,7,8,9,
public int[]osp=new int[19]{6,6,6,6,6,6,6,6,6,6,6,5,3,3,2,2,7,0,1}; //数组中元素依次为: "sin","cos","tan","cot","arcsin","arccos","arctan","sec","csc","ln","^","*","/","+","-","(",")","" 的栈外(因为有的运算符是从右向左计算,有的是从左往右计算,用内外优先级可以限制其执行顺序)优先级
public int[]isp=new int[18]{5,5,5,5,5,5,5,5,5,5,5,4,3,3,2,2,1,1}; //数组中元素依次为: "sin","cos","tan","cot","arcsin","arccos","arctan","sec","csc","ln","^","*","/","+","-","(" ,"end" 的栈内(因为有的运算符是从右向左计算,有的是从左往右计算,用内外优先级可以限制其执行顺序)优先级
//定义存放从键盘扫描的数据的栈
public double[]dataStack=new double[30]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
//定义表态指针
public int opTop=-1; //指向存放(从键盘扫描的)运算符栈的指针
public int dataTop=-1;//指向存放(从键盘扫描的)数据栈指针
//定义存放从键盘输入的起始字符串
public string startString; //存放优化后的表达式字符串
public int startTop=0; //
public double start=0; //图象显示区间的开始变量
//定义颜色数组
int color=1;
//定义中间字符串 (如果两次输入一样的表达式,则只显示第一个表达式图像)
string[] tempString=new string[50]; //存放正在显示图像表达式
public int tempTop=-1;
private int sign=0; //由于DrawFrontPicture()过程在两个不同的地方调用,用于控制里面的某些语句是否执行
private bool drawPoint=true; //如果输入表达式定义域有一个点有意义,则值为真,否则为假
private int daultScale_X; //保存初始的比例值,以便恢复时用
private int daultScale_Y;
private int view_X=1,view_Y=1; //置视野默认值为1
public static FormKeyBoard formKeyBoard; //<鼠标帮助输入窗口> 类的变量声明
public static bool keyboardWindowCreated=false; //标志是否显示此窗口
public static pictureHelp formPictureHelp; //<帮助窗口> 类的变量声明
public static bool pictureHelpCreated=false; //标志是否显示此窗口
public static Form2 computerForm; //<多功能计算器> 类的变量声明
public static bool computerFormCreated=false; //标志此窗口是否显示
public int startTopMoveCount=0; //在扫描输入的表达式时,用于记录 运算符/三角函数/常数/数据字数据的长度
#region Windows Form Designer generated code(包含所有控件的声明)
private System.Windows.Forms.Label label3;
private System.ComponentModel.Container components = null;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label label7;
public System.Windows.Forms.ComboBox expressBox;
private System.Windows.Forms.Button btnClearone;
private System.Windows.Forms.Button btnClearAll;
private System.Windows.Forms.Button btnDisplay;
private System.Windows.Forms.Button btnRefresh;
private System.Windows.Forms.Button btnRewrite;
private System.Windows.Forms.ComboBox functionsBox;
private System.Windows.Forms.Label label_X_Y;
private System.Windows.Forms.Label labelExpress;
private System.Windows.Forms.Label labelDifinition;
private System.Windows.Forms.Label labelfunctions;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.PictureBox pictureBox;
private System.Windows.Forms.Button btnPictureBig;
private System.Windows.Forms.Button btnPictureSmall;
private System.Windows.Forms.Button btnViewBig;
private System.Windows.Forms.Button btnViewSmall;
private System.Windows.Forms.Button btnPictureRestore;
private System.Windows.Forms.Button btnViewRestore;
private System.Windows.Forms.Button btnMouseScanf;
private System.Windows.Forms.ComboBox scale_X;
private System.Windows.Forms.ComboBox scale_Y;
private System.Windows.Forms.ComboBox area_X;
private System.Windows.Forms.ComboBox area_Y;
private System.Windows.Forms.ComboBox difinitionExpress;
private System.Windows.Forms.Button btnHelp;
private System.Windows.Forms.MenuItem menuItem1;
private System.Windows.Forms.MenuItem menuItem2;
private System.Windows.Forms.MenuItem menuItem3;
private System.Windows.Forms.MenuItem menuItem4;
private System.Windows.Forms.MenuItem menuItem5;
private System.Windows.Forms.MenuItem menuItem6;
private System.Windows.Forms.MenuItem menuItem7;
private System.Windows.Forms.MenuItem menuItem8;
private System.Windows.Forms.MenuItem menuItem9;
private System.Windows.Forms.MenuItem menuItem10;
private System.Windows.Forms.MenuItem menuItem12;
private System.Windows.Forms.MenuItem menuItem13;
private System.Windows.Forms.MenuItem menuItem14;
private System.Windows.Forms.MenuItem menuItem15;
private System.Windows.Forms.MenuItem menuItem16;
private System.Windows.Forms.MenuItem menuItem17;
private System.Windows.Forms.MenuItem menuItem18;
private System.Windows.Forms.MenuItem menuItem19;
private System.Windows.Forms.MenuItem menuItem20;
private System.Windows.Forms.MenuItem menuItem21;
private System.Windows.Forms.MenuItem menuItem22;
private System.Windows.Forms.MenuItem menuItem23;
private System.Windows.Forms.MenuItem menuItem24;
public System.Windows.Forms.MainMenu mainMenu;
private System.Windows.Forms.MenuItem menuItem26;
private System.Windows.Forms.MenuItem menuItem25;
#endregion
#region Windows Form Designer Initialize code(初始化)
public Form()
{
InitializeComponent(); //Windows Form Designer generated code
InitializeOpchTblStack();
daultScale_X=int.Parse(scale_X.Text);
daultScale_Y=int.Parse(scale_Y.Text);
this.menuItem1.Visible=false;
this.menuItem2.Visible=false;
this.menuItem3.Visible=false;
this.menuItem4.Visible=false;
this.menuItem5.Visible=false;
this.menuItem10.Visible=false;
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#endregion
#region Windows Form Designer generated code(创建所有控件)
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.label_X_Y = new System.Windows.Forms.Label();
this.btnDisplay = new System.Windows.Forms.Button();
this.labelExpress = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.btnClearAll = new System.Windows.Forms.Button();
this.btnClearone = new System.Windows.Forms.Button();
this.labelDifinition = new System.Windows.Forms.Label();
this.expressBox = new System.Windows.Forms.ComboBox();
this.btnPictureBig = new System.Windows.Forms.Button();
this.btnPictureSmall = new System.Windows.Forms.Button();
this.btnPictureRestore = new System.Windows.Forms.Button();
this.btnMouseScanf = new System.Windows.Forms.Button();
this.btnRefresh = new System.Windows.Forms.Button();
this.btnRewrite = new System.Windows.Forms.Button();
this.labelfunctions = new System.Windows.Forms.Label();
this.functionsBox = new System.Windows.Forms.ComboBox();
this.panel1 = new System.Windows.Forms.Panel();
this.pictureBox = new System.Windows.Forms.PictureBox();
this.btnViewBig = new System.Windows.Forms.Button();
this.btnViewRestore = new System.Windows.Forms.Button();
this.btnViewSmall = new System.Windows.Forms.Button();
this.scale_X = new System.Windows.Forms.ComboBox();
this.scale_Y = new System.Windows.Forms.ComboBox();
this.area_X = new System.Windows.Forms.ComboBox();
this.area_Y = new System.Windows.Forms.ComboBox();
this.difinitionExpress = new System.Windows.Forms.ComboBox();
this.btnHelp = new System.Windows.Forms.Button();
this.mainMenu = new System.Windows.Forms.MainMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.menuItem9 = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.menuItem7 = new System.Windows.Forms.MenuItem();
this.menuItem8 = new System.Windows.Forms.MenuItem();
this.menuItem26 = new System.Windows.Forms.MenuItem();
this.menuItem12 = new System.Windows.Forms.MenuItem();
this.menuItem13 = new System.Windows.Forms.MenuItem();
this.menuItem14 = new System.Windows.Forms.MenuItem();
this.menuItem15 = new System.Windows.Forms.MenuItem();
this.menuItem16 = new System.Windows.Forms.MenuItem();
this.menuItem17 = new System.Windows.Forms.MenuItem();
this.menuItem18 = new System.Windows.Forms.MenuItem();
this.menuItem19 = new System.Windows.Forms.MenuItem();
this.menuItem20 = new System.Windows.Forms.MenuItem();
this.menuItem21 = new System.Windows.Forms.MenuItem();
this.menuItem22 = new System.Windows.Forms.MenuItem();
this.menuItem23 = new System.Windows.Forms.MenuItem();
this.menuItem10 = new System.Windows.Forms.MenuItem();
this.menuItem24 = new System.Windows.Forms.MenuItem();
this.menuItem25 = new System.Windows.Forms.MenuItem();
this.menuItem4 = new System.Windows.Forms.MenuItem();
this.menuItem6 = new System.Windows.Forms.MenuItem();
this.menuItem5 = new System.Windows.Forms.MenuItem();
this.menuItem3 = new System.Windows.Forms.MenuItem();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// label_X_Y
//
this.label_X_Y.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.label_X_Y.AutoSize = true;
this.label_X_Y.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.label_X_Y.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label_X_Y.Location = new System.Drawing.Point(8, 424);
this.label_X_Y.Name = "label_X_Y";
this.label_X_Y.Size = new System.Drawing.Size(62, 20);
this.label_X_Y.TabIndex = 1;
this.label_X_Y.Text = "坐标显示:";
this.label_X_Y.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// btnDisplay
//
this.btnDisplay.AccessibleDescription = "";
this.btnDisplay.AccessibleName = "";
this.btnDisplay.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnDisplay.BackColor = System.Drawing.Color.LightSlateGray;
this.btnDisplay.Location = new System.Drawing.Point(192, 360);
this.btnDisplay.Name = "btnDisplay";
this.btnDisplay.Size = new System.Drawing.Size(72, 24);
this.btnDisplay.TabIndex = 4;
this.btnDisplay.Text = "显示图像";
this.btnDisplay.Click += new System.EventHandler(this.button1_Click);
//
// labelExpress
//
this.labelExpress.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.labelExpress.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.labelExpress.Location = new System.Drawing.Point(8, 328);
this.labelExpress.Name = "labelExpress";
this.labelExpress.Size = new System.Drawing.Size(72, 21);
this.labelExpress.TabIndex = 6;
this.labelExpress.Text = "表达式: y=";
this.labelExpress.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label3
//
this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.label3.Location = new System.Drawing.Point(80, 424);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(104, 32);
this.label3.TabIndex = 7;
this.label3.Text = "这里显示坐标";
//
// label4
//
this.label4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.label4.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.label4.Location = new System.Drawing.Point(468, 328);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(64, 21);
this.label4.TabIndex = 9;
this.label4.Text = "比例 X:";
//
// label5
//
this.label5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.label5.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.label5.Location = new System.Drawing.Point(596, 328);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(24, 21);
this.label5.TabIndex = 11;
this.label5.Text = "Y:";
//
// label6
//
this.label6.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.label6.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.label6.Location = new System.Drawing.Point(468, 352);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(64, 21);
this.label6.TabIndex = 13;
this.label6.Text = "区间 X:";
//
// label7
//
this.label7.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.label7.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.label7.Location = new System.Drawing.Point(596, 352);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(24, 21);
this.label7.TabIndex = 16;
this.label7.Text = "Y:";
//
// btnClearAll
//
this.btnClearAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnClearAll.BackColor = System.Drawing.Color.LightSlateGray;
this.btnClearAll.Location = new System.Drawing.Point(296, 424);
this.btnClearAll.Name = "btnClearAll";
this.btnClearAll.Size = new System.Drawing.Size(88, 24);
this.btnClearAll.TabIndex = 16;
this.btnClearAll.Text = "清除所有图像";
this.btnClearAll.Click += new System.EventHandler(this.button1_Click_1);
//
// btnClearone
//
this.btnClearone.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnClearone.BackColor = System.Drawing.Color.LightSlateGray;
this.btnClearone.ForeColor = System.Drawing.SystemColors.WindowFrame;
this.btnClearone.Location = new System.Drawing.Point(192, 424);
this.btnClearone.Name = "btnClearone";
this.btnClearone.Size = new System.Drawing.Size(88, 24);
this.btnClearone.TabIndex = 15;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -