Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
/*
|
|
|
|
|
|
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.
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2018-05-11 18:41:34 -07:00
|
|
|
|
using System;
|
2017-06-21 07:43:40 -07:00
|
|
|
|
using System.IO;
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using MatterHackers.Agg;
|
|
|
|
|
|
using MatterHackers.Agg.Image;
|
2017-12-15 14:55:10 -08:00
|
|
|
|
using MatterHackers.Agg.Platform;
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
using MatterHackers.Agg.UI;
|
|
|
|
|
|
using MatterHackers.MatterControl.Library;
|
|
|
|
|
|
using MatterHackers.MatterControl.PartPreviewWindow;
|
|
|
|
|
|
using MatterHackers.VectorMath;
|
|
|
|
|
|
|
|
|
|
|
|
namespace MatterHackers.MatterControl.CustomWidgets
|
|
|
|
|
|
{
|
|
|
|
|
|
public class ListViewItemBase : GuiWidget
|
|
|
|
|
|
{
|
2018-04-21 14:59:45 -07:00
|
|
|
|
private static ImageBuffer defaultFolderIcon = AggContext.StaticData.LoadIcon(Path.Combine("FileDialog", "folder.png")).SetPreMultiply();
|
2017-12-15 14:55:10 -08:00
|
|
|
|
private static ImageBuffer defaultItemIcon = AggContext.StaticData.LoadIcon(Path.Combine("FileDialog", "file.png"));
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
|
2018-05-09 20:39:53 -07:00
|
|
|
|
protected ThemeConfig theme;
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
protected ListViewItem listViewItem;
|
|
|
|
|
|
protected View3DWidget view3DWidget;
|
|
|
|
|
|
protected bool mouseInBounds = false;
|
|
|
|
|
|
private bool mouseDownInBounds = false;
|
|
|
|
|
|
private Vector2 mouseDownAt;
|
|
|
|
|
|
|
2018-05-18 12:01:52 -07:00
|
|
|
|
public ImageWidget imageWidget;
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
protected int thumbWidth;
|
|
|
|
|
|
protected int thumbHeight;
|
|
|
|
|
|
|
2018-05-09 20:39:53 -07:00
|
|
|
|
public ListViewItemBase(ListViewItem listViewItem, int width, int height, ThemeConfig theme)
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
{
|
2018-05-09 20:39:53 -07:00
|
|
|
|
this.theme = theme;
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
this.listViewItem = listViewItem;
|
|
|
|
|
|
this.thumbWidth = width;
|
|
|
|
|
|
this.thumbHeight = height;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-06-20 15:07:21 -07:00
|
|
|
|
public async Task LoadItemThumbnail()
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
{
|
2018-06-20 15:07:21 -07:00
|
|
|
|
ILibraryItem libraryItem = listViewItem.Model;
|
|
|
|
|
|
ILibraryContainer libraryContainer = listViewItem.Container;
|
2018-05-21 13:35:17 -07:00
|
|
|
|
|
2018-06-21 21:52:47 -07:00
|
|
|
|
// Load from cache via LibraryID
|
|
|
|
|
|
var thumbnail = ApplicationController.Instance.Thumbnails.LoadCachedImage(libraryItem, thumbWidth, thumbHeight);
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
if (thumbnail != null)
|
|
|
|
|
|
{
|
2018-06-20 22:32:15 -07:00
|
|
|
|
this.SetItemThumbnail(thumbnail);
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (thumbnail == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Ask the container - allows the container to provide its own interpretation of the item thumbnail
|
2018-05-11 18:41:34 -07:00
|
|
|
|
thumbnail = await libraryContainer.GetThumbnail(libraryItem, thumbWidth, thumbHeight);
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-05-11 18:41:34 -07:00
|
|
|
|
if (thumbnail == null && libraryItem is IThumbnail)
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
{
|
|
|
|
|
|
// If the item provides its own thumbnail, try to collect it
|
2018-05-11 18:41:34 -07:00
|
|
|
|
thumbnail = await (libraryItem as IThumbnail).GetThumbnail(thumbWidth, thumbHeight);
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (thumbnail == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Ask content provider - allows type specific thumbnail creation
|
2018-05-11 18:41:34 -07:00
|
|
|
|
var contentProvider = ApplicationController.Instance.Library.GetContentProvider(libraryItem);
|
2018-05-21 13:27:06 -07:00
|
|
|
|
if (contentProvider != null)
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
{
|
|
|
|
|
|
// Before we have a thumbnail set to the content specific thumbnail
|
2017-07-28 17:35:50 -07:00
|
|
|
|
thumbnail = contentProvider.DefaultImage;
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
|
2018-06-20 16:26:25 -07:00
|
|
|
|
if (contentProvider is MeshContentProvider meshContentProvider)
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
{
|
2018-06-20 16:26:25 -07:00
|
|
|
|
// Store meshContentProvider reference
|
|
|
|
|
|
this.meshContentProvider = meshContentProvider;
|
|
|
|
|
|
|
|
|
|
|
|
// Schedule work
|
|
|
|
|
|
this.ScheduleRaytraceOperation();
|
|
|
|
|
|
}
|
2018-06-20 16:28:10 -07:00
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
// Show processing image
|
2018-06-26 08:40:28 -07:00
|
|
|
|
this.SetItemThumbnail(theme.GeneratingThumbnailIcon);
|
2018-06-20 16:28:10 -07:00
|
|
|
|
|
|
|
|
|
|
// Ask the provider for a content specific thumbnail
|
2018-06-20 22:22:37 -07:00
|
|
|
|
thumbnail = await contentProvider.GetThumbnail(libraryItem, thumbWidth, thumbHeight);
|
2018-06-20 16:28:10 -07:00
|
|
|
|
}
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (thumbnail == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Use the listview defaults
|
2018-05-11 18:41:34 -07:00
|
|
|
|
thumbnail = ((libraryItem is ILibraryContainerLink) ? defaultFolderIcon : defaultItemIcon).AlphaToPrimaryAccent();
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-06-20 22:32:15 -07:00
|
|
|
|
this.SetItemThumbnail(thumbnail);
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-06-20 16:26:25 -07:00
|
|
|
|
private void ScheduleRaytraceOperation()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (meshContentProvider == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-06-21 10:50:40 -07:00
|
|
|
|
ApplicationController.Instance.Thumbnails.QueueForGeneration(async () =>
|
2018-06-20 16:26:25 -07:00
|
|
|
|
{
|
2018-06-20 22:22:37 -07:00
|
|
|
|
// When dequeued for generation, ensure visible before raytracing. Off-screen widgets are dequeue and will reschedule if redrawn
|
2018-06-20 16:26:25 -07:00
|
|
|
|
if (!this.ActuallyVisibleOnScreen())
|
|
|
|
|
|
{
|
|
|
|
|
|
// Skip raytracing operation, requeue on next draw
|
|
|
|
|
|
raytraceSkipped = true;
|
|
|
|
|
|
raytracePending = false;
|
|
|
|
|
|
requeueRaytraceOnDraw = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
raytraceSkipped = false;
|
|
|
|
|
|
requeueRaytraceOnDraw = false;
|
|
|
|
|
|
|
|
|
|
|
|
// Show processing image
|
2018-06-26 08:40:28 -07:00
|
|
|
|
this.SetItemThumbnail(theme.GeneratingThumbnailIcon);
|
2018-06-20 16:26:25 -07:00
|
|
|
|
|
|
|
|
|
|
// Ask the MeshContentProvider to RayTrace the image
|
2018-06-20 22:22:37 -07:00
|
|
|
|
var thumbnail = await meshContentProvider.GetThumbnail(listViewItem.Model, thumbWidth, thumbHeight);
|
|
|
|
|
|
if (thumbnail != null)
|
|
|
|
|
|
{
|
2018-06-20 22:32:15 -07:00
|
|
|
|
requeueRaytraceOnDraw = false;
|
|
|
|
|
|
raytracePending = false;
|
|
|
|
|
|
|
|
|
|
|
|
this.SetItemThumbnail(thumbnail);
|
2018-06-20 22:22:37 -07:00
|
|
|
|
}
|
2018-06-20 16:26:25 -07:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-09-29 18:31:31 -07:00
|
|
|
|
internal void EnsureSelection()
|
2017-06-03 15:11:12 -07:00
|
|
|
|
{
|
2017-09-29 18:31:31 -07:00
|
|
|
|
if (this.IsSelectableContent)
|
|
|
|
|
|
{
|
2018-08-07 07:35:51 -07:00
|
|
|
|
// Clear existing selection when item is not selected and control key is not press
|
|
|
|
|
|
if (!this.IsSelected
|
|
|
|
|
|
&& !Keyboard.IsKeyDown(Keys.ControlKey))
|
2017-09-29 18:31:31 -07:00
|
|
|
|
{
|
2018-05-11 18:41:34 -07:00
|
|
|
|
listViewItem.ListView?.SelectedItems.Clear();
|
2017-09-29 18:31:31 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Any mouse down ensures selection - mouse up will evaluate if DragDrop occurred and toggle selection if not
|
2018-05-11 18:41:34 -07:00
|
|
|
|
if (!listViewItem.ListView?.SelectedItems.Contains(listViewItem) == true)
|
2017-09-29 18:31:31 -07:00
|
|
|
|
{
|
2018-05-11 18:41:34 -07:00
|
|
|
|
listViewItem.ListView?.SelectedItems.Add(listViewItem);
|
2017-09-29 18:31:31 -07:00
|
|
|
|
}
|
2017-06-03 15:11:12 -07:00
|
|
|
|
|
2017-09-29 18:31:31 -07:00
|
|
|
|
Invalidate();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-06-21 07:43:40 -07:00
|
|
|
|
|
2017-09-29 18:31:31 -07:00
|
|
|
|
internal void OnItemSelect()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.IsSelectableContent
|
|
|
|
|
|
&& !hitDragThreshold)
|
2017-06-03 15:11:12 -07:00
|
|
|
|
{
|
2018-08-07 07:35:51 -07:00
|
|
|
|
if (toggleSelection)
|
2017-06-03 15:11:12 -07:00
|
|
|
|
{
|
2018-05-11 18:41:34 -07:00
|
|
|
|
listViewItem.ListView?.SelectedItems.Remove(listViewItem);
|
2017-06-03 15:11:12 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Invalidate();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-09-29 18:31:31 -07:00
|
|
|
|
private bool IsSelectableContent
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
2018-02-12 13:05:42 -08:00
|
|
|
|
bool isContentItem = listViewItem.Model is ILibraryObject3D;
|
2018-02-12 13:55:31 -08:00
|
|
|
|
bool isValidStream = (listViewItem.Model is ILibraryAssetStream stream
|
2017-09-29 18:31:31 -07:00
|
|
|
|
&& ApplicationController.Instance.Library.IsContentFileType(stream.FileName));
|
|
|
|
|
|
bool isContainerLink = listViewItem.Model is ILibraryContainerLink;
|
|
|
|
|
|
|
|
|
|
|
|
bool isGCode = listViewItem.Model is FileSystemFileItem item && Path.GetExtension(item.FileName.ToUpper()) == ".GCODE"
|
|
|
|
|
|
|| listViewItem.Model is SDCardFileItem sdItem && Path.GetExtension(sdItem.Name.ToUpper()) == ".GCODE";
|
|
|
|
|
|
|
|
|
|
|
|
return isContentItem || isValidStream || isContainerLink || isGCode;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-05-18 12:01:52 -07:00
|
|
|
|
public event EventHandler ImageSet;
|
|
|
|
|
|
|
2018-06-20 22:32:15 -07:00
|
|
|
|
protected void SetItemThumbnail(ImageBuffer thumbnail)
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
{
|
|
|
|
|
|
if (thumbnail != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Resize canvas to target as fallback
|
|
|
|
|
|
if (thumbnail.Width < thumbWidth || thumbnail.Height < thumbHeight)
|
|
|
|
|
|
{
|
2018-05-11 18:41:34 -07:00
|
|
|
|
thumbnail = ListView.ResizeCanvas(thumbnail, thumbWidth, thumbHeight);
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
}
|
|
|
|
|
|
else if (thumbnail.Width > thumbWidth || thumbnail.Height > thumbHeight)
|
|
|
|
|
|
{
|
|
|
|
|
|
thumbnail = LibraryProviderHelpers.ResizeImage(thumbnail, thumbWidth, thumbHeight);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-04-24 07:59:46 -07:00
|
|
|
|
if (GuiWidget.DeviceScale != 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
thumbnail = thumbnail.CreateScaledImage(GuiWidget.DeviceScale);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
// TODO: Resolve and implement
|
|
|
|
|
|
// Allow the container to draw an overlay - use signal interface or add method to interface?
|
|
|
|
|
|
//var iconWithOverlay = ActiveContainer.DrawOverlay()
|
2018-05-30 16:42:17 -07:00
|
|
|
|
|
|
|
|
|
|
if (thumbnail != null
|
2018-06-26 10:09:55 -07:00
|
|
|
|
&& this.imageWidget != null
|
2018-05-30 16:42:17 -07:00
|
|
|
|
&& (this.imageWidget.Image == null
|
|
|
|
|
|
|| !thumbnail.Equals(this.imageWidget.Image, 5)))
|
2018-05-30 16:28:54 -07:00
|
|
|
|
{
|
|
|
|
|
|
this.imageWidget.Image = thumbnail;
|
2018-05-30 16:42:17 -07:00
|
|
|
|
this.ImageSet?.Invoke(this, null);
|
|
|
|
|
|
this.Invalidate();
|
|
|
|
|
|
}
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-05-09 20:39:53 -07:00
|
|
|
|
public override Color BorderColor
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
{
|
2018-05-09 20:39:53 -07:00
|
|
|
|
get => (this.IsSelected || mouseInBounds) ? theme.Colors.PrimaryAccentColor : base.BorderColor;
|
|
|
|
|
|
set => base.BorderColor = value;
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-09-29 18:31:31 -07:00
|
|
|
|
private bool hitDragThreshold = false;
|
|
|
|
|
|
|
2018-08-07 07:35:51 -07:00
|
|
|
|
private bool toggleSelection = false;
|
2017-09-29 18:31:31 -07:00
|
|
|
|
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
public override void OnMouseDown(MouseEventArgs mouseEvent)
|
|
|
|
|
|
{
|
|
|
|
|
|
mouseDownInBounds = true;
|
|
|
|
|
|
mouseDownAt = mouseEvent.Position;
|
2017-09-29 18:31:31 -07:00
|
|
|
|
hitDragThreshold = false;
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
|
2018-08-07 07:35:51 -07:00
|
|
|
|
// Used to toggle selection on selected items - revised to require control key
|
|
|
|
|
|
toggleSelection = this.IsSelected && Keyboard.IsKeyDown(Keys.ControlKey);
|
2017-09-29 18:31:31 -07:00
|
|
|
|
|
|
|
|
|
|
this.EnsureSelection();
|
2017-09-19 19:59:55 -07:00
|
|
|
|
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
if (IsDoubleClick(mouseEvent))
|
|
|
|
|
|
{
|
|
|
|
|
|
listViewItem.OnDoubleClick();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// On mouse down update the view3DWidget reference that will be used in MouseMove and MouseUp
|
2017-09-19 19:59:55 -07:00
|
|
|
|
view3DWidget = ApplicationController.Instance.DragDropData.View3DWidget;
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
|
|
|
|
|
|
base.OnMouseDown(mouseEvent);
|
2018-05-21 12:57:59 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-06-20 16:19:40 -07:00
|
|
|
|
public override void OnLoad(EventArgs args)
|
2018-05-21 12:57:59 -07:00
|
|
|
|
{
|
2018-06-20 16:19:40 -07:00
|
|
|
|
// On first draw, lookup and set best thumbnail
|
|
|
|
|
|
this.LoadItemThumbnail().ConfigureAwait(false);
|
|
|
|
|
|
|
2018-05-21 12:57:59 -07:00
|
|
|
|
base.OnLoad(args);
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-06-20 16:19:40 -07:00
|
|
|
|
public override void OnDraw(Graphics2D graphics2D)
|
2018-05-21 13:35:17 -07:00
|
|
|
|
{
|
2018-06-20 14:55:56 -07:00
|
|
|
|
if (requeueRaytraceOnDraw
|
2018-05-21 13:35:17 -07:00
|
|
|
|
&& !raytracePending
|
2018-06-20 14:55:56 -07:00
|
|
|
|
&& raytraceSkipped)
|
2018-05-21 13:35:17 -07:00
|
|
|
|
{
|
|
|
|
|
|
raytracePending = true;
|
|
|
|
|
|
|
|
|
|
|
|
// Requeue thumbnail generation
|
2018-06-20 16:27:00 -07:00
|
|
|
|
this.ScheduleRaytraceOperation();
|
2018-05-21 13:35:17 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
base.OnDraw(graphics2D);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
public override void OnMouseMove(MouseEventArgs mouseEvent)
|
|
|
|
|
|
{
|
|
|
|
|
|
var delta = mouseDownAt - mouseEvent.Position;
|
|
|
|
|
|
|
2017-09-19 19:59:55 -07:00
|
|
|
|
// If mouseDown on us and we've moved past are drag determination threshold, notify view3DWidget
|
2018-02-15 14:27:01 -08:00
|
|
|
|
if (mouseDownInBounds && delta.Length > 40
|
2018-04-27 17:43:46 -07:00
|
|
|
|
&& view3DWidget != null
|
2018-02-15 14:27:01 -08:00
|
|
|
|
&& !(listViewItem.Model is MissingFileItem))
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
{
|
2017-09-29 18:31:31 -07:00
|
|
|
|
hitDragThreshold = true;
|
|
|
|
|
|
|
2017-09-19 19:59:55 -07:00
|
|
|
|
// Performs move and possible Scene add in View3DWidget
|
|
|
|
|
|
view3DWidget.ExternalDragOver(screenSpaceMousePosition: this.TransformToScreenSpace(mouseEvent.Position));
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
base.OnMouseMove(mouseEvent);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void OnMouseUp(MouseEventArgs mouseEvent)
|
|
|
|
|
|
{
|
2017-09-29 18:31:31 -07:00
|
|
|
|
this.OnItemSelect();
|
|
|
|
|
|
|
2018-04-27 17:43:46 -07:00
|
|
|
|
if (view3DWidget?.DragOperationActive == true)
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
{
|
|
|
|
|
|
// Mouse and widget positions
|
|
|
|
|
|
var screenSpaceMousePosition = this.TransformToScreenSpace(mouseEvent.Position);
|
2018-04-27 17:43:46 -07:00
|
|
|
|
var meshViewerPosition = view3DWidget.meshViewerWidget.TransformToScreenSpace(view3DWidget.meshViewerWidget.LocalBounds);
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
|
2017-09-19 19:59:55 -07:00
|
|
|
|
// Notify of drag operation complete
|
|
|
|
|
|
view3DWidget.FinishDrop(mouseUpInBounds: meshViewerPosition.Contains(screenSpaceMousePosition));
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-04-27 17:43:46 -07:00
|
|
|
|
view3DWidget = null;
|
|
|
|
|
|
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
mouseDownInBounds = false;
|
|
|
|
|
|
base.OnMouseUp(mouseEvent);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void OnMouseEnterBounds(MouseEventArgs mouseEvent)
|
|
|
|
|
|
{
|
|
|
|
|
|
base.OnMouseEnterBounds(mouseEvent);
|
|
|
|
|
|
mouseInBounds = true;
|
|
|
|
|
|
UpdateHoverState();
|
|
|
|
|
|
Invalidate();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void OnMouseLeaveBounds(MouseEventArgs mouseEvent)
|
|
|
|
|
|
{
|
|
|
|
|
|
mouseInBounds = false;
|
|
|
|
|
|
base.OnMouseLeaveBounds(mouseEvent);
|
|
|
|
|
|
UpdateHoverState();
|
|
|
|
|
|
Invalidate();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected virtual void UpdateColors()
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-03-25 15:35:20 -07:00
|
|
|
|
protected virtual void UpdateHoverState()
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public virtual bool IsHoverItem { get; set; }
|
|
|
|
|
|
public virtual bool EditMode { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
private bool isSelected = false;
|
2018-05-21 13:35:17 -07:00
|
|
|
|
private bool raytraceSkipped;
|
2018-06-20 14:55:56 -07:00
|
|
|
|
private bool requeueRaytraceOnDraw;
|
2018-05-21 13:35:17 -07:00
|
|
|
|
private bool raytracePending;
|
2018-06-20 16:26:25 -07:00
|
|
|
|
private MeshContentProvider meshContentProvider;
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
|
|
|
|
|
|
public bool IsSelected
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return isSelected;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
if (isSelected != value)
|
|
|
|
|
|
{
|
|
|
|
|
|
//selectionCheckBox.Checked = value;
|
|
|
|
|
|
|
|
|
|
|
|
isSelected = value;
|
|
|
|
|
|
UpdateColors();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|