Add per workspace library context
- Add WrappedLibraryContainer for per workspace containers (support for printer specific containers) - Issue MatterHackers/MCCentral#4710 All printers and parts share the same library view
This commit is contained in:
parent
aaa335f8c4
commit
a22866abcf
12 changed files with 290 additions and 39 deletions
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
Copyright (c) 2018, 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.Collections.Generic;
|
||||
using System.IO;
|
||||
using MatterHackers.Agg.Platform;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
|
||||
namespace MatterHackers.MatterControl.Library
|
||||
{
|
||||
public class OpenPrintersContainer : LibraryContainer
|
||||
{
|
||||
public OpenPrintersContainer()
|
||||
{
|
||||
this.ChildContainers = new List<ILibraryContainerLink>();
|
||||
this.Items = new List<ILibraryItem>();
|
||||
this.Name = "Printers".Localize();
|
||||
}
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
this.Items.Clear();
|
||||
this.ChildContainers.Clear();
|
||||
|
||||
foreach(var printer in ApplicationController.Instance.ActivePrinters)
|
||||
{
|
||||
this.ChildContainers.Add(
|
||||
new DynamicContainerLink(
|
||||
() => printer.Settings.GetValue(SettingsKey.printer_name),
|
||||
AggContext.StaticData.LoadIcon(Path.Combine("Library", "sd_20x20.png")),
|
||||
AggContext.StaticData.LoadIcon(Path.Combine("Library", "sd_folder.png")),
|
||||
() => new PrinterContainer(printer),
|
||||
() =>
|
||||
{
|
||||
return printer.Settings.GetValue<bool>(SettingsKey.has_sd_card_reader);
|
||||
})
|
||||
{
|
||||
IsReadOnly = true
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
Copyright (c) 2018, 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.Collections.Generic;
|
||||
using System.IO;
|
||||
using MatterHackers.Agg.Platform;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
|
||||
namespace MatterHackers.MatterControl.Library
|
||||
{
|
||||
// Printer specific containers
|
||||
public class PrinterContainer : LibraryContainer
|
||||
{
|
||||
private PrinterConfig printer;
|
||||
|
||||
public PrinterContainer(PrinterConfig printer)
|
||||
{
|
||||
this.printer = printer;
|
||||
this.ChildContainers = new List<ILibraryContainerLink>();
|
||||
this.Items = new List<ILibraryItem>();
|
||||
this.Name = "Printers".Localize();
|
||||
}
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
this.Items.Clear();
|
||||
this.ChildContainers.Clear();
|
||||
|
||||
this.ChildContainers.Add(
|
||||
new DynamicContainerLink(
|
||||
() => "SD Card".Localize(),
|
||||
AggContext.StaticData.LoadIcon(Path.Combine("Library", "sd_20x20.png")),
|
||||
AggContext.StaticData.LoadIcon(Path.Combine("Library", "sd_folder.png")),
|
||||
() => new SDCardContainer(printer),
|
||||
() =>
|
||||
{
|
||||
return printer.Settings.GetValue<bool>(SettingsKey.has_sd_card_reader);
|
||||
})
|
||||
{
|
||||
IsReadOnly = true
|
||||
});
|
||||
|
||||
this.ChildContainers.Add(
|
||||
new DynamicContainerLink(
|
||||
() => "Calibration Parts".Localize(),
|
||||
AggContext.StaticData.LoadIcon(Path.Combine("Library", "folder_20x20.png")),
|
||||
AggContext.StaticData.LoadIcon(Path.Combine("Library", "folder.png")),
|
||||
() => new CalibrationPartsContainer())
|
||||
{
|
||||
IsReadOnly = true
|
||||
});
|
||||
|
||||
// TODO: An enumerable list of serialized container paths (or some other markup) to construct for this printer
|
||||
// printer.Settings.GetValue(SettingsKey.library_containers);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (c) 2017, John Lewin
|
||||
Copyright (c) 2018, John Lewin
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -32,7 +32,6 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.Image;
|
||||
using MatterHackers.Agg.Platform;
|
||||
using MatterHackers.Agg.UI;
|
||||
|
|
@ -45,8 +44,6 @@ namespace MatterHackers.MatterControl.Library
|
|||
{
|
||||
private bool gotBeginFileList;
|
||||
|
||||
private EventHandler unregisterEvents;
|
||||
|
||||
private PrinterConfig printer;
|
||||
|
||||
private AutoResetEvent autoResetEvent;
|
||||
|
|
@ -56,7 +53,7 @@ namespace MatterHackers.MatterControl.Library
|
|||
this.ChildContainers = new List<ILibraryContainerLink>();
|
||||
this.Items = new List<ILibraryItem>();
|
||||
this.Name = "SD Card".Localize();
|
||||
|
||||
this.printer = printer;
|
||||
void CommunicationStateChanged(object s, EventArgs e)
|
||||
{
|
||||
switch (printer.Connection.CommunicationState)
|
||||
|
|
@ -150,8 +147,6 @@ namespace MatterHackers.MatterControl.Library
|
|||
|
||||
public override void Dispose()
|
||||
{
|
||||
unregisterEvents?.Invoke(this, null);
|
||||
|
||||
// Ensure released
|
||||
autoResetEvent?.Set();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue