private async Task SeedTestData(ILibraryContext context)
        {
            context.Users.Add(new User("FirstName", "LastName", new Email("*****@*****.**"), UserRolesConsts.Reader));
            context.Users.Add(new User("FirstName", "LastName", new Email("*****@*****.**"), UserRolesConsts.Reader));
            context.Users.Add(new User("FirstName", "LastName", new Email("*****@*****.**"), UserRolesConsts.Librarian));

            await context.SaveChangesAsync();
        }
 public FolderBreadCrumbWidget(ILibraryContext libraryContext, ThemeConfig theme)
 {
     this.libraryContext = libraryContext;
     this.Name           = "FolderBreadCrumbWidget";
     this.HAnchor        = HAnchor.Stretch;
     this.VAnchor        = VAnchor.Fit | VAnchor.Center;
     this.MinimumSize    = new VectorMath.Vector2(0, 1);          // Force some minimum bounds to ensure draw and thus onload (and our local init) are called on startup
     this.theme          = theme;
 }
Example #3
0
 public Repository(ILibraryContext dbContext)
 {
     if (dbContext == null)
     {
         throw new ArgumentNullException("dbContext");
     }
     this.DbContext = dbContext;
     this.DbSet     = this.DbContext.Set <T>();
 }
Example #4
0
        public PartWorkspace(ISceneContext sceneContext)
        {
            // Create a new library context for the SaveAs view
            this.LibraryView = new LibraryConfig()
            {
                ActiveContainer = new WrappedLibraryContainer(ApplicationController.Instance.Library.RootLibaryContainer)
            };

            this.SceneContext = sceneContext;
            Name = sceneContext.EditContext?.SourceItem?.Name ?? "Unknown";
        }
Example #5
0
        public RepositoryFake(ILibraryContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            this.Context = context;

            if (typeof(T) == typeof(Author))
            {
                this.Set = (IDbSet <T>)context.Authors;
            }
            if (typeof(T) == typeof(Item))
            {
                this.Set = (IDbSet <T>)context.Items;
            }
            if (typeof(T) == typeof(Inventory))
            {
                this.Set = (IDbSet <T>)context.Inventory;
            }
            if (typeof(T) == typeof(Consignment))
            {
                this.Set = (IDbSet <T>)context.Consignment;
            }
            if (typeof(T) == typeof(Reader))
            {
                this.Set = (IDbSet <T>)context.Readers;
            }
            if (typeof(T) == typeof(ReaderHistory))
            {
                this.Set = (IDbSet <T>)context.ReaderHistory;
            }
            if (typeof(T) == typeof(ReservedItem))
            {
                this.Set = (IDbSet <T>)context.ReservedItem;
            }
            if (typeof(T) == typeof(ScannedPage))
            {
                this.Set = (IDbSet <T>)context.ScannedPage;
            }
            if (typeof(T) == typeof(UserProfile))
            {
                this.Set = (IDbSet <T>)context.UserProfiles;
            }
            if (typeof(T) == typeof(Tag))
            {
                this.Set = (IDbSet <T>)context.Tags;
            }
            if (typeof(T) == typeof(TagScore))
            {
                this.Set = (IDbSet <T>)context.TagScores;
            }
        }
        public LibraryBrowserPage(Action <string, ILibraryWritableContainer> acceptCallback, string acceptButtonText)
        {
            FolderBreadCrumbWidget breadCrumbWidget = null;

            this.WindowSize = new Vector2(480, 500);

            contentRow.Padding = 0;

            // Create a new library context for the SaveAs view
            libraryNavContext = new LibraryConfig()
            {
                ActiveContainer = ApplicationController.Instance.Library.RootLibaryContainer
            };
            libraryNavContext.ContainerChanged += (s, e) =>
            {
                acceptButton.Enabled = libraryNavContext.ActiveContainer is ILibraryWritableContainer;
                breadCrumbWidget.SetContainer(libraryNavContext.ActiveContainer);
            };

            librarySelectorWidget = new ListView(libraryNavContext, new IconListView(theme, 75), theme)
            {
                BackgroundColor = ActiveTheme.Instance.TertiaryBackgroundColor,
                ShowItems       = false,
                ContainerFilter = (container) => !container.IsReadOnly,
            };

            // put in the bread crumb widget
            breadCrumbWidget = new FolderBreadCrumbWidget(librarySelectorWidget, theme);
            breadCrumbWidget.BackgroundColor = ActiveTheme.Instance.TertiaryBackgroundColor;
            contentRow.AddChild(breadCrumbWidget);
            contentRow.BackgroundColor = Color.Transparent;

            contentRow.AddChild(librarySelectorWidget);

            acceptButton      = theme.CreateDialogButton(acceptButtonText);
            acceptButton.Name = "Accept Button";
            // Disable the save as button until the user actually selects a provider
            acceptButton.Enabled = false;
            acceptButton.Cursor  = Cursors.Hand;
            acceptButton.Click  += (s, e) =>
            {
                if (librarySelectorWidget.ActiveContainer is ILibraryWritableContainer writableContainer)
                {
                    acceptCallback(
                        itemNameWidget?.ActualTextEditWidget.Text ?? "none",
                        writableContainer);
                }

                this.DialogWindow.CloseOnIdle();
            };

            this.AddPageAction(acceptButton);
        }
