diff --git a/RockLabelPrinter.cs b/RockLabelPrinter.cs
index 83b292b..b53f9bb 100644
--- a/RockLabelPrinter.cs
+++ b/RockLabelPrinter.cs
@@ -183,6 +183,25 @@ private void PrintLabel( string labelContents, string labelPrinterIp )
}
}
+ ///
+ /// Prints a test label to the chosen hardware printer.
+ ///
+ public void TestPrint()
+ {
+ var text = @"CT~~CD,~CC^~CT~
+^XA~TA000~JSN^LT0^MNW^MTD^PON^PMN^LH0,0^JMA^PR4,4~SD15^JUS^LRN^CI0^XZ
+^XA
+^MMT
+^PW609
+^LL0406
+^LS0
+^FT275,210^A0N,28,28^FH\^FDTEST^FS
+^PQ1,0,1,Y^XZ
+";
+ var rockConfig = RockConfig.Load();
+ RawPrinterHelper.SendStringToPrinter( rockConfig.PrinterOverrideLocal, text );
+ }
+
///
/// Prints the via ip.
///
diff --git a/StartupPage.xaml b/StartupPage.xaml
index fe46020..1d143d3 100644
--- a/StartupPage.xaml
+++ b/StartupPage.xaml
@@ -52,6 +52,7 @@
+
diff --git a/StartupPage.xaml.cs b/StartupPage.xaml.cs
index 66c46ff..2740766 100644
--- a/StartupPage.xaml.cs
+++ b/StartupPage.xaml.cs
@@ -32,6 +32,30 @@ public partial class StartupPage : Page
public StartupPage()
{
InitializeComponent();
+
+ btnTest.Visibility = TestButtonVisiblity();
+ }
+
+ ///
+ /// Determines if the test button should be visible.
+ ///
+ ///
+ private Visibility TestButtonVisiblity()
+ {
+ foreach ( Control control in spUsbPrinterList.Children )
+ {
+ if ( control is ToggleButton )
+ {
+ ToggleButton tbControl = control as ToggleButton;
+ if ( tbControl.IsChecked == true )
+ {
+ // show if a client printer is checked
+ return Visibility.Visible;
+ }
+ }
+ }
+ // don't show if no printer selected
+ return Visibility.Hidden;
}
///
@@ -158,6 +182,37 @@ private void btnToggle_Click( object sender, RoutedEventArgs e )
tbControl.IsChecked = false;
}
}
+ btnTest.Visibility = TestButtonVisiblity();
+ }
+
+ ///
+ /// Handles the Click event of the btnTest control.
+ ///
+ /// The source of the event.
+ /// The instance containing the event data.
+ private void btnTest_Click( object sender, RoutedEventArgs e )
+ {
+ var rockConfig = RockConfig.Load();
+ rockConfig.PrinterOverrideIp = txtPrinterOverrideIp.Text;
+ rockConfig.PrinterOverrideLocal = string.Empty;
+
+ if ( txtPrinterOverrideIp.Text == string.Empty )
+ {
+ foreach ( Control control in spUsbPrinterList.Children )
+ {
+ if ( control is ToggleButton )
+ {
+ ToggleButton tbControl = control as ToggleButton;
+ if ( tbControl.IsChecked != null && tbControl.IsChecked.Value == true )
+ {
+ rockConfig.PrinterOverrideLocal = tbControl.Content.ToString();
+ }
+ }
+ }
+ }
+ rockConfig.Save();
+ var printer = new RockLabelPrinter();
+ printer.TestPrint();
}
}
}