Update checker is mostly done. Negative zoom levels are no longer permitted either.
This commit is contained in:
parent
aba32f8b58
commit
789a3b448e
107
Base/Forms/GraphForm.Designer.cs
generated
107
Base/Forms/GraphForm.Designer.cs
generated
@ -51,16 +51,22 @@ namespace Graphing.Forms
|
|||||||
MenuMisc = new ToolStripMenuItem();
|
MenuMisc = new ToolStripMenuItem();
|
||||||
MenuMiscCaches = new ToolStripMenuItem();
|
MenuMiscCaches = new ToolStripMenuItem();
|
||||||
MiscMenuPreload = new ToolStripMenuItem();
|
MiscMenuPreload = new ToolStripMenuItem();
|
||||||
|
UpdaterPopup = new Panel();
|
||||||
|
UpdaterPopupDownloadButton = new Button();
|
||||||
|
UpdaterPopupCloseButton = new Button();
|
||||||
|
UpdaterPopupMessage = new Label();
|
||||||
GraphMenu.SuspendLayout();
|
GraphMenu.SuspendLayout();
|
||||||
|
UpdaterPopup.SuspendLayout();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// ResetViewportButton
|
// ResetViewportButton
|
||||||
//
|
//
|
||||||
ResetViewportButton.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
ResetViewportButton.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
ResetViewportButton.Font = new Font("Segoe UI Emoji", 12F, FontStyle.Regular, GraphicsUnit.Point, 0);
|
ResetViewportButton.Font = new Font("Segoe UI Emoji", 12F, FontStyle.Regular, GraphicsUnit.Point, 0);
|
||||||
ResetViewportButton.Location = new Point(1373, 43);
|
ResetViewportButton.Location = new Point(739, 20);
|
||||||
|
ResetViewportButton.Margin = new Padding(2, 1, 2, 1);
|
||||||
ResetViewportButton.Name = "ResetViewportButton";
|
ResetViewportButton.Name = "ResetViewportButton";
|
||||||
ResetViewportButton.Size = new Size(64, 64);
|
ResetViewportButton.Size = new Size(34, 30);
|
||||||
ResetViewportButton.TabIndex = 0;
|
ResetViewportButton.TabIndex = 0;
|
||||||
ResetViewportButton.Text = "🏠";
|
ResetViewportButton.Text = "🏠";
|
||||||
ResetViewportButton.UseVisualStyleBackColor = true;
|
ResetViewportButton.UseVisualStyleBackColor = true;
|
||||||
@ -72,7 +78,8 @@ namespace Graphing.Forms
|
|||||||
GraphMenu.Items.AddRange(new ToolStripItem[] { MenuViewport, MenuElements, MenuOperations, MenuConvert, MenuMisc });
|
GraphMenu.Items.AddRange(new ToolStripItem[] { MenuViewport, MenuElements, MenuOperations, MenuConvert, MenuMisc });
|
||||||
GraphMenu.Location = new Point(0, 0);
|
GraphMenu.Location = new Point(0, 0);
|
||||||
GraphMenu.Name = "GraphMenu";
|
GraphMenu.Name = "GraphMenu";
|
||||||
GraphMenu.Size = new Size(1449, 40);
|
GraphMenu.Padding = new Padding(3, 1, 0, 1);
|
||||||
|
GraphMenu.Size = new Size(780, 24);
|
||||||
GraphMenu.TabIndex = 1;
|
GraphMenu.TabIndex = 1;
|
||||||
GraphMenu.Text = "menuStrip1";
|
GraphMenu.Text = "menuStrip1";
|
||||||
//
|
//
|
||||||
@ -80,34 +87,34 @@ namespace Graphing.Forms
|
|||||||
//
|
//
|
||||||
MenuViewport.DropDownItems.AddRange(new ToolStripItem[] { ButtonViewportSetZoom, ButtonViewportSetCenter, ButtonViewportReset, ButtonViewportResetWindow });
|
MenuViewport.DropDownItems.AddRange(new ToolStripItem[] { ButtonViewportSetZoom, ButtonViewportSetCenter, ButtonViewportReset, ButtonViewportResetWindow });
|
||||||
MenuViewport.Name = "MenuViewport";
|
MenuViewport.Name = "MenuViewport";
|
||||||
MenuViewport.Size = new Size(129, 36);
|
MenuViewport.Size = new Size(66, 22);
|
||||||
MenuViewport.Text = "Viewport";
|
MenuViewport.Text = "Viewport";
|
||||||
//
|
//
|
||||||
// ButtonViewportSetZoom
|
// ButtonViewportSetZoom
|
||||||
//
|
//
|
||||||
ButtonViewportSetZoom.Name = "ButtonViewportSetZoom";
|
ButtonViewportSetZoom.Name = "ButtonViewportSetZoom";
|
||||||
ButtonViewportSetZoom.Size = new Size(350, 44);
|
ButtonViewportSetZoom.Size = new Size(174, 22);
|
||||||
ButtonViewportSetZoom.Text = "Set Zoom";
|
ButtonViewportSetZoom.Text = "Set Zoom";
|
||||||
ButtonViewportSetZoom.Click += ButtonViewportSetZoom_Click;
|
ButtonViewportSetZoom.Click += ButtonViewportSetZoom_Click;
|
||||||
//
|
//
|
||||||
// ButtonViewportSetCenter
|
// ButtonViewportSetCenter
|
||||||
//
|
//
|
||||||
ButtonViewportSetCenter.Name = "ButtonViewportSetCenter";
|
ButtonViewportSetCenter.Name = "ButtonViewportSetCenter";
|
||||||
ButtonViewportSetCenter.Size = new Size(350, 44);
|
ButtonViewportSetCenter.Size = new Size(174, 22);
|
||||||
ButtonViewportSetCenter.Text = "Set Center Position";
|
ButtonViewportSetCenter.Text = "Set Center Position";
|
||||||
ButtonViewportSetCenter.Click += ButtonViewportSetCenter_Click;
|
ButtonViewportSetCenter.Click += ButtonViewportSetCenter_Click;
|
||||||
//
|
//
|
||||||
// ButtonViewportReset
|
// ButtonViewportReset
|
||||||
//
|
//
|
||||||
ButtonViewportReset.Name = "ButtonViewportReset";
|
ButtonViewportReset.Name = "ButtonViewportReset";
|
||||||
ButtonViewportReset.Size = new Size(350, 44);
|
ButtonViewportReset.Size = new Size(174, 22);
|
||||||
ButtonViewportReset.Text = "Reset Viewport";
|
ButtonViewportReset.Text = "Reset Viewport";
|
||||||
ButtonViewportReset.Click += ButtonViewportReset_Click;
|
ButtonViewportReset.Click += ButtonViewportReset_Click;
|
||||||
//
|
//
|
||||||
// ButtonViewportResetWindow
|
// ButtonViewportResetWindow
|
||||||
//
|
//
|
||||||
ButtonViewportResetWindow.Name = "ButtonViewportResetWindow";
|
ButtonViewportResetWindow.Name = "ButtonViewportResetWindow";
|
||||||
ButtonViewportResetWindow.Size = new Size(350, 44);
|
ButtonViewportResetWindow.Size = new Size(174, 22);
|
||||||
ButtonViewportResetWindow.Text = "Reset Window Size";
|
ButtonViewportResetWindow.Text = "Reset Window Size";
|
||||||
ButtonViewportResetWindow.Click += ButtonViewportResetWindow_Click;
|
ButtonViewportResetWindow.Click += ButtonViewportResetWindow_Click;
|
||||||
//
|
//
|
||||||
@ -115,98 +122,148 @@ namespace Graphing.Forms
|
|||||||
//
|
//
|
||||||
MenuElements.DropDownItems.AddRange(new ToolStripItem[] { MenuElementsColors, MenuElementsRemove });
|
MenuElements.DropDownItems.AddRange(new ToolStripItem[] { MenuElementsColors, MenuElementsRemove });
|
||||||
MenuElements.Name = "MenuElements";
|
MenuElements.Name = "MenuElements";
|
||||||
MenuElements.Size = new Size(131, 36);
|
MenuElements.Size = new Size(67, 22);
|
||||||
MenuElements.Text = "Elements";
|
MenuElements.Text = "Elements";
|
||||||
//
|
//
|
||||||
// MenuElementsColors
|
// MenuElementsColors
|
||||||
//
|
//
|
||||||
MenuElementsColors.Name = "MenuElementsColors";
|
MenuElementsColors.Name = "MenuElementsColors";
|
||||||
MenuElementsColors.Size = new Size(233, 44);
|
MenuElementsColors.Size = new Size(117, 22);
|
||||||
MenuElementsColors.Text = "Colors";
|
MenuElementsColors.Text = "Colors";
|
||||||
//
|
//
|
||||||
// MenuElementsRemove
|
// MenuElementsRemove
|
||||||
//
|
//
|
||||||
MenuElementsRemove.Name = "MenuElementsRemove";
|
MenuElementsRemove.Name = "MenuElementsRemove";
|
||||||
MenuElementsRemove.Size = new Size(233, 44);
|
MenuElementsRemove.Size = new Size(117, 22);
|
||||||
MenuElementsRemove.Text = "Remove";
|
MenuElementsRemove.Text = "Remove";
|
||||||
//
|
//
|
||||||
// MenuOperations
|
// MenuOperations
|
||||||
//
|
//
|
||||||
MenuOperations.DropDownItems.AddRange(new ToolStripItem[] { MenuOperationsDerivative, MenuOperationsIntegral, MenuOperationsTranslate });
|
MenuOperations.DropDownItems.AddRange(new ToolStripItem[] { MenuOperationsDerivative, MenuOperationsIntegral, MenuOperationsTranslate });
|
||||||
MenuOperations.Name = "MenuOperations";
|
MenuOperations.Name = "MenuOperations";
|
||||||
MenuOperations.Size = new Size(151, 36);
|
MenuOperations.Size = new Size(77, 22);
|
||||||
MenuOperations.Text = "Operations";
|
MenuOperations.Text = "Operations";
|
||||||
//
|
//
|
||||||
// MenuOperationsDerivative
|
// MenuOperationsDerivative
|
||||||
//
|
//
|
||||||
MenuOperationsDerivative.Name = "MenuOperationsDerivative";
|
MenuOperationsDerivative.Name = "MenuOperationsDerivative";
|
||||||
MenuOperationsDerivative.Size = new Size(360, 44);
|
MenuOperationsDerivative.Size = new Size(179, 22);
|
||||||
MenuOperationsDerivative.Text = "Compute Derivative";
|
MenuOperationsDerivative.Text = "Compute Derivative";
|
||||||
//
|
//
|
||||||
// MenuOperationsIntegral
|
// MenuOperationsIntegral
|
||||||
//
|
//
|
||||||
MenuOperationsIntegral.Name = "MenuOperationsIntegral";
|
MenuOperationsIntegral.Name = "MenuOperationsIntegral";
|
||||||
MenuOperationsIntegral.Size = new Size(360, 44);
|
MenuOperationsIntegral.Size = new Size(179, 22);
|
||||||
MenuOperationsIntegral.Text = "Compute Integral";
|
MenuOperationsIntegral.Text = "Compute Integral";
|
||||||
//
|
//
|
||||||
// MenuOperationsTranslate
|
// MenuOperationsTranslate
|
||||||
//
|
//
|
||||||
MenuOperationsTranslate.Name = "MenuOperationsTranslate";
|
MenuOperationsTranslate.Name = "MenuOperationsTranslate";
|
||||||
MenuOperationsTranslate.Size = new Size(360, 44);
|
MenuOperationsTranslate.Size = new Size(179, 22);
|
||||||
MenuOperationsTranslate.Text = "Translate";
|
MenuOperationsTranslate.Text = "Translate";
|
||||||
//
|
//
|
||||||
// MenuConvert
|
// MenuConvert
|
||||||
//
|
//
|
||||||
MenuConvert.DropDownItems.AddRange(new ToolStripItem[] { MenuConvertEquation, MenuConvertSlopeField });
|
MenuConvert.DropDownItems.AddRange(new ToolStripItem[] { MenuConvertEquation, MenuConvertSlopeField });
|
||||||
MenuConvert.Name = "MenuConvert";
|
MenuConvert.Name = "MenuConvert";
|
||||||
MenuConvert.Size = new Size(118, 36);
|
MenuConvert.Size = new Size(61, 22);
|
||||||
MenuConvert.Text = "Convert";
|
MenuConvert.Text = "Convert";
|
||||||
//
|
//
|
||||||
// MenuConvertEquation
|
// MenuConvertEquation
|
||||||
//
|
//
|
||||||
MenuConvertEquation.Name = "MenuConvertEquation";
|
MenuConvertEquation.Name = "MenuConvertEquation";
|
||||||
MenuConvertEquation.Size = new Size(297, 44);
|
MenuConvertEquation.Size = new Size(146, 22);
|
||||||
MenuConvertEquation.Text = "To Equation";
|
MenuConvertEquation.Text = "To Equation";
|
||||||
//
|
//
|
||||||
// MenuConvertSlopeField
|
// MenuConvertSlopeField
|
||||||
//
|
//
|
||||||
MenuConvertSlopeField.Name = "MenuConvertSlopeField";
|
MenuConvertSlopeField.Name = "MenuConvertSlopeField";
|
||||||
MenuConvertSlopeField.Size = new Size(297, 44);
|
MenuConvertSlopeField.Size = new Size(146, 22);
|
||||||
MenuConvertSlopeField.Text = "To Slope Field";
|
MenuConvertSlopeField.Text = "To Slope Field";
|
||||||
//
|
//
|
||||||
// MenuMisc
|
// MenuMisc
|
||||||
//
|
//
|
||||||
MenuMisc.DropDownItems.AddRange(new ToolStripItem[] { MenuMiscCaches, MiscMenuPreload });
|
MenuMisc.DropDownItems.AddRange(new ToolStripItem[] { MenuMiscCaches, MiscMenuPreload });
|
||||||
MenuMisc.Name = "MenuMisc";
|
MenuMisc.Name = "MenuMisc";
|
||||||
MenuMisc.Size = new Size(83, 36);
|
MenuMisc.Size = new Size(44, 22);
|
||||||
MenuMisc.Text = "Misc";
|
MenuMisc.Text = "Misc";
|
||||||
//
|
//
|
||||||
// MenuMiscCaches
|
// MenuMiscCaches
|
||||||
//
|
//
|
||||||
MenuMiscCaches.Name = "MenuMiscCaches";
|
MenuMiscCaches.Name = "MenuMiscCaches";
|
||||||
MenuMiscCaches.Size = new Size(299, 44);
|
MenuMiscCaches.Size = new Size(150, 22);
|
||||||
MenuMiscCaches.Text = "View Caches";
|
MenuMiscCaches.Text = "View Caches";
|
||||||
MenuMiscCaches.Click += MenuMiscCaches_Click;
|
MenuMiscCaches.Click += MenuMiscCaches_Click;
|
||||||
//
|
//
|
||||||
// MiscMenuPreload
|
// MiscMenuPreload
|
||||||
//
|
//
|
||||||
MiscMenuPreload.Name = "MiscMenuPreload";
|
MiscMenuPreload.Name = "MiscMenuPreload";
|
||||||
MiscMenuPreload.Size = new Size(299, 44);
|
MiscMenuPreload.Size = new Size(150, 22);
|
||||||
MiscMenuPreload.Text = "Preload Cache";
|
MiscMenuPreload.Text = "Preload Cache";
|
||||||
MiscMenuPreload.Click += MiscMenuPreload_Click;
|
MiscMenuPreload.Click += MiscMenuPreload_Click;
|
||||||
//
|
//
|
||||||
|
// UpdaterPopup
|
||||||
|
//
|
||||||
|
UpdaterPopup.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
|
UpdaterPopup.BackColor = SystemColors.HighlightText;
|
||||||
|
UpdaterPopup.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
UpdaterPopup.Controls.Add(UpdaterPopupDownloadButton);
|
||||||
|
UpdaterPopup.Controls.Add(UpdaterPopupCloseButton);
|
||||||
|
UpdaterPopup.Controls.Add(UpdaterPopupMessage);
|
||||||
|
UpdaterPopup.Location = new Point(520, 371);
|
||||||
|
UpdaterPopup.Name = "UpdaterPopup";
|
||||||
|
UpdaterPopup.Size = new Size(261, 55);
|
||||||
|
UpdaterPopup.TabIndex = 2;
|
||||||
|
UpdaterPopup.Visible = false;
|
||||||
|
//
|
||||||
|
// UpdaterPopupDownloadButton
|
||||||
|
//
|
||||||
|
UpdaterPopupDownloadButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
|
UpdaterPopupDownloadButton.Location = new Point(181, 27);
|
||||||
|
UpdaterPopupDownloadButton.Name = "UpdaterPopupDownloadButton";
|
||||||
|
UpdaterPopupDownloadButton.Size = new Size(75, 23);
|
||||||
|
UpdaterPopupDownloadButton.TabIndex = 2;
|
||||||
|
UpdaterPopupDownloadButton.Text = "Visit";
|
||||||
|
UpdaterPopupDownloadButton.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// UpdaterPopupCloseButton
|
||||||
|
//
|
||||||
|
UpdaterPopupCloseButton.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
|
UpdaterPopupCloseButton.Location = new Point(234, 1);
|
||||||
|
UpdaterPopupCloseButton.Margin = new Padding(1);
|
||||||
|
UpdaterPopupCloseButton.Name = "UpdaterPopupCloseButton";
|
||||||
|
UpdaterPopupCloseButton.Size = new Size(24, 24);
|
||||||
|
UpdaterPopupCloseButton.TabIndex = 1;
|
||||||
|
UpdaterPopupCloseButton.Text = "X";
|
||||||
|
UpdaterPopupCloseButton.UseVisualStyleBackColor = true;
|
||||||
|
UpdaterPopupCloseButton.Click += UpdaterPopupCloseButton_Click;
|
||||||
|
//
|
||||||
|
// UpdaterPopupMessage
|
||||||
|
//
|
||||||
|
UpdaterPopupMessage.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left;
|
||||||
|
UpdaterPopupMessage.Font = new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point, 0);
|
||||||
|
UpdaterPopupMessage.Location = new Point(3, 3);
|
||||||
|
UpdaterPopupMessage.Margin = new Padding(3);
|
||||||
|
UpdaterPopupMessage.Name = "UpdaterPopupMessage";
|
||||||
|
UpdaterPopupMessage.Size = new Size(228, 47);
|
||||||
|
UpdaterPopupMessage.TabIndex = 0;
|
||||||
|
UpdaterPopupMessage.Text = "A <type> update is available!\r\nA.B.C → E.F.G";
|
||||||
|
//
|
||||||
// GraphForm
|
// GraphForm
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(13F, 32F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(1449, 907);
|
ClientSize = new Size(780, 425);
|
||||||
|
Controls.Add(UpdaterPopup);
|
||||||
Controls.Add(ResetViewportButton);
|
Controls.Add(ResetViewportButton);
|
||||||
Controls.Add(GraphMenu);
|
Controls.Add(GraphMenu);
|
||||||
MainMenuStrip = GraphMenu;
|
MainMenuStrip = GraphMenu;
|
||||||
|
Margin = new Padding(2, 1, 2, 1);
|
||||||
Name = "GraphForm";
|
Name = "GraphForm";
|
||||||
Text = "GraphFormBase";
|
Text = "GraphFormBase";
|
||||||
GraphMenu.ResumeLayout(false);
|
GraphMenu.ResumeLayout(false);
|
||||||
GraphMenu.PerformLayout();
|
GraphMenu.PerformLayout();
|
||||||
|
UpdaterPopup.ResumeLayout(false);
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
PerformLayout();
|
PerformLayout();
|
||||||
}
|
}
|
||||||
@ -233,5 +290,9 @@ namespace Graphing.Forms
|
|||||||
private ToolStripMenuItem MenuElementsRemove;
|
private ToolStripMenuItem MenuElementsRemove;
|
||||||
private ToolStripMenuItem MenuOperationsTranslate;
|
private ToolStripMenuItem MenuOperationsTranslate;
|
||||||
private ToolStripMenuItem MenuConvertSlopeField;
|
private ToolStripMenuItem MenuConvertSlopeField;
|
||||||
|
private Panel UpdaterPopup;
|
||||||
|
private Label UpdaterPopupMessage;
|
||||||
|
private Button UpdaterPopupCloseButton;
|
||||||
|
private Button UpdaterPopupDownloadButton;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,8 +1,7 @@
|
|||||||
using Graphing.Abstract;
|
using Graphing.Abstract;
|
||||||
using Graphing.Helpers;
|
|
||||||
using Graphing.Parts;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Drawing2D;
|
using System.Drawing.Drawing2D;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -18,11 +17,14 @@ public partial class GraphForm : Form
|
|||||||
{
|
{
|
||||||
public static readonly Color BackgroundColor = Color.White;
|
public static readonly Color BackgroundColor = Color.White;
|
||||||
public static readonly Color MainAxisColor = Color.Black;
|
public static readonly Color MainAxisColor = Color.Black;
|
||||||
public static readonly Color SemiAxisColor = Color.FromArgb(unchecked((int)0xFF_999999));
|
public static readonly Color SemiAxisColor = Color.FromArgb(unchecked((int)0xFF_999999)); // Grayish
|
||||||
public static readonly Color QuarterAxisColor = Color.FromArgb(unchecked((int)0xFF_E0E0E0));
|
public static readonly Color QuarterAxisColor = Color.FromArgb(unchecked((int)0xFF_E0E0E0)); // Lighter grayish
|
||||||
public static readonly Color UnitsTextColor = Color.Black;
|
public static readonly Color UnitsTextColor = Color.Black;
|
||||||
public static readonly Color ZoomBoxColor = Color.Black;
|
public static readonly Color ZoomBoxColor = Color.Black;
|
||||||
|
|
||||||
|
public static readonly Color MajorUpdateColor = Color.FromArgb(unchecked((int)0xFF_F74434)); // Red
|
||||||
|
public static readonly Color MinorUpdateColor = Color.FromArgb(unchecked((int)0xFF_FCA103)); // Orange
|
||||||
|
|
||||||
public Float2 ScreenCenter { get; set; }
|
public Float2 ScreenCenter { get; set; }
|
||||||
public Float2 Dpi { get; private set; }
|
public Float2 Dpi { get; private set; }
|
||||||
|
|
||||||
@ -630,6 +632,10 @@ public partial class GraphForm : Form
|
|||||||
foreach (Graphable able in Graphables) able.Preload(xRange, yRange, step);
|
foreach (Graphable able in Graphables) able.Preload(xRange, yRange, step);
|
||||||
Invalidate(false);
|
Invalidate(false);
|
||||||
}
|
}
|
||||||
|
private void UpdaterPopupCloseButton_Click(object? sender, EventArgs e)
|
||||||
|
{
|
||||||
|
UpdaterPopup.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
private void ElementsOperationsTranslate_Click(Graphable ableRaw, ITranslatable ableTrans)
|
private void ElementsOperationsTranslate_Click(Graphable ableRaw, ITranslatable ableTrans)
|
||||||
{
|
{
|
||||||
@ -646,7 +652,7 @@ public partial class GraphForm : Form
|
|||||||
shifter.Show();
|
shifter.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async void RunUpdateChecker()
|
private async void RunUpdateChecker()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -669,56 +675,39 @@ public partial class GraphForm : Form
|
|||||||
|
|
||||||
if (newVersion > curVersion)
|
if (newVersion > curVersion)
|
||||||
{
|
{
|
||||||
// Updates are required.
|
string type;
|
||||||
DialogResult button = MessageBox.Show(
|
|
||||||
$"A new update is available!\n{curVersion} -> {newVersion}\nWould you like to download the update?",
|
|
||||||
"Graphing Calculator Update", MessageBoxButtons.YesNo);
|
|
||||||
|
|
||||||
if (button == DialogResult.No) return;
|
if (newVersion.Major > curVersion.Major || // x.0.0
|
||||||
|
newVersion.Minor > curVersion.Minor) // 0.x.0
|
||||||
string? project = UpdaterHelper.GetProjectPath();
|
|
||||||
if (project is null)
|
|
||||||
{
|
{
|
||||||
MessageBox.Show("Cannot find project root. You'll likely have to update manually.",
|
type = "major";
|
||||||
"Error running automatic updates.", MessageBoxButtons.OK,
|
UpdaterPopupMessage.ForeColor = MajorUpdateColor;
|
||||||
MessageBoxIcon.Error);
|
}
|
||||||
return;
|
else // 0.0.x
|
||||||
|
{
|
||||||
|
type = "minor";
|
||||||
|
UpdaterPopupMessage.ForeColor = MinorUpdateColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await UpdaterHelper.UsingNugetPackage(project))
|
UpdaterPopupMessage.Text = $"A {type} update is available!\n{curVersion} → {newVersion}";
|
||||||
|
UpdaterPopup.Visible = true;
|
||||||
|
|
||||||
|
string url = latest["html_url"]!.GetValue<string>();
|
||||||
|
Console.WriteLine($"An update is available! {curVersion} -> {newVersion}\n{url}");
|
||||||
|
UpdaterPopupDownloadButton.Click += (o, e) =>
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Attempting to update via the NuGet Package Manager.");
|
ProcessStartInfo website = new()
|
||||||
bool status = await UpdaterHelper.UpdateProjectByNuget(latest["tag_name"]!.GetValue<string>(), project);
|
|
||||||
if (!status)
|
|
||||||
{
|
{
|
||||||
MessageBox.Show("Failed to update with the NuGet Package Manager. " +
|
FileName = url,
|
||||||
"You'll likely have to update manually.",
|
UseShellExecute = true
|
||||||
"Error running automatic updates.", MessageBoxButtons.OK,
|
};
|
||||||
MessageBoxIcon.Error);
|
Process.Start(website);
|
||||||
return;
|
};
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Attempting to update via a GitHub asset download.");
|
Console.WriteLine("Up-to-date.");
|
||||||
bool status = await UpdaterHelper.UpdateProjectByGitHub(latest["tag_name"]!.GetValue<string>(), project);
|
UpdaterPopup.Dispose();
|
||||||
if (status)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Update ready. Restart the project to complete the update.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBox.Show("Failed to update with an automatic download. " +
|
|
||||||
"You'll likely have to update manually.",
|
|
||||||
"Error running automatic updates.", MessageBoxButtons.OK,
|
|
||||||
MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Console.WriteLine($"Up-to-date.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
@ -98,6 +98,17 @@ public partial class SetZoomForm : Form
|
|||||||
{
|
{
|
||||||
Float2 min = refForm.MinVisibleGraph, max = refForm.MaxVisibleGraph;
|
Float2 min = refForm.MinVisibleGraph, max = refForm.MaxVisibleGraph;
|
||||||
|
|
||||||
|
if (minX > max.x)
|
||||||
|
{
|
||||||
|
MaxBoxX.Text = MinBoxX.Text;
|
||||||
|
MaxBoxX_Finish(sender, e);
|
||||||
|
minX = max.x;
|
||||||
|
|
||||||
|
// Redefine bounds.
|
||||||
|
min = refForm.MinVisibleGraph;
|
||||||
|
max = refForm.MaxVisibleGraph;
|
||||||
|
}
|
||||||
|
|
||||||
double newCenterX = (minX + max.x) / 2,
|
double newCenterX = (minX + max.x) / 2,
|
||||||
zoomFactorX = (max.x - minX) / (max.x - min.x);
|
zoomFactorX = (max.x - minX) / (max.x - min.x);
|
||||||
|
|
||||||
@ -113,6 +124,17 @@ public partial class SetZoomForm : Form
|
|||||||
{
|
{
|
||||||
Float2 min = refForm.MinVisibleGraph, max = refForm.MaxVisibleGraph;
|
Float2 min = refForm.MinVisibleGraph, max = refForm.MaxVisibleGraph;
|
||||||
|
|
||||||
|
if (maxX < min.x)
|
||||||
|
{
|
||||||
|
MinBoxX.Text = MaxBoxX.Text;
|
||||||
|
MinBoxX_Finish(sender, e);
|
||||||
|
maxX = min.x;
|
||||||
|
|
||||||
|
// Redefine bounds.
|
||||||
|
min = refForm.MinVisibleGraph;
|
||||||
|
max = refForm.MaxVisibleGraph;
|
||||||
|
}
|
||||||
|
|
||||||
double newCenterX = (min.x + maxX) / 2,
|
double newCenterX = (min.x + maxX) / 2,
|
||||||
zoomFactorX = (maxX - min.x) / (max.x - min.x);
|
zoomFactorX = (maxX - min.x) / (max.x - min.x);
|
||||||
|
|
||||||
@ -128,6 +150,17 @@ public partial class SetZoomForm : Form
|
|||||||
{
|
{
|
||||||
Float2 min = refForm.MinVisibleGraph, max = refForm.MaxVisibleGraph;
|
Float2 min = refForm.MinVisibleGraph, max = refForm.MaxVisibleGraph;
|
||||||
|
|
||||||
|
if (minY > max.y)
|
||||||
|
{
|
||||||
|
MaxBoxY.Text = MinBoxY.Text;
|
||||||
|
MaxBoxY_Finish(sender, e);
|
||||||
|
minY = max.y;
|
||||||
|
|
||||||
|
// Redefine bounds.
|
||||||
|
min = refForm.MinVisibleGraph;
|
||||||
|
max = refForm.MaxVisibleGraph;
|
||||||
|
}
|
||||||
|
|
||||||
double newCenterY = -(minY + max.y) / 2, // Keeping it positive flips it for some reason ???
|
double newCenterY = -(minY + max.y) / 2, // Keeping it positive flips it for some reason ???
|
||||||
zoomFactorY = (max.y - minY) / (max.y - min.y);
|
zoomFactorY = (max.y - minY) / (max.y - min.y);
|
||||||
|
|
||||||
@ -143,6 +176,17 @@ public partial class SetZoomForm : Form
|
|||||||
{
|
{
|
||||||
Float2 min = refForm.MinVisibleGraph, max = refForm.MaxVisibleGraph;
|
Float2 min = refForm.MinVisibleGraph, max = refForm.MaxVisibleGraph;
|
||||||
|
|
||||||
|
if (maxY < min.y)
|
||||||
|
{
|
||||||
|
MinBoxY.Text = MaxBoxY.Text;
|
||||||
|
MinBoxY_Finish(sender, e);
|
||||||
|
maxY = min.y;
|
||||||
|
|
||||||
|
// Redefine bounds.
|
||||||
|
min = refForm.MinVisibleGraph;
|
||||||
|
max = refForm.MaxVisibleGraph;
|
||||||
|
}
|
||||||
|
|
||||||
double newCenterY = -(min.y + maxY) / 2, // Keeping it positive flips it for some reason ???
|
double newCenterY = -(min.y + maxY) / 2, // Keeping it positive flips it for some reason ???
|
||||||
zoomFactorY = (maxY - min.y) / (max.y - min.y);
|
zoomFactorY = (maxY - min.y) / (max.y - min.y);
|
||||||
|
|
||||||
|
|||||||
@ -1,83 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Graphing.Helpers;
|
|
||||||
|
|
||||||
internal static class UpdaterHelper
|
|
||||||
{
|
|
||||||
public static async Task<bool> UsingNugetPackage(string? project = null)
|
|
||||||
{
|
|
||||||
project ??= GetProjectPath();
|
|
||||||
|
|
||||||
Process packageListProc = new();
|
|
||||||
packageListProc.StartInfo.FileName = "dotnet";
|
|
||||||
packageListProc.StartInfo.Arguments = "list package";
|
|
||||||
packageListProc.StartInfo.WorkingDirectory = Path.GetDirectoryName(project);
|
|
||||||
|
|
||||||
packageListProc.StartInfo.UseShellExecute = false;
|
|
||||||
packageListProc.StartInfo.RedirectStandardOutput = true;
|
|
||||||
|
|
||||||
StringBuilder contentBuilder = new();
|
|
||||||
packageListProc.OutputDataReceived += (o, e) => contentBuilder.AppendLine(e.Data);
|
|
||||||
|
|
||||||
packageListProc.Start();
|
|
||||||
packageListProc.BeginOutputReadLine();
|
|
||||||
await packageListProc.WaitForExitAsync();
|
|
||||||
|
|
||||||
string content = contentBuilder.ToString();
|
|
||||||
return content.Contains($"ThatOneNerd.Graphing");
|
|
||||||
}
|
|
||||||
public static async Task<bool> UpdateProjectByNuget(string version, string? project = null)
|
|
||||||
{
|
|
||||||
project ??= GetProjectPath();
|
|
||||||
|
|
||||||
Process updateProc = new();
|
|
||||||
updateProc.StartInfo.FileName = "dotnet";
|
|
||||||
updateProc.StartInfo.Arguments = $"add package ThatOneNerd.Graphing --version {version}";
|
|
||||||
updateProc.StartInfo.WorkingDirectory = Path.GetDirectoryName(project);
|
|
||||||
|
|
||||||
updateProc.StartInfo.UseShellExecute = false;
|
|
||||||
updateProc.StartInfo.RedirectStandardError = true;
|
|
||||||
|
|
||||||
StringBuilder errorBuilder = new();
|
|
||||||
updateProc.ErrorDataReceived += (o, e) => errorBuilder.AppendLine(e.Data);
|
|
||||||
|
|
||||||
updateProc.Start();
|
|
||||||
updateProc.BeginErrorReadLine();
|
|
||||||
await updateProc.WaitForExitAsync();
|
|
||||||
|
|
||||||
// Could be shrunk but it makes it less clear. If there's any data written to
|
|
||||||
// the error stream, it did not succeed.
|
|
||||||
if (errorBuilder.Length > 0) return false; // Error.
|
|
||||||
else return true; // Success.
|
|
||||||
}
|
|
||||||
public static async Task<bool> UpdateProjectByGitHub(string version, string? project = null)
|
|
||||||
{
|
|
||||||
// TODO
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string? GetProjectPath()
|
|
||||||
{
|
|
||||||
Assembly? entryAsm = Assembly.GetEntryAssembly();
|
|
||||||
if (entryAsm is null) return null;
|
|
||||||
|
|
||||||
string? directory = Path.GetDirectoryName(entryAsm.Location);
|
|
||||||
while (directory is not null)
|
|
||||||
{
|
|
||||||
string[] files = Directory.GetFiles(directory);
|
|
||||||
string? project = files.FirstOrDefault(x => x.EndsWith(".csproj") ||
|
|
||||||
x.EndsWith(".sln"));
|
|
||||||
if (project is not null) return project;
|
|
||||||
|
|
||||||
directory = Path.GetDirectoryName(directory);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user