Add Document Properties dialog for advanced options
This commit is contained in:
parent
77ea58340f
commit
a28da99fc2
@ -1,6 +1,6 @@
|
||||
namespace UniversalEditor.UserInterface.WindowsForms.Dialogs
|
||||
{
|
||||
partial class DocumentPropertiesDialog
|
||||
partial class DocumentPropertiesDialogBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@ -39,7 +39,7 @@
|
||||
this.cmdOK = new System.Windows.Forms.Button();
|
||||
this.fraDataFormatOptions = new System.Windows.Forms.GroupBox();
|
||||
this.mnuAccessor = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.localfileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mnuAccessorLocalFile = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.fTPServerToolStripMenuItem = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.hTTPServerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.fTPServerToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
@ -161,34 +161,35 @@
|
||||
// mnuAccessor
|
||||
//
|
||||
this.mnuAccessor.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.localfileToolStripMenuItem,
|
||||
this.mnuAccessorLocalFile,
|
||||
this.fTPServerToolStripMenuItem,
|
||||
this.hTTPServerToolStripMenuItem,
|
||||
this.fTPServerToolStripMenuItem1});
|
||||
this.mnuAccessor.Name = "mnuAccessor";
|
||||
this.mnuAccessor.Size = new System.Drawing.Size(135, 76);
|
||||
this.mnuAccessor.Size = new System.Drawing.Size(153, 98);
|
||||
//
|
||||
// localfileToolStripMenuItem
|
||||
// mnuAccessorLocalFile
|
||||
//
|
||||
this.localfileToolStripMenuItem.Name = "localfileToolStripMenuItem";
|
||||
this.localfileToolStripMenuItem.Size = new System.Drawing.Size(134, 22);
|
||||
this.localfileToolStripMenuItem.Text = "&Local File";
|
||||
this.mnuAccessorLocalFile.Name = "mnuAccessorLocalFile";
|
||||
this.mnuAccessorLocalFile.Size = new System.Drawing.Size(152, 22);
|
||||
this.mnuAccessorLocalFile.Text = "&Local File";
|
||||
this.mnuAccessorLocalFile.Click += new System.EventHandler(this.mnuAccessorLocalFile_Click);
|
||||
//
|
||||
// fTPServerToolStripMenuItem
|
||||
//
|
||||
this.fTPServerToolStripMenuItem.Name = "fTPServerToolStripMenuItem";
|
||||
this.fTPServerToolStripMenuItem.Size = new System.Drawing.Size(131, 6);
|
||||
this.fTPServerToolStripMenuItem.Size = new System.Drawing.Size(149, 6);
|
||||
//
|
||||
// hTTPServerToolStripMenuItem
|
||||
//
|
||||
this.hTTPServerToolStripMenuItem.Name = "hTTPServerToolStripMenuItem";
|
||||
this.hTTPServerToolStripMenuItem.Size = new System.Drawing.Size(134, 22);
|
||||
this.hTTPServerToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
|
||||
this.hTTPServerToolStripMenuItem.Text = "&HTTP Server";
|
||||
//
|
||||
// fTPServerToolStripMenuItem1
|
||||
//
|
||||
this.fTPServerToolStripMenuItem1.Name = "fTPServerToolStripMenuItem1";
|
||||
this.fTPServerToolStripMenuItem1.Size = new System.Drawing.Size(134, 22);
|
||||
this.fTPServerToolStripMenuItem1.Size = new System.Drawing.Size(152, 22);
|
||||
this.fTPServerToolStripMenuItem1.Text = "&FTP Server";
|
||||
//
|
||||
// mnuObjectModel
|
||||
@ -226,26 +227,26 @@
|
||||
this.mnuDataFormatSelect,
|
||||
this.mnuDataFormatClear});
|
||||
this.mnuDataFormat.Name = "mnuDataFormat";
|
||||
this.mnuDataFormat.Size = new System.Drawing.Size(153, 76);
|
||||
this.mnuDataFormat.Size = new System.Drawing.Size(148, 54);
|
||||
//
|
||||
// mnuDataFormatSep1
|
||||
//
|
||||
this.mnuDataFormatSep1.Name = "mnuDataFormatSep1";
|
||||
this.mnuDataFormatSep1.Size = new System.Drawing.Size(149, 6);
|
||||
this.mnuDataFormatSep1.Size = new System.Drawing.Size(144, 6);
|
||||
//
|
||||
// mnuDataFormatSelect
|
||||
//
|
||||
this.mnuDataFormatSelect.Name = "mnuDataFormatSelect";
|
||||
this.mnuDataFormatSelect.Size = new System.Drawing.Size(152, 22);
|
||||
this.mnuDataFormatSelect.Size = new System.Drawing.Size(147, 22);
|
||||
this.mnuDataFormatSelect.Text = "&Select from List";
|
||||
//
|
||||
// mnuDataFormatClear
|
||||
//
|
||||
this.mnuDataFormatClear.Name = "mnuDataFormatClear";
|
||||
this.mnuDataFormatClear.Size = new System.Drawing.Size(152, 22);
|
||||
this.mnuDataFormatClear.Size = new System.Drawing.Size(147, 22);
|
||||
this.mnuDataFormatClear.Text = "&Clear Selection";
|
||||
//
|
||||
// DocumentPropertiesDialog
|
||||
// DocumentPropertiesDialogBase
|
||||
//
|
||||
this.AcceptButton = this.cmdOK;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
@ -261,7 +262,7 @@
|
||||
this.Controls.Add(this.txtDataFormat);
|
||||
this.Controls.Add(this.cmdObjectModel);
|
||||
this.Controls.Add(this.txtObjectModel);
|
||||
this.Name = "DocumentPropertiesDialog";
|
||||
this.Name = "DocumentPropertiesDialogBase";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Document Properties";
|
||||
this.mnuAccessor.ResumeLayout(false);
|
||||
@ -284,7 +285,7 @@
|
||||
private System.Windows.Forms.Button cmdOK;
|
||||
private System.Windows.Forms.GroupBox fraDataFormatOptions;
|
||||
private System.Windows.Forms.ContextMenuStrip mnuAccessor;
|
||||
private System.Windows.Forms.ToolStripMenuItem localfileToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuAccessorLocalFile;
|
||||
private System.Windows.Forms.ToolStripSeparator fTPServerToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem hTTPServerToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem fTPServerToolStripMenuItem1;
|
||||
|
||||
@ -4,16 +4,21 @@ using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using UniversalEditor.Accessors;
|
||||
|
||||
namespace UniversalEditor.UserInterface.WindowsForms.Dialogs
|
||||
{
|
||||
public partial class DocumentPropertiesDialog : Form
|
||||
public partial class DocumentPropertiesDialogBase : Form
|
||||
{
|
||||
public DocumentPropertiesDialog()
|
||||
public DocumentPropertiesDialogBase()
|
||||
{
|
||||
InitializeComponent();
|
||||
Font = SystemFonts.MenuFont;
|
||||
}
|
||||
|
||||
private DocumentPropertiesDialogMode mvarMode = DocumentPropertiesDialogMode.Open;
|
||||
public DocumentPropertiesDialogMode Mode { get { return mvarMode; } set { mvarMode = value; } }
|
||||
|
||||
private ObjectModel mvarObjectModel = null;
|
||||
public ObjectModel ObjectModel { get { return mvarObjectModel; } set { mvarObjectModel = value; } }
|
||||
|
||||
@ -86,14 +91,94 @@ namespace UniversalEditor.UserInterface.WindowsForms.Dialogs
|
||||
|
||||
private void RefreshButtons()
|
||||
{
|
||||
if (mvarAccessor is FileAccessor)
|
||||
{
|
||||
string filename = (mvarAccessor as FileAccessor).FileName;
|
||||
DataFormatReference[] dfrs = UniversalEditor.Common.Reflection.GetAvailableDataFormats(filename);
|
||||
|
||||
if (mvarDataFormat == null)
|
||||
{
|
||||
if (dfrs.Length > 0)
|
||||
{
|
||||
mvarDataFormat = dfrs[0].Create();
|
||||
}
|
||||
}
|
||||
|
||||
mnuDataFormat.Items.Clear();
|
||||
foreach (DataFormatReference dfr in dfrs)
|
||||
{
|
||||
ToolStripMenuItem tsmi = new ToolStripMenuItem();
|
||||
tsmi.Text = DataFormatReferenceToString(dfr);
|
||||
tsmi.Tag = dfr;
|
||||
tsmi.Click += tsmi_Click;
|
||||
if (mvarDataFormat != null)
|
||||
{
|
||||
if (mvarDataFormat.GetType() == dfr.DataFormatType)
|
||||
{
|
||||
tsmi.Checked = true;
|
||||
}
|
||||
}
|
||||
mnuDataFormat.Items.Add(tsmi);
|
||||
}
|
||||
|
||||
mnuDataFormat.Items.Add(mnuDataFormatSep1);
|
||||
mnuDataFormat.Items.Add(mnuDataFormatSelect);
|
||||
mnuDataFormat.Items.Add(mnuDataFormatClear);
|
||||
}
|
||||
if (mvarObjectModel == null)
|
||||
{
|
||||
if (mvarDataFormat != null)
|
||||
{
|
||||
ObjectModelReference[] omrs = UniversalEditor.Common.Reflection.GetAvailableObjectModels(mvarDataFormat.MakeReference());
|
||||
if (omrs.Length > 0)
|
||||
{
|
||||
mvarObjectModel = omrs[0].Create();
|
||||
}
|
||||
}
|
||||
else if (mvarAccessor is FileAccessor)
|
||||
{
|
||||
string filename = (mvarAccessor as FileAccessor).FileName;
|
||||
ObjectModelReference[] omrs = UniversalEditor.Common.Reflection.GetAvailableObjectModels(filename);
|
||||
if (omrs.Length == 1)
|
||||
{
|
||||
mvarObjectModel = omrs[0].Create();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mvarAccessor != null)
|
||||
{
|
||||
if (mvarAccessor is FileAccessor)
|
||||
{
|
||||
txtAccessor.Text = "File: " + (mvarAccessor as FileAccessor).FileName;
|
||||
}
|
||||
}
|
||||
if (mvarDataFormat != null)
|
||||
{
|
||||
DataFormatReference dfr = mvarDataFormat.MakeReference();
|
||||
txtDataFormat.Text = dfr.Title + " (" + DataFormatFilterCollectionToString(dfr.Filters) + ")";
|
||||
txtDataFormat.Text = DataFormatReferenceToString(dfr);
|
||||
}
|
||||
if (mvarObjectModel != null)
|
||||
{
|
||||
ObjectModelReference omr = mvarObjectModel.MakeReference();
|
||||
txtObjectModel.Text = omr.Title;
|
||||
}
|
||||
|
||||
cmdOK.Enabled = (mvarObjectModel != null && mvarDataFormat != null && mvarAccessor != null);
|
||||
}
|
||||
|
||||
private void tsmi_Click(object sender, EventArgs e)
|
||||
{
|
||||
ToolStripMenuItem tsmi = (sender as ToolStripMenuItem);
|
||||
mvarDataFormat = (tsmi.Tag as DataFormatReference).Create();
|
||||
RefreshButtons();
|
||||
}
|
||||
|
||||
private string DataFormatReferenceToString(DataFormatReference dfr)
|
||||
{
|
||||
return dfr.Title + " (" + DataFormatFilterCollectionToString(dfr.Filters) + ")";
|
||||
}
|
||||
|
||||
private string DataFormatFilterCollectionToString(DataFormatFilter.DataFormatFilterCollection collection)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
@ -132,5 +217,77 @@ namespace UniversalEditor.UserInterface.WindowsForms.Dialogs
|
||||
mvarDataFormat = null;
|
||||
RefreshButtons();
|
||||
}
|
||||
|
||||
private void mnuAccessorLocalFile_Click(object sender, EventArgs e)
|
||||
{
|
||||
switch (mvarMode)
|
||||
{
|
||||
case DocumentPropertiesDialogMode.Open:
|
||||
{
|
||||
OpenFileDialog ofd = new OpenFileDialog();
|
||||
if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
||||
{
|
||||
mvarAccessor = new FileAccessor(ofd.FileName);
|
||||
txtAccessor.Text = "File: " + ofd.FileName;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DocumentPropertiesDialogMode.Save:
|
||||
{
|
||||
SaveFileDialog sfd = new SaveFileDialog();
|
||||
if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
||||
{
|
||||
mvarAccessor = new FileAccessor(sfd.FileName, true, true);
|
||||
txtAccessor.Text = "File: " + sfd.FileName;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
RefreshButtons();
|
||||
}
|
||||
}
|
||||
|
||||
public enum DocumentPropertiesDialogMode
|
||||
{
|
||||
Open,
|
||||
Save
|
||||
}
|
||||
public class DocumentPropertiesDialog
|
||||
{
|
||||
private DocumentPropertiesDialogBase dlg = null;
|
||||
|
||||
private DocumentPropertiesDialogMode mvarMode = DocumentPropertiesDialogMode.Open;
|
||||
public DocumentPropertiesDialogMode Mode { get { return mvarMode; } set { mvarMode = value; } }
|
||||
|
||||
private ObjectModel mvarObjectModel = null;
|
||||
public ObjectModel ObjectModel { get { return mvarObjectModel; } set { mvarObjectModel = value; } }
|
||||
|
||||
private DataFormat mvarDataFormat = null;
|
||||
public DataFormat DataFormat { get { return mvarDataFormat; } set { mvarDataFormat = value; } }
|
||||
|
||||
private Accessor mvarAccessor = null;
|
||||
public Accessor Accessor { get { return mvarAccessor; } set { mvarAccessor = value; } }
|
||||
|
||||
public DialogResult ShowDialog()
|
||||
{
|
||||
if (dlg == null) dlg = new DocumentPropertiesDialogBase();
|
||||
if (dlg.IsDisposed) dlg = new DocumentPropertiesDialogBase();
|
||||
|
||||
dlg.Mode = mvarMode;
|
||||
dlg.ObjectModel = mvarObjectModel;
|
||||
dlg.DataFormat = mvarDataFormat;
|
||||
dlg.Accessor = mvarAccessor;
|
||||
|
||||
DialogResult result = dlg.ShowDialog();
|
||||
|
||||
if (result == DialogResult.OK)
|
||||
{
|
||||
mvarObjectModel = dlg.ObjectModel;
|
||||
mvarDataFormat = dlg.DataFormat;
|
||||
mvarAccessor = dlg.Accessor;
|
||||
return DialogResult.OK;
|
||||
}
|
||||
return DialogResult.Cancel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -604,7 +604,15 @@ namespace UniversalEditor.UserInterface.WindowsForms
|
||||
|
||||
public void OpenFile()
|
||||
{
|
||||
DocumentPropertiesDialog dlg = new DocumentPropertiesDialog();
|
||||
dlg.Mode = DocumentPropertiesDialogMode.Open;
|
||||
if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
||||
{
|
||||
OpenFile((dlg.Accessor as FileAccessor).FileName);
|
||||
}
|
||||
|
||||
// Display the Open File dialog
|
||||
/*
|
||||
using (OpenFileDialog ofd = new OpenFileDialog())
|
||||
{
|
||||
ofd.AutoUpgradeEnabled = true;
|
||||
@ -628,6 +636,7 @@ namespace UniversalEditor.UserInterface.WindowsForms
|
||||
OpenFile(ofd.FileNames);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
public void OpenFile(params string[] FileNames)
|
||||
{
|
||||
@ -1002,6 +1011,13 @@ namespace UniversalEditor.UserInterface.WindowsForms
|
||||
retrySaveFileAs:
|
||||
if (FileName == null)
|
||||
{
|
||||
DocumentPropertiesDialog dlg = new DocumentPropertiesDialog();
|
||||
if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
||||
{
|
||||
dfr = dlg.DataFormat.MakeReference();
|
||||
}
|
||||
|
||||
/*
|
||||
SaveFileDialog sfd = new SaveFileDialog();
|
||||
|
||||
List<DataFormatReference> list = new List<DataFormatReference>();
|
||||
@ -1017,8 +1033,9 @@ namespace UniversalEditor.UserInterface.WindowsForms
|
||||
dfr = list[sfd.FilterIndex - 2];
|
||||
}
|
||||
FileName = sfd.FileName;
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
if (dfr == null)
|
||||
{
|
||||
DataFormatReference[] dfrs = UniversalEditor.Common.Reflection.GetAvailableDataFormats(FileName, doc.ObjectModel.MakeReference());
|
||||
@ -1036,10 +1053,11 @@ namespace UniversalEditor.UserInterface.WindowsForms
|
||||
}
|
||||
dfr = dfrs[0];
|
||||
}
|
||||
*/
|
||||
|
||||
DataFormat df = dfr.Create();
|
||||
DataFormatOptionsDialog.ShowDialog(ref df, DataFormatOptionsDialogType.Export);
|
||||
|
||||
|
||||
#region Save Code
|
||||
NotifySaving(doc);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user