2017-07-27 14:25:21 -07:00
/ *
Copyright ( c ) 2017 , Lars Brubaker , John Lewin
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 .
* /
using MatterHackers.Agg ;
using MatterHackers.Agg.UI ;
using MatterHackers.Localizations ;
using MatterHackers.MatterControl.ActionBar ;
using MatterHackers.MatterControl.PrinterCommunication ;
namespace MatterHackers.MatterControl.PartPreviewWindow
{
public class PlusTabPage : FlowLayoutWidget
{
public PlusTabPage ( )
2017-08-04 15:42:23 -07:00
: base ( FlowDirection . TopToBottom )
2017-07-27 14:25:21 -07:00
{
2017-08-04 15:42:23 -07:00
this . Name = "+" ;
this . HAnchor = HAnchor . ParentLeftRight ;
this . VAnchor = VAnchor . ParentBottomTop ;
this . Padding = 20 ;
2017-07-27 14:25:21 -07:00
// put in the add new design stuff
2017-08-04 15:42:23 -07:00
var createItemsSection = CreateSection ( "Create New" . Localize ( ) + ":" ) ;
2017-07-27 14:25:21 -07:00
2017-08-01 08:25:42 -07:00
var createPart = ApplicationController . Instance . Theme . ButtonFactory . Generate ( "Create Part" . Localize ( ) ) ;
2017-07-27 14:25:21 -07:00
createPart . HAnchor = HAnchor . ParentLeft ;
2017-08-04 15:42:23 -07:00
createItemsSection . AddChild ( createPart ) ;
2017-07-27 14:25:21 -07:00
2017-08-01 08:25:42 -07:00
var createPrinter = ApplicationController . Instance . Theme . ButtonFactory . Generate ( "Create Printer" . Localize ( ) ) ;
2017-07-27 14:25:21 -07:00
createPrinter . HAnchor = HAnchor . ParentLeft ;
createPrinter . Click + = ( s , e ) = >
{
if ( PrinterConnection . Instance . PrinterIsPrinting
| | PrinterConnection . Instance . PrinterIsPaused )
{
UiThread . RunOnIdle ( ( ) = >
StyledMessageBox . ShowMessageBox ( null , "Please wait until the print has finished and try again." . Localize ( ) , "Can't add printers while printing" . Localize ( ) )
) ;
}
else
{
UiThread . RunOnIdle ( ( ) = >
{
WizardWindow . ShowPrinterSetup ( true ) ;
} ) ;
}
} ;
2017-08-04 15:42:23 -07:00
createItemsSection . AddChild ( createPrinter ) ;
var existingPrinterSection = CreateSection ( "Open Existing" . Localize ( ) + ":" ) ;
var printerSelector = new PrinterSelectEditDropdown ( )
{
Margin = new BorderDouble ( left : 15 )
} ;
existingPrinterSection . AddChild ( printerSelector ) ;
var otherItemsSection = CreateSection ( "Other" . Localize ( ) + ":" ) ;
var redeemDesignCode = ApplicationController . Instance . Theme . ButtonFactory . Generate ( "Redeem Design Code" . Localize ( ) ) ;
redeemDesignCode . HAnchor = HAnchor . ParentLeft ;
redeemDesignCode . Click + = ( s , e ) = >
{
// Implementation already does RunOnIdle
ApplicationController . Instance . RedeemDesignCode ? . Invoke ( ) ;
} ;
otherItemsSection . AddChild ( redeemDesignCode ) ;
var redeemShareCode = ApplicationController . Instance . Theme . ButtonFactory . Generate ( "Enter Share Code" . Localize ( ) ) ;
redeemShareCode . HAnchor = HAnchor . ParentLeft ;
redeemShareCode . Click + = ( s , e ) = >
{
// Implementation already does RunOnIdle
ApplicationController . Instance . EnterShareCode ? . Invoke ( ) ;
} ;
otherItemsSection . AddChild ( redeemShareCode ) ;
2017-07-27 14:25:21 -07:00
2017-08-01 08:25:42 -07:00
var importButton = ApplicationController . Instance . Theme . ButtonFactory . Generate ( "Import" . Localize ( ) ) ;
2017-07-28 14:05:02 -07:00
importButton . Click + = ( s , e ) = >
{
UiThread . RunOnIdle ( ( ) = > WizardWindow . Show < ImportSettingsPage > ( "ImportSettingsPage" , "Import Settings Page" ) ) ;
} ;
2017-08-04 15:42:23 -07:00
otherItemsSection . AddChild ( importButton ) ;
}
2017-07-28 14:05:02 -07:00
2017-08-04 15:42:23 -07:00
private FlowLayoutWidget CreateSection ( string headingText )
{
// Add heading
this . AddChild ( new TextWidget ( headingText , textColor : ActiveTheme . Instance . PrimaryTextColor ) ) ;
2017-07-27 14:25:21 -07:00
2017-08-04 15:42:23 -07:00
// Add container
var container = new FlowLayoutWidget ( FlowDirection . TopToBottom )
2017-07-27 14:25:21 -07:00
{
2017-08-04 15:42:23 -07:00
HAnchor = HAnchor . ParentLeftRight ,
VAnchor = VAnchor . FitToChildren ,
Margin = new BorderDouble ( 15 , 15 , 15 , 8 ) ,
2017-07-27 14:25:21 -07:00
} ;
2017-08-04 15:42:23 -07:00
this . AddChild ( container ) ;
return container ;
2017-07-27 14:25:21 -07:00
}
}
}