Пример #1
0
        public void LoadPresets()
        {
            listViewIntegrators.Clear();
            listViewIntegrators.GridLines     = true;
            listViewIntegrators.FullRowSelect = true;
            var column = listViewIntegrators.Columns.Add("Mitsuba Rendering Presets");

            column.Width = 376;

            LibraryPresets.Init();

            if (LibraryPresets.Presets != null && LibraryPresets.Presets.Any())
            {
                foreach (var preset in LibraryPresets.Presets)
                {
                    listViewIntegrators.Items.Add(preset);
                }
            }

            column.TextAlign = HorizontalAlignment.Center;

            if (!String.IsNullOrEmpty(MitsubaSettings.DefaultRenderSettingsPresetName))
            {
                for (int i = 0; i < listViewIntegrators.Items.Count; i++)
                {
                    if (listViewIntegrators.Items[i].Text == MitsubaSettings.DefaultRenderSettingsPresetName)
                    {
                        listViewIntegrators.Items[i].Selected = true;
                        listViewIntegrators.Items[i].Focused  = true;
                        listViewIntegrators.FocusedItem       = listViewIntegrators.Items[i];

                        break;
                    }
                }
            }
        }
Пример #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();
            }
        }