private void AddOpenFileDialogCustomControls(CommonFileDialog openDialog)
        {
            // Add a geometry type ComboBox
            CommonFileDialogGroupBox geoBox      = new CommonFileDialogGroupBox("Geometry");
            CommonFileDialogComboBox geoComboBox = new CommonFileDialogComboBox("geoComboBox");

            geoComboBox.Items.Add(new CommonFileDialogComboBoxItem(".fbx"));
            geoComboBox.Items.Add(new CommonFileDialogComboBoxItem(".obj"));
            geoComboBox.SelectedIndex = 1;
            geoBox.Items.Add(geoComboBox);
            openDialog.Controls.Add(geoBox);

            // Add a texture ComboBox
            CommonFileDialogGroupBox texBox      = new CommonFileDialogGroupBox("Texture");
            CommonFileDialogComboBox texComboBox = new CommonFileDialogComboBox("texComboBox");

            texComboBox.Items.Add(new CommonFileDialogComboBoxItem(".bmp"));
            texComboBox.Items.Add(new CommonFileDialogComboBoxItem(".jpg"));
            texComboBox.Items.Add(new CommonFileDialogComboBoxItem(".png"));
            texComboBox.Items.Add(new CommonFileDialogComboBoxItem(".tga"));
            texComboBox.SelectedIndex = 2;
            texBox.Items.Add(texComboBox);
            openDialog.Controls.Add(texBox);

            // Create and add a separator
            openDialog.Controls.Add(new CommonFileDialogSeparator());

            // Add a world or local space option
            openDialog.Controls.Add(new CommonFileDialogCheckBox("worldSpaceCheckBox", "World Space", false));

            // Add a multiple objects or single merged object
            openDialog.Controls.Add(new CommonFileDialogCheckBox("mergeCheckBox", "Merge", false));
        }
Exemple #2
0
        private string GetCustomControlValues()
        {
            string values = "Custom Cotnrols Values:" + Environment.NewLine;

            CommonFileDialogRadioButtonList list = currentFileDialog.Controls["radioButtonOptions"] as CommonFileDialogRadioButtonList;

            values += String.Format("Radio Button List: Total Options = {0}; Selected Option = \"{1}\"; Selected Option Index = {2}", list.Items.Count, list.Items[list.SelectedIndex].Text, list.SelectedIndex) + Environment.NewLine;

            CommonFileDialogComboBox combo = currentFileDialog.Controls["comboBox"] as CommonFileDialogComboBox;

            values += String.Format("Combo Box: Total Items = {0}; Selected Item = \"{1}\"; Selected Item Index = {2}", combo.Items.Count, combo.Items[combo.SelectedIndex].Text, combo.SelectedIndex) + Environment.NewLine;

            CommonFileDialogCheckBox checkBox = currentFileDialog.Controls["chkOptionA"] as CommonFileDialogCheckBox;

            values += String.Format("Check Box \"{0}\" is {1}", checkBox.Text, checkBox.IsChecked ? "Checked" : "Unchecked") + Environment.NewLine;

            checkBox = currentFileDialog.Controls["chkOptionB"] as CommonFileDialogCheckBox;
            values  += String.Format("Check Box \"{0}\" is {1}", checkBox.Text, checkBox.IsChecked ? "Checked" : "Unchecked") + Environment.NewLine;

            CommonFileDialogTextBox textBox = currentFileDialog.Controls["textName"] as CommonFileDialogTextBox;

            values += String.Format("TextBox \"Name\" = {0}", textBox.Text);

            return(values);
        }
Exemple #3
0
        private void AddCustomControls(CommonFileDialog openDialog)
        {
            // Add a RadioButtonList
            CommonFileDialogRadioButtonList list = new CommonFileDialogRadioButtonList("Options");

            list.Items.Add(new CommonFileDialogRadioButtonListItem("Option A"));
            list.Items.Add(new CommonFileDialogRadioButtonListItem("Option B"));
            list.SelectedIndexChanged += RBLOptions_SelectedIndexChanged;
            list.SelectedIndex         = 1;
            openDialog.Controls.Add(list);

            // Create a groupbox
            CommonFileDialogGroupBox groupBox = new CommonFileDialogGroupBox("Options");

            // Create and add two check boxes to this group
            CommonFileDialogCheckBox checkA = new CommonFileDialogCheckBox("Option A", true);
            CommonFileDialogCheckBox checkB = new CommonFileDialogCheckBox("Option B", true);

            checkA.CheckedChanged += ChkOptionA_CheckedChanged;
            checkB.CheckedChanged += ChkOptionB_CheckedChanged;
            groupBox.Items.Add(checkA);
            groupBox.Items.Add(checkB);

            // Create and add a separator to this group
            groupBox.Items.Add(new CommonFileDialogSeparator());

            // Create and add a button to this group
            CommonFileDialogButton btnCFDPushButton = new CommonFileDialogButton("Push Button");

            btnCFDPushButton.Click += PushButton_Click;
            groupBox.Items.Add(btnCFDPushButton);

            // Add groupbox to dialog
            openDialog.Controls.Add(groupBox);

            // Add a Menu
            CommonFileDialogMenu     menu  = new CommonFileDialogMenu("Sample Menu");
            CommonFileDialogMenuItem itemA = new CommonFileDialogMenuItem("Menu Item 1");
            CommonFileDialogMenuItem itemB = new CommonFileDialogMenuItem("Menu Item 2");

            itemA.Click += MenuOptionA_Click;
            itemB.Click += MenuOptionA_Click;
            menu.Items.Add(itemA);
            menu.Items.Add(itemB);
            openDialog.Controls.Add(menu);

            // Add a TextBox
            openDialog.Controls.Add(new CommonFileDialogLabel("Enter name"));
            openDialog.Controls.Add(new CommonFileDialogTextBox("textBox", Environment.UserName));

            // Add a ComboBox
            CommonFileDialogComboBox comboBox = new CommonFileDialogComboBox();

            comboBox.SelectedIndexChanged += ComboEncoding_SelectedIndexChanged;
            comboBox.Items.Add(new CommonFileDialogComboBoxItem("Combobox Item 1"));
            comboBox.Items.Add(new CommonFileDialogComboBoxItem("Combobox Item 2"));
            comboBox.SelectedIndex = 1;
            openDialog.Controls.Add(comboBox);
        }
        private void Export(TreeNode node)
        {
            // OBJ for now
            var dlg = new CommonOpenFileDialog()
            {
                Title = "Select export folder"
            };

            dlg.IsFolderPicker = true;
            AddOpenFileDialogCustomControls(dlg);

            if (dlg.ShowDialog() == CommonFileDialogResult.Ok)
            {
                string exportMeshDirectory = dlg.FileName;

                CommonFileDialogComboBox geoComboBox = dlg.Controls["geoComboBox"] as CommonFileDialogComboBox;
                string modelExtension = geoComboBox.Items[geoComboBox.SelectedIndex].Text;

                CommonFileDialogComboBox texComboBox = dlg.Controls["texComboBox"] as CommonFileDialogComboBox;
                string texExtension = texComboBox.Items[texComboBox.SelectedIndex].Text;

                CommonFileDialogCheckBox worldSpaceCheckBox = dlg.Controls["worldSpaceCheckBox"] as CommonFileDialogCheckBox;
                bool transformToWorld = worldSpaceCheckBox.IsChecked;

                CommonFileDialogCheckBox mergeCheckBox = dlg.Controls["mergeCheckBox"] as CommonFileDialogCheckBox;
                bool mergeObjects = mergeCheckBox.IsChecked;

                exportMeshButton.Enabled = false;

                if (node.Nodes.Count > 0)
                {
                    // TODO: if merging is desired, combine all the objects into one mesh with multiple buffers
                    progressBar.Maximum = node.Nodes.Count;

                    int instance = 0;
                    foreach (RenderTreeNode rn in node.Nodes)
                    {
                        string instanceName = "_" + instance.ToString();
                        ExportNode(rn, exportMeshDirectory, modelExtension, texExtension, transformToWorld, instanceName);
                        ++instance;

                        progressBar.PerformStep();
                    }

                    progressBar.Value = 0;
                }
                else
                {
                    string instanceName = "";
                    ExportNode((RenderTreeNode)node, exportMeshDirectory, modelExtension, texExtension, transformToWorld, instanceName);
                }

                exportMeshButton.Enabled = true;
            }
        }
Exemple #5
0
        public static CommonFileDialogControl GetMidiExportDialogControls()
        {
            var cb = new CommonFileDialogComboBox()
            {
                Name        = "MidiChunksSelector",
                IsProminent = true
            };

            cb.Items.Add(new CommonFileDialogComboBoxItem("1 Chunk"));
            cb.Items.Add(new CommonFileDialogComboBoxItem("2 Chunks"));
            cb.SelectedIndex = 1;
            return(cb);
        }
        public static CommonFileDialogComboBox ConvertToComboBox(Encoding defaultEncoding)
        {
            var comboBox  = new CommonFileDialogComboBox();
            var encodings = Encoding.GetEncodings().Select(e => e.GetEncoding());

            for (var i = 0; i < encodings.Count(); i++)
            {
                comboBox.Items.Add(new CommonFileDialogEncodingComboBoxItem(encodings.ElementAt(i)));
                if (encodings.ElementAt(i).Equals(defaultEncoding))
                {
                    comboBox.SelectedIndex = i;
                }
            }
            return(comboBox);
        }
Exemple #7
0
        public bool Run(AddFileDialogData data)
        {
            var parent = data.TransientFor ?? MessageService.RootWindow;
            var dialog = new CommonOpenFileDialog();

            SelectFileDialogHandler.SetCommonFormProperties(data, dialog);

            var buildActionCombo = new CommonFileDialogComboBox();
            var group            = new CommonFileDialogGroupBox("overridebuildaction", "Override build action:");

            buildActionCombo.Items.Add(new CommonFileDialogComboBoxItem(GettextCatalog.GetString("Default")));
            foreach (var ba in data.BuildActions)
            {
                if (ba == "--")
                {
                    continue;
                }

                buildActionCombo.Items.Add(new CommonFileDialogComboBoxItem(ba));
            }

            buildActionCombo.SelectedIndex = 0;
            group.Items.Add(buildActionCombo);
            dialog.Controls.Add(group);

            if (!GdkWin32.RunModalWin32Dialog(dialog, parent))
            {
                return(false);
            }

            SelectFileDialogHandler.GetCommonFormProperties(data, dialog);
            var idx = buildActionCombo.SelectedIndex;

            if (idx > 0)
            {
                data.OverrideAction = buildActionCombo.Items [idx].Text;
            }

            return(true);
        }
        bool Save(SaveOperation operation)
        {
            if (!CanSave)
            {
                return(false);
            }

            var saveOperation = Session.CreateWorkbookSaveOperation();
            var savePath      = Session.Workbook.LogicalPath;

            if (savePath.IsNull || operation == SaveOperation.SaveAs)
            {
                var saveDialog = new CommonSaveFileDialog {
                    Title           = Catalog.GetString("Save Workbook"),
                    DefaultFileName = Session.Title,
                    AlwaysAppendDefaultExtension = true,
                    DefaultExtension             = ".workbook"
                };

                if (!savePath.IsNull)
                {
                    saveDialog.InitialDirectory = savePath.DirectoryExists
                        ? savePath.ParentDirectory
                        : savePath;
                }

                saveDialog.FolderChanging += (o, e) => {
                    if (e.Folder.EndsWith(".workbook", StringComparison.OrdinalIgnoreCase))
                    {
                        e.Cancel = true;
                    }
                };

                saveDialog.Filters.Add(new CommonFileDialogFilter("Xamarin Workbook", ".workbook"));

                CommonFileDialogComboBox formatComboBox = null;

                if (saveOperation.SupportedOptions.HasFlag(WorkbookSaveOptions.Archive))
                {
                    formatComboBox = new CommonFileDialogComboBox();
                    formatComboBox.Items.Add(new CommonFileDialogComboBoxItem(
                                                 Catalog.GetString("Package Directory")));
                    formatComboBox.Items.Add(new CommonFileDialogComboBoxItem(
                                                 Catalog.GetString("Archive")));
                    formatComboBox.SelectedIndex = saveOperation.Options.HasFlag(
                        WorkbookSaveOptions.Archive) ? 1 : 0;

                    var formatGroup = new CommonFileDialogGroupBox("Workbook Format:");
                    formatGroup.Items.Add(formatComboBox);
                    saveDialog.Controls.Add(formatGroup);
                }

                if (saveDialog.ShowDialog(this) != CommonFileDialogResult.Ok)
                {
                    return(false);
                }

                if (formatComboBox != null)
                {
                    switch (formatComboBox.SelectedIndex)
                    {
                    case 0:
                        saveOperation.Options &= ~WorkbookSaveOptions.Archive;
                        break;

                    case 1:
                        saveOperation.Options |= WorkbookSaveOptions.Archive;
                        break;

                    default:
                        throw new IndexOutOfRangeException();
                    }
                }

                savePath = saveDialog.FileName;

                saveOperation.Destination = savePath;
            }

            var success = false;

            try {
                Session.SaveWorkbook(saveOperation);
                NoteRecentDocument();
                success = true;
                IsDirty = false;
            } catch (Exception e) {
                Log.Error(TAG, e);
            }

            return(success);
        }
Exemple #9
0
        private void ComboEncoding_SelectedIndexChanged(object sender, EventArgs e)
        {
            CommonFileDialogComboBox combo = currentFileDialog.Controls["comboBox"] as CommonFileDialogComboBox;

            MessageBox.Show(String.Format("Combo box sel index changed: Total Items = {0}; Selected Index = {1}; Selected Item = {2}", combo.Items.Count, combo.SelectedIndex, combo.Items[combo.SelectedIndex].Text));
        }