public static bool Save(MeasureProfile current, MeasureProfile newprof)
        {
            FormSaveProfileType inst = FormSaveProfileType.Instance;

            if (current != null)
            {
                inst.labelNowProfile.Text = "\'" + current.ToString() + "\'";
            }

            if (inst.ShowDialog() == DialogResult.OK)
            {
                bool   newp = inst.radioButtonNew.Checked;
                string name = inst.textBoxName.Text;

                if (!newp)
                {
                    if (current == null || current.ID < 0)
                    {
                        MessageBox.Show("Профиль не заменён: не выбран основной.");
                        return(false);
                    }
                    else
                    {
                        newprof.Name = current.Name;
                        Program.DataProvider.delete("MeasureProfile", "ID=" + current.ID);
                        Program.DataProvider.insertMeasureProfile(newprof);
                    }
                }
                else
                {
                    if (name.Trim() == "")
                    {
                        MessageBox.Show("Профиль не сохранён: вы не ввели название.");
                        return(false);
                    }
                    else
                    {
                        newprof.Name = name;
                        Program.DataProvider.insertMeasureProfile(newprof);
                    }
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }
        private void button3_Click(object sender, EventArgs e)
        {
            MeasureProfile prf = collectProfile("");

            if (prf == null)
            {
                MessageBox.Show("Профиль собран некорректно. Вы не можете его сохранить!");
                return;
            }

            if (FormSaveProfileType.Save(comboBoxProfiles.SelectedItem as MeasureProfile, prf))
            {
                int c = Program.DataProvider.getMeasureProfiles().Count;
                if (c > 0)
                {
                    MeasureProfile mp = Program.DataProvider.MeasureProfiles[c - 1];
                    Program.Presets.MainWin.refreshComboProfiles();
                    Program.Presets.MainWin.stackPlotters(mp);
                    fillProfiles(mp.ID);
                }
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (
                textBoxName.Text != "Новое измерение"
                ||
                MessageBox.Show("Вы не ввели название измерения. Начать измерение с названием 'Новое измерение'?", "Название", MessageBoxButtons.YesNo) == DialogResult.Yes
                )
            {
                MeasureProfile prof = collectProfile("");
                MeasureProfile curr = comboBoxProfiles.SelectedItem as MeasureProfile;

                if (prof == null)
                {
                    MessageBox.Show("Профиль собран некорректно. Вы не можете его сохранить!");
                    DialogResult = DialogResult.Cancel;
                    return;
                }

                bool eq = true;

                for (int pos = 0; pos < combos.Count; pos++)
                {
                    if (curr == null || prof.Settings.ContainsKey(pos) ^ curr.Settings.ContainsKey(pos))
                    {
                        eq = false;
                    }
                    else if (prof.Settings.ContainsKey(pos))
                    {
                        if (!prof.Settings[pos].Equals(curr.Settings[pos]))
                        {
                            eq = false;
                        }
                    }
                }

                if (!eq)
                {
                    if (FormSaveProfileType.Save(comboBoxProfiles.SelectedItem as MeasureProfile, prof))
                    {
                        int c = Program.DataProvider.getMeasureProfiles().Count;
                        if (c > 0)
                        {
                            MeasureProfile mp = Program.DataProvider.MeasureProfiles[c - 1];
                            Program.Presets.MainWin.refreshComboProfiles();
                            Program.Presets.MainWin.stackPlotters(mp);
                            fillProfiles(mp.ID);
                            usedProfile = mp;
                        }
                        else
                        {
                            usedProfile = Program.Presets.CurrentProfile;
                        }
                    }
                    else
                    {
                        usedProfile = prof;
                    }
                    #region какой-то код

                    /*
                     * if (MessageBox.Show("Установки были изменены. Сохранить изменения?", "изменённые настройки", MessageBoxButtons.YesNo) == DialogResult.Yes)
                     * {
                     * string name = FormStringRequest.GetString("Введите название профиля");
                     * if (name != null)
                     * {
                     *  prof.Name = name;
                     *  Program.dataProvider.insertMeasureProfile(prof);
                     *  usedProfile = Program.dataProvider.MeasureProfiles[Program.dataProvider.MeasureProfiles.Count - 1];
                     * }
                     * else
                     *  usedProfile = collectProfile("неизвестный");
                     *
                     * }
                     * else
                     * usedProfile = collectProfile("неизвестный");
                     */
                    #endregion
                }
                else
                {
                    usedProfile = curr;
                }
                longitude = Convert.ToInt32(textBox6.Text);
                latitude  = Convert.ToInt32(textBox7.Text);
                Program.Presets.CurrentProfile = curr;
                DialogResult = DialogResult.OK;
                Close();
            }
        }