Major user interface updates, may require additional testing
This commit is contained in:
parent
e1120e3b47
commit
272e632777
@ -0,0 +1,116 @@
|
||||
namespace UniversalEditor.UserInterface.WindowsForms.Dialogs
|
||||
{
|
||||
partial class CustomOptionDialog
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -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<string, Control> CustomOptionControls = new Dictionary<string, Control>();
|
||||
|
||||
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<string, Control>();
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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<DataFormat> mvarDataFormats = new System.Collections.ObjectModel.Collection<DataFormat>();
|
||||
public System.Collections.ObjectModel.Collection<DataFormat> 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,115 +0,0 @@
|
||||
namespace UniversalEditor.UserInterface.WindowsForms.Dialogs
|
||||
{
|
||||
partial class DataFormatOptionsDialog
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -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<string, Control> CustomOptionControls = new Dictionary<string, Control>();
|
||||
|
||||
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<string, Control>();
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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<ObjectModel, ObjectModelReference> dlg = new GenericBrowserPopup<ObjectModel, ObjectModelReference>();
|
||||
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<DataFormat, DataFormatReference> dlg = new GenericBrowserPopup<DataFormat, DataFormatReference>();
|
||||
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<ObjectModel, ObjectModelReference> dlg = (sender as GenericBrowserPopup<ObjectModel, ObjectModelReference>);
|
||||
mvarObjectModel = dlg.SelectedObject;
|
||||
RefreshButtons();
|
||||
}
|
||||
private void dlgDataFormat_SelectionChanged(object sender, EventArgs e)
|
||||
{
|
||||
DataFormatBrowserPopup dlg = (sender as DataFormatBrowserPopup);
|
||||
mvarDataFormat = dlg.DataFormat;
|
||||
GenericBrowserPopup<DataFormat, DataFormatReference> dlg = (sender as GenericBrowserPopup<DataFormat, DataFormatReference>);
|
||||
mvarDataFormat = dlg.SelectedObject;
|
||||
RefreshButtons();
|
||||
}
|
||||
private void dlgAccessor_SelectionChanged(object sender, EventArgs e)
|
||||
{
|
||||
GenericBrowserPopup<Accessor, AccessorReference> dlg = (sender as GenericBrowserPopup<Accessor, AccessorReference>);
|
||||
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<Accessor, AccessorReference> dlg = new GenericBrowserPopup<Accessor, AccessorReference>();
|
||||
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)
|
||||
|
||||
@ -1,33 +1,33 @@
|
||||
namespace UniversalEditor.UserInterface.WindowsForms.Dialogs
|
||||
{
|
||||
partial class DataFormatBrowserPopup
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
partial class GenericBrowserPopup<TObj, TRef>
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
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
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -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<TObj, TRef> : Form
|
||||
where TObj : class, References<TRef>
|
||||
where TRef : class, ReferencedBy<TObj>
|
||||
{
|
||||
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<TObj> mvarAvailableObjects = new System.Collections.ObjectModel.Collection<TObj>();
|
||||
public System.Collections.ObjectModel.Collection<TObj> 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,126 +0,0 @@
|
||||
namespace UniversalEditor.UserInterface.WindowsForms.Dialogs
|
||||
{
|
||||
partial class ObjectModelBrowserPopup
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
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;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@ -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<ObjectModel> mvarObjectModels = new System.Collections.ObjectModel.Collection<ObjectModel>();
|
||||
public System.Collections.ObjectModel.Collection<ObjectModel> 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,120 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -55,24 +55,18 @@
|
||||
<Compile Include="Controls\OutputWindow.Designer.cs">
|
||||
<DependentUpon>OutputWindow.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Dialogs\GenericBrowserPopup.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Dialogs\GenericBrowserPopup.Designer.cs">
|
||||
<DependentUpon>GenericBrowserPopup.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Dialogs\CrashDialog.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Dialogs\CrashDialog.Designer.cs">
|
||||
<DependentUpon>CrashDialog.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Dialogs\ObjectModelBrowserPopup.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Dialogs\ObjectModelBrowserPopup.Designer.cs">
|
||||
<DependentUpon>ObjectModelBrowserPopup.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Dialogs\DataFormatBrowserPopup.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Dialogs\DataFormatBrowserPopup.Designer.cs">
|
||||
<DependentUpon>DataFormatBrowserPopup.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Dialogs\DocumentPropertiesDialog.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
@ -104,11 +98,11 @@
|
||||
<Compile Include="Dialogs\DataFormatAboutDialog.Designer.cs">
|
||||
<DependentUpon>DataFormatAboutDialog.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Dialogs\DataFormatOptionsDialog.cs">
|
||||
<Compile Include="Dialogs\CustomOptionsDialog.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Dialogs\DataFormatOptionsDialog.Designer.cs">
|
||||
<DependentUpon>DataFormatOptionsDialog.cs</DependentUpon>
|
||||
<Compile Include="Dialogs\CustomOptionsDialog.Designer.cs">
|
||||
<DependentUpon>CustomOptionsDialog.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Dialogs\NewDialog.cs">
|
||||
<SubType>Form</SubType>
|
||||
@ -228,20 +222,17 @@
|
||||
<EmbeddedResource Include="Dialogs\AboutDialog.resx">
|
||||
<DependentUpon>AboutDialog.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Dialogs\GenericBrowserPopup.resx">
|
||||
<DependentUpon>GenericBrowserPopup.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Dialogs\CrashDialog.resx">
|
||||
<DependentUpon>CrashDialog.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Dialogs\ObjectModelBrowserPopup.resx">
|
||||
<DependentUpon>ObjectModelBrowserPopup.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Dialogs\DataFormatAboutDialog.resx">
|
||||
<DependentUpon>DataFormatAboutDialog.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Dialogs\DataFormatBrowserPopup.resx">
|
||||
<DependentUpon>DataFormatBrowserPopup.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Dialogs\DataFormatOptionsDialog.resx">
|
||||
<DependentUpon>DataFormatOptionsDialog.cs</DependentUpon>
|
||||
<EmbeddedResource Include="Dialogs\CustomOptionsDialog.resx">
|
||||
<DependentUpon>CustomOptionsDialog.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Dialogs\NewDialog.resx">
|
||||
<DependentUpon>NewDialog.cs</DependentUpon>
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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
|
||||
/// <param name="title">The title of the export option.</param>
|
||||
/// <param name="requireChoice"></param>
|
||||
/// <param name="choices"></param>
|
||||
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
|
||||
{
|
||||
|
||||
@ -6,7 +6,7 @@ using UniversalEditor.IO;
|
||||
|
||||
namespace UniversalEditor
|
||||
{
|
||||
public abstract class DataFormat
|
||||
public abstract class DataFormat : References<DataFormatReference>
|
||||
{
|
||||
internal DataFormatReference mvarReference = null;
|
||||
/// <summary>
|
||||
|
||||
@ -5,7 +5,7 @@ using System.Text;
|
||||
|
||||
namespace UniversalEditor
|
||||
{
|
||||
public class DataFormatReference
|
||||
public class DataFormatReference : ReferencedBy<DataFormat>
|
||||
{
|
||||
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)))
|
||||
|
||||
@ -4,7 +4,7 @@ using System.Text;
|
||||
|
||||
namespace UniversalEditor
|
||||
{
|
||||
public abstract class ObjectModel : ICloneable
|
||||
public abstract class ObjectModel : ICloneable, References<ObjectModelReference>
|
||||
{
|
||||
public virtual ObjectModelReference MakeReference()
|
||||
{
|
||||
|
||||
@ -5,7 +5,7 @@ using System.Text;
|
||||
|
||||
namespace UniversalEditor
|
||||
{
|
||||
public class ObjectModelReference
|
||||
public class ObjectModelReference : ReferencedBy<ObjectModel>
|
||||
{
|
||||
public class ObjectModelReferenceCollection
|
||||
: System.Collections.ObjectModel.Collection<ObjectModelReference>
|
||||
@ -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; } }
|
||||
|
||||
|
||||
@ -39,6 +39,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Accessor.cs" />
|
||||
<Compile Include="AccessorReference.cs" />
|
||||
<Compile Include="Accessors\FileAccessor.cs" />
|
||||
<Compile Include="Accessors\MemoryAccessor.cs" />
|
||||
<Compile Include="Accessors\StreamAccessor.cs" />
|
||||
@ -77,6 +78,7 @@
|
||||
<Compile Include="ObjectModelReference.cs" />
|
||||
<Compile Include="ProgressEvent.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="References.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
|
||||
@ -5,7 +5,7 @@ using System.Text;
|
||||
|
||||
namespace UniversalEditor.UserInterface
|
||||
{
|
||||
public enum DataFormatOptionsDialogType
|
||||
public enum CustomOptionDialogType
|
||||
{
|
||||
Import,
|
||||
Export
|
||||
@ -414,8 +414,9 @@ namespace UniversalEditor.UserInterface
|
||||
/// <param name="FileNames">The file name(s) of the document(s) to load.</param>
|
||||
/// <returns>An <see cref="IHostApplicationWindow"/> representing the window that was created.</returns>
|
||||
protected abstract IHostApplicationWindow OpenWindowInternal(params string[] FileNames);
|
||||
|
||||
|
||||
public abstract void ShowAboutDialog();
|
||||
public abstract void ShowAboutDialog(DataFormatReference dfr);
|
||||
|
||||
/// <summary>
|
||||
/// 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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@
|
||||
<Compile Include="CommandShortcutKey.cs" />
|
||||
<Compile Include="Common\Reflection.cs" />
|
||||
<Compile Include="ConfigurationManager.cs" />
|
||||
<Compile Include="DataFormatOptionsDialogType.cs" />
|
||||
<Compile Include="CustomOptionDialogType.cs" />
|
||||
<Compile Include="EditorReference.cs" />
|
||||
<Compile Include="Engine.cs" />
|
||||
<Compile Include="HostApplication.cs" />
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user