/** * Constructor. * * @param bookParagraphsList * List of book paragraphs */ public BookPagesListDataControl(List <BookPage> bookPagesList, BookDataControl dControl) { this.bookPagesList = bookPagesList; this.dControl = dControl; selectedPage = -1; defaultType = BookPage.TYPE_RESOURCE; defaultMargin = 0; defaultScrollable = false; }
public override bool addElement(int type, string bookId) { bool elementAdded = false; if (type == Controller.BOOK) { int bookType = -1; //TODO: tmp, delete this line bookType = 0; //TODO: implement //BookTypesDialog bookTypesDialog = new BookTypesDialog(Book.TYPE_PARAGRAPHS); //bookType = bookTypesDialog.getOptionSelected(); if (bookType != -1) { // Show a dialog asking for the book id if (bookId == null || bookId.Equals("")) { bookId = controller.showInputDialog(TC.get("Operation.AddBookTitle"), TC.get("Operation.AddBookMessage"), TC.get("Operation.AddBookDefaultValue")); } // If some value was typed and the identifier is valid if (bookId != null && controller.isElementIdValid(bookId)) { // Add thew new book Book newBook = new Book(bookId); newBook.setType(bookType); // Set default background ResourcesUni resources = new ResourcesUni(); resources.addAsset("background", SpecialAssetPaths.ASSET_DEFAULT_BOOK_IMAGE); resources.addAsset("arrowLeftNormal", SpecialAssetPaths.ASSET_DEFAULT_ARROW_NORMAL); resources.addAsset("arrowLeftOver", SpecialAssetPaths.ASSET_DEFAULT_ARROW_OVER); newBook.addResources(resources); BookDataControl newDataControl = new BookDataControl(newBook); booksList.Add(newBook); booksDataControlList.Add(newDataControl); controller.getIdentifierSummary().addBookId(bookId); //controller.dataModified( ); elementAdded = true; } } } return(elementAdded); }
public override bool moveElementDown(DataControl dataControl) { bool elementMoved = false; int elementIndex = booksList.IndexOf((Book)dataControl.getContent()); if (elementIndex < booksList.Count - 1) { Book e = booksList[elementIndex]; BookDataControl c = booksDataControlList[elementIndex]; booksList.RemoveAt(elementIndex); booksDataControlList.RemoveAt(elementIndex); booksList.Insert(elementIndex + 1, e); booksDataControlList.Insert(elementIndex + 1, c); //controller.dataModified( ); elementMoved = true; } return(elementMoved); }
public void Init(DialogReceiverInterface e, BookDataControl book) { bookRef = book; string backgroundPath = book.getPreviewImage(); backgroundPreviewTex = (Texture2D)Resources.Load(backgroundPath.Substring(0, backgroundPath.LastIndexOf(".")), typeof(Texture2D)); string leftNormalArrowPath = book.getArrowImagePath_WithDefault(BookDataControl.ARROW_LEFT, BookDataControl.ARROW_NORMAL); leftArrowTex = (Texture2D) Resources.Load(leftNormalArrowPath.Substring(0, leftNormalArrowPath.LastIndexOf(".")), typeof(Texture2D)); string rightNormalArrowPath = book.getArrowImagePath_WithDefault(BookDataControl.ARROW_RIGHT, BookDataControl.ARROW_NORMAL); rightArrowTex = (Texture2D) Resources.Load(rightNormalArrowPath.Substring(0, rightNormalArrowPath.LastIndexOf(".")), typeof(Texture2D)); imageBackgroundRect = new Rect(0f, 0f, backgroundPreviewTex.width, backgroundPreviewTex.height); defaultPreviousPageArrowPosition = new Vector2(MARGIN, backgroundPreviewTex.height - leftArrowTex.height - MARGIN); defaultNextPageArrowPosition = new Vector2(backgroundPreviewTex.width - rightArrowTex.width - MARGIN, backgroundPreviewTex.height - rightArrowTex.height - MARGIN); if (bookRef.getPreviousPagePosition() == Vector2.zero && bookRef.getNextPagePosition() == Vector2.zero) { SetDefaultArrowsPosition(); } CalculateArrowsPosition(); base.Init(e, backgroundPreviewTex.width, backgroundPreviewTex.height); }