Ejemplo n.º 1
0
        private void lstBxComics_SelectedIndexChanged(object sender, EventArgs e)
        {
            //highligh selection made in lstBxComics
            if (lstBxComics.SelectedItem != null)
            {
                Trace.WriteLine("Selection Index Changed: " + lstBxComics.SelectedIndices[0].ToString());
                int    selectedIndex = lstBxComics.SelectedIndices[0];
                string selectedItem  = lstBxComics.SelectedItem.ToString();

                string    cbFullPath = Path.GetFullPath(Path.Combine(@"Resources", @"comicbooks", selectedItem));
                ComicBook selectedComic;
                selectedComic = comicManager.GetComicBook(cbFullPath);

                //enable textboxes/labels
                ComicInfo_Enabled(true);

                //set values in textboxes/labels
                ComicInfo_SetValues(selectedComic);
            }
            //highlight selection disappeared from lstBxComics
            else
            {
                Trace.WriteLine("Selection Index Changed: " + "NULL");
                //hide the controls and disable the textboxes
                ComicInfo_Enabled(false);
            }
        }
Ejemplo n.º 2
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            string fileName = lstBxAvailableComics.SelectedItem.ToString();

            //get comic book
            UserComicBook importedCb = UserComicBook.MorphToUserComicBook(comicManager.GetComicBook(Path.Combine(cbResourceDirectory, fileName)));
            Bookmark      bm         = new Bookmark(importedCb.PageCount);

            importedCb.BookMark = bm;
            //add to user library
            loggedInUser.MyComicLibrary.AddComicBook(importedCb);
            //write changes
            accountManager.WriteComicLibrary(loggedInUser.Id, loggedInUser.MyComicLibrary);
            //refresh to reflect changes
            ReloadLibrary();
            btnImport.Enabled = false;
        }
Ejemplo n.º 3
0
        private void lstBxComics_DoubleClick(object sender, EventArgs e)
        {
            if (lstBxComics.SelectedItem != null)
            {
                //get selected item
                string fileName = lstBxComics.SelectedItem.ToString();
                string fullPath = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), cbResourceDirectory, fileName));

                //increment view count
                loggedInUser.MyComicLibrary.GetComicBook(fullPath);
                var publicCb = comicManager.GetComicBook(fullPath);
                publicCb.ViewCount++;
                //write changes
                comicManager.UpdateComicBookRecord(publicCb);
                accountManager.WriteComicLibrary(loggedInUser.Id,
                                                 loggedInUser.MyComicLibrary);

                //open new comicView window
                ComicView ui_view = new ComicView(fullPath, loggedInUser);
                ui_view.ShowDialog();
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// reread available comics
        /// </summary>
        private void lstViewAvailableComics_Refresh()
        {
            //reset cache comic books and clear items
            comicBooks = null;
            lstViewAvailableComics.Items.Clear();

            //update the comic book archives into the view
            //cache each into comic book records
            List <Business_Logic.ComicBook> cbList = new List <Business_Logic.ComicBook>();

            foreach (var file in Directory.GetFiles(Path.Combine(Directory.GetCurrentDirectory(), "Resources", "comicbooks")))
            {
                lstViewAvailableComics.Items.Add(Path.GetFileName(file));

                string cbFullPath = "";
                Business_Logic.ComicBook cb;
                try
                {
                    //get full path of comic book archive
                    cbFullPath = Path.GetFullPath(Path.Combine(@"Resources", @"comicbooks", Path.GetFileName(file)));

                    //get comicbook instance
                    cb = comicReader.GetComicBook(cbFullPath);
                    if (cb == null)
                    {
                        throw new InvalidOperationException("Comic book records is empty.");
                    }
                }
                catch (InvalidOperationException exc)
                {
                    Trace.WriteLine("Exception thrown: " + exc.Message);
                    Trace.WriteLine("Comic book selected with archive path: <" + cbFullPath + "> does not exist in the comic book records. Initialized the comic book.");
                    comicReader.InitializeNewComicBook(cbFullPath);
                    cb = comicReader.GetComicBook(cbFullPath);
                }

                //add comic book to list
                cbList.Add(cb);
            }

            comicBooks = cbList.ToArray();
        }