Exemple #1
0
        private void EditContent()
        {
            try
            {
                if (currentSelection2 != null)
                {
                    List <Resolution> result = JsonWriteLoad.LoadJson(_fileName);



                    int first = currentSelection2.Width;
                    int last  = currentSelection2.Height;
                    int index = result.FindIndex(x => x.Width == currentSelection2.Width && x.Height == currentSelection2.Height);
                    int.TryParse(textBox1.Text, out first);
                    int.TryParse(textBox2.Text, out last);
                    result[index].Width    = first;
                    result[index].Height   = last;
                    result[index].IsActive = currentSelection2.IsActive;
                    JsonWriteLoad.WriteJson(_fileName, result);

                    LoadToGrid(_fileName);
                    element           = -1;
                    currentSelection2 = null;
                    if (currentSelection2 == null)
                    {
                        button3.Enabled = false;
                    }
                    StringBuilder str = new StringBuilder();
                    str.Append("Total Resolutions : ");
                    str.Append(dataGridView1.Rows.Count);
                    label4.Text = str.ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Unhandled Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                int w = -1;
                int h = -1;

                int.TryParse(textBox1.Text, out w);
                int.TryParse(textBox2.Text, out h);
                if (w > 20 && h > 20)
                {
                    List <Resolution> result = JsonWriteLoad.LoadJson(_fileName);

                    Resolution r = new Resolution();
                    r.Width  = w;
                    r.Height = h;
                    if (result.FindIndex(x => x.Width == r.Width && x.Height == r.Height) < 0)
                    {
                        result.Add(r);
                        JsonWriteLoad.WriteJson(_fileName, result);
                        LoadToGrid(_fileName);
                    }
                    else
                    {
                        MessageBox.Show("Resolution Already Exists!");
                    }
                }
                else
                {
                    MessageBox.Show("Please Enter Valid Resolution!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Unhandled Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }