Making android not connect to unspecified printer
This commit is contained in:
parent
0d028a6429
commit
b522a47dbe
7 changed files with 112 additions and 132 deletions
|
|
@ -57,7 +57,7 @@ namespace MatterHackers.MatterControl
|
|||
// Add Child Elements
|
||||
if (UserSettings.Instance.DisplayMode == ApplicationDisplayType.Responsive)
|
||||
{
|
||||
this.AddChild(new ActionBar.PrinterActionRow());
|
||||
this.AddChild(new PrinterConnectAndSelectControl());
|
||||
}
|
||||
this.AddChild(PrintStatusRow.Create(queueDataView));
|
||||
this.Padding = new BorderDouble(bottom: 6);
|
||||
|
|
|
|||
|
|
@ -1,66 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2016, Lars Brubaker
|
||||
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.Agg.VertexSource;
|
||||
using System;
|
||||
|
||||
namespace MatterHackers.MatterControl.ActionBar
|
||||
{
|
||||
//Base widget for ActionBarRows
|
||||
public abstract class ActionRowBase : FlowLayoutWidget
|
||||
{
|
||||
public ActionRowBase()
|
||||
: base(FlowDirection.LeftToRight)
|
||||
{
|
||||
Initialize();
|
||||
SetDisplayAttributes();
|
||||
AddChildElements();
|
||||
AddHandlers();
|
||||
}
|
||||
|
||||
protected virtual void Initialize()
|
||||
{
|
||||
//Placeholder for row-specific initialization
|
||||
}
|
||||
|
||||
protected void SetDisplayAttributes()
|
||||
{
|
||||
this.HAnchor = HAnchor.ParentLeftRight;
|
||||
}
|
||||
|
||||
protected abstract void AddChildElements();
|
||||
|
||||
protected virtual void AddHandlers()
|
||||
{
|
||||
//Placeholder for row-specific handlers
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -46,10 +46,11 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace MatterHackers.MatterControl.ActionBar
|
||||
{
|
||||
internal class PrintActionRow : ActionRowBase
|
||||
internal class PrintActionRow : FlowLayoutWidget
|
||||
{
|
||||
private List<Button> activePrintButtons = new List<Button>();
|
||||
private Button addButton;
|
||||
|
|
@ -59,6 +60,8 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
private string cancelCurrentPrintMessage = "Cancel the current print?".Localize();
|
||||
private string cancelCurrentPrintTitle = "Cancel Print?".Localize();
|
||||
private Button connectButton;
|
||||
private Button addPrinterButton;
|
||||
private Button selectPrinterButton;
|
||||
private Button resetConnectionButton;
|
||||
private Button doneWithCurrentPartButton;
|
||||
private Button pauseButton;
|
||||
|
|
@ -74,7 +77,24 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
|
||||
public PrintActionRow(QueueDataView queueDataView)
|
||||
{
|
||||
this.HAnchor = HAnchor.ParentLeftRight;
|
||||
|
||||
textImageButtonFactory.normalTextColor = RGBA_Bytes.White;
|
||||
textImageButtonFactory.disabledTextColor = RGBA_Bytes.LightGray;
|
||||
textImageButtonFactory.hoverTextColor = RGBA_Bytes.White;
|
||||
textImageButtonFactory.pressedTextColor = RGBA_Bytes.White;
|
||||
textImageButtonFactory.AllowThemeToAdjustImage = false;
|
||||
|
||||
textImageButtonFactory.borderWidth = 1;
|
||||
textImageButtonFactory.FixedHeight = 52 * GuiWidget.DeviceScale;
|
||||
textImageButtonFactory.fontSize = 14;
|
||||
textImageButtonFactory.normalBorderColor = new RGBA_Bytes(255, 255, 255, 100);
|
||||
textImageButtonFactory.hoverBorderColor = new RGBA_Bytes(255, 255, 255, 100);
|
||||
|
||||
this.queueDataView = queueDataView;
|
||||
|
||||
AddChildElements();
|
||||
AddHandlers();
|
||||
}
|
||||
|
||||
private event EventHandler unregisterEvents;
|
||||
|
|
@ -93,7 +113,7 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
this.Invalidate();
|
||||
}
|
||||
|
||||
protected override void AddChildElements()
|
||||
protected void AddChildElements()
|
||||
{
|
||||
addButton = textImageButtonFactory.GenerateTooltipButton("Add".Localize(), StaticData.Instance.LoadIcon("icon_circle_plus.png",32,32).InvertLightness());
|
||||
addButton.ToolTipText = "Add a file to be printed".Localize();
|
||||
|
|
@ -111,12 +131,43 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
configureButton.Margin = new BorderDouble(6, 6, 6, 3);
|
||||
configureButton.Click += onStartButton_Click;
|
||||
|
||||
string connectButtonText = "Connect".Localize();
|
||||
string connectButtonMessage = "Connect to the printer".Localize();
|
||||
connectButton = textImageButtonFactory.GenerateTooltipButton(connectButtonText, StaticData.Instance.LoadIcon("icon_power_32x32.png",32,32).InvertLightness());
|
||||
connectButton.ToolTipText = connectButtonMessage;
|
||||
connectButton = textImageButtonFactory.GenerateTooltipButton("Connect".Localize(), StaticData.Instance.LoadIcon("icon_power_32x32.png",32,32).InvertLightness());
|
||||
connectButton.ToolTipText = "Connect to the printer".Localize();
|
||||
connectButton.Margin = new BorderDouble(6, 6, 6, 3);
|
||||
connectButton.Click += onConnectButton_Click;
|
||||
connectButton.Click += (s, e) =>
|
||||
{
|
||||
if (ActiveSliceSettings.Instance.PrinterSelected)
|
||||
{
|
||||
#if __ANDROID__
|
||||
if (!FrostedSerialPort.HasPermissionToDevice())
|
||||
{
|
||||
// Opens the USB device permissions dialog which will call back into our UsbDevice broadcast receiver to connect
|
||||
FrostedSerialPort.RequestPermissionToDevice(RunTroubleShooting);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
PrinterConnectionAndCommunication.Instance.HaltConnectionThread();
|
||||
PrinterConnectionAndCommunication.Instance.ConnectToActivePrinter(true);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
addPrinterButton = textImageButtonFactory.GenerateTooltipButton("Add Printer".Localize());
|
||||
addPrinterButton.ToolTipText = "Select and add a new printer.".Localize();
|
||||
addPrinterButton.Margin = new BorderDouble(6, 6, 6, 3);
|
||||
addPrinterButton.Click += (s, e) =>
|
||||
{
|
||||
UiThread.RunOnIdle(() => WizardWindow.ShowPrinterSetup(true));
|
||||
};
|
||||
|
||||
selectPrinterButton = textImageButtonFactory.GenerateTooltipButton("Select Printer".Localize());
|
||||
selectPrinterButton.ToolTipText = "Select an existing printer.".Localize();
|
||||
selectPrinterButton.Margin = new BorderDouble(6, 6, 6, 3);
|
||||
selectPrinterButton.Click += (s, e) =>
|
||||
{
|
||||
WizardWindow.Show<SetupOptionsPage>("/SetupOptions", "Setup Wizard");
|
||||
};
|
||||
|
||||
string resetConnectionButtontText = "Reset".Localize();
|
||||
string resetConnectionButtonMessage = "Reboots the firmware on the controller".Localize();
|
||||
|
|
@ -186,6 +237,12 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
this.AddChild(connectButton);
|
||||
allPrintButtons.Add(connectButton);
|
||||
|
||||
this.AddChild(addPrinterButton);
|
||||
allPrintButtons.Add(addPrinterButton);
|
||||
|
||||
this.AddChild(selectPrinterButton);
|
||||
allPrintButtons.Add(selectPrinterButton);
|
||||
|
||||
this.AddChild(addButton);
|
||||
allPrintButtons.Add(addButton);
|
||||
|
||||
|
|
@ -219,7 +276,7 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
SetButtonStates();
|
||||
}
|
||||
|
||||
protected override void AddHandlers()
|
||||
protected void AddHandlers()
|
||||
{
|
||||
PrinterConnectionAndCommunication.Instance.ActivePrintItemChanged.RegisterEvent(onStateChanged, ref unregisterEvents);
|
||||
PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent(onStateChanged, ref unregisterEvents);
|
||||
|
|
@ -250,21 +307,6 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
}
|
||||
}
|
||||
|
||||
protected override void Initialize()
|
||||
{
|
||||
textImageButtonFactory.normalTextColor = RGBA_Bytes.White;
|
||||
textImageButtonFactory.disabledTextColor = RGBA_Bytes.LightGray;
|
||||
textImageButtonFactory.hoverTextColor = RGBA_Bytes.White;
|
||||
textImageButtonFactory.pressedTextColor = RGBA_Bytes.White;
|
||||
textImageButtonFactory.AllowThemeToAdjustImage = false;
|
||||
|
||||
textImageButtonFactory.borderWidth = 1;
|
||||
textImageButtonFactory.FixedHeight = 52 * GuiWidget.DeviceScale;
|
||||
textImageButtonFactory.fontSize = 14;
|
||||
textImageButtonFactory.normalBorderColor = new RGBA_Bytes(255, 255, 255, 100);
|
||||
textImageButtonFactory.hoverBorderColor = new RGBA_Bytes(255, 255, 255, 100);
|
||||
}
|
||||
|
||||
protected Button makeButton(string buttonText, string buttonToolTip = "")
|
||||
{
|
||||
Button button = textImageButtonFactory.GenerateTooltipButton(buttonText);
|
||||
|
|
@ -280,9 +322,21 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
if (!PrinterConnectionAndCommunication.Instance.PrinterIsConnected
|
||||
&& PrinterConnectionAndCommunication.Instance.CommunicationState != PrinterConnectionAndCommunication.CommunicationStates.AttemptingToConnect)
|
||||
{
|
||||
if (UserSettings.Instance.IsTouchScreen)
|
||||
if (ProfileManager.Instance.Profiles.Count() == 0)
|
||||
{
|
||||
this.activePrintButtons.Add(connectButton);
|
||||
this.activePrintButtons.Add(addPrinterButton);
|
||||
}
|
||||
else if (UserSettings.Instance.IsTouchScreen)
|
||||
{
|
||||
// only on touch screen because desktop has a printer list and a connect button
|
||||
if (ActiveSliceSettings.Instance.PrinterSelected)
|
||||
{
|
||||
this.activePrintButtons.Add(connectButton);
|
||||
}
|
||||
else // no printer selected
|
||||
{
|
||||
this.activePrintButtons.Add(selectPrinterButton);
|
||||
}
|
||||
}
|
||||
ShowActiveButtons();
|
||||
EnableActiveButtons();
|
||||
|
|
@ -438,25 +492,6 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
UiThread.RunOnIdle(AddButtonOnIdle);
|
||||
}
|
||||
|
||||
private void onConnectButton_Click(object sender, EventArgs mouseEvent)
|
||||
{
|
||||
if (ActiveSliceSettings.Instance.PrinterSelected)
|
||||
{
|
||||
#if __ANDROID__
|
||||
if (!FrostedSerialPort.HasPermissionToDevice())
|
||||
{
|
||||
// Opens the USB device permissions dialog which will call back into our UsbDevice broadcast receiver to connect
|
||||
FrostedSerialPort.RequestPermissionToDevice(RunTroubleShooting);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
PrinterConnectionAndCommunication.Instance.HaltConnectionThread();
|
||||
PrinterConnectionAndCommunication.Instance.ConnectToActivePrinter(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RunTroubleShooting()
|
||||
{
|
||||
WizardWindow.Show<SetupWizardTroubleshooting>("TroubleShooting", "Trouble Shooting");
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace MatterHackers.MatterControl.ActionBar
|
||||
{
|
||||
public class PrinterActionRow : ActionRowBase
|
||||
public class PrinterConnectAndSelectControl : FlowLayoutWidget
|
||||
{
|
||||
private TextImageButtonFactory actionBarButtonFactory = new TextImageButtonFactory();
|
||||
private Button connectPrinterButton;
|
||||
|
|
@ -55,13 +55,34 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
private event EventHandler unregisterEvents;
|
||||
static EventHandler staticUnregisterEvents;
|
||||
|
||||
public PrinterConnectAndSelectControl()
|
||||
{
|
||||
this.HAnchor = HAnchor.ParentLeftRight;
|
||||
|
||||
actionBarButtonFactory.normalTextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
actionBarButtonFactory.hoverTextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
actionBarButtonFactory.pressedTextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
|
||||
actionBarButtonFactory.disabledTextColor = ActiveTheme.Instance.TabLabelUnselected;
|
||||
actionBarButtonFactory.disabledFillColor = ActiveTheme.Instance.PrimaryBackgroundColor;
|
||||
actionBarButtonFactory.disabledBorderColor = ActiveTheme.Instance.PrimaryBackgroundColor;
|
||||
|
||||
actionBarButtonFactory.hoverFillColor = ActiveTheme.Instance.PrimaryBackgroundColor;
|
||||
|
||||
actionBarButtonFactory.invertImageLocation = true;
|
||||
actionBarButtonFactory.borderWidth = 0;
|
||||
this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
|
||||
|
||||
AddChildElements();
|
||||
}
|
||||
|
||||
public override void OnClosed(EventArgs e)
|
||||
{
|
||||
unregisterEvents?.Invoke(this, null);
|
||||
base.OnClosed(e);
|
||||
}
|
||||
|
||||
protected override void AddChildElements()
|
||||
protected void AddChildElements()
|
||||
{
|
||||
actionBarButtonFactory.invertImageLocation = false;
|
||||
actionBarButtonFactory.borderWidth = 1;
|
||||
|
|
@ -205,23 +226,6 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents);
|
||||
}
|
||||
|
||||
protected override void Initialize()
|
||||
{
|
||||
actionBarButtonFactory.normalTextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
actionBarButtonFactory.hoverTextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
actionBarButtonFactory.pressedTextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
|
||||
actionBarButtonFactory.disabledTextColor = ActiveTheme.Instance.TabLabelUnselected;
|
||||
actionBarButtonFactory.disabledFillColor = ActiveTheme.Instance.PrimaryBackgroundColor;
|
||||
actionBarButtonFactory.disabledBorderColor = ActiveTheme.Instance.PrimaryBackgroundColor;
|
||||
|
||||
actionBarButtonFactory.hoverFillColor = ActiveTheme.Instance.PrimaryBackgroundColor;
|
||||
|
||||
actionBarButtonFactory.invertImageLocation = true;
|
||||
actionBarButtonFactory.borderWidth = 0;
|
||||
this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
|
||||
}
|
||||
|
||||
static public void UserRequestedConnectToActivePrinter()
|
||||
{
|
||||
if (staticUnregisterEvents != null)
|
||||
|
|
@ -126,12 +126,11 @@
|
|||
<Compile Include="AboutPage\UpdateControlData.cs" />
|
||||
<Compile Include="AboutPage\UpdateControlView.cs" />
|
||||
<Compile Include="AboutPage\HTMLParser\HtmlParser.cs" />
|
||||
<Compile Include="ActionBar\ActionRowBase.cs" />
|
||||
<Compile Include="ActionBar\ActionBarPlus.cs" />
|
||||
<Compile Include="ActionBar\PrinterSelector.cs" />
|
||||
<Compile Include="ActionBar\TemperatureWidgetBed.cs" />
|
||||
<Compile Include="ActionBar\PrintActionRow.cs" />
|
||||
<Compile Include="ActionBar\PrinterActionRow.cs" />
|
||||
<Compile Include="ActionBar\PrinterConnectAndSelectControl.cs" />
|
||||
<Compile Include="ActionBar\PrintStatusRow.cs" />
|
||||
<Compile Include="ActionBar\TemperatureWidgetBase.cs" />
|
||||
<Compile Include="ActionBar\TemperatureWidgetExtruder.cs" />
|
||||
|
|
|
|||
|
|
@ -5449,3 +5449,9 @@ Translated:It's time to migrate your existing printer settings to your MatterHac
|
|||
English:Migrate Printers to Account
|
||||
Translated:Migrate Printers to Account
|
||||
|
||||
English:Select and add a new printer.
|
||||
Translated:Select and add a new printer.
|
||||
|
||||
English:Select an existing printer.
|
||||
Translated:Select an existing printer.
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ using NUnit.Framework;
|
|||
|
||||
namespace MatterHackers.MatterControl.Slicing.Tests
|
||||
{
|
||||
#if !__ANDROID__
|
||||
[TestFixture, Category("MatterControl.Slicing")]
|
||||
public class SliceLayersTests
|
||||
{
|
||||
|
|
@ -73,4 +74,5 @@ namespace MatterHackers.MatterControl.Slicing.Tests
|
|||
Assert.IsTrue(layers.AllLayers.Count == 99);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue