Improving startup

This commit is contained in:
Lars Brubaker 2022-01-06 16:55:55 -08:00
parent 9aaa069533
commit 569e316f38
16 changed files with 315 additions and 27 deletions

View file

@ -779,7 +779,9 @@ namespace MatterHackers.MatterControl
}
if (UserSettings.Instance.get(UserSettingsKey.ShownWelcomeMessage) != "false")
// If we have not cancled the show welcome message and there is a window open
if (UserSettings.Instance.get(UserSettingsKey.ShownWelcomeMessage) != "false"
&& ApplicationController.Instance.Workspaces.Count > 0)
{
UiThread.RunOnIdle(() =>
{

View file

@ -1599,7 +1599,7 @@ namespace MatterHackers.MatterControl
this.OpenWorkspace(workspace, WorkspacesChangedEventArgs.OperationType.Add);
}
private void OpenWorkspace(PartWorkspace workspace, WorkspacesChangedEventArgs.OperationType operationType)
public void OpenWorkspace(PartWorkspace workspace, WorkspacesChangedEventArgs.OperationType operationType)
{
this.OnWorkspacesChanged(
new WorkspacesChangedEventArgs(
@ -1707,25 +1707,14 @@ namespace MatterHackers.MatterControl
}
}
if (this.Workspaces.Count == 0)
// If the use does not have a workspace open and has not setup any hardware, show the startup screen
if (this.Workspaces.Count == 0
&& !ProfileManager.Instance.ActiveProfiles.Any())
{
var workspace = new PartWorkspace(new BedConfig(history))
UiThread.RunOnIdle(() =>
{
Name = "New Design".Localize()
};
// Load it up
workspace.SceneContext.LoadEmptyContent(
new EditContext()
{
ContentStore = history,
SourceItem = history.NewPlatingItem(workspace.SceneContext.Scene)
});
ApplicationController.Instance.MainTabKey = workspace.Name;
// Open but no need to save
this.OpenWorkspace(workspace, WorkspacesChangedEventArgs.OperationType.Restore);
DialogWindow.Show<StartupPage>();
});
}
}

View file

@ -50,6 +50,7 @@ namespace MatterHackers.MatterControl.CustomWidgets
this.HoverColor = theme.SlightShade;
this.MouseDownColor = theme.MinimalShade;
this.Margin = 0;
this.Cursor = Cursors.Hand;
this.TabStop = true;
}

View file

