Making print history clearable and update with new data

fixing warnings
This commit is contained in:
Lars Brubaker 2020-07-03 12:05:28 -07:00
parent 215e86eb5a
commit 78d4059c80
16 changed files with 447 additions and 247 deletions

View file

@ -268,12 +268,14 @@ namespace SQLiteWin32
{
_mappings = new Dictionary<string, TableMapping>();
}
TableMapping map;
if (!_mappings.TryGetValue(type.FullName, out map))
{
map = new TableMapping(type);
_mappings[type.FullName] = map;
}
return map;
}
@ -1123,6 +1125,7 @@ namespace SQLiteWin32
{
return 0;
}
lock (locker)
{
return Insert(obj, "", obj.GetType());

View file

@ -27,6 +27,21 @@ 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.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using global::MatterControl.Printing;
using MatterHackers.Agg;
using MatterHackers.Agg.Font;
@ -58,21 +73,6 @@ using MatterHackers.VectorMath;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
[assembly: InternalsVisibleTo("MatterControl.Tests")]
[assembly: InternalsVisibleTo("MatterControl.AutomationTests")]
@ -122,6 +122,10 @@ namespace MatterHackers.MatterControl
public event EventHandler<string> ShellFileOpened;
public event EventHandler AnyPrintStarted;
public event EventHandler AnyPrintCanceled;
public event EventHandler AnyPrintComplete;
public bool IsMatterControlPro()
{
var result = ApplicationController.Instance.UserHasPermissionToId?.Invoke("ag1zfm1oLWRmcy1wcm9kchgLEgtEaWdpdGFsSXRlbRiAgIDzyMGxCgw");
@ -3158,6 +3162,11 @@ namespace MatterHackers.MatterControl
UiThread.RunOnIdle(() => this.ShellFileOpened?.Invoke(this, file));
}
public void Connection_PrintStarted(object sender, EventArgs e)
{
AnyPrintStarted?.Invoke(sender, e);
}
public void Connection_PrintFinished(object sender, string e)
{
if (sender is PrinterConnection printerConnection
@ -3182,6 +3191,8 @@ Support and tutorials:
var time = Stopwatch.StartNew();
ShowNotification("Congratulations Print Complete".Localize(), markdownText, UserSettingsKey.ShownPrintCompleteMessage);
}
AnyPrintComplete?.Invoke(sender, null);
}
public void Connection_PrintCanceled(object sender, EventArgs e)
@ -3204,9 +3215,11 @@ Support and tutorials:
var time = Stopwatch.StartNew();
ShowNotification("Print Canceled".Localize(), markdownText, UserSettingsKey.ShownPrintCanceledMessage);
}
}
private void ShowNotification(string title, string markdownText, string userKey)
AnyPrintCanceled?.Invoke(sender, e);
}
private void ShowNotification(string title, string markdownText, string userKey)
{
var hideAfterPrintMessage = new CheckBox("Don't show this again".Localize())
{

View file

@ -70,6 +70,7 @@ namespace MatterHackers.MatterControl
// Register listeners
this.Connection.TemporarilyHoldingTemp += ApplicationController.Instance.Connection_TemporarilyHoldingTemp;
this.Connection.PrintStarted += ApplicationController.Instance.Connection_PrintStarted;
this.Connection.PrintFinished += ApplicationController.Instance.Connection_PrintFinished;
this.Connection.PrintCanceled += ApplicationController.Instance.Connection_PrintCanceled;
this.Connection.ErrorReported += ApplicationController.Instance.Connection_ErrorReported;

View file

@ -139,6 +139,7 @@ namespace MatterHackers.MatterControl.DataStorage
}
}
}
this.hashCode = bigStringForHashCode.ToString().GetHashCode();
}
@ -355,6 +356,7 @@ namespace MatterHackers.MatterControl.DataStorage
TimeSpan printTimeSpan = PrintEnd.Subtract(PrintStart);
PrintTimeSeconds = (int)printTimeSpan.TotalSeconds;
}
base.Commit();
}
}

View file

