2020-10-04 10:57:55 -07:00
|
|
|
|
/*
|
|
|
|
|
|
Copyright (c) 2020, Kevin Pope, John Lewin, 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 System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using Markdig.Agg;
|
|
|
|
|
|
using MatterHackers.Agg;
|
2020-10-25 23:11:59 -07:00
|
|
|
|
using MatterHackers.Agg.Platform;
|
2020-10-04 10:57:55 -07:00
|
|
|
|
using MatterHackers.Agg.UI;
|
|
|
|
|
|
using MatterHackers.Localizations;
|
|
|
|
|
|
using MatterHackers.MatterControl.DataStorage;
|
|
|
|
|
|
using MatterHackers.MatterControl.PartPreviewWindow;
|
2020-10-26 16:40:36 -07:00
|
|
|
|
using MatterHackers.MatterControl.SlicerConfiguration;
|
2020-10-04 10:57:55 -07:00
|
|
|
|
using MatterHackers.VectorMath;
|
|
|
|
|
|
|
|
|
|
|
|
namespace MatterHackers.MatterControl.PrintHistory
|
|
|
|
|
|
{
|
|
|
|
|
|
public class PrintHistoryEditor
|
|
|
|
|
|
{
|
2020-10-25 15:45:51 -07:00
|
|
|
|
private readonly PrinterConfig printer;
|
2020-10-25 08:48:43 -07:00
|
|
|
|
private readonly ThemeConfig theme;
|
|
|
|
|
|
private readonly PrintTask printTask;
|
|
|
|
|
|
private readonly IEnumerable<PrintTask> printTasks;
|
2020-10-04 10:57:55 -07:00
|
|
|
|
|
2020-10-25 15:45:51 -07:00
|
|
|
|
public PrintHistoryEditor(PrinterConfig printer, ThemeConfig theme, PrintTask printTask, IEnumerable<PrintTask> printTasks)
|
2020-10-04 10:57:55 -07:00
|
|
|
|
{
|
2020-10-25 15:45:51 -07:00
|
|
|
|
this.printer = printer;
|
2020-10-04 10:57:55 -07:00
|
|
|
|
this.theme = theme;
|
|
|
|
|
|
this.printTask = printTask;
|
|
|
|
|
|
this.printTasks = printTasks;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static readonly string[] QualityNames = new string[]
|
|
|
|
|
|
{
|
|
|
|
|
|
"Failed".Localize(),
|
|
|
|
|
|
"Terrible".Localize(),
|
|
|
|
|
|
"Bad".Localize(),
|
|
|
|
|
|
"Good".Localize(),
|
|
|
|
|
|
"Great".Localize(),
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
public void AddNotesMenu(PopupMenu popupMenu, IEnumerable<PrintTask> printTasks, Action notesChanged)
|
|
|
|
|
|
{
|
2020-10-26 11:25:18 -07:00
|
|
|
|
var addNote = popupMenu.CreateMenuItem(string.IsNullOrEmpty(printTask.Note) ? "Add Note...".Localize() : "Edit Note...".Localize());
|
|
|
|
|
|
addNote.Enabled = printTasks.Any();
|
|
|
|
|
|
addNote.Click += (s, e) =>
|
2020-10-04 10:57:55 -07:00
|
|
|
|
{
|
|
|
|
|
|
var inputBoxPage = new InputBoxPage(
|
|
|
|
|
|
"Print History Note".Localize(),
|
2020-10-26 16:40:36 -07:00
|
|
|
|
"",
|
2020-10-25 08:48:43 -07:00
|
|
|
|
printTask.Note ?? "",
|
2020-10-04 10:57:55 -07:00
|
|
|
|
"Enter Note Here".Localize(),
|
|
|
|
|
|
string.IsNullOrEmpty(printTask.Note) ? "Add Note".Localize() : "Update".Localize(),
|
|
|
|
|
|
(newNote) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
printTask.Note = newNote;
|
2020-10-23 16:57:26 -07:00
|
|
|
|
printTask.CommitAndPushToServer();
|
2020-10-04 10:57:55 -07:00
|
|
|
|
popupMenu.Unfocus();
|
|
|
|
|
|
notesChanged();
|
|
|
|
|
|
})
|
|
|
|
|
|
{
|
|
|
|
|
|
AllowEmpty = true,
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2020-10-26 16:40:36 -07:00
|
|
|
|
inputBoxPage.ContentRow.AddChild(CreateDefaultOptions(inputBoxPage.TextEditWidget, theme), 0);
|
2020-10-04 10:57:55 -07:00
|
|
|
|
|
|
|
|
|
|
DialogWindow.Show(inputBoxPage);
|
|
|
|
|
|
|
|
|
|
|
|
inputBoxPage.Parent.Height += 40 * GuiWidget.DeviceScale;
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-10-06 22:00:28 -07:00
|
|
|
|
public static GuiWidget GetQualityWidget(ThemeConfig theme, PrintTask printTask, Action clicked, double buttonFontSize)
|
2020-10-04 10:57:55 -07:00
|
|
|
|
{
|
|
|
|
|
|
var content = new FlowLayoutWidget()
|
|
|
|
|
|
{
|
|
|
|
|
|
HAnchor = HAnchor.Fit | HAnchor.Stretch
|
|
|
|
|
|
};
|
2020-10-30 07:48:25 -07:00
|
|
|
|
var siblings = new List<GuiWidget>();
|
2020-10-04 10:57:55 -07:00
|
|
|
|
|
2020-10-25 15:45:51 -07:00
|
|
|
|
var textWidget = new TextWidget("Print Quality".Localize() + ":", pointSize: theme.DefaultFontSize, textColor: theme.TextColor)
|
|
|
|
|
|
{
|
|
|
|
|
|
VAnchor = VAnchor.Center
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2020-10-04 10:57:55 -07:00
|
|
|
|
content.AddChild(textWidget);
|
|
|
|
|
|
|
2020-10-25 23:11:59 -07:00
|
|
|
|
var size = (int)(buttonFontSize * GuiWidget.DeviceScale);
|
|
|
|
|
|
|
|
|
|
|
|
var star = AggContext.StaticData.LoadIcon("star.png", size, size, theme.InvertIcons);
|
2020-10-30 07:48:25 -07:00
|
|
|
|
var openStar = AggContext.StaticData.LoadIcon("open_star.png", size, size, theme.InvertIcons);
|
2020-10-25 23:11:59 -07:00
|
|
|
|
var failure = AggContext.StaticData.LoadIcon("failure.png", size, size, theme.InvertIcons);
|
|
|
|
|
|
|
|
|
|
|
|
content.AddChild(new GuiWidget(size, 1));
|
2020-10-04 10:57:55 -07:00
|
|
|
|
|
2020-10-30 07:48:25 -07:00
|
|
|
|
content.MouseLeaveBounds += (s, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
SetStarState(theme, siblings, printTask);
|
|
|
|
|
|
};
|
2020-10-04 10:57:55 -07:00
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < QualityNames.Length; i++)
|
|
|
|
|
|
{
|
2020-10-30 07:48:25 -07:00
|
|
|
|
var buttonIndex = i;
|
|
|
|
|
|
GuiWidget buttonContent;
|
|
|
|
|
|
if (i == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
buttonContent = new ImageWidget(failure);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
buttonContent = new GuiWidget()
|
|
|
|
|
|
{
|
|
|
|
|
|
HAnchor = HAnchor.Fit,
|
|
|
|
|
|
VAnchor = VAnchor.Fit
|
|
|
|
|
|
};
|
|
|
|
|
|
buttonContent.AddChild(new ImageWidget(openStar)
|
|
|
|
|
|
{
|
|
|
|
|
|
Name = "open"
|
|
|
|
|
|
});
|
|
|
|
|
|
buttonContent.AddChild(new ImageWidget(star)
|
|
|
|
|
|
{
|
|
|
|
|
|
Name = "closed",
|
|
|
|
|
|
Visible = false
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var button = new RadioButton(buttonContent)
|
2020-10-04 10:57:55 -07:00
|
|
|
|
{
|
|
|
|
|
|
Enabled = printTask.PrintComplete,
|
|
|
|
|
|
Checked = printTask.QualityWasSet && printTask.PrintQuality == i,
|
|
|
|
|
|
ToolTipText = QualityNames[i],
|
|
|
|
|
|
Margin = 0,
|
|
|
|
|
|
Padding = 5,
|
|
|
|
|
|
HAnchor = HAnchor.Fit,
|
|
|
|
|
|
VAnchor = VAnchor.Fit,
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
button.MouseEnterBounds += (s, e) =>
|
|
|
|
|
|
{
|
2020-10-30 07:48:25 -07:00
|
|
|
|
// set the correct filled stars for the hover
|
|
|
|
|
|
for (int j = 0; j < siblings.Count; j++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var open = siblings[j].Descendants().Where(d => d.Name == "open").FirstOrDefault();
|
|
|
|
|
|
var closed = siblings[j].Descendants().Where(d => d.Name == "closed").FirstOrDefault();
|
2020-10-04 10:57:55 -07:00
|
|
|
|
|
2020-10-30 07:48:25 -07:00
|
|
|
|
if (j == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (buttonIndex == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
siblings[j].BackgroundColor = theme.AccentMimimalOverlay;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
siblings[j].BackgroundColor = Color.Transparent;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (j <= buttonIndex)
|
|
|
|
|
|
{
|
|
|
|
|
|
siblings[j].BackgroundColor = theme.AccentMimimalOverlay;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
siblings[j].BackgroundColor = Color.Transparent;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (j <= buttonIndex)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (open != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
open.Visible = false;
|
|
|
|
|
|
closed.Visible = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (open != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
open.Visible = true;
|
|
|
|
|
|
closed.Visible = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2020-10-04 10:57:55 -07:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
siblings.Add(button);
|
|
|
|
|
|
|
|
|
|
|
|
button.SiblingRadioButtonList = siblings;
|
|
|
|
|
|
|
|
|
|
|
|
content.AddChild(button);
|
|
|
|
|
|
|
|
|
|
|
|
button.Click += (s, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
printTask.PrintQuality = siblings.IndexOf((GuiWidget)s);
|
|
|
|
|
|
printTask.QualityWasSet = true;
|
2020-10-23 16:57:26 -07:00
|
|
|
|
printTask.CommitAndPushToServer();
|
2020-10-04 22:21:17 -07:00
|
|
|
|
clicked();
|
2020-10-04 10:57:55 -07:00
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-10-30 07:48:25 -07:00
|
|
|
|
SetStarState(theme, siblings, printTask);
|
|
|
|
|
|
|
2020-10-04 22:21:17 -07:00
|
|
|
|
return content;
|
2020-10-04 10:57:55 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-10-30 07:48:25 -07:00
|
|
|
|
private static void SetStarState(ThemeConfig theme, List<GuiWidget> siblings, PrintTask printTask)
|
|
|
|
|
|
{
|
|
|
|
|
|
var checkedButton = -1;
|
|
|
|
|
|
if (printTask.QualityWasSet)
|
|
|
|
|
|
{
|
|
|
|
|
|
checkedButton = printTask.PrintQuality;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (int j = 0; j < siblings.Count; j++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var open = siblings[j].Descendants().Where(d => d.Name == "open").FirstOrDefault();
|
|
|
|
|
|
var closed = siblings[j].Descendants().Where(d => d.Name == "closed").FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
|
|
if (j == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (checkedButton == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
siblings[j].BackgroundColor = theme.AccentMimimalOverlay;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
siblings[j].BackgroundColor = Color.Transparent;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (j <= checkedButton)
|
|
|
|
|
|
{
|
|
|
|
|
|
siblings[j].BackgroundColor = theme.AccentMimimalOverlay;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
siblings[j].BackgroundColor = Color.Transparent;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (j <= checkedButton)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (open != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
open.Visible = false;
|
|
|
|
|
|
closed.Visible = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (open != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
open.Visible = true;
|
|
|
|
|
|
closed.Visible = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-10-26 11:25:18 -07:00
|
|
|
|
public static MHDropDownList CreateDefaultOptions(GuiWidget textField, ThemeConfig theme)
|
2020-10-04 10:57:55 -07:00
|
|
|
|
{
|
2020-11-05 09:49:11 -08:00
|
|
|
|
var options = new List<(string group, string item)>()
|
|
|
|
|
|
{
|
|
|
|
|
|
("First Layer", "First Layer Bad Quality"),
|
|
|
|
|
|
("First Layer", "Initial Z Height Incorrect"),
|
|
|
|
|
|
("Quality", "Dislodged From Bed"),
|
|
|
|
|
|
("Quality", "Layer Shift"),
|
|
|
|
|
|
("Quality", "General Quality"),
|
|
|
|
|
|
("Quality", "Rough Overhangs"),
|
|
|
|
|
|
("Quality", "Skipped Layers"),
|
|
|
|
|
|
("Quality", "Some Parts Lifted"),
|
|
|
|
|
|
("Quality", "Stringing / Poor retractions"),
|
|
|
|
|
|
("Quality", "Warping"),
|
|
|
|
|
|
("Mechanical", "Bed Dislodged"),
|
|
|
|
|
|
("Mechanical", "Bowden Tube Popped Out"),
|
|
|
|
|
|
("Mechanical", "Extruder Slipping"),
|
|
|
|
|
|
("Mechanical", "Flooded Hot End"),
|
|
|
|
|
|
("Mechanical", "Power Outage"),
|
|
|
|
|
|
("Computer / MatterControl", "Computer Crashed"),
|
|
|
|
|
|
("Computer / MatterControl", "Computer Slow / Lagging"),
|
|
|
|
|
|
("Computer / MatterControl", "Couldn't Resume"),
|
|
|
|
|
|
("Computer / MatterControl", "Wouldn’t Slice Correctly"),
|
|
|
|
|
|
("Filament", "Filament Jam"),
|
|
|
|
|
|
("Filament", "Filament Runout"),
|
|
|
|
|
|
("Filament", "Filament Snapped"),
|
|
|
|
|
|
("Heating", "Thermal Runaway - Bed"),
|
|
|
|
|
|
("Heating", "Thermal Runaway - Hot End"),
|
|
|
|
|
|
("Heating", "Thermal Runaway"),
|
|
|
|
|
|
("Heating", "Took Too Long To Heat"),
|
|
|
|
|
|
("Heating", "Bad Thermistor"),
|
|
|
|
|
|
("X", "Test Print"),
|
|
|
|
|
|
("X", "User Error"),
|
|
|
|
|
|
("X", "Other"),
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2020-10-04 10:57:55 -07:00
|
|
|
|
var issues = new string[]
|
|
|
|
|
|
{
|
2020-10-26 16:40:36 -07:00
|
|
|
|
"Bad Thermistor".Localize(),
|
|
|
|
|
|
"Bed Dislodged".Localize(),
|
|
|
|
|
|
"Bowden Tube Popped Out".Localize(),
|
|
|
|
|
|
"Computer Crashed".Localize(),
|
|
|
|
|
|
"Computer Slow/Lagging".Localize(),
|
|
|
|
|
|
"Couldn't Resume".Localize(),
|
|
|
|
|
|
"Dislodged From Bed".Localize(),
|
|
|
|
|
|
"Extruder Slipping".Localize(),
|
|
|
|
|
|
"Filament Jam".Localize(),
|
|
|
|
|
|
"Filament Runout".Localize(),
|
|
|
|
|
|
"Filament Snapped".Localize(),
|
|
|
|
|
|
"First Layer Bad Quality".Localize(),
|
|
|
|
|
|
"Flooded Hot End".Localize(),
|
|
|
|
|
|
"Initial Z Height Incorrect".Localize(),
|
|
|
|
|
|
"Layer Shift".Localize(),
|
|
|
|
|
|
"Power Outage".Localize(),
|
|
|
|
|
|
"Print Quality".Localize(),
|
|
|
|
|
|
"Rough Overhangs".Localize(),
|
|
|
|
|
|
"Skipped Layers".Localize(),
|
|
|
|
|
|
"Some Parts Lifted".Localize(),
|
|
|
|
|
|
"Stringing / Poor retractions".Localize(),
|
|
|
|
|
|
"Test Print".Localize(),
|
|
|
|
|
|
"Thermal Runaway - Bed".Localize(),
|
|
|
|
|
|
"Thermal Runaway - Hot End".Localize(),
|
|
|
|
|
|
"Thermal Runaway".Localize(),
|
|
|
|
|
|
"Took Too Long To Heat".Localize(),
|
|
|
|
|
|
"User Error".Localize(),
|
|
|
|
|
|
"Warping".Localize(),
|
|
|
|
|
|
"Wouldn’t Slice Correctly".Localize(),
|
|
|
|
|
|
"Other...".Localize()
|
2020-10-04 10:57:55 -07:00
|
|
|
|
};
|
|
|
|
|
|
|
2020-10-26 16:40:36 -07:00
|
|
|
|
textField.Visible = false;
|
|
|
|
|
|
|
|
|
|
|
|
var dropdownList = new MHDropDownList("What went wrong?".Localize(), theme, maxHeight: 300 * GuiWidget.DeviceScale);
|
2020-10-04 10:57:55 -07:00
|
|
|
|
|
|
|
|
|
|
foreach (var issue in issues)
|
|
|
|
|
|
{
|
|
|
|
|
|
MenuItem newItem = dropdownList.AddItem(issue);
|
|
|
|
|
|
|
|
|
|
|
|
newItem.Selected += (sender, e) =>
|
|
|
|
|
|
{
|
2020-10-26 16:40:36 -07:00
|
|
|
|
if (dropdownList.SelectedIndex == issues.Length - 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
textField.Text = "";
|
|
|
|
|
|
textField.Visible = true;
|
|
|
|
|
|
UiThread.RunOnIdle(textField.Focus);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
textField.Text = issue;
|
|
|
|
|
|
textField.Visible = false;
|
|
|
|
|
|
}
|
2020-10-04 10:57:55 -07:00
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return dropdownList;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-10-25 15:45:51 -07:00
|
|
|
|
private static string articles = @"
|
|
|
|
|
|
- [MatterControl Tutorials](https://www.matterhackers.com/store/l/mattercontrol/sk/MKZGTDW6#tutorials)
|
|
|
|
|
|
- [Trick, Tips & Support Articles](https://www.matterhackers.com/topic/tips-and-tricks)
|
|
|
|
|
|
- [MatterControl Articles](https://www.matterhackers.com/topic/mattercontrol)
|
2020-10-04 10:57:55 -07:00
|
|
|
|
- [MatterControl Docs](https://www.matterhackers.com/mattercontrol/support)
|
|
|
|
|
|
- [User Forum](https://forums.matterhackers.com/recent)";
|
|
|
|
|
|
|
2020-10-25 15:45:51 -07:00
|
|
|
|
public void CollectInfoPrintCanceled()
|
|
|
|
|
|
{
|
|
|
|
|
|
string markdownText = @"If you need help, here are some links that might be useful." + articles;
|
|
|
|
|
|
|
2020-10-06 22:00:28 -07:00
|
|
|
|
new CollectPrintDetailsPage("Print Canceled".Localize(),
|
2020-10-25 15:45:51 -07:00
|
|
|
|
printer,
|
2020-10-25 08:48:43 -07:00
|
|
|
|
"Oops, looks like you canceled the print.",
|
2020-10-04 22:21:17 -07:00
|
|
|
|
markdownText,
|
2020-10-25 08:48:43 -07:00
|
|
|
|
printTask,
|
|
|
|
|
|
false);
|
2020-10-04 10:57:55 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void CollectInfoPrintFinished()
|
|
|
|
|
|
{
|
|
|
|
|
|
// show a long running task asking about print feedback and up-selling more materials
|
|
|
|
|
|
// Ask about the print, offer help if needed.
|
|
|
|
|
|
// Let us know how your print came out.
|
|
|
|
|
|
string markdownText = @"**Find more at MatterHackers**
|
|
|
|
|
|
|
|
|
|
|
|
Supplies and accessories:
|
2020-10-25 08:48:43 -07:00
|
|
|
|
|
|
|
|
|
|
[](https://www.matterhackers.com/store/c/3d-printer-filament) [](https://www.matterhackers.com/store/c/3d-printer-adhesive) [](https://www.matterhackers.com/store/c/printer-accessories)
|
2020-10-04 10:57:55 -07:00
|
|
|
|
|
2020-10-25 15:45:51 -07:00
|
|
|
|
Support and tutorials:" + articles;
|
2020-10-04 10:57:55 -07:00
|
|
|
|
|
2020-10-25 15:45:51 -07:00
|
|
|
|
new CollectPrintDetailsPage("Print Complete".Localize(),
|
|
|
|
|
|
printer,
|
2020-10-25 08:48:43 -07:00
|
|
|
|
"How did this print come out?",
|
2020-10-06 22:00:28 -07:00
|
|
|
|
markdownText,
|
2020-10-25 08:48:43 -07:00
|
|
|
|
printTask,
|
|
|
|
|
|
true);
|
2020-10-04 10:57:55 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-10-25 08:48:43 -07:00
|
|
|
|
public class CollectPrintDetailsPage : DialogPage
|
2020-10-04 10:57:55 -07:00
|
|
|
|
{
|
2020-10-25 08:48:43 -07:00
|
|
|
|
private readonly MHTextEditWidget textEditWidget;
|
2020-10-04 10:57:55 -07:00
|
|
|
|
|
2020-10-25 08:48:43 -07:00
|
|
|
|
public override string Text { get => textEditWidget.Text; set => textEditWidget.Text = value; }
|
|
|
|
|
|
|
|
|
|
|
|
public CollectPrintDetailsPage(string windowTitle,
|
2020-10-25 15:45:51 -07:00
|
|
|
|
PrinterConfig printer,
|
2020-10-25 08:48:43 -07:00
|
|
|
|
string topMarkDown,
|
|
|
|
|
|
string descriptionMarkdown,
|
|
|
|
|
|
PrintTask printTask,
|
|
|
|
|
|
bool collectQuality)
|
2020-10-25 15:45:51 -07:00
|
|
|
|
: base("Close".Localize())
|
2020-10-04 10:57:55 -07:00
|
|
|
|
{
|
2020-10-25 08:48:43 -07:00
|
|
|
|
this.WindowTitle = windowTitle;
|
2020-10-26 16:40:36 -07:00
|
|
|
|
this.HeaderText = printer.Settings.GetValue(SettingsKey.printer_name) + ": " + windowTitle;
|
|
|
|
|
|
this.WindowSize = new Vector2(500 * GuiWidget.DeviceScale, 440 * GuiWidget.DeviceScale);
|
2020-10-06 22:00:28 -07:00
|
|
|
|
|
2020-10-25 08:48:43 -07:00
|
|
|
|
var scrollable = new ScrollableWidget(autoScroll: true)
|
|
|
|
|
|
{
|
|
|
|
|
|
HAnchor = HAnchor.Stretch,
|
|
|
|
|
|
VAnchor = VAnchor.Stretch,
|
|
|
|
|
|
Margin = new BorderDouble(bottom: 10),
|
|
|
|
|
|
};
|
2020-10-06 22:00:28 -07:00
|
|
|
|
|
2020-10-25 08:48:43 -07:00
|
|
|
|
scrollable.ScrollArea.HAnchor = HAnchor.Stretch;
|
|
|
|
|
|
scrollable.ScrollArea.VAnchor = VAnchor.Fit;
|
|
|
|
|
|
contentRow.AddChild(scrollable);
|
2020-10-04 10:57:55 -07:00
|
|
|
|
|
2020-10-25 08:48:43 -07:00
|
|
|
|
var topToBottom = scrollable.AddChild(new FlowLayoutWidget(FlowDirection.TopToBottom)
|
|
|
|
|
|
{
|
|
|
|
|
|
HAnchor = HAnchor.Stretch
|
|
|
|
|
|
});
|
2020-10-06 22:00:28 -07:00
|
|
|
|
|
2020-10-25 08:48:43 -07:00
|
|
|
|
topToBottom.AddChild(new MarkdownWidget(theme, false)
|
2020-10-06 22:00:28 -07:00
|
|
|
|
{
|
2020-10-25 08:48:43 -07:00
|
|
|
|
Markdown = topMarkDown,
|
|
|
|
|
|
});
|
2020-10-06 22:00:28 -07:00
|
|
|
|
|
2020-10-25 08:48:43 -07:00
|
|
|
|
var reasonSection = new FlowLayoutWidget(FlowDirection.TopToBottom)
|
|
|
|
|
|
{
|
|
|
|
|
|
HAnchor = HAnchor.Stretch,
|
|
|
|
|
|
Visible = !collectQuality
|
|
|
|
|
|
};
|
2020-10-06 22:00:28 -07:00
|
|
|
|
|
2020-10-25 08:48:43 -07:00
|
|
|
|
if (collectQuality)
|
2020-10-06 22:00:28 -07:00
|
|
|
|
{
|
2020-10-25 08:48:43 -07:00
|
|
|
|
var qualityInput = GetQualityWidget(theme,
|
|
|
|
|
|
printTask,
|
|
|
|
|
|
() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
reasonSection.Visible = printTask.PrintQuality == 0;
|
|
|
|
|
|
this.Descendants<ScrollableWidget>().First().ScrollPositionFromTop = new Vector2(0, 0);
|
|
|
|
|
|
},
|
|
|
|
|
|
16);
|
|
|
|
|
|
qualityInput.Margin = new BorderDouble(5, 0);
|
|
|
|
|
|
qualityInput.HAnchor = HAnchor.Left;
|
|
|
|
|
|
topToBottom.AddChild(qualityInput);
|
2020-10-06 22:00:28 -07:00
|
|
|
|
}
|
2020-10-25 08:48:43 -07:00
|
|
|
|
|
|
|
|
|
|
topToBottom.AddChild(reasonSection);
|
|
|
|
|
|
|
|
|
|
|
|
// Adds text box and check box to the above container
|
|
|
|
|
|
var emptyText = "What went wrong?".Localize();
|
|
|
|
|
|
var initialValue = printTask.Note ?? "";
|
|
|
|
|
|
textEditWidget = new MHTextEditWidget(initialValue, theme, pixelWidth: 300, messageWhenEmptyAndNotSelected: emptyText)
|
2020-10-06 22:00:28 -07:00
|
|
|
|
{
|
2020-10-25 08:48:43 -07:00
|
|
|
|
Name = "InputBoxPage TextEditWidget",
|
|
|
|
|
|
HAnchor = HAnchor.Stretch,
|
2020-10-26 16:40:36 -07:00
|
|
|
|
Margin = new BorderDouble(5),
|
2020-10-25 08:48:43 -07:00
|
|
|
|
};
|
2020-10-06 22:00:28 -07:00
|
|
|
|
|
2020-10-26 11:25:18 -07:00
|
|
|
|
textEditWidget.ActualTextEditWidget.EditComplete += (s, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
printTask.Note = textEditWidget.Text;
|
|
|
|
|
|
printTask.CommitAndPushToServer();
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2020-10-26 16:40:36 -07:00
|
|
|
|
var dropDownList = CreateDefaultOptions(textEditWidget, theme);
|
2020-10-26 11:25:18 -07:00
|
|
|
|
dropDownList.Margin = new BorderDouble(5, 0);
|
|
|
|
|
|
dropDownList.HAnchor = HAnchor.Left;
|
|
|
|
|
|
reasonSection.AddChild(dropDownList);
|
2020-10-26 16:40:36 -07:00
|
|
|
|
reasonSection.AddChild(textEditWidget);
|
2020-10-26 11:25:18 -07:00
|
|
|
|
|
|
|
|
|
|
dropDownList.SelectionChanged += (s, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
// Delay this so we wait for the text to be updated
|
|
|
|
|
|
UiThread.RunOnIdle(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
printTask.Note = textEditWidget.Text;
|
|
|
|
|
|
printTask.CommitAndPushToServer();
|
|
|
|
|
|
});
|
|
|
|
|
|
};
|
2020-10-04 10:57:55 -07:00
|
|
|
|
|
2020-10-25 08:48:43 -07:00
|
|
|
|
topToBottom.AddChild(new HorizontalLine(theme.BorderColor40)
|
|
|
|
|
|
{
|
|
|
|
|
|
Margin = new BorderDouble(0, 5)
|
|
|
|
|
|
});
|
2020-10-04 10:57:55 -07:00
|
|
|
|
|
2020-10-25 08:48:43 -07:00
|
|
|
|
topToBottom.AddChild(new MarkdownWidget(theme, false)
|
|
|
|
|
|
{
|
|
|
|
|
|
Markdown = descriptionMarkdown,
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2020-10-26 11:25:18 -07:00
|
|
|
|
var collectHistoryHidden = UserSettings.Instance.get(UserSettingsKey.CollectPrintHistoryData) == "false";
|
|
|
|
|
|
if (!collectHistoryHidden)
|
2020-10-25 08:48:43 -07:00
|
|
|
|
{
|
|
|
|
|
|
UiThread.RunOnIdle(() =>
|
|
|
|
|
|
{
|
2020-11-02 18:24:19 -08:00
|
|
|
|
DialogWindow.Show(this, printTask.Id);
|
2020-10-25 08:48:43 -07:00
|
|
|
|
// this will cause a layout that fixes a display issue
|
2020-10-26 16:40:36 -07:00
|
|
|
|
scrollable.ScrollArea.BoundsChanged += (s, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
scrollable.ScrollPositionFromTop = new Vector2(0, 0);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
scrollable.ScrollPositionFromTop = new Vector2(0, 0);
|
2020-10-25 08:48:43 -07:00
|
|
|
|
});
|
|
|
|
|
|
}
|
2020-10-25 15:45:51 -07:00
|
|
|
|
|
|
|
|
|
|
if (printer != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
var printAgainButton = PrintPopupMenu.CreateStartPrintButton("Print Again", printer, theme, out _);
|
|
|
|
|
|
printAgainButton.Click += (s, e) => this.DialogWindow?.ClosePage();
|
|
|
|
|
|
AddPageAction(printAgainButton);
|
|
|
|
|
|
}
|
2020-10-25 08:48:43 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool AllowEmpty { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public override void OnLoad(EventArgs args)
|
2020-10-04 10:57:55 -07:00
|
|
|
|
{
|
2020-10-25 08:48:43 -07:00
|
|
|
|
UiThread.RunOnIdle(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
textEditWidget.Focus();
|
|
|
|
|
|
textEditWidget.ActualTextEditWidget.InternalTextEditWidget.SelectAll();
|
|
|
|
|
|
});
|
|
|
|
|
|
base.OnLoad(args);
|
|
|
|
|
|
}
|
2020-10-04 10:57:55 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|