From e71c0f0e3c1a8c8b4036cfe42f21b912f459264a Mon Sep 17 00:00:00 2001 From: alcexhim Date: Tue, 24 Jun 2014 15:43:45 -0400 Subject: [PATCH] Implemented more commands, made some stuff more cross-platform and implemented languages --- .../Controls/SolutionExplorer.cs | 2 +- .../Dialogs/SessionDialog.cs | 10 +- .../MainWindow.Designer.cs | 41 ---- .../MainWindow.cs | 24 +- .../Pages/StartPage.cs | 2 +- .../WindowsFormsEngine.cs | 71 +----- .../UniversalEditor.UserInterface/Engine.cs | 217 ++++++++++++++++-- .../IHostApplicationWindow.cs | 17 ++ .../UniversalEditor.UserInterface/Language.cs | 51 ++++ .../UniversalEditor.UserInterface.csproj | 3 +- 10 files changed, 297 insertions(+), 141 deletions(-) create mode 100644 CSharp/Libraries/UniversalEditor.UserInterface/Language.cs diff --git a/CSharp/Environments/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Controls/SolutionExplorer.cs b/CSharp/Environments/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Controls/SolutionExplorer.cs index 894a0914..6a55f5a0 100644 --- a/CSharp/Environments/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Controls/SolutionExplorer.cs +++ b/CSharp/Environments/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Controls/SolutionExplorer.cs @@ -269,7 +269,7 @@ namespace UniversalEditor.UserInterface.WindowsForms.Controls ToolStripMenuItem tsmi = (sender as ToolStripMenuItem); ProjectTypeItemShortcut its = (tsmi.Tag as ProjectTypeItemShortcut); - WindowsFormsEngine.LastWindow.NewFile(); + Engine.CurrentEngine.Commands["FileNewDocument"].Execute(); } private void mnuContextAddNewProject_Click(object sender, EventArgs e) diff --git a/CSharp/Environments/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/SessionDialog.cs b/CSharp/Environments/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/SessionDialog.cs index 90f4e359..7a6187a1 100644 --- a/CSharp/Environments/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/SessionDialog.cs +++ b/CSharp/Environments/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/SessionDialog.cs @@ -46,7 +46,7 @@ namespace UniversalEditor.UserInterface.WindowsForms.Dialogs this.Close(); WindowsFormsEngine.SessionLoading = true; - WindowsFormsEngine.CloseAllWindows(); + Engine.CurrentEngine.CloseAllWindows(); SessionManager.Session session = (lv.SelectedItems[0].Data as SessionManager.Session); @@ -62,7 +62,7 @@ namespace UniversalEditor.UserInterface.WindowsForms.Dialogs filenames.Add(wnd, window.FileNames.ToArray()); wnd.Show(); - WindowsFormsEngine.Windows.Add(wnd); + Engine.CurrentEngine.Windows.Add(wnd); } foreach (KeyValuePair fkvp in filenames) @@ -78,7 +78,7 @@ namespace UniversalEditor.UserInterface.WindowsForms.Dialogs SessionManager.Session session = new SessionManager.Session(); session.Title = txtSessionName.Text; - foreach (MainWindow wnd in WindowsFormsEngine.Windows) + foreach (MainWindow wnd in Engine.CurrentEngine.Windows) { SessionManager.Window window = new SessionManager.Window(); window.Left = wnd.Left; @@ -123,8 +123,8 @@ namespace UniversalEditor.UserInterface.WindowsForms.Dialogs if (MessageBox.Show("Would you like to close all active windows and start a new session at this time?", "Close Session", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { WindowsFormsEngine.SessionLoading = true; - WindowsFormsEngine.CloseAllWindows(); - WindowsFormsEngine.OpenWindow(); + Engine.CurrentEngine.CloseAllWindows(); + Engine.CurrentEngine.OpenWindow(); WindowsFormsEngine.SessionLoading = false; } } diff --git a/CSharp/Environments/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/MainWindow.Designer.cs b/CSharp/Environments/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/MainWindow.Designer.cs index 7546b6dc..37b1d2b0 100644 --- a/CSharp/Environments/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/MainWindow.Designer.cs +++ b/CSharp/Environments/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/MainWindow.Designer.cs @@ -383,47 +383,6 @@ namespace UniversalEditor.UserInterface.WindowsForms this.mnuFileSaveAll.Text = "A&ll Files and Projects"; this.mnuFileSaveAll.Click += new System.EventHandler(this.FileSaveAll_Click); // - // mnuFileClose - // - this.mnuFileClose.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.mnuFileCloseFile, - this.mnuFileCloseProject, - this.toolStripMenuItem11, - this.mnuFileCloseWindow}); - this.mnuFileClose.Name = "mnuFileClose"; - this.mnuFileClose.Size = new System.Drawing.Size(156, 22); - this.mnuFileClose.Text = "&Close"; - // - // mnuFileCloseFile - // - this.mnuFileCloseFile.Name = "mnuFileCloseFile"; - this.mnuFileCloseFile.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.W))); - this.mnuFileCloseFile.Size = new System.Drawing.Size(237, 22); - this.mnuFileCloseFile.Text = "&File"; - this.mnuFileCloseFile.Click += new System.EventHandler(this.FileCloseFile_Click); - // - // mnuFileCloseProject - // - this.mnuFileCloseProject.Name = "mnuFileCloseProject"; - this.mnuFileCloseProject.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) - | System.Windows.Forms.Keys.W))); - this.mnuFileCloseProject.Size = new System.Drawing.Size(237, 22); - this.mnuFileCloseProject.Text = "&Project/Solution"; - this.mnuFileCloseProject.Click += new System.EventHandler(this.FileCloseProject_Click); - // - // toolStripMenuItem11 - // - this.toolStripMenuItem11.Name = "toolStripMenuItem11"; - this.toolStripMenuItem11.Size = new System.Drawing.Size(234, 6); - // - // mnuFileCloseWindow - // - this.mnuFileCloseWindow.Name = "mnuFileCloseWindow"; - this.mnuFileCloseWindow.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Alt | System.Windows.Forms.Keys.F4))); - this.mnuFileCloseWindow.Size = new System.Drawing.Size(237, 22); - this.mnuFileCloseWindow.Text = "&Window"; - this.mnuFileCloseWindow.Click += new System.EventHandler(this.mnuFileCloseWindow_Click); - // // mnuFileSep1 // this.mnuFileSep1.Name = "mnuFileSep1"; diff --git a/CSharp/Environments/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/MainWindow.cs b/CSharp/Environments/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/MainWindow.cs index adff2652..2122ce85 100644 --- a/CSharp/Environments/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/MainWindow.cs +++ b/CSharp/Environments/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/MainWindow.cs @@ -17,6 +17,8 @@ namespace UniversalEditor.UserInterface.WindowsForms { public partial class MainWindow : AwesomeControls.Window, IHostApplicationWindow { + public event EventHandler WindowClosed; + #region Docking Windows private Controls.ErrorList pnlErrorList = new Controls.ErrorList(); private DockingWindow dwErrorList = null; @@ -103,7 +105,7 @@ namespace UniversalEditor.UserInterface.WindowsForms ToolStripMenuItem tsmi = new ToolStripMenuItem(); tsmi.Click += tsmiCommand_Click; tsmi.Tag = cmd; - tsmi.Text = cmd.Title; + tsmi.Text = cmd.Title.Replace("_", "&"); foreach (CommandItem item1 in cmd.Items) { LoadCommandBarItem(item1, tsmi); @@ -1413,9 +1415,9 @@ namespace UniversalEditor.UserInterface.WindowsForms protected override void OnClosed(EventArgs e) { base.OnClosed(e); - if (WindowsFormsEngine.Windows.Contains(this)) WindowsFormsEngine.Windows.Remove(this); + if (WindowClosed != null) WindowClosed(this, e); - if (!WindowsFormsEngine.SessionLoading && WindowsFormsEngine.Windows.Count == 0) + if (!WindowsFormsEngine.SessionLoading && Engine.CurrentEngine.Windows.Count == 0) { Application.Exit(); } @@ -1703,12 +1705,20 @@ namespace UniversalEditor.UserInterface.WindowsForms cbc.ShowCustomizeDialog(); } - private OptionsDialog dlgOptions = null; private void ToolsOptions_Click(object sender, EventArgs e) + { + } + + private OptionsDialog dlgOptions = null; + public bool ShowOptionsDialog() { if (dlgOptions == null) dlgOptions = new OptionsDialog(); if (dlgOptions.IsDisposed) dlgOptions = new OptionsDialog(); - dlgOptions.ShowDialog(); + if (dlgOptions.ShowDialog() == System.Windows.Forms.DialogResult.OK) + { + return true; + } + return false; } protected override void OnShown(EventArgs e) @@ -1723,7 +1733,7 @@ namespace UniversalEditor.UserInterface.WindowsForms protected override void OnActivated(EventArgs e) { base.OnActivated(e); - WindowsFormsEngine.LastWindow = this; + Engine.CurrentEngine.LastWindow = this; HostApplication.CurrentWindow = this; } @@ -1793,7 +1803,7 @@ namespace UniversalEditor.UserInterface.WindowsForms private void mnuWindowNewWindow_Click(object sender, EventArgs e) { - WindowsFormsEngine.OpenWindow(); + Engine.CurrentEngine.OpenWindow(); } private void cboAddress_KeyDown(object sender, KeyEventArgs e) diff --git a/CSharp/Environments/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Pages/StartPage.cs b/CSharp/Environments/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Pages/StartPage.cs index f6937430..0a5371ef 100644 --- a/CSharp/Environments/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Pages/StartPage.cs +++ b/CSharp/Environments/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Pages/StartPage.cs @@ -63,7 +63,7 @@ namespace UniversalEditor.UserInterface.WindowsForms.Pages } return; } - WindowsFormsEngine.OpenFile(lvRecent.SelectedItems[0].TooltipText); + Engine.CurrentEngine.OpenFile(lvRecent.SelectedItems[0].TooltipText); } } } diff --git a/CSharp/Environments/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/WindowsFormsEngine.cs b/CSharp/Environments/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/WindowsFormsEngine.cs index 47357465..bdd8402a 100644 --- a/CSharp/Environments/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/WindowsFormsEngine.cs +++ b/CSharp/Environments/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/WindowsFormsEngine.cs @@ -18,11 +18,6 @@ namespace UniversalEditor.UserInterface.WindowsForms internal class WindowsFormsEngine : Engine { - internal static MainWindow LastWindow = null; - - private static List mvarWindows = new List(); - public static List Windows { get { return mvarWindows; } } - private static SplashScreenWindow splasher = null; public static bool SessionLoading = false; @@ -31,49 +26,6 @@ namespace UniversalEditor.UserInterface.WindowsForms { base.AfterInitialization(); - #region File - Commands["FileNewDocument"].Executed += delegate(object sender, EventArgs e) - { - LastWindow.NewFile(); - }; - Commands["FileNewProject"].Executed += delegate(object sender, EventArgs e) - { - LastWindow.NewProject(); - }; - Commands["FileOpenDocument"].Executed += delegate(object sender, EventArgs e) - { - LastWindow.OpenFile(); - }; - Commands["FileOpenProject"].Executed += delegate(object sender, EventArgs e) - { - LastWindow.OpenProject(); - }; - Commands["FileSaveDocument"].Executed += delegate(object sender, EventArgs e) - { - LastWindow.SaveFile(); - }; - Commands["FileSaveDocumentAs"].Executed += delegate(object sender, EventArgs e) - { - LastWindow.SaveFileAs(); - }; - Commands["FileSaveProject"].Executed += delegate(object sender, EventArgs e) - { - LastWindow.SaveProject(); - }; - Commands["FileSaveProjectAs"].Executed += delegate(object sender, EventArgs e) - { - LastWindow.SaveProjectAs(); - }; - Commands["FileSaveAll"].Executed += delegate(object sender, EventArgs e) - { - LastWindow.SaveAll(); - }; - Commands["FileCloseDocument"].Executed += delegate(object sender, EventArgs e) - { - LastWindow.CloseFile(); - }; - #endregion - Commands["HelpLicensingAndActivation"].Executed += delegate(object sender, EventArgs e) { MessageBox.Show("This product has already been activated.", "Licensing and Activation", MessageBoxButtons.OK, MessageBoxIcon.Information); @@ -426,11 +378,7 @@ namespace UniversalEditor.UserInterface.WindowsForms } } - public static void OpenFile(params string[] FileNames) - { - LastWindow.OpenFile(FileNames); - } - public static void OpenWindow(params string[] FileNames) + public override void OpenWindow(params string[] FileNames) { MainWindow mw = new MainWindow(); @@ -440,10 +388,10 @@ namespace UniversalEditor.UserInterface.WindowsForms } mw.Show(); - mvarWindows.Add(mw); + Windows.Add(mw); } - public static void ExitApplication() + public override void ExitApplication() { if (LocalConfiguration.ConfirmExit) { @@ -454,18 +402,5 @@ namespace UniversalEditor.UserInterface.WindowsForms } Application.Exit(); } - - public static void CloseAllWindows() - { - List windowsToClose = new List(); - foreach (MainWindow window in mvarWindows) - { - windowsToClose.Add(window); - } - foreach (MainWindow window in windowsToClose) - { - window.Close(); - } - } } } diff --git a/CSharp/Libraries/UniversalEditor.UserInterface/Engine.cs b/CSharp/Libraries/UniversalEditor.UserInterface/Engine.cs index 96c6e7d4..6c1a57d6 100644 --- a/CSharp/Libraries/UniversalEditor.UserInterface/Engine.cs +++ b/CSharp/Libraries/UniversalEditor.UserInterface/Engine.cs @@ -61,12 +61,98 @@ namespace UniversalEditor.UserInterface return m_AvailableEngines; } - protected virtual void BeforeInitialization() - { - } - protected virtual void AfterInitialization() - { - } + public bool AttachCommandEventHandler(string commandID, EventHandler handler) + { + Command cmd = Commands[commandID]; + if (cmd != null) + { + cmd.Executed += handler; + return true; + } + Console.WriteLine("attempted to attach handler for unknown command '" + commandID + "'"); + return false; + } + + protected virtual void BeforeInitialization() + { + } + protected virtual void AfterInitialization() + { + // Initialize all the commands that are common to UniversalEditor + #region File + AttachCommandEventHandler("FileNewDocument", delegate(object sender, EventArgs e) + { + LastWindow.NewFile(); + }); + AttachCommandEventHandler("FileNewProject", delegate(object sender, EventArgs e) + { + LastWindow.NewProject(); + }); + AttachCommandEventHandler("FileOpenDocument", delegate(object sender, EventArgs e) + { + LastWindow.OpenFile(); + }); + AttachCommandEventHandler("FileOpenProject", delegate(object sender, EventArgs e) + { + LastWindow.OpenProject(); + }); + AttachCommandEventHandler("FileSaveDocument", delegate(object sender, EventArgs e) + { + LastWindow.SaveFile(); + }); + AttachCommandEventHandler("FileSaveDocumentAs", delegate(object sender, EventArgs e) + { + LastWindow.SaveFileAs(); + }); + AttachCommandEventHandler("FileSaveProject", delegate(object sender, EventArgs e) + { + LastWindow.SaveProject(); + }); + AttachCommandEventHandler("FileSaveProjectAs", delegate(object sender, EventArgs e) + { + LastWindow.SaveProjectAs(); + }); + AttachCommandEventHandler("FileSaveAll", delegate(object sender, EventArgs e) + { + LastWindow.SaveAll(); + }); + AttachCommandEventHandler("FileCloseDocument", delegate(object sender, EventArgs e) + { + LastWindow.CloseFile(); + }); + AttachCommandEventHandler("FileExit", delegate(object sender, EventArgs e) + { + ExitApplication(); + }); + #endregion + #region Tools + // ToolsOptions should actually be under the Edit menu as "Preferences" on Linux systems + AttachCommandEventHandler("ToolsOptions", delegate(object sender, EventArgs e) + { + LastWindow.ShowOptionsDialog(); + }); + #endregion + } + + public virtual void ExitApplication() + { + } + + private IHostApplicationWindowCollection mvarWindows = new IHostApplicationWindowCollection(); + public IHostApplicationWindowCollection Windows { get { return mvarWindows; } } + + public void CloseAllWindows() + { + List windowsToClose = new List(); + foreach (IHostApplicationWindow window in mvarWindows) + { + windowsToClose.Add(window); + } + foreach (IHostApplicationWindow window in windowsToClose) + { + window.CloseWindow(); + } + } public static bool Execute() { @@ -93,6 +179,18 @@ namespace UniversalEditor.UserInterface /// The commands defined for this application. /// public Command.CommandCollection Commands { get { return mvarCommands; } } + + private Language mvarDefaultLanguage = null; + /// + /// The default used to display translatable text in this application. + /// + public Language DefaultLanguage { get { return mvarDefaultLanguage; } set { mvarDefaultLanguage = value; } } + + private Language.LanguageCollection mvarLanguages = new Language.LanguageCollection(); + /// + /// The languages defined for this application. Translations can be added through XML files in the ~/Languages folder. + /// + public Language.LanguageCollection Languages { get { return mvarLanguages; } } private EngineMainMenu mvarMainMenu = new EngineMainMenu(); /// @@ -135,6 +233,19 @@ namespace UniversalEditor.UserInterface private IHostApplicationWindow mvarLastWindow = null; public IHostApplicationWindow LastWindow { get { return mvarLastWindow; } set { mvarLastWindow = value; } } + public void OpenFile(params string[] FileNames) + { + LastWindow.OpenFile(FileNames); + } + /// + /// Opens a new window, optionally loading the specified documents. + /// + /// The file name(s) of the document(s) to load. + public virtual void OpenWindow(params string[] FileNames) + { + + } + // UniversalDataStorage.Editor.WindowsForms.Program private void SingleInstanceManager_Callback(object sender, SingleInstanceManager.InstanceCallbackEventArgs e) { @@ -189,14 +300,14 @@ namespace UniversalEditor.UserInterface cmd.ID = attID.Value; MarkupAttribute attTitle = tagCommand.Attributes["Title"]; - if (attTitle != null) - { - cmd.Title = attTitle.Value; - } - else - { - cmd.Title = cmd.ID; - } + if (attTitle != null) + { + cmd.Title = attTitle.Value; + } + else + { + cmd.Title = cmd.ID; + } MarkupTagElement tagItems = (tagCommand.Elements["Items"] as MarkupTagElement); if (tagItems != null) @@ -221,8 +332,80 @@ namespace UniversalEditor.UserInterface if (tagItem == null) continue; InitializeMainMenuItem(tagItem, null); } - + + MarkupTagElement tagLanguages = (mvarRawMarkup.FindElement("UniversalEditor", "Application", "Languages") as MarkupTagElement); + foreach (MarkupElement elLanguage in tagLanguages.Elements) + { + MarkupTagElement tagLanguage = (elLanguage as MarkupTagElement); + if (tagLanguage == null) continue; + if (tagLanguage.FullName != "Language") continue; + InitializeLanguage(tagLanguage); + } + + MarkupAttribute attDefaultLanguageID = tagLanguages.Attributes["DefaultLanguageID"]; + if (attDefaultLanguageID != null) + { + mvarDefaultLanguage = mvarLanguages[attDefaultLanguageID.Value]; + } #endregion + + if (mvarDefaultLanguage != null) + { + foreach (Command cmd in mvarCommands) + { + cmd.Title = mvarDefaultLanguage.GetCommandTitle(cmd.ID, cmd.ID); + } + } + } + + private void InitializeLanguage(MarkupTagElement tag) + { + Language lang = new Language(); + MarkupAttribute attID = tag.Attributes["ID"]; + if (attID != null) + { + lang.ID = attID.Value; + } + + MarkupTagElement tagStringTable = (tag.Elements["StringTable"] as MarkupTagElement); + if (tagStringTable != null) + { + foreach (MarkupElement elStringTableEntry in tagStringTable.Elements) + { + MarkupTagElement tagStringTableEntry = (elStringTableEntry as MarkupTagElement); + if (tagStringTableEntry == null) continue; + if (tagStringTableEntry.FullName != "StringTableEntry") continue; + + MarkupAttribute attStringTableEntryID = tagStringTableEntry.Attributes["ID"]; + if (attStringTableEntryID == null) continue; + + MarkupAttribute attStringTableEntryValue = tagStringTableEntry.Attributes["Value"]; + if (attStringTableEntryValue == null) continue; + + lang.SetStringTableEntry(attStringTableEntryID.Value, attStringTableEntryValue.Value); + } + } + + MarkupTagElement tagCommands = (tag.Elements["Commands"] as MarkupTagElement); + if (tagCommands != null) + { + foreach (MarkupElement elCommand in tagCommands.Elements) + { + MarkupTagElement tagCommand = (elCommand as MarkupTagElement); + if (tagCommand == null) continue; + if (tagCommand.FullName != "Command") continue; + + MarkupAttribute attCommandID = tagCommand.Attributes["ID"]; + if (attCommandID == null) continue; + + MarkupAttribute attCommandTitle = tagCommand.Attributes["Title"]; + if (attCommandTitle == null) continue; + + lang.SetCommandTitle(attCommandID.Value, attCommandTitle.Value); + } + } + + mvarLanguages.Add(lang); } private void InitializeMainMenuItem(MarkupTagElement tag, Command parent) @@ -295,7 +478,7 @@ namespace UniversalEditor.UserInterface // overridden with a switch (/basepath:...) ? mvarBasePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); - BeforeInitialization(); + BeforeInitialization(); // Initialize the XML files InitializeXMLConfiguration(); @@ -323,7 +506,7 @@ namespace UniversalEditor.UserInterface } if (!SingleInstanceManager.CreateSingleInstance(INSTANCEID, new EventHandler(SingleInstanceManager_Callback))) return; - AfterInitialization(); + AfterInitialization(); MainLoop(); } diff --git a/CSharp/Libraries/UniversalEditor.UserInterface/IHostApplicationWindow.cs b/CSharp/Libraries/UniversalEditor.UserInterface/IHostApplicationWindow.cs index 1d5e8386..ad6d82d6 100644 --- a/CSharp/Libraries/UniversalEditor.UserInterface/IHostApplicationWindow.cs +++ b/CSharp/Libraries/UniversalEditor.UserInterface/IHostApplicationWindow.cs @@ -7,6 +7,8 @@ namespace UniversalEditor.UserInterface { public interface IHostApplicationWindow { + event EventHandler WindowClosed; + void NewFile(); void NewProject(bool combineObjects = false); @@ -24,6 +26,16 @@ namespace UniversalEditor.UserInterface void SaveProjectAs(string FileName, DataFormat df); void SaveAll(); + + void CloseFile(); + void CloseWindow(); + + /// + /// Displays the "Options" dialog (on Windows, under the "Tools" menu; on Linux, under the "Edit" + /// menu, labeled as "Preferences"). + /// + /// True if the user accepted the dialog; false otherwise. + bool ShowOptionsDialog(); void ToggleMenuItemEnabled(string menuItemName, bool enabled); void RefreshCommand(object nativeCommandObject); @@ -35,4 +47,9 @@ namespace UniversalEditor.UserInterface void ActivateWindow(); } + public class IHostApplicationWindowCollection + : System.Collections.ObjectModel.Collection + { + + } } diff --git a/CSharp/Libraries/UniversalEditor.UserInterface/Language.cs b/CSharp/Libraries/UniversalEditor.UserInterface/Language.cs new file mode 100644 index 00000000..2c7c2d79 --- /dev/null +++ b/CSharp/Libraries/UniversalEditor.UserInterface/Language.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace UniversalEditor.UserInterface +{ + public class Language + { + public class LanguageCollection + : System.Collections.ObjectModel.Collection + { + public Language this[string ID] + { + get + { + foreach (Language language in this) + { + if (language.ID == ID) return language; + } + return null; + } + } + } + + private string mvarID = String.Empty; + public string ID { get { return mvarID; } set { mvarID = value; } } + + private Dictionary mvarCommandTitles = new Dictionary(); + private Dictionary mvarStringTableEntries = new Dictionary(); + + public string GetCommandTitle(string id, string defaultValue = null) + { + if (mvarCommandTitles.ContainsKey(id)) return mvarCommandTitles[id]; + return defaultValue; + } + public void SetCommandTitle(string id, string value) + { + mvarCommandTitles[id] = value; + } + public string GetStringTableEntry(string id, string defaultValue = null) + { + if (mvarStringTableEntries.ContainsKey(id)) return mvarStringTableEntries[id]; + return defaultValue; + } + public void SetStringTableEntry(string id, string value) + { + mvarStringTableEntries[id] = value; + } + } +} diff --git a/CSharp/Libraries/UniversalEditor.UserInterface/UniversalEditor.UserInterface.csproj b/CSharp/Libraries/UniversalEditor.UserInterface/UniversalEditor.UserInterface.csproj index 3de047ad..f15438a6 100644 --- a/CSharp/Libraries/UniversalEditor.UserInterface/UniversalEditor.UserInterface.csproj +++ b/CSharp/Libraries/UniversalEditor.UserInterface/UniversalEditor.UserInterface.csproj @@ -1,4 +1,4 @@ - + Debug @@ -63,6 +63,7 @@ +