Input options now work. I think I can call it done for the zooming system.
This commit is contained in:
parent
ed4ce2bbeb
commit
aba32f8b58
@ -23,7 +23,7 @@ public partial class GraphForm : Form
|
||||
public static readonly Color UnitsTextColor = Color.Black;
|
||||
public static readonly Color ZoomBoxColor = Color.Black;
|
||||
|
||||
public Float2 ScreenCenter { get; private set; }
|
||||
public Float2 ScreenCenter { get; set; }
|
||||
public Float2 Dpi { get; private set; }
|
||||
|
||||
public float DpiFloat { get; private set; }
|
||||
|
||||
@ -16,6 +16,28 @@ public partial class SetZoomForm : Form
|
||||
|
||||
refForm.Paint += (o, e) => RedeclareValues();
|
||||
RedeclareValues();
|
||||
|
||||
MinBoxX.Leave += MinBoxX_Finish;
|
||||
MinBoxX.KeyDown += (o, e) =>
|
||||
{
|
||||
if (e.KeyCode == Keys.Enter) MinBoxX_Finish(o, e);
|
||||
};
|
||||
MaxBoxX.Leave += MaxBoxX_Finish;
|
||||
MaxBoxX.KeyDown += (o, e) =>
|
||||
{
|
||||
if (e.KeyCode == Keys.Enter) MaxBoxX_Finish(o, e);
|
||||
};
|
||||
|
||||
MinBoxY.Leave += MinBoxY_Finish;
|
||||
MinBoxY.KeyDown += (o, e) =>
|
||||
{
|
||||
if (e.KeyCode == Keys.Enter) MinBoxY_Finish(o, e);
|
||||
};
|
||||
MaxBoxY.Leave += MaxBoxY_Finish;
|
||||
MaxBoxY.KeyDown += (o, e) =>
|
||||
{
|
||||
if (e.KeyCode == Keys.Enter) MaxBoxY_Finish(o, e);
|
||||
};
|
||||
}
|
||||
|
||||
private void EnableBoxSelect_Click(object? sender, EventArgs e)
|
||||
@ -64,8 +86,74 @@ public partial class SetZoomForm : Form
|
||||
{
|
||||
refForm.ResetAllViewport();
|
||||
}
|
||||
private void ViewportLock_CheckedChanged(object? sender, EventArgs e)
|
||||
{
|
||||
refForm.ViewportLocked = ViewportLock.Checked;
|
||||
RedeclareValues();
|
||||
}
|
||||
|
||||
private void RedeclareValues()
|
||||
private void MinBoxX_Finish(object? sender, EventArgs e)
|
||||
{
|
||||
if (double.TryParse(MinBoxX.Text, out double minX))
|
||||
{
|
||||
Float2 min = refForm.MinVisibleGraph, max = refForm.MaxVisibleGraph;
|
||||
|
||||
double newCenterX = (minX + max.x) / 2,
|
||||
zoomFactorX = (max.x - minX) / (max.x - min.x);
|
||||
|
||||
refForm.ScreenCenter = new(newCenterX, refForm.ScreenCenter.y);
|
||||
refForm.ZoomLevel = new(refForm.ZoomLevel.x * zoomFactorX, refForm.ZoomLevel.y);
|
||||
}
|
||||
|
||||
refForm.Invalidate(false);
|
||||
}
|
||||
private void MaxBoxX_Finish(object? sender, EventArgs e)
|
||||
{
|
||||
if (double.TryParse(MaxBoxX.Text, out double maxX))
|
||||
{
|
||||
Float2 min = refForm.MinVisibleGraph, max = refForm.MaxVisibleGraph;
|
||||
|
||||
double newCenterX = (min.x + maxX) / 2,
|
||||
zoomFactorX = (maxX - min.x) / (max.x - min.x);
|
||||
|
||||
refForm.ScreenCenter = new(newCenterX, refForm.ScreenCenter.y);
|
||||
refForm.ZoomLevel = new(refForm.ZoomLevel.x * zoomFactorX, refForm.ZoomLevel.y);
|
||||
}
|
||||
|
||||
refForm.Invalidate(false);
|
||||
}
|
||||
private void MinBoxY_Finish(object? sender, EventArgs e)
|
||||
{
|
||||
if (double.TryParse(MinBoxY.Text, out double minY))
|
||||
{
|
||||
Float2 min = refForm.MinVisibleGraph, max = refForm.MaxVisibleGraph;
|
||||
|
||||
double newCenterY = -(minY + max.y) / 2, // Keeping it positive flips it for some reason ???
|
||||
zoomFactorY = (max.y - minY) / (max.y - min.y);
|
||||
|
||||
refForm.ScreenCenter = new(refForm.ScreenCenter.x, newCenterY);
|
||||
refForm.ZoomLevel = new(refForm.ZoomLevel.x, refForm.ZoomLevel.y * zoomFactorY);
|
||||
}
|
||||
|
||||
refForm.Invalidate(false);
|
||||
}
|
||||
private void MaxBoxY_Finish(object? sender, EventArgs e)
|
||||
{
|
||||
if (double.TryParse(MaxBoxY.Text, out double maxY))
|
||||
{
|
||||
Float2 min = refForm.MinVisibleGraph, max = refForm.MaxVisibleGraph;
|
||||
|
||||
double newCenterY = -(min.y + maxY) / 2, // Keeping it positive flips it for some reason ???
|
||||
zoomFactorY = (maxY - min.y) / (max.y - min.y);
|
||||
|
||||
refForm.ScreenCenter = new(refForm.ScreenCenter.x, newCenterY);
|
||||
refForm.ZoomLevel = new(refForm.ZoomLevel.x, refForm.ZoomLevel.y * zoomFactorY);
|
||||
}
|
||||
|
||||
refForm.Invalidate(false);
|
||||
}
|
||||
|
||||
public void RedeclareValues()
|
||||
{
|
||||
bool enabled = !refForm.ViewportLocked;
|
||||
|
||||
@ -92,10 +180,4 @@ public partial class SetZoomForm : Form
|
||||
{
|
||||
if (boxSelectEnabled) EnableBoxSelect_Click(null, new());
|
||||
}
|
||||
|
||||
private void ViewportLock_CheckedChanged(object? sender, EventArgs e)
|
||||
{
|
||||
refForm.ViewportLocked = ViewportLock.Checked;
|
||||
RedeclareValues();
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user