Example #7
0
        public PartWorkspace(ISceneContext bedConfig)
        {
            var extraContainers = new List <ILibraryContainerLink>();

            // Create a new library context for the SaveAs view
            this.LibraryView = new LibraryConfig()
            {
                ActiveContainer = new WrappedLibraryContainer(ApplicationController.Instance.Library.RootLibaryContainer)
            };

            _sceneContext = bedConfig;
            Name          = _sceneContext.EditContext?.SourceItem?.Name ?? "Unknown";
        }
Example #8
0
        /// <summary>
        /// Create a library by combining several intermediates (objects).
        /// </summary>
        /// <returns>Returns the new library.</returns>
        public Intermediate Combine(ILibraryContext context)
        {
            if (String.IsNullOrEmpty(context.LibraryId))
            {
                context.LibraryId = Convert.ToBase64String(Guid.NewGuid().ToByteArray()).TrimEnd('=').Replace('+', '.').Replace('/', '_');
            }

            foreach (var extension in context.Extensions)
            {
                extension.PreCombine(context);
            }

            Intermediate library = null;

            try
            {
                var sections = context.Intermediates.SelectMany(i => i.Sections).ToList();

                var collate = new CollateLocalizationsCommand(this.Messaging, context.Localizations);
                var localizationsByCulture = collate.Execute();

                if (this.Messaging.EncounteredError)
                {
                    return(null);
                }

                this.ResolveFilePathsToEmbed(context, sections);

                foreach (var section in sections)
                {
                    section.AssignToLibrary(context.LibraryId);
                }

                library = new Intermediate(context.LibraryId, IntermediateLevels.Compiled, sections, localizationsByCulture);

                library.UpdateLevel(IntermediateLevels.Combined);

                this.Validate(library);
            }
            finally
            {
                foreach (var extension in context.Extensions)
                {
                    extension.PostCombine(library);
                }
            }

            return(this.Messaging.EncounteredError ? null : library);
        }
Example #9
0
 public FilledBookRepository(ILibraryContext dbContext)
 {
     _dbContext = dbContext;
     if (_dbContext.Books.Count() == 0)
     {
         _dbContext.Books.Add(new Book {
             title = "Tennis", isbn = "11111", author = "Andy Murray", publishDate = "01/01/2001"
         });
         _dbContext.Books.Add(new Book {
             title = "All about tennis", isbn = "22222", author = "Tim Henman", publishDate = "02/02/2002"
         });
         _dbContext.Books.Add(new Book {
             title = "Yeah tennis", isbn = "33333", author = "Boris Becker", publishDate = "03/03/2003"
         });
     }
     _dbContext.SaveChanges();
 }
Example #10
0
        public ListView(ILibraryContext context, GuiWidget libraryView, ThemeConfig theme)
        {
            contentView = new IconListView(theme);

            this.theme          = theme;
            this.LibraryContext = context;

            // Set Display Attributes
            this.MinimumSize = new Vector2(0, 200);
            this.AnchorAll();
            this.AutoScroll         = true;
            this.ScrollArea.Padding = new BorderDouble(3);
            this.ScrollArea.HAnchor = HAnchor.Stretch;
            this.ListContentView    = libraryView;

            context.ContainerChanged += ActiveContainer_Changed;
            context.ContentChanged   += ActiveContainer_ContentChanged;
        }
Example #11
0
        private List <string> ResolveFilePathsToEmbed(ILibraryContext context, IEnumerable <IntermediateSection> sections)
        {
            var embedFilePaths = new List <string>();

            // Resolve paths to files that are to be embedded in the library.
            if (context.BindFiles)
            {
                var variableResolver = new WixVariableResolver(this.Messaging);

                var fileResolver = new FileResolver(context.BindPaths, context.Extensions);

                foreach (var tuple in sections.SelectMany(s => s.Tuples))
                {
                    foreach (var field in tuple.Fields.Where(f => f?.Type == IntermediateFieldType.Path))
                    {
                        var pathField = field.AsPath();

                        if (pathField != null)
                        {
                            var resolution = variableResolver.ResolveVariables(tuple.SourceLineNumbers, pathField.Path, false);

                            var file = fileResolver.Resolve(tuple.SourceLineNumbers, tuple.Definition, resolution.Value);

                            if (!String.IsNullOrEmpty(file))
                            {
                                // File was successfully resolved so track the embedded index as the embedded file index.
                                field.Set(new IntermediateFieldPathValue {
                                    EmbeddedFileIndex = embedFilePaths.Count
                                });

                                embedFilePaths.Add(file);
                            }
                            else
                            {
                                this.Messaging.Write(ErrorMessages.FileNotFound(tuple.SourceLineNumbers, pathField.Path, tuple.Definition.Name));
                            }
                        }
                    }
                }
            }

            return(embedFilePaths);
        }
Example #12
0
        private async Task SeedTestData(ILibraryContext context)
        {
            context.Books.Add(new Book("To Kill a Mockingbird", new Author("Harper", "Lee"), 1960,
                                       "Beautiful story about how humans treat each other."));

            context.Books.Add(new Book("The Great Gatsby", new Author("Scott", "Fitzgerald"), 1925,
                                       "The greatest, most scathing dissection of the hollowness at the heart of the American dream."));

            context.Books.Add(new Book("One Hundred Years of Solitude", new Author("Gabriel", "Marquez"), 1813,
                                       "Both funny and moving."));

            context.Books.Add(new Book("In Cold Blood", new Author("Truman", "Capote"), 1965,
                                       "The true crime TV show."));

            context.Books.Add(new Book("Go Set a Watchman", new Author("Harper", "Lee"), 2015,
                                       "Stunning novel that is worth reading."));

            await context.SaveChangesAsync();
        }
Example #13
0
        public LibraryListView(ILibraryContext context, GuiWidget libraryView, ThemeConfig theme)
        {
            contentView = new IconListView(theme);

            libraryView.Click += ContentView_Click;

            loadingBackgroundColor = new Color(theme.PrimaryAccentColor, 10);

            this.theme          = theme;
            this.LibraryContext = context;

            // Set Display Attributes
            this.AnchorAll();
            this.AutoScroll         = true;
            this.ScrollArea.Padding = new BorderDouble(3);
            this.ScrollArea.HAnchor = HAnchor.Stretch;
            this.ListContentView    = libraryView;

            context.ContainerChanged += ActiveContainer_Changed;
            context.ContentChanged   += ActiveContainer_ContentChanged;
        }
Example #14
0
        private void ResolveFilePathsToEmbed(ILibraryContext context, IEnumerable <IntermediateSection> sections)
        {
            // Resolve paths to files that are to be embedded in the library.
            if (context.BindFiles)
            {
                var variableResolver = this.ServiceProvider.GetService <IVariableResolver>();

                var fileResolver = new FileResolver(context.BindPaths, context.Extensions);

                foreach (var symbol in sections.SelectMany(s => s.Symbols))
                {
                    foreach (var field in symbol.Fields.Where(f => f?.Type == IntermediateFieldType.Path))
                    {
                        var pathField = field.AsPath();

                        if (pathField != null && !String.IsNullOrEmpty(pathField.Path))
                        {
                            var resolution = variableResolver.ResolveVariables(symbol.SourceLineNumbers, pathField.Path);

                            var file = fileResolver.Resolve(symbol.SourceLineNumbers, symbol.Definition, resolution.Value);

                            if (!String.IsNullOrEmpty(file))
                            {
                                // File was successfully resolved so track the embedded index as the embedded file index.
                                field.Set(new IntermediateFieldPathValue {
                                    Embed = true, Path = file
                                });
                            }
                            else
                            {
                                this.Messaging.Write(ErrorMessages.FileNotFound(symbol.SourceLineNumbers, pathField.Path, symbol.Definition.Name));
                            }
                        }
                    }
                }
            }
        }
Example #15
0
        public PrintLibraryWidget(MainViewWidget mainViewWidget, PartWorkspace workspace, ThemeConfig theme, Color libraryBackground, PopupMenuButton popupMenuButton)
        {
            this.theme          = theme;
            this.mainViewWidget = mainViewWidget;
            this.Padding        = 0;
            this.AnchorAll();

            var allControls = new FlowLayoutWidget(FlowDirection.TopToBottom);

            libraryContext = workspace.LibraryView;

            libraryView = new LibraryListView(libraryContext, theme)
            {
                Name = "LibraryView",
                // Drop containers if ShowContainers != 1
                ContainerFilter = (container) => this.ShowContainers,
                BackgroundColor = libraryBackground,
                Border          = new BorderDouble(top: 1)
            };

            navBar = new OverflowBar(theme)
            {
                HAnchor = HAnchor.Stretch,
                VAnchor = VAnchor.Fit,
            };
            allControls.AddChild(navBar);
            theme.ApplyBottomBorder(navBar);

            var toolbar = new OverflowBar(StaticData.Instance.LoadIcon("fa-sort_16.png", 32, 32, theme.InvertIcons), theme)
            {
                HAnchor = HAnchor.Stretch,
                VAnchor = VAnchor.Fit,
                Name    = "Folders Toolbar",
            };

            toolbar.OverflowButton.ToolTipText = "Sorting".Localize();

            theme.ApplyBottomBorder(toolbar, shadedBorder: true);

            toolbar.OverflowButton.Name = "Print Library View Options";
            toolbar.Padding             = theme.ToolbarPadding;

            toolbar.ExtendOverflowMenu = (popupMenu) => LibraryWidget.CreateSortingMenu(popupMenu, libraryView);

            allControls.AddChild(toolbar);

            toolbar.AddChild(new HorizontalSpacer());

            toolbar.AddChild(LibraryWidget.CreateViewOptionsMenuButton(theme,
                                                                       libraryView,
                                                                       (show) => ShowContainers = show,
                                                                       () => ShowContainers));

            breadCrumbWidget = new FolderBreadCrumbWidget(workspace.LibraryView, theme);
            navBar.AddChild(breadCrumbWidget);

            var searchPanel = new TextEditWithInlineCancel(theme)
            {
                Visible = false,
                Margin  = new BorderDouble(10, 0, 5, 0),
            };

            searchPanel.TextEditWidget.ActualTextEditWidget.EnterPressed += (s, e) =>
            {
                this.PerformSearch();
            };
            searchPanel.ResetButton.Click += (s, e) =>
            {
                breadCrumbWidget.Visible = true;
                searchPanel.Visible      = false;

                searchPanel.TextEditWidget.Text = "";

                this.ClearSearch();
            };

            // Store a reference to the input field
            this.searchInput = searchPanel.TextEditWidget;

            navBar.AddChild(searchPanel);

            searchButton         = theme.CreateSearchButton();
            searchButton.Enabled = false;
            searchButton.Name    = "Search Library Button";
            searchButton.Click  += (s, e) =>
            {
                if (searchPanel.Visible)
                {
                    PerformSearch();
                }
                else
                {
                    searchContainer = libraryView.ActiveContainer;

                    breadCrumbWidget.Visible = false;
                    searchPanel.Visible      = true;
                    searchInput.Focus();
                }
            };
            navBar.AddChild(searchButton);

            allControls.AddChild(libraryView);

            buttonPanel = new FlowLayoutWidget()
            {
                HAnchor = HAnchor.Stretch,
                Padding = theme.ToolbarPadding,
            };
            AddLibraryButtonElements();
            allControls.AddChild(buttonPanel);

            allControls.AnchorAll();

            this.AddChild(allControls);

            // Register listeners
            libraryView.SelectedItems.CollectionChanged += SelectedItems_CollectionChanged;
            libraryContext.ContainerChanged             += Library_ContainerChanged;
        }
 public BookRepository(ILibraryContext dbContext)
 {
     _dbContext = dbContext;
 }
