Ejemplo n.º 1
0
        /// <summary>
        /// Constructor. Writes metadata and Id column header to excel.
        /// </summary>
        public ExcelPresenterBase(string type, IExcelFile file, Views.IExportDialog dialog)
        {
            Views.Excel.Excel excel = new Views.Excel.Excel();
            this._dialog = dialog;
            this._file   = file;

            this._type = type;

            this._dialog.Title              = this._type;
            this._dialog.Label1             = string.Empty;
            this._dialog.Label2             = string.Empty;
            this._dialog.StartButtonEnabled = false;

            // create styles
            // headers and metadata
            var namedStyle = excel.Package.Workbook.Styles.CreateNamedStyle(HEADER_AND_META_STYLE);

            namedStyle.Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
            namedStyle.Style.Fill.BackgroundColor.SetColor(Color.FromArgb(255, 0, 0, 170));
            namedStyle.Style.Font.Bold = true;
            namedStyle.Style.Font.Color.SetColor(Color.FromArgb(255, 255, 255, 255));
            namedStyle.Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
            // even data row
            namedStyle = excel.Package.Workbook.Styles.CreateNamedStyle(EVEN_ROW_STYLE);
            namedStyle.Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
            namedStyle.Style.Fill.BackgroundColor.SetColor(Color.FromArgb(255, 239, 239, 255));
            // odd data row
            namedStyle = excel.Package.Workbook.Styles.CreateNamedStyle(ODD_ROW_STYLE);
            namedStyle.Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
            namedStyle.Style.Fill.BackgroundColor.SetColor(Color.FromArgb(255, 207, 207, 255));

            // write metadata
            excel.Worksheet = excel.Package.Workbook.Worksheets.Add(type);
            excel.Worksheet.Cells["A1"].Value        = "MyLibrary";
            excel.Worksheet.Cells[1, 1, 1, 2].Merge  = true;
            excel.Worksheet.Cells["A2"].Value        = "Type";
            excel.Worksheet.Cells["B2"].Value        = this._type + "s";
            excel.Worksheet.Cells["A3"].Value        = "App Version:";
            excel.Worksheet.Cells["B3"].Value        = Configuration.APP_VERSION.ToString();
            excel.Worksheet.Cells["A4"].Value        = "Extracted At:";
            excel.Worksheet.Cells["B4"].Value        = DateTime.Now.ToString("dddd, dd MMMM yyyy HH:mm:ss");
            excel.Worksheet.Cells["A1:B4"].StyleName = HEADER_AND_META_STYLE;
            excel.Worksheet.Cells["A1:B4"].AutoFitColumns();
            this._excel = excel;
            // write Id column header
            WriteHeaderCell("A", "Id");
            // set the current row to the first data row, ready for writing entities
            this._currRow = HEADER_ROW + 1;

            // subscribe to dialog view's events
            this._dialog.BrowseButtonClicked += BrowseButtonClicked;
            this._dialog.StartButtonClicked  += (async(sender, args) =>
            {
                await HandleStartButtonClicked(sender, args);
            });
            this._dialog.Cancelled += Closed;

            this._dialog.Title = "Export " + this._type + "s";
        }
Ejemplo n.º 2
0
 public TagExcelPresenter(Views.IExportDialog dialog)
     : base("Tag", new ExcelFile(), dialog)
 {
     this._tagService = new TagService();
     WriteHeaders();
 }
Ejemplo n.º 3
0
 public TagExcelPresenter(ITagService tagService, IExcelFile file, Views.IExportDialog dialog)
     : base("Tag", file, dialog)
 {
     this._tagService = tagService;
     WriteHeaders();
 }
Ejemplo n.º 4
0
 public BookExcelPresenter(Views.IExportDialog dialog)
     : base("Book", new ExcelFile(), dialog)
 {
     this._bookService = new BookService();
     WriteHeaders();
 }
Ejemplo n.º 5
0
 public MediaItemExcelPresenter(Views.IExportDialog dialog)
     : base("Media item", new ExcelFile(), dialog)
 {
     this._mediaItemService = new MediaItemService();
     WriteHeaders();
 }
Ejemplo n.º 6
0
 public BookExcelPresenter(IBookService bookService, IExcelFile file, Views.IExportDialog dialog)
     : base("Book", file, dialog)
 {
     this._bookService = bookService;
     WriteHeaders();
 }
Ejemplo n.º 7
0
 public WishlistExcelPresenter(Views.IExportDialog dialog)
     : base("Wishlist item", new ExcelFile(), dialog)
 {
     this._wishlistService = new WishlistService();
     WriteHeaders();
 }
Ejemplo n.º 8
0
 public MediaItemExcelPresenter(IMediaItemService tagService, IExcelFile file, Views.IExportDialog dialog)
     : base("Media item", file, dialog)
 {
     this._mediaItemService = tagService;
     WriteHeaders();
 }
Ejemplo n.º 9
0
 public WishlistExcelPresenter(IWishlistService wishlistService, IExcelFile file, Views.IExportDialog dialog)
     : base("Wishlist item", file, dialog)
 {
     this._wishlistService = wishlistService;
     WriteHeaders();
 }
Ejemplo n.º 10
0
 public AuthorExcelPresenter(Views.IExportDialog dialog)
     : base("Author", new ExcelFile(), dialog)
 {
     this._authorService = new AuthorService();
     WriteHeaders();
 }
Ejemplo n.º 11
0
 public AuthorExcelPresenter(IAuthorService authorService, IExcelFile file, Views.IExportDialog dialog)
     : base("Author", file, dialog)
 {
     this._authorService = authorService;
     WriteHeaders();
 }
Ejemplo n.º 12
0
 public PublisherExcelPresenter(Views.IExportDialog dialog)
     : base("Publisher", new ExcelFile(), dialog)
 {
     this._publisherService = new PublisherService();
     WriteHeaders();
 }
Ejemplo n.º 13
0
 public PublisherExcelPresenter(IPublisherService publisherService, IExcelFile file, Views.IExportDialog dialog)
     : base("Publisher", file, dialog)
 {
     this._publisherService = publisherService;
     WriteHeaders();
 }