2017-08-23 23:59:45 -07:00
/ *
2019-04-05 13:18:32 -07:00
Copyright ( c ) 2019 , Lars Brubaker , John Lewin
2017-08-23 23:59:45 -07:00
All rights reserved .
Redistribution and use in source and binary forms , with or without
modification , are permitted provided that the following conditions are met :
1. Redistributions of source code must retain the above copyright notice , this
list of conditions and the following disclaimer .
2. Redistributions in binary form must reproduce the above copyright notice ,
this list of conditions and the following disclaimer in the documentation
and / or other materials provided with the distribution .
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT LIMITED TO , THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT , INDIRECT , INCIDENTAL , SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES
( INCLUDING , BUT NOT LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ;
LOSS OF USE , DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT
( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE .
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies ,
either expressed or implied , of the FreeBSD Project .
* /
2019-04-05 13:18:32 -07:00
using System.IO ;
2017-08-23 23:59:45 -07:00
using MatterHackers.Agg ;
2018-11-01 14:07:21 -07:00
using MatterHackers.Agg.Image ;
using MatterHackers.Agg.Platform ;
2014-01-29 19:09:30 -08:00
using MatterHackers.Agg.UI ;
using MatterHackers.Localizations ;
namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
{
2017-11-08 15:56:37 -08:00
public class SetupStepComPortOne : DialogPage
2015-04-08 15:20:10 -07:00
{
2017-09-17 21:08:16 -07:00
public SetupStepComPortOne ( PrinterConfig printer )
2015-04-08 15:20:10 -07:00
{
2017-10-18 14:56:10 -07:00
this . WindowTitle = "Setup Wizard" . Localize ( ) ;
2017-09-17 21:08:16 -07:00
var container = new FlowLayoutWidget ( FlowDirection . TopToBottom )
2015-04-08 15:20:10 -07:00
{
2017-09-17 21:08:16 -07:00
VAnchor = VAnchor . Stretch ,
Margin = new BorderDouble ( 5 ) ,
HAnchor = HAnchor . Stretch
} ;
2014-01-29 19:09:30 -08:00
2019-04-05 13:18:32 -07:00
var elementMargin = new BorderDouble ( top : 5 ) ;
2014-01-29 19:09:30 -08:00
2021-11-30 11:54:36 -08:00
var printerMessageOne = new TextWidget ( "MatterControl will now attempt to auto-detect your printer." . Localize ( ) , 0 , 0 , 10 )
2017-09-17 21:08:16 -07:00
{
2018-11-03 09:13:07 -07:00
TextColor = theme . TextColor ,
2017-09-17 21:08:16 -07:00
HAnchor = HAnchor . Stretch ,
Margin = elementMargin
} ;
container . AddChild ( printerMessageOne ) ;
2021-11-30 11:54:36 -08:00
var printerMessageTwo = new WrappedTextWidget ( string . Format ( "1.) {0} ({1})." , "Unplug printer USB cable from computer" . Localize ( ) , "if connected" . Localize ( ) ) , 12 )
2017-09-17 21:08:16 -07:00
{
2018-11-03 09:13:07 -07:00
TextColor = theme . TextColor ,
2017-09-17 21:08:16 -07:00
HAnchor = HAnchor . Stretch ,
Margin = elementMargin
} ;
container . AddChild ( printerMessageTwo ) ;
var printerMessageThree = new TextWidget ( string . Format ( "2.) {0} '{1}'." , "Press" . Localize ( ) , "Continue" . Localize ( ) ) , 0 , 0 , 12 )
{
2018-11-03 09:13:07 -07:00
TextColor = theme . TextColor ,
2017-09-17 21:08:16 -07:00
HAnchor = HAnchor . Stretch ,
Margin = elementMargin
} ;
container . AddChild ( printerMessageThree ) ;
2014-01-29 19:09:30 -08:00
2020-11-25 07:39:36 -08:00
var removeImage = StaticData . Instance . LoadImage ( Path . Combine ( "Images" , "remove usb.png" ) ) ;
2018-11-01 14:07:21 -07:00
removeImage . SetRecieveBlender ( new BlenderPreMultBGRA ( ) ) ;
container . AddChild ( new ImageWidget ( removeImage )
{
HAnchor = HAnchor . Center ,
Margin = new BorderDouble ( 0 , 10 ) ,
} ) ;
2015-04-08 15:20:10 -07:00
GuiWidget vSpacer = new GuiWidget ( ) ;
2017-08-07 15:47:27 -07:00
vSpacer . VAnchor = VAnchor . Stretch ;
2017-09-17 21:08:16 -07:00
container . AddChild ( vSpacer ) ;
2014-01-29 19:09:30 -08:00
2017-09-17 21:08:16 -07:00
var setupManualConfigurationOrSkipConnectionWidget = new TextWidget ( "You can also" . Localize ( ) + ":" , 0 , 0 , 10 )
{
2018-11-03 09:13:07 -07:00
TextColor = theme . TextColor ,
2017-09-17 21:08:16 -07:00
HAnchor = HAnchor . Stretch ,
Margin = elementMargin
} ;
container . AddChild ( setupManualConfigurationOrSkipConnectionWidget ) ;
2014-04-08 12:50:26 -07:00
2018-07-11 09:26:54 -07:00
var manualLink = new LinkLabel ( "Manually Configure Connection" . Localize ( ) , theme )
{
Margin = new BorderDouble ( 0 , 5 ) ,
2018-11-03 09:13:07 -07:00
TextColor = theme . TextColor
2018-07-11 09:26:54 -07:00
} ;
2017-08-23 15:51:29 -07:00
manualLink . Click + = ( s , e ) = > UiThread . RunOnIdle ( ( ) = >
{
2018-06-19 15:02:25 -07:00
DialogWindow . ChangeToPage ( new SetupStepComPortManual ( printer ) ) ;
2017-08-23 15:51:29 -07:00
} ) ;
2017-09-17 21:08:16 -07:00
container . AddChild ( manualLink ) ;
2014-01-29 19:09:30 -08:00
2017-09-17 21:08:16 -07:00
var printerMessageFour = new TextWidget ( "or" . Localize ( ) , 0 , 0 , 10 )
{
2018-11-03 09:13:07 -07:00
TextColor = theme . TextColor ,
2017-09-17 21:08:16 -07:00
HAnchor = HAnchor . Stretch ,
Margin = elementMargin
} ;
container . AddChild ( printerMessageFour ) ;
2014-04-08 12:50:26 -07:00
2018-07-11 09:26:54 -07:00
var skipConnectionLink = new LinkLabel ( "Skip Connection Setup" . Localize ( ) , theme )
{
Margin = new BorderDouble ( 0 , 8 ) ,
2018-11-03 09:13:07 -07:00
TextColor = theme . TextColor
2018-07-11 09:26:54 -07:00
} ;
2019-06-28 22:22:58 -07:00
skipConnectionLink . Click + = ( s , e ) = >
2017-09-17 21:08:16 -07:00
{
printer . Connection . HaltConnectionThread ( ) ;
Parent . Close ( ) ;
2019-06-28 22:22:58 -07:00
} ;
2014-04-08 12:50:26 -07:00
container . AddChild ( skipConnectionLink ) ;
2018-11-03 10:12:27 -07:00
contentRow . AddChild ( container ) ;
2014-01-29 19:09:30 -08:00
2019-06-28 22:22:58 -07:00
// Construct buttons
2018-04-14 20:51:01 -07:00
var nextButton = theme . CreateDialogButton ( "Continue" . Localize ( ) ) ;
2019-06-28 22:22:58 -07:00
nextButton . Click + = ( s , e ) = >
2017-09-17 21:08:16 -07:00
{
2018-06-19 15:02:25 -07:00
DialogWindow . ChangeToPage ( new SetupStepComPortTwo ( printer ) ) ;
2019-06-28 22:22:58 -07:00
} ;
2017-09-17 21:08:16 -07:00
this . AddPageAction ( nextButton ) ;
2014-04-08 12:50:26 -07:00
}
2015-04-08 15:20:10 -07:00
}
}