2016-04-18 11:31:31 -07:00
/ *
2014-03-17 14:41:26 -07:00
Copyright ( c ) 2014 , Kevin Pope
All rights reserved .
Redistribution and use in source and binary forms , with or without
2015-04-08 15:20:10 -07:00
modification , are permitted provided that the following conditions are met :
2014-03-17 14:41:26 -07:00
1. Redistributions of source code must retain the above copyright notice , this
2015-04-08 15:20:10 -07:00
list of conditions and the following disclaimer .
2014-03-17 14:41:26 -07:00
2. Redistributions in binary form must reproduce the above copyright notice ,
this list of conditions and the following disclaimer in the documentation
2015-04-08 15:20:10 -07:00
and / or other materials provided with the distribution .
2014-03-17 14:41:26 -07:00
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
2015-04-08 15:20:10 -07:00
of the authors and should not be interpreted as representing official policies ,
2014-03-17 14:41:26 -07:00
either expressed or implied , of the FreeBSD Project .
* /
2015-04-08 15:20:10 -07:00
using System ;
2016-04-18 11:31:31 -07:00
using MatterHackers.Agg ;
using MatterHackers.Agg.UI ;
2017-05-23 10:51:12 -07:00
using MatterHackers.MatterControl.CustomWidgets ;
2016-04-18 11:31:31 -07:00
using MatterHackers.MatterControl.PartPreviewWindow ;
using MatterHackers.MatterControl.PrinterCommunication ;
using MatterHackers.VectorMath ;
2014-03-17 14:41:26 -07:00
namespace MatterHackers.MatterControl
2014-04-19 10:35:53 -07:00
{
2015-04-08 15:20:10 -07:00
public class WidescreenPanel : FlowLayoutWidget
{
private static readonly int ColumnOneFixedWidth = 590 ;
2016-10-07 09:06:35 -07:00
private int lastNumberOfVisiblePanels = 0 ;
2015-04-08 15:20:10 -07:00
private TextImageButtonFactory advancedControlsButtonFactory = new TextImageButtonFactory ( ) ;
private RGBA_Bytes unselectedTextColor = ActiveTheme . Instance . TabLabelUnselected ;
private FlowLayoutWidget ColumnOne ;
private FlowLayoutWidget ColumnTwo ;
2016-05-06 17:56:27 -07:00
private double Force1PanelWidth = 990 * GuiWidget . DeviceScale ;
private double Force2PanelWidth = 1590 * GuiWidget . DeviceScale ;
2015-04-08 15:20:10 -07:00
private GuiWidget leftBorderLine ;
2016-12-29 06:55:12 -08:00
private EventHandler unregisterEvents ;
2015-04-08 15:20:10 -07:00
public static RootedObjectEventHandler PreChangePanels = new RootedObjectEventHandler ( ) ;
public WidescreenPanel ( )
: base ( FlowDirection . LeftToRight )
{
Name = "WidescreenPanel" ;
AnchorAll ( ) ;
BackgroundColor = ActiveTheme . Instance . PrimaryBackgroundColor ;
Padding = new BorderDouble ( 4 ) ;
2016-07-13 11:45:12 -07:00
ApplicationController . Instance . AdvancedControlsPanelReloading . RegisterEvent ( ( s , e ) = > UiThread . RunOnIdle ( ReloadAdvancedControlsPanel ) , ref unregisterEvents ) ;
2015-04-08 15:20:10 -07:00
}
2016-10-05 09:00:23 -07:00
public override void OnBoundsChanged ( EventArgs e )
2015-04-08 15:20:10 -07:00
{
2016-10-05 09:00:23 -07:00
if ( this . VisiblePanelCount ! = lastNumberOfVisiblePanels )
2015-04-08 15:20:10 -07:00
{
RecreateAllPanels ( ) ;
}
2016-10-05 09:00:23 -07:00
base . OnBoundsChanged ( e ) ;
2015-04-08 15:20:10 -07:00
}
2017-02-03 13:06:08 -08:00
public override void OnClosed ( ClosedEventArgs e )
2015-04-08 15:20:10 -07:00
{
2016-04-18 11:31:31 -07:00
unregisterEvents ? . Invoke ( this , null ) ;
2015-04-08 15:20:10 -07:00
base . OnClosed ( e ) ;
}
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
AdvancedControlsPanel advancedControlsPanel ;
2015-04-08 15:20:10 -07:00
private void LoadCompactView ( )
{
ColumnOne . RemoveAllChildren ( ) ;
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
advancedControlsPanel = new AdvancedControlsPanel ( )
{
Name = "For - CompactSlidePanel"
} ;
ColumnOne . AddChild ( advancedControlsPanel ) ;
2015-04-08 15:20:10 -07:00
ColumnOne . AnchorAll ( ) ;
}
2015-06-11 12:06:40 -07:00
private void LoadColumnTwo ( )
2015-04-08 15:20:10 -07:00
{
2016-01-24 20:06:04 -08:00
PopOutManager . SaveIfClosed = false ;
2016-01-12 11:20:27 -08:00
ColumnTwo . CloseAllChildren ( ) ;
2016-01-24 20:06:04 -08:00
PopOutManager . SaveIfClosed = true ;
2015-04-08 15:20:10 -07:00
2017-05-24 19:11:51 -07:00
// HACK: Short term restore auto population of ActivePrintItem based on Queue Index0. Long term, persist Scene as needed before running operations that depend on ActivePrintItem
if ( PrinterConnectionAndCommunication . Instance . ActivePrintItem = = null )
{
2017-06-02 17:04:02 -07:00
ApplicationController . Instance . ClearPlate ( ) ;
2017-05-24 19:11:51 -07:00
}
2017-03-15 16:17:06 -07:00
PartPreviewContent partViewContent = new PartPreviewContent ( PrinterConnectionAndCommunication . Instance . ActivePrintItem , View3DWidget . WindowMode . Embeded , View3DWidget . AutoRotate . Disabled ) ;
2015-04-08 15:20:10 -07:00
partViewContent . AnchorAll ( ) ;
ColumnTwo . AddChild ( partViewContent ) ;
ColumnTwo . AnchorAll ( ) ;
}
2016-10-05 09:00:23 -07:00
private int VisiblePanelCount = > ( this . Width < Force1PanelWidth ) ? 1 : 2 ;
2015-04-08 15:20:10 -07:00
public void RecreateAllPanels ( object state = null )
{
if ( Width = = 0 )
{
return ;
}
2016-10-05 09:00:23 -07:00
int numberOfPanels = this . VisiblePanelCount ;
2015-04-08 15:20:10 -07:00
PreChangePanels . CallEvents ( this , null ) ;
RemovePanelsAndCreateEmpties ( ) ;
2016-10-05 09:00:23 -07:00
LoadCompactView ( ) ;
2015-04-08 15:20:10 -07:00
2016-10-05 09:00:23 -07:00
// Load ColumnTwo if applicable - i.e. widescreen view
if ( numberOfPanels = = 2 )
{
LoadColumnTwo ( ) ;
2015-04-08 15:20:10 -07:00
}
SetColumnVisibility ( ) ;
lastNumberOfVisiblePanels = numberOfPanels ;
}
private void SetColumnVisibility ( object state = null )
{
2016-10-05 09:00:23 -07:00
int numberOfPanels = this . VisiblePanelCount ;
2015-04-08 15:20:10 -07:00
switch ( numberOfPanels )
{
case 1 :
{
ColumnTwo . Visible = false ;
ColumnOne . Visible = true ;
Padding = new BorderDouble ( 0 ) ;
leftBorderLine . Visible = false ;
}
break ;
case 2 :
Padding = new BorderDouble ( 4 ) ;
ColumnOne . Visible = true ;
ColumnTwo . Visible = true ;
2015-05-18 17:29:05 -07:00
ColumnOne . HAnchor = HAnchor . AbsolutePosition ;
2015-04-08 15:20:10 -07:00
ColumnOne . Width = ColumnOneFixedWidth ; // it can hold the slice settings so it needs to be bigger.
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
// TODO: Couldn't this just use this.Width so that we could lose the advancedControlsPanel variable?
ColumnOne . MinimumSize = new Vector2 ( Math . Max ( advancedControlsPanel . Width , ColumnOneFixedWidth ) , 0 ) ; //Ordering here matters - must go after children are added
2015-04-08 15:20:10 -07:00
break ;
}
}
private void RemovePanelsAndCreateEmpties ( )
{
2016-01-12 11:20:27 -08:00
CloseAllChildren ( ) ;
2015-04-08 15:20:10 -07:00
ColumnOne = new FlowLayoutWidget ( FlowDirection . TopToBottom ) ;
ColumnTwo = new FlowLayoutWidget ( FlowDirection . TopToBottom ) ;
2017-05-23 10:51:12 -07:00
this . AddChild ( ColumnOne ) ;
2017-02-01 16:39:24 -08:00
leftBorderLine = new GuiWidget ( )
{
2017-05-23 10:51:12 -07:00
VAnchor = VAnchor . ParentBottomTop ,
Width = 15 ,
Padding = 5
2017-02-01 16:39:24 -08:00
} ;
2017-05-23 10:51:12 -07:00
leftBorderLine . AddChild ( new VerticalLine ( alpha : 50 )
2015-04-08 15:20:10 -07:00
{
2017-05-23 10:51:12 -07:00
HAnchor = HAnchor . ParentLeft
} ) ;
this . AddChild ( leftBorderLine ) ;
this . AddChild ( ColumnTwo ) ;
2015-04-08 15:20:10 -07:00
}
2015-06-11 12:06:40 -07:00
public void ReloadAdvancedControlsPanel ( )
2015-04-08 15:20:10 -07:00
{
PreChangePanels . CallEvents ( this , null ) ;
}
}
2015-07-02 14:36:04 -07:00
public class UpdateNotificationMark : GuiWidget
2015-04-08 15:20:10 -07:00
{
2015-06-15 09:55:38 -07:00
public UpdateNotificationMark ( )
2015-04-08 15:20:10 -07:00
: base ( 12 , 12 )
{
}
public override void OnDraw ( Graphics2D graphics2D )
{
graphics2D . Circle ( Width / 2 , Height / 2 , Width / 2 , RGBA_Bytes . White ) ;
graphics2D . Circle ( Width / 2 , Height / 2 , Width / 2 - 1 , RGBA_Bytes . Red ) ;
graphics2D . FillRectangle ( Width / 2 - 1 , Height / 2 - 3 , Width / 2 + 1 , Height / 2 + 3 , RGBA_Bytes . White ) ;
base . OnDraw ( graphics2D ) ;
}
}
}