예제 #1
0
        private void BtnOk_Click(object sender, EventArgs e)
        {
            bool   error;
            string pName   = TxtProfile.Text;
            long   pSize   = 0;
            double dblSize = 0;

            double.TryParse(TxtSize.Text, out dblSize);
            pSize = (long)(dblSize * Math.Pow(1024, CmbUnit.SelectedIndex));

            if (pSize > (long)Math.Pow(1024, 5))
            {
                MessageBox.Show("Invalid size, Part size is too large.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            error = CheckErrors();

            if (!error)
            {
                if (!editMode)
                {
                    if (Ini.KeyExists("profiles", pName))
                    {
                        MessageBox.Show("Profile name '" + pName + "' is already existed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }

                    Ini.WriteValue("profiles", pName, IoTools.ParseSize(pSize));
                }

                Ini.WriteValue(pName, "name", TxtProfile.Text);
                Ini.WriteValue(pName, "size", pSize.ToString());
                Ini.WriteValue(pName, "index", CmbUnit.SelectedIndex);
                Ini.WriteValue(pName, "description", TxtDesc.Text);

                this.Close();
            }
        }