Example #17
0
 public UserRepository(ILibraryContext context)
 {
     _context = context;
 }
Example #18
0
 public BookLoanRepository(ILibraryContext context)
 {
     _context = context;
 }
Example #19
0
        public PrintLibraryWidget(MainViewWidget mainViewWidget, PartWorkspace workspace, ThemeConfig theme, PopupMenuButton popupMenuButton)
        {
            this.theme          = theme;
            this.mainViewWidget = mainViewWidget;
            this.Padding        = 0;
            this.AnchorAll();

            var allControls = new FlowLayoutWidget(FlowDirection.TopToBottom);

            libraryContext = workspace.LibraryView;

            libraryView = new LibraryListView(libraryContext, theme)
            {
                Name = "LibraryView",
                // Drop containers if ShowContainers != 1
                ContainerFilter = (container) => UserSettings.Instance.ShowContainers,
                BackgroundColor = theme.BackgroundColor,
                Border          = new BorderDouble(top: 1)
            };

            navBar = new OverflowBar(theme)
            {
                HAnchor = HAnchor.Stretch,
                VAnchor = VAnchor.Fit,
            };
            allControls.AddChild(navBar);
            theme.ApplyBottomBorder(navBar);

            var toolbar = new OverflowBar(AggContext.StaticData.LoadIcon("fa-sort_16.png", 32, 32, theme.InvertIcons), theme)
            {
                HAnchor = HAnchor.Stretch,
                VAnchor = VAnchor.Fit,
                Name    = "Folders Toolbar"
            };

            theme.ApplyBottomBorder(toolbar, shadedBorder: true);

            toolbar.OverflowButton.Name = "Print Library View Options";
            toolbar.Padding             = theme.ToolbarPadding;

            toolbar.ExtendOverflowMenu = (popupMenu) =>
            {
                var siblingList = new List <GuiWidget>();

                popupMenu.CreateBoolMenuItem(
                    "Date Created".Localize(),
                    () => libraryView.ActiveSort == LibraryListView.SortKey.CreatedDate,
                    (v) => libraryView.ActiveSort = LibraryListView.SortKey.CreatedDate,
                    useRadioStyle: true,
                    siblingRadioButtonList: siblingList);

                popupMenu.CreateBoolMenuItem(
                    "Date Modified".Localize(),
                    () => libraryView.ActiveSort == LibraryListView.SortKey.ModifiedDate,
                    (v) => libraryView.ActiveSort = LibraryListView.SortKey.ModifiedDate,
                    useRadioStyle: true,
                    siblingRadioButtonList: siblingList);

                popupMenu.CreateBoolMenuItem(
                    "Name".Localize(),
                    () => libraryView.ActiveSort == LibraryListView.SortKey.Name,
                    (v) => libraryView.ActiveSort = LibraryListView.SortKey.Name,
                    useRadioStyle: true,
                    siblingRadioButtonList: siblingList);

                popupMenu.CreateSeparator();

                siblingList = new List <GuiWidget>();

                popupMenu.CreateBoolMenuItem(
                    "Ascending".Localize(),
                    () => libraryView.Ascending,
                    (v) => libraryView.Ascending = true,
                    useRadioStyle: true,
                    siblingRadioButtonList: siblingList);

                popupMenu.CreateBoolMenuItem(
                    "Descending".Localize(),
                    () => !libraryView.Ascending,
                    (v) => libraryView.Ascending = false,
                    useRadioStyle: true,
                    siblingRadioButtonList: siblingList);
            };

            allControls.AddChild(toolbar);

            var showFolders = new ExpandCheckboxButton("Folders".Localize(), theme)
            {
                HAnchor = HAnchor.Stretch,
                VAnchor = VAnchor.Fit | VAnchor.Center,
                Margin  = theme.ButtonSpacing,
                Name    = "Show Folders Toggle",
                Checked = UserSettings.Instance.ShowContainers,
            };

            showFolders.SetIconMargin(theme.ButtonSpacing);
            showFolders.CheckedStateChanged += async(s, e) =>
            {
                UserSettings.Instance.set(UserSettingsKey.ShowContainers, showFolders.Checked ? "1" : "0");
                await libraryView.Reload();
            };
            toolbar.AddChild(showFolders);

            PopupMenuButton viewMenuButton;

            toolbar.AddChild(
                viewMenuButton = new PopupMenuButton(
                    new ImageWidget(AggContext.StaticData.LoadIcon("mi-view-list_10.png", 32, 32, theme.InvertIcons))
            {
                //VAnchor = VAnchor.Center
            },
                    theme)
            {
                AlignToRightEdge = true
            });

            viewMenuButton.DynamicPopupContent = () =>
            {
                var popupMenu = new PopupMenu(ApplicationController.Instance.MenuTheme);

                var listView = this.libraryView;

                var siblingList = new List <GuiWidget>();

                popupMenu.CreateBoolMenuItem(
                    "View List".Localize(),
                    () => ApplicationController.Instance.ViewState.LibraryViewMode == ListViewModes.RowListView,
                    (isChecked) =>
                {
                    ApplicationController.Instance.ViewState.LibraryViewMode = ListViewModes.RowListView;
                    listView.ListContentView = new RowListView(theme);
                    listView.Reload().ConfigureAwait(false);
                },
                    useRadioStyle: true,
                    siblingRadioButtonList: siblingList);
#if DEBUG
                popupMenu.CreateBoolMenuItem(
                    "View XSmall Icons".Localize(),
                    () => ApplicationController.Instance.ViewState.LibraryViewMode == ListViewModes.IconListView18,
                    (isChecked) =>
                {
                    ApplicationController.Instance.ViewState.LibraryViewMode = ListViewModes.IconListView18;
                    listView.ListContentView = new IconListView(theme, 18);
                    listView.Reload().ConfigureAwait(false);
                },
                    useRadioStyle: true,
                    siblingRadioButtonList: siblingList);

                popupMenu.CreateBoolMenuItem(
                    "View Small Icons".Localize(),
                    () => ApplicationController.Instance.ViewState.LibraryViewMode == ListViewModes.IconListView70,
                    (isChecked) =>
                {
                    ApplicationController.Instance.ViewState.LibraryViewMode = ListViewModes.IconListView70;
                    listView.ListContentView = new IconListView(theme, 70);
                    listView.Reload().ConfigureAwait(false);
                },
                    useRadioStyle: true,
                    siblingRadioButtonList: siblingList);
#endif
                popupMenu.CreateBoolMenuItem(
                    "View Icons".Localize(),
                    () => ApplicationController.Instance.ViewState.LibraryViewMode == ListViewModes.IconListView,
                    (isChecked) =>
                {
                    ApplicationController.Instance.ViewState.LibraryViewMode = ListViewModes.IconListView;
                    listView.ListContentView = new IconListView(theme);
                    listView.Reload().ConfigureAwait(false);
                },
                    useRadioStyle: true,
                    siblingRadioButtonList: siblingList);

                popupMenu.CreateBoolMenuItem(
                    "View Large Icons".Localize(),
                    () => ApplicationController.Instance.ViewState.LibraryViewMode == ListViewModes.IconListView256,
                    (isChecked) =>
                {
                    ApplicationController.Instance.ViewState.LibraryViewMode = ListViewModes.IconListView256;
                    listView.ListContentView = new IconListView(theme, 256);
                    listView.Reload().ConfigureAwait(false);
                },
                    useRadioStyle: true,
                    siblingRadioButtonList: siblingList);

                return(popupMenu);
            };

            breadCrumbWidget = new FolderBreadCrumbWidget(workspace.LibraryView, theme);
            navBar.AddChild(breadCrumbWidget);

            var searchPanel = new SearchInputBox(theme)
            {
                Visible = false,
                Margin  = new BorderDouble(10, 0, 5, 0),
            };
            searchPanel.searchInput.ActualTextEditWidget.EnterPressed += (s, e) =>
            {
                this.PerformSearch();
            };
            searchPanel.ResetButton.Click += (s, e) =>
            {
                breadCrumbWidget.Visible = true;
                searchPanel.Visible      = false;

                searchPanel.searchInput.Text = "";

                this.ClearSearch();
            };

            // Store a reference to the input field
            this.searchInput = searchPanel.searchInput;

            navBar.AddChild(searchPanel);

            searchButton         = theme.CreateSearchButton();
            searchButton.Enabled = false;
            searchButton.Name    = "Search Library Button";
            searchButton.Click  += (s, e) =>
            {
                if (searchPanel.Visible)
                {
                    PerformSearch();
                }
                else
                {
                    searchContainer = libraryView.ActiveContainer;

                    breadCrumbWidget.Visible = false;
                    searchPanel.Visible      = true;
                    searchInput.Focus();
                }
            };
            navBar.AddChild(searchButton);

            allControls.AddChild(libraryView);

            buttonPanel = new FlowLayoutWidget()
            {
                HAnchor = HAnchor.Stretch,
                Padding = theme.ToolbarPadding,
            };
            AddLibraryButtonElements();
            allControls.AddChild(buttonPanel);

            allControls.AnchorAll();

            this.AddChild(allControls);

            // Register listeners
            libraryView.SelectedItems.CollectionChanged += SelectedItems_CollectionChanged;
            libraryContext.ContainerChanged             += Library_ContainerChanged;
        }
