Ejemplo n.º 1
0
        private void PreviewToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TreeView tree = null;

            if (tc_Info.SelectedTab == tabPage_Book)
            {
                tree = tw_Book;
            }
            if (tc_Info.SelectedTab == tabPage_Film)
            {
                tree = tw_Film;
            }

            if ((tree.SelectedNode != null) && (TreeViewOPs.GetDeepestChildNodeLevel(tree.SelectedNode) == 1))
            {
                try
                {
                    print_PreviewDialog.Document = print_Doc;
                    //print_PreviewDialog.Height = 700;
                    //print_PreviewDialog.Width = 500;
                    print_PreviewDialog.ShowDialog();
                }
                catch (Exception ex) { MessageBox.Show(ex.ToString()); }
            }
        }
Ejemplo n.º 2
0
        private void tw_Book_AfterSelect(object sender, TreeViewEventArgs e)
        {
            List <Book> parse = FileOPs.ParseBookXmlToList(bookFileName);

            if ((tw_Book.SelectedNode != null) && (TreeViewOPs.GetDeepestChildNodeLevel(e.Node.TreeView.SelectedNode) == 1))
            {
                try
                {
                    imageNumber = 0;
                    grpbox_BookInfo.Show();
                    txtbox_BookID.Text             = parse.Find(b => b.bookAuthor == e.Node.Parent.Parent.Text && b.bookTitle == e.Node.Text).bookID.ToString();
                    txtbox_BookMajorSeries.Text    = parse.Find(b => b.bookAuthor == e.Node.Parent.Parent.Text && b.bookTitle == e.Node.Text).bookMajorSeries;
                    txtbox_BookAuthor.Text         = e.Node.Parent.Parent.Text;
                    txtbox_BookTitle.Text          = e.Node.Text;
                    txtbox_BookSeries.Text         = parse.Find(b => b.bookAuthor == e.Node.Parent.Parent.Text && b.bookTitle == e.Node.Text).bookSeries;
                    txtbox_BookNumberInSeries.Text = parse.Find(b => b.bookAuthor == e.Node.Parent.Parent.Text && b.bookTitle == e.Node.Text).bookNumberInSeries.ToString();
                    txtbox_BookGenre.Text          = parse.Find(b => b.bookAuthor == e.Node.Parent.Parent.Text && b.bookTitle == e.Node.Text).bookGenre;
                    txtbox_BookPagesCount.Text     = parse.Find(b => b.bookAuthor == e.Node.Parent.Parent.Text && b.bookTitle == e.Node.Text).bookPagesCount.ToString();
                    txtbox_BookPublisher.Text      = parse.Find(b => b.bookAuthor == e.Node.Parent.Parent.Text && b.bookTitle == e.Node.Text).bookPublisher;
                    txtbox_BookPrintYear.Text      = parse.Find(b => b.bookAuthor == e.Node.Parent.Parent.Text && b.bookTitle == e.Node.Text).bookPrintYear.ToString();
                    txtbox_BookPrintCity.Text      = parse.Find(b => b.bookAuthor == e.Node.Parent.Parent.Text && b.bookTitle == e.Node.Text).bookPrintCity;
                    if (parse.Find(b => b.bookAuthor == e.Node.Parent.Parent.Text && b.bookTitle == e.Node.Text).bookISBN.ToString().Length == 10)
                    {
                        msktxtbox_BookISBN.Mask = "000000000-0";
                    }
                    else if (parse.Find(b => b.bookAuthor == e.Node.Parent.Parent.Text && b.bookTitle == e.Node.Text).bookISBN.ToString().Length == 13)
                    {
                        msktxtbox_BookISBN.Mask = "000-0-00-000000-0";
                    }
                    msktxtbox_BookISBN.Text          = parse.Find(b => b.bookAuthor == e.Node.Parent.Parent.Text && b.bookTitle == e.Node.Text).bookISBN.ToString();
                    txtbox_BookTranslator.Text       = parse.Find(b => b.bookAuthor == e.Node.Parent.Parent.Text && b.bookTitle == e.Node.Text).bookTranslator;
                    txtbox_BookArtist.Text           = parse.Find(b => b.bookAuthor == e.Node.Parent.Parent.Text && b.bookTitle == e.Node.Text).bookArtist;
                    txtbox_BookNotes.Text            = parse.Find(b => b.bookAuthor == e.Node.Parent.Parent.Text && b.bookTitle == e.Node.Text).bookNotes;
                    picBox_BookPreview.ImageLocation = parse.Find(b => b.bookAuthor == e.Node.Parent.Parent.Text && b.bookTitle == e.Node.Text).picturesPath[0].ToString();
                    label1.Text = parse.Find(b => b.bookAuthor == e.Node.Parent.Parent.Text && b.bookTitle == e.Node.Text).picturesPath[0];
                    label2.Text = parse.Find(b => b.bookAuthor == e.Node.Parent.Parent.Text && b.bookTitle == e.Node.Text).picturesPath[1];
                    label3.Text = parse.Find(b => b.bookAuthor == e.Node.Parent.Parent.Text && b.bookTitle == e.Node.Text).picturesPath[2];
                    timer_Preview.Start();
                }
                catch (Exception) { }
            }
            else
            {
                grpbox_BookInfo.Hide();
                timer_Preview.Stop();
                picBox_BookPreview.Image = null;
                if (e.Node.IsExpanded)
                {
                    e.Node.Collapse();
                }
                else
                {
                    e.Node.Expand();
                }
            }
        }
