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;
|
2018-08-03 23:30:11 -07:00
|
|
|
|
using System.Linq;
|
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;
|
2021-05-21 15:23:25 -07:00
|
|
|
|
using MatterHackers.ImageProcessing;
|
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.MatterControl.Library;
|
|
|
|
|
|
using MatterHackers.MatterControl.PartPreviewWindow;
|
2018-08-03 23:30:11 -07:00
|
|
|
|
using MatterHackers.MatterControl.PrintQueue;
|
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.VectorMath;
|
|
|
|
|
|
|
|
|
|
|
|
namespace MatterHackers.MatterControl.CustomWidgets
|
|
|
|
|
|
{
|
|
|
|
|
|
public class ListViewItemBase : GuiWidget
|
|
|
|
|
|
{
|
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-08-07 17:31:08 -07:00
|
|
|
|
private ImageBuffer overflowIcon;
|
|
|
|
|
|
|
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-08-07 17:31:08 -07:00
|
|
|
|
|
2023-10-03 16:17:01 -07:00
|
|
|
|
overflowIcon = StaticData.Instance.LoadIcon(Path.Combine("ViewTransformControls", "overflow.png"), 32, 32).GrayToColor(theme.TextColor);
|
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-03 23:30:11 -07:00
|
|
|
|
public bool HasMenu { get; set; } = false;
|
|
|
|
|
|
|
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-10-06 09:20:27 -07:00
|
|
|
|
// On first draw, lookup and set best thumbnail
|
|
|
|
|
|
await ApplicationController.Instance.Library.LoadItemThumbnail(
|
2018-10-06 13:51:09 -07:00
|
|
|
|
this.SetSizedThumbnail,
|
2018-10-06 09:20:27 -07:00
|
|
|
|
(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-10-06 09:20:27 -07:00
|
|
|
|
// Store meshContentProvider reference
|
|
|
|
|
|
this.meshContentProvider = meshContentProvider;
|
|
|
|
|
|
|
|
|
|
|
|
// Schedule work
|
|
|
|
|
|
this.ScheduleRaytraceOperation();
|
|
|
|
|
|
},
|
|
|
|
|
|
listViewItem.Model,
|
|
|
|
|
|
listViewItem.Container,
|
|
|
|
|
|
this.thumbWidth,
|
|
|
|
|
|
this.thumbHeight,
|
|
|
|
|
|
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-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-10-06 13:51:09 -07:00
|
|
|
|
this.SetUnsizedThumbnail(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;
|
|
|
|
|
|
|
2020-09-10 09:50:33 -07:00
|
|
|
|
if (GuiWidget.DeviceScale != 1
|
|
|
|
|
|
&& thumbnail.Width != thumbWidth * GuiWidget.DeviceScale)
|
|
|
|
|
|
{
|
|
|
|
|
|
thumbnail = thumbnail.CreateScaledImage(GuiWidget.DeviceScale);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-10-22 17:44:08 -07:00
|
|
|
|
if (thumbnail.Width != thumbWidth
|
|
|
|
|
|
|| thumbnail.Height != thumbHeight)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.SetUnsizedThumbnail(thumbnail);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
this.SetSizedThumbnail(thumbnail);
|
2018-11-05 17:27:06 -08:00
|
|
|
|
|
|
|
|
|
|
if (listViewItem.Container is ILibraryWritableContainer writableContainer)
|
|
|
|
|
|
{
|
|
|
|
|
|
writableContainer.SetThumbnail(listViewItem.Model, thumbWidth, thumbHeight, thumbnail);
|
|
|
|
|
|
}
|
2018-10-22 17:44:08 -07:00
|
|
|
|
}
|
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
|
2021-01-23 09:19:08 -08:00
|
|
|
|
&& !Keyboard.IsKeyDown(Keys.Control))
|
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;
|
2020-07-03 12:05:28 -07:00
|
|
|
|
bool isValidStream = listViewItem.Model is ILibraryAssetStream stream
|
|
|
|
|
|
&& ApplicationController.Instance.Library.IsContentFileType(stream.FileName);
|
2017-09-29 18:31:31 -07:00
|
|
|
|
bool isContainerLink = listViewItem.Model is ILibraryContainerLink;
|
|
|
|
|
|
|
2020-07-03 12:05:28 -07:00
|
|
|
|
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);
|
2017-09-29 18:31:31 -07:00
|
|
|
|
|
|
|
|
|
|
return isContentItem || isValidStream || isContainerLink || isGCode;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-10-06 13:51:09 -07:00
|
|
|
|
protected void SetUnsizedThumbnail(ImageBuffer thumbnail)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.SetSizedThumbnail(
|
|
|
|
|
|
ApplicationController.Instance.Library.EnsureCorrectThumbnailSizing(
|
2018-10-22 17:44:08 -07:00
|
|
|
|
thumbnail,
|
2018-10-06 13:51:09 -07:00
|
|
|
|
thumbWidth,
|
2020-09-10 09:50:33 -07:00
|
|
|
|
thumbHeight,
|
|
|
|
|
|
(image) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
SetSizedThumbnail(image);
|
|
|
|
|
|
}));
|
2018-10-06 13:51:09 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void SetSizedThumbnail(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
|
|
|
|
{
|
2018-10-06 09:20:27 -07:00
|
|
|
|
if (thumbnail != null
|
|
|
|
|
|
&& this.imageWidget != null
|
|
|
|
|
|
&& (this.imageWidget.Image == null
|
|
|
|
|
|
|| !thumbnail.Equals(this.imageWidget.Image, 5)))
|
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-10-06 09:20:27 -07:00
|
|
|
|
this.imageWidget.Image = thumbnail;
|
|
|
|
|
|
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-10-15 18:25:53 -07:00
|
|
|
|
get => (this.IsSelected || mouseInBounds) ? theme.PrimaryAccentColor : base.BorderColor;
|
2018-05-09 20:39:53 -07:00
|
|
|
|
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
|
2021-01-23 09:19:08 -08:00
|
|
|
|
toggleSelection = this.IsSelected && Keyboard.IsKeyDown(Keys.Control);
|
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))
|
|
|
|
|
|
{
|
2022-02-10 12:06:48 -08:00
|
|
|
|
listViewItem.OnDoubleClick(mouseEvent);
|
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
|
|
|
|
}
|
2022-02-10 12:06:48 -08:00
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
listViewItem.OnClick(mouseEvent);
|
|
|
|
|
|
}
|
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
|
|
|
|
|
|
|
|
|
|
// 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-08-03 23:30:11 -07:00
|
|
|
|
foreach (var child in Children)
|
|
|
|
|
|
{
|
|
|
|
|
|
child.Selectable = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-06-20 16:19:40 -07:00
|
|
|
|
// On first draw, lookup and set best thumbnail
|
2018-12-27 15:54:45 -08:00
|
|
|
|
Task.Run(this.LoadItemThumbnail);
|
2018-06-20 16:19:40 -07:00
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
2018-08-03 23:30:11 -07:00
|
|
|
|
if (this.mouseInBounds
|
|
|
|
|
|
&& this.HasMenu)
|
|
|
|
|
|
{
|
|
|
|
|
|
var bounds = this.LocalBounds;
|
|
|
|
|
|
graphics2D.Render(overflowIcon, new Point2D(bounds.Right - 32, bounds.Top - 32 - 3));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
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
|
2022-02-10 12:06:48 -08:00
|
|
|
|
if (LibraryBrowserPage.AllowDragToBed
|
|
|
|
|
|
&& 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
|
2021-10-19 10:19:34 -07:00
|
|
|
|
var listView = this.Parents<LibraryListView>().First();
|
|
|
|
|
|
var posRelListView = this.TransformToParentSpace(listView, mouseEvent.Position);
|
|
|
|
|
|
if (!listView.LocalBounds.Contains(posRelListView))
|
|
|
|
|
|
{
|
|
|
|
|
|
view3DWidget.ExternalDragOver(screenSpaceMousePosition: this.TransformToScreenSpace(mouseEvent.Position), sourceWidget: this.listViewItem.ListView);
|
|
|
|
|
|
}
|
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);
|
2020-09-11 19:59:14 -07:00
|
|
|
|
var meshViewerPosition = view3DWidget.Object3DControlLayer.TransformToScreenSpace(view3DWidget.Object3DControlLayer.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();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-07-23 18:19:04 -07:00
|
|
|
|
public override void OnKeyDown(KeyEventArgs keyEvent)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!keyEvent.Handled)
|
|
|
|
|
|
{
|
|
|
|
|
|
var listView = listViewItem.ListView;
|
|
|
|
|
|
if (listView != null
|
|
|
|
|
|
&& listView.SelectedItems.Count == 1
|
|
|
|
|
|
&& listView.SelectedItems.FirstOrDefault()?.Model is ILibraryItem firstItem
|
|
|
|
|
|
&& !firstItem.IsProtected
|
|
|
|
|
|
&& listView.ActiveContainer is ILibraryWritableContainer)
|
|
|
|
|
|
{
|
|
|
|
|
|
switch (keyEvent.KeyCode)
|
|
|
|
|
|
{
|
|
|
|
|
|
case Keys.F2:
|
2022-01-21 15:21:07 -08:00
|
|
|
|
firstItem.Rename();
|
2021-07-23 18:19:04 -07:00
|
|
|
|
listView.SelectedItems.Clear();
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
base.OnKeyDown(keyEvent);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-06-04 11:02:50 -07:00
|
|
|
|
protected override void OnClick(MouseEventArgs mouseEvent)
|
2018-08-03 23:30:11 -07:00
|
|
|
|
{
|
|
|
|
|
|
var bounds = this.LocalBounds;
|
|
|
|
|
|
var hitRegion = new RectangleDouble(
|
|
|
|
|
|
new Vector2(bounds.Right - 32, bounds.Top),
|
|
|
|
|
|
new Vector2(bounds.Right, bounds.Top - 32));
|
|
|
|
|
|
|
|
|
|
|
|
if (this.HasMenu
|
2018-11-05 15:20:10 -08:00
|
|
|
|
&& listViewItem?.ListView?.MenuActions?.Any() == true
|
2018-08-03 23:30:11 -07:00
|
|
|
|
&& (hitRegion.Contains(mouseEvent.Position)
|
|
|
|
|
|
|| mouseEvent.Button == MouseButtons.Right))
|
|
|
|
|
|
{
|
2020-07-09 07:12:00 -07:00
|
|
|
|
var popupMenu = new PopupMenu(ApplicationController.Instance.MenuTheme);
|
2018-08-03 23:30:11 -07:00
|
|
|
|
|
2018-11-05 15:20:10 -08:00
|
|
|
|
foreach (var menuAction in listViewItem.ListView.MenuActions.Where(m => m.Scope == ActionScope.ListItem))
|
2018-08-03 23:30:11 -07:00
|
|
|
|
{
|
|
|
|
|
|
if (menuAction is MenuSeparator)
|
|
|
|
|
|
{
|
2020-07-09 07:12:00 -07:00
|
|
|
|
popupMenu.CreateSeparator();
|
2018-08-03 23:30:11 -07:00
|
|
|
|
}
|
|
|
|
|
|
else if (menuAction.IsEnabled(this.listViewItem.ListView.SelectedItems, this.listViewItem.ListView))
|
|
|
|
|
|
{
|
2020-07-09 07:12:00 -07:00
|
|
|
|
var item = popupMenu.CreateMenuItem(menuAction.Title, menuAction.Icon);
|
2019-06-28 22:22:58 -07:00
|
|
|
|
item.Click += (s, e) =>
|
2018-08-03 23:30:11 -07:00
|
|
|
|
{
|
2020-07-09 07:12:00 -07:00
|
|
|
|
popupMenu.Close();
|
2018-08-03 23:30:11 -07:00
|
|
|
|
menuAction.Action.Invoke(this.listViewItem.ListView.SelectedItems.Select(o => o.Model), this.listViewItem.ListView);
|
2019-06-28 22:22:58 -07:00
|
|
|
|
};
|
2018-08-03 23:30:11 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
RectangleDouble popupBounds;
|
|
|
|
|
|
if (mouseEvent.Button == MouseButtons.Right)
|
|
|
|
|
|
{
|
2018-08-07 11:55:48 -07:00
|
|
|
|
popupBounds = new RectangleDouble(mouseEvent.X + 1, mouseEvent.Y + 1, mouseEvent.X + 1, mouseEvent.Y + 1);
|
2018-08-03 23:30:11 -07:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
popupBounds = new RectangleDouble(this.Width - 32, this.Height - 32, this.Width, this.Height);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-07-09 07:12:00 -07:00
|
|
|
|
popupMenu.ShowMenu(this, mouseEvent);
|
2018-08-03 23:30:11 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
base.OnClick(mouseEvent);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
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 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; }
|
2020-07-03 12:05:28 -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 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;
|
|
|
|
|
|
}
|
2020-07-03 12:05:28 -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
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
if (isSelected != value)
|
|
|
|
|
|
{
|
2020-07-03 12:05:28 -07:00
|
|
|
|
// selectionCheckBox.Checked = 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
|
|
|
|
|
|
|
|
|
|
isSelected = value;
|
|
|
|
|
|
UpdateColors();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-02-10 12:06:48 -08: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
|
|
|
|
}
|