コード例 #1
0
        private void bEdit_Click(object sender, EventArgs e)
        {
            Functions.getInstance().CancelEdit = true;

            if (Functions.getInstance().FilmCount() == 0)
            {
                MessageBox.Show("No films to edit!");
                return;
            }
            Functions.getInstance().EditChange = true;
            fAddEdit edit = new fAddEdit();

            edit.Text = "Edit";

            edit.ShowDialog();
            edit.Dispose();
            Functions.getInstance().EditChange = false;

            if (Functions.getInstance().CancelEdit)
            {
                dGTable.Rows.Clear();

                for (int i = 0; i < Functions.getInstance().FilmCount(); i++)
                {
                    dGTable.Rows.Add(Functions.getInstance().GetFilm(i).Title, Functions.getInstance().GetFilm(i).Runtime, Functions.getInstance().GetFilm(i).Viewed);
                }
            }
        }
コード例 #2
0
        private void dGTable_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1)
            {
                return;
            }

            lbDescription.Items.Clear();
            rTBdescription.Clear();
            pbPicture.Image = null;

            if (dGTable.CurrentRow != null)
            {
                int  index = Functions.getInstance().SelectedIndexForEdit = e.RowIndex;
                bool found = true;

                string ListName = Functions.getInstance().GetList()[index].Title;
                string DGName   = dGTable[0, index].Value.ToString();

                if (ListName != DGName)
                {
                    found = false;
                }

                while (true)
                {
                    if (found)
                    {
                        lbDescription.Items.Add($"Title: {Functions.getInstance().GetList()[index].Title}");
                        lbDescription.Items.Add($"Year: {Functions.getInstance().GetList()[index].Year}");
                        lbDescription.Items.Add($"Genre: {Functions.getInstance().GetList()[index].Genre}");
                        lbDescription.Items.Add($"Language: {Functions.getInstance().GetList()[index].Language}");
                        lbDescription.Items.Add($"Director(s): {Functions.getInstance().GetList()[index].Director}");

                        rTBdescription.Text = Functions.getInstance().GetList()[index].Description;

                        if (Functions.getInstance().GetList()[index].PicturePath != null && Functions.getInstance().GetList()[index].PicturePath != "")
                        {
                            pbPicture.Image = Image.FromFile(Functions.getInstance().GetList()[index].PicturePath);
                            pbPicture.Invalidate();
                        }

                        break;
                    }
                    else
                    {
                        for (int i = 0; i < Functions.getInstance().FilmCount(); i++)
                        {
                            if (DGName == Functions.getInstance().GetList()[i].Title)
                            {
                                index = i;
                                found = true;
                                break;
                            }
                        }
                    }
                }
            }
        }
コード例 #3
0
ファイル: fAddEdit.cs プロジェクト: Maxai2/FilmsWork
        private void bCancel_Click(object sender, EventArgs e)
        {
            Functions.getInstance().CancelAdd = false;

            if (Functions.getInstance().EditChange)
            {
                Functions.getInstance().CancelEdit = false;
            }
        }
コード例 #4
0
 private void dGTable_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Delete)
     {
         Functions.getInstance().GetList().Remove(Functions.getInstance().GetList()[Functions.getInstance().SelectedIndexForEdit]);
         lbDescription.Items.Clear();
         rTBdescription.Clear();
         pbPicture.Image = null;
         pbPicture.Invalidate();
     }
 }
コード例 #5
0
        private void FilmsView_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (Functions.getInstance().FilmCount() == 0)
            {
                File.Delete("Films.dat");
                return;
            }
            if (listBeginnerCount != Functions.getInstance().FilmCount())
            {
                using (var fStream = new FileStream("Films.dat", FileMode.OpenOrCreate))
                {
                    BinaryFormatter formatter = new BinaryFormatter();

                    formatter.Serialize(fStream, Functions.getInstance().GetList());
                }
            }
        }
コード例 #6
0
        private void bAdd_Click(object sender, EventArgs e)
        {
            Functions.getInstance().CancelAdd = true;

            fAddEdit add = new fAddEdit();

            add.ShowDialog();

            add.Dispose();

            if (Functions.getInstance().CancelAdd)
            {
                dGTable.Invalidate();
                int lastIndex = Functions.getInstance().FilmCount() - 1;

                dGTable.Rows.Add(Functions.getInstance().GetFilm(lastIndex).Title, Functions.getInstance().GetFilm(lastIndex).Runtime, Functions.getInstance().GetFilm(lastIndex).Viewed);

                dGTable.Refresh();
            }
        }
コード例 #7
0
ファイル: fAddEdit.cs プロジェクト: Maxai2/FilmsWork
        public fAddEdit()
        {
            InitializeComponent();

            if (Functions.getInstance().EditChange)
            {
                tBTitle.Text        = Functions.getInstance().GetList()[Functions.getInstance().SelectedIndexForEdit].Title;
                mtBYear.Text        = Functions.getInstance().GetList()[Functions.getInstance().SelectedIndexForEdit].Year.ToString();
                mtBRuntime.Text     = Functions.getInstance().GetList()[Functions.getInstance().SelectedIndexForEdit].Runtime.ToString();
                cBGenre.Text        = Functions.getInstance().GetList()[Functions.getInstance().SelectedIndexForEdit].Genre;
                cBLanguage.Text     = Functions.getInstance().GetList()[Functions.getInstance().SelectedIndexForEdit].Language;
                tBDirector.Text     = Functions.getInstance().GetList()[Functions.getInstance().SelectedIndexForEdit].Director;
                rTBDescription.Text = Functions.getInstance().GetList()[Functions.getInstance().SelectedIndexForEdit].Description;
                cBViewed.Checked    = Functions.getInstance().GetList()[Functions.getInstance().SelectedIndexForEdit].Viewed;

                if (Functions.getInstance().GetList()[Functions.getInstance().SelectedIndexForEdit].PicturePath == " " || Functions.getInstance().GetList()[Functions.getInstance().SelectedIndexForEdit].PicturePath == null)
                {
                    tbPicPath.Text       = Functions.getInstance().GetList()[Functions.getInstance().SelectedIndexForEdit].PicturePath;
                    pbSearchResult.Image = Image.FromFile(tbPicPath.Text);
                }
            }
        }
コード例 #8
0
        public FilmsView()
        {
            InitializeComponent();

            if (!File.Exists("Films.dat"))
            {
                goto NOLOAD;
            }

            Functions.getInstance().LoadList();

            for (int i = 0; i < Functions.getInstance().FilmCount(); i++)
            {
                dGTable.Rows.Add(Functions.getInstance().GetFilm(i).Title, Functions.getInstance().GetFilm(i).Runtime, Functions.getInstance().GetFilm(i).Viewed);
            }

            //dGTable.Refresh();

NOLOAD:

            listBeginnerCount = Functions.getInstance().FilmCount();
        }
コード例 #9
0
ファイル: fAddEdit.cs プロジェクト: Maxai2/FilmsWork
        private void bOk_Click(object sender, EventArgs e)
        {
            if (Functions.getInstance().EditChange)
            {
                int index = Functions.getInstance().SelectedIndexForEdit;

                Functions.getInstance().GetList()[index].Description = rTBDescription.Text;
                Functions.getInstance().GetList()[index].Director    = tBDirector.Text;
                Functions.getInstance().GetList()[index].Genre       = cBGenre.Text;
                Functions.getInstance().GetList()[index].Language    = cBLanguage.Text;
                Functions.getInstance().GetList()[index].PicturePath = tbPicPath.Text;
                Functions.getInstance().GetList()[index].Runtime     = Convert.ToInt32(mtBRuntime.Text);
                Functions.getInstance().GetList()[index].Title       = tBTitle.Text;
                Functions.getInstance().GetList()[index].Viewed      = cBViewed.Checked;
                Functions.getInstance().GetList()[index].Year        = Convert.ToInt32(mtBYear.Text);
            }
            else
            {
                Film temp = new Film(tBTitle.Text, Convert.ToInt32(mtBYear.Text), Convert.ToInt32(mtBRuntime.Text), cBGenre.Text, cBLanguage.Text, tBDirector.Text, rTBDescription.Text, cBViewed.Checked, tbPicPath.Text);

                Functions.getInstance().AddFilm(temp);
            }
        }