Ejemplo n.º 1
0
        public override void Rename(ILibraryItem item, string revisedName)
        {
            if (item is DirectoryContainerLink directoryLink)
            {
                if (Directory.Exists(directoryLink.Path))
                {
                    Process.Start(this.FullPath);
                }
            }
            else if (item is FileSystemFileItem fileItem)
            {
                string sourceFile = fileItem.Path;
                if (File.Exists(sourceFile))
                {
                    string extension = Path.GetExtension(sourceFile);
                    string destFile  = Path.Combine(Path.GetDirectoryName(sourceFile), revisedName);
                    destFile = Path.ChangeExtension(destFile, extension);

                    File.Move(sourceFile, destFile);

                    fileItem.Path = destFile;

                    this.ReloadContent();
                }
            }
        }
Ejemplo n.º 2
0
 // Container override of child thumbnails
 public override Task <ImageBuffer> GetThumbnail(ILibraryItem item, int width, int height)
 {
     return(Task.FromResult(
                AggContext.StaticData.LoadIcon(
                    Path.Combine((width > 50 || height > 50) ? "icon_sd_card_115x115.png" : "icon_sd_card_50x50.png"),
                    ApplicationController.Instance.Theme.InvertIcons)));
 }
Ejemplo n.º 3
0
        private void OnLibraryItemReceived(object sender, MultiboxClientCSharpCore.Net.ServerInterfaceEventArgs.LibraryItemReceivedEventArgs eventArgs)
        {
            ILibraryItem item = eventArgs.LibraryItem;
            LibraryItemReceivedEventArgs libraryEventArgs = new LibraryItemReceivedEventArgs(item);

            messageQueue.Post(() => LibraryItemReceived(this, libraryEventArgs));
        }
Ejemplo n.º 4
0
        private TreeNode CreateTreeNode(ILibraryItem containerItem, ILibraryContainer parentContainer)
        {
            var treeNode = new ContainerTreeNode(theme, parentContainer)
            {
                Text             = containerItem.Name,
                Tag              = containerItem,
                AlwaysExpandable = true
            };

            ApplicationController.Instance.Library.LoadItemThumbnail(
                (icon) =>
            {
                treeNode.Image = icon.SetPreMultiply();
            },
                null,
                containerItem,
                null,
                20,
                20,
                theme).ConfigureAwait(false);

            treeNode.ExpandedChanged += (s, e) =>
            {
                this.EnsureExpanded(containerItem, treeNode).ConfigureAwait(false);
            };

            return(treeNode);
        }
Ejemplo n.º 5
0
 public async Task EnsureExpanded(ILibraryItem libraryItem, ContainerTreeNode treeNode)
 {
     if (!treeNode.ContainerAcquired)
     {
         await GetExpansionItems(libraryItem, treeNode).ConfigureAwait(false);
     }
 }
Ejemplo n.º 6
0
        public async Task <IObject3D> CreateItem(ILibraryItem item, Action <double, string> reporter)
        {
            return(await Task.Run(async() =>
            {
                var imageBuffer = await this.LoadImage(item);
                if (imageBuffer != null)
                {
                    string assetPath = "";

                    if (item is FileSystemFileItem fileItem)
                    {
                        assetPath = fileItem.Path;
                    }
                    else if (item is ILibraryAssetStream streamInterface)
                    {
                        using (var streamAndLength = await streamInterface.GetStream(null))
                        {
                            assetPath = AssetObject3D.AssetManager.StoreStream(streamAndLength.Stream, Path.GetExtension(streamInterface.FileName));
                        }
                    }

                    return new ImageObject3D()
                    {
                        AssetPath = assetPath,
                        Name = "Image"
                    };
                }
                else
                {
                    return null;
                }
            }));
        }
Ejemplo n.º 7
0
        public static Guid GetSingleUseToken(ILibraryItem item)
        {
            Guid g = Guid.NewGuid();

            _lookupTable[g] = item;
            return(g);
        }
        public void AllLibraryItemsWriteTest()
        {
            StringBuilder actualResult = new StringBuilder();
            StringWriter  sw           = new StringWriter(actualResult);
            var           book         = GetBook();
            var           newspaper    = GetNewsPaper();
            var           patent       = GetPatent();
            var           entities     = new ILibraryItem[]
            {
                book,
                newspaper,
                patent
            };
            string expectedResult = @"<?xml version=""1.0"" encoding=""utf-16""?>" +
                                    "<catalog>" +
                                    GetBookXml() +
                                    GetNewspaperXml() +
                                    GetPatentXml() +
                                    "</catalog>";

            _library.WriteTo(sw, entities);
            sw.Dispose();

            Assert.AreEqual(expectedResult, actualResult.ToString());
        }
Ejemplo n.º 9
0
 public override void Visit(ILibraryItem libraryItem)
 {
     // if (libraryItem.Id == 0)
     // {
     // libraryItem.Id = this.GenerateId();
     // }
 }
Ejemplo n.º 10
0
        private void OnLibraryItemReceived(GetLibraryItemResultData result)
        {
            ILibraryItem libraryItem = result.LibraryItem;

            LibraryItemReceivedEventArgs eventArgs = new LibraryItemReceivedEventArgs(libraryItem);

            LibraryItemReceived(this, eventArgs);
        }
 public static bool IsContentFileType(this ILibraryItem item)
 {
     return(item is ILibraryObject3D ||
            item is SDCardFileItem ||
            item is PrintHistoryItem ||
            (item is ILibraryAssetStream contentStream &&
             ApplicationController.Instance.Library.IsContentFileType(contentStream.FileName)));
 }
        public static Task <IObject3D> CreateContent(this ILibraryItem libraryItem, Action <double, string> progressReporter)
        {
            if (ApplicationController.Instance.Library.GetContentProvider(libraryItem) is ISceneContentProvider contentProvider)
            {
                return(contentProvider?.CreateItem(libraryItem, progressReporter));
            }

            return(Task.FromResult <IObject3D>(null));
        }
        public int DaysTillDue(ILibraryItem item, DateTime date)
        {
            if (item.IsCheckedOut == false)
            {
                return(0);
            }

            return((date - (item.DayCheckedOut + item.LengthOfCheckoutPeriod)).Value.Days * -1);
        }
Ejemplo n.º 14
0
        public virtual Task <ImageBuffer> GetThumbnail(ILibraryItem item, int width, int height)
        {
            if (item is LocalZipContainerLink)
            {
                return(Task.FromResult(AggContext.StaticData.LoadIcon(Path.Combine("Library", "zip_folder.png")).AlphaToPrimaryAccent().SetPreMultiply()));
            }

            return(Task.FromResult <ImageBuffer>(null));
        }
Ejemplo n.º 15
0
 public Task LoadLibraryContent(ILibraryItem libraryItem)
 {
     return(this.LoadContent(
                new EditContext()
     {
         ContentStore = ApplicationController.Instance.Library.PlatingHistory,
         SourceItem = libraryItem
     }));
 }
Ejemplo n.º 16
0
        public async Task LoadPrinterOpenItem(ILibraryItem libraryItem)
        {
            var printer = await LoadPrinter();

            await printer?.Bed?.LoadContent(new EditContext()
            {
                ContentStore = ApplicationController.Instance.Library.PlatingHistory,
                SourceItem   = libraryItem
            });
        }
Ejemplo n.º 17
0
        public virtual void Save(ILibraryItem item, IObject3D content)
        {
            if (item is FileSystemFileItem fileItem)
            {
                // Serialize the scene to disk using a modified Json.net pipeline with custom ContractResolvers and JsonConverters
                File.WriteAllText(fileItem.Path, content.ToJson());

                this.OnItemContentChanged(new ItemChangedEventArgs(fileItem));
            }
        }
