diff --git a/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/CustomOptionsDialog.Designer.cs b/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/CustomOptionsDialog.Designer.cs
new file mode 100644
index 00000000..2adbe608
--- /dev/null
+++ b/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/CustomOptionsDialog.Designer.cs
@@ -0,0 +1,116 @@
+namespace UniversalEditor.UserInterface.WindowsForms.Dialogs
+{
+ partial class CustomOptionDialog
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.tbl = new System.Windows.Forms.TableLayoutPanel();
+ this.cmdCancel = new System.Windows.Forms.Button();
+ this.cmdOK = new System.Windows.Forms.Button();
+ this.cmdAbout = new System.Windows.Forms.Button();
+ this.SuspendLayout();
+ //
+ // tbl
+ //
+ this.tbl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.tbl.ColumnCount = 3;
+ this.tbl.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
+ this.tbl.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
+ this.tbl.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tbl.Location = new System.Drawing.Point(12, 12);
+ this.tbl.Name = "tbl";
+ this.tbl.RowCount = 2;
+ this.tbl.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 27F));
+ this.tbl.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
+ this.tbl.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tbl.Size = new System.Drawing.Size(404, 192);
+ this.tbl.TabIndex = 0;
+ //
+ // cmdCancel
+ //
+ this.cmdCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.cmdCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
+ this.cmdCancel.FlatStyle = System.Windows.Forms.FlatStyle.System;
+ this.cmdCancel.Location = new System.Drawing.Point(341, 221);
+ this.cmdCancel.Name = "cmdCancel";
+ this.cmdCancel.Size = new System.Drawing.Size(75, 23);
+ this.cmdCancel.TabIndex = 1;
+ this.cmdCancel.Text = "Cancel";
+ this.cmdCancel.UseVisualStyleBackColor = true;
+ //
+ // cmdOK
+ //
+ this.cmdOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.cmdOK.FlatStyle = System.Windows.Forms.FlatStyle.System;
+ this.cmdOK.Location = new System.Drawing.Point(260, 221);
+ this.cmdOK.Name = "cmdOK";
+ this.cmdOK.Size = new System.Drawing.Size(75, 23);
+ this.cmdOK.TabIndex = 1;
+ this.cmdOK.Text = "OK";
+ this.cmdOK.UseVisualStyleBackColor = true;
+ this.cmdOK.Click += new System.EventHandler(this.cmdOK_Click);
+ //
+ // cmdAbout
+ //
+ this.cmdAbout.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+ this.cmdAbout.FlatStyle = System.Windows.Forms.FlatStyle.System;
+ this.cmdAbout.Location = new System.Drawing.Point(12, 221);
+ this.cmdAbout.Name = "cmdAbout";
+ this.cmdAbout.Size = new System.Drawing.Size(75, 23);
+ this.cmdAbout.TabIndex = 2;
+ this.cmdAbout.Text = "&About...";
+ this.cmdAbout.UseVisualStyleBackColor = true;
+ this.cmdAbout.Click += new System.EventHandler(this.cmdAbout_Click);
+ //
+ // CustomOptionDialog
+ //
+ this.AcceptButton = this.cmdOK;
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.CancelButton = this.cmdCancel;
+ this.ClientSize = new System.Drawing.Size(428, 256);
+ this.Controls.Add(this.cmdAbout);
+ this.Controls.Add(this.cmdOK);
+ this.Controls.Add(this.cmdCancel);
+ this.Controls.Add(this.tbl);
+ this.Name = "CustomOptionDialog";
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
+ this.Text = "DataFormat-specific options";
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.TableLayoutPanel tbl;
+ private System.Windows.Forms.Button cmdCancel;
+ private System.Windows.Forms.Button cmdOK;
+ private System.Windows.Forms.Button cmdAbout;
+ }
+}
\ No newline at end of file
diff --git a/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/CustomOptionsDialog.cs b/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/CustomOptionsDialog.cs
new file mode 100644
index 00000000..e0503f54
--- /dev/null
+++ b/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/CustomOptionsDialog.cs
@@ -0,0 +1,226 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+
+namespace UniversalEditor.UserInterface.WindowsForms.Dialogs
+{
+ public partial class CustomOptionDialog : AwesomeControls.Dialog
+ {
+ public CustomOptionDialog()
+ {
+ InitializeComponent();
+ }
+
+ private Dictionary CustomOptionControls = new Dictionary();
+
+ public event EventHandler AboutButtonClicked;
+
+ private void cmdAbout_Click(object sender, EventArgs e)
+ {
+ if (AboutButtonClicked != null)
+ {
+ AboutButtonClicked(sender, e);
+ }
+ }
+
+ private CustomOption.CustomOptionCollection mvarCustomOptions = new CustomOption.CustomOptionCollection();
+ public CustomOption.CustomOptionCollection CustomOptions { get { return mvarCustomOptions; } set { mvarCustomOptions = value; } }
+
+ protected override void OnShown(EventArgs e)
+ {
+ base.OnShown(e);
+
+ tbl.Controls.Clear();
+ CustomOptionControls = new Dictionary();
+
+ foreach (CustomOption eo in mvarCustomOptions)
+ {
+ if (!(eo is CustomOptionBoolean))
+ {
+ Label lbl = new Label();
+ lbl.FlatStyle = FlatStyle.System;
+ lbl.AutoSize = true;
+ lbl.Dock = DockStyle.None;
+ lbl.Anchor = AnchorStyles.Left;
+ lbl.Text = eo.Title;
+ tbl.Controls.Add(lbl);
+ }
+
+ if (eo is CustomOptionChoice)
+ {
+ CustomOptionChoice option = (eo as CustomOptionChoice);
+
+ ComboBox cbo = new ComboBox();
+ if (option.RequireChoice) cbo.DropDownStyle = ComboBoxStyle.DropDownList;
+ foreach (CustomOptionFieldChoice choice in option.Choices)
+ {
+ cbo.Items.Add(choice);
+ }
+ cbo.Dock = DockStyle.Fill;
+
+ tbl.Controls.Add(cbo);
+
+ CustomOptionControls.Add(eo.PropertyName, cbo);
+ }
+ else if (eo is CustomOptionNumber)
+ {
+ CustomOptionNumber option = (eo as CustomOptionNumber);
+
+ NumericUpDown txt = new NumericUpDown();
+ if (option.MaximumValue.HasValue)
+ {
+ txt.Maximum = option.MaximumValue.Value;
+ }
+ else
+ {
+ txt.Maximum = Decimal.MaxValue;
+ }
+ if (option.MinimumValue.HasValue)
+ {
+ txt.Minimum = option.MinimumValue.Value;
+ }
+ else
+ {
+ txt.Minimum = Decimal.MinValue;
+ }
+ txt.Value = option.DefaultValue;
+ txt.Dock = DockStyle.Fill;
+
+ tbl.Controls.Add(txt);
+
+ CustomOptionControls.Add(eo.PropertyName, txt);
+ }
+ else if (eo is CustomOptionText)
+ {
+ CustomOptionText option = (eo as CustomOptionText);
+
+ TextBox txt = new TextBox();
+ txt.Text = option.DefaultValue;
+ txt.Dock = DockStyle.Fill;
+ if (option.MaximumLength.HasValue) txt.MaxLength = option.MaximumLength.Value;
+
+ tbl.Controls.Add(txt);
+
+ CustomOptionControls.Add(eo.PropertyName, txt);
+ }
+ else if (eo is CustomOptionBoolean)
+ {
+ CustomOptionBoolean option = (eo as CustomOptionBoolean);
+
+ CheckBox chk = new CheckBox();
+ chk.AutoSize = true;
+ chk.Anchor = AnchorStyles.Left | AnchorStyles.Right;
+ chk.Text = option.Title;
+
+ tbl.Controls.Add(chk);
+ tbl.SetColumnSpan(chk, 2);
+
+ CustomOptionControls.Add(eo.PropertyName, chk);
+ }
+ else if (eo is CustomOptionFile)
+ {
+ CustomOptionFile option = (eo as CustomOptionFile);
+
+ AwesomeControls.FileTextBox.FileTextBoxControl cmd = new AwesomeControls.FileTextBox.FileTextBoxControl();
+ cmd.Click += cmdFileBrowse_Click;
+ cmd.Dock = DockStyle.Fill;
+ cmd.Tag = eo;
+
+ tbl.Controls.Add(cmd);
+
+ CustomOptionControls.Add(eo.PropertyName, cmd);
+ }
+ }
+
+ foreach (RowStyle rs in tbl.RowStyles)
+ {
+ rs.SizeType = SizeType.AutoSize;
+ }
+
+ Label lblSpacer = new Label();
+ lblSpacer.Dock = DockStyle.Fill;
+ tbl.Controls.Add(lblSpacer);
+ tbl.SetColumnSpan(lblSpacer, 2);
+
+ Font = SystemFonts.MenuFont;
+ }
+
+ private void cmdFileBrowse_Click(object sender, EventArgs e)
+ {
+ Button cmd = (sender as Button);
+ CustomOptionFile eo = (cmd.Tag as CustomOptionFile);
+
+ if (eo.DialogMode == CustomOptionFileDialogMode.Open)
+ {
+ OpenFileDialog ofd = new OpenFileDialog();
+ if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+ {
+ cmd.Text = ofd.FileName;
+ }
+ }
+ else if (eo.DialogMode == CustomOptionFileDialogMode.Save)
+ {
+ SaveFileDialog sfd = new SaveFileDialog();
+ if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+ {
+ cmd.Text = sfd.FileName;
+ }
+ }
+ }
+
+ private void cmdOK_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ foreach (CustomOption eo in mvarCustomOptions)
+ {
+ Control ctl = CustomOptionControls[eo.PropertyName];
+ if (ctl is NumericUpDown)
+ {
+ NumericUpDown itm = (ctl as NumericUpDown);
+ (eo as CustomOptionNumber).Value = itm.Value;
+ }
+ if (ctl is CheckBox)
+ {
+ CheckBox itm = (ctl as CheckBox);
+ (eo as CustomOptionBoolean).Value = itm.Checked;
+ }
+ else if (ctl is ComboBox)
+ {
+ CustomOptionFieldChoice choice = ((ctl as ComboBox).SelectedItem as CustomOptionFieldChoice);
+ (eo as CustomOptionChoice).Value = choice;
+ }
+ else if (ctl is TextBox)
+ {
+ TextBox itm = (ctl as TextBox);
+ (eo as CustomOptionText).Value = itm.Text;
+ }
+ }
+ }
+ catch (OverflowException ex)
+ {
+ MessageBox.Show("One or more of the parameters you specified is invalid. Please ensure you have provided the correct parameters, and then try again.\r\n\r\n" + ex.Message, "Invalid Parameters Specified", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+
+ this.DialogResult = System.Windows.Forms.DialogResult.OK;
+ this.Close();
+ }
+
+ public static DialogResult ShowDialog(ref CustomOption.CustomOptionCollection coll, string title, EventHandler aboutButtonClicked)
+ {
+ CustomOptionDialog dlg = new CustomOptionDialog();
+ if (aboutButtonClicked != null) dlg.AboutButtonClicked += aboutButtonClicked;
+ dlg.CustomOptions = coll;
+ dlg.Text = title;
+ if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.Cancel)
+ {
+ return DialogResult.Cancel;
+ }
+ return DialogResult.OK;
+ }
+ }
+}
diff --git a/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/DataFormatBrowserPopup.resx b/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/CustomOptionsDialog.resx
similarity index 100%
rename from CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/DataFormatBrowserPopup.resx
rename to CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/CustomOptionsDialog.resx
diff --git a/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/DataFormatBrowserPopup.cs b/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/DataFormatBrowserPopup.cs
deleted file mode 100644
index 9ecde04a..00000000
--- a/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/DataFormatBrowserPopup.cs
+++ /dev/null
@@ -1,159 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Drawing;
-using System.Text;
-using System.Windows.Forms;
-
-namespace UniversalEditor.UserInterface.WindowsForms.Dialogs
-{
- public partial class DataFormatBrowserPopup : Form
- {
- public event EventHandler SelectionChanged;
-
- public DataFormatBrowserPopup()
- {
- InitializeComponent();
- Font = SystemFonts.MenuFont;
- }
-
- protected override void OnDeactivate(EventArgs e)
- {
- base.OnDeactivate(e);
- this.Close();
- }
-
- private System.Collections.ObjectModel.Collection mvarDataFormats = new System.Collections.ObjectModel.Collection();
- public System.Collections.ObjectModel.Collection DataFormats { get { return mvarDataFormats; } }
-
- private DataFormat mvarDataFormat = null;
- public DataFormat DataFormat { get { return mvarDataFormat; } set { mvarDataFormat = value; } }
-
- private string DataFormatFilterCollectionToString(DataFormatFilter.DataFormatFilterCollection collection)
- {
- StringBuilder sb = new StringBuilder();
- foreach (DataFormatFilter filter in collection)
- {
- sb.Append(StringArrayToString(filter.FileNameFilters));
- if (collection.IndexOf(filter) < collection.Count - 1)
- {
- sb.Append("; ");
- }
- }
- return sb.ToString();
- }
-
- private string StringArrayToString(System.Collections.Specialized.StringCollection collection)
- {
- StringBuilder sb = new StringBuilder();
- foreach (string s in collection)
- {
- sb.Append(s);
- if (collection.IndexOf(s) < collection.Count - 1)
- {
- sb.Append(", ");
- }
- }
- return sb.ToString();
- }
-
-
- protected override void OnShown(EventArgs e)
- {
- base.OnShown(e);
- UpdateSearch();
- }
-
- private void UpdateSearch()
- {
- lv.Items.Clear();
- foreach (DataFormat df in mvarDataFormats)
- {
- DataFormatReference dfr = df.MakeReference();
- if (txtSearch.Text == String.Empty)
- {
- AddDataFormatToList(dfr);
- }
- else
- {
- if (dfr.Title != null && dfr.Title.ToLower().Contains(txtSearch.Text.ToLower()))
- {
- AddDataFormatToList(dfr);
- }
- else
- {
- bool nextDFR = false;
- foreach (DataFormatFilter filter in dfr.Filters)
- {
- foreach (string s in filter.FileNameFilters)
- {
- if (s.ToLower().Contains(txtSearch.Text.ToLower()))
- {
- AddDataFormatToList(dfr);
- nextDFR = true;
- break;
- }
- }
- if (nextDFR) break;
- }
- if (nextDFR) continue;
- }
- }
- }
-
- if (lv.Items.Count == 1)
- {
- lv.Items[0].Selected = true;
- }
- lv.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
- }
-
- private void AddDataFormatToList(DataFormatReference dfr)
- {
- ListViewItem lvi = new ListViewItem();
- lvi.Text = dfr.Title;
- lvi.Tag = dfr;
- lvi.SubItems.Add(DataFormatFilterCollectionToString(dfr.Filters));
- lv.Items.Add(lvi);
- }
-
- private void txtSearch_TextChanged(object sender, EventArgs e)
- {
- UpdateSearch();
- }
-
- private void lv_ItemActivate(object sender, EventArgs e)
- {
- if (lv.SelectedItems.Count != 1) return;
-
- mvarDataFormat = (lv.SelectedItems[0].Tag as DataFormatReference).Create();
- if (SelectionChanged != null) SelectionChanged(this, e);
-
- Close();
- }
-
- private void txtSearch_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- if (lv.SelectedItems.Count != 1) return;
-
- mvarDataFormat = (lv.SelectedItems[0].Tag as DataFormatReference).Create();
- if (SelectionChanged != null) SelectionChanged(this, e);
-
- Close();
- }
- else if (e.KeyCode == Keys.Escape)
- {
- Close();
- }
- }
-
- private void cmdClear_Click(object sender, EventArgs e)
- {
- mvarDataFormat = null;
- if (SelectionChanged != null) SelectionChanged(this, e);
- Close();
- }
- }
-}
diff --git a/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/DataFormatOptionsDialog.Designer.cs b/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/DataFormatOptionsDialog.Designer.cs
deleted file mode 100644
index 87ca063e..00000000
--- a/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/DataFormatOptionsDialog.Designer.cs
+++ /dev/null
@@ -1,115 +0,0 @@
-namespace UniversalEditor.UserInterface.WindowsForms.Dialogs
-{
- partial class DataFormatOptionsDialog
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Windows Form Designer generated code
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- this.tbl = new System.Windows.Forms.TableLayoutPanel();
- this.cmdCancel = new System.Windows.Forms.Button();
- this.cmdOK = new System.Windows.Forms.Button();
- this.cmdAbout = new System.Windows.Forms.Button();
- this.SuspendLayout();
- //
- // tbl
- //
- this.tbl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.tbl.ColumnCount = 2;
- this.tbl.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
- this.tbl.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
- this.tbl.Location = new System.Drawing.Point(12, 12);
- this.tbl.Name = "tbl";
- this.tbl.RowCount = 2;
- this.tbl.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 27F));
- this.tbl.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
- this.tbl.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tbl.Size = new System.Drawing.Size(404, 192);
- this.tbl.TabIndex = 0;
- //
- // cmdCancel
- //
- this.cmdCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.cmdCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
- this.cmdCancel.FlatStyle = System.Windows.Forms.FlatStyle.System;
- this.cmdCancel.Location = new System.Drawing.Point(341, 221);
- this.cmdCancel.Name = "cmdCancel";
- this.cmdCancel.Size = new System.Drawing.Size(75, 23);
- this.cmdCancel.TabIndex = 1;
- this.cmdCancel.Text = "Cancel";
- this.cmdCancel.UseVisualStyleBackColor = true;
- //
- // cmdOK
- //
- this.cmdOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.cmdOK.FlatStyle = System.Windows.Forms.FlatStyle.System;
- this.cmdOK.Location = new System.Drawing.Point(260, 221);
- this.cmdOK.Name = "cmdOK";
- this.cmdOK.Size = new System.Drawing.Size(75, 23);
- this.cmdOK.TabIndex = 1;
- this.cmdOK.Text = "OK";
- this.cmdOK.UseVisualStyleBackColor = true;
- this.cmdOK.Click += new System.EventHandler(this.cmdOK_Click);
- //
- // cmdAbout
- //
- this.cmdAbout.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
- this.cmdAbout.FlatStyle = System.Windows.Forms.FlatStyle.System;
- this.cmdAbout.Location = new System.Drawing.Point(12, 221);
- this.cmdAbout.Name = "cmdAbout";
- this.cmdAbout.Size = new System.Drawing.Size(75, 23);
- this.cmdAbout.TabIndex = 2;
- this.cmdAbout.Text = "&About...";
- this.cmdAbout.UseVisualStyleBackColor = true;
- this.cmdAbout.Click += new System.EventHandler(this.cmdAbout_Click);
- //
- // DataFormatOptionsDialog
- //
- this.AcceptButton = this.cmdOK;
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.CancelButton = this.cmdCancel;
- this.ClientSize = new System.Drawing.Size(428, 256);
- this.Controls.Add(this.cmdAbout);
- this.Controls.Add(this.cmdOK);
- this.Controls.Add(this.cmdCancel);
- this.Controls.Add(this.tbl);
- this.Name = "DataFormatOptionsDialog";
- this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
- this.Text = "DataFormat-specific options";
- this.ResumeLayout(false);
-
- }
-
- #endregion
-
- private System.Windows.Forms.TableLayoutPanel tbl;
- private System.Windows.Forms.Button cmdCancel;
- private System.Windows.Forms.Button cmdOK;
- private System.Windows.Forms.Button cmdAbout;
- }
-}
\ No newline at end of file
diff --git a/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/DataFormatOptionsDialog.cs b/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/DataFormatOptionsDialog.cs
deleted file mode 100644
index 65fb1768..00000000
--- a/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/DataFormatOptionsDialog.cs
+++ /dev/null
@@ -1,247 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Drawing;
-using System.Text;
-using System.Windows.Forms;
-
-namespace UniversalEditor.UserInterface.WindowsForms.Dialogs
-{
- public partial class DataFormatOptionsDialog : AwesomeControls.Dialog
- {
- public DataFormatOptionsDialog()
- {
- InitializeComponent();
- }
-
- private DataFormatOptionsDialogType mvarDialogType = DataFormatOptionsDialogType.Export;
- public DataFormatOptionsDialogType DialogType { get { return mvarDialogType; } set { mvarDialogType = value; } }
-
- private Dictionary CustomOptionControls = new Dictionary();
-
- private DataFormat mvarDataFormat = null;
- public DataFormat DataFormat
- {
- get { return mvarDataFormat; }
- set
- {
- mvarDataFormat = value;
- cmdAbout.Enabled = (mvarDataFormat != null);
- if (mvarDataFormat == null) return;
-
- this.Text = mvarDataFormat.MakeReference().Title + " Options";
-
- DataFormatReference dfr = mvarDataFormat.MakeReference();
- CustomOptionControls = new Dictionary();
-
- CustomOption.CustomOptionCollection coll = null;
- if (mvarDialogType == DataFormatOptionsDialogType.Export)
- {
- coll = dfr.ExportOptions;
- }
- else
- {
- coll = dfr.ImportOptions;
- }
-
- foreach (CustomOption eo in coll)
- {
- if (!(eo is CustomOptionBoolean))
- {
- Label lbl = new Label();
- lbl.FlatStyle = FlatStyle.System;
- lbl.AutoSize = true;
- lbl.Dock = DockStyle.None;
- lbl.Anchor = AnchorStyles.Left;
- lbl.Text = eo.Title;
- tbl.Controls.Add(lbl);
- }
-
- if (eo is CustomOptionChoice)
- {
- CustomOptionChoice option = (eo as CustomOptionChoice);
-
- ComboBox cbo = new ComboBox();
- if (option.RequireChoice) cbo.DropDownStyle = ComboBoxStyle.DropDownList;
- foreach (CustomOptionFieldChoice choice in option.Choices)
- {
- cbo.Items.Add(choice);
- }
- cbo.Dock = DockStyle.Fill;
-
- tbl.Controls.Add(cbo);
-
- CustomOptionControls.Add(eo.PropertyName, cbo);
- }
- else if (eo is CustomOptionNumber)
- {
- CustomOptionNumber option = (eo as CustomOptionNumber);
-
- NumericUpDown txt = new NumericUpDown();
- if (option.MaximumValue.HasValue)
- {
- txt.Maximum = option.MaximumValue.Value;
- }
- else
- {
- txt.Maximum = Decimal.MaxValue;
- }
- if (option.MinimumValue.HasValue)
- {
- txt.Minimum = option.MinimumValue.Value;
- }
- else
- {
- txt.Minimum = Decimal.MinValue;
- }
- txt.Value = option.DefaultValue;
- txt.Dock = DockStyle.Fill;
-
- tbl.Controls.Add(txt);
-
- CustomOptionControls.Add(eo.PropertyName, txt);
- }
- else if (eo is CustomOptionText)
- {
- CustomOptionText option = (eo as CustomOptionText);
-
- TextBox txt = new TextBox();
- txt.Text = option.DefaultValue;
- txt.Dock = DockStyle.Fill;
- if (option.MaximumLength.HasValue) txt.MaxLength = option.MaximumLength.Value;
-
- tbl.Controls.Add(txt);
-
- CustomOptionControls.Add(eo.PropertyName, txt);
- }
- else if (eo is CustomOptionBoolean)
- {
- CustomOptionBoolean option = (eo as CustomOptionBoolean);
-
- CheckBox chk = new CheckBox();
- chk.AutoSize = true;
- chk.Anchor = AnchorStyles.Left | AnchorStyles.Right;
- chk.Text = option.Title;
-
- tbl.Controls.Add(chk);
- tbl.SetColumnSpan(chk, 2);
-
- CustomOptionControls.Add(eo.PropertyName, chk);
- }
- }
-
- foreach (RowStyle rs in tbl.RowStyles)
- {
- rs.SizeType = SizeType.AutoSize;
- }
-
- Label lblSpacer = new Label();
- lblSpacer.Dock = DockStyle.Fill;
- tbl.Controls.Add(lblSpacer);
- tbl.SetColumnSpan(lblSpacer, 2);
-
- Font = SystemFonts.MenuFont;
- }
- }
-
- private void cmdAbout_Click(object sender, EventArgs e)
- {
- DataFormatAboutDialog dlg = new DataFormatAboutDialog();
- dlg.DataFormatReference = mvarDataFormat.MakeReference();
- dlg.ShowDialog();
- }
-
- private void cmdOK_Click(object sender, EventArgs e)
- {
- DataFormatReference dfr = mvarDataFormat.MakeReference();
- Type type = mvarDataFormat.GetType();
-
- CustomOption.CustomOptionCollection coll = null;
- if (mvarDialogType == DataFormatOptionsDialogType.Export)
- {
- coll = dfr.ExportOptions;
- }
- else
- {
- coll = dfr.ImportOptions;
- }
-
- try
- {
- foreach (CustomOption eo in coll)
- {
- System.Reflection.PropertyInfo pi = type.GetProperty(eo.PropertyName);
- if (pi == null) continue;
-
- Control ctl = CustomOptionControls[eo.PropertyName];
- if (ctl is NumericUpDown)
- {
- NumericUpDown txt = (ctl as NumericUpDown);
- pi.SetValue(mvarDataFormat, Convert.ChangeType(txt.Value, pi.PropertyType), null);
- }
- if (ctl is CheckBox)
- {
- CheckBox txt = (ctl as CheckBox);
- pi.SetValue(mvarDataFormat, Convert.ChangeType(txt.Checked, pi.PropertyType), null);
- }
- else if (ctl is ComboBox)
- {
- CustomOptionFieldChoice choice = ((ctl as ComboBox).SelectedItem as CustomOptionFieldChoice);
- if (choice != null)
- {
- Type[] interfaces = pi.PropertyType.GetInterfaces();
- bool convertible = false;
- foreach (Type t in interfaces)
- {
- if (t == typeof(IConvertible))
- {
- convertible = true;
- break;
- }
- }
- if (convertible)
- {
- pi.SetValue(mvarDataFormat, Convert.ChangeType(choice.Value, pi.PropertyType), null);
- }
- else
- {
- pi.SetValue(mvarDataFormat, choice.Value, null);
- }
- }
- }
- else if (ctl is TextBox)
- {
- TextBox txt = (ctl as TextBox);
- pi.SetValue(mvarDataFormat, Convert.ChangeType(txt.Text, pi.PropertyType), null);
- }
- }
- }
- catch (OverflowException ex)
- {
- MessageBox.Show("One or more of the parameters you specified is invalid. Please ensure you have provided the correct parameters, and then try again.\r\n\r\n" + ex.Message, "Invalid Parameters Specified", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
-
- this.DialogResult = System.Windows.Forms.DialogResult.OK;
- this.Close();
- }
-
- public static DialogResult ShowDialog(ref DataFormat fmt, DataFormatOptionsDialogType dialogType)
- {
- DataFormatReference dfr = fmt.MakeReference();
- if ((dialogType == DataFormatOptionsDialogType.Export && dfr.ExportOptions.Count > 0) || (dialogType == DataFormatOptionsDialogType.Import && dfr.ImportOptions.Count > 0))
- {
- DataFormatOptionsDialog dlg = new DataFormatOptionsDialog();
- dlg.DialogType = dialogType;
- dlg.DataFormat = fmt;
-
- if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.Cancel)
- {
- return DialogResult.Cancel;
- }
- return DialogResult.OK;
- }
- return DialogResult.None;
- }
- }
-}
diff --git a/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/DocumentPropertiesDialog.cs b/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/DocumentPropertiesDialog.cs
index 28357abf..f82bb1e3 100644
--- a/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/DocumentPropertiesDialog.cs
+++ b/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/DocumentPropertiesDialog.cs
@@ -70,8 +70,8 @@ namespace UniversalEditor.UserInterface.WindowsForms.Dialogs
private void cmdObjectModel_Click(object sender, EventArgs e)
{
- ObjectModelBrowserPopup dlg = new ObjectModelBrowserPopup();
- dlg.ObjectModel = mvarObjectModel;
+ GenericBrowserPopup dlg = new GenericBrowserPopup();
+ dlg.SelectedObject = mvarObjectModel;
Point loc = PointToScreen(cmdObjectModel.Location);
dlg.Location = new Point(loc.X, loc.Y + cmdObjectModel.Height);
@@ -98,7 +98,7 @@ namespace UniversalEditor.UserInterface.WindowsForms.Dialogs
}
foreach (ObjectModelReference dfr in omrs)
{
- dlg.ObjectModels.Add(dfr.Create());
+ dlg.AvailableObjects.Add(dfr.Create());
}
dlg.SelectionChanged += dlgObjectModel_SelectionChanged;
dlg.Show();
@@ -106,8 +106,8 @@ namespace UniversalEditor.UserInterface.WindowsForms.Dialogs
private void cmdDataFormat_Click(object sender, EventArgs e)
{
- DataFormatBrowserPopup dlg = new DataFormatBrowserPopup();
- dlg.DataFormat = mvarDataFormat;
+ GenericBrowserPopup dlg = new GenericBrowserPopup();
+ dlg.SelectedObject = mvarDataFormat;
Point loc = PointToScreen(cmdDataFormat.Location);
dlg.Location = new Point(loc.X, loc.Y + cmdDataFormat.Height);
@@ -137,7 +137,7 @@ namespace UniversalEditor.UserInterface.WindowsForms.Dialogs
}
foreach (DataFormatReference dfr in dfrs)
{
- dlg.DataFormats.Add(dfr.Create());
+ dlg.AvailableObjects.Add(dfr.Create());
}
dlg.SelectionChanged += dlgDataFormat_SelectionChanged;
dlg.Show();
@@ -145,20 +145,55 @@ namespace UniversalEditor.UserInterface.WindowsForms.Dialogs
private void dlgObjectModel_SelectionChanged(object sender, EventArgs e)
{
- ObjectModelBrowserPopup dlg = (sender as ObjectModelBrowserPopup);
- mvarObjectModel = dlg.ObjectModel;
+ GenericBrowserPopup dlg = (sender as GenericBrowserPopup);
+ mvarObjectModel = dlg.SelectedObject;
RefreshButtons();
}
private void dlgDataFormat_SelectionChanged(object sender, EventArgs e)
{
- DataFormatBrowserPopup dlg = (sender as DataFormatBrowserPopup);
- mvarDataFormat = dlg.DataFormat;
+ GenericBrowserPopup dlg = (sender as GenericBrowserPopup);
+ mvarDataFormat = dlg.SelectedObject;
+ RefreshButtons();
+ }
+ private void dlgAccessor_SelectionChanged(object sender, EventArgs e)
+ {
+ GenericBrowserPopup dlg = (sender as GenericBrowserPopup);
+ mvarAccessor = dlg.SelectedObject;
+
+ switch (mvarMode)
+ {
+ case DocumentPropertiesDialogMode.Open:
+ {
+ Engine.CurrentEngine.ShowCustomOptionDialog(ref mvarAccessor, CustomOptionDialogType.Import);
+ break;
+ }
+ case DocumentPropertiesDialogMode.Save:
+ {
+ Engine.CurrentEngine.ShowCustomOptionDialog(ref mvarAccessor, CustomOptionDialogType.Export);
+ break;
+ }
+ }
+
RefreshButtons();
}
private void cmdAccessor_Click(object sender, EventArgs e)
{
- ShowContextMenuBelow(mnuAccessor, cmdAccessor);
+ GenericBrowserPopup dlg = new GenericBrowserPopup();
+ dlg.SelectedObject = mvarAccessor;
+
+ Point loc = PointToScreen(cmdAccessor.Location);
+ dlg.Location = new Point(loc.X, loc.Y + cmdAccessor.Height);
+ dlg.Size = new Size(Width, 200);
+
+ AccessorReference[] ars = UniversalEditor.Common.Reflection.GetAvailableAccessors();
+ foreach (AccessorReference ar in ars)
+ {
+ if (!ar.Visible) continue;
+ dlg.AvailableObjects.Add(ar.Create());
+ }
+ dlg.SelectionChanged += dlgAccessor_SelectionChanged;
+ dlg.Show();
}
private void ShowContextMenuBelow(ContextMenuStrip menu, Control parent)
diff --git a/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/DataFormatBrowserPopup.Designer.cs b/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/GenericBrowserPopup.Designer.cs
similarity index 68%
rename from CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/DataFormatBrowserPopup.Designer.cs
rename to CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/GenericBrowserPopup.Designer.cs
index 1484d547..fc5d7c2a 100644
--- a/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/DataFormatBrowserPopup.Designer.cs
+++ b/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/GenericBrowserPopup.Designer.cs
@@ -1,33 +1,33 @@
namespace UniversalEditor.UserInterface.WindowsForms.Dialogs
{
- partial class DataFormatBrowserPopup
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
+ partial class GenericBrowserPopup
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
- #region Windows Form Designer generated code
+ #region Windows Form Designer generated code
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
this.txtSearch = new System.Windows.Forms.TextBox();
this.lv = new System.Windows.Forms.ListView();
this.chTitle = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
@@ -38,7 +38,7 @@
// txtSearch
//
this.txtSearch.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
+ | System.Windows.Forms.AnchorStyles.Right)));
this.txtSearch.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.txtSearch.Location = new System.Drawing.Point(6, 7);
this.txtSearch.Name = "txtSearch";
@@ -50,12 +50,12 @@
// lv
//
this.lv.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
this.lv.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.lv.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
- this.chTitle,
- this.chFilters});
+ this.chTitle,
+ this.chFilters});
this.lv.FullRowSelect = true;
this.lv.GridLines = true;
this.lv.HideSelection = false;
@@ -104,14 +104,14 @@
this.ResumeLayout(false);
this.PerformLayout();
- }
+ }
- #endregion
+ #endregion
- private System.Windows.Forms.TextBox txtSearch;
- private System.Windows.Forms.ListView lv;
- private System.Windows.Forms.ColumnHeader chTitle;
- private System.Windows.Forms.ColumnHeader chFilters;
- private System.Windows.Forms.Button cmdClear;
- }
+ private System.Windows.Forms.TextBox txtSearch;
+ private System.Windows.Forms.ListView lv;
+ private System.Windows.Forms.ColumnHeader chTitle;
+ private System.Windows.Forms.ColumnHeader chFilters;
+ private System.Windows.Forms.Button cmdClear;
+ }
}
\ No newline at end of file
diff --git a/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/GenericBrowserPopup.cs b/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/GenericBrowserPopup.cs
new file mode 100644
index 00000000..14ff7816
--- /dev/null
+++ b/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/GenericBrowserPopup.cs
@@ -0,0 +1,111 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+
+namespace UniversalEditor.UserInterface.WindowsForms.Dialogs
+{
+ public partial class GenericBrowserPopup : Form
+ where TObj : class, References
+ where TRef : class, ReferencedBy
+ {
+ public event EventHandler SelectionChanged;
+
+ public GenericBrowserPopup()
+ {
+ InitializeComponent();
+ Font = SystemFonts.MenuFont;
+ }
+
+ protected override void OnDeactivate(EventArgs e)
+ {
+ // base.OnDeactivate(e);
+ // this.Close();
+ }
+
+ private System.Collections.ObjectModel.Collection mvarAvailableObjects = new System.Collections.ObjectModel.Collection();
+ public System.Collections.ObjectModel.Collection AvailableObjects { get { return mvarAvailableObjects; } }
+
+ private TObj mvarSelectedObject = default(TObj);
+ public TObj SelectedObject { get { return mvarSelectedObject; } set { mvarSelectedObject = value; } }
+
+ protected override void OnShown(EventArgs e)
+ {
+ base.OnShown(e);
+ UpdateSearch();
+ }
+
+ private void UpdateSearch()
+ {
+ lv.Items.Clear();
+ foreach (TObj item in mvarAvailableObjects)
+ {
+ TRef itmr = item.MakeReference();
+ if (String.IsNullOrEmpty(txtSearch.Text.Trim()) || itmr.ShouldFilterObject(txtSearch.Text))
+ {
+ AddObjectToList(itmr);
+ }
+ }
+
+ if (lv.Items.Count == 1)
+ {
+ lv.Items[0].Selected = true;
+ }
+ lv.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
+ }
+
+ private void AddObjectToList(TRef itmr)
+ {
+ ListViewItem lvi = new ListViewItem();
+ string[] details = itmr.GetDetails();
+ lvi.Text = details[0];
+ for (int i = 1; i < details.Length; i++)
+ {
+ lvi.SubItems.Add(details[i]);
+ }
+ lvi.Tag = itmr;
+ lv.Items.Add(lvi);
+ }
+
+ private void txtSearch_TextChanged(object sender, EventArgs e)
+ {
+ UpdateSearch();
+ }
+
+ private void lv_ItemActivate(object sender, EventArgs e)
+ {
+ if (lv.SelectedItems.Count != 1) return;
+
+ mvarSelectedObject = (lv.SelectedItems[0].Tag as TRef).Create();
+ if (SelectionChanged != null) SelectionChanged(this, e);
+
+ Close();
+ }
+
+ private void txtSearch_KeyDown(object sender, KeyEventArgs e)
+ {
+ if (e.KeyCode == Keys.Enter)
+ {
+ if (lv.SelectedItems.Count != 1) return;
+
+ mvarSelectedObject = (lv.SelectedItems[0].Tag as TRef).Create();
+ if (SelectionChanged != null) SelectionChanged(this, e);
+
+ Close();
+ }
+ else if (e.KeyCode == Keys.Escape)
+ {
+ Close();
+ }
+ }
+
+ private void cmdClear_Click(object sender, EventArgs e)
+ {
+ mvarSelectedObject = null;
+ if (SelectionChanged != null) SelectionChanged(this, e);
+ Close();
+ }
+ }
+}
diff --git a/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/DataFormatOptionsDialog.resx b/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/GenericBrowserPopup.resx
similarity index 100%
rename from CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/DataFormatOptionsDialog.resx
rename to CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/GenericBrowserPopup.resx
diff --git a/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/ObjectModelBrowserPopup.Designer.cs b/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/ObjectModelBrowserPopup.Designer.cs
deleted file mode 100644
index 6476efdd..00000000
--- a/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/ObjectModelBrowserPopup.Designer.cs
+++ /dev/null
@@ -1,126 +0,0 @@
-namespace UniversalEditor.UserInterface.WindowsForms.Dialogs
-{
- partial class ObjectModelBrowserPopup
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Windows Form Designer generated code
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- this.lv = new System.Windows.Forms.ListView();
- this.chTitle = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
- this.chDescription = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
- this.chAssembly = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
- this.txtSearch = new System.Windows.Forms.TextBox();
- this.cmdClear = new System.Windows.Forms.Button();
- this.SuspendLayout();
- //
- // lv
- //
- this.lv.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.lv.BorderStyle = System.Windows.Forms.BorderStyle.None;
- this.lv.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
- this.chTitle,
- this.chDescription,
- this.chAssembly});
- this.lv.FullRowSelect = true;
- this.lv.GridLines = true;
- this.lv.HideSelection = false;
- this.lv.Location = new System.Drawing.Point(0, 26);
- this.lv.MultiSelect = false;
- this.lv.Name = "lv";
- this.lv.Size = new System.Drawing.Size(364, 183);
- this.lv.TabIndex = 3;
- this.lv.UseCompatibleStateImageBehavior = false;
- this.lv.View = System.Windows.Forms.View.Details;
- this.lv.ItemActivate += new System.EventHandler(this.lv_ItemActivate);
- this.lv.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtSearch_KeyDown);
- //
- // chTitle
- //
- this.chTitle.Text = "Title";
- //
- // chDescription
- //
- this.chDescription.Text = "Description";
- //
- // chAssembly
- //
- this.chAssembly.Text = "Assembly";
- //
- // txtSearch
- //
- this.txtSearch.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.txtSearch.BorderStyle = System.Windows.Forms.BorderStyle.None;
- this.txtSearch.Location = new System.Drawing.Point(6, 7);
- this.txtSearch.Name = "txtSearch";
- this.txtSearch.Size = new System.Drawing.Size(277, 13);
- this.txtSearch.TabIndex = 2;
- this.txtSearch.TextChanged += new System.EventHandler(this.txtSearch_TextChanged);
- this.txtSearch.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtSearch_KeyDown);
- //
- // cmdClear
- //
- this.cmdClear.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.cmdClear.FlatStyle = System.Windows.Forms.FlatStyle.System;
- this.cmdClear.Location = new System.Drawing.Point(289, 2);
- this.cmdClear.Name = "cmdClear";
- this.cmdClear.Size = new System.Drawing.Size(75, 23);
- this.cmdClear.TabIndex = 4;
- this.cmdClear.Text = "&Clear";
- this.cmdClear.UseVisualStyleBackColor = false;
- this.cmdClear.Click += new System.EventHandler(this.cmdClear_Click);
- //
- // ObjectModelBrowserPopup
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.BackColor = System.Drawing.SystemColors.Window;
- this.ClientSize = new System.Drawing.Size(364, 213);
- this.ControlBox = false;
- this.Controls.Add(this.cmdClear);
- this.Controls.Add(this.lv);
- this.Controls.Add(this.txtSearch);
- this.Name = "ObjectModelBrowserPopup";
- this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
- this.ResumeLayout(false);
- this.PerformLayout();
-
- }
-
- #endregion
-
- private System.Windows.Forms.ListView lv;
- private System.Windows.Forms.ColumnHeader chTitle;
- private System.Windows.Forms.ColumnHeader chDescription;
- private System.Windows.Forms.TextBox txtSearch;
- private System.Windows.Forms.Button cmdClear;
- private System.Windows.Forms.ColumnHeader chAssembly;
-
-
- }
-}
\ No newline at end of file
diff --git a/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/ObjectModelBrowserPopup.cs b/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/ObjectModelBrowserPopup.cs
deleted file mode 100644
index 23e434b2..00000000
--- a/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/ObjectModelBrowserPopup.cs
+++ /dev/null
@@ -1,175 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Drawing;
-using System.Text;
-using System.Windows.Forms;
-
-namespace UniversalEditor.UserInterface.WindowsForms.Dialogs
-{
- public partial class ObjectModelBrowserPopup : Form
- {
- public event EventHandler SelectionChanged;
-
- public ObjectModelBrowserPopup()
- {
- InitializeComponent();
- Font = SystemFonts.MenuFont;
- }
-
- protected override void OnDeactivate(EventArgs e)
- {
- base.OnDeactivate(e);
- this.Close();
- }
-
- private System.Collections.ObjectModel.Collection mvarObjectModels = new System.Collections.ObjectModel.Collection();
- public System.Collections.ObjectModel.Collection ObjectModels { get { return mvarObjectModels; } }
-
- private ObjectModel mvarObjectModel = null;
- public ObjectModel ObjectModel { get { return mvarObjectModel; } set { mvarObjectModel = value; } }
-
- /*
- private void documentTypeSelector1_SelectionFinalized(object sender, EventArgs e)
- {
- if (documentTypeSelector1.SelectedObject == null) return;
-
- mvarObjectModel = (documentTypeSelector1.SelectedObject as ObjectModelReference).Create();
- Close();
-
- if (SelectionChanged != null) SelectionChanged(this, e);
- }
-
- private void documentTypeSelector1_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- mvarObjectModel = (documentTypeSelector1.SelectedObject as ObjectModel);
- Close();
-
- if (SelectionChanged != null) SelectionChanged(this, e);
- }
- else if (e.KeyCode == Keys.Escape)
- {
- Close();
- }
- }
- */
-
- private string DataFormatFilterCollectionToString(DataFormatFilter.DataFormatFilterCollection collection)
- {
- StringBuilder sb = new StringBuilder();
- foreach (DataFormatFilter filter in collection)
- {
- sb.Append(StringArrayToString(filter.FileNameFilters));
- if (collection.IndexOf(filter) < collection.Count - 1)
- {
- sb.Append("; ");
- }
- }
- return sb.ToString();
- }
-
- private string StringArrayToString(System.Collections.Specialized.StringCollection collection)
- {
- StringBuilder sb = new StringBuilder();
- foreach (string s in collection)
- {
- sb.Append(s);
- if (collection.IndexOf(s) < collection.Count - 1)
- {
- sb.Append(", ");
- }
- }
- return sb.ToString();
- }
-
-
- protected override void OnShown(EventArgs e)
- {
- base.OnShown(e);
- UpdateSearch();
- }
-
- private void UpdateSearch()
- {
- lv.Items.Clear();
- foreach (ObjectModel df in mvarObjectModels)
- {
- ObjectModelReference dfr = df.MakeReference();
- if (txtSearch.Text == String.Empty)
- {
- AddObjectModelToList(dfr);
- }
- else
- {
- if (String.IsNullOrEmpty(dfr.Title)) continue;
-
- if ((dfr.Title.ToLower().Contains(txtSearch.Text.Trim().ToLower()))
- || (dfr.Description.ToLower().Contains(txtSearch.Text.Trim().ToLower())))
- {
- AddObjectModelToList(dfr);
- }
- }
- }
-
- if (lv.Items.Count == 1)
- {
- lv.Items[0].Selected = true;
- }
- lv.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
- }
-
- private void AddObjectModelToList(ObjectModelReference dfr)
- {
- ListViewItem lvi = new ListViewItem();
- lvi.Text = dfr.Title;
- lvi.SubItems.Add(dfr.Description);
- if (dfr.ObjectModelType != null)
- {
- lvi.SubItems.Add(dfr.ObjectModelType.Assembly.Location);
- }
- lvi.Tag = dfr;
- lv.Items.Add(lvi);
- }
-
- private void txtSearch_TextChanged(object sender, EventArgs e)
- {
- UpdateSearch();
- }
-
- private void lv_ItemActivate(object sender, EventArgs e)
- {
- if (lv.SelectedItems.Count != 1) return;
-
- mvarObjectModel = (lv.SelectedItems[0].Tag as ObjectModelReference).Create();
- if (SelectionChanged != null) SelectionChanged(this, e);
-
- Close();
- }
-
- private void txtSearch_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- if (lv.SelectedItems.Count != 1) return;
-
- mvarObjectModel = (lv.SelectedItems[0].Tag as ObjectModelReference).Create();
- if (SelectionChanged != null) SelectionChanged(this, e);
-
- Close();
- }
- else if (e.KeyCode == Keys.Escape)
- {
- Close();
- }
- }
-
- private void cmdClear_Click(object sender, EventArgs e)
- {
- mvarObjectModel = null;
- if (SelectionChanged != null) SelectionChanged(this, e);
- Close();
- }
- }
-}
diff --git a/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/ObjectModelBrowserPopup.resx b/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/ObjectModelBrowserPopup.resx
deleted file mode 100644
index 7080a7d1..00000000
--- a/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/ObjectModelBrowserPopup.resx
+++ /dev/null
@@ -1,120 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
\ No newline at end of file
diff --git a/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/MainWindow.cs b/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/MainWindow.cs
index 9b0faedb..b1f1c192 100644
--- a/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/MainWindow.cs
+++ b/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/MainWindow.cs
@@ -1302,7 +1302,7 @@ namespace UniversalEditor.UserInterface.WindowsForms
*/
DataFormat df = dfr.Create();
- if (!Engine.CurrentEngine.ShowDataFormatOptionsDialog(ref df, DataFormatOptionsDialogType.Export))
+ if (!Engine.CurrentEngine.ShowCustomOptionDialog(ref df, CustomOptionDialogType.Export))
{
return false;
}
diff --git a/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Pages/EditorPage.cs b/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Pages/EditorPage.cs
index c2f2d619..a0324d46 100644
--- a/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Pages/EditorPage.cs
+++ b/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Pages/EditorPage.cs
@@ -365,7 +365,7 @@ namespace UniversalEditor.UserInterface.WindowsForms.Pages
}
else
{
- if (!Engine.CurrentEngine.ShowDataFormatOptionsDialog(ref fmt, DataFormatOptionsDialogType.Import)) return;
+ if (!Engine.CurrentEngine.ShowCustomOptionDialog(ref fmt, CustomOptionDialogType.Import)) return;
Document document = new UniversalEditor.Document(objm, fmt, new FileAccessor(FileName));
document.InputAccessor.Open();
diff --git a/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/UniversalEditor.UserInterface.WindowsForms.DesktopApplication.csproj b/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/UniversalEditor.UserInterface.WindowsForms.DesktopApplication.csproj
index 194c0ee5..637f2092 100644
--- a/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/UniversalEditor.UserInterface.WindowsForms.DesktopApplication.csproj
+++ b/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/UniversalEditor.UserInterface.WindowsForms.DesktopApplication.csproj
@@ -55,24 +55,18 @@
OutputWindow.cs
+
+ Form
+
+
+ GenericBrowserPopup.cs
+
Form
CrashDialog.cs
-
- Form
-
-
- ObjectModelBrowserPopup.cs
-
-
- Form
-
-
- DataFormatBrowserPopup.cs
-
Form
@@ -104,11 +98,11 @@
DataFormatAboutDialog.cs
-
+
Form
-
- DataFormatOptionsDialog.cs
+
+ CustomOptionsDialog.cs
Form
@@ -228,20 +222,17 @@
AboutDialog.cs
+
+ GenericBrowserPopup.cs
+
CrashDialog.cs
-
- ObjectModelBrowserPopup.cs
-
DataFormatAboutDialog.cs
-
- DataFormatBrowserPopup.cs
-
-
- DataFormatOptionsDialog.cs
+
+ CustomOptionsDialog.cs
NewDialog.cs
diff --git a/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/WindowsFormsEngine.cs b/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/WindowsFormsEngine.cs
index 4cadfed3..a1fdde5c 100644
--- a/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/WindowsFormsEngine.cs
+++ b/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/WindowsFormsEngine.cs
@@ -387,7 +387,13 @@ namespace UniversalEditor.UserInterface.WindowsForms
public override void ShowAboutDialog()
{
- Dialogs.AboutDialog dlg = new AboutDialog();
+ AboutDialog dlg = new AboutDialog();
+ dlg.ShowDialog();
+ }
+ public override void ShowAboutDialog(DataFormatReference dfr)
+ {
+ DataFormatAboutDialog dlg = new DataFormatAboutDialog();
+ dlg.DataFormatReference = dfr;
dlg.ShowDialog();
}
@@ -412,9 +418,9 @@ namespace UniversalEditor.UserInterface.WindowsForms
Application.Exit();
}
- public override bool ShowDataFormatOptionsDialog(ref DataFormat df, DataFormatOptionsDialogType type)
+ public override bool ShowCustomOptionDialog(ref CustomOption.CustomOptionCollection customOptions, string title = null, EventHandler aboutButtonClicked = null)
{
- if (DataFormatOptionsDialog.ShowDialog(ref df, type) == DialogResult.Cancel)
+ if (CustomOptionDialog.ShowDialog(ref customOptions, title, aboutButtonClicked) == DialogResult.Cancel)
{
return false;
}
diff --git a/CSharp/Libraries/UniversalEditor.Core/CustomOption.cs b/CSharp/Libraries/UniversalEditor.Core/CustomOption.cs
index 524e1a4c..58958d27 100644
--- a/CSharp/Libraries/UniversalEditor.Core/CustomOption.cs
+++ b/CSharp/Libraries/UniversalEditor.Core/CustomOption.cs
@@ -15,6 +15,9 @@ namespace UniversalEditor
private bool mvarDefaultValue = false;
public bool DefaultValue { get { return mvarDefaultValue; } set { mvarDefaultValue = value; } }
+
+ private bool mvarValue = false;
+ public bool Value { get { return mvarValue; } set { mvarValue = value; } }
}
public class CustomOptionGroup : CustomOption
{
@@ -136,6 +139,9 @@ namespace UniversalEditor
private string mvarDefaultValue = String.Empty;
public string DefaultValue { get { return mvarDefaultValue; } set { mvarDefaultValue = value; } }
+
+ private string mvarValue = String.Empty;
+ public string Value { get { return mvarValue; } set { mvarValue = value; } }
}
public class CustomOptionChoice : CustomOption
{
@@ -145,7 +151,17 @@ namespace UniversalEditor
/// The title of the export option.
///
///
- public CustomOptionChoice(string propertyName, string title, bool requireChoice = false, params CustomOptionFieldChoice[] choices, bool enabled = true, bool visible = true)
+ public CustomOptionChoice(string propertyName, string title, bool requireChoice = false, params CustomOptionFieldChoice[] choices)
+ : base(propertyName, title)
+ {
+ mvarIsRadioButton = false;
+ mvarRequireChoice = requireChoice;
+ foreach (CustomOptionFieldChoice choice in choices)
+ {
+ mvarChoices.Add(choice);
+ }
+ }
+ public CustomOptionChoice(string propertyName, string title, bool requireChoice = false, bool enabled = true, bool visible = true, params CustomOptionFieldChoice[] choices)
: base(propertyName, title, enabled, visible)
{
mvarIsRadioButton = false;
@@ -182,6 +198,12 @@ namespace UniversalEditor
private CustomOptionFieldChoice.CustomOptionFieldChoiceCollection mvarChoices = new CustomOptionFieldChoice.CustomOptionFieldChoiceCollection();
public CustomOptionFieldChoice.CustomOptionFieldChoiceCollection Choices { get { return mvarChoices; } }
+
+ private CustomOptionFieldChoice mvarDefaultValue = null;
+ public CustomOptionFieldChoice DefaultValue { get { return mvarDefaultValue; } set { mvarDefaultValue = value; } }
+
+ private CustomOptionFieldChoice mvarValue = null;
+ public CustomOptionFieldChoice Value { get { return mvarValue; } set { mvarValue = value; } }
}
public class DataFormatOptionNumberSuggestedValue
@@ -222,6 +244,9 @@ namespace UniversalEditor
private decimal mvarDefaultValue = 0;
public decimal DefaultValue { get { return mvarDefaultValue; } set { mvarDefaultValue = value; } }
+ private decimal mvarValue = 0;
+ public decimal Value { get { return mvarValue; } set { mvarValue = value; } }
+
public CustomOptionNumber(string propertyName, string title, decimal defaultValue = 0, decimal? minimumValue = null, decimal? maximumValue = null, bool enabled = true, bool visible = true)
: base(propertyName, title, enabled, visible)
{
@@ -232,11 +257,22 @@ namespace UniversalEditor
}
public class CustomOptionMultipleChoice : CustomOption
{
- public CustomOptionMultipleChoice(string propertyName, string title, params CustomOptionFieldChoice[] choices, bool enabled = true, bool visible = true)
- : base(propertyName, title, enabled, visible)
+ public CustomOptionMultipleChoice(string propertyName, string title, params CustomOptionFieldChoice[] choices)
+ : base(propertyName, title)
{
}
+ public CustomOptionMultipleChoice(string propertyName, string title, bool enabled = true, bool visible = true, params CustomOptionFieldChoice[] choices)
+ : base(propertyName, title, enabled, visible)
+ {
+
+ }
+ }
+
+ public enum CustomOptionFileDialogMode
+ {
+ Open,
+ Save
}
public class CustomOptionFile : CustomOption
{
@@ -246,16 +282,18 @@ namespace UniversalEditor
private string mvarFilter = String.Empty;
public string Filter { get { return mvarFilter; } set { mvarFilter = value; } }
- private bool mvarRequireChoice = false;
- public bool RequireChoice { get { return mvarRequireChoice; } set { mvarRequireChoice = value; } }
+ private string mvarValue = String.Empty;
+ public string Value { get { return mvarValue; } set { mvarValue = value; } }
- public CustomOptionFile(string propertyName, string title, string defaultValue = "", string filter = "*.*", bool requireChoice = false, bool enabled = true, bool visible = true)
+ public CustomOptionFile(string propertyName, string title, string defaultValue = "", string filter = "*.*", bool enabled = true, bool visible = true)
: base(propertyName, title, enabled, visible)
{
mvarDefaultValue = defaultValue;
mvarFilter = filter;
- mvarRequireChoice = requireChoice;
}
+
+ private CustomOptionFileDialogMode mvarDialogMode = CustomOptionFileDialogMode.Open;
+ public CustomOptionFileDialogMode DialogMode { get { return mvarDialogMode; } set { mvarDialogMode = value; } }
}
public class CustomOptionVersion : CustomOption
{
diff --git a/CSharp/Libraries/UniversalEditor.Core/DataFormat.cs b/CSharp/Libraries/UniversalEditor.Core/DataFormat.cs
index a716842a..27d8794a 100644
--- a/CSharp/Libraries/UniversalEditor.Core/DataFormat.cs
+++ b/CSharp/Libraries/UniversalEditor.Core/DataFormat.cs
@@ -6,7 +6,7 @@ using UniversalEditor.IO;
namespace UniversalEditor
{
- public abstract class DataFormat
+ public abstract class DataFormat : References
{
internal DataFormatReference mvarReference = null;
///
diff --git a/CSharp/Libraries/UniversalEditor.Core/DataFormatReference.cs b/CSharp/Libraries/UniversalEditor.Core/DataFormatReference.cs
index 2fdd55d7..88e1e3a2 100644
--- a/CSharp/Libraries/UniversalEditor.Core/DataFormatReference.cs
+++ b/CSharp/Libraries/UniversalEditor.Core/DataFormatReference.cs
@@ -5,7 +5,7 @@ using System.Text;
namespace UniversalEditor
{
- public class DataFormatReference
+ public class DataFormatReference : ReferencedBy
{
private string mvarTitle = null;
public string Title
@@ -24,6 +24,65 @@ namespace UniversalEditor
private Type mvarDataFormatType = null;
public Type DataFormatType { get { return mvarDataFormatType; } }
+ private string DataFormatFilterCollectionToString(DataFormatFilter.DataFormatFilterCollection collection)
+ {
+ StringBuilder sb = new StringBuilder();
+ foreach (DataFormatFilter filter in collection)
+ {
+ sb.Append(StringArrayToString(filter.FileNameFilters));
+ if (collection.IndexOf(filter) < collection.Count - 1)
+ {
+ sb.Append("; ");
+ }
+ }
+ return sb.ToString();
+ }
+ private string StringArrayToString(System.Collections.Specialized.StringCollection collection)
+ {
+ StringBuilder sb = new StringBuilder();
+ foreach (string s in collection)
+ {
+ sb.Append(s);
+ if (collection.IndexOf(s) < collection.Count - 1)
+ {
+ sb.Append(", ");
+ }
+ }
+ return sb.ToString();
+ }
+
+ public string[] GetDetails()
+ {
+ string title = mvarTitle;
+ if (String.IsNullOrEmpty(mvarTitle) && mvarFilters.Count > 0)
+ {
+ title = mvarFilters[0].Title;
+ }
+ return new string[] { title, DataFormatFilterCollectionToString(mvarFilters) };
+ }
+ public bool ShouldFilterObject(string filter)
+ {
+ string title = mvarTitle;
+ if (String.IsNullOrEmpty(mvarTitle) && mvarFilters.Count > 0)
+ {
+ title = mvarFilters[0].Title;
+ }
+ if (title == null) title = String.Empty;
+ if (title.ToLower().Contains(filter.ToLower())) return true;
+
+ foreach (DataFormatFilter filter1 in mvarFilters)
+ {
+ foreach (string s in filter1.FileNameFilters)
+ {
+ if (s.ToLower().Contains(filter.ToLower()))
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
public DataFormatReference(Type dataFormatType)
{
if (!dataFormatType.IsSubclassOf(typeof(DataFormat)))
diff --git a/CSharp/Libraries/UniversalEditor.Core/ObjectModel.cs b/CSharp/Libraries/UniversalEditor.Core/ObjectModel.cs
index 6df65256..d2cee5e1 100644
--- a/CSharp/Libraries/UniversalEditor.Core/ObjectModel.cs
+++ b/CSharp/Libraries/UniversalEditor.Core/ObjectModel.cs
@@ -4,7 +4,7 @@ using System.Text;
namespace UniversalEditor
{
- public abstract class ObjectModel : ICloneable
+ public abstract class ObjectModel : ICloneable, References
{
public virtual ObjectModelReference MakeReference()
{
diff --git a/CSharp/Libraries/UniversalEditor.Core/ObjectModelReference.cs b/CSharp/Libraries/UniversalEditor.Core/ObjectModelReference.cs
index 12c591a4..5ff0879a 100644
--- a/CSharp/Libraries/UniversalEditor.Core/ObjectModelReference.cs
+++ b/CSharp/Libraries/UniversalEditor.Core/ObjectModelReference.cs
@@ -5,7 +5,7 @@ using System.Text;
namespace UniversalEditor
{
- public class ObjectModelReference
+ public class ObjectModelReference : ReferencedBy
{
public class ObjectModelReferenceCollection
: System.Collections.ObjectModel.Collection
@@ -86,6 +86,22 @@ namespace UniversalEditor
}
}
+ public string[] GetDetails()
+ {
+ return new string[] { mvarTitle, mvarDescription };
+ }
+ public bool ShouldFilterObject(string filter)
+ {
+ string title = mvarTitle;
+ if (title == null) title = String.Empty;
+
+ string description = mvarDescription;
+ if (description == null) description = String.Empty;
+
+ return ((title.ToLower().Contains(filter.Trim().ToLower()))
+ || (description.ToLower().Contains(filter.Trim().ToLower())));
+ }
+
private Type mvarObjectModelType = null;
public Type ObjectModelType { get { return mvarObjectModelType; } }
diff --git a/CSharp/Libraries/UniversalEditor.Core/UniversalEditor.Core.csproj b/CSharp/Libraries/UniversalEditor.Core/UniversalEditor.Core.csproj
index 69e7514c..78671d84 100644
--- a/CSharp/Libraries/UniversalEditor.Core/UniversalEditor.Core.csproj
+++ b/CSharp/Libraries/UniversalEditor.Core/UniversalEditor.Core.csproj
@@ -39,6 +39,7 @@
+
@@ -77,6 +78,7 @@
+
diff --git a/CSharp/Libraries/UniversalEditor.UserInterface/DataFormatOptionsDialogType.cs b/CSharp/Libraries/UniversalEditor.UserInterface/CustomOptionDialogType.cs
similarity index 79%
rename from CSharp/Libraries/UniversalEditor.UserInterface/DataFormatOptionsDialogType.cs
rename to CSharp/Libraries/UniversalEditor.UserInterface/CustomOptionDialogType.cs
index 8fe258d0..b77ffcbf 100644
--- a/CSharp/Libraries/UniversalEditor.UserInterface/DataFormatOptionsDialogType.cs
+++ b/CSharp/Libraries/UniversalEditor.UserInterface/CustomOptionDialogType.cs
@@ -5,7 +5,7 @@ using System.Text;
namespace UniversalEditor.UserInterface
{
- public enum DataFormatOptionsDialogType
+ public enum CustomOptionDialogType
{
Import,
Export
diff --git a/CSharp/Libraries/UniversalEditor.UserInterface/Engine.cs b/CSharp/Libraries/UniversalEditor.UserInterface/Engine.cs
index 94ba08e5..67e03054 100644
--- a/CSharp/Libraries/UniversalEditor.UserInterface/Engine.cs
+++ b/CSharp/Libraries/UniversalEditor.UserInterface/Engine.cs
@@ -414,8 +414,9 @@ namespace UniversalEditor.UserInterface
/// The file name(s) of the document(s) to load.
/// An representing the window that was created.
protected abstract IHostApplicationWindow OpenWindowInternal(params string[] FileNames);
-
+
public abstract void ShowAboutDialog();
+ public abstract void ShowAboutDialog(DataFormatReference dfr);
///
/// Opens a new window, optionally loading the specified documents.
@@ -1097,6 +1098,151 @@ namespace UniversalEditor.UserInterface
{
}
- public abstract bool ShowDataFormatOptionsDialog(ref DataFormat df, DataFormatOptionsDialogType dataFormatOptionsDialogType);
+ public bool ShowCustomOptionDialog(ref DataFormat df, CustomOptionDialogType type)
+ {
+ CustomOption.CustomOptionCollection coll = null;
+ DataFormatReference dfr = df.MakeReference();
+
+ if (type == CustomOptionDialogType.Export)
+ {
+ coll = dfr.ExportOptions;
+ }
+ else
+ {
+ coll = dfr.ImportOptions;
+ }
+ if (coll.Count == 0) return true;
+
+ bool retval = ShowCustomOptionDialog(ref coll, dfr.Title + " Options", delegate(object sender, EventArgs e)
+ {
+ ShowAboutDialog(dfr);
+ });
+
+ if (retval)
+ {
+ foreach (CustomOption eo in coll)
+ {
+ System.Reflection.PropertyInfo pi = dfr.DataFormatType.GetProperty(eo.PropertyName);
+ if (pi == null) continue;
+
+ if (eo is CustomOptionNumber)
+ {
+ CustomOptionNumber itm = (eo as CustomOptionNumber);
+ pi.SetValue(df, Convert.ChangeType(itm.Value, pi.PropertyType), null);
+ }
+ else if (eo is CustomOptionBoolean)
+ {
+ CustomOptionBoolean itm = (eo as CustomOptionBoolean);
+ pi.SetValue(df, Convert.ChangeType(itm.Value, pi.PropertyType), null);
+ }
+ else if (eo is CustomOptionChoice)
+ {
+ CustomOptionFieldChoice choice = (eo as CustomOptionChoice).Value;
+ if (choice != null)
+ {
+ Type[] interfaces = pi.PropertyType.GetInterfaces();
+ bool convertible = false;
+ foreach (Type t in interfaces)
+ {
+ if (t == typeof(IConvertible))
+ {
+ convertible = true;
+ break;
+ }
+ }
+ if (convertible)
+ {
+ pi.SetValue(df, Convert.ChangeType(choice.Value, pi.PropertyType), null);
+ }
+ else
+ {
+ pi.SetValue(df, choice.Value, null);
+ }
+ }
+ }
+ else if (eo is CustomOptionText)
+ {
+ CustomOptionText itm = (eo as CustomOptionText);
+ pi.SetValue(df, Convert.ChangeType(itm.Value, pi.PropertyType), null);
+ }
+ }
+
+ return true;
+ }
+ return false;
+ }
+ public bool ShowCustomOptionDialog(ref Accessor df, CustomOptionDialogType type)
+ {
+ if (df == null) return true;
+
+ CustomOption.CustomOptionCollection coll = null;
+ AccessorReference dfr = df.MakeReference();
+
+ if (type == CustomOptionDialogType.Export)
+ {
+ coll = dfr.ExportOptions;
+ }
+ else
+ {
+ coll = dfr.ImportOptions;
+ }
+ if (coll.Count == 0) return true;
+
+ bool retval = ShowCustomOptionDialog(ref coll, dfr.Title + " Options");
+
+ if (retval)
+ {
+ foreach (CustomOption eo in coll)
+ {
+ System.Reflection.PropertyInfo pi = dfr.AccessorType.GetProperty(eo.PropertyName);
+ if (pi == null) continue;
+
+ if (eo is CustomOptionNumber)
+ {
+ CustomOptionNumber itm = (eo as CustomOptionNumber);
+ pi.SetValue(df, Convert.ChangeType(itm.Value, pi.PropertyType), null);
+ }
+ else if (eo is CustomOptionBoolean)
+ {
+ CustomOptionBoolean itm = (eo as CustomOptionBoolean);
+ pi.SetValue(df, Convert.ChangeType(itm.Value, pi.PropertyType), null);
+ }
+ else if (eo is CustomOptionChoice)
+ {
+ CustomOptionFieldChoice choice = (eo as CustomOptionChoice).Value;
+ if (choice != null)
+ {
+ Type[] interfaces = pi.PropertyType.GetInterfaces();
+ bool convertible = false;
+ foreach (Type t in interfaces)
+ {
+ if (t == typeof(IConvertible))
+ {
+ convertible = true;
+ break;
+ }
+ }
+ if (convertible)
+ {
+ pi.SetValue(df, Convert.ChangeType(choice.Value, pi.PropertyType), null);
+ }
+ else
+ {
+ pi.SetValue(df, choice.Value, null);
+ }
+ }
+ }
+ else if (eo is CustomOptionText)
+ {
+ CustomOptionText itm = (eo as CustomOptionText);
+ pi.SetValue(df, Convert.ChangeType(itm.Value, pi.PropertyType), null);
+ }
+ }
+
+ return true;
+ }
+ return false;
+ }
+ public abstract bool ShowCustomOptionDialog(ref CustomOption.CustomOptionCollection customOptions, string title = null, EventHandler aboutButtonClicked = null);
}
}
diff --git a/CSharp/Libraries/UniversalEditor.UserInterface/UniversalEditor.UserInterface.csproj b/CSharp/Libraries/UniversalEditor.UserInterface/UniversalEditor.UserInterface.csproj
index 7e0e4ab9..4a300d98 100644
--- a/CSharp/Libraries/UniversalEditor.UserInterface/UniversalEditor.UserInterface.csproj
+++ b/CSharp/Libraries/UniversalEditor.UserInterface/UniversalEditor.UserInterface.csproj
@@ -59,7 +59,7 @@
-
+