示例#1
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("Необходимо выбрать 'Фильм'");
                }
            }
        }
示例#2
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);
     }
 }
示例#3
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);
            }
        }
示例#4
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();
        }
示例#5
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()); }
                }
            }
        }
示例#6
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);
            }
        }