Ejemplo n.º 18
0
        public async Task <IObject3D> CreateItem(ILibraryItem item, Action <double, string> reporter)
        {
            const double DefaultSizeMm = 40;

            return(await Task.Run(async() =>
            {
                if (imageBuffer != null)
                {
                    // Build an ImageBuffer from some svg content
                    double scaleMmPerPixels = Math.Min(DefaultSizeMm / imageBuffer.Width, DefaultSizeMm / imageBuffer.Height);

                    // Create texture mesh
                    double width = scaleMmPerPixels * imageBuffer.Width;
                    double height = scaleMmPerPixels * imageBuffer.Height;

                    Mesh textureMesh = PlatonicSolids.CreateCube(width, height, 0.2);
                    textureMesh.PlaceTextureOnFaces(0, imageBuffer);

                    string assetPath = null;

                    if (item is ILibraryAssetStream assetStream)
                    {
                        assetPath = assetStream.AssetPath;

                        if (string.IsNullOrWhiteSpace(assetPath))
                        {
                            using (var streamAndLength = await assetStream.GetStream(null))
                            {
                                string assetID = AssetObject3D.AssetManager.StoreStream(streamAndLength.Stream, ".svg");
                                assetPath = assetID;
                            }
                        }
                    }

                    var svgObject = new SvgObject3D()
                    {
                        DString = "",                         // How to acquire?
                        SvgPath = assetPath
                    };

                    svgObject.Children.Add(new Object3D()
                    {
                        Mesh = textureMesh
                    });

                    await svgObject.Rebuild();

                    return svgObject;
                }
                else
                {
                    return null;
                }
            }));
        }
Ejemplo n.º 19
0
        public IContentProvider GetContentProvider(ILibraryItem item)
        {
            string contentType = (item as ILibraryAssetStream)?.ContentType ?? (item as ILibraryObject3D)?.ContentType;

            if (contentType == null)
            {
                return(null);
            }

            return(GetContentProvider(contentType));
        }
Ejemplo n.º 20
0
 public void AddObject(ILibraryItem item)
 {
     if (item.Title != string.Empty)
     {
         PeopleController.Person.Library.Magazines.AddLibraryItem(Magazine);
     }
     else
     {
         Console.WriteLine("Magazine title is required!");
     }
 }
 public IEnumerable <ILibraryItem> ListLibraryItem(ILibraryItem item)
 {
     foreach (var mov in PeopleController.Person.Library.Movies)
     {
         Console.WriteLine("Movies: ");
         Console.WriteLine("Title: {0} ", item.Title);
         Console.WriteLine("Director: {0} ", mov.Director);
         Console.WriteLine("Release Date: {0} ", item.ReleaseDate);
     }
     return(PeopleController.Person.Library.Movies);
 }
Ejemplo n.º 22
0
 public IEnumerable <ILibraryItem> ListLibraryItem(ILibraryItem item)
 {
     foreach (var mag in PeopleController.Person.Library.Magazines)
     {
         Console.WriteLine("Magazines ");
         Console.WriteLine("Title: {0} ", item.Title);
         Console.WriteLine("Writer: {0} ", item.Writer);
         Console.WriteLine("Publisher: {0} ", mag.Publisher);
         Console.WriteLine("Volume: {0} ", mag.Volume);
     }
     return(PeopleController.Person.Library.Magazines);
 }
Ejemplo n.º 23
0
        private async Task GetExpansionItems(ILibraryItem containerItem, ContainerTreeNode treeNode)
        {
            if (containerItem is ILibraryContainerLink containerLink)
            {
                // Prevent invalid assignment of container.Parent due to overlapping load attempts that
                // would otherwise result in containers with self referencing parent properties
                //if (loadingContainerLink != containerLink)
                //{
                //	loadingContainerLink = containerLink;

                try
                {
                    // Container items
                    var container = await containerLink.GetContainer(null);

                    if (container != null)
                    {
                        await Task.Run(() =>
                        {
                            container.Load();
                        });

                        if (treeNode.NodeParent is ContainerTreeNode parentNode)
                        {
                            container.Parent = parentNode.Container;
                        }

                        foreach (var childContainer in container.ChildContainers)
                        {
                            treeNode.Nodes.Add(CreateTreeNode(childContainer));
                        }

                        treeNode.Container = container;

                        treeNode.AlwaysExpandable = treeNode.Nodes.Count > 0;
                        treeNode.Expandable       = treeNode.Nodes.Count > 0;
                        treeNode.Expanded         = treeNode.Nodes.Count > 0;

                        treeNode.Invalidate();

                        //	container.Parent = ActiveContainer;
                        // SetActiveContainer(container);
                    }
                }
                catch { }
                finally
                {
                    // Clear the loading guard and any completed load attempt
                    // loadingContainerLink = null;
                }
            }
        }
 public IEnumerable <ILibraryItem> ListLibraryItem(ILibraryItem item)
 {
     foreach (var b in PeopleController.Person.Library.Books)
     {
         Console.WriteLine("Books: ");
         Console.WriteLine("Id: {0} ", b.BookId);
         Console.WriteLine("Title: {0} ", item.Title);
         Console.WriteLine("Author: {0} ", b.Author);
         Console.WriteLine("Publisher: {0} ", b.Publisher);
         Console.WriteLine("Published: {0} ", b.Published);
     }
     return(PeopleController.Person.Library.Books);
 }
