diff --git a/PowerCalc.sln b/PowerCalc.sln index 0c0f69e..deb6590 100644 --- a/PowerCalc.sln +++ b/PowerCalc.sln @@ -5,6 +5,11 @@ VisualStudioVersion = 16.0.29519.87 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PowerCalc", "PowerCalc\PowerCalc.csproj", "{C97F69FA-BACC-45BE-97A2-6D88535B7665}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{0E74F5E8-1B7D-4D54-A5BD-9369050A8F98}" + ProjectSection(SolutionItems) = preProject + README.md = README.md + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/PowerCalc/MainForm.Designer.cs b/PowerCalc/MainForm.Designer.cs index 427a497..cfd43e7 100644 --- a/PowerCalc/MainForm.Designer.cs +++ b/PowerCalc/MainForm.Designer.cs @@ -43,6 +43,7 @@ this.logExpandButton = new System.Windows.Forms.Button(); this.logBox = new System.Windows.Forms.TextBox(); this.logCollapseButton = new System.Windows.Forms.Button(); + this.saveButton = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit(); this.splitContainer.Panel1.SuspendLayout(); this.splitContainer.Panel2.SuspendLayout(); @@ -158,6 +159,7 @@ // splitContainer.Panel1 // this.splitContainer.Panel1.AutoScroll = true; + this.splitContainer.Panel1.Controls.Add(this.saveButton); this.splitContainer.Panel1.Controls.Add(this.coordLabel); this.splitContainer.Panel1.Controls.Add(this.evalButton); this.splitContainer.Panel1.Controls.Add(this.logExpandButton); @@ -187,15 +189,16 @@ this.coordLabel.AutoSize = true; this.coordLabel.Location = new System.Drawing.Point(68, 155); this.coordLabel.Name = "coordLabel"; - this.coordLabel.Size = new System.Drawing.Size(0, 13); + this.coordLabel.Size = new System.Drawing.Size(44, 13); this.coordLabel.TabIndex = 10; + this.coordLabel.Text = "{X=,Y=}"; // // evalButton // this.evalButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.evalButton.Location = new System.Drawing.Point(3, 150); this.evalButton.Name = "evalButton"; - this.evalButton.Size = new System.Drawing.Size(59, 23); + this.evalButton.Size = new System.Drawing.Size(36, 23); this.evalButton.TabIndex = 9; this.evalButton.Text = "Eval"; this.evalButton.UseVisualStyleBackColor = true; @@ -233,6 +236,17 @@ this.logCollapseButton.UseVisualStyleBackColor = true; this.logCollapseButton.Click += new System.EventHandler(this.logCollapseButton_Click); // + // saveButton + // + this.saveButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.saveButton.Location = new System.Drawing.Point(39, 150); + this.saveButton.Name = "saveButton"; + this.saveButton.Size = new System.Drawing.Size(23, 23); + this.saveButton.TabIndex = 11; + this.saveButton.Text = "💾"; + this.saveButton.UseVisualStyleBackColor = true; + this.saveButton.Click += new System.EventHandler(this.saveButton_Click); + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -271,6 +285,7 @@ private System.Windows.Forms.Button logExpandButton; private System.Windows.Forms.Button evalButton; private System.Windows.Forms.Label coordLabel; + private System.Windows.Forms.Button saveButton; } } diff --git a/PowerCalc/MainForm.cs b/PowerCalc/MainForm.cs index 0f38f05..ac22d57 100644 --- a/PowerCalc/MainForm.cs +++ b/PowerCalc/MainForm.cs @@ -2,15 +2,24 @@ using System; using System.Collections.Generic; using System.Drawing; +using System.Drawing.Imaging; using System.Linq; -using System.Threading; using System.Windows.Forms; namespace PowerCalc { public partial class MainForm : Form { - public MainForm() => InitializeComponent(); + public MainForm() + { + InitializeComponent(); + evalBox_MouseLeave(null, null); +#if DEBUG + logExpandButton_Click(null, null); +#else + logCollapseButton_Click(null, null); +#endif + } private void logCollapseButton_Click(object sender, EventArgs e) { @@ -130,6 +139,31 @@ namespace PowerCalc private void evalBox_MouseMove(object sender, MouseEventArgs e) => coordLabel.Text = new Point(e.X, evalBox.Height - e.Y).ToString(); - private void evalBox_MouseLeave(object sender, EventArgs e) => coordLabel.Text = ""; + private void evalBox_MouseLeave(object sender, EventArgs e) => coordLabel.Text = Point.Empty.ToString().Replace("0", ""); + + private void saveButton_Click(object sender, EventArgs e) + { + ImageFormat[] formats = new ImageFormat[] + { + ImageFormat.Bmp, + ImageFormat.Emf, + ImageFormat.Gif, + ImageFormat.Jpeg, + ImageFormat.Png, + ImageFormat.Tiff, + ImageFormat.Wmf + }; + SaveFileDialog dlg = new SaveFileDialog + { + FileName = "Graph", + Filter = string.Join("|", formats.Select(s => s.ToString() + " Image|*." + (s.ToString() == "Jpeg" ? "jpg" : s.ToString().ToLower())).ToArray()) + }; + if (dlg.ShowDialog() == DialogResult.OK) + { + Bitmap bmp = new Bitmap(evalBox.Width, evalBox.Height); + evalBox_Paint(evalBox, new PaintEventArgs(Graphics.FromImage(bmp), new Rectangle(Point.Empty, bmp.Size))); + bmp.Save(dlg.FileName, formats[dlg.FilterIndex - 1]); + } + } } } \ No newline at end of file