OnePerMeter : Alignment

This commit is contained in:
Milan Hanajik
2023-11-09 17:44:00 +01:00
parent c4c86b36d2
commit 8318ed33e1
6 changed files with 320 additions and 187 deletions
@@ -313,7 +313,15 @@ namespace Results.Output.Printers.OnePerMeter
} }
SizeF size = table.Measure(e); SizeF size = table.Measure(e);
float tableLeft = (float)leftMargin + ((float)printWidth - size.Width) / 2; float sideMargin = (printWidth - size.Width) / 2;
float tableLeft;
switch (cfg.Alignment)
{
case Alignment.Left: tableLeft = leftMargin; break;
default:
case Alignment.Center: tableLeft = leftMargin + sideMargin; break;
case Alignment.Right: tableLeft = leftMargin + 2 * sideMargin; break;
}
belowTop = table.Draw(e, tableLeft, tableTop); belowTop = table.Draw(e, tableLeft, tableTop);
if (pageNr == nrPages) if (pageNr == nrPages)
@@ -34,6 +34,7 @@ namespace Results.Output.Printers.OnePerMeter
public string[] CommonItems2; public string[] CommonItems2;
public string[] CommonItems3; public string[] CommonItems3;
public Common.TableForm Form; public Common.TableForm Form;
public Common.Alignment Alignment;
public string[] TestItems; public string[] TestItems;
public string[] TestItems2; public string[] TestItems2;
public int BelowW0Pct; public int BelowW0Pct;
@@ -105,6 +105,7 @@ namespace TBF.Rig.Output.Printers.OnePerMeter
printerCfg.CommonItems2 = newCfg.CommonItems2; printerCfg.CommonItems2 = newCfg.CommonItems2;
printerCfg.CommonItems3 = newCfg.CommonItems3; printerCfg.CommonItems3 = newCfg.CommonItems3;
printerCfg.Form = newCfg.Form; printerCfg.Form = newCfg.Form;
printerCfg.Alignment = newCfg.Alignment;
printerCfg.SelectedItems = newCfg.SelectedItems; printerCfg.SelectedItems = newCfg.SelectedItems;
printerCfg.SelectedItems2 = newCfg.SelectedItems2; printerCfg.SelectedItems2 = newCfg.SelectedItems2;
printerCfg.BelowW0Pct = newCfg.BelowW0Pct; printerCfg.BelowW0Pct = newCfg.BelowW0Pct;
@@ -227,6 +228,7 @@ namespace TBF.Rig.Output.Printers.OnePerMeter
CommonItems2 = printerCfg.CommonItems2, CommonItems2 = printerCfg.CommonItems2,
CommonItems3 = printerCfg.CommonItems3, CommonItems3 = printerCfg.CommonItems3,
Form = printerCfg.Form, Form = printerCfg.Form,
Alignment = printerCfg.Alignment,
TestItems = printerCfg.SelectedItems, TestItems = printerCfg.SelectedItems,
TestItems2 = printerCfg.SelectedItems2, TestItems2 = printerCfg.SelectedItems2,
BelowW0Pct = printerCfg.BelowW0Pct, BelowW0Pct = printerCfg.BelowW0Pct,
@@ -50,6 +50,7 @@ namespace TBF.Rig.Output.Printers.OnePerMeter
public string[] CommonItems3; public string[] CommonItems3;
public TableForm Form; public TableForm Form;
public Alignment Alignment;
public string[] SelectedItems; public string[] SelectedItems;
public string[] SelectedItems2; public string[] SelectedItems2;
File diff suppressed because it is too large Load Diff
@@ -59,7 +59,12 @@ namespace TBF.Rig.Output.Printers.OnePerMeter
for (TableForm f = 0; f < TableForm.Count; f++) for (TableForm f = 0; f < TableForm.Count; f++)
{ {
table1FormComboBox.Items.Add(f.ToString()); tableFormComboBox.Items.Add(f.ToString());
}
for (Alignment a = 0; a < Alignment.Count; a++)
{
tableAlignmentComboBox.Items.Add(a.ToDescription());
} }
for (BarcodeType bt = BarcodeType.None; bt < BarcodeType.Count; bt++) for (BarcodeType bt = BarcodeType.None; bt < BarcodeType.Count; bt++)
@@ -158,7 +163,8 @@ namespace TBF.Rig.Output.Printers.OnePerMeter
imageNameTextBox.Text = config.ImgName; imageNameTextBox.Text = config.ImgName;
docNameTextBox.Text = config.DocName; docNameTextBox.Text = config.DocName;
table1FormComboBox.Text = config.Form.ToString(); tableFormComboBox.Text = config.Form.ToString();
tableAlignmentComboBox.Text = config.Alignment.ToDescription();
barcodeTypeComboBox.Text = config.BarcodeType.ToString(); barcodeTypeComboBox.Text = config.BarcodeType.ToString();
barcodeLeftTextBox.Text = config.BarcodeLeft.ToString(); barcodeLeftTextBox.Text = config.BarcodeLeft.ToString();
@@ -203,7 +209,8 @@ namespace TBF.Rig.Output.Printers.OnePerMeter
commonItems1Button.Enabled = true; commonItems1Button.Enabled = true;
commonItems2Button.Enabled = true; commonItems2Button.Enabled = true;
commonItems3Button.Enabled = true; commonItems3Button.Enabled = true;
table1FormComboBox.Enabled = true; tableFormComboBox.Enabled = true;
tableAlignmentComboBox.Enabled = true;
testItemsButton.Enabled = true; testItemsButton.Enabled = true;
testItems2Button.Enabled = true; testItems2Button.Enabled = true;
belowW0TextBox.Enabled = true; belowW0TextBox.Enabled = true;
@@ -376,12 +383,18 @@ namespace TBF.Rig.Output.Printers.OnePerMeter
flags |= CfgUpdateFlags.Error; flags |= CfgUpdateFlags.Error;
} }
if (!table1FormComboBox.Items.Contains(table1FormComboBox.Text)) if (!tableFormComboBox.Items.Contains(tableFormComboBox.Text))
{ {
message += Environment.NewLine + "Invalid 'Table form'"; message += Environment.NewLine + "Invalid 'Table form'";
flags |= CfgUpdateFlags.Error; flags |= CfgUpdateFlags.Error;
} }
if (!tableAlignmentComboBox.Items.Contains(tableAlignmentComboBox.Text))
{
message += Environment.NewLine + "Invalid 'Table alignmentm'";
flags |= CfgUpdateFlags.Error;
}
if (!barcodeTypeComboBox.Items.Contains(barcodeTypeComboBox.Text)) if (!barcodeTypeComboBox.Items.Contains(barcodeTypeComboBox.Text))
{ {
message += Environment.NewLine + "Invalid barcode type"; message += Environment.NewLine + "Invalid barcode type";
@@ -505,13 +518,22 @@ namespace TBF.Rig.Output.Printers.OnePerMeter
for (TableForm f = 0; f < TableForm.Count; f++) for (TableForm f = 0; f < TableForm.Count; f++)
{ {
if (f.ToString().Equals(table1FormComboBox.Text)) if (f.ToString().Equals(tableFormComboBox.Text))
{ {
config.Form = f; config.Form = f;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
} }
} }
for (Alignment a = 0; a < Alignment.Count; a++)
{
if (a.ToDescription().Equals(tableAlignmentComboBox.Text))
{
config.Alignment = a;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
}
flags |= UpdateDifferent(ref config.GraphLeft, graphLeftTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); flags |= UpdateDifferent(ref config.GraphLeft, graphLeftTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref config.GraphTop, graphTopTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); flags |= UpdateDifferent(ref config.GraphTop, graphTopTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref config.GraphWid, graphWidthTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); flags |= UpdateDifferent(ref config.GraphWid, graphWidthTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);