Added menu bar.

This commit is contained in:
kevinepope 2014-04-27 20:24:58 -07:00
parent 0f9dd2427f
commit cc44b0ef04
11 changed files with 276 additions and 48 deletions

View file

@ -110,7 +110,7 @@ namespace MatterHackers.MatterControl.ActionBar
protected double borderWidth;
protected double borderRadius;
protected double padding;
protected double statusTextHeight = 10;
protected double statusTextHeight = 8;
TextWidget printerStatusText;
TextWidget printerNameText;
@ -133,7 +133,7 @@ namespace MatterHackers.MatterControl.ActionBar
this.fillColor = fillColor;
this.borderColor = borderColor;
this.padding = padding;
this.Padding = new BorderDouble(10, 5);
this.Padding = new BorderDouble(10, 3);
this.HAnchor = HAnchor.ParentLeftRight;
FlowLayoutWidget textContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
@ -240,10 +240,10 @@ namespace MatterHackers.MatterControl.ActionBar
public class PrinterSelectButton : Button
{
double width = 180;
double height = 48;
double height = 39;
double borderRadius = 0;
double borderWidth = 1;
double fontSize = 16;
double fontSize = 14;
double padding = 3;
BorderDouble margin = new BorderDouble(0, 0);

View file

@ -48,14 +48,14 @@ namespace MatterHackers.MatterControl.ActionBar
actionBarButtonFactory.invertImageLocation = false;
string connectString = "Connect".Localize().ToUpper();
connectPrinterButton = actionBarButtonFactory.Generate(connectString, "icon_power_32x32.png");
connectPrinterButton.Margin = new BorderDouble(0, 0, 3);
connectPrinterButton.VAnchor = VAnchor.ParentCenter;
connectPrinterButton.Margin = new BorderDouble(0, 0, 3, 6);
connectPrinterButton.VAnchor = VAnchor.ParentTop;
connectPrinterButton.Cursor = Cursors.Hand;
string disconnectString = "Disconnect".Localize().ToUpper();
disconnectPrinterButton = actionBarButtonFactory.Generate(disconnectString, "icon_power_32x32.png");
disconnectPrinterButton.Margin = new BorderDouble(0, 0, 3);
disconnectPrinterButton.VAnchor = VAnchor.ParentCenter;
disconnectPrinterButton.Margin = new BorderDouble(0, 0, 3, 6);
disconnectPrinterButton.VAnchor = VAnchor.ParentTop;
disconnectPrinterButton.Visible = false;
disconnectPrinterButton.Cursor = Cursors.Hand;
@ -80,33 +80,6 @@ namespace MatterHackers.MatterControl.ActionBar
//this.AddChild(CreateOptionsMenu());
}
GuiWidget CreateOptionsMenu()
{
ImageBuffer gearImage = new ImageBuffer();
string imagePathAndFile = Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath, "gear_icon.png");
ImageIO.LoadImageData(imagePathAndFile, gearImage);
FlowLayoutWidget leftToRight = new FlowLayoutWidget();
leftToRight.Margin = new BorderDouble(5, 0);
string optionsString = "Options".Localize().ToUpper();
TextWidget optionsText = new TextWidget(optionsString, textColor: ActiveTheme.Instance.PrimaryTextColor);
optionsText.VAnchor = Agg.UI.VAnchor.ParentCenter;
optionsText.Margin = new BorderDouble(0, 0, 3, 0);
leftToRight.AddChild(optionsText);
GuiWidget gearWidget = new ImageWidget(gearImage);
gearWidget.VAnchor = Agg.UI.VAnchor.ParentCenter;
leftToRight.AddChild(gearWidget);
leftToRight.HAnchor = HAnchor.FitToChildren;
leftToRight.VAnchor = VAnchor.FitToChildren;
Menu optionMenu = new Menu(leftToRight);
optionMenu.OpenOffset = new Vector2(-2, -10);
optionMenu.VAnchor = Agg.UI.VAnchor.ParentCenter;
optionMenu.MenuItems.Add(new MenuItem(new ThemeColorSelectorWidget()));
return optionMenu;
}
event EventHandler unregisterEvents;
protected override void AddHandlers()
{

View file

@ -0,0 +1,215 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MatterHackers.Agg;
using MatterHackers.Agg.Transform;
using MatterHackers.Agg.Image;
using MatterHackers.Agg.VertexSource;
using MatterHackers.Agg.UI;
using MatterHackers.Agg.Font;
using MatterHackers.VectorMath;
using MatterHackers.MatterControl.CustomWidgets;
using MatterHackers.Localizations;
namespace MatterHackers.MatterControl
{
public class ApplicationMenuRow : FlowLayoutWidget
{
static FlowLayoutWidget rightElement;
public ApplicationMenuRow()
:base(FlowDirection.LeftToRight)
{
LinkButtonFactory linkButtonFactory = new LinkButtonFactory();
linkButtonFactory.textColor = ActiveTheme.Instance.PrimaryTextColor;
linkButtonFactory.fontSize = 8;
Button signInLink = linkButtonFactory.Generate("(Sign Out)");
signInLink.VAnchor = Agg.UI.VAnchor.ParentCenter;
signInLink.Margin = new BorderDouble(top: 0);
this.HAnchor = HAnchor.ParentLeftRight;
this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
MenuOptionFile menuOptionFile = new MenuOptionFile();
//TextWidget menuOptionFile = new TextWidget("FILE", pointSize: 10);
//menuOptionFile.TextColor = ActiveTheme.Instance.PrimaryTextColor;
MenuOptionHelp menuOptionHelp = new MenuOptionHelp();
rightElement = new FlowLayoutWidget(FlowDirection.LeftToRight);
rightElement.Height = 24;
rightElement.Margin = new BorderDouble(bottom: 4);
//rightElement.VAnchor = Agg.UI.VAnchor.ParentCenter;
this.AddChild(menuOptionFile);
this.AddChild(menuOptionHelp);
this.AddChild(new HorizontalSpacer());
this.AddChild(rightElement);
this.Padding = new BorderDouble(0, 0, 6, 0);
if (privateAddRightElement != null)
{
privateAddRightElement(rightElement);
}
}
public delegate void AddRightElementDelegate(GuiWidget iconContainer);
private static event AddRightElementDelegate privateAddRightElement;
public static event AddRightElementDelegate AddRightElement
{
add
{
privateAddRightElement += value;
// and call it right away
value(rightElement);
}
remove
{
privateAddRightElement -= value;
}
}
}
public class MenuOptionFile : GuiWidget
{
public DropDownMenu MenuDropList;
private TupleList<string, Func<bool>> menuItems;
public MenuOptionFile()
{
MenuDropList = new DropDownMenu("File".Localize().ToUpper(), Direction.Down,pointSize:10);
MenuDropList.MenuItemsPadding = new BorderDouble(0);
MenuDropList.Margin = new BorderDouble(0);
MenuDropList.Padding = new BorderDouble(0);
SetMenuItems();
AddChild(MenuDropList);
this.Width = 44;
this.Height = 20;
this.Margin = new BorderDouble(0);
this.Padding = new BorderDouble(0);
this.VAnchor = Agg.UI.VAnchor.ParentCenter;
this.MenuDropList.SelectionChanged += new EventHandler(MenuDropList_SelectionChanged);
this.MenuDropList.OpenOffset = new Vector2(0, 0);
}
void MenuDropList_SelectionChanged(object sender, EventArgs e)
{
string menuSelection = ((DropDownMenu)sender).SelectedValue;
foreach (Tuple<string, Func<bool>> item in menuItems)
{
if (item.Item1 == menuSelection)
{
if (item.Item2 != null)
{
item.Item2();
}
}
}
}
void SetMenuItems()
{
menuItems = new TupleList<string, Func<bool>>
{
{LocalizedString.Get("Import File"), doSomething_Click},
{LocalizedString.Get("Exit"), doSomething_Click},
};
BorderDouble padding = MenuDropList.MenuItemsPadding;
//Add the menu items to the menu itself
foreach (Tuple<string, Func<bool>> item in menuItems)
{
MenuDropList.MenuItemsPadding = new BorderDouble(8,4,8,4);
MenuDropList.AddItem(item.Item1,pointSize:10);
}
MenuDropList.Padding = padding;
}
bool doSomething_Click()
{
return true;
}
}
public class MenuOptionHelp : GuiWidget
{
public DropDownMenu MenuDropList;
private TupleList<string, Func<bool>> menuItems;
public MenuOptionHelp()
{
MenuDropList = new DropDownMenu("Help".Localize().ToUpper(), Direction.Down, pointSize: 10);
MenuDropList.MenuItemsPadding = new BorderDouble(0);
MenuDropList.Margin = new BorderDouble(0);
MenuDropList.Padding = new BorderDouble(0);
SetMenuItems();
AddChild(MenuDropList);
this.Width = 46;
this.Height = 20;
this.Margin = new BorderDouble(0);
this.Padding = new BorderDouble(0);
this.VAnchor = Agg.UI.VAnchor.ParentCenter;
this.MenuDropList.SelectionChanged += new EventHandler(MenuDropList_SelectionChanged);
this.MenuDropList.OpenOffset = new Vector2(0, 0);
}
void MenuDropList_SelectionChanged(object sender, EventArgs e)
{
string menuSelection = ((DropDownMenu)sender).SelectedValue;
foreach (Tuple<string, Func<bool>> item in menuItems)
{
if (item.Item1 == menuSelection)
{
if (item.Item2 != null)
{
item.Item2();
}
}
}
}
void SetMenuItems()
{
menuItems = new TupleList<string, Func<bool>>
{
{LocalizedString.Get("Getting Started"), doSomething_Click},
{LocalizedString.Get("View Help"), doSomething_Click},
{LocalizedString.Get("About"), doSomething_Click},
};
BorderDouble padding = MenuDropList.MenuItemsPadding;
//Add the menu items to the menu itself
foreach (Tuple<string, Func<bool>> item in menuItems)
{
MenuDropList.MenuItemsPadding = new BorderDouble(8, 4, 8, 4);
MenuDropList.AddItem(item.Item1, pointSize: 10);
}
MenuDropList.Padding = padding;
}
bool doSomething_Click()
{
return true;
}
}
}

View file

@ -45,6 +45,7 @@ using MatterHackers.MatterControl.PrintQueue;
using MatterHackers.MatterControl.PrintLibrary;
using MatterHackers.MatterControl.SlicerConfiguration;
using MatterHackers.MatterControl.DataStorage;
using MatterHackers.MatterControl.CustomWidgets;
using MatterHackers.Localizations;
namespace MatterHackers.MatterControl
@ -84,13 +85,30 @@ namespace MatterHackers.MatterControl
}
WidescreenPanel widescreenPanel;
public void AddElements()
void AddElements()
{
//this.AddChild(new CompactSlidePanel());
this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
FlowLayoutWidget container = new FlowLayoutWidget(FlowDirection.TopToBottom);
container.AnchorAll();
ApplicationMenuRow menuRow = new ApplicationMenuRow();
container.AddChild(menuRow);
GuiWidget menuSeparator = new GuiWidget();
menuSeparator.BackgroundColor = new RGBA_Bytes(200, 200, 200);
menuSeparator.Height = 2;
menuSeparator.HAnchor = HAnchor.ParentLeftRight;
menuSeparator.Margin = new BorderDouble(3, 0);
container.AddChild(menuSeparator);
widescreenPanel = new WidescreenPanel();
this.AddChild(widescreenPanel);
this.AnchorAll();
SetUpdateNotification(this, null);
container.AddChild(widescreenPanel);
this.AddChild(container);
}
public void ReloadAll(object sender, EventArgs e)
@ -99,19 +117,25 @@ namespace MatterHackers.MatterControl
{
widescreenPanel.StoreUiState();
this.RemoveAllChildren();
widescreenPanel = new WidescreenPanel();
this.AddChild(widescreenPanel);
AddElements();
});
}
void Initialize()
{
this.AnchorAll();
SetUpdateNotification(this, null);
}
public static ApplicationWidget Instance
{
get
{
if (globalInstance == null)
{
globalInstance = new ApplicationWidget();
globalInstance = new ApplicationWidget();
globalInstance.AddElements();
globalInstance.Initialize();
}
return globalInstance;
}

View file

@ -92,6 +92,7 @@
<Compile Include="ActionBar\PrintStatusRow.cs" />
<Compile Include="ActionBar\TemperatureWidgetBase.cs" />
<Compile Include="ActionBar\TemperatureWidgetExtruder.cs" />
<Compile Include="ApplicationView\ApplicationMenuRow.cs" />
<Compile Include="ApplicationView\CompactSlidePanel.cs" />
<Compile Include="ApplicationView\MainScreenTabView.cs" />
<Compile Include="ConfigurationPage\LanguageSelector.cs" />
@ -105,7 +106,7 @@
<Compile Include="CustomWidgets\DisableableWidget.cs" />
<Compile Include="CustomWidgets\ExportPrintItemWindow.cs" />
<Compile Include="PrintLibrary\LibraryData.cs" />
<Compile Include="PrintQueue\OptionsMenue\ExportToFolderFeedbackWindow.cs" />
<Compile Include="PrintQueue\OptionsMenu\ExportToFolderFeedbackWindow.cs" />
<Compile Include="EeProm\EePromMarlinSettings.cs" />
<Compile Include="PrinterControls\EditLevelingSettingsWindow.cs" />
<Compile Include="PrintHistory\PrintHistoryListControl.cs" />
@ -151,7 +152,7 @@
<Compile Include="ControlElements\ImageButtonFactory.cs" />
<Compile Include="ControlElements\LinkButtonFactory.cs" />
<Compile Include="CustomWidgets\PrintProgressBarWidget.cs" />
<Compile Include="PrintQueue\OptionsMenue\ExportToSdCardFeedbackWindow.cs" />
<Compile Include="PrintQueue\OptionsMenu\ExportToSdCardFeedbackWindow.cs" />
<Compile Include="CustomWidgets\SlidePanelWidget.cs" />
<Compile Include="CustomWidgets\StyledDropDownList.cs" />
<Compile Include="ControlElements\StyledMessageBoxWindow.cs" />
@ -170,7 +171,7 @@
<Compile Include="ControlElements\MHTextEditWidget.cs" />
<Compile Include="PartPreviewWindow\GcodeViewBasic.cs" />
<Compile Include="PartPreviewWindow\PartPreviewMainWindow.cs" />
<Compile Include="PrintQueue\OptionsMenue\PartsSheetCreator.cs" />
<Compile Include="PrintQueue\OptionsMenu\PartsSheetCreator.cs" />
<Compile Include="Utilities\WebUtilities\JsonResponseDictionary.cs" />
<Compile Include="PrinterCommunication\PrinterCommunication.cs" />
<Compile Include="PrinterControls\PrintLeveling.cs" />
@ -195,13 +196,13 @@
<Compile Include="PrintLibrary\LibraryDataView.cs" />
<Compile Include="PrintLibrary\LibraryRowItem.cs" />
<Compile Include="PrintLibrary\PrintLibraryWidget.cs" />
<Compile Include="PrintQueue\OptionsMenue\ExportToFolderProcess.cs" />
<Compile Include="PrintQueue\OptionsMenu\ExportToFolderProcess.cs" />
<Compile Include="CustomWidgets\PartThumbnailWidget.cs" />
<Compile Include="PrintQueue\PrintItemWrapper.cs" />
<Compile Include="PrintQueue\QueueRowItem.cs" />
<Compile Include="MatterControlApplication.cs" />
<Compile Include="PrintQueue\QueueDataView.cs" />
<Compile Include="PrintQueue\OptionsMenue\QueueOptionsMenu.cs" />
<Compile Include="PrintQueue\OptionsMenu\QueueOptionsMenu.cs" />
<Compile Include="Utilities\ProjectFileHandler.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Utilities\WebUtilities\RequestManager.cs" />

View file

@ -60,6 +60,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MatterSlice", "..\MatterSli
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Launcher", "Launcher\Launcher.csproj", "{3DF4CB3D-9A03-4256-9A81-70523AAD828B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MatterControlAuth", "..\MatterControlAuth\MatterControlAuth\MatterControlAuth.csproj", "{5258F3E5-A1BB-4BCA-B899-C5CD6157D0A3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -425,6 +427,18 @@ Global
{3DF4CB3D-9A03-4256-9A81-70523AAD828B}.Release64|x64.ActiveCfg = Release64|Any CPU
{3DF4CB3D-9A03-4256-9A81-70523AAD828B}.Release64|x64.Build.0 = Release64|Any CPU
{3DF4CB3D-9A03-4256-9A81-70523AAD828B}.Release64|x86.ActiveCfg = Release64|Any CPU
{5258F3E5-A1BB-4BCA-B899-C5CD6157D0A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5258F3E5-A1BB-4BCA-B899-C5CD6157D0A3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5258F3E5-A1BB-4BCA-B899-C5CD6157D0A3}.Debug|x64.ActiveCfg = Debug|Any CPU
{5258F3E5-A1BB-4BCA-B899-C5CD6157D0A3}.Debug|x86.ActiveCfg = Debug|Any CPU
{5258F3E5-A1BB-4BCA-B899-C5CD6157D0A3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5258F3E5-A1BB-4BCA-B899-C5CD6157D0A3}.Release|Any CPU.Build.0 = Release|Any CPU
{5258F3E5-A1BB-4BCA-B899-C5CD6157D0A3}.Release|x64.ActiveCfg = Release|Any CPU
{5258F3E5-A1BB-4BCA-B899-C5CD6157D0A3}.Release|x86.ActiveCfg = Release|Any CPU
{5258F3E5-A1BB-4BCA-B899-C5CD6157D0A3}.Release64|Any CPU.ActiveCfg = Release|Any CPU
{5258F3E5-A1BB-4BCA-B899-C5CD6157D0A3}.Release64|Any CPU.Build.0 = Release|Any CPU
{5258F3E5-A1BB-4BCA-B899-C5CD6157D0A3}.Release64|x64.ActiveCfg = Release|Any CPU
{5258F3E5-A1BB-4BCA-B899-C5CD6157D0A3}.Release64|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -433,6 +447,7 @@ Global
{291CD87C-2C58-4369-9D85-238C7EB31542} = {DA2BE4E5-5FB2-4C74-9170-0D2513AAFC84}
{F49EC1DD-D645-4709-8667-B57318AF67B0} = {DA2BE4E5-5FB2-4C74-9170-0D2513AAFC84}
{BEC6FD13-C765-4B90-836B-53823AC12E20} = {DA2BE4E5-5FB2-4C74-9170-0D2513AAFC84}
{5258F3E5-A1BB-4BCA-B899-C5CD6157D0A3} = {DA2BE4E5-5FB2-4C74-9170-0D2513AAFC84}
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = MatterControl.csproj