Example #20
0
 public LibraryUow(ILibraryContext context)
 {
     this.context = context;
 }
 public BookController(ILibraryContext context)
 {
     db = context;
 }
 public GetBooksListQueryHandler(ILibraryContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
Example #23
0
 public void ApplyFilter(string filter, ILibraryContext libraryContext)
 {
     keywordFilter = filter;
     this.Load();
     this.OnContentChanged();
 }
 public GetReaderDetailsQueryHandlerTests()
 {
     _mapper = new UserMapper();
     _libraryContextFactory = new InMemoryLibraryContextFactory();
     _libraryContext        = _libraryContextFactory.Create();
 }
Example #25
0
 public LibraryUow()
 {
     this.context = new LibraryContext();
 }
Example #26
0
 public BookDBRepository(ILibraryContext db)
 {
     this.db = db;
 }
Example #27
0
 // Default constructor uses IconListView
 public ListView(ILibraryContext context, ThemeConfig theme)
     : this(context, new IconListView(theme), theme)
 {
 }
Example #28
0
 public static void CreateMenuActions(LibraryListView libraryView, List <LibraryAction> menuActions, ILibraryContext libraryContext, MainViewWidget mainViewWidget, ThemeConfig theme, bool allowPrint)
 {
     menuActions.Add(new LibraryAction(ActionScope.ListView)
     {
         Icon        = StaticData.Instance.LoadIcon("cube.png", 16, 16, ApplicationController.Instance.MenuTheme.InvertIcons),
         Title       = "Add".Localize(),
         ToolTipText = "Add an.stl, .obj, .amf, .gcode or.zip file to the Library".Localize(),
         Action      = (selectedLibraryItems, listView) =>
         {
             UiThread.RunOnIdle(() =>
             {
                 AggContext.FileDialogs.OpenFileDialog(
                     new OpenFileDialogParams(ApplicationSettings.OpenPrintableFileParams, multiSelect: true),
                     (openParams) =>
                 {
                     if (openParams.FileNames != null)
                     {
                         if (libraryView.ActiveContainer is ILibraryWritableContainer writableContainer &&
                             openParams.FileNames.Length > 0)
                         {
                             writableContainer.Add(openParams.FileNames.Select(f => new FileSystemFileItem(f)));
                         }
                     }
                 });
             });
 public WriterController(ILibraryContext context)
 {
     db = context;
 }
Example #30
0
        public LibraryWidget(MainViewWidget mainViewWidget, ThemeConfig theme)
        {
            this.theme          = theme;
            this.mainViewWidget = mainViewWidget;
            this.Padding        = 0;
            this.AnchorAll();

            var allControls = new FlowLayoutWidget(FlowDirection.TopToBottom);

            libraryContext = ApplicationController.Instance.LibraryTabContext;

            libraryView = new LibraryListView(libraryContext, theme)
            {
                Name = "LibraryView",
                // Drop containers if ShowContainers != 1
                ContainerFilter   = (container) => this.ShowContainers,
                BackgroundColor   = theme.BackgroundColor,
                Border            = new BorderDouble(top: 1),
                DoubleClickAction = LibraryListView.DoubleClickActions.PreviewItem
            };

            navBar = new OverflowBar(theme)
            {
                HAnchor = HAnchor.Stretch,
                VAnchor = VAnchor.Fit,
            };
            theme.ApplyBottomBorder(navBar);

            breadCrumbWidget = new FolderBreadCrumbWidget(libraryContext, theme);
            navBar.AddChild(breadCrumbWidget);

            var searchPanel = new TextEditWithInlineCancel(theme)
            {
                Visible = false,
                Margin  = new BorderDouble(10, 0, 5, 0),
            };

            searchPanel.TextEditWidget.ActualTextEditWidget.EnterPressed += (s, e) =>
            {
                this.PerformSearch();
            };
            searchPanel.ResetButton.Click += (s, e) =>
            {
                breadCrumbWidget.Visible = true;
                searchPanel.Visible      = false;

                searchPanel.TextEditWidget.Text = "";

                this.ClearSearch();
            };

            // Store a reference to the input field
            this.searchInput = searchPanel.TextEditWidget;

            navBar.AddChild(searchPanel);

            searchButton         = theme.CreateSearchButton();
            searchButton.Enabled = false;
            searchButton.Name    = "Search Library Button";
            searchButton.Click  += (s, e) =>
            {
                if (searchPanel.Visible)
                {
                    PerformSearch();
                }
                else
                {
                    searchContainer = libraryContext.ActiveContainer;

                    breadCrumbWidget.Visible = false;
                    searchPanel.Visible      = true;
                    searchInput.Focus();
                }
            };
            navBar.AddChild(searchButton);

            navBar.AddChild(CreateViewOptionsMenuButton(theme, libraryView, (show) => ShowContainers = show, () => ShowContainers));

            navBar.AddChild(CreateSortingMenuButton(theme, libraryView));

            allControls.AddChild(navBar);

            var horizontalSplitter = new Splitter()
            {
                SplitterDistance   = UserSettings.Instance.LibraryViewWidth,
                SplitterSize       = theme.SplitterWidth,
                SplitterBackground = theme.SplitterBackground
            };

            horizontalSplitter.AnchorAll();

            horizontalSplitter.DistanceChanged += (s, e) =>
            {
                UserSettings.Instance.LibraryViewWidth = horizontalSplitter.SplitterDistance;
            };

            allControls.AddChild(horizontalSplitter);

            libraryTreeView = new TreeView(theme)
            {
                HAnchor = HAnchor.Stretch,
                VAnchor = VAnchor.Stretch,
                Margin  = 5
            };
            libraryTreeView.AfterSelect += async(s, e) =>
            {
                if (libraryTreeView.SelectedNode is ContainerTreeNode treeNode)
                {
                    if (!treeNode.ContainerAcquired)
                    {
                        await this.EnsureExpanded(treeNode.Tag as ILibraryItem, treeNode);
                    }

                    if (treeNode.ContainerAcquired)
                    {
                        libraryContext.ActiveContainer = treeNode.Container;
                    }
                }
            };
            horizontalSplitter.Panel1.AddChild(libraryTreeView);

            var rootColumn = new FlowLayoutWidget(FlowDirection.TopToBottom)
            {
                HAnchor = HAnchor.Fit,
                VAnchor = VAnchor.Fit,
                Margin  = new BorderDouble(left: 10)
            };

            libraryTreeView.AddChild(rootColumn);

            if (AppContext.IsLoading)
            {
                ApplicationController.StartupActions.Add(new ApplicationController.StartupAction()
                {
                    Title    = "Initializing Library".Localize(),
                    Priority = 0,
                    Action   = () =>
                    {
                        this.LoadRootLibraryNodes(rootColumn);
                    }
                });
            }
            else
            {
                this.LoadRootLibraryNodes(rootColumn);
            }

            horizontalSplitter.Panel2.AddChild(libraryView);

            buttonPanel = new FlowLayoutWidget()
            {
                HAnchor = HAnchor.Stretch,
                Padding = theme.ToolbarPadding,
            };
            AddLibraryButtonElements();
            allControls.AddChild(buttonPanel);

            allControls.AnchorAll();

            this.AddChild(allControls);

            // Register listeners
            libraryView.SelectedItems.CollectionChanged += SelectedItems_CollectionChanged;
            libraryContext.ContainerChanged             += Library_ContainerChanged;
        }