move IHostApplication core into UniversalEditor.Core

This commit is contained in:
Michael Becker 2021-03-23 14:43:23 -04:00
parent 79e8877be7
commit e167853c28
No known key found for this signature in database
GPG Key ID: 98C333A81F18C22C
16 changed files with 48 additions and 44 deletions

View File

@ -99,6 +99,9 @@
<Compile Include="Criterion.cs" />
<Compile Include="Selection.cs" />
<Compile Include="NonSerializedPropertyAttribute.cs" />
<Compile Include="UserInterface\IHostApplication.cs" />
<Compile Include="UserInterface\HostApplicationMessage.cs" />
<Compile Include="UserInterface\HostApplicationOutputWindow.cs" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
@ -109,6 +112,7 @@
</ItemGroup>
<ItemGroup>
<Folder Include="IO\Transformations\" />
<Folder Include="UserInterface\" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Accessors\FileAccessor.uexml" />

View File

@ -5,7 +5,7 @@
/// <summary>
/// Gets or sets the current window of the host application.
/// </summary>
IHostApplicationWindow CurrentWindow { get; set; }
// IHostApplicationWindow CurrentWindow { get; set; }
/// <summary>
/// Gets or sets the output window of the host application, where other plugins can read from and write to.
/// </summary>

View File

@ -28,6 +28,8 @@ using UniversalEditor.Compression;
using UniversalEditor.IO;
using UniversalEditor.DataFormats.FileSystem.ZIP.ExtraDataFields;
using MBS.Framework;
using UniversalEditor.UserInterface;
namespace UniversalEditor.DataFormats.FileSystem.ZIP
{
@ -701,6 +703,7 @@ namespace UniversalEditor.DataFormats.FileSystem.ZIP
}
reader.Seek(-5, SeekOrigin.Current);
}
((IHostApplication)Application.Instance).Messages.Add(HostApplicationMessageSeverity.Warning, "end of central directory signature not found", Accessor.GetFileName());
return -1;
}

View File

@ -149,12 +149,12 @@ namespace UniversalEditor.UserInterface.Dialogs
CriteriaResult result = e.Row.GetExtraData<CriteriaResult>("result");
if (result == null) return;
Editor editor = (Application.Instance as IHostApplication).CurrentWindow.GetCurrentEditor();
Editor editor = ((Application.Instance as UIApplication).CurrentWindow as IHostApplicationWindow).GetCurrentEditor();
if (editor == null) return;
editor.Selections.Add(editor.CreateSelection(result.Value));
(Application.Instance as IHostApplication).CurrentWindow.Present(DateTime.Now);
((Application.Instance as UIApplication).CurrentWindow as IHostApplicationWindow).Present(DateTime.Now);
}
protected override void OnKeyDown(KeyEventArgs e)

View File

