Making the windows understand their closed states better.
Made print history have a data and a view
This commit is contained in:
parent
9679512a7b
commit
c4a6a9960a
9 changed files with 146 additions and 86 deletions
|
|
@ -166,10 +166,15 @@ namespace MatterHackers.MatterControl
|
|||
HelpTextWidget.Instance.HideHoverText();
|
||||
}
|
||||
|
||||
public override void OnClosed(EventArgs e)
|
||||
public override void OnClosing(out bool cancelClose)
|
||||
{
|
||||
lastPanelIndexOnClose = PanelIndex;
|
||||
lastAdvanceControlsIndex = advancedControlsTabControl.SelectedTabIndex;
|
||||
base.OnClosing(out cancelClose);
|
||||
}
|
||||
|
||||
public override void OnClosed(EventArgs e)
|
||||
{
|
||||
if (unregisterEvents != null)
|
||||
{
|
||||
unregisterEvents(this, null);
|
||||
|
|
|
|||
|
|
@ -98,6 +98,11 @@ namespace MatterHackers.MatterControl
|
|||
UiThread.RunOnIdle((state) =>
|
||||
{
|
||||
widescreenPanel.StoreUiState();
|
||||
|
||||
// give the widget a chance to hear about the close before they are actually colsed.
|
||||
bool cancelClose;
|
||||
this.OnClosing(out cancelClose);
|
||||
|
||||
this.CloseAndRemoveAllChildren();
|
||||
AddElements();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -109,9 +109,14 @@ namespace MatterHackers.MatterControl
|
|||
QueueTabPage.Text = string.Format(queueString, QueueData.Instance.Count);
|
||||
}
|
||||
|
||||
public override void OnClosed(EventArgs e)
|
||||
public override void OnClosing(out bool cancelClose)
|
||||
{
|
||||
tabStateBeforeClose = SelectedTabIndex;
|
||||
base.OnClosing(out cancelClose);
|
||||
}
|
||||
|
||||
public override void OnClosed(EventArgs e)
|
||||
{
|
||||
if (unregisterEvents != null)
|
||||
{
|
||||
unregisterEvents(this, null);
|
||||
|
|
|
|||
|
|
@ -136,11 +136,18 @@ namespace MatterHackers.MatterControl
|
|||
base.OnClosed(e);
|
||||
}
|
||||
|
||||
void AdvancedControlsClosed(object sender, EventArgs e)
|
||||
{
|
||||
advancedControls.Closed -= AdvancedControlsClosed;
|
||||
advancedControls = null;
|
||||
}
|
||||
|
||||
TabControl CreateNewAdvancedControlsTab(SliceSettingsWidget.UiState sliceSettingsUiState)
|
||||
{
|
||||
StoreUiState();
|
||||
|
||||
advancedControls = new TabControl();
|
||||
advancedControls.Closed += AdvancedControlsClosed;
|
||||
advancedControls.AnchorAll();
|
||||
advancedControls.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
|
||||
advancedControls.TabBar.BorderColor = ActiveTheme.Instance.SecondaryTextColor;
|
||||
|
|
|
|||
|
|
@ -119,11 +119,12 @@
|
|||
<Compile Include="PrinterCommunication\Io\PrinterIoBase.cs" />
|
||||
<Compile Include="PrinterCommunication\Io\PrinterIoGCodeFile.cs" />
|
||||
<Compile Include="PrinterCommunication\Io\PrinterIoInjectionFifo.cs" />
|
||||
<Compile Include="PrintHistory\PrintHistoryData.cs" />
|
||||
<Compile Include="PrintLibrary\LibraryData.cs" />
|
||||
<Compile Include="PrintQueue\OptionsMenu\ExportToFolderFeedbackWindow.cs" />
|
||||
<Compile Include="EeProm\EePromMarlinSettings.cs" />
|
||||
<Compile Include="PrinterControls\EditLevelingSettingsWindow.cs" />
|
||||
<Compile Include="PrintHistory\PrintHistoryListControl.cs" />
|
||||
<Compile Include="PrintHistory\PrintHistoryDataView.cs" />
|
||||
<Compile Include="PrintHistory\PrintHistoryListItem.cs" />
|
||||
<Compile Include="PrintHistory\PrintHistoryWidget.cs" />
|
||||
<Compile Include="PrintQueue\QueueData.cs" />
|
||||
|
|
|
|||
|
|
@ -771,7 +771,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
displayOptionsContainer.Visible = expandDisplayOptions.Checked;
|
||||
}
|
||||
|
||||
public override void OnClosed(EventArgs e)
|
||||
public override void OnClosing(out bool cancelClose)
|
||||
{
|
||||
GuiWidget parent = Parent;
|
||||
while (parent as SystemWindow == null)
|
||||
|
|
@ -794,7 +794,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
SlicingQueue.Instance.CancelCurrentSlicing();
|
||||
}
|
||||
}
|
||||
base.OnClosed(e);
|
||||
|
||||
base.OnClosing(out cancelClose);
|
||||
}
|
||||
|
||||
void generateButton_Click(object sender, MouseEventArgs mouseEvent)
|
||||
|
|
|
|||
101
PrintHistory/PrintHistoryData.cs
Normal file
101
PrintHistory/PrintHistoryData.cs
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
Copyright (c) 2014, Kevin Pope
|
||||
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 MatterHackers.Agg;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.MatterControl.DataStorage;
|
||||
using MatterHackers.MatterControl.PrinterCommunication;
|
||||
using MatterHackers.VectorMath;
|
||||
|
||||
namespace MatterHackers.MatterControl.PrintHistory
|
||||
{
|
||||
public class PrintHistoryData
|
||||
{
|
||||
static PrintHistoryData instance;
|
||||
public bool ShowTimestamp;
|
||||
|
||||
public static PrintHistoryData Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
instance = new PrintHistoryData();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
private List<string> GetLibraryParts()
|
||||
{
|
||||
List<string> libraryFilesToPreload = new List<string>();
|
||||
string setupSettingsPathAndFile = Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath, "OEMSettings", "PreloadedLibraryFiles.txt");
|
||||
if (System.IO.File.Exists(setupSettingsPathAndFile))
|
||||
{
|
||||
try
|
||||
{
|
||||
string[] lines = System.IO.File.ReadAllLines(setupSettingsPathAndFile);
|
||||
foreach (string line in lines)
|
||||
{
|
||||
//Ignore commented lines
|
||||
if (!line.StartsWith("#"))
|
||||
{
|
||||
string settingLine = line.Trim();
|
||||
libraryFilesToPreload.Add(settingLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
return libraryFilesToPreload;
|
||||
}
|
||||
|
||||
public static readonly int RecordLimit = 20;
|
||||
public IEnumerable<DataStorage.PrintTask> GetHistoryItems(int recordCount)
|
||||
{
|
||||
string query;
|
||||
if (UserSettings.Instance.get("PrintHistoryFilterShowCompleted") == "true")
|
||||
{
|
||||
query = string.Format("SELECT * FROM PrintTask WHERE PrintComplete = 1 ORDER BY PrintStart DESC LIMIT {0};", recordCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
query = string.Format("SELECT * FROM PrintTask ORDER BY PrintStart DESC LIMIT {0};", recordCount);
|
||||
}
|
||||
IEnumerable<DataStorage.PrintTask> result = (IEnumerable<DataStorage.PrintTask>)DataStorage.Datastore.Instance.dbSQLite.Query<DataStorage.PrintTask>(query);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -62,24 +62,10 @@ namespace MatterHackers.MatterControl.PrintHistory
|
|||
}
|
||||
}
|
||||
|
||||
public class PrintHistoryListControl : ScrollableWidget
|
||||
public class PrintHistoryDataView : ScrollableWidget
|
||||
{
|
||||
static PrintHistoryListControl instance;
|
||||
public bool ShowTimestamp;
|
||||
|
||||
public static PrintHistoryListControl Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
instance = new PrintHistoryListControl();
|
||||
instance.LoadHistoryItems();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetDisplayAttributes()
|
||||
{
|
||||
this.MinimumSize = new Vector2(0, 200);
|
||||
|
|
@ -89,65 +75,20 @@ namespace MatterHackers.MatterControl.PrintHistory
|
|||
this.ScrollArea.Padding = new BorderDouble(3, 3, 15, 3);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private List<string> GetLibraryParts()
|
||||
{
|
||||
List<string> libraryFilesToPreload = new List<string>();
|
||||
string setupSettingsPathAndFile = Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath, "OEMSettings", "PreloadedLibraryFiles.txt");
|
||||
if (System.IO.File.Exists(setupSettingsPathAndFile))
|
||||
{
|
||||
try
|
||||
{
|
||||
string[] lines = System.IO.File.ReadAllLines(setupSettingsPathAndFile);
|
||||
foreach (string line in lines)
|
||||
{
|
||||
//Ignore commented lines
|
||||
if (!line.StartsWith("#"))
|
||||
{
|
||||
string settingLine = line.Trim();
|
||||
libraryFilesToPreload.Add(settingLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
return libraryFilesToPreload;
|
||||
}
|
||||
|
||||
int RecordLimit = 20;
|
||||
IEnumerable<DataStorage.PrintTask> GetHistoryItems(int recordCount)
|
||||
{
|
||||
string query;
|
||||
if (UserSettings.Instance.get("PrintHistoryFilterShowCompleted") == "true")
|
||||
{
|
||||
query = string.Format("SELECT * FROM PrintTask WHERE PrintComplete = 1 ORDER BY PrintStart DESC LIMIT {0};", recordCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
query = string.Format("SELECT * FROM PrintTask ORDER BY PrintStart DESC LIMIT {0};", recordCount);
|
||||
}
|
||||
IEnumerable<DataStorage.PrintTask> result = (IEnumerable<DataStorage.PrintTask>)DataStorage.Datastore.Instance.dbSQLite.Query<DataStorage.PrintTask>(query);
|
||||
return result;
|
||||
}
|
||||
|
||||
public void LoadHistoryItems(int NumItemsToLoad = 0)
|
||||
{
|
||||
if (NumItemsToLoad == 0 || NumItemsToLoad < RecordLimit)
|
||||
if (NumItemsToLoad == 0 || NumItemsToLoad < PrintHistoryData.RecordLimit)
|
||||
{
|
||||
NumItemsToLoad = RecordLimit;
|
||||
NumItemsToLoad = PrintHistoryData.RecordLimit;
|
||||
}
|
||||
|
||||
RemoveListItems();
|
||||
IEnumerable<DataStorage.PrintTask> partFiles = GetHistoryItems(NumItemsToLoad);
|
||||
IEnumerable<DataStorage.PrintTask> partFiles = PrintHistoryData.Instance.GetHistoryItems(NumItemsToLoad);
|
||||
if (partFiles != null)
|
||||
{
|
||||
foreach (PrintTask part in partFiles)
|
||||
{
|
||||
PrintHistoryListControl.Instance.AddChild(new PrintHistoryListItem(part, ShowTimestamp));
|
||||
AddChild(new PrintHistoryListItem(part, ShowTimestamp));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -155,7 +96,6 @@ namespace MatterHackers.MatterControl.PrintHistory
|
|||
|
||||
protected FlowLayoutWidget topToBottomItemList;
|
||||
|
||||
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
|
|
@ -164,9 +104,7 @@ namespace MatterHackers.MatterControl.PrintHistory
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public PrintHistoryListControl()
|
||||
public PrintHistoryDataView()
|
||||
{
|
||||
ShowTimestamp = (UserSettings.Instance.get("PrintHistoryFilterShowTimestamp") == "true");
|
||||
|
||||
|
|
@ -177,8 +115,9 @@ namespace MatterHackers.MatterControl.PrintHistory
|
|||
topToBottomItemList = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
||||
topToBottomItemList.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth;
|
||||
base.AddChild(topToBottomItemList);
|
||||
AddHandlers();
|
||||
|
||||
AddHandlers();
|
||||
|
||||
LoadHistoryItems();
|
||||
}
|
||||
|
||||
void AddHandlers()
|
||||
|
|
@ -54,6 +54,7 @@ namespace MatterHackers.MatterControl.PrintHistory
|
|||
Button deleteFromLibraryButton;
|
||||
CheckBox showOnlyCompletedCheckbox;
|
||||
CheckBox showTimestampCheckbox;
|
||||
PrintHistoryDataView historyView;
|
||||
|
||||
public PrintHistoryWidget()
|
||||
{
|
||||
|
|
@ -64,9 +65,6 @@ namespace MatterHackers.MatterControl.PrintHistory
|
|||
|
||||
FlowLayoutWidget allControls = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
||||
{
|
||||
|
||||
|
||||
|
||||
FlowLayoutWidget completedStatsContainer = new FlowLayoutWidget();
|
||||
completedStatsContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
|
||||
completedStatsContainer.Padding = new BorderDouble(6, 2);
|
||||
|
|
@ -115,11 +113,8 @@ namespace MatterHackers.MatterControl.PrintHistory
|
|||
}
|
||||
|
||||
allControls.AddChild(searchPanel);
|
||||
if (PrintHistoryListControl.Instance.Parent != null)
|
||||
{
|
||||
PrintHistoryListControl.Instance.Parent.RemoveChild(PrintHistoryListControl.Instance);
|
||||
}
|
||||
allControls.AddChild(PrintHistoryListControl.Instance);
|
||||
historyView = new PrintHistoryDataView();
|
||||
allControls.AddChild(historyView);
|
||||
allControls.AddChild(buttonPanel);
|
||||
}
|
||||
allControls.AnchorAll();
|
||||
|
|
@ -145,7 +140,8 @@ namespace MatterHackers.MatterControl.PrintHistory
|
|||
{
|
||||
UserSettings.Instance.set("PrintHistoryFilterShowCompleted", "false");
|
||||
}
|
||||
PrintHistoryListControl.Instance.LoadHistoryItems();
|
||||
|
||||
historyView.LoadHistoryItems();
|
||||
}
|
||||
|
||||
private void UpdateHistoryFilterShowTimestamp(object sender, EventArgs e)
|
||||
|
|
@ -158,8 +154,8 @@ namespace MatterHackers.MatterControl.PrintHistory
|
|||
{
|
||||
UserSettings.Instance.set("PrintHistoryFilterShowTimestamp", "false");
|
||||
}
|
||||
PrintHistoryListControl.Instance.ShowTimestamp = showTimestampCheckbox.Checked;
|
||||
PrintHistoryListControl.Instance.LoadHistoryItems();
|
||||
historyView.ShowTimestamp = showTimestampCheckbox.Checked;
|
||||
historyView.LoadHistoryItems();
|
||||
}
|
||||
|
||||
private int GetCompletedPrints()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue