Пример #1
0
        private void cbSweepSettings_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cbSweepSettings.SelectedItem == null)
            {
                return;
            }

            var sweepName = cbSweepSettings.SelectedItem as string;

            if (string.IsNullOrEmpty(sweepName))
            {
                LogMessage("Failed loading sweep name!");
                return;
            }


            if (!SweepSettingsList.ContainsKey(sweepName))
            {
                LogMessage("Failed finding sweep " + sweepName);
                return;
            }

            CurrentSweepSettings     = SweepSettingsList[sweepName];
            tbHuginTemplate.Text     = CurrentSweepSettings.HuginTemplate;
            btnNextSweepStep.Enabled = btnStartSweep.Enabled = true;
            btnResetSweep.Enabled    = true;
            btnGoToMidFrame.Enabled  = true;
        }
Пример #2
0
        private void btnSaveSweepSettings_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(tbHuginTemplate.Text) || !File.Exists(tbHuginTemplate.Text))
            {
                MessageBox.Show("You must specify the Hugin panorama file before saving the sweep.");
                return;
            }

            string name;

            while (true)
            {
                name = Microsoft.VisualBasic.Interaction.InputBox("Name your sweep", "Save sweep settings");
                if (string.IsNullOrWhiteSpace(name))
                {
                    return;
                }

                if (name.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0)
                {
                    MessageBox.Show("Invalid sweep name; it has to be a valid filename");
                    continue;
                }

                if (!SweepSettingsList.ContainsKey(name))
                {
                    break;
                }

                if (DialogResult.OK == MessageBox.Show("Sweep «" + name + "» already exists. Overwrite?", "Overwrite sweep?", MessageBoxButtons.OKCancel))
                {
                    break;
                }
            }

            var finalFilename = Path.Combine(HuginPanoramaFolder, name + ".pto");

            File.Copy(tbHuginTemplate.Text, finalFilename, true);
            tbHuginTemplate.Text = finalFilename;

            var sweep = new SweepSettings()
            {
                DslrSize      = CurrentSweepSettings.DslrSize,
                FilmSize      = CurrentSweepSettings.FilmSize,
                HuginTemplate = finalFilename,
            };

            SweepSettingsList[name] = sweep;
            SaveSweepSettings();
        }