2016-04-18 11:31:31 -07:00
|
|
|
|
/*
|
2018-10-29 21:47:03 -07:00
|
|
|
|
Copyright (c) 2018, John Lewin
|
2014-03-17 14:41:26 -07:00
|
|
|
|
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.
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2018-10-14 10:55:31 -07:00
|
|
|
|
using System;
|
2022-02-12 18:47:59 -08:00
|
|
|
|
using System.Linq;
|
2018-10-14 10:55:31 -07:00
|
|
|
|
using MatterHackers.Agg;
|
|
|
|
|
|
using MatterHackers.Agg.Image;
|
2017-08-20 02:34:39 -07:00
|
|
|
|
using MatterHackers.Agg.Platform;
|
2018-10-22 11:44:25 -07:00
|
|
|
|
using MatterHackers.Agg.Transform;
|
2016-04-18 11:31:31 -07:00
|
|
|
|
using MatterHackers.Agg.UI;
|
2021-05-21 15:23:25 -07:00
|
|
|
|
using MatterHackers.ImageProcessing;
|
2018-10-14 10:55:31 -07:00
|
|
|
|
using MatterHackers.Localizations;
|
2017-08-04 15:42:23 -07:00
|
|
|
|
using MatterHackers.MatterControl.ConfigurationPage;
|
2017-11-11 17:28:03 -08:00
|
|
|
|
using MatterHackers.MatterControl.CustomWidgets;
|
2016-04-18 11:31:31 -07:00
|
|
|
|
using MatterHackers.MatterControl.PartPreviewWindow;
|
2017-11-11 17:28:03 -08:00
|
|
|
|
using MatterHackers.VectorMath;
|
2016-04-18 11:31:31 -07:00
|
|
|
|
|
2014-03-17 14:41:26 -07:00
|
|
|
|
namespace MatterHackers.MatterControl
|
2014-04-19 10:35:53 -07:00
|
|
|
|
{
|
2018-10-14 10:55:31 -07:00
|
|
|
|
public class BrandMenuButton : PopupMenuButton
|
2017-08-04 15:42:23 -07:00
|
|
|
|
{
|
2017-11-11 17:28:03 -08:00
|
|
|
|
public BrandMenuButton(ThemeConfig theme)
|
2018-10-14 10:55:31 -07:00
|
|
|
|
: base (theme)
|
2017-08-04 15:42:23 -07:00
|
|
|
|
{
|
2017-11-11 17:28:03 -08:00
|
|
|
|
this.Name = "MatterControl BrandMenuButton";
|
2017-11-15 16:13:59 -08:00
|
|
|
|
this.VAnchor = VAnchor.Fit;
|
2018-10-07 11:36:52 -07:00
|
|
|
|
this.HAnchor = HAnchor.Fit;
|
2017-11-11 17:28:03 -08:00
|
|
|
|
this.Margin = 0;
|
2018-10-14 10:55:31 -07:00
|
|
|
|
|
2022-07-15 19:13:44 -07:00
|
|
|
|
this.DynamicPopupContent = () => BrandMenuButton.CreatePopupMenu(theme);
|
2017-09-25 22:27:46 -07:00
|
|
|
|
|
2017-11-11 17:28:03 -08:00
|
|
|
|
var row = new FlowLayoutWidget()
|
2017-10-15 01:01:56 -07:00
|
|
|
|
{
|
2018-10-07 11:36:52 -07:00
|
|
|
|
HAnchor = HAnchor.Fit,
|
2018-04-24 18:39:43 -07:00
|
|
|
|
VAnchor = VAnchor.Fit,
|
2017-10-15 01:01:56 -07:00
|
|
|
|
};
|
2017-11-11 17:28:03 -08:00
|
|
|
|
this.AddChild(row);
|
|
|
|
|
|
|
2022-07-16 07:46:44 -07:00
|
|
|
|
row.AddChild(new ThemedIconButton(StaticData.Instance.LoadIcon("mh-app-logo.png", 16, 16).SetToColor(theme.TextColor), theme)
|
2017-10-15 01:01:56 -07:00
|
|
|
|
{
|
|
|
|
|
|
VAnchor = VAnchor.Center,
|
2018-05-17 12:41:00 -07:00
|
|
|
|
Margin = theme.ButtonSpacing,
|
2017-11-11 17:28:03 -08:00
|
|
|
|
Selectable = false
|
2017-10-15 01:01:56 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
2023-03-18 20:07:56 -07:00
|
|
|
|
row.AddChild(new TextWidget(ApplicationController.Instance.ProductName, textColor: theme.TextColor)
|
2017-08-04 15:42:23 -07:00
|
|
|
|
{
|
2017-08-07 15:47:27 -07:00
|
|
|
|
VAnchor = VAnchor.Center
|
2017-08-04 15:42:23 -07:00
|
|
|
|
});
|
2018-10-07 11:36:52 -07:00
|
|
|
|
|
|
|
|
|
|
foreach (var child in this.Children)
|
|
|
|
|
|
{
|
|
|
|
|
|
child.Selectable = false;
|
|
|
|
|
|
}
|
2017-08-04 15:42:23 -07:00
|
|
|
|
}
|
2018-10-14 10:55:31 -07:00
|
|
|
|
|
2022-07-15 19:13:44 -07:00
|
|
|
|
private static PopupMenu CreatePopupMenu(ThemeConfig theme)
|
2018-10-14 10:55:31 -07:00
|
|
|
|
{
|
|
|
|
|
|
var menuTheme = ApplicationController.Instance.MenuTheme;
|
|
|
|
|
|
|
|
|
|
|
|
var popupMenu = new PopupMenu(menuTheme)
|
|
|
|
|
|
{
|
|
|
|
|
|
MinimumSize = new Vector2(300, 0)
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2021-05-21 15:23:25 -07:00
|
|
|
|
var linkIcon = StaticData.Instance.LoadIcon("fa-link_16.png", 16, 16).SetToColor(menuTheme.TextColor);
|
2018-10-14 10:55:31 -07:00
|
|
|
|
|
|
|
|
|
|
PopupMenu.MenuItem menuItem;
|
|
|
|
|
|
|
2022-02-20 07:59:28 -08:00
|
|
|
|
menuItem = popupMenu.CreateMenuItem("Open System File", StaticData.Instance.LoadIcon("fa-folder-open_16.png", 16, 16).SetToColor(menuTheme.TextColor));
|
|
|
|
|
|
menuItem.Click += (s, e) => ApplicationController.OpenFileWithSystemDialog((fileNames) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
if (fileNames != null && fileNames.Any())
|
|
|
|
|
|
{
|
|
|
|
|
|
ApplicationController.Instance.MainView.OpenFile(fileNames.FirstOrDefault());
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2022-02-12 18:47:59 -08:00
|
|
|
|
|
|
|
|
|
|
popupMenu.CreateSeparator();
|
|
|
|
|
|
|
2021-05-21 15:23:25 -07:00
|
|
|
|
menuItem = popupMenu.CreateMenuItem("Help".Localize(), StaticData.Instance.LoadIcon("help_page.png", 16, 16).SetToColor(menuTheme.TextColor));
|
2021-02-22 21:48:47 -08:00
|
|
|
|
menuItem.Click += (s, e) => ApplicationController.Instance.ShowApplicationHelp("Docs");
|
2018-10-14 10:55:31 -07:00
|
|
|
|
|
2021-05-21 15:23:25 -07:00
|
|
|
|
menuItem = popupMenu.CreateMenuItem("Interface Tour".Localize(), StaticData.Instance.LoadIcon("tour.png", 16, 16).SetToColor(menuTheme.TextColor));
|
2018-11-30 12:05:30 -08:00
|
|
|
|
menuItem.Click += (s, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
UiThread.RunOnIdle(() =>
|
|
|
|
|
|
{
|
2018-12-30 10:53:02 -08:00
|
|
|
|
DialogWindow.Show<Tour.WelcomePage>();
|
2018-11-30 12:05:30 -08:00
|
|
|
|
});
|
|
|
|
|
|
};
|
2018-11-27 18:15:17 -08:00
|
|
|
|
|
2019-01-31 09:42:54 -08:00
|
|
|
|
if (Application.EnableNetworkTraffic)
|
2018-10-14 10:55:31 -07:00
|
|
|
|
{
|
2019-01-31 09:42:54 -08:00
|
|
|
|
popupMenu.CreateSeparator();
|
|
|
|
|
|
|
2021-05-21 15:23:25 -07:00
|
|
|
|
menuItem = popupMenu.CreateMenuItem("Check For Update".Localize(), StaticData.Instance.LoadIcon("update.png", 16, 16).SetToColor(menuTheme.TextColor));
|
2019-01-31 09:42:54 -08:00
|
|
|
|
menuItem.Click += (s, e) => UiThread.RunOnIdle(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
UpdateControlData.Instance.CheckForUpdate();
|
|
|
|
|
|
DialogWindow.Show<CheckForUpdatesPage>();
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2018-10-14 10:55:31 -07:00
|
|
|
|
|
2018-10-24 21:13:10 -07:00
|
|
|
|
popupMenu.CreateSeparator();
|
2018-10-14 11:31:24 -07:00
|
|
|
|
|
2021-05-21 15:23:25 -07:00
|
|
|
|
menuItem = popupMenu.CreateMenuItem("Settings".Localize(), StaticData.Instance.LoadIcon("fa-cog_16.png", 16, 16).SetToColor(menuTheme.TextColor));
|
2018-10-14 11:31:24 -07:00
|
|
|
|
menuItem.Click += (s, e) => DialogWindow.Show<ApplicationSettingsPage>();
|
|
|
|
|
|
menuItem.Name = "Settings MenuItem";
|
|
|
|
|
|
|
2018-10-24 21:13:10 -07:00
|
|
|
|
popupMenu.CreateSeparator();
|
2018-10-14 11:31:24 -07:00
|
|
|
|
|
2018-10-14 10:55:31 -07:00
|
|
|
|
ImageBuffer indicatorIcon = null;
|
|
|
|
|
|
|
|
|
|
|
|
if (IntPtr.Size == 8)
|
|
|
|
|
|
{
|
2021-05-21 15:23:25 -07:00
|
|
|
|
indicatorIcon = StaticData.Instance.LoadIcon("x64.png", 16, 16).SetToColor(menuTheme.TextColor);
|
2018-10-14 10:55:31 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-10-15 17:57:26 -07:00
|
|
|
|
popupMenu.CreateSubMenu("Community".Localize(), menuTheme, (modifyMenu) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
menuItem = modifyMenu.CreateMenuItem("Forums".Localize(), linkIcon);
|
2020-09-22 17:52:57 -07:00
|
|
|
|
menuItem.Click += (s, e) => ApplicationController.LaunchBrowser("https://forums.matterhackers.com/category/20/mattercontrol");
|
2018-10-14 10:55:31 -07:00
|
|
|
|
|
2018-10-15 17:57:26 -07:00
|
|
|
|
menuItem = modifyMenu.CreateMenuItem("Guides and Articles".Localize(), linkIcon);
|
2020-09-22 17:52:57 -07:00
|
|
|
|
menuItem.Click += (s, e) => ApplicationController.LaunchBrowser("https://www.matterhackers.com/topic/mattercontrol");
|
2018-10-14 10:55:31 -07:00
|
|
|
|
|
2018-10-15 17:57:26 -07:00
|
|
|
|
menuItem = modifyMenu.CreateMenuItem("Support".Localize(), linkIcon);
|
2020-09-22 17:52:57 -07:00
|
|
|
|
menuItem.Click += (s, e) => ApplicationController.LaunchBrowser("https://www.matterhackers.com/mattercontrol/support");
|
2018-10-14 11:31:24 -07:00
|
|
|
|
|
2018-10-15 17:57:26 -07:00
|
|
|
|
menuItem = modifyMenu.CreateMenuItem("Release Notes".Localize(), linkIcon);
|
2020-09-22 17:52:57 -07:00
|
|
|
|
menuItem.Click += (s, e) => ApplicationController.LaunchBrowser("https://www.matterhackers.com/mattercontrol/support/release-notes");
|
2018-10-14 11:31:24 -07:00
|
|
|
|
|
2018-10-24 21:13:10 -07:00
|
|
|
|
modifyMenu.CreateSeparator();
|
2018-10-14 11:31:24 -07:00
|
|
|
|
|
2021-05-21 15:23:25 -07:00
|
|
|
|
menuItem = modifyMenu.CreateMenuItem("Report a Bug".Localize(), StaticData.Instance.LoadIcon("feedback.png", 16, 16).SetToColor(menuTheme.TextColor));
|
2020-09-22 17:52:57 -07:00
|
|
|
|
menuItem.Click += (s, e) => ApplicationController.LaunchBrowser("https://github.com/MatterHackers/MatterControl/issues");
|
2021-05-21 15:23:25 -07:00
|
|
|
|
}, StaticData.Instance.LoadIcon("feedback.png", 16, 16).SetToColor(menuTheme.TextColor));
|
2018-10-14 11:31:24 -07:00
|
|
|
|
|
2018-10-24 21:13:10 -07:00
|
|
|
|
popupMenu.CreateSeparator();
|
2018-10-14 11:31:24 -07:00
|
|
|
|
|
2018-10-22 11:44:25 -07:00
|
|
|
|
var imageBuffer = new ImageBuffer(18, 18);
|
|
|
|
|
|
|
|
|
|
|
|
// x64 indicator icon
|
|
|
|
|
|
if (IntPtr.Size == 8)
|
|
|
|
|
|
{
|
|
|
|
|
|
var graphics = imageBuffer.NewGraphics2D();
|
2018-11-03 09:50:09 -07:00
|
|
|
|
graphics.Clear(menuTheme.BackgroundColor);
|
2018-10-22 11:44:25 -07:00
|
|
|
|
graphics.Rectangle(imageBuffer.GetBoundingRect(), menuTheme.PrimaryAccentColor);
|
|
|
|
|
|
graphics.DrawString("64", imageBuffer.Width / 2, imageBuffer.Height / 2, 8, Agg.Font.Justification.Center, Agg.Font.Baseline.BoundsCenter, color: menuTheme.PrimaryAccentColor);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-18 20:07:56 -07:00
|
|
|
|
menuItem = popupMenu.CreateMenuItem("About".Localize() + " " + ApplicationController.Instance.ProductName, imageBuffer);
|
2018-10-14 10:55:31 -07:00
|
|
|
|
menuItem.Click += (s, e) => ApplicationController.Instance.ShowAboutPage();
|
|
|
|
|
|
return popupMenu;
|
|
|
|
|
|
}
|
2017-08-04 15:42:23 -07:00
|
|
|
|
}
|
2017-08-20 02:34:39 -07:00
|
|
|
|
}
|