public override async void OnLoad(EventArgs args) { if (File.Exists(printerInfo.ProfilePath)) { // load up the printer profile so we can get the MatterHackers Skew-ID out of it var printerSettings = PrinterSettings.LoadFile(printerInfo.ProfilePath); // Get the printer sid from settings string storeID = null; // Use the make-model mapping table if (OemSettings.Instance.OemPrinters.TryGetValue($"{printerInfo.Make}-{ printerInfo.Model}", out StorePrinterID storePrinterID)) { storeID = storePrinterID?.SID; } if (!string.IsNullOrWhiteSpace(storeID)) { var product = (await LoadProductData(storeID)).ProductSku; // put in controls from the feed that show relevant printer information var row = new FlowLayoutWidget() { HAnchor = HAnchor.Stretch, Margin = new BorderDouble(top: theme.DefaultContainerPadding) }; this.AddChild(row); var image = new ImageBuffer(150, 10); row.AddChild(new ImageWidget(image) { Margin = new BorderDouble(right: theme.DefaultContainerPadding), VAnchor = VAnchor.Top }); ApplicationController.Instance.DownloadToImageAsync(image, product.FeaturedImage.ImageUrl, scaleToImageX: true); var descriptionBackground = new GuiWidget() { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit | VAnchor.Top, Padding = theme.DefaultContainerPadding }; var description = new MarkdownWidget(theme) { MinimumSize = new VectorMath.Vector2(350, 0), HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, Markdown = product.ProductDescription.Trim() }; descriptionBackground.AddChild(description); descriptionBackground.BeforeDraw += (s, e) => { var rect = new RoundedRect(descriptionBackground.LocalBounds, 3); e.Graphics2D.Render(rect, theme.SlightShade); }; row.AddChild(descriptionBackground); var padding = theme.DefaultContainerPadding; var addonsColumn = new FlowLayoutWidget(FlowDirection.TopToBottom) { Padding = new BorderDouble(padding, padding, padding, 0), HAnchor = HAnchor.Stretch }; var addonsSection = new SectionWidget("Upgrades and Accessories", addonsColumn, theme); this.AddChild(addonsSection); theme.ApplyBoxStyle(addonsSection); addonsSection.Margin = addonsSection.Margin.Clone(left: 0); foreach (var item in product.ProductListing.AddOns) { var icon = new ImageBuffer(80, 0); ApplicationController.Instance.DownloadToImageAsync(icon, item.FeaturedImage.ImageUrl, scaleToImageX: true); var addOnRow = new AddOnRow(item.AddOnTitle, theme, null, icon) { HAnchor = HAnchor.Stretch, Cursor = Cursors.Hand }; foreach (var child in addOnRow.Children) { child.Selectable = false; } addOnRow.Click += (s, e) => { ApplicationController.Instance.LaunchBrowser($"https://www.matterhackers.com/store/l/{item.AddOnListingReference}/sk/{item.AddOnSkuReference}"); }; addonsColumn.AddChild(addOnRow); } if (false) { var settingsPanel = new GuiWidget() { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch, MinimumSize = new VectorMath.Vector2(20, 20), DebugShowBounds = true }; settingsPanel.Load += (s, e) => { var printer = new PrinterConfig(printerSettings); var settingsContext = new SettingsContext( printer, null, NamedSettingsLayers.All); settingsPanel.AddChild( new ConfigurePrinterWidget(settingsContext, printer, theme) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch, }); }; this.AddChild(new SectionWidget("Settings", settingsPanel, theme, expanded: false, setContentVAnchor: false) { VAnchor = VAnchor.Stretch }); } } } base.OnLoad(args); }
//private void CreateProductDataWidgets(PrinterSettings printerSettings, ProductSkuData product) private void CreateProductDataWidgets(ProductSkuData product) { var row = new FlowLayoutWidget() { HAnchor = HAnchor.Stretch, Margin = new BorderDouble(top: theme.DefaultContainerPadding) }; productDataContainer.AddChild(row); var image = new ImageBuffer(150, 10); row.AddChild(new ImageWidget(image) { Margin = new BorderDouble(right: theme.DefaultContainerPadding), VAnchor = VAnchor.Top }); WebCache.RetrieveImageAsync(image, product.FeaturedImage.ImageUrl, scaleToImageX: true); var descriptionBackground = new GuiWidget() { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit | VAnchor.Top, Padding = theme.DefaultContainerPadding }; var description = new MarkdownWidget(theme) { MinimumSize = new VectorMath.Vector2(50, 0), HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, AutoScroll = false, Markdown = product.ProductDescription.Trim() }; descriptionBackground.AddChild(description); descriptionBackground.BeforeDraw += (s, e) => { var rect = new RoundedRect(descriptionBackground.LocalBounds, 3); e.Graphics2D.Render(rect, theme.SlightShade); }; row.AddChild(descriptionBackground); if (this.ShowProducts) { var padding = theme.DefaultContainerPadding; var addonsColumn = new FlowLayoutWidget(FlowDirection.TopToBottom) { Padding = new BorderDouble(padding, padding, padding, 0), HAnchor = HAnchor.Stretch }; var addonsSection = new SectionWidget("Upgrades and Accessories", addonsColumn, theme); productDataContainer.AddChild(addonsSection); theme.ApplyBoxStyle(addonsSection); addonsSection.Margin = addonsSection.Margin.Clone(left: 0); foreach (var item in product.ProductListing.AddOns) { var addOnRow = new AddOnRow(item.AddOnTitle, theme, null, item.Icon) { HAnchor = HAnchor.Stretch, Cursor = Cursors.Hand }; foreach (var child in addOnRow.Children) { child.Selectable = false; } addOnRow.Click += (s, e) => { ApplicationController.LaunchBrowser($"https://www.matterhackers.com/store/l/{item.AddOnListingReference}/sk/{item.AddOnSkuReference}"); }; addonsColumn.AddChild(addOnRow); } } //if (false) //{ // var settingsPanel = new GuiWidget() // { // HAnchor = HAnchor.Stretch, // VAnchor = VAnchor.Stretch, // MinimumSize = new VectorMath.Vector2(20, 20), // DebugShowBounds = true // }; // settingsPanel.Load += (s, e) => // { // var printer = new PrinterConfig(printerSettings); // var settingsContext = new SettingsContext( // printer, // null, // NamedSettingsLayers.All); // settingsPanel.AddChild( // new ConfigurePrinterWidget(settingsContext, printer, theme) // { // HAnchor = HAnchor.Stretch, // VAnchor = VAnchor.Stretch, // }); // }; // this.AddChild(new SectionWidget("Settings", settingsPanel, theme, expanded: false, setContentVAnchor: false) // { // VAnchor = VAnchor.Stretch // }); //} }