@ -42,7 +42,7 @@ using Newtonsoft.Json;
namespace MatterHackers.MatterControl
{
public class AboutPage : DialogPage
public class AboutPage : DialogPage
{
public AboutPage()
: base("Close".Localize())

View file

@ -0,0 +1,187 @@
/*
Copyright (c) 2018, 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 System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using MatterHackers.Agg;
using MatterHackers.Agg.Image;
using MatterHackers.Agg.Platform;
using MatterHackers.Agg.UI;
using MatterHackers.Agg.VertexSource;
using MatterHackers.ImageProcessing;
using MatterHackers.Localizations;
using MatterHackers.MatterControl.CustomWidgets;
using MatterHackers.MatterControl.PrinterControls.PrinterConnections;
using MatterHackers.VectorMath;
using Newtonsoft.Json;
namespace MatterHackers.MatterControl
{
public class StartupPage : DialogPage
{
public StartupPage()
: base("Close".Localize())
{
this.WindowTitle = "Setup".Localize() + " " + ApplicationController.Instance.ProductName;
this.MinimumSize = new Vector2(480 * GuiWidget.DeviceScale, 250 * GuiWidget.DeviceScale);
this.WindowSize = new Vector2(500 * GuiWidget.DeviceScale, 300 * GuiWidget.DeviceScale);
contentRow.BackgroundColor = Color.Transparent;
headerRow.Visible = false;
contentRow.AddChild(
new WrappedTextWidget(
"Welcome to MatterControl! What would you like to do today?".Localize(),
pointSize: theme.DefaultFontSize,
textColor: theme.TextColor)
{
Margin = new BorderDouble(0, 15)
});
var buttonRow = new FlowLayoutWidget()
{
HAnchor = HAnchor.Center | HAnchor.Fit
};
var size = (int)(128 * DeviceScale);
var borderImage = new ImageBuffer(size, size);
var graphics = borderImage.NewGraphics2D();
var bounds = borderImage.GetBounds();
var radius = size * 10 / 100;
var stroke = DeviceScale * 4;
var margin = stroke * 2;
bounds.Inflate((int)(-stroke / 2));
//graphics.FillRectangle(bounds, theme.BackgroundColor);
graphics.Render(new Stroke(new RoundedRect(bounds, radius), stroke), 0, 0, theme.TextColor);
GuiWidget AddButtonText(GuiWidget button, string text)
{
var content = new FlowLayoutWidget(FlowDirection.TopToBottom);
content.AddChild(button);
content.AddChild(new TextWidget(text,
pointSize: theme.DefaultFontSize,
textColor: theme.TextColor)
{
HAnchor = HAnchor.Center
});
return content;
}
var pulseImage = new ImageBuffer(borderImage);
var pulseWord = StaticData.Instance.LoadIcon("pulse_word.png").SetToColor(theme.TextColor);
var wordWidth = bounds.Width * .8;
graphics = pulseImage.NewGraphics2D();
graphics.ImageRenderQuality = Graphics2D.TransformQuality.Best;
graphics.RenderMaxSize(pulseWord, pulseImage.Width / 2 - wordWidth / 2, margin, wordWidth, bounds.Height, out _);
var pulseLogo = StaticData.Instance.LoadIcon("pulse_logo.png").SetToColor(theme.TextColor);
var logoWidth = bounds.Width * .5;
graphics = pulseImage.NewGraphics2D();
graphics.ImageRenderQuality = Graphics2D.TransformQuality.Best;
graphics.RenderMaxSize(pulseLogo, pulseImage.Width / 2 - logoWidth / 2, pulseImage.Height * .42, logoWidth, bounds.Height, out _);
IconButton lastButton = null;
buttonRow.AddChild(AddButtonText(lastButton = new IconButton(pulseImage, theme)
{
HAnchor = HAnchor.Fit,
VAnchor = VAnchor.Fit,
Margin = new BorderDouble(15)
}, "Setup New Pulse".Localize()));
lastButton.Click += (s, e) => UiThread.RunOnIdle(() =>
{
DialogWindow.Show(PrinterSetup.GetBestStartPage(PrinterSetup.StartPageOptions.ShowPulseModels));
this.DialogWindow.Close();
});
ImageBuffer CreateButtonImage(string iconFile)
{
var printerImage = new ImageBuffer(borderImage);
graphics = printerImage.NewGraphics2D();
graphics.ImageRenderQuality = Graphics2D.TransformQuality.Best;
var imageWidth = bounds.Width * .8;
var printerIcon = StaticData.Instance.LoadIcon(iconFile).CropToVisible().SetToColor(theme.TextColor);
var offset = pulseImage.Width / 2 - imageWidth / 2;
graphics.RenderMaxSize(printerIcon, offset, offset, imageWidth, bounds.Height, out _);
return printerImage;
}
buttonRow.AddChild(AddButtonText(lastButton = new IconButton(CreateButtonImage("3d_printer.png"), theme)
{
HAnchor = HAnchor.Fit,
VAnchor = VAnchor.Fit,
Margin = new BorderDouble(15)
}, "Setup New Printer".Localize()));
lastButton.Click += (s, e) => UiThread.RunOnIdle(() =>
{
DialogWindow.Show(PrinterSetup.GetBestStartPage(PrinterSetup.StartPageOptions.ShowMakeModel));
this.DialogWindow.Close();
});
buttonRow.AddChild(AddButtonText(lastButton = new IconButton(CreateButtonImage("edit_design.png"), theme)
{
HAnchor = HAnchor.Fit,
VAnchor = VAnchor.Fit,
Margin = new BorderDouble(15)
}, "Start New Design".Localize()));
lastButton.Click += (s, e) => UiThread.RunOnIdle(() =>
{
LoadEmptyScene();
this.DialogWindow.Close();
});
contentRow.AddChild(buttonRow);
}
void LoadEmptyScene()
{
var history = ApplicationController.Instance.Library.PlatingHistory;
var workspace = new PartWorkspace(new BedConfig(history))
{
Name = "New Design".Localize()
};
// Load it up
workspace.SceneContext.LoadEmptyContent(
new EditContext()
{
ContentStore = history,
SourceItem = history.NewPlatingItem(workspace.SceneContext.Scene)
});
ApplicationController.Instance.MainTabKey = workspace.Name;
// Open but no need to save
ApplicationController.Instance.OpenWorkspace(workspace, WorkspacesChangedEventArgs.OperationType.Restore);
}
}
}

View file

@ -50,7 +50,7 @@ namespace MatterHackers.MatterControl.PrintLibrary
private Action<bool> nextButtonEnabled;
private FlowLayoutWidget printerInfo;
public AddPrinterWidget(ThemeConfig theme, Action<bool> nextButtonEnabled)
public AddPrinterWidget(ThemeConfig theme, Action<bool> nextButtonEnabled, bool filterToPulse)
: base(theme)
{
this.nextButtonEnabled = nextButtonEnabled;
@ -65,6 +65,10 @@ namespace MatterHackers.MatterControl.PrintLibrary
{
foreach (var oem in OemSettings.Instance.OemProfiles.OrderBy(o => o.Key))
{
if (filterToPulse && !oem.Key.Contains("Pulse"))
{
continue;
}
var rootNode = this.CreateTreeNode(oem);
rootNode.Expandable = true;
rootNode.TreeView = treeView;
@ -75,6 +79,11 @@ namespace MatterHackers.MatterControl.PrintLibrary
SetImage(rootNode, image);
};
if (filterToPulse)
{
rootNode.Expanded = true;
}
contentPanel.AddChild(rootNode);
}

View file

@ -74,6 +74,22 @@ namespace MatterHackers.MatterControl.PrintLibrary
mainRow.HAnchor = HAnchor.Stretch;
mainRow.AddChild(new HorizontalSpacer());
// add in the create pulse button
var createPulse = new IconButton(StaticData.Instance.LoadIcon("pulse_logo.png", 18, 18).SetToColor(theme.TextColor), theme)
{
Name = "Setup Pulse",
VAnchor = VAnchor.Center,
Margin = theme.ButtonSpacing.Clone(left: theme.ButtonSpacing.Right),
ToolTipText = "Create Pulse".Localize(),
Height = forcedHeight,
Width = forcedHeight
};
createPulse.Click += (s, e) => UiThread.RunOnIdle(() =>
{
DialogWindow.Show(PrinterSetup.GetBestStartPage(PrinterSetup.StartPageOptions.ShowPulseModels));
});
mainRow.AddChild(createPulse);
// add in the create printer button
var createPrinter = new IconButton(StaticData.Instance.LoadIcon("md-add-circle_18.png", 18, 18).SetToColor(theme.TextColor), theme)
{

View file

@ -963,7 +963,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
else if (ProfileManager.Instance.ActiveProfiles.Count() <= 0)
{
// If no printer profiles exist, show the printer setup wizard
var window = DialogWindow.Show(new SetupStepMakeModelName());
var window = DialogWindow.Show(new SetupStepMakeModelName(false));
window.Closed += (s2, e2) =>
{
if (ApplicationController.Instance.ActivePrinters.FirstOrDefault() is PrinterConfig printer

View file

@ -33,7 +33,13 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
{
public static class PrinterSetup
{
public enum StartPageOptions { Default, SkipWifiSetup, ShowMakeModel }
public enum StartPageOptions
{
Default,
SkipWifiSetup,
ShowMakeModel,
ShowPulseModels
}
public static DialogPage GetBestStartPage(StartPageOptions options = StartPageOptions.Default)
{
@ -46,7 +52,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
}
else
{
return new SetupStepMakeModelName();
return new SetupStepMakeModelName(options == StartPageOptions.ShowPulseModels);
}
}
}

View file

@ -45,7 +45,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
private readonly RadioButton createPrinterRadioButton = null;
private readonly RadioButton signInRadioButton;
public SetupStepMakeModelName()
public SetupStepMakeModelName(bool filterToPulse)
{
bool userIsLoggedIn = !ApplicationController.GuestUserActive?.Invoke() ?? false;
@ -58,7 +58,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
printerPanel = new AddPrinterWidget(theme, (enabled) =>
{
nextButton.Enabled = enabled;
})
}, filterToPulse)
{
HAnchor = HAnchor.Stretch,
VAnchor = VAnchor.Stretch

View file

@ -550,6 +550,9 @@ Translated:Count
English:count or mm
Translated:count or mm
English:Create An Account
Translated:Create An Account
English:Create Brim
Translated:Create Brim
@ -691,6 +694,9 @@ Translated:Disconnect
English:Disconnect from current printer
Translated:Disconnect from current printer
English:Disconnected
Translated:Disconnected
English:Dismiss
Translated:Dismiss
@ -706,6 +712,9 @@ Translated:Distance or Loops
English:Done
Translated:Done
English:Don't remind me again
Translated:Don't remind me again
English:Downloading
Translated:Downloading
@ -796,6 +805,12 @@ Translated:Enter Person Access Token
English:Enter Share Code
Translated:Enter Share Code
English:Enter your password
Translated:Enter your password
English:Enter your username or email address
Translated:Enter your username or email address
English:Estimated Cost
Translated:Estimated Cost
@ -1000,6 +1015,9 @@ Translated:Forces the printer to heat the nozzle before homing.
English:Forces the slicer to attempt to avoid having the perimeter line cross over existing perimeter lines. This can help with oozing or strings.
Translated:Forces the slicer to attempt to avoid having the perimeter line cross over existing perimeter lines. This can help with oozing or strings.
English:Forgot Password
Translated:Forgot Password
English:Forums
Translated:Forums
@ -1417,6 +1435,9 @@ Translated:Length of filament to extrude after a complete retraction (in additio
English:Length on Tool Change
Translated:Length on Tool Change
English:Let's show you around before you get started.
Translated:Let's show you around before you get started.
English:Letter
Translated:Letter
@ -1744,6 +1765,9 @@ Translated:New Design
English:New Printer Name
Translated:New Printer Name
English:New User?
Translated:New User?
English:Next
Translated:Next
@ -1909,6 +1933,9 @@ Translated:Part(s) to Subtract
English:Part(s) to Subtract and Replace
Translated:Part(s) to Subtract and Replace
English:Password
Translated:Password
English:Paste
Translated:Paste
@ -2440,6 +2467,9 @@ Translated:Serial port in use
English:Services
Translated:Services
English:Session Cleared
Translated:Session Cleared
English:Session Expired
Translated:Session Expired
@ -2464,9 +2494,24 @@ Translated:Settings Update Available
English:Settings View Options
Translated:Settings View Options
English:Setup
Translated:Setup
English:Setup Needs to be Run
Translated:Setup Needs to be Run
English:Setup New Printer
Translated:Setup New Printer
English:Setup New Pulse
Translated:Setup New Pulse
English:Setup Printer
Translated:Setup Printer
English:Setup Pulse
Translated:Setup Pulse
English:Setup Wizard
Translated:Setup Wizard
@ -2500,6 +2545,9 @@ Translated:Show in Explorer
English:Show Materials
Translated:Show Materials
English:Show Password
Translated:Show Password
English:Show Print Area
Translated:Show Print Area
@ -2524,6 +2572,21 @@ Translated:Shows a button at the right side of the Printer Connection Bar used t
English:Sides
Translated:Sides
English:sign in
Translated:sign in
English:Sign in
Translated:Sign in
English:Sign in to access your existing printers
Translated:Sign in to access your existing printers
English:Sign in to my account
Translated:Sign in to my account
English:Sign in to your MatterControl account
Translated:Sign in to your MatterControl account
English:Sign Out
Translated:Sign Out
@ -2623,6 +2686,9 @@ Translated:Start Height
English:Start Height Percent
Translated:Start Height Percent
English:Start New Design
Translated:Start New Design
English:Start Percent
Translated:Start Percent
@ -3286,6 +3352,9 @@ Translated:Update Settings
English:Update Settings...
Translated:Update Settings...
English:Upgrade
Translated:Upgrade
English:Use Automatic Z Probe
Translated:Use Automatic Z Probe
@ -3307,6 +3376,9 @@ Translated:Used to specify if more than one extruder share a common heater cartr
English:User Control
Translated:User Control
English:Username or Email
Translated:Username or Email
English:Utilize High Res Monitors
Translated:Utilize High Res Monitors
@ -3379,6 +3451,12 @@ Translated:WARNING: In order to perform print recovery, your printer must move d
English:Wedge
Translated:Wedge
English:Welcome to MatterControl
Translated:Welcome to MatterControl
English:Welcome to MatterControl! What would you like to do today?
Translated:Welcome to MatterControl! What would you like to do today?
English:Weld Edges
Translated:Weld Edges

@ -1 +1 @@
Subproject commit 03e836b4b1a85321ef1d33fc66c1e2b5f67134df
Subproject commit 90f586219ed8743e2e3a93e061a61fbd7cd33207