Ejemplo n.º 3
0
        private void EditToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (tc_Info.SelectedTab == tabPage_Book)
            {
                if ((tw_Book.SelectedNode != null) && (TreeViewOPs.GetDeepestChildNodeLevel(tw_Book.SelectedNode) == 1))
                {
                    try
                    {
                        List <Book> parse = FileOPs.ParseBookXmlToList(bookFileName);

                        Book bookToEdit = parse.Find(b => b.bookTitle == tw_Book.SelectedNode.Text && b.bookSeries == tw_Book.SelectedNode.Parent.Text && b.bookAuthor == tw_Book.SelectedNode.Parent.Parent.Text);

                        timer_Preview.Stop();
                        picBox_BookPreview.Image = null;

                        form_EditBook formEdit = new form_EditBook(bookToEdit);
                        formEdit.Show();

                        TreeViewOPs.CreateBookTree(tw_Book);
                    }
                    catch (Exception ex) { MessageBox.Show(ex.ToString()); }
                }
                else
                {
                    MessageBox.Show("Необходимо выбрать 'Книгу'");
                }
            }

            if (tc_Info.SelectedTab == tabPage_Film)
            {
                if ((tw_Film.SelectedNode != null) && (TreeViewOPs.GetDeepestChildNodeLevel(tw_Film.SelectedNode) == 1))
                {
                    try
                    {
                        List <Film> parse = FileOPs.ParseFilmXmlToList(filmFileName);

                        Film filmToEdit = parse.Find(f => f.filmTitle == tw_Film.SelectedNode.Text && f.filmProducer == tw_Film.SelectedNode.Parent.Text);

                        timer_Preview.Stop();
                        picBox_FilmPreview.Image = null;

                        form_EditFilm formEdit = new form_EditFilm(filmToEdit);
                        formEdit.Show();

                        TreeViewOPs.CreateFilmTree(tw_Film);
                    }
                    catch (Exception ex) { MessageBox.Show(ex.ToString()); }
                }
                else
                {
                    MessageBox.Show("Необходимо выбрать 'Фильм'");
                }
            }
        }
Ejemplo n.º 4
0
 private void CloneToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (tc_Info.SelectedTab == tabPage_Book)
     {
         TreeViewOPs.CopyBookTreeNode(tw_Book);
     }
     if (tc_Info.SelectedTab == tabPage_Film)
     {
         TreeViewOPs.CopyFilmTreeNode(tw_Film);
     }
 }
Ejemplo n.º 5
0
 private void timer_Preview_Tick(object sender, EventArgs e)
 {
     if (tc_Info.SelectedTab == tabPage_Book)
     {
         TreeViewOPs.LoadBookNextImage(tw_Book.SelectedNode, ref picBox_BookPreview);
     }
     if (tc_Info.SelectedTab == tabPage_Film)
     {
         TreeViewOPs.LoadFilmNextImage(tw_Film.SelectedNode, ref picBox_FilmPreview);
     }
 }
Ejemplo n.º 6
0
 private void tc_Info_Selected(object sender, EventArgs e)
 {
     if (tc_Info.SelectedTab == tabPage_Book)
     {
         timer_Preview.Stop();
         grpbox_BookInfo.Hide();
         TreeViewOPs.CreateBookTree(tw_Book);
     }
     if (tc_Info.SelectedTab == tabPage_Film)
     {
         timer_Preview.Stop();
         grpbox_FilmInfo.Hide();
         TreeViewOPs.CreateFilmTree(tw_Film);
     }
 }