Ejemplo n.º 25
0
 public static ILibraryItem GetItem(Guid token)
 {
     if (_lookupTable.ContainsKey(token))
     {
         ILibraryItem i = _lookupTable[token];
         _lookupTable.Remove(token);
         return(i);
     }
     else
     {
         return(null);
     }
 }
        public LibraryItemStatus CalculateItemStatus(ILibraryItem item, int daysTillDue)
        {
            if (!item.IsCheckedOut)
            {
                return(LibraryItemStatus.Available);
            }

            if (daysTillDue == 0)
            {
                return(LibraryItemStatus.Due);
            }

            return(daysTillDue < 0 ? LibraryItemStatus.Overdue : LibraryItemStatus.CheckedOut);
        }
        public static async Task <IObject3D> CreateContent(this ILibraryItem libraryItem, Action <double, string> progressReporter)
        {
            if (libraryItem is IRequireInitialize requiresInitialize)
            {
                await requiresInitialize.Initialize();
            }

            if (ApplicationController.Instance.Library.GetContentProvider(libraryItem) is ISceneContentProvider contentProvider)
            {
                return(await contentProvider?.CreateItem(libraryItem, progressReporter));
            }

            return(null);
        }
Ejemplo n.º 28
0
        public void DeleteCache(ILibraryItem sourceItem)
        {
            var thumbnailPath = ApplicationController.Instance.Thumbnails.CachePath(sourceItem);

            if (File.Exists(thumbnailPath))
            {
                File.Delete(thumbnailPath);
            }

            // Purge any specifically sized thumbnails
            foreach (var sizedThumbnail in Directory.GetFiles(Path.GetDirectoryName(thumbnailPath), Path.GetFileNameWithoutExtension(thumbnailPath) + "-*.png"))
            {
                File.Delete(sizedThumbnail);
            }
        }
Ejemplo n.º 29
0
        public async Task <ImageBuffer> GetThumbnail(ILibraryItem libraryItem, int width, int height)
        {
            IObject3D object3D = null;

            long fileSize = 0;

            if (libraryItem is ILibraryAssetStream contentModel
                // Only load the stream if it's available - prevents download of Internet content simply for thumbnails
                && contentModel.LocalContentExists &&
                contentModel.FileSize < MaxFileSizeForThumbnail)
            {
                fileSize = contentModel.FileSize;
                // TODO: Wire up limits for thumbnail generation. If content is too big, return null allowing the thumbnail to fall back to content default
                object3D = await contentModel.CreateContent();
            }
Ejemplo n.º 30
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (!(obj is ILibraryItem))
            {
                return(false);
            }

            ILibraryItem item = obj as ILibraryItem;

            return(Equals(item));
        }
Ejemplo n.º 31
0
 public static Guid GetSingleUseToken(ILibraryItem item)
 {
     Guid g = Guid.NewGuid();
     _lookupTable[g] = item;
     return g;
 }
Ejemplo n.º 32
0
 private void sceneContentEditor_ReplicaCreated(ILibraryItem libraryItem)
 {
     libraryViewModel.Items.Add((LibraryItem)libraryItem);
 }