@ -0,0 +1,160 @@
/*
Copyright (c) 2018, Kevin Pope, 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.Linq;
using MatterHackers.Agg;
using MatterHackers.Agg.UI;
using MatterHackers.Localizations;
using MatterHackers.MatterControl.CustomWidgets;
using MatterHackers.MatterControl.Library;
using MatterHackers.MatterControl.PartPreviewWindow;
namespace MatterHackers.MatterControl.PrintHistory
{
public class HistoryListView : FlowLayoutWidget, IListContentView
{
private readonly ThemeConfig theme = ApplicationController.Instance.Theme;
public int ThumbWidth { get; } = 50;
public int ThumbHeight { get; } = 50;
// Parameterless constructor required for ListView
public HistoryListView()
: base(FlowDirection.TopToBottom)
{
}
public HistoryListView(ThemeConfig theme)
: base(FlowDirection.TopToBottom)
{
this.theme = theme;
}
protected override void OnClick(MouseEventArgs mouseEvent)
{
if (mouseEvent.Button == MouseButtons.Right)
{
var theme = ApplicationController.Instance.MenuTheme;
// show a right click menu ('Set as Default' & 'Help')
var popupMenu = new PopupMenu(theme);
var historyItems = PrintHistoryData.Instance.GetHistoryItems(1).Select(f => new PrintHistoryItem(f)).ToList<ILibraryItem>();
var exportPrintHistory = popupMenu.CreateMenuItem("Export History".Localize() + "...");
exportPrintHistory.Enabled = historyItems.Count > 0;
exportPrintHistory.Click += (s, e) =>
{
};
bool showFilter = false;
if (showFilter)
{
popupMenu.CreateSubMenu("Filter".Localize(), theme, (subMenu) =>
{
// foreach (var printer in AllPrinters)
// {
// var menuItem = subMenu.CreateMenuItem(nodeOperation.Title, nodeOperation.IconCollector?.Invoke(menuTheme.InvertIcons));
// menuItem.Click += (s, e) =>
// {
// nodeOperation.Operation(selectedItem, scene).ConfigureAwait(false);
// };
// }
});
}
popupMenu.CreateSeparator();
var clearPrintHistory = popupMenu.CreateMenuItem("Clear History".Localize());
clearPrintHistory.Enabled = historyItems.Count > 0;
clearPrintHistory.Click += (s, e) =>
{
// clear history
StyledMessageBox.ShowMessageBox(
(clearHistory) =>
{
if (clearHistory)
{
PrintHistoryData.Instance.ClearHistory();
}
},
"Are you sure you want to clear your print history?".Localize(),
"Clear History?".Localize(),
StyledMessageBox.MessageType.YES_NO,
"Clear History".Localize());
};
ShowMenu(mouseEvent, popupMenu);
}
base.OnClick(mouseEvent);
}
private void ShowMenu(MouseEventArgs mouseEvent, PopupMenu popupMenu)
{
var sourceEvent = mouseEvent.Position;
var systemWindow = this.Parents<SystemWindow>().FirstOrDefault();
this.Parents<SystemWindow>().FirstOrDefault().ToolTipManager.Clear();
systemWindow.ShowPopup(
new MatePoint(this)
{
Mate = new MateOptions(MateEdge.Left, MateEdge.Top),
AltMate = new MateOptions(MateEdge.Left, MateEdge.Top)
},
new MatePoint(popupMenu)
{
Mate = new MateOptions(MateEdge.Left, MateEdge.Top),
AltMate = new MateOptions(MateEdge.Right, MateEdge.Top)
},
altBounds: new RectangleDouble(sourceEvent.X + 1, sourceEvent.Y + 1, sourceEvent.X + 1, sourceEvent.Y + 1));
}
public ListViewItemBase AddItem(ListViewItem item)
{
var historyRowItem = item.Model as PrintHistoryItem;
var detailsView = new PrintHistoryListItem(item, this.ThumbWidth, this.ThumbHeight, historyRowItem?.PrintTask, theme);
detailsView.Selectable = false;
this.AddChild(detailsView);
return detailsView;
}
public void ClearItems()
{
}
public void BeginReload()
{
}
public void EndReload()
{
}
}
}

View file

@ -36,8 +36,9 @@ namespace MatterHackers.MatterControl.PrintHistory
public class PrintHistoryData
{
public static readonly int RecordLimit = 20;
public RootedObjectEventHandler HistoryCleared = new RootedObjectEventHandler();
public bool ShowTimestamp;
public RootedObjectEventHandler HistoryCleared { get; private set; } = new RootedObjectEventHandler();
private static PrintHistoryData instance;
public static PrintHistoryData Instance
@ -48,6 +49,7 @@ namespace MatterHackers.MatterControl.PrintHistory
{
instance = new PrintHistoryData();
}
return instance;
}
}

View file

@ -31,99 +31,36 @@ using System;
using System.Globalization;
using MatterHackers.Agg;
using MatterHackers.Agg.UI;
using MatterHackers.Agg.VertexSource;
using MatterHackers.Localizations;
using MatterHackers.MatterControl.CustomWidgets;
using MatterHackers.MatterControl.DataStorage;
using MatterHackers.MatterControl.Library;
using MatterHackers.MatterControl.PrintQueue;
namespace MatterHackers.MatterControl.PrintHistory
{
public class HistoryListView : FlowLayoutWidget, IListContentView
{
private ThemeConfig theme = ApplicationController.Instance.Theme;
public int ThumbWidth { get; } = 50;
public int ThumbHeight { get; } = 50;
// Parameterless constructor required for ListView
public HistoryListView()
: base (FlowDirection.TopToBottom)
{
}
public HistoryListView(ThemeConfig theme)
: base(FlowDirection.TopToBottom)
{
this.theme = theme;
}
public ListViewItemBase AddItem(ListViewItem item)
{
var historyRowItem = item.Model as PrintHistoryItem;
var detailsView = new PrintHistoryListItem(item, this.ThumbWidth, this.ThumbHeight, historyRowItem?.PrintTask, true, theme);
this.AddChild(detailsView);
return detailsView;
}
public void ClearItems()
{
}
public void BeginReload()
{
}
public void EndReload()
{
}
}
public class PrintHistoryListItem : ListViewItemBase
{
public PrintTask printTask;
public Color WidgetTextColor;
public Color WidgetBackgroundColor;
public bool isActivePrint = false;
public bool isSelectedItem = false;
public bool isHoverItem = false;
private bool showTimestamp;
private TextWidget partLabel;
public CheckBox selectionCheckBox;
#if(__ANDROID__)
private float pointSizeFactor = 0.85f;
private static int rightOverlayWidth = 240;
#else
private float pointSizeFactor = 1f;
private static int rightOverlayWidth = 200;
#endif
private int actionButtonSize = rightOverlayWidth/2;
public PrintHistoryListItem(ListViewItem listViewItem, int thumbWidth, int thumbHeight, PrintTask printTask, bool showTimestamp, ThemeConfig theme)
public PrintHistoryListItem(ListViewItem listViewItem, int thumbWidth, int thumbHeight, PrintTask printTask, ThemeConfig theme)
: base(listViewItem, thumbWidth, thumbHeight, theme)
{
this.printTask = printTask;
this.showTimestamp = showTimestamp;
this.HAnchor = Agg.UI.HAnchor.Stretch;
this.Height = 50;
this.BackgroundColor = this.WidgetBackgroundColor;
this.Padding = new BorderDouble(0);
this.Margin = new BorderDouble(6, 0, 6, 6);
var mainContainer = new GuiWidget();
mainContainer.HAnchor = HAnchor.Stretch;
mainContainer.VAnchor = VAnchor.Stretch;
var mainContainer = new GuiWidget
{
HAnchor = HAnchor.Stretch,
VAnchor = VAnchor.Stretch
};
TextInfo textInfo = new CultureInfo("en-US", false).TextInfo;
{
GuiWidget indicator = new GuiWidget();
indicator.VAnchor = Agg.UI.VAnchor.Stretch;
indicator.Width = 15;
var indicator = new GuiWidget
{
VAnchor = Agg.UI.VAnchor.Stretch,
Width = 15
};
if (printTask.PrintComplete)
{
indicator.BackgroundColor = new Color(38, 147, 51, 180);
@ -133,31 +70,41 @@ namespace MatterHackers.MatterControl.PrintHistory
indicator.BackgroundColor = new Color(252, 209, 22, 180);
}
FlowLayoutWidget middleColumn = new FlowLayoutWidget(FlowDirection.TopToBottom);
middleColumn.HAnchor = Agg.UI.HAnchor.Stretch;
middleColumn.Padding = new BorderDouble(6, 3);
var middleColumn = new FlowLayoutWidget(FlowDirection.TopToBottom)
{
FlowLayoutWidget labelContainer = new FlowLayoutWidget();
labelContainer.HAnchor = Agg.UI.HAnchor.Stretch;
HAnchor = Agg.UI.HAnchor.Stretch,
Padding = new BorderDouble(6, 3)
};
{
var labelContainer = new FlowLayoutWidget
{
HAnchor = Agg.UI.HAnchor.Stretch
};
string labelName = textInfo.ToTitleCase(printTask.PrintName);
labelName = labelName.Replace('_', ' ');
partLabel = new TextWidget(labelName, pointSize: 15 * pointSizeFactor);
partLabel.TextColor = WidgetTextColor;
var partLabel = new TextWidget(labelName, pointSize: 15)
{
TextColor = Color.Black
};
labelContainer.AddChild(partLabel);
middleColumn.AddChild(labelContainer);
}
Color timeTextColor = new Color(34, 34, 34);
var timeTextColor = new Color(34, 34, 34);
FlowLayoutWidget buttonContainer = new FlowLayoutWidget();
buttonContainer.Margin = new BorderDouble(0);
buttonContainer.HAnchor = Agg.UI.HAnchor.Stretch;
var detailsRow = new FlowLayoutWidget
{
var timeLabel = new TextWidget("Time".Localize().ToUpper() + ": ", pointSize: 8 * pointSizeFactor);
timeLabel.TextColor = timeTextColor;
Margin = new BorderDouble(0),
HAnchor = Agg.UI.HAnchor.Stretch
};
{
var timeLabel = new TextWidget("Time".Localize().ToUpper() + ": ", pointSize: 8)
{
TextColor = timeTextColor
};
TextWidget timeIndicator;
int minutes = printTask.PrintTimeMinutes;
@ -167,11 +114,11 @@ namespace MatterHackers.MatterControl.PrintHistory
}
else if (minutes > 60)
{
timeIndicator = new TextWidget("{0}hrs {1}min".FormatWith(printTask.PrintTimeMinutes / 60, printTask.PrintTimeMinutes % 60), pointSize: 12 * pointSizeFactor);
timeIndicator = new TextWidget("{0}hrs {1}min".FormatWith(printTask.PrintTimeMinutes / 60, printTask.PrintTimeMinutes % 60), pointSize: 12);
}
else
{
timeIndicator = new TextWidget(string.Format("{0}min", printTask.PrintTimeMinutes), pointSize: 12 * pointSizeFactor);
timeIndicator = new TextWidget(string.Format("{0}min", printTask.PrintTimeMinutes), pointSize: 12);
}
if (printTask.PercentDone > 0)
@ -179,7 +126,7 @@ namespace MatterHackers.MatterControl.PrintHistory
timeIndicator.AutoExpandBoundsToText = true;
timeIndicator.Text += $" ({printTask.PercentDone:0.0}%)";
if(printTask.RecoveryCount > 0)
if (printTask.RecoveryCount > 0)
{
if (printTask.RecoveryCount == 1)
{
@ -195,90 +142,114 @@ namespace MatterHackers.MatterControl.PrintHistory
timeIndicator.Margin = new BorderDouble(right: 6);
timeIndicator.TextColor = timeTextColor;
buttonContainer.AddChild(timeLabel);
buttonContainer.AddChild(timeIndicator);
buttonContainer.AddChild(new HorizontalSpacer());
middleColumn.AddChild(buttonContainer);
detailsRow.AddChild(timeLabel);
detailsRow.AddChild(timeIndicator);
detailsRow.AddChild(new HorizontalSpacer());
middleColumn.AddChild(detailsRow);
}
GuiWidget primaryContainer = new GuiWidget();
primaryContainer.HAnchor = HAnchor.Stretch;
primaryContainer.VAnchor = VAnchor.Stretch;
var primaryContainer = new GuiWidget
{
HAnchor = HAnchor.Stretch,
VAnchor = VAnchor.Stretch
};
FlowLayoutWidget primaryFlow = new FlowLayoutWidget(FlowDirection.LeftToRight);
primaryFlow.HAnchor = HAnchor.Stretch;
primaryFlow.VAnchor = VAnchor.Stretch;
var primaryFlow = new FlowLayoutWidget(FlowDirection.LeftToRight)
{
HAnchor = HAnchor.Stretch,
VAnchor = VAnchor.Stretch
};
primaryFlow.AddChild(indicator);
primaryFlow.AddChild(middleColumn);
primaryContainer.AddChild(primaryFlow);
if (showTimestamp)
{
FlowLayoutWidget timestampColumn = new FlowLayoutWidget(FlowDirection.TopToBottom);
timestampColumn.VAnchor = Agg.UI.VAnchor.Stretch;
timestampColumn.BackgroundColor = Color.LightGray;
timestampColumn.Padding = new BorderDouble(6, 0);
FlowLayoutWidget startTimeContainer = new FlowLayoutWidget();
startTimeContainer.HAnchor = Agg.UI.HAnchor.Stretch;
startTimeContainer.Padding = new BorderDouble(0, 3);
string startLabelFull = "{0}:".FormatWith("Start".Localize().ToUpper());
TextWidget startLabel = new TextWidget(startLabelFull, pointSize: 8 * pointSizeFactor);
startLabel.TextColor = timeTextColor;
string startTimeString = printTask.PrintStart.ToString("MMM d yyyy h:mm ") + printTask.PrintStart.ToString("tt").ToLower();
TextWidget startDate = new TextWidget(startTimeString, pointSize: 12 * pointSizeFactor);
startDate.TextColor = timeTextColor;
startTimeContainer.AddChild(startLabel);
startTimeContainer.AddChild(new HorizontalSpacer());
startTimeContainer.AddChild(startDate);
FlowLayoutWidget endTimeContainer = new FlowLayoutWidget();
endTimeContainer.HAnchor = Agg.UI.HAnchor.Stretch;
endTimeContainer.Padding = new BorderDouble(0, 3);
string endLabelFull = "{0}:".FormatWith("End".Localize().ToUpper());
TextWidget endLabel = new TextWidget(endLabelFull, pointSize: 8 * pointSizeFactor);
endLabel.TextColor = timeTextColor;
string endTimeString;
if (printTask.PrintEnd != DateTime.MinValue)
{
endTimeString = printTask.PrintEnd.ToString("MMM d yyyy h:mm ") + printTask.PrintEnd.ToString("tt").ToLower();
}
else
{
endTimeString = "Unknown".Localize();
}
TextWidget endDate = new TextWidget(endTimeString, pointSize: 12 * pointSizeFactor);
endDate.TextColor = timeTextColor;
endTimeContainer.AddChild(endLabel);
endTimeContainer.AddChild(new HorizontalSpacer());
endTimeContainer.AddChild(endDate);
HorizontalLine horizontalLine = new HorizontalLine();
horizontalLine.BackgroundColor = Color.Gray;
timestampColumn.AddChild(endTimeContainer);
timestampColumn.AddChild(horizontalLine);
timestampColumn.AddChild(startTimeContainer);
timestampColumn.HAnchor = HAnchor.Stretch;
timestampColumn.Padding = new BorderDouble(5, 0, 15, 0);
primaryFlow.AddChild(timestampColumn);
}
AddTimeStamp(printTask, timeTextColor, primaryFlow);
mainContainer.AddChild(primaryContainer);
this.AddChild(mainContainer);
}
this.BackgroundColor = new Color(255, 255, 255, 255);
}
private void AddTimeStamp(PrintTask printTask, Color timeTextColor, FlowLayoutWidget primaryFlow)
{
var timestampColumn = new FlowLayoutWidget(FlowDirection.TopToBottom)
{
VAnchor = Agg.UI.VAnchor.Stretch,
BackgroundColor = Color.LightGray,
Padding = new BorderDouble(6, 0)
};
var startTimeContainer = new FlowLayoutWidget
{
HAnchor = Agg.UI.HAnchor.Stretch,
Padding = new BorderDouble(0, 3)
};
string startLabelFull = "{0}:".FormatWith("Start".Localize().ToUpper());
var startLabel = new TextWidget(startLabelFull, pointSize: 8)
{
TextColor = timeTextColor
};
string startTimeString = printTask.PrintStart.ToString("MMM d yyyy h:mm ") + printTask.PrintStart.ToString("tt").ToLower();
var startDate = new TextWidget(startTimeString, pointSize: 12)
{
TextColor = timeTextColor
};
startTimeContainer.AddChild(startLabel);
startTimeContainer.AddChild(new HorizontalSpacer());
startTimeContainer.AddChild(startDate);
var endTimeContainer = new FlowLayoutWidget
{
HAnchor = Agg.UI.HAnchor.Stretch,
Padding = new BorderDouble(0, 3)
};
string endLabelFull = "{0}:".FormatWith("End".Localize().ToUpper());
var endLabel = new TextWidget(endLabelFull, pointSize: 8)
{
TextColor = timeTextColor
};
string endTimeString;
if (printTask.PrintEnd != DateTime.MinValue)
{
endTimeString = printTask.PrintEnd.ToString("MMM d yyyy h:mm ") + printTask.PrintEnd.ToString("tt").ToLower();
}
else
{
endTimeString = "Unknown".Localize();
}
var endDate = new TextWidget(endTimeString, pointSize: 12)
{
TextColor = timeTextColor
};
endTimeContainer.AddChild(endLabel);
endTimeContainer.AddChild(new HorizontalSpacer());
endTimeContainer.AddChild(endDate);
var horizontalLine = new HorizontalLine
{
BackgroundColor = Color.Gray
};
timestampColumn.AddChild(endTimeContainer);
timestampColumn.AddChild(horizontalLine);
timestampColumn.AddChild(startTimeContainer);
timestampColumn.HAnchor = HAnchor.Stretch;
timestampColumn.Padding = new BorderDouble(5, 0, 15, 0);
primaryFlow.AddChild(timestampColumn);
}
public void ShowCantFindFileMessage(PrintItemWrapper printItemWrapper)
@ -291,20 +262,21 @@ namespace MatterHackers.MatterControl.PrintHistory
if (maxLengthName.Length > maxLength)
{
string start = maxLengthName.Substring(0, 15) + "...";
int amountRemaining = (maxLength - start.Length);
int amountRemaining = maxLength - start.Length;
string end = maxLengthName.Substring(maxLengthName.Length - amountRemaining, amountRemaining);
maxLengthName = start + end;
}
string notFoundMessage = "Oops! Could not find this file".Localize() + ":";
string message = "{0}:\n'{1}'".FormatWith(notFoundMessage, maxLengthName);
string titleLabel = "Item not Found".Localize();
StyledMessageBox.ShowMessageBox(onConfirmRemove, message, titleLabel, StyledMessageBox.MessageType.OK);
StyledMessageBox.ShowMessageBox(OnConfirmRemove, message, titleLabel, StyledMessageBox.MessageType.OK);
});
}
private PrintItemWrapper itemToRemove;
private void onConfirmRemove(bool messageBoxResponse)
private void OnConfirmRemove(bool messageBoxResponse)
{
if (messageBoxResponse)
{
@ -312,37 +284,5 @@ namespace MatterHackers.MatterControl.PrintHistory
UiThread.RunOnIdle(() => QueueData.Instance.RemoveAt(index));
}
}
public override void OnDraw(Graphics2D graphics2D)
{
base.OnDraw(graphics2D);
if (this.isSelectedItem)
{
this.BackgroundColor = theme.PrimaryAccentColor;
this.partLabel.TextColor = Color.White;
this.selectionCheckBox.TextColor = Color.White;
//RectangleDouble Bounds = LocalBounds;
//RoundedRect rectBorder = new RoundedRect(Bounds, 0);
//graphics2D.Render(new Stroke(rectBorder, 3), Color.White);
}
else if (this.isHoverItem)
{
RectangleDouble Bounds = LocalBounds;
RoundedRect rectBorder = new RoundedRect(Bounds, 0);
this.BackgroundColor = theme.PrimaryAccentColor;
this.partLabel.TextColor = Color.White;
this.selectionCheckBox.TextColor = Color.White;
graphics2D.Render(new Stroke(rectBorder, 3), theme.PrimaryAccentColor);
}
else
{
this.BackgroundColor = new Color(255, 255, 255, 255);
this.partLabel.TextColor = Color.Black;
}
}
}
}

View file

@ -27,6 +27,7 @@ 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 MatterHackers.Localizations;
@ -36,18 +37,37 @@ namespace MatterHackers.MatterControl.Library
{
public class PrintHistoryContainer : LibraryContainer
{
private EventHandler unregisterEvents;
public PrintHistoryContainer()
{
this.ChildContainers = new List<ILibraryContainerLink>();
this.Items = new List<ILibraryItem>();
this.Name = "Print History".Localize();
this.DefaultView = typeof(HistoryListView);
PrintHistoryData.Instance.HistoryCleared.RegisterEvent(HistoryChanged, ref unregisterEvents);
ApplicationController.Instance.AnyPrintStarted += HistoryChanged;
ApplicationController.Instance.AnyPrintCanceled += HistoryChanged;
ApplicationController.Instance.AnyPrintComplete += HistoryChanged;
}
private void HistoryChanged(object sender, EventArgs e)
{
ReloadContent();
}
public override void Dispose()
{
unregisterEvents?.Invoke(this, null);
base.Dispose();
}
public override void Load()
{
// PrintItems projected onto FileSystemFileItem
Items = PrintHistoryData.Instance.GetHistoryItems(25).Select(f => new PrintHistoryItem(f)).ToList<ILibraryItem>();
Items = PrintHistoryData.Instance.GetHistoryItems(50).Select(f => new PrintHistoryItem(f)).ToList<ILibraryItem>();
}
}
}

View file

@ -0,0 +1,53 @@
/*
Copyright (c) 2017, 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 System.Threading.Tasks;
using MatterHackers.Localizations;
using MatterHackers.MatterControl.DataStorage;
using MatterHackers.MatterControl.PrintQueue;
namespace MatterHackers.MatterControl.Library
{
public class SqliteFileItem : FileSystemFileItem
{
public PrintItem PrintItem { get; }
public SqliteFileItem(PrintItem printItem)
: base(printItem.FileLocation)
{
this.PrintItem = printItem;
}
public override string Name { get => this.PrintItem.Name; set => this.PrintItem.Name = value; }
}
}

View file

@ -38,19 +38,6 @@ using MatterHackers.MatterControl.PrintQueue;
namespace MatterHackers.MatterControl.Library
{
public class SqliteFileItem : FileSystemFileItem
{
public PrintItem PrintItem { get; }
public SqliteFileItem(PrintItem printItem)
: base(printItem.FileLocation)
{
this.PrintItem = printItem;
}
public override string Name { get => this.PrintItem.Name; set => this.PrintItem.Name = value; }
}
public class SqliteLibraryContainer : WritableContainer, ICustomSearch
{
private string keywordFilter = "";
@ -106,7 +93,7 @@ namespace MatterHackers.MatterControl.Library
else
{
return new MessageItem($"{printItem.Name} (Missing)");
//return new MissingFileItem() // Needs to return a content specific icon with a missing overlay - needs to lack all print operations
// return new MissingFileItem() // Needs to return a content specific icon with a missing overlay - needs to lack all print operations
}
}).ToList();
}
@ -120,15 +107,19 @@ namespace MatterHackers.MatterControl.Library
switch (item)
{
case CreateFolderItem newFolder:
var newFolderCollection = new PrintItemCollection(newFolder.Name, "");
newFolderCollection.ParentCollectionID = this.CollectionID;
var newFolderCollection = new PrintItemCollection(newFolder.Name, "")
{
ParentCollectionID = this.CollectionID
};
newFolderCollection.Commit();
break;
case ILibraryContainerLink containerInfo:
var newCollection = new PrintItemCollection(containerInfo.Name, "");
newCollection.ParentCollectionID = this.CollectionID;
var newCollection = new PrintItemCollection(containerInfo.Name, "")
{
ParentCollectionID = this.CollectionID
};
newCollection.Commit();
break;
@ -176,13 +167,13 @@ namespace MatterHackers.MatterControl.Library
public override void Remove(IEnumerable<ILibraryItem> items)
{
// TODO: Handle Containers
foreach(var item in items)
foreach (var item in items)
{
if (item is SqliteFileItem sqlItem)
{
sqlItem.PrintItem.Delete();
}
else if (item is LocalLibraryZipContainerLink link)
else if (item is LocalLibraryZipContainerLink link)
{
string sql = $"SELECT * FROM PrintItem WHERE ID = @id";
var container = Datastore.Instance.dbSQLite.Query<PrintItem>(sql, link.RowID).FirstOrDefault();

View file

@ -33,11 +33,15 @@ namespace MatterHackers.MatterControl.CustomWidgets
public interface IListContentView
{
int ThumbWidth { get; }
int ThumbHeight { get; }
ListViewItemBase AddItem(ListViewItem item);
void ClearItems();
void BeginReload();
void EndReload();
}
}

View file

@ -144,6 +144,7 @@ namespace MatterHackers.MatterControl.CustomWidgets
else if (stashedContentView != null)
{
// Switch back to the original view
stashedContentView.ClearRemovedFlag();
this.ListContentView = stashedContentView;
stashedContentView = null;
}
@ -158,6 +159,7 @@ namespace MatterHackers.MatterControl.CustomWidgets
Ascending = this.Ascending
};
}
this.ActiveSort = activeContainer.DefaultSort.SortKey;
this.Ascending = activeContainer.DefaultSort.Ascending;
}
@ -413,11 +415,11 @@ namespace MatterHackers.MatterControl.CustomWidgets
var y = height / 2 - originalImage.Height / 2;
var center = new RectangleInt(x, y + originalImage.Height, x + originalImage.Width, y);
//renderGraphics.FillRectangle(center, this.ThumbnailForeground);
// renderGraphics.FillRectangle(center, this.ThumbnailForeground);
renderGraphics.ImageRenderQuality = Graphics2D.TransformQuality.Best;
//originalImage = originalImage.Multiply(this.ThumbnailBackground);
// originalImage = originalImage.Multiply(this.ThumbnailBackground);
renderGraphics.Render(originalImage, width /2 - originalImage.Width /2, height /2 - originalImage.Height /2);

View file

@ -180,12 +180,14 @@ namespace MatterHackers.MatterControl.CustomWidgets
get
{
bool isContentItem = listViewItem.Model is ILibraryObject3D;
bool isValidStream = (listViewItem.Model is ILibraryAssetStream stream
&& ApplicationController.Instance.Library.IsContentFileType(stream.FileName));
bool isValidStream = listViewItem.Model is ILibraryAssetStream stream
&& ApplicationController.Instance.Library.IsContentFileType(stream.FileName);
bool isContainerLink = listViewItem.Model is ILibraryContainerLink;
bool isGCode = listViewItem.Model is FileSystemFileItem item && Path.GetExtension(item.Name).IndexOf(".gco", StringComparison.OrdinalIgnoreCase) == 0
|| listViewItem.Model is SDCardFileItem sdItem && Path.GetExtension(sdItem.Name).IndexOf(".gco", StringComparison.OrdinalIgnoreCase) == 0;
bool isGCode = (listViewItem.Model is FileSystemFileItem item
&& Path.GetExtension(item.Name).IndexOf(".gco", StringComparison.OrdinalIgnoreCase) == 0)
|| (listViewItem.Model is SDCardFileItem sdItem
&& Path.GetExtension(sdItem.Name).IndexOf(".gco", StringComparison.OrdinalIgnoreCase) == 0);
return isContentItem || isValidStream || isContainerLink || isGCode;
}
@ -404,6 +406,7 @@ namespace MatterHackers.MatterControl.CustomWidgets
}
public virtual bool IsHoverItem { get; set; }
public virtual bool EditMode { get; set; }
private bool isSelected = false;
@ -418,11 +421,12 @@ namespace MatterHackers.MatterControl.CustomWidgets
{
return isSelected;
}
set
{
if (isSelected != value)
{
//selectionCheckBox.Checked = value;
// selectionCheckBox.Checked = value;
isSelected = value;
UpdateColors();

View file

@ -88,7 +88,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
if (this.AnchorMate.Widget == null)
{
this.AnchorMate.Widget = this;
};
}
var popupContent = this.PopupContent();
if (popupContent == null
@ -103,14 +103,14 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
{
MenuVisible = true;
void popupContent_Closed(object sender, EventArgs e)
void PopupContent_Closed(object sender, EventArgs e)
{
// Reset menuVisible
MenuVisible = false;
popupContent.Closed -= popupContent_Closed;
popupContent.Closed -= PopupContent_Closed;
}
popupContent.Closed += popupContent_Closed;
popupContent.Closed += PopupContent_Closed;
systemWindow.ShowPopup(
this.AnchorMate,

View file

@ -154,6 +154,8 @@ namespace MatterHackers.MatterControl.PrinterCommunication
public event EventHandler<string> PrintFinished;
public event EventHandler PrintStarted;
public event EventHandler PrintCanceled;
public event EventHandler<PrintPauseEventArgs> PauseOnLayer;
@ -2147,6 +2149,8 @@ Make sure that your printer is turned on. Some printers will appear to be connec
ActivePrintTask.Commit();
Task.Run(() => this.SyncProgressToDB(printingCancellation.Token));
PrintStarted?.Invoke(this, null);
}
}
}
@ -2773,6 +2777,7 @@ Make sure that your printer is turned on. Some printers will appear to be connec
public PrintTask ActivePrintTask { get; set; }
public ExtrusionMultiplierStream ExtrusionMultiplierStream { get; private set; }
public FeedRateMultiplierStream FeedRateMultiplierStream { get; private set; }
public void TurnOffPartCoolingFan()

@ -1 +1 @@
Subproject commit 0a75bfae95beab9e256faa235fabe472aed97a59
Subproject commit b1710fc08dbd485a24f94536df3b19718d20b697