@ -40,7 +40,7 @@ namespace UniversalEditor.UserInterface
{
get
{
ListViewControl lv = ((MainWindow)(Application.Instance as IHostApplication).CurrentWindow).DocumentExplorerPanel.ListView;
ListViewControl lv = ((MainWindow)(Application.Instance as UIApplication).CurrentWindow).DocumentExplorerPanel.ListView;
if (lv.SelectedRows.Count > 0)
{
return lv.SelectedRows[0].GetExtraData<EditorDocumentExplorerNode>("node");
@ -52,7 +52,7 @@ namespace UniversalEditor.UserInterface
TreeModelRow row = FindRow(value);
if (row != null)
{
ListViewControl lv = ((MainWindow)(Application.Instance as IHostApplication).CurrentWindow).DocumentExplorerPanel.ListView;
ListViewControl lv = ((MainWindow)(Application.Instance as UIApplication).CurrentWindow).DocumentExplorerPanel.ListView;
lv.SelectedRows.Clear();
lv.SelectedRows.Add(row);
@ -63,7 +63,7 @@ namespace UniversalEditor.UserInterface
private TreeModelRow FindRow(EditorDocumentExplorerNode node, TreeModelRow parent = null)
{
ListViewControl lv = ((MainWindow)(Application.Instance as IHostApplication).CurrentWindow).DocumentExplorerPanel.ListView;
ListViewControl lv = ((MainWindow)(Application.Instance as UIApplication).CurrentWindow).DocumentExplorerPanel.ListView;
TreeModelRow.TreeModelRowCollection coll = lv.Model.Rows;
if (parent != null)

View File

@ -200,7 +200,7 @@ namespace UniversalEditor.UserInterface.Editors.Database.Views
d.IsSaved = false;
d.IsChanged = true;
d.Title = "New Query";
(Application.Instance as IHostApplication).CurrentWindow.OpenFile(new Document[]
((Application.Instance as UIApplication).CurrentWindow as IHostApplicationWindow).OpenFile(new Document[]
{
d
});

View File

@ -149,7 +149,7 @@ namespace UniversalEditor.Editors.FileSystem
EmbeddedFileAccessor ma = new EmbeddedFileAccessor(f);
Document doc = new Document(ma);
doc.Saved += doc_Saved;
(Application.Instance as IHostApplication).CurrentWindow.OpenFile(doc);
((Application.Instance as UIApplication).CurrentWindow as IHostApplicationWindow)?.OpenFile(doc);
}
else if (fso is Folder)
{
@ -259,7 +259,7 @@ namespace UniversalEditor.Editors.FileSystem
if (fsom == null)
return;
Document d = (Application.Instance as IHostApplication).CurrentWindow.NewFile();
Document d = ((Application.Instance as UIApplication).CurrentWindow as IHostApplicationWindow)?.NewFile();
if (d != null)
{
BeginEdit();

View File

@ -470,50 +470,50 @@ namespace UniversalEditor.UserInterface
#region Perspective
Application.Instance.AttachCommandEventHandler("ViewPerspective1", delegate(object sender, EventArgs e)
{
(Application.Instance as IHostApplication).CurrentWindow.SwitchPerspective(1);
((Application.Instance as UIApplication).CurrentWindow as IHostApplicationWindow)?.SwitchPerspective(1);
});
Application.Instance.AttachCommandEventHandler("ViewPerspective2", delegate(object sender, EventArgs e)
{
(Application.Instance as IHostApplication).CurrentWindow.SwitchPerspective(2);
((Application.Instance as UIApplication).CurrentWindow as IHostApplicationWindow)?.SwitchPerspective(2);
});
Application.Instance.AttachCommandEventHandler("ViewPerspective3", delegate(object sender, EventArgs e)
{
(Application.Instance as IHostApplication).CurrentWindow.SwitchPerspective(3);
((Application.Instance as UIApplication).CurrentWindow as IHostApplicationWindow)?.SwitchPerspective(3);
});
Application.Instance.AttachCommandEventHandler("ViewPerspective4", delegate(object sender, EventArgs e)
{
(Application.Instance as IHostApplication).CurrentWindow.SwitchPerspective(4);
((Application.Instance as UIApplication).CurrentWindow as IHostApplicationWindow)?.SwitchPerspective(4);
});
Application.Instance.AttachCommandEventHandler("ViewPerspective5", delegate(object sender, EventArgs e)
{
(Application.Instance as IHostApplication).CurrentWindow.SwitchPerspective(5);
((Application.Instance as UIApplication).CurrentWindow as IHostApplicationWindow)?.SwitchPerspective(5);
});
Application.Instance.AttachCommandEventHandler("ViewPerspective6", delegate(object sender, EventArgs e)
{
(Application.Instance as IHostApplication).CurrentWindow.SwitchPerspective(6);
((Application.Instance as UIApplication).CurrentWindow as IHostApplicationWindow)?.SwitchPerspective(6);
});
Application.Instance.AttachCommandEventHandler("ViewPerspective7", delegate(object sender, EventArgs e)
{
(Application.Instance as IHostApplication).CurrentWindow.SwitchPerspective(7);
((Application.Instance as UIApplication).CurrentWindow as IHostApplicationWindow)?.SwitchPerspective(7);
});
Application.Instance.AttachCommandEventHandler("ViewPerspective8", delegate(object sender, EventArgs e)
{
(Application.Instance as IHostApplication).CurrentWindow.SwitchPerspective(8);
((Application.Instance as UIApplication).CurrentWindow as IHostApplicationWindow)?.SwitchPerspective(8);
});
Application.Instance.AttachCommandEventHandler("ViewPerspective9", delegate(object sender, EventArgs e)
{
(Application.Instance as IHostApplication).CurrentWindow.SwitchPerspective(9);
((Application.Instance as UIApplication).CurrentWindow as IHostApplicationWindow)?.SwitchPerspective(9);
});
#endregion
Application.Instance.AttachCommandEventHandler("ViewStartPage", delegate(object sender, EventArgs e)
{
(Application.Instance as IHostApplication).CurrentWindow.ShowStartPage();
((Application.Instance as UIApplication).CurrentWindow as IHostApplicationWindow)?.ShowStartPage();
});
Application.Instance.AttachCommandEventHandler("ViewStatusBar", delegate (object sender, EventArgs e)
{
(Application.Instance as IHostApplication).CurrentWindow.StatusBar.Visible = !(Application.Instance as IHostApplication).CurrentWindow.StatusBar.Visible;
Application.Instance.Commands["ViewStatusBar"].Checked = (Application.Instance as IHostApplication).CurrentWindow.StatusBar.Visible;
((Application.Instance as UIApplication).CurrentWindow as IHostApplicationWindow).StatusBar.Visible = !((Application.Instance as UIApplication).CurrentWindow as IHostApplicationWindow).StatusBar.Visible;
Application.Instance.Commands["ViewStatusBar"].Checked = ((Application.Instance as UIApplication).CurrentWindow as IHostApplicationWindow).StatusBar.Visible;
});
#endregion

View File

@ -67,11 +67,11 @@ namespace UniversalEditor.UserInterface.Panels
private void cmdCreateNewProject_Click(object sender, EventArgs e)
{
(Application.Instance as IHostApplication).CurrentWindow?.NewProject();
((Application.Instance as UIApplication).CurrentWindow as IHostApplicationWindow)?.NewProject();
}
private void cmdOpenExistingProject_Click(object sender, EventArgs e)
{
(Application.Instance as IHostApplication).CurrentWindow?.OpenProject();
((Application.Instance as UIApplication).CurrentWindow as IHostApplicationWindow)?.OpenProject();
}
}
}

View File

@ -301,7 +301,7 @@ namespace UniversalEditor.UserInterface.Panels
Accessors.MemoryAccessor ma = new Accessors.MemoryAccessor(new byte[0], String.Format("{0} Properties", project.Title));
Document d = new Document(project, null, ma);
d.Title = String.Format("{0} Properties", project.Title);
(Application.Instance as IHostApplication).CurrentWindow.OpenFile(d);
((Application.Instance as UIApplication).CurrentWindow as IHostApplicationWindow).OpenFile(d);
}
else if (file != null)
{

View File

@ -62,10 +62,7 @@
<Compile Include="CustomOptionDialogType.cs" />
<Compile Include="EditorReference.cs" />
<Compile Include="Engine.cs" />
<Compile Include="HostApplicationMessage.cs" />
<Compile Include="HostApplicationOutputWindow.cs" />
<Compile Include="Editor.cs" />
<Compile Include="IHostApplicationWindow.cs" />
<Compile Include="ObjectModelChangingEvent.cs" />
<Compile Include="Perspective.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
@ -132,10 +129,10 @@
<Compile Include="PrintHandlers\FileSystemPrintHandler.cs" />
<Compile Include="IDocumentPropertiesProvider.cs" />
<Compile Include="EditorApplication.cs" />
<Compile Include="IHostApplication.cs" />
<Compile Include="Controls\PrintDialogOptionsTabPage.cs" />
<Compile Include="Editors\Database\Dialogs\ColumnPropertiesDialog.cs" />
<Compile Include="Pages\StartPage.cs" />
<Compile Include="IHostApplicationWindow.cs" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">

View File

@ -39,7 +39,7 @@ namespace UniversalEditor.Plugins.Multimedia.UserInterface.Collaboration
Context = new UIContext(new Guid("{262a622c-c9e3-458b-8fbb-49cf9258b05d}"), "Multimedia Collaboration Plugin");
Context.AttachCommandEventHandler("Collaboration_Tracking_Track", delegate (object sender, EventArgs e)
{
Editor editor = (Application.Instance as IHostApplication).CurrentWindow.GetCurrentEditor();
Editor editor = ((Application.Instance as UIApplication).CurrentWindow as IHostApplicationWindow)?.GetCurrentEditor();
Document d = editor?.Document;
if (d != null)
{
@ -74,7 +74,7 @@ namespace UniversalEditor.Plugins.Multimedia.UserInterface.Collaboration
});
Context.AttachCommandEventHandler("Collaboration_Tracking_PreviousChange", delegate (object sender, EventArgs e)
{
Editor editor = (Application.Instance as IHostApplication).CurrentWindow.GetCurrentEditor();
Editor editor = ((Application.Instance as UIApplication).CurrentWindow as IHostApplicationWindow)?.GetCurrentEditor();
Document d = editor?.Document;
if (d == null)
return;
@ -113,7 +113,7 @@ namespace UniversalEditor.Plugins.Multimedia.UserInterface.Collaboration
});
Context.AttachCommandEventHandler("Collaboration_Tracking_NextChange", delegate (object sender, EventArgs e)
{
Editor editor = (Application.Instance as IHostApplication).CurrentWindow.GetCurrentEditor();
Editor editor = ((Application.Instance as UIApplication).CurrentWindow as IHostApplicationWindow)?.GetCurrentEditor();
Document d = editor?.Document;
if (d == null)
return;
@ -154,7 +154,7 @@ namespace UniversalEditor.Plugins.Multimedia.UserInterface.Collaboration
private SynthesizedAudioCommandChange.SynthesizedAudioCommandChangeCollection GetChangedCommandsList()
{
Editor editor = (Application.Instance as IHostApplication).CurrentWindow.GetCurrentEditor();
Editor editor = ((Application.Instance as UIApplication).CurrentWindow as IHostApplicationWindow)?.GetCurrentEditor();
Document d = editor?.Document;
if (d == null)
return null;
@ -172,7 +172,7 @@ namespace UniversalEditor.Plugins.Multimedia.UserInterface.Collaboration
private void ed_PianoRoll_NoteInserted(object sender, NoteEventArgs e)
{
Editor editor = (Application.Instance as IHostApplication).CurrentWindow.GetCurrentEditor();
Editor editor = ((Application.Instance as UIApplication).CurrentWindow as IHostApplicationWindow)?.GetCurrentEditor();
Document d = editor?.Document;
CollaborationPlugin plugin = (UserInterfacePlugin.Get(new Guid("{981d54ae-dee6-47c7-bea6-20890b3baa23}")) as CollaborationPlugin);
CollaborationSettings collab = plugin.GetCollaborationSettings(d);
@ -189,7 +189,7 @@ namespace UniversalEditor.Plugins.Multimedia.UserInterface.Collaboration
private void ed_PianoRoll_NoteDeleted(object sender, NoteEventArgs e)
{
Editor editor = (Application.Instance as IHostApplication).CurrentWindow.GetCurrentEditor();
Editor editor = ((Application.Instance as UIApplication).CurrentWindow as IHostApplicationWindow)?.GetCurrentEditor();
Document d = editor?.Document;
CollaborationPlugin plugin = (UserInterfacePlugin.Get(new Guid("{981d54ae-dee6-47c7-bea6-20890b3baa23}")) as CollaborationPlugin);
CollaborationSettings collab = plugin.GetCollaborationSettings(d);
@ -215,7 +215,7 @@ namespace UniversalEditor.Plugins.Multimedia.UserInterface.Collaboration
{
get
{
Editor editor = (Application.Instance as IHostApplication).CurrentWindow.GetCurrentEditor();
Editor editor = ((Application.Instance as UIApplication).CurrentWindow as IHostApplicationWindow)?.GetCurrentEditor();
Document d = editor?.Document;
CollaborationPlugin plugin = (UserInterfacePlugin.Get(new Guid("{981d54ae-dee6-47c7-bea6-20890b3baa23}")) as CollaborationPlugin);
CollaborationSettings collab = plugin.GetCollaborationSettings(d);
@ -223,7 +223,7 @@ namespace UniversalEditor.Plugins.Multimedia.UserInterface.Collaboration
}
set
{
Editor editor = (Application.Instance as IHostApplication).CurrentWindow.GetCurrentEditor();
Editor editor = ((Application.Instance as UIApplication).CurrentWindow as IHostApplicationWindow)?.GetCurrentEditor();
Document d = editor?.Document;
CollaborationPlugin plugin = (UserInterfacePlugin.Get(new Guid("{981d54ae-dee6-47c7-bea6-20890b3baa23}")) as CollaborationPlugin);
CollaborationSettings collab = plugin.GetCollaborationSettings(d);
@ -234,7 +234,7 @@ namespace UniversalEditor.Plugins.Multimedia.UserInterface.Collaboration
private void ed_PianoRoll_Paint(object sender, PaintEventArgs e)
{
// painting is handled by PianoRoll._vp, not PianoRollView!!!
SynthesizedAudioEditor editor = (Application.Instance as IHostApplication).CurrentWindow.GetCurrentEditor() as SynthesizedAudioEditor;
SynthesizedAudioEditor editor = ((Application.Instance as UIApplication).CurrentWindow as IHostApplicationWindow)?.GetCurrentEditor() as SynthesizedAudioEditor;
CollaborationPlugin plugin = (UserInterfacePlugin.Get(new Guid("{981d54ae-dee6-47c7-bea6-20890b3baa23}")) as CollaborationPlugin);
CollaborationSettings collab = plugin.GetCollaborationSettings();
@ -254,7 +254,7 @@ namespace UniversalEditor.Plugins.Multimedia.UserInterface.Collaboration
private void ed_PianoRoll_NoteRendered(object sender, NoteRenderedEventArgs e)
{
Editor editor = (Application.Instance as IHostApplication).CurrentWindow.GetCurrentEditor();
Editor editor = ((Application.Instance as UIApplication).CurrentWindow as IHostApplicationWindow)?.GetCurrentEditor();
Document d = editor?.Document;
CollaborationPlugin plugin = (UserInterfacePlugin.Get(new Guid("{981d54ae-dee6-47c7-bea6-20890b3baa23}")) as CollaborationPlugin);
CollaborationSettings collab = plugin.GetCollaborationSettings(d);

View File

@ -43,14 +43,14 @@ namespace UniversalEditor.Plugins.AutoSave
{
Console.WriteLine("autosave: looking for dirty documents...");
IHostApplication ha = (Application.Instance as IHostApplication);
UIApplication ha = (Application.Instance as UIApplication);
string path = System.IO.Path.Combine(new string[] { GetAutosavePath(), DateTime.Now.ToString("yyyyMMdd") });
Console.WriteLine("autosave: saving dirty documents in /tmp/autosave/universal-editor/...");
for (int i = 0; i < ha.CurrentWindow.Editors.Count; i++)
for (int i = 0; i < (ha.CurrentWindow as IHostApplicationWindow).Editors.Count; i++)
{
Editor ed = ha.CurrentWindow.Editors[i];
Editor ed = (ha.CurrentWindow as IHostApplicationWindow).Editors[i];
if (ed.Changed || !ed.Document.IsSaved)
{
string filename = System.IO.Path.Combine(new string[] { path, String.Format("{0}{1}.tmp", DateTime.Now.ToString("HHmmss"), i.ToString().PadLeft(2, '0')) });

View File

@ -34,7 +34,7 @@ namespace UniversalEditor.Plugins.Collaboration
{
if (document == null)
{
document = (Application.Instance as IHostApplication).CurrentWindow?.GetCurrentEditor()?.Document;
document = ((Application.Instance as UIApplication).CurrentWindow as IHostApplicationWindow)?.GetCurrentEditor()?.Document;
}
if (!_CollaborationSettings.ContainsKey(document))
@ -50,7 +50,7 @@ namespace UniversalEditor.Plugins.Collaboration
Context = new UIContext(ID, "Collaboration Plugin");
Context.AttachCommandEventHandler("Collaboration_Tracking_Track", delegate (object sender, EventArgs e)
{
Editor editor = (Application.Instance as IHostApplication).CurrentWindow.GetCurrentEditor();
Editor editor = ((Application.Instance as UIApplication).CurrentWindow as IHostApplicationWindow)?.GetCurrentEditor();
Document d = editor?.Document;
if (d != null)
{
@ -66,7 +66,7 @@ namespace UniversalEditor.Plugins.Collaboration
{
base.UpdateMenuItemsInternal();
Editor ed = (Application.Instance as IHostApplication).CurrentWindow?.GetCurrentEditor();
Editor ed = ((Application.Instance as UIApplication).CurrentWindow as IHostApplicationWindow)?.GetCurrentEditor();
// not sure why this is registered (in Plugins/UniversalEditor.Plugins.Collaboration/Commands/Review.uexml) as a global command, but whatever
Application.Instance.Commands["Collaboration_Comments_New"].Enabled = ed != null;