コード例 #1
0
ファイル: TreeViewOPs.cs プロジェクト: VaHaBBeaT/Catalog
        public static void CreateFilmTree(TreeView tree)
        {
            XDocument xDoc = FileOPs.LoadXmlFile(form_Catalog.filmFileName);

            tree.Nodes.Clear();
            tree.Nodes.Add(new TreeNode(xDoc.Root.Name.ToString()));

            List <Film> parse           = FileOPs.ParseFilmXmlToList(form_Catalog.filmFileName);
            List <Film> noDupesProducer = parse.GroupBy(a => a.filmProducer).Select(grp => grp.FirstOrDefault()).OrderBy(a => a.filmProducer).ToList();

            foreach (Film nDP in noDupesProducer)
            {
                tree.Nodes[0].Nodes.Add(nDP.filmProducer);
                List <Film> filmTitle = parse.FindAll(x => x.filmProducer.Equals(nDP.filmProducer)).OrderBy(s => s.filmTitle).ToList();

                foreach (var ft in filmTitle)
                {
                    tree.Nodes[0].Nodes[noDupesProducer.IndexOf(nDP)].Nodes.Add(ft.filmTitle);
                }
            }

            tree.ExpandAll();

            FileOPs.SetFilmLastID();
        }
コード例 #2
0
ファイル: TreeViewOPs.cs プロジェクト: VaHaBBeaT/Catalog
        public static void CreateBookTree(TreeView tree)
        {
            XDocument xDoc = FileOPs.LoadXmlFile(form_Catalog.bookFileName);

            tree.Nodes.Clear();
            tree.Nodes.Add(new TreeNode(xDoc.Root.Name.ToString()));

            List <Book> parse         = FileOPs.ParseBookXmlToList(form_Catalog.bookFileName);
            List <Book> noDupesAuthor = parse.GroupBy(a => a.bookAuthor).Select(grp => grp.FirstOrDefault()).OrderBy(a => a.bookAuthor).ToList();

            foreach (Book nDA in noDupesAuthor)
            {
                tree.Nodes[0].Nodes.Add(nDA.bookAuthor);
                List <Book> bookSeries = parse.FindAll(x => x.bookAuthor.Equals(nDA.bookAuthor)).GroupBy(s => s.bookSeries).Select(grp => grp.FirstOrDefault()).OrderBy(s => s.bookSeries).ToList();

                foreach (var bs in bookSeries)
                {
                    tree.Nodes[0].Nodes[noDupesAuthor.IndexOf(nDA)].Nodes.Add(bs.bookSeries);
                    List <Book> bookTitle = parse.FindAll(x => x.bookAuthor.Equals(nDA.bookAuthor) && x.bookSeries.Equals(bs.bookSeries));

                    foreach (var bn in bookTitle)
                    {
                        tree.Nodes[0].Nodes[noDupesAuthor.IndexOf(nDA)].Nodes[bookSeries.IndexOf(bs)].Nodes.Add(bn.bookTitle);
                    }
                }
            }

            tree.ExpandAll();

            FileOPs.SetBookLastID();
        }
コード例 #3
0
ファイル: form_EditFilm.cs プロジェクト: VaHaBBeaT/Catalog
        private void btn_SaveBook_Click(object sender, EventArgs e)
        {
            List <Film> parse = FileOPs.ParseFilmXmlToList(form_Catalog.filmFileName);

            List <string> filePath = new List <string>();

            int count = 1;

            foreach (string file in fileNames)
            {
                try
                {
                    Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + @"Pics\Films" + txtbox_Producer.Text + @"\" + txtbox_Title.Text);
                    string extension    = Path.GetExtension(file);
                    string path         = string.Format(@".\Pics\Films\" + txtbox_Producer.Text + @"\" + txtbox_Title.Text + @"\");
                    string tempFileName = string.Format("{0}-{1}", txtbox_Title.Text, count++);

                    string fullPath = Path.Combine(path, tempFileName + extension);

                    FileInfo newFile = new FileInfo(file).CopyTo(fullPath, true);
                    filePath.Add(fullPath);
                }
                catch (Exception ex) { MessageBox.Show(ex.Message); }
            }

            Film filmToEdit = new Film(int.Parse(txtbox_ID.Text), txtbox_Title.Text, txtbox_Genre.Text,
                                       txtbox_Producer.Text, txtbox_Actors.Text, int.Parse(txtbox_Length.Text),
                                       txtbox_Country.Text, DateTime.Parse(txtbox_Premiere.Text), cmbbox_MPAA.Text,
                                       txtbox_CriticsRating.Text, int.Parse(txtbox_Grosses.Text),
                                       txtbox_Notes.Text, filePath);

            try
            {
                FileOPs.EditXmlFile(filmToEdit, form_Catalog.filmFileName);

                txtbox_ID.Clear();
                txtbox_Title.Clear();
                txtbox_Genre.Clear();
                txtbox_Producer.Clear();
                txtbox_Actors.Clear();
                txtbox_Length.Clear();
                txtbox_Country.Clear();
                txtbox_Premiere.Clear();
                cmbbox_MPAA.SelectedIndex = -1;
                txtbox_CriticsRating.Clear();
                txtbox_Grosses.Clear();
                txtbox_Notes.Clear();

                flp_FileSelector.Controls.Clear();

                tssl_StatusFilmEdit.Text = "Success!";

                Close();
            }
            catch (FileNotFoundException ex)
            {
                MessageBox.Show(ex.Message);
                tssl_StatusFilmEdit.Text = "Error!";
            }
        }
コード例 #4
0
ファイル: form_Catalog.cs プロジェクト: VaHaBBeaT/Catalog
 public form_Catalog()
 {
     Thread.CurrentThread.CurrentUICulture = new CultureInfo("ru-RU");
     FileOPs.SetFileName();
     InitializeComponent();
     tc_Info.SelectedIndexChanged += new EventHandler(tc_Info_Selected);
     watch();
 }
コード例 #5
0
ファイル: form_Catalog.cs プロジェクト: VaHaBBeaT/Catalog
        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();
                }
            }
        }
コード例 #6
0
ファイル: form_Catalog.cs プロジェクト: VaHaBBeaT/Catalog
        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("Необходимо выбрать 'Фильм'");
                }
            }
        }
コード例 #7
0
ファイル: TreeViewOPs.cs プロジェクト: VaHaBBeaT/Catalog
        public static void LoadFilmNextImage(TreeNode node, ref PictureBox picBox)
        {
            List <Film> parse = FileOPs.ParseFilmXmlToList(form_Catalog.filmFileName);

            var item = parse.Find(a => a.filmTitle.Equals(node.Text));

            if (form_Catalog.imageNumber == item.picturesPath.Count)
            {
                form_Catalog.imageNumber = 0;
            }

            picBox.ImageLocation = item.picturesPath[form_Catalog.imageNumber].ToString();
            form_Catalog.imageNumber++;
        }
コード例 #8
0
ファイル: form_Catalog.cs プロジェクト: VaHaBBeaT/Catalog
        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);
            }
        }
コード例 #9
0
ファイル: form_Catalog.cs プロジェクト: VaHaBBeaT/Catalog
        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();
                }
            }
        }
コード例 #10
0
ファイル: form_Catalog.cs プロジェクト: VaHaBBeaT/Catalog
        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();
        }
コード例 #11
0
ファイル: form_Catalog.cs プロジェクト: VaHaBBeaT/Catalog
        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()); }
                }
            }
        }
コード例 #12
0
ファイル: TreeViewOPs.cs プロジェクト: VaHaBBeaT/Catalog
        public static void CopyFilmTreeNode(TreeView tree)
        {
            if ((tree.SelectedNode != null) && (GetDeepestChildNodeLevel(tree.SelectedNode) == 1))
            {
                try
                {
                    List <Book> parse     = FileOPs.ParseBookXmlToList(form_Catalog.bookFileName);
                    Book        cloneBook = parse.Find(b => b.bookTitle == tree.SelectedNode.Text && b.bookSeries == tree.SelectedNode.Parent.Text && b.bookAuthor == tree.SelectedNode.Parent.Parent.Text);

                    //MessageBox.Show(string.Format("Cloning book:\nAuthor: {0}\nSeries: {1}\nBook: {2}", cloneBook.bookAuthor, cloneBook.bookSeries, cloneBook.bookTitle));

                    form_CreateBook form = new form_CreateBook();
                    form.txtbox_ID.Text             = form_Catalog.lastbookID++.ToString();
                    form.txtbox_MajorSeries.Text    = cloneBook.bookMajorSeries;
                    form.txtbox_Author.Text         = cloneBook.bookAuthor;
                    form.txtbox_Title.Text          = cloneBook.bookTitle;
                    form.txtbox_Series.Text         = cloneBook.bookSeries;
                    form.txtbox_NumberInSeries.Text = cloneBook.bookNumberInSeries.ToString();
                    form.txtbox_Genre.Text          = cloneBook.bookGenre;
                    form.txtbox_PagesCount.Text     = cloneBook.bookPagesCount.ToString();
                    form.txtbox_Publisher.Text      = cloneBook.bookPublisher;
                    form.txtbox_PrintYear.Text      = cloneBook.bookPrintYear.ToString();
                    form.txtbox_PrintCity.Text      = cloneBook.bookPrintCity;
                    form.txtbox_ISBN.Text           = cloneBook.bookISBN.ToString();
                    form.txtbox_Translator.Text     = cloneBook.bookTranslator;
                    form.txtbox_Artist.Text         = cloneBook.bookArtist;
                    form.txtbox_Notes.Text          = cloneBook.bookNotes;

                    form_Catalog.imageNumber = 0;

                    tree.SelectedNode = new TreeNode(cloneBook.bookTitle);

                    form.Show();
                }
                catch (Exception ex) { MessageBox.Show(ex.ToString()); }
            }
            else
            {
                MessageBox.Show("Select 'Film' node");
            }
        }
コード例 #13
0
        private void btn_SaveBook_Click(object sender, EventArgs e)
        {
            List <Book> parse = FileOPs.ParseBookXmlToList(form_Catalog.bookFileName);

            List <string> filePath = new List <string>();

            int count = 1;

            foreach (string file in fileNames)
            {
                try
                {
                    Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + @"Pics\Books" + txtbox_Author.Text + @"\" + txtbox_Title.Text);
                    string extension    = Path.GetExtension(file);
                    string path         = string.Format(@".\Pics\Books\" + txtbox_Author.Text + @"\" + txtbox_Title.Text + @"\");
                    string tempFileName = string.Format("{0}-{1}", txtbox_Title.Text, count++);

                    string fullPath = Path.Combine(path, tempFileName + extension);

                    FileInfo newFile = new FileInfo(file).CopyTo(fullPath, true);
                    filePath.Add(fullPath);
                }
                catch (Exception ex) { MessageBox.Show(ex.Message); }
            }

            Book bookToEdit = new Book(int.Parse(txtbox_ID.Text), txtbox_MajorSeries.Text, txtbox_Author.Text,
                                       txtbox_Title.Text, txtbox_Series.Text, int.Parse(txtbox_NumberInSeries.Text),
                                       txtbox_Genre.Text, int.Parse(txtbox_PagesCount.Text), txtbox_Publisher.Text,
                                       int.Parse(txtbox_PrintYear.Text), txtbox_PrintCity.Text,
                                       long.Parse(txtbox_ISBN.Text), txtbox_Translator.Text, txtbox_Artist.Text,
                                       txtbox_Notes.Text, filePath);

            try
            {
                FileOPs.EditXmlFile(bookToEdit, form_Catalog.bookFileName);

                txtbox_ID.Clear();
                txtbox_MajorSeries.Clear();
                txtbox_Author.Clear();
                txtbox_Title.Clear();
                txtbox_Series.Clear();
                txtbox_NumberInSeries.Clear();
                txtbox_Genre.Clear();
                txtbox_PagesCount.Clear();
                txtbox_Publisher.Clear();
                txtbox_PrintYear.Clear();
                txtbox_PrintCity.Clear();
                txtbox_ISBN.Clear();
                txtbox_Translator.Clear();
                txtbox_Artist.Clear();
                txtbox_Notes.Clear();

                flp_FileSelector.Controls.Clear();

                tssl_StatusBookEdit.Text = "Success!";

                Close();
            }
            catch (FileNotFoundException ex)
            {
                MessageBox.Show(ex.Message);
                tssl_StatusBookEdit.Text = "Error!";
            }
        }
コード例 #14
0
ファイル: form_Catalog.cs プロジェクト: VaHaBBeaT/Catalog
        private void print_Doc_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            if (tc_Info.SelectedTab == tabPage_Book)
            {
                List <Book> parse = FileOPs.ParseBookXmlToList(bookFileName);
                Image       image = Image.FromFile(parse.Find(b => b.bookAuthor == tw_Book.SelectedNode.Parent.Parent.Text && b.bookTitle == tw_Book.SelectedNode.Text).picturesPath[0]);

                PrivateFontCollection fontColl = new PrivateFontCollection();
                fontColl.AddFontFile(AppDomain.CurrentDomain.BaseDirectory + @"\Fonts\Header.TTF");
                fontColl.AddFontFile(AppDomain.CurrentDomain.BaseDirectory + @"\Fonts\Text.TTF");
                Font myHeaderFont = new Font(fontColl.Families[0], 36f);
                Font myTextFont   = new Font(fontColl.Families[1], 16f);

                StringFormat stringFormat = new StringFormat();
                stringFormat.Alignment     = StringAlignment.Center;
                stringFormat.LineAlignment = StringAlignment.Center;

                e.Graphics.PageUnit = GraphicsUnit.Millimeter;

                e.Graphics.DrawString(txtbox_BookAuthor.Text, myHeaderFont, Brushes.Black, new Rectangle(0, 10, 205, 15), stringFormat);
                e.Graphics.DrawString(txtbox_BookTitle.Text, myHeaderFont, Brushes.Black, new Rectangle(0, 25, 205, 15), stringFormat);

                e.Graphics.DrawImage(image, 20, 40, 70, 100);

                e.Graphics.DrawString("Серия: " + txtbox_BookSeries.Text + " - " + txtbox_BookNumberInSeries.Text, myTextFont, Brushes.Black, 100, 50);
                e.Graphics.DrawString("Жанр: " + txtbox_BookGenre.Text, myTextFont, Brushes.Black, 100, 60);
                e.Graphics.DrawString("Кол-во страниц: " + txtbox_BookPagesCount.Text, myTextFont, Brushes.Black, 100, 70);
                e.Graphics.DrawString("Издание: " + txtbox_BookPublisher.Text + ", " + txtbox_BookPrintCity.Text + ", " + txtbox_BookPrintYear.Text, myTextFont, Brushes.Black, 100, 80);
                e.Graphics.DrawString("ISBN: " + msktxtbox_BookISBN.Text, myTextFont, Brushes.Black, 100, 90);
                e.Graphics.DrawString("Переводчик: " + txtbox_BookTranslator.Text, myTextFont, Brushes.Black, 100, 100);
                e.Graphics.DrawString("Художник: " + txtbox_BookArtist.Text, myTextFont, Brushes.Black, 100, 110);
                e.Graphics.DrawString("Заметки: " + txtbox_BookNotes.Text, myTextFont, Brushes.Black, 100, 120);
            }

            if (tc_Info.SelectedTab == tabPage_Film)
            {
                List <Film> parse = FileOPs.ParseFilmXmlToList(filmFileName);
                Image       image = Image.FromFile(parse.Find(f => f.filmProducer == tw_Film.SelectedNode.Parent.Text && f.filmTitle == tw_Film.SelectedNode.Text).picturesPath[0]);

                PrivateFontCollection fontColl = new PrivateFontCollection();
                fontColl.AddFontFile(AppDomain.CurrentDomain.BaseDirectory + @"\Fonts\Header.TTF");
                fontColl.AddFontFile(AppDomain.CurrentDomain.BaseDirectory + @"\Fonts\Text.TTF");
                Font myHeaderFont = new Font(fontColl.Families[0], 36f);
                Font myTextFont   = new Font(fontColl.Families[1], 16f);

                StringFormat stringFormat = new StringFormat();
                stringFormat.Alignment     = StringAlignment.Center;
                stringFormat.LineAlignment = StringAlignment.Center;

                e.Graphics.PageUnit = GraphicsUnit.Millimeter;

                e.Graphics.DrawString(txtbox_FilmProducer.Text, myHeaderFont, Brushes.Black, new Rectangle(0, 10, 205, 15), stringFormat);
                e.Graphics.DrawString(txtbox_FilmTitle.Text, myHeaderFont, Brushes.Black, new Rectangle(0, 25, 205, 15), stringFormat);

                e.Graphics.DrawImage(image, 20, 40, 70, 100);

                e.Graphics.DrawString("Жанр: " + txtbox_FilmGenre.Text, myTextFont, Brushes.Black, 100, 50);
                e.Graphics.DrawString("Актеры: " + txtbox_FilmActors.Text, myTextFont, Brushes.Black, 100, 60);
                e.Graphics.DrawString("Продолжительность: " + txtbox_FilmLength.Text + ", " + txtbox_BookPrintCity.Text + ", " + txtbox_BookPrintYear.Text, myTextFont, Brushes.Black, 100, 70);
                e.Graphics.DrawString("Страна: " + txtbox_FilmCountry.Text, myTextFont, Brushes.Black, 100, 80);
                e.Graphics.DrawString("Премьера: " + txtbox_FilmPremiere.Text, myTextFont, Brushes.Black, 100, 90);
                e.Graphics.DrawString("Рейтинг MPAA: " + txtbox_FilmMPAA.Text, myTextFont, Brushes.Black, 100, 100);
                e.Graphics.DrawString("Рейтинг критиков: " + txtbox_FilmCriticsRating.Text, myTextFont, Brushes.Black, 100, 110);
                e.Graphics.DrawString("Сборы ($): " + txtbox_FilmGrosses.Text, myTextFont, Brushes.Black, 100, 120);
                e.Graphics.DrawString("Заметки: " + txtbox_FilmNotes.Text, myTextFont, Brushes.Black, 100, 130);
            }
        }
コード例 #15
0
ファイル: form_Catalog.cs プロジェクト: VaHaBBeaT/Catalog
        private void SaveAsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            sfd_SaveXmlFile.InitialDirectory             = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Data");
            sfd_SaveXmlFile.CreatePrompt                 = true;
            sfd_SaveXmlFile.OverwritePrompt              = true;
            sfd_SaveXmlFile.RestoreDirectory             = true;
            sfd_SaveXmlFile.Filter                       = "XML (*.Xml)|*.Xml|" + "All files (*.*)|*.*";
            sfd_SaveXmlFile.SupportMultiDottedExtensions = true;
            sfd_SaveXmlFile.Title = "My Data file Browser";

            //TBD refactor
            if (tc_Info.SelectedTab == tabPage_Book)
            {
                List <Book> parse = FileOPs.ParseBookXmlToList(bookFileName);

                if (sfd_SaveXmlFile.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        bookFileName = sfd_SaveXmlFile.FileName;
                        FileOPs.SaveXmlFile(parse, 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: " + sfd_SaveXmlFile.FileName.Substring(sfd_SaveXmlFile.FileName.LastIndexOf('\\'))
                                        + ". You may not have permission to read the file, or " +
                                        "it may be corrupt.\n\nReported error: " + ex.Message);
                    }
                }
            }

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

                if (sfd_SaveXmlFile.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        filmFileName = sfd_SaveXmlFile.FileName;
                        FileOPs.SaveXmlFile(parse, 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: " + sfd_SaveXmlFile.FileName.Substring(sfd_SaveXmlFile.FileName.LastIndexOf('\\'))
                                        + ". You may not have permission to read the file, or " +
                                        "it may be corrupt.\n\nReported error: " + ex.Message);
                    }
                }
            }
        }
コード例 #16
0
ファイル: form_CreateFilm.cs プロジェクト: VaHaBBeaT/Catalog
        private void btn_SaveBook_Click(object sender, EventArgs e)
        {
            List <Film> parse = FileOPs.ParseFilmXmlToList(form_Catalog.filmFileName);

            Film film = parse.Find(f => f.filmProducer == txtbox_Producer.Text && f.filmTitle == txtbox_Title.Text);

            if (film == null)
            {
                List <string> filePath = new List <string>();

                int count = 1;

                foreach (string file in fileNames)
                {
                    try
                    {
                        Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + @"Pics\Films" + txtbox_Producer.Text + @"\" + txtbox_Title.Text);
                        string extension    = Path.GetExtension(file);
                        string path         = string.Format(@".\Pics\Films\" + txtbox_Producer.Text + @"\" + txtbox_Title.Text + @"\");
                        string tempFileName = string.Format("{0}-{1}", txtbox_Title.Text, count++);

                        string fullPath = Path.Combine(path, tempFileName + extension);
                        File.Copy(file, fullPath);
                        filePath.Add(fullPath);
                    }
                    catch (Exception ex) { MessageBox.Show(ex.Message); }
                }

                Film filmAppend = new Film(int.Parse(txtbox_ID.Text), txtbox_Title.Text, txtbox_Genre.Text,
                                           txtbox_Producer.Text, txtbox_Actors.Text, int.Parse(txtbox_Length.Text),
                                           txtbox_Country.Text, DateTime.Parse(txtbox_Premiere.Text), cmbbox_MPAA.Text,
                                           txtbox_CriticsRating.Text, int.Parse(txtbox_Grosses.Text),
                                           txtbox_Notes.Text, filePath);

                try
                {
                    FileOPs.AppendToXmlFile(filmAppend, form_Catalog.filmFileName);

                    txtbox_ID.Clear();
                    txtbox_Title.Clear();
                    txtbox_Genre.Clear();
                    txtbox_Producer.Clear();
                    txtbox_Actors.Clear();
                    txtbox_Length.Clear();
                    txtbox_Country.Clear();
                    txtbox_Premiere.Clear();
                    cmbbox_MPAA.SelectedIndex = -1;
                    txtbox_CriticsRating.Clear();
                    txtbox_Grosses.Clear();
                    txtbox_Notes.Clear();

                    flp_FileSelector.Controls.Clear();

                    tssl_StatusFilmCreate.Text = "Success!";

                    form_Catalog.lastfilmID++;
                    txtbox_ID.Text = form_Catalog.lastfilmID.ToString();
                }

                catch (FileNotFoundException ex)
                {
                    MessageBox.Show(ex.Message);
                    tssl_StatusFilmCreate.Text = "Error!";
                }
            }
            else
            {
                MessageBox.Show(string.Format("Producers {0} film '{1}' already exist, please edit filminfo", txtbox_Producer.Text, txtbox_Title.Text));
            }
        }
コード例 #17
0
ファイル: form_ViewXML.cs プロジェクト: VaHaBBeaT/Catalog
 private void form_ViewXML_Load(object sender, EventArgs e, string file)
 {
     rtbXMLInfo.Text = FileOPs.LoadXmlFile(file).ToString();
 }
コード例 #18
0
        private void btn_SaveBook_Click(object sender, EventArgs e)
        {
            List <Book> parse = FileOPs.ParseBookXmlToList(form_Catalog.bookFileName);

            Book book = parse.Find(b => b.bookAuthor == txtbox_Author.Text && b.bookTitle == txtbox_Title.Text);

            if (book == null)
            {
                List <string> filePath = new List <string>();

                int count = 1;

                foreach (string file in fileNames)
                {
                    try
                    {
                        Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + @"Pics\Books" + txtbox_Author.Text + @"\" + txtbox_Title.Text);
                        string extension    = Path.GetExtension(file);
                        string path         = string.Format(@".\Pics\Books\" + txtbox_Author.Text + @"\" + txtbox_Title.Text + @"\");
                        string tempFileName = string.Format("{0}-{1}", txtbox_Title.Text, count++);

                        string fullPath = Path.Combine(path, tempFileName + extension);
                        File.Copy(file, fullPath);
                        filePath.Add(fullPath);
                    }
                    catch (Exception ex) { MessageBox.Show(ex.Message); }
                }

                Book bookAppend = new Book(int.Parse(txtbox_ID.Text), txtbox_MajorSeries.Text, txtbox_Author.Text,
                                           txtbox_Title.Text, txtbox_Series.Text, int.Parse(txtbox_NumberInSeries.Text),
                                           txtbox_Genre.Text, int.Parse(txtbox_PagesCount.Text), txtbox_Publisher.Text,
                                           int.Parse(txtbox_PrintYear.Text), txtbox_PrintCity.Text,
                                           long.Parse(txtbox_ISBN.Text), txtbox_Translator.Text, txtbox_Artist.Text,
                                           txtbox_Notes.Text, filePath);

                try
                {
                    FileOPs.AppendToXmlFile(bookAppend, form_Catalog.bookFileName);

                    txtbox_ID.Clear();
                    txtbox_MajorSeries.Clear();
                    txtbox_Author.Clear();
                    txtbox_Title.Clear();
                    txtbox_Series.Clear();
                    txtbox_NumberInSeries.Clear();
                    txtbox_Genre.Clear();
                    txtbox_PagesCount.Clear();
                    txtbox_Publisher.Clear();
                    txtbox_PrintYear.Clear();
                    txtbox_PrintCity.Clear();
                    txtbox_ISBN.Clear();
                    txtbox_Translator.Clear();
                    txtbox_Artist.Clear();
                    txtbox_Notes.Clear();

                    flp_FileSelector.Controls.Clear();

                    tssl_StatusBookCreate.Text = "Success!";

                    form_Catalog.lastbookID++;
                    txtbox_ID.Text = form_Catalog.lastbookID.ToString();
                }

                catch (FileNotFoundException ex)
                {
                    MessageBox.Show(ex.Message);
                    tssl_StatusBookCreate.Text = "Error!";
                }
            }
            else
            {
                MessageBox.Show(string.Format("Authors {0} book '{1}' already exist, please edit bookinfo", txtbox_Author.Text, txtbox_Title.Text));
            }
        }