Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
using GerberLibrary;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace GerberCombinerBuilder
{
public partial class InstanceDialog :Form
{
GerberPanelize TargetInstance;
public InstanceDialog()
{
InitializeComponent();
panel1.Enabled = false;
}
private bool Initializing = true;
public void UpdateBoxes(GerberPanelize newTarget)
{
TargetInstance = newTarget;
if (TargetInstance == null) { panel1.Enabled = false; return; } else { panel1.Enabled = true; }
newTarget.SuspendRedraw = true;
bool hasSelection = TargetInstance.SelectedInstance != null;
tableLayoutPanel1.Enabled = hasSelection;
Up.Enabled = hasSelection;
Down.Enabled = hasSelection;
LeftButton.Enabled = hasSelection;
RightButton.Enabled = hasSelection;
Clock.Enabled = hasSelection;
AClock.Enabled = hasSelection;
// Bigger/Smaller depended on BreakTab anyway, but global disable handles them.
// But now we need to be careful.
// Bigger/Smaller are disabled by default logic below if not BreakTab.
if (!hasSelection)
{
newTarget.SuspendRedraw = false;
return;
}
double x = TargetInstance.SelectedInstance.Center.X;
double y = TargetInstance.SelectedInstance.Center.Y;
double r = TargetInstance.SelectedInstance.Angle;
double rad = 0;
radiusbox.Enabled = false;
Bigger.Enabled = false;
Smaller.Enabled = false;
if (TargetInstance.SelectedInstance.GetType() == typeof(BreakTab))
{
BreakTab BT = TargetInstance.SelectedInstance as BreakTab;
NameLabel.Text = "Break tab";
Bigger.Enabled = true;
Smaller.Enabled = true;
rad = BT.Radius;
radiusbox.Enabled = true;
}
if (TargetInstance.SelectedInstance.GetType() == typeof(GerberInstance))
{
GerberInstance GI = TargetInstance.SelectedInstance as GerberInstance;
NameLabel.Text = Path.GetFileName(Path.GetDirectoryName( GI.GerberPath));
}
xbox.Value = (decimal)x;
ybox.Value = (decimal)y;
rbox.Value = (decimal)r;
radiusbox.Value = (decimal) rad;
Initializing = false;
newTarget.SuspendRedraw = false;
}
private void ZoomInButton_Click(object sender, EventArgs e)
{
if (TargetInstance != null) TargetInstance.ZoomIn();
}
private void ZoomOutButton_Click(object sender, EventArgs e)
{
if (TargetInstance != null) TargetInstance.ZoomOut();
}
void UpdateInstance()
{
if (Initializing) return;
if (TargetInstance == null) return;
if (TargetInstance.SelectedInstance == null) return;
TargetInstance.SelectedInstance.Center.X = (float)xbox.Value;
TargetInstance.SelectedInstance.Center.Y = (float)ybox.Value;
TargetInstance.SelectedInstance.Angle = (float)rbox.Value;
if (TargetInstance.SelectedInstance.GetType() == typeof(BreakTab))
{
BreakTab BT = TargetInstance.SelectedInstance as BreakTab;
BT.Radius = (float)radiusbox.Value;
}
else if (TargetInstance.SelectedInstance.GetType() == typeof(GerberInstance))
{
GerberInstance GI = TargetInstance.SelectedInstance as GerberInstance;
GI.RebuildTransformed(TargetInstance.ThePanel.GerberOutlines[GI.GerberPath], TargetInstance.ThePanel.TheSet.ExtraTabDrillDistance);
}
TargetInstance.UpdateHoverControls();
TargetInstance.Redraw(true);
}
private void Up_Click(object sender, EventArgs e)
{
ybox.Value += 1;
UpdateInstance();
}
private void Left_Click(object sender, EventArgs e)
{
xbox.Value -= 1;
UpdateInstance();
}
private void Right_Click(object sender, EventArgs e)
{
xbox.Value += 1;
UpdateInstance();
}
private void Down_Click(object sender, EventArgs e)
{
ybox.Value -= 1;
UpdateInstance();
}
private void AClock_Click(object sender, EventArgs e)
{
decimal newval = rbox.Value - 90;
if (newval < -180) newval += 360;
rbox.Value = newval;
UpdateInstance();
}
private void Clock_Click(object sender, EventArgs e)
{
decimal newval = rbox.Value + 90;
if (newval > 180) newval -= 360;
rbox.Value = newval;
UpdateInstance();
}
private void xbox_ValueChanged(object sender, EventArgs e)
{
UpdateInstance();
}
private void ybox_ValueChanged(object sender, EventArgs e)
{
UpdateInstance();
}
private void rbox_ValueChanged(object sender, EventArgs e)
{
UpdateInstance();
}
private void Bigger_Click(object sender, EventArgs e)
{
radiusbox.Value += 1;
UpdateInstance();
}
private void Smaller_Click(object sender, EventArgs e)
{
radiusbox.Value -= 1;
UpdateInstance();
}
private void radiusbox_ValueChanged(object sender, EventArgs e)
{
UpdateInstance();
}
private void flowLayoutPanel1_Paint(object sender, PaintEventArgs e)
{
}
private void tableLayoutPanel3_Paint(object sender, PaintEventArgs e)
{
}
private void Up_Click_1(object sender, EventArgs e)
{
Up_Click(sender, e);
}
private void Down_Click_1(object sender, EventArgs e)
{
Down_Click(sender, e);
}
private void Clock_Click_1(object sender, EventArgs e)
{
Clock_Click(sender, e);
}
private void AClock_Click_1(object sender, EventArgs e)
{
AClock_Click(sender, e);
}
private void Left_Click_1(object sender, EventArgs e)
{
Left_Click(sender, e);
}
private void Right_Click_1(object sender, EventArgs e)
{
Right_Click(sender, e);
}
private void Bigger_Click_1(object sender, EventArgs e)
{
Bigger_Click(sender, e);
}
private void Smaller_Click_1(object sender, EventArgs e)
{
Smaller_Click(sender, e);
}
}
}
5203ce801This file is pinned to the selected release. Download the original to open it in your design tool.