From 5233118a56508bd7a5206751c3c35174c9f5bd3f Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Tue, 23 Mar 2021 14:49:55 -0400 Subject: [PATCH] suggest ObjectModel if not specified when selecting DataFormat --- .../Dialogs/DocumentPropertiesDialog.cs | 32 ++++++++++++------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/Libraries/UniversalEditor.UserInterface/Dialogs/DocumentPropertiesDialog.cs b/Libraries/UniversalEditor.UserInterface/Dialogs/DocumentPropertiesDialog.cs index 896e937c..848e3c59 100644 --- a/Libraries/UniversalEditor.UserInterface/Dialogs/DocumentPropertiesDialog.cs +++ b/Libraries/UniversalEditor.UserInterface/Dialogs/DocumentPropertiesDialog.cs @@ -21,15 +21,12 @@ using System; using System.Collections.Generic; using System.Text; -using UniversalEditor.Accessors; +using MBS.Framework; +using MBS.Framework.Drawing; using MBS.Framework.UserInterface; using MBS.Framework.UserInterface.Controls; -using MBS.Framework.UserInterface.Drawing; - -using MBS.Framework.Drawing; -using System.ComponentModel; using MBS.Framework.UserInterface.Dialogs; -using MBS.Framework; +using UniversalEditor.Accessors; namespace UniversalEditor.UserInterface.Dialogs { @@ -372,6 +369,8 @@ namespace UniversalEditor.UserInterface.Dialogs } DataFormat = df; + RefreshODA(false); + RefreshButtons(); } private void dlgAccessor_SelectionChanged(object sender, EventArgs e) @@ -428,11 +427,20 @@ namespace UniversalEditor.UserInterface.Dialogs Accessor = acc; + RefreshODA(); + + RefreshButtons(); + + dlg.AutoClose = true; + } + + private void RefreshODA(bool checkAccessor = true) + { DataFormat df = null; // pro feature: if we find a better OM/DF, maybe ask the user "do you wish to change object model to ___ ?" before doing so if (Mode == DocumentPropertiesDialogMode.Open) { - if (Accessor is FileAccessor) + if (checkAccessor && Accessor is FileAccessor) { if (!System.IO.File.Exists(Accessor.GetFileName())) { @@ -461,9 +469,10 @@ namespace UniversalEditor.UserInterface.Dialogs { } } + if (ObjectModel == null) { - if (df != null) + if (checkAccessor && df != null) { switch (Mode) { @@ -485,7 +494,10 @@ namespace UniversalEditor.UserInterface.Dialogs } } DataFormat = df; + } + if (DataFormat != null) + { ObjectModelReference[] omrs = UniversalEditor.Common.Reflection.GetAvailableObjectModels(DataFormat.MakeReference()); if (omrs.Length > 0) { @@ -505,10 +517,6 @@ namespace UniversalEditor.UserInterface.Dialogs } } } - - RefreshButtons(); - - dlg.AutoClose = true; } [EventHandler(nameof(cmdDataFormatOptions), "Click")]