Ejemplo n.º 7
0
        private void Catalog_Load(object sender, EventArgs e)
        {
            timer_Preview.Stop();
            FileOPs.SetBookLastID();
            FileOPs.SetFilmLastID();

            if (tc_Info.SelectedTab == tabPage_Book)
            {
                grpbox_BookInfo.Hide();
                TreeViewOPs.CreateBookTree(tw_Book);
            }
            if (tc_Info.SelectedTab == tabPage_Film)
            {
                grpbox_FilmInfo.Hide();
                TreeViewOPs.CreateFilmTree(tw_Film);
            }
        }
Ejemplo n.º 8
0
        private void tw_Film_AfterSelect(object sender, TreeViewEventArgs e)
        {
            List <Film> parse = FileOPs.ParseFilmXmlToList(filmFileName);

            if ((tw_Film.SelectedNode != null) && (TreeViewOPs.GetDeepestChildNodeLevel(e.Node.TreeView.SelectedNode) == 1))
            {
                try
                {
                    imageNumber = 0;
                    grpbox_FilmInfo.Show();
                    txtbox_FilmID.Text               = parse.Find(f => f.filmProducer == e.Node.Parent.Text && f.filmTitle == e.Node.Text).filmID.ToString();
                    txtbox_FilmProducer.Text         = e.Node.Parent.Text;
                    txtbox_FilmTitle.Text            = e.Node.Text;
                    txtbox_FilmGenre.Text            = parse.Find(f => f.filmProducer == e.Node.Parent.Text && f.filmTitle == e.Node.Text).filmGenre;
                    txtbox_FilmActors.Text           = parse.Find(f => f.filmProducer == e.Node.Parent.Text && f.filmTitle == e.Node.Text).filmActors;
                    txtbox_FilmLength.Text           = parse.Find(f => f.filmProducer == e.Node.Parent.Text && f.filmTitle == e.Node.Text).filmLengthInMinutes.ToString();
                    txtbox_FilmCountry.Text          = parse.Find(f => f.filmProducer == e.Node.Parent.Text && f.filmTitle == e.Node.Text).filmCountry;
                    txtbox_FilmPremiere.Text         = parse.Find(f => f.filmProducer == e.Node.Parent.Text && f.filmTitle == e.Node.Text).filmPremiere.ToString();
                    txtbox_FilmMPAA.Text             = parse.Find(f => f.filmProducer == e.Node.Parent.Text && f.filmTitle == e.Node.Text).filmMPAARating;
                    txtbox_FilmCriticsRating.Text    = parse.Find(f => f.filmProducer == e.Node.Parent.Text && f.filmTitle == e.Node.Text).filmCriticsRating;
                    txtbox_FilmGrosses.Text          = parse.Find(f => f.filmProducer == e.Node.Parent.Text && f.filmTitle == e.Node.Text).filmGrosses.ToString();
                    txtbox_FilmNotes.Text            = parse.Find(f => f.filmProducer == e.Node.Parent.Text && f.filmTitle == e.Node.Text).filmNotes;
                    picBox_FilmPreview.ImageLocation = parse.Find(f => f.filmProducer == e.Node.Parent.Text && f.filmTitle == e.Node.Text).picturesPath[0].ToString();
                    label11.Text = parse.Find(f => f.filmProducer == e.Node.Parent.Text && f.filmTitle == e.Node.Text).picturesPath[0];
                    label12.Text = parse.Find(f => f.filmProducer == e.Node.Parent.Text && f.filmTitle == e.Node.Text).picturesPath[1];
                    label13.Text = parse.Find(f => f.filmProducer == e.Node.Parent.Text && f.filmTitle == e.Node.Text).picturesPath[2];
                    timer_Preview.Start();
                }
                catch (Exception) { }
            }
            else
            {
                grpbox_FilmInfo.Hide();
                timer_Preview.Stop();
                picBox_FilmPreview.Image = null;
                if (e.Node.IsExpanded)
                {
                    e.Node.Collapse();
                }
                else
                {
                    e.Node.Expand();
                }
            }
        }
Ejemplo n.º 9
0
        private void OnChanged(object source, FileSystemEventArgs e)
        {
            Thread.Sleep(10);
            Invoke((MethodInvoker) delegate
            {
                if (tc_Info.SelectedTab == tabPage_Book)
                {
                    TreeViewOPs.CreateBookTree(tw_Book);
                }
                if (tc_Info.SelectedTab == tabPage_Film)
                {
                    TreeViewOPs.CreateBookTree(tw_Film);
                }
            });

            FileOPs.SetBookLastID();
            FileOPs.SetFilmLastID();
        }
Ejemplo n.º 10
0
        private void RemoveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (tc_Info.SelectedTab == tabPage_Book)
            {
                List <Book> parse = FileOPs.ParseBookXmlToList(bookFileName);

                if ((tw_Book.SelectedNode != null) && (TreeViewOPs.GetDeepestChildNodeLevel(tw_Book.SelectedNode) == 1))
                {
                    try
                    {
                        timer_Preview.Stop();
                        picBox_BookPreview.Image = null;
                        grpbox_BookInfo.Hide();

                        FileOPs.RemoveFromXmlFile(parse.Find(b => b.bookAuthor == tw_Book.SelectedNode.Parent.Parent.Text && b.bookTitle == tw_Book.SelectedNode.Text), bookFileName);

                        TreeViewOPs.CreateBookTree(tw_Book);
                    }
                    catch (Exception ex) { MessageBox.Show(ex.ToString()); }
                }
            }

            if (tc_Info.SelectedTab == tabPage_Film)
            {
                List <Film> parse = FileOPs.ParseFilmXmlToList(filmFileName);

                if ((tw_Film.SelectedNode != null) && (TreeViewOPs.GetDeepestChildNodeLevel(tw_Film.SelectedNode) == 1))
                {
                    try
                    {
                        timer_Preview.Stop();
                        picBox_FilmPreview.Image = null;
                        grpbox_FilmInfo.Hide();

                        FileOPs.RemoveFromXmlFile(parse.Find(f => f.filmProducer == tw_Film.SelectedNode.Parent.Text && f.filmTitle == tw_Film.SelectedNode.Text), filmFileName);

                        TreeViewOPs.CreateFilmTree(tw_Film);
                    }
                    catch (Exception ex) { MessageBox.Show(ex.ToString()); }
                }
            }
        }
Ejemplo n.º 11
0
        private void PrintToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TreeView tree = null;

            if (tc_Info.SelectedTab == tabPage_Book)
            {
                tree = tw_Book;
            }
            if (tc_Info.SelectedTab == tabPage_Film)
            {
                tree = tw_Film;
            }

            if ((tree.SelectedNode != null) && (TreeViewOPs.GetDeepestChildNodeLevel(tree.SelectedNode) == 1))
            {
                print_Dialog.Document = print_Doc;

                if (print_Dialog.ShowDialog() == DialogResult.OK)
                {
                    print_Doc.Print();
                }
            }
        }
Ejemplo n.º 12
0
        private void LoadToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ofd_LoadXmlFile.InitialDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Data");
            ofd_LoadXmlFile.Filter           = "XML (*.Xml)|*.Xml|" + "All files (*.*)|*.*";
            ofd_LoadXmlFile.Multiselect      = false;
            ofd_LoadXmlFile.Title            = "My Data file Browser";

            //TBD refactor
            if (tc_Info.SelectedTab == tabPage_Book)
            {
                if (ofd_LoadXmlFile.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        FileOPs.SaveXmlFile(FileOPs.ParseBookXmlToList(bookFileName), bookFileName);
                    }
                    catch (SecurityException ex)
                    {
                        // The user lacks appropriate permissions to read files, discover paths, etc.
                        MessageBox.Show("Security error. Please contact your administrator for details.\n\n" +
                                        "Error message: " + ex.Message + "\n\n" +
                                        "Details (send to Support):\n\n" + ex.StackTrace
                                        );
                    }
                    catch (Exception ex)
                    {
                        // Could not load the image - probably related to Windows file system permissions.
                        MessageBox.Show("Cannot open file: " + ofd_LoadXmlFile.FileName.Substring(ofd_LoadXmlFile.FileName.LastIndexOf('\\'))
                                        + ". You may not have permission to read the file, or " +
                                        "it may be corrupt.\n\nReported error: " + ex.Message);
                    }
                }

                TreeViewOPs.CreateBookTree(tw_Book);
            }

            if (tc_Info.SelectedTab == tabPage_Film)
            {
                if (ofd_LoadXmlFile.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        FileOPs.SaveXmlFile(FileOPs.ParseFilmXmlToList(filmFileName), filmFileName);
                    }
                    catch (SecurityException ex)
                    {
                        // The user lacks appropriate permissions to read files, discover paths, etc.
                        MessageBox.Show("Security error. Please contact your administrator for details.\n\n" +
                                        "Error message: " + ex.Message + "\n\n" +
                                        "Details (send to Support):\n\n" + ex.StackTrace
                                        );
                    }
                    catch (Exception ex)
                    {
                        // Could not load the image - probably related to Windows file system permissions.
                        MessageBox.Show("Cannot open file: " + ofd_LoadXmlFile.FileName.Substring(ofd_LoadXmlFile.FileName.LastIndexOf('\\'))
                                        + ". You may not have permission to read the file, or " +
                                        "it may be corrupt.\n\nReported error: " + ex.Message);
                    }
                }

                TreeViewOPs.CreateBookTree(tw_Film);
            }
        }