Example #1
0
        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();
        }
Example #3
0
        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);
            });
        }
Example #4
0
        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);
        }
Example #5
0
        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);
        }
Example #6
0
 public void AddCollection(PrintItemCollection collection)
 {
     collection.Commit();
 }