|
@@ -55,7 +55,6 @@ namespace InABox.DynamicGrid
|
|
|
|
|
|
public event DynamicGridSaveEvent? OnSaveItem;
|
|
|
|
|
|
-
|
|
|
DynamicEditorPages? Pages { get; }
|
|
|
|
|
|
bool ReadOnly { get; set; }
|
|
@@ -67,6 +66,8 @@ namespace InABox.DynamicGrid
|
|
|
|
|
|
IDynamicEditorControl FindEditor(string columnName);
|
|
|
|
|
|
+ void SetLayoutType<T>() where T : DynamicEditorGridLayout;
|
|
|
+
|
|
|
void UnloadEditorPages(bool saved);
|
|
|
}
|
|
|
|
|
@@ -79,12 +80,12 @@ namespace InABox.DynamicGrid
|
|
|
public ICommand Command { get; set; }
|
|
|
}
|
|
|
|
|
|
- public class UtilityViewModel
|
|
|
+ public class DynamicEditorFormModel
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// Constructor of the UtilityViewModel class.
|
|
|
/// </summary>
|
|
|
- public UtilityViewModel()
|
|
|
+ public DynamicEditorFormModel()
|
|
|
{
|
|
|
var utilities = new ObservableCollection<UtilityItem>();
|
|
|
utilities.Add(new UtilityItem
|
|
@@ -177,6 +178,7 @@ namespace InABox.DynamicGrid
|
|
|
{
|
|
|
Form.Setup(type, pages, buttons, pageDataHandler, preloadPages);
|
|
|
}
|
|
|
+ public void SetLayoutType<T>() where T : DynamicEditorGridLayout => Form.SetLayoutType<T>();
|
|
|
|
|
|
private void Form_OnCancel()
|
|
|
{
|
|
@@ -195,8 +197,8 @@ namespace InABox.DynamicGrid
|
|
|
double spareheight = 90;
|
|
|
double sparewidth = 25;
|
|
|
|
|
|
- var desiredheight = height + spareheight;
|
|
|
- var desiredwidth = width + sparewidth;
|
|
|
+ var desiredheight = height;
|
|
|
+ var desiredwidth = width;
|
|
|
if (Form.Pages != null)
|
|
|
foreach (var page in Form.Pages)
|
|
|
{
|
|
@@ -206,6 +208,9 @@ namespace InABox.DynamicGrid
|
|
|
desiredwidth = page.MinimumSize().Width;
|
|
|
}
|
|
|
|
|
|
+ desiredheight += spareheight;
|
|
|
+ desiredwidth += sparewidth;
|
|
|
+
|
|
|
var maxheight = screen.WorkingArea.Height - 0;
|
|
|
Height = desiredheight > maxheight ? maxheight : desiredheight;
|
|
|
|
|
@@ -217,8 +222,6 @@ namespace InABox.DynamicGrid
|
|
|
|
|
|
var scaption = Form.Items[0].GetType().GetCaption();
|
|
|
Title = "Edit " + scaption.SplitCamelCase();
|
|
|
- if (Form.Editor.IsCustomLayout)
|
|
|
- Title += "*";
|
|
|
}
|
|
|
|
|
|
private void Window_Closing(object sender, CancelEventArgs e)
|
|
@@ -226,78 +229,5 @@ namespace InABox.DynamicGrid
|
|
|
if (DialogResult == true)
|
|
|
Form.SaveItem(e);
|
|
|
}
|
|
|
-
|
|
|
- #region Win32 API Stuff
|
|
|
-
|
|
|
- // Define the Win32 API methods we are going to use
|
|
|
- [DllImport("user32.dll")]
|
|
|
- private static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);
|
|
|
-
|
|
|
- [DllImport("user32.dll")]
|
|
|
- private static extern bool InsertMenu(IntPtr hMenu, int wPosition, int wFlags, int wIDNewItem, string lpNewItem);
|
|
|
-
|
|
|
- /// Define our Constants we will use
|
|
|
- public const int WM_SYSCOMMAND = 0x112;
|
|
|
-
|
|
|
- public const int MF_SEPARATOR = 0x800;
|
|
|
- public const int MF_BYPOSITION = 0x400;
|
|
|
- public const int MF_STRING = 0x0;
|
|
|
-
|
|
|
- public const int _EditLayoutID = 1000;
|
|
|
- public const int _ResetLayoutID = 1001;
|
|
|
-
|
|
|
- public IntPtr Handle => new WindowInteropHelper(this).Handle;
|
|
|
-
|
|
|
- private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
|
|
|
- {
|
|
|
- // Check if a System Command has been executed
|
|
|
- if (msg == WM_SYSCOMMAND)
|
|
|
- // Execute the appropriate code for the System Menu item that was clicked
|
|
|
- switch (wParam.ToInt32())
|
|
|
- {
|
|
|
- case _EditLayoutID:
|
|
|
- Form.EditLayout();
|
|
|
- handled = true;
|
|
|
- break;
|
|
|
- case _ResetLayoutID:
|
|
|
- if (MessageBox.Show(
|
|
|
- "WARNING: This will delete any customisations you have made!\n\nAre you sure you wish to reset this layout?",
|
|
|
- "Confirm Layout Reset", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
|
|
|
- Form.ResetLayout();
|
|
|
- handled = true;
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- return IntPtr.Zero;
|
|
|
- }
|
|
|
-
|
|
|
- private void ConfigureSystemMenu(object sender, RoutedEventArgs e)
|
|
|
- {
|
|
|
- /// Get the Handle for the Forms System Menu
|
|
|
- var systemMenuHandle = GetSystemMenu(Handle, false);
|
|
|
-
|
|
|
- /// Create our new System Menu items just before the Close menu item
|
|
|
- InsertMenu(systemMenuHandle, 5, MF_BYPOSITION | MF_SEPARATOR, 0, string.Empty); // <-- Add a menu seperator
|
|
|
- InsertMenu(systemMenuHandle, 6, MF_BYPOSITION, _EditLayoutID, "Edit Layout");
|
|
|
- InsertMenu(systemMenuHandle, 7, MF_BYPOSITION, _ResetLayoutID, "Reset Layout");
|
|
|
-
|
|
|
- // Attach our WndProc handler to this Window
|
|
|
- var source = HwndSource.FromHwnd(Handle);
|
|
|
- source.AddHook(WndProc);
|
|
|
- }
|
|
|
-
|
|
|
- #endregion
|
|
|
-
|
|
|
- //private void Wiki_Click(object sender, RoutedEventArgs e)
|
|
|
- //{
|
|
|
- // System.Diagnostics.Process.Start("https://prs-software.com.au/wiki/index.php/" + CurrentPanelSlug());
|
|
|
- //}
|
|
|
-
|
|
|
- //private string CurrentPanelSlug()
|
|
|
- //{
|
|
|
- // if ((Items != null) && Items.Any())
|
|
|
- // return Items.First().GetType().EntityName().Split('.').Last();
|
|
|
- // return "";
|
|
|
- //}
|
|
|
}
|
|
|
}
|