Пример #1
0
        private void ButtonDuplicateFilterClick(object sender, EventArgs e)
        {
            var name      = comboBoxReconstruction.SelectedItem.ToString();
            var finalName = name;
            var sampler   = LibraryReconstructionFilters.GetReconstructionFilter(name);
            var isaveObj  = sampler as ISave;

            var num  = 1;
            var path = Path.Combine(MitsubaSettings.FolderReconstructionFiltersFolder,
                                    name) + LibraryReconstructionFilters.Extension;;

            while (File.Exists(path))
            {
                num++;
                finalName = name + " (" + num + ")";
                path      = Path.Combine(MitsubaSettings.FolderReconstructionFiltersFolder, finalName);
                path     += LibraryReconstructionFilters.Extension;
            }

            if (isaveObj != null)
            {
                var input = new InputBoxDlg {
                    Titul     = "Mistuba Render Reconstruction Filter",
                    TopicText = "Please Type a Name",
                    InputText = finalName
                };

                input.ShowDialog();

                if (input.DialogResult == DialogResult.OK)
                {
                    finalName = input.InputText;
                    path      = Path.Combine(MitsubaSettings.FolderReconstructionFiltersFolder, finalName);

                    if (File.Exists(path))
                    {
                        //TODO Localize me
                        if (MessageBox.Show("This file already exist, do you want to overwrite it?",
                                            "Mistuba Render Reconstruction Filter", MessageBoxButtons.YesNo) == DialogResult.No)
                        {
                            return;
                        }
                    }

                    isaveObj.Save(finalName);
                    LibraryReconstructionFilters.Init();
                    comboBoxReconstruction.DataSource   = LibraryReconstructionFilters.ReconstructionFilters.ToArray();
                    comboBoxReconstruction.SelectedItem = finalName;
                }
            }
        }
Пример #2
0
        private void ButtonSaveClick(object sender, EventArgs e)
        {
            //New Preset
            if (String.IsNullOrEmpty(_editingPreset))
            {
                const string name      = "New Render Preset";
                var          finalName = name;
                var          path      = Path.Combine(MitsubaSettings.FolderRenderSettingsPresetsFolder, finalName) + LibraryPresets.Extension;

                var num = 1;

                while (File.Exists(path))
                {
                    num++;
                    finalName = name + "(" + num + ")";
                    path      = Path.Combine(MitsubaSettings.FolderRenderSettingsPresetsFolder, finalName) + LibraryPresets.Extension;
                }


                var input = new InputBoxDlg {
                    Titul     = "Mistuba Render Settings Preset",
                    TopicText = "Please Type a Name",
                    InputText = finalName
                };

                input.ShowDialog();

                if (input.DialogResult == DialogResult.OK)
                {
                    finalName = input.InputText;
                    //var path = Path.Combine(MitsubaSettings.FolderRenderSettingsPresetsFolder, finalName);

                    var presetObj = new RenderSettingsPreset {
                        IntegratorName           = comboBoxIntegrator.SelectedItem.ToString(),
                        SamplerName              = comboBoxSampler.SelectedItem.ToString(),
                        ReconstructionFilterName = comboBoxReconstruction.SelectedItem.ToString(),
                    };


                    if (String.IsNullOrEmpty(_editingPreset))
                    {
                        path = Path.Combine(MitsubaSettings.FolderRenderSettingsPresetsFolder, finalName) + LibraryPresets.Extension;

                        if (File.Exists(path))
                        {
                            //TODO: Localize me
                            var res = MessageBox.Show(String.Format("{0} already exists, do you want to overwrite it?", finalName),
                                                      "Mitsuba Save Render Settings", MessageBoxButtons.YesNoCancel);

                            if (res == DialogResult.No)
                            {
                                Close();
                            }
                            else if (res == DialogResult.Cancel)
                            {
                                return;
                            }
                        }
                    }

                    if (!presetObj.Save(finalName))
                    {
                        //TODO: Localize me
                        MessageBox.Show(String.Format("There was problem saving {0}", finalName));
                    }

                    LibraryPresets.Init();
                    Close();
                }
            }

            //Editing Preset
            else
            {
                var presetObj = new RenderSettingsPreset {
                    IntegratorName           = comboBoxIntegrator.SelectedItem.ToString(),
                    SamplerName              = comboBoxSampler.SelectedItem.ToString(),
                    ReconstructionFilterName = comboBoxReconstruction.SelectedItem.ToString(),
                };

                if (!presetObj.Save(_editingPreset))
                {
                    //TODO: Localize me
                    MessageBox.Show(String.Format("There was problem saving {0}", _editingPreset));
                }

                Close();
            }
        }