Working on the Hadware page
This commit is contained in:
parent
3fee869824
commit
e532b3c465
16 changed files with 181 additions and 38 deletions
|
|
@ -33,6 +33,7 @@ using MatterHackers.Agg;
|
|||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.CustomWidgets;
|
||||
using MatterHackers.MatterControl.Library.Widgets.HardwarePage;
|
||||
using MatterHackers.MatterControl.PartPreviewWindow;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
|
||||
|
|
@ -28,23 +28,33 @@ either expressed or implied, of the FreeBSD Project.
|
|||
*/
|
||||
|
||||
|
||||
using Markdig.Agg;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.Image;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.Agg.VertexSource;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.CustomWidgets;
|
||||
using MatterHackers.MatterControl.SettingsManagement;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MatterHackers.MatterControl.PrintLibrary
|
||||
namespace MatterHackers.MatterControl.Library.Widgets.HardwarePage
|
||||
{
|
||||
public class PrinterDetails : FlowLayoutWidget
|
||||
{
|
||||
private ThemeConfig theme;
|
||||
private PrinterInfo printerInfo;
|
||||
|
||||
public PrinterDetails(PrinterInfo printerInfo, ThemeConfig theme)
|
||||
: base (FlowDirection.TopToBottom)
|
||||
: base(FlowDirection.TopToBottom)
|
||||
{
|
||||
this.printerInfo = printerInfo;
|
||||
this.theme = theme;
|
||||
|
||||
var headingRow = this.AddHeading(
|
||||
|
|
@ -66,44 +76,116 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
|
||||
|
||||
this.AddChild(headingRow);
|
||||
}
|
||||
|
||||
GuiWidget row;
|
||||
|
||||
row = this.AddHeading("Parts & Accessories");
|
||||
row.Margin = row.Margin.Clone(top: 20);
|
||||
this.AddChild(row);
|
||||
|
||||
if (printerInfo.Make == "BCN")
|
||||
public override async void OnLoad(EventArgs args)
|
||||
{
|
||||
if (File.Exists(printerInfo.ProfilePath))
|
||||
{
|
||||
var accessoriesImage = new ImageBuffer();
|
||||
row = new ImageWidget(accessoriesImage);
|
||||
this.AddChild(row);
|
||||
// load up the printer profile so we can get the MatterHackers Skew-ID out of it
|
||||
var profile = PrinterSettings.LoadFile(printerInfo.ProfilePath);
|
||||
|
||||
ApplicationController.Instance.LoadRemoteImage(accessoriesImage, "https://i.imgur.com/io37z8h.png", false).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
row = this.AddHeading("Upgrades");
|
||||
row.Margin = row.Margin.Clone(top: 20);
|
||||
this.AddChild(row);
|
||||
|
||||
var upgradesImage = new ImageBuffer();
|
||||
row = new ImageWidget(upgradesImage);
|
||||
this.AddChild(row);
|
||||
|
||||
ApplicationController.Instance.LoadRemoteImage(upgradesImage, "https://i.imgur.com/kDiV2Da.png", false).ConfigureAwait(false);
|
||||
|
||||
|
||||
if (printerInfo.Make == "BCN")
|
||||
{
|
||||
var accessoriesImage = new ImageBuffer();
|
||||
row = new ImageWidget(accessoriesImage)
|
||||
// if there is a SID than get the data from that url and display it
|
||||
var sid = profile.GetValue(SettingsKey.matterhackers_sid);
|
||||
if (!string.IsNullOrWhiteSpace(sid))
|
||||
{
|
||||
Margin = new BorderDouble(top: 30)
|
||||
};
|
||||
this.AddChild(row);
|
||||
var product = (await LoadProductData(sid)).ProductSku;
|
||||
// put in controls from the feed that show relevant printer information
|
||||
|
||||
ApplicationController.Instance.LoadRemoteImage(accessoriesImage, "https://i.imgur.com/rrEwKY9.png", false).ConfigureAwait(false);
|
||||
GuiWidget row;
|
||||
row = this.AddHeading("Description".Localize() + ":");
|
||||
row.Margin = row.Margin.Clone(top: 20);
|
||||
this.AddChild(row);
|
||||
|
||||
var descriptionBackground = new GuiWidget()
|
||||
{
|
||||
HAnchor = HAnchor.Stretch,
|
||||
VAnchor = VAnchor.Fit
|
||||
};
|
||||
|
||||
var image = new ImageBuffer();
|
||||
this.AddChild(new ImageWidget(image));
|
||||
|
||||
ApplicationController.Instance.DownloadToImageAsync(image, product.FeaturedImage.ImageUrl, false);
|
||||
|
||||
var description = new MarkdownWidget(theme)
|
||||
{
|
||||
MinimumSize = new VectorMath.Vector2(350, 0),
|
||||
HAnchor = HAnchor.Stretch,
|
||||
VAnchor = VAnchor.Fit,
|
||||
Margin = new BorderDouble(5),
|
||||
Markdown = product.ProductDescription.Trim()
|
||||
};
|
||||
descriptionBackground.AddChild(description);
|
||||
|
||||
descriptionBackground.BeforeDraw += (s, e) =>
|
||||
{
|
||||
var rect = new RoundedRect(descriptionBackground.LocalBounds, 3);
|
||||
e.Graphics2D.Render(rect, theme.SlightShade);
|
||||
};
|
||||
|
||||
this.AddChild(descriptionBackground);
|
||||
}
|
||||
else // show some test data
|
||||
{
|
||||
GuiWidget row;
|
||||
row = this.AddHeading("Parts & Accessories");
|
||||
row.Margin = row.Margin.Clone(top: 20);
|
||||
this.AddChild(row);
|
||||
|
||||
if (printerInfo.Make == "BCN")
|
||||
{
|
||||
var accessoriesImage = new ImageBuffer();
|
||||
row = new ImageWidget(accessoriesImage);
|
||||
this.AddChild(row);
|
||||
|
||||
ApplicationController.Instance.LoadRemoteImage(accessoriesImage, "https://i.imgur.com/io37z8h.png", false).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
row = this.AddHeading("Upgrades");
|
||||
row.Margin = row.Margin.Clone(top: 20);
|
||||
this.AddChild(row);
|
||||
|
||||
var upgradesImage = new ImageBuffer();
|
||||
row = new ImageWidget(upgradesImage);
|
||||
this.AddChild(row);
|
||||
|
||||
ApplicationController.Instance.LoadRemoteImage(upgradesImage, "https://i.imgur.com/kDiV2Da.png", false).ConfigureAwait(false);
|
||||
|
||||
|
||||
if (printerInfo.Make == "BCN")
|
||||
{
|
||||
var accessoriesImage = new ImageBuffer();
|
||||
row = new ImageWidget(accessoriesImage)
|
||||
{
|
||||
Margin = new BorderDouble(top: 30)
|
||||
};
|
||||
this.AddChild(row);
|
||||
|
||||
ApplicationController.Instance.LoadRemoteImage(accessoriesImage, "https://i.imgur.com/rrEwKY9.png", false).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
base.OnLoad(args);
|
||||
}
|
||||
|
||||
public async Task<ProductSidData> LoadProductData(string sid)
|
||||
{
|
||||
try
|
||||
{
|
||||
var client = new HttpClient();
|
||||
string json = await client.GetStringAsync($"https://mh-pls-prod.appspot.com/p/1/product-sid/{sid}?IncludeListingData=True");
|
||||
|
||||
var result = JsonConvert.DeserializeObject<ProductSidData>(json);
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Trace.WriteLine("Error collecting or loading printer details: " + ex.Message);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void SwitchPrinters(string printerID)
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
namespace MatterHackers.MatterControl.Library.Widgets.HardwarePage
|
||||
{
|
||||
public class ProductSidData
|
||||
{
|
||||
public ProductSkuData ProductSku;
|
||||
}
|
||||
|
||||
public class ProductSkuData
|
||||
{
|
||||
public string ProductDescription;
|
||||
public string ReferenceUrl;
|
||||
public string SkuName;
|
||||
public string Status;
|
||||
public FeaturedImage FeaturedImage;
|
||||
}
|
||||
|
||||
public class FeaturedImage
|
||||
{
|
||||
public string ImageUrl;
|
||||
}
|
||||
}
|
||||
|
|
@ -105,8 +105,10 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
public const string layer_height = nameof(layer_height);
|
||||
public const string layer_name = nameof(layer_name);
|
||||
public const string layer_to_pause = nameof(layer_to_pause);
|
||||
public const string load_filament_length = nameof(load_filament_length);
|
||||
public const string make = nameof(make);
|
||||
public const string manual_movement_speeds = nameof(manual_movement_speeds);
|
||||
public const string matterhackers_sid = nameof(matterhackers_sid);
|
||||
public const string max_acceleration = nameof(max_acceleration);
|
||||
public const string max_velocity = nameof(max_velocity);
|
||||
public const string merge_overlapping_lines = nameof(merge_overlapping_lines);
|
||||
|
|
|
|||
|
|
@ -113,12 +113,13 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
SettingsKey.ip_address,
|
||||
SettingsKey.ip_port,
|
||||
SettingsKey.progress_reporting,
|
||||
"load_filament_length",
|
||||
SettingsKey.load_filament_length,
|
||||
"trim_filament_markdown",
|
||||
"insert_filament_markdown",
|
||||
"running_clean_markdown",
|
||||
"unload_filament_length",
|
||||
"load_filament_speed",
|
||||
SettingsKey.matterhackers_sid,
|
||||
};
|
||||
|
||||
public List<MappedSetting> MappedSettings { get; private set; }
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
new MappedSetting("max_fan_speed","max_fan_speed"),
|
||||
new MappedSetting("min_fan_speed","min_fan_speed"),
|
||||
new MappedSetting("retract_length","retract_length"),
|
||||
new LoadTimeFromSpeedAndLength("load_filament_time", "load_filament_length", "load_filament_speed"),
|
||||
new LoadTimeFromSpeedAndLength("load_filament_time", SettingsKey.load_filament_length, "load_filament_speed"),
|
||||
new LoadTimeFromSpeedAndLength("unload_filament_time", "unload_filament_length", "load_filament_speed"),
|
||||
new MappedSetting(SettingsKey.temperature,SettingsKey.temperature),
|
||||
new MappedSetting("z_offset","z_offset"),
|
||||
|
|
@ -66,7 +66,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
new ScaledSingleNumber("retract_speed","retract_speed", 60),
|
||||
new ScaledSingleNumber("support_material_speed","support_material_speed", 60),
|
||||
new ScaledSingleNumber("travel_speed", "travel_speed", 60),
|
||||
new AsPercentOfReferenceOrDirect("load_filament_length_over_six", "", "load_filament_length", 1.0/6.0, false),
|
||||
new AsPercentOfReferenceOrDirect("load_filament_length_over_six", "", SettingsKey.load_filament_length, 1.0/6.0, false),
|
||||
new AsPercentOfReferenceOrDirect("unload_filament_length_over_six", "", "unload_filament_length", 1.0/6.0, false),
|
||||
new ScaledSingleNumber("load_filament_speed", "load_filament_speed", 60),
|
||||
new MappedSetting("trim_filament_markdown", "trim_filament_markdown"),
|
||||
|
|
|
|||
|
|
@ -213,7 +213,7 @@ Printer
|
|||
trim_filament_markdown
|
||||
insert_filament_markdown
|
||||
running_clean_markdown
|
||||
|
||||
matterhackers_sid
|
||||
G-Code
|
||||
G-Code
|
||||
G-Code
|
||||
|
|
|
|||
|
|
@ -120,6 +120,13 @@
|
|||
"ShowIfSet": "!sla_printer",
|
||||
"DefaultValue": "In a few seconds filament should be coming out of the extruder\n* Wait for the new filament to be coming out with no trace of the previous filament\n* Click 'Continue' when the new filament is running cleanly\n## Success! Your new filament should now be loaded"
|
||||
},
|
||||
{
|
||||
"SlicerConfigName": "matterhackers_sid",
|
||||
"PresentationName": "MatterHackers Sku-ID",
|
||||
"HelpText": "The identification used on MatterHackers.com for this product. This will allow detailed information to show up on the printer page.",
|
||||
"DataEditType": "STRING",
|
||||
"DefaultValue": ""
|
||||
},
|
||||
{
|
||||
"SlicerConfigName": "bottom_solid_layers",
|
||||
"PresentationName": "Bottom Solid Layers",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue