コード例 #1
0
ファイル: MoreInfoForm.cs プロジェクト: Globys031/TMJ_TP
        private void btnSaveChanges_Click(object sender, EventArgs e)
        {
            string ErrorMsg;

            if (!changed)
            {
                lblAnyText.Text = "Can't save, nothing has changed.";
                return;
            }
            var errors = ValidateFields();

            if (errors != "")
            {
                ErrorMsg        = "Can't save, errors: " + errors;
                lblAnyText.Text = ErrorMsg;
                return;
            }

            entry.SetImage(openFileDialog1.FileName);

            DatabaseClass.UpdateEntries(category, entry.name, txtEntryName.Text, Int32.Parse(drpdRating.SelectedItem.ToString()), txtEntryDescription.Text,
                                        dateRelease.Value.ToShortDateString(), Int32.Parse(txtWatchCount.Text), entry.image);

            this.Close();
            this.Dispose();
        }
コード例 #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string name        = txtEntryName.Text;
            string rating      = drpdRating.SelectedItem.ToString();
            string description = txtEntryDescription.Text;
            string dateTime    = dateRelease.Value.Date.ToShortDateString();

            var    errors = ValidateFields(name);
            string ErrorMsg;

            if (errors != "")
            {
                ErrorMsg        = "Can't save, errors: " + errors;
                lblAnyText.Text = ErrorMsg;
                return;
            }

            var ent = new Entry(name, openFileDialog1.FileName, Int32.Parse(rating), description, dateTime, 0);

            entryComponents.Add(new EntryComponent(entryComponents.Count + 1, ent, category));

            DatabaseClass.SetData(category, name, Int32.Parse(rating), description, dateTime, ent.image);
            parent.DataPanel.Controls.Add(entryComponents[entryComponents.Count - 1].mainPanel);

            this.Close();
            this.Dispose();
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: Globys031/TMJ_TP
 /// <summary>
 /// Redraws category buttons in the correct order
 /// We need to call this to display the category buttons correctly, because if you just add it
 /// it will go to the front of the panel
 /// </summary>
 public void RedrawCats()
 {
     panel1.Controls.Clear();
     Categories = new List <string>();
     Categories = DatabaseClass.GetCategoriesList();
     if (Categories.Count == 3)
     {
         for (int i = 0; i < Buttons.Count - 1; i++)
         {
             if (i == 3)
             {
                 Buttons.RemoveAt(i);
                 i--;
             }
         }
         panel1.Controls.Add(Buttons[Buttons.Count - 1]);
         for (int i = 3 - 1; i >= 0; i--)
         {
             panel1.Controls.Add(Buttons[i]);
         }
     }
     else
     {
         for (int i = Buttons.Count - 1; i >= 0; i--)
         {
             panel1.Controls.Add(Buttons[i]);
         }
     }
 }
コード例 #4
0
ファイル: Form1.cs プロジェクト: Globys031/TMJ_TP
        private void Form1_Load(object sender, EventArgs e)
        {
            Region = new Region(new Rectangle(0, 0, Width, Height));

            //Fill list with categories
            Categories = new List <string>();
            foreach (string cat in DatabaseClass.GetCategoriesList())
            {
                Categories.Add(cat);
            }

            Buttons = new List <Button>();
            Buttons.Add(button1);
            Buttons.Add(button3);
            Buttons.Add(b_TvSeries);
            Buttons.Add(b_addCat);

            bool added = false;

            for (int i = 3; i < Categories.Count; i++)
            {
                added = true;
                CreateAndAddCatBut(Categories[i], false);
            }
            if (added)
            {
                RedrawCats();
            }
        }
コード例 #5
0
ファイル: AddCatForm.cs プロジェクト: Globys031/TMJ_TP
        private void btnSave_Click(object sender, EventArgs e)
        {
            // first do validation
            if (Categories.Contains(txtCatName.Text))
            {
                //set error
                return;
            }
            //      too long?

            //set new category
            DatabaseClass.SetCategory(txtCatName.Text);

            //create and cache new button
            Categories.Add(txtCatName.Text);
            //quick solution to notify that a new category has been added
            //add a string of 50 chars, definitely longer than anything the user can add
            //and when we close this form we invoke FormClosed event and check if the last value length is 50
            //this way I don't have to track any additional variables that keep the last length of the array
            //and will be a tiny bit faster and simpler to implement
            Categories.Add("00000000000000000000000000000000000000000000000000");

            //close this form and open new one
            this.Close();
        }
コード例 #6
0
ファイル: ChildForm.cs プロジェクト: Globys031/TMJ_TP
        private void btnSearch_Click(object sender, EventArgs e)
        {
            DataPanel.Controls.Clear();
            InitAddButton(DataPanel);
            entryComponents.Clear();

            string search = textBox1.Text;

            if (search == "")
            {
                return;     //should later add some message
            }
            switch (search) //super secret dev commands hehe
            {
            case "!wipecats":
                var cats = DatabaseClass.GetCategoriesList();
                for (int j = 3; j < cats.Count; j++)
                {
                    var entries = DatabaseClass.GetDataByCategory(cats[j], "");
                    if (entries != null)
                    {
                        foreach (Entry entry in entries)
                        {
                            DatabaseClass.RemoveEntry(category, entry.name);
                        }
                    }
                    DatabaseClass.RemoveCategory(cats[j]);
                }
                var pp = Parent.Parent as Form1;
                pp.RedrawCats();
                break;

            case "!wipeentries":
                var entriess = DatabaseClass.GetDataByCategory(category, "");
                foreach (Entry entry in entriess)
                {
                    DatabaseClass.RemoveEntry(category, entry.name);
                }
                break;

            case "!wipeall":
                DatabaseClass.RemoveAllEntries();
                DatabaseClass.RemoveNonMandatoryCategories();
                var ppp = Parent.Parent as Form1;
                ppp.RedrawCats();
                break;
            }
            var list = DatabaseClass.GetCategoryEntry(DatabaseClass.FindCategoryId(category), search);

            int i = 0;

            foreach (Entry ent in list)
            {
                EntryComponent entr = new EntryComponent(i, ent, category);
                DataPanel.Controls.Add(entr.mainPanel);
                entryComponents.Add(entr);
            }
        }
コード例 #7
0
ファイル: MoreInfoForm.cs プロジェクト: Globys031/TMJ_TP
 private void btnDeleteEntry_Click(object sender, EventArgs e)
 {
     if (delete)
     {
         DatabaseClass.RemoveEntry(category, entry.name);
         this.Close();
     }
     else
     {
         lblAnyText.Text = "Are you sure you want to delete this entry? It will be lost forever. To confirm click that button again.";
         delete          = true;
     }
 }
コード例 #8
0
ファイル: ChildForm.cs プロジェクト: Globys031/TMJ_TP
        private void btnSortScore_Click(object sender, EventArgs e)
        {
            DataPanel.Controls.Clear();
            InitAddButton(DataPanel);
            entryComponents.Clear();

            var list = DatabaseClass.SortEntries(category, 4, true);//sort by score descending

            int i = 0;

            foreach (Entry ent in list)
            {
                EntryComponent entr = new EntryComponent(i, ent, category);
                DataPanel.Controls.Add(entr.mainPanel);
                entryComponents.Add(entr);
            }
        }
コード例 #9
0
ファイル: ChildForm.cs プロジェクト: Globys031/TMJ_TP
 private void ChildForm_Leave(object sender, EventArgs e)
 {
     if (type == ChildFormType.Category)
     {
         foreach (EntryComponent entry in entryComponents)
         {
             Entry cons = entry.entry;
             DatabaseClass.UpdateEntries(category,
                                         cons.name, cons.name, cons.score, cons.description,
                                         cons.date, cons.watchCount, cons.image);
             entry.DestroyComponent();
         }
         btnAddEntry.Image.Dispose();
         btnSearch.BackgroundImage.Dispose();
         this.Dispose(true);
         this.Close();
     }
 }
コード例 #10
0
ファイル: ChildForm.cs プロジェクト: Globys031/TMJ_TP
        public void ChildForm_Shown(object sender, EventArgs e)
        {
            if (Controls.Count == 0)       //when this is called if an entry is deleted the controls should be empty
            {
                InitializeComponent(size); //need to init because it also has that big plus button
            }
            entryComponents = new List <EntryComponent>();

            var entries = DatabaseClass.GetDataByCategory(category, "");

            int i = 0;

            foreach (Entry ent in entries)
            {
                EntryComponent entr = new EntryComponent(i, ent, category);
                DataPanel.Controls.Add(entr.mainPanel);
                entryComponents.Add(entr);
            }
        }