public LibraryRowItemCollection(PrintItemCollection collection, LibraryDataView libraryDataView, LibraryProvider parentProvider, GuiWidget thumbnailWidget) : base(libraryDataView, thumbnailWidget) { this.parentProvider = parentProvider; this.printItemCollection = collection; CreateGuiElements(); }
private void AddAllItems() { topToBottomItemList.RemoveAllChildren(); if (LibraryDataView.CurrentLibraryProvider.ParentLibraryProvider != null) { PrintItemCollection parent = new PrintItemCollection("..", LibraryDataView.CurrentLibraryProvider.ProviderKey); LibraryRowItem queueItem = new LibraryRowItemCollection(parent, this, LibraryDataView.CurrentLibraryProvider.ParentLibraryProvider, GetThumbnailWidget(true, LibraryDataView.CurrentLibraryProvider.ParentLibraryProvider, parent)); AddListItemToTopToBottom(queueItem); } for (int i = 0; i < LibraryDataView.CurrentLibraryProvider.CollectionCount; i++) { PrintItemCollection item = LibraryDataView.CurrentLibraryProvider.GetCollectionItem(i); LibraryRowItem queueItem = new LibraryRowItemCollection(item, this, null, GetThumbnailWidget(false, null, item)); AddListItemToTopToBottom(queueItem); } for (int i = 0; i < LibraryDataView.CurrentLibraryProvider.ItemCount; i++) { PrintItemWrapper item = LibraryDataView.CurrentLibraryProvider.GetPrintItemWrapper(i); GuiWidget thumbnailWidget = LibraryDataView.CurrentLibraryProvider.GetItemThumbnail(i); LibraryRowItem queueItem = new LibraryRowItemPart(item, this, thumbnailWidget); AddListItemToTopToBottom(queueItem); } }
private void AddAllItems() { topToBottomItemList.RemoveAllChildren(); var provider = this.CurrentLibraryProvider; if (provider != null) { if (provider.ProviderKey != LibraryProviderSelector.ProviderKeyName) { PrintItemCollection parent = new PrintItemCollection("..", provider.ProviderKey); LibrarySelectorRowItem queueItem = new LibrarySelectorRowItem(parent, -1, this, provider.ParentLibraryProvider, GetThumbnailWidget(provider.ParentLibraryProvider, parent, LibraryProvider.UpFolderImage), "Back".Localize()); AddListItemToTopToBottom(queueItem); } for (int i = 0; i < provider.CollectionCount; i++) { PrintItemCollection item = provider.GetCollectionItem(i); if (item.Key != "LibraryProviderPurchasedKey" && item.Key != "LibraryProviderSharedKey") { LibrarySelectorRowItem queueItem = new LibrarySelectorRowItem(item, i, this, null, GetThumbnailWidget(null, item, provider.GetCollectionFolderImage(i)), "Open".Localize()); AddListItemToTopToBottom(queueItem); } } } }
protected GuiWidget GetThumbnailWidget(LibraryProvider parentProvider, PrintItemCollection printItemCollection, ImageBuffer imageBuffer) { Vector2 expectedSize = new Vector2((int)(50 * TextWidget.GlobalPointSizeScaleRatio), (int)(50 * TextWidget.GlobalPointSizeScaleRatio)); if (imageBuffer.Width != expectedSize.x) { ImageBuffer scaledImageBuffer = new ImageBuffer((int)expectedSize.x, (int)expectedSize.y, 32, new BlenderBGRA()); scaledImageBuffer.NewGraphics2D().Render(imageBuffer, 0, 0, scaledImageBuffer.Width, scaledImageBuffer.Height); imageBuffer = scaledImageBuffer; } ImageWidget folderThumbnail = new ImageWidget(imageBuffer); folderThumbnail.BackgroundColor = ActiveTheme.Instance.PrimaryAccentColor; Button clickThumbnail = new Button(0, 0, folderThumbnail); clickThumbnail.Cursor = Cursors.Hand; clickThumbnail.Click += (sender, e) => { if (parentProvider == null) { this.CurrentLibraryProvider = this.CurrentLibraryProvider.GetProviderForCollection(printItemCollection); } else { this.CurrentLibraryProvider = parentProvider; } UiThread.RunOnIdle(RebuildView); }; return(clickThumbnail); }
private void AddAllItems() { topToBottomItemList.RemoveAllChildren(); var provider = this.CurrentLibraryProvider; if (provider != null && provider.ProviderKey != "ProviderSelectorKey") { PrintItemCollection parent = new PrintItemCollection("..", provider.ProviderKey); LibraryRowItem queueItem = new LibraryRowItemCollection(parent, provider, -1, this, provider.ParentLibraryProvider, GetThumbnailWidget(provider.ParentLibraryProvider, parent, LibraryProvider.UpFolderImage)); AddListItemToTopToBottom(queueItem); } for (int i = 0; i < provider.CollectionCount; i++) { PrintItemCollection item = provider.GetCollectionItem(i); LibraryRowItem queueItem = new LibraryRowItemCollection(item, provider, i, this, null, GetThumbnailWidget(null, item, provider.GetCollectionFolderImage(i))); AddListItemToTopToBottom(queueItem); } for (int i = 0; i < provider.ItemCount; i++) { GuiWidget thumbnailWidget = provider.GetItemThumbnail(i); LibraryRowItem queueItem = new LibraryRowItemPart(provider, i, this, thumbnailWidget); AddListItemToTopToBottom(queueItem); } }
public override void AddCollectionToLibrary(string collectionName) { PrintItemCollection newCollection = new PrintItemCollection(collectionName, ""); newCollection.ParentCollectionID = baseLibraryCollection.Id; newCollection.Commit(); LoadLibraryItems(); }
public async Task AddCollectionToLibraryAsync(string collectionName) { PrintItemCollection newCollection = new PrintItemCollection(collectionName, ""); newCollection.ParentCollectionID = baseLibraryCollection.Id; newCollection.Commit(); await LoadLibraryItems(); }
protected GuiWidget GetThumbnailWidget(LibraryProvider parentProvider, PrintItemCollection printItemCollection, ImageBuffer imageBuffer) { Vector2 expectedSize = new Vector2((int)(50 * GuiWidget.DeviceScale), (int)(50 * GuiWidget.DeviceScale)); if (imageBuffer.Width != expectedSize.x) { ImageBuffer scaledImageBuffer = new ImageBuffer((int)expectedSize.x, (int)expectedSize.y); scaledImageBuffer.NewGraphics2D().Render(imageBuffer, 0, 0, scaledImageBuffer.Width, scaledImageBuffer.Height); imageBuffer = scaledImageBuffer; } ImageWidget folderThumbnail = new ImageWidget(imageBuffer); folderThumbnail.BackgroundColor = ActiveTheme.Instance.PrimaryAccentColor; Button clickThumbnail = new Button(0, 0, folderThumbnail); PrintItemCollection localPrintItemCollection = printItemCollection; clickThumbnail.Click += (sender, e) => { if (UserSettings.Instance.IsTouchScreen) { if (parentProvider == null) { this.CurrentLibraryProvider = this.CurrentLibraryProvider.GetProviderForCollection(localPrintItemCollection); } else { this.CurrentLibraryProvider = parentProvider; } } else { MouseEventArgs mouseEvent = e as MouseEventArgs; if (mouseEvent != null && IsDoubleClick(mouseEvent)) { if (parentProvider == null) { this.CurrentLibraryProvider = this.CurrentLibraryProvider.GetProviderForCollection(localPrintItemCollection); } else { this.CurrentLibraryProvider = parentProvider; } } } UiThread.RunOnIdle(RebuildView); }; return(clickThumbnail); }
public LibraryProviderSQLite(PrintItemCollection baseLibraryCollection, LibraryProvider parentLibraryProvider) : base(parentLibraryProvider) { if (baseLibraryCollection == null) { baseLibraryCollection = GetRootLibraryCollection2(this); } this.baseLibraryCollection = baseLibraryCollection; LoadLibraryItems(); }
public LibraryRowItemCollection(PrintItemCollection collection, LibraryProvider currentProvider, int collectionIndex, LibraryDataView libraryDataView, LibraryProvider parentProvider, GuiWidget thumbnailWidget) : base(libraryDataView, thumbnailWidget) { this.currentProvider = currentProvider; this.CollectionIndex = collectionIndex; this.parentProvider = parentProvider; this.printItemCollection = collection; this.ItemName = printItemCollection.Name; CreateGuiElements(); }
public override LibraryProvider GetProviderForItem(PrintItemCollection collection) { foreach (LibraryProvider libraryProvider in libraryProviders) { if (collection.Key == libraryProvider.ProviderKey) { return(libraryProvider); } } throw new NotImplementedException(); }
public LibrarySelectorRowItem(PrintItemCollection collection, int collectionIndex, LibrarySelectorWidget libraryDataView, LibraryProvider parentProvider, GuiWidget thumbnailWidget) { this.thumbnailWidget = thumbnailWidget; this.libraryDataView = libraryDataView; this.CollectionIndex = collectionIndex; this.parentProvider = parentProvider; this.printItemCollection = collection; this.ItemName = printItemCollection.Name; CreateGuiElements(); }
public override LibraryProvider GetProviderForCollection(PrintItemCollection collection) { foreach (ILibraryCreator libraryCreator in libraryCreators) { if (collection.Key == libraryCreator.ProviderKey) { return(libraryCreator.CreateLibraryProvider(this)); } } throw new NotImplementedException(); }
public LibraryProviderSQLite(PrintItemCollection baseLibraryCollection, LibraryProvider parentLibraryProvider, string visibleName) : base(parentLibraryProvider) { this.Name = visibleName; if (baseLibraryCollection == null) { baseLibraryCollection = GetRootLibraryCollection2().Result; } this.baseLibraryCollection = baseLibraryCollection; LoadLibraryItems(); }
protected GuiWidget GetThumbnailWidget(LibraryProvider parentProvider, PrintItemCollection printItemCollection, ImageBuffer imageBuffer) { Vector2 expectedSize = new Vector2((int)(50 * TextWidget.GlobalPointSizeScaleRatio), (int)(50 * TextWidget.GlobalPointSizeScaleRatio)); if (imageBuffer.Width != expectedSize.x) { ImageBuffer scaledImageBuffer = new ImageBuffer((int)expectedSize.x, (int)expectedSize.y, 32, new BlenderBGRA()); scaledImageBuffer.NewGraphics2D().Render(imageBuffer, 0, 0, scaledImageBuffer.Width, scaledImageBuffer.Height); imageBuffer = scaledImageBuffer; } ImageWidget folderThumbnail = new ImageWidget(imageBuffer); folderThumbnail.BackgroundColor = ActiveTheme.Instance.PrimaryAccentColor; Button clickThumbnail = new Button(0, 0, folderThumbnail); clickThumbnail.Click += (sender, e) => { if (ActiveTheme.Instance.IsTouchScreen) { if (parentProvider == null) { this.CurrentLibraryProvider = this.CurrentLibraryProvider.GetProviderForCollection(printItemCollection); } else { this.CurrentLibraryProvider = parentProvider; } } else { MouseEventArgs mouseEvent = e as MouseEventArgs; if (mouseEvent != null && mouseEvent.Clicks == 2) { if (parentProvider == null) { this.CurrentLibraryProvider = this.CurrentLibraryProvider.GetProviderForCollection(printItemCollection); } else { this.CurrentLibraryProvider = parentProvider; } } } }; return(clickThumbnail); }
public override async void Add(IEnumerable <ILibraryItem> items) { await Task.Run(async() => { foreach (var item in items) { switch (item) { case CreateFolderItem newFolder: var newFolderCollection = new PrintItemCollection(newFolder.Name, "") { ParentCollectionID = this.CollectionID }; newFolderCollection.Commit(); break; case ILibraryContainerLink containerInfo: var newCollection = new PrintItemCollection(containerInfo.Name, "") { ParentCollectionID = this.CollectionID }; newCollection.Commit(); break; case ILibraryAssetStream streamItem: var fileName = (streamItem as ILibraryAssetStream)?.FileName; using (var streamInfo = await streamItem.GetStream(null)) { // If the passed in item name equals the fileName, perform friendly name conversion, otherwise use supplied value string name = streamItem.Name; if (name == fileName) { name = PrintItemWrapperExtensionMethods.GetFriendlyName(Path.GetFileNameWithoutExtension(fileName)); } AddItem(streamInfo.Stream, streamItem.ContentType, name); } break; } } UiThread.RunOnIdle(this.ReloadContent); }); }
public LibraryProviderSQLite(PrintItemCollection baseLibraryCollection, Action <LibraryProvider> setCurrentLibraryProvider, LibraryProvider parentLibraryProvider, string visibleName) : base(parentLibraryProvider, setCurrentLibraryProvider) { this.Name = visibleName; if (baseLibraryCollection == null) { baseLibraryCollection = GetRootLibraryCollection().Result; } this.baseLibraryCollection = baseLibraryCollection; LoadLibraryItems(); ItemAdded.RegisterEvent(DatabaseFileChange, ref unregisterEvents); }
public override void RemoveCollection(PrintItemCollection collectionToRemove) { string directoryPath = collectionToRemove.Key; if (Directory.Exists(directoryPath)) { Stopwatch time = Stopwatch.StartNew(); Directory.Delete(directoryPath, true); // Wait for up to some amount of time for the directory to be gone. while (Directory.Exists(directoryPath) && time.ElapsedMilliseconds < 100) { Thread.Sleep(1); // make sure we are not eating all the cpu time. } GetFilesAndCollectionsInCurrentDirectory(); } }
public LibraryProviderSQLite(PrintItemCollection callerSuppliedCollection, Action <LibraryProvider> setCurrentLibraryProvider, LibraryProvider parentLibraryProvider, string visibleName) : base(parentLibraryProvider, setCurrentLibraryProvider) { this.Name = visibleName; // Lock ensures that SQLite providers initialized near the same time from different threads (which has been observed during debug) // will run in a serial fashion and only one instance will construct and assign to .baseLibraryCollection lock (initializingLock) { // Use null coalescing operator to assign either the caller supplied collection or if null, the root library collection this.baseLibraryCollection = callerSuppliedCollection ?? GetRootLibraryCollection(); } LoadLibraryItems(); ItemAdded.RegisterEvent(DatabaseFileChange, ref unregisterEvents); }
public LibrarySelectorRowItem(PrintItemCollection collection, int collectionIndex, LibrarySelectorWidget libraryDataView, LibraryProvider parentProvider, GuiWidget thumbnailWidget, string openButtonText) { this.thumbnailWidget = thumbnailWidget; this.libraryDataView = libraryDataView; this.CollectionIndex = collectionIndex; this.parentProvider = parentProvider; this.printItemCollection = collection; this.ItemName = printItemCollection.Name; this.Name = this.ItemName + " Row Item Collection"; CreateGuiElements(openButtonText); MouseEnterBounds += (s, e) => UpdateHoverState(); MouseLeaveBounds += (s, e) => UpdateHoverState(); }
public override LibraryProvider GetProviderForCollection(PrintItemCollection collection) { LibraryProvider provider = libraryProviders.Values.Where(p => p.ProviderKey == collection.Key).FirstOrDefault(); if (provider != null) { return(provider); } foreach (ILibraryCreator libraryCreator in libraryCreators) { if (collection.Key == libraryCreator.ProviderKey) { return(libraryCreator.CreateLibraryProvider(this, SetCurrentLibraryProvider)); } } throw new NotImplementedException(); }
private void AddAllItems(object inData = null) { // Clear SelectedItems when the list is rebuilt to prevent duplicate entries this.SelectedItems.Clear(); topToBottomItemList.RemoveAllChildren(); var provider = this.CurrentLibraryProvider; if (provider != null) { if (provider.ProviderKey != LibraryProviderSelector.ProviderKeyName) { // Create logical "up folder" entry PrintItemCollection parent = new PrintItemCollection("..", provider.ProviderKey); LibraryRowItem queueItem = new LibraryRowItemCollection(parent, provider, -1, this, provider.ParentLibraryProvider, GetThumbnailWidget(provider.ParentLibraryProvider, parent, LibraryProvider.UpFolderImage), "Back".Localize()); queueItem.IsViewHelperItem = true; AddListItemToTopToBottom(queueItem); } for (int i = 0; i < provider.CollectionCount; i++) { PrintItemCollection item = provider.GetCollectionItem(i); LibraryRowItem queueItem = new LibraryRowItemCollection(item, provider, i, this, null, GetThumbnailWidget(null, item, provider.GetCollectionFolderImage(i)), "Open".Localize()); AddListItemToTopToBottom(queueItem); } for (int i = 0; i < provider.ItemCount; i++) { GuiWidget thumbnailWidget = provider.GetItemThumbnail(i); LibraryRowItem queueItem = new LibraryRowItemPart(provider, i, this, thumbnailWidget); AddListItemToTopToBottom(queueItem); } } LastScrollPosition scrollPosition = inData as LastScrollPosition; if (scrollPosition != null) { this.TopLeftOffset = scrollPosition.topLeftScrollPosition; } }
public LibraryRowItemCollection(PrintItemCollection collection, LibraryProvider currentProvider, int collectionIndex, LibraryDataView libraryDataView, LibraryProvider parentProvider, GuiWidget thumbnailWidget, string openButtonText) : base(libraryDataView, thumbnailWidget) { this.openButtonText = openButtonText; this.currentProvider = currentProvider; this.CollectionIndex = collectionIndex; this.parentProvider = parentProvider; this.printItemCollection = collection; this.ItemName = printItemCollection.Name; this.Name = this.ItemName + " Row Item Collection"; if (collection.Key == LibraryRowItem.LoadingPlaceholderToken) { this.EnableSlideInActions = false; this.IsViewHelperItem = true; } CreateGuiElements(); }
public static async Task <LibraryProvider> GetLibraryFromLocator(List <ProviderLocatorNode> libraryProviderLocator) { LibraryProviderSelector selector = new LibraryProviderSelector(null, true); LibraryProvider lastProvider = null; if (libraryProviderLocator.Count > 1) { ProviderLocatorNode selectorNode = libraryProviderLocator[1]; foreach (ILibraryCreator libraryCreator in selector.libraryCreators) { if (libraryCreator.ProviderKey == selectorNode.Key) { // We found the right creatory, make the library and then iterate through it to get to the correct sub library lastProvider = libraryCreator.CreateLibraryProvider(null, null); for (int i = 2; i < libraryProviderLocator.Count; i++) { ProviderLocatorNode currentNode = libraryProviderLocator[i]; // wait for our current providre to finish loading while (lastProvider.CollectionCount == 0) { Thread.Sleep(100); } // now find the next sub provider and go to it for (int collectionIndex = 0; collectionIndex < lastProvider.CollectionCount; collectionIndex++) { PrintItemCollection collection = lastProvider.GetCollectionItem(collectionIndex); if (collection.Key == currentNode.Key) { lastProvider = lastProvider.GetProviderForCollection(collection); } } } } } } return(lastProvider); }
private async Task <PrintItemCollection> GetRootLibraryCollection2() { // Attempt to initialize the library from the Datastore if null PrintItemCollection rootLibraryCollection = Datastore.Instance.dbSQLite.Table <PrintItemCollection>().Where(v => v.Name == "_library").Take(1).FirstOrDefault(); // If the _library collection is still missing, create and populate it with default content if (rootLibraryCollection == null) { rootLibraryCollection = new PrintItemCollection(); rootLibraryCollection.Name = "_library"; rootLibraryCollection.Commit(); // In this case we now need to update the baseLibraryCollection instance member as code that executes // down this path will attempt to use the property and will exception if its not set this.baseLibraryCollection = rootLibraryCollection; // Preload library with Oem supplied list of default parts await this.EnsureSamplePartsExist(OemSettings.Instance.PreloadedLibraryFiles); } return(rootLibraryCollection); }
static PrintItemCollection GetRootLibraryCollection2(LibraryProviderSQLite rootLibrary) { // Attempt to initialize the library from the Datastore if null PrintItemCollection rootLibraryCollection = Datastore.Instance.dbSQLite.Table <PrintItemCollection>().Where(v => v.Name == "_library").Take(1).FirstOrDefault(); // If the _library collection is still missing, create and populate it with default content if (rootLibraryCollection == null) { rootLibraryCollection = new PrintItemCollection(); rootLibraryCollection.Name = "_library"; rootLibraryCollection.Commit(); // Preload library with Oem supplied list of default parts string[] itemsToAdd = SyncCalibrationFilesToDisk(OemSettings.Instance.PreloadedLibraryFiles); if (itemsToAdd.Length > 0) { // Import any files sync'd to disk into the library, then add them to the queue rootLibrary.AddFilesToLibrary(itemsToAdd); } } return(rootLibraryCollection); }
public override LibraryProvider GetProviderForCollection(PrintItemCollection collection) { return(new LibraryProviderFileSystem(Path.Combine(rootPath, collection.Key), collection.Name, this)); }
public LibraryProviderQueue(PrintItemCollection baseLibraryCollection, Action <LibraryProvider> setCurrentLibraryProvider, LibraryProvider parentLibraryProvider) : base(parentLibraryProvider, setCurrentLibraryProvider) { QueueData.Instance.ItemAdded.RegisterEvent((sender, e) => OnDataReloaded(null), ref unregisterEvent); this.Name = "Print Queue"; }
public override void RemoveCollection(PrintItemCollection collectionToRemove) { collectionToRemove.Delete(); LoadLibraryItems(); LibraryProvider.OnDataReloaded(null); }
public override LibraryProvider GetProviderForItem(PrintItemCollection collection) { return(new LibraryProviderSQLite(collection, this)); }