diff --git a/CSharp/Libraries/UniversalEditor.UserInterface/Editors/FileSystem/Dialogs/FilePropertiesDialog.cs b/CSharp/Libraries/UniversalEditor.UserInterface/Editors/FileSystem/Dialogs/FilePropertiesDialog.cs deleted file mode 100644 index 9f52208e..00000000 --- a/CSharp/Libraries/UniversalEditor.UserInterface/Editors/FileSystem/Dialogs/FilePropertiesDialog.cs +++ /dev/null @@ -1,104 +0,0 @@ -// -// FilePropertiesDialog.cs -// -// Author: -// Mike Becker -// -// Copyright (c) 2019 Mike Becker -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -using System; -using System.ComponentModel; -using MBS.Framework.UserInterface; -using MBS.Framework.UserInterface.Controls; -using MBS.Framework.UserInterface.Layouts; -using UniversalEditor.ObjectModels.FileSystem; - -namespace UniversalEditor.Editors.FileSystem.Dialogs -{ - public class FilePropertiesDialog : Dialog - { - private TextBox txtFileName = null; - private TextBox txtFileType = null; - private TextBox txtFileSize = null; - private TextBox txtFileDate = null; - - public static DialogResult ShowDialog(IFileSystemObject fso) - { - FilePropertiesDialog dlg = new FilePropertiesDialog(); - dlg.Text = String.Format("{0} Properties", fso.Name); - dlg.txtFileName.Text = fso.Name; - - if (fso is Folder) - { - Folder f = fso as Folder; - dlg.txtFileType.Text = "Folder"; - dlg.txtFileSize.Text = String.Format("{0} files, {1} folders", f.Files.Count, f.Folders.Count); - } - else if (fso is File) - { - File f = fso as File; - dlg.txtFileType.Text = System.IO.Path.GetExtension(f.Name) + " File"; - dlg.txtFileSize.Text = UniversalEditor.UserInterface.Common.FileInfo.FormatSize(f.Size); - } - - if (dlg.ShowDialog() == DialogResult.OK) - { - fso.Name = dlg.txtFileName.Text; - return DialogResult.OK; - } - return DialogResult.Cancel; - } - - public FilePropertiesDialog() - { - Layout = new BoxLayout(Orientation.Vertical); - Size = new MBS.Framework.Drawing.Dimension2D(400, 600); - - TabContainer tbs = new TabContainer(); - - TabPage tabGeneral = new TabPage(); - tabGeneral.Text = "General"; - tabGeneral.Layout = new GridLayout(); - - tabGeneral.Controls.Add(new Label("_Name"), new GridLayout.Constraints(0, 0)); - txtFileName = new TextBox(); - tabGeneral.Controls.Add(txtFileName, new GridLayout.Constraints(0, 1, 1, 2, ExpandMode.Horizontal)); - - tabGeneral.Controls.Add(new Label("_Size"), new GridLayout.Constraints(1, 0)); - txtFileSize = new TextBox(); - txtFileSize.Editable = false; - tabGeneral.Controls.Add(txtFileSize, new GridLayout.Constraints(1, 1, 1, 2, ExpandMode.Horizontal)); - - tabGeneral.Controls.Add(new Label("_Type"), new GridLayout.Constraints(2, 0)); - txtFileType = new TextBox(); - txtFileType.Editable = false; - tabGeneral.Controls.Add(txtFileType, new GridLayout.Constraints(2, 1, 1, 2, ExpandMode.Horizontal)); - - Button cmdChangeType = new Button("C_hange..."); - tabGeneral.Controls.Add(cmdChangeType, new GridLayout.Constraints(2, 2, 1, 1)); - - tabGeneral.Controls.Add(new Label("_Date modified"), new GridLayout.Constraints(3, 0)); - txtFileDate = new TextBox(); - tabGeneral.Controls.Add(txtFileDate, new GridLayout.Constraints(3, 1, 1, 2, ExpandMode.Horizontal)); - - tbs.TabPages.Add(tabGeneral); - - Controls.Add(tbs, new BoxLayout.Constraints(true, true)); - - Buttons.Add(new Button(StockType.OK, DialogResult.OK)); - Buttons.Add(new Button(StockType.Cancel, DialogResult.Cancel)); - } - } -} diff --git a/CSharp/Libraries/UniversalEditor.UserInterface/Editors/FileSystem/FileSystemEditor.cs b/CSharp/Libraries/UniversalEditor.UserInterface/Editors/FileSystem/FileSystemEditor.cs index 127f2107..91f09ed0 100644 --- a/CSharp/Libraries/UniversalEditor.UserInterface/Editors/FileSystem/FileSystemEditor.cs +++ b/CSharp/Libraries/UniversalEditor.UserInterface/Editors/FileSystem/FileSystemEditor.cs @@ -28,7 +28,6 @@ using MBS.Framework.UserInterface.Dialogs; using MBS.Framework.UserInterface.DragDrop; using MBS.Framework.UserInterface.Input.Keyboard; using MBS.Framework.UserInterface.Input.Mouse; -using UniversalEditor.Editors.FileSystem.Dialogs; using UniversalEditor.Accessors; using MBS.Framework.UserInterface.Controls; @@ -497,23 +496,6 @@ namespace UniversalEditor.Editors.FileSystem } } - private void ContextMenuProperties_Click(object sender, EventArgs e) - { - if (tv.SelectedRows.Count == 1 && tv.LastHitTest.Row != null) - { - TreeModelRow row = tv.SelectedRows[0]; - IFileSystemObject fso = row.GetExtraData("item"); - - if (FilePropertiesDialog.ShowDialog(fso) == DialogResult.OK) - { - row.RowColumns[0].Value = fso.Name; - } - } - else - { - } - } - /// /// Prompts the user to choose a filename, and then extracts the selected file in the current to a file on disk with the chosen filename. /// @@ -654,5 +636,29 @@ namespace UniversalEditor.Editors.FileSystem Application.Commands["EditPaste"].Enabled = Clipboard.Default.ContainsFileList; // (tv.ContextMenu.Items["FileSystemContextMenu_PasteShortcut"] as CommandMenuItem).Enabled = Clipboard.Default.ContainsFileList; } + + protected override SettingsProvider[] GetDocumentPropertiesSettingsProviders() + { + List list = new List(); + + FileSystemEditorDocumentPropertiesSettingsProvider docprops = new FileSystemEditorDocumentPropertiesSettingsProvider(); + + FileSystemObjectModel fsom = (ObjectModel as FileSystemObjectModel); + docprops.ObjectModel = fsom; + + if (tv.Focused) + { + if (tv.LastHitTest != null) + { + if (tv.LastHitTest.Row != null) + { + docprops.FileSystemObject = tv.LastHitTest.Row.GetExtraData("item"); + } + } + } + list.Add(docprops); + + return list.ToArray(); + } } } diff --git a/CSharp/Libraries/UniversalEditor.UserInterface/Editors/FileSystem/FileSystemEditorDocumentPropertiesSettingsProvider.cs b/CSharp/Libraries/UniversalEditor.UserInterface/Editors/FileSystem/FileSystemEditorDocumentPropertiesSettingsProvider.cs new file mode 100644 index 00000000..8189498c --- /dev/null +++ b/CSharp/Libraries/UniversalEditor.UserInterface/Editors/FileSystem/FileSystemEditorDocumentPropertiesSettingsProvider.cs @@ -0,0 +1,90 @@ +// +// FileSystemEditorDocumentPropertiesSettingsProvider.cs +// +// Author: +// Mike Becker +// +// Copyright (c) 2020 Mike Becker +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +using System; +using MBS.Framework.UserInterface; +using UniversalEditor.ObjectModels.FileSystem; + +namespace UniversalEditor.Editors.FileSystem +{ + public class FileSystemEditorDocumentPropertiesSettingsProvider : SettingsProvider + { + private FileSystemObjectModel _FileSystemObjectModel = null; + public FileSystemObjectModel ObjectModel + { + get { return _FileSystemObjectModel; } + set + { + _FileSystemObjectModel = value; + LoadSettings(); + } + } + + private IFileSystemObject _FileSystemObject = null; + public IFileSystemObject FileSystemObject + { + get { return _FileSystemObject; } + set + { + _FileSystemObject = value; + LoadSettings(); + } + } + + public FileSystemEditorDocumentPropertiesSettingsProvider() + { + SettingsGroups.Add(new SettingsGroup("General", new Setting[] + { + new TextSetting("_Name"), + new TextSetting("_Size"), + new TextSetting("_Type"), + new TextSetting("_Date modified") + })); + } + + protected override void LoadSettingsInternal() + { + base.LoadSettingsInternal(); + + if (FileSystemObject != null) + { + if (FileSystemObject is File) + { + File f = (File)FileSystemObject; + SettingsGroups[0].Settings[0].SetValue(f.Name); + SettingsGroups[0].Settings[1].SetValue(f.Size); + // SettingsGroups[0].Settings[2].SetValue(f); + SettingsGroups[0].Settings[3].SetValue(f.ModificationTimestamp); + } + return; + } + + if (ObjectModel != null) + { + if (ObjectModel.Accessor != null) + SettingsGroups[0].Settings[0].SetValue(ObjectModel.Accessor.GetFileName()); + + // SettingsGroups[0].Settings[1].SetValue(f.Size); + // SettingsGroups[0].Settings[2].SetValue(f); + // SettingsGroups[0].Settings[3].SetValue(f.ModificationTimestamp); + } + } + } +} diff --git a/CSharp/Libraries/UniversalEditor.UserInterface/UniversalEditor.UserInterface.csproj b/CSharp/Libraries/UniversalEditor.UserInterface/UniversalEditor.UserInterface.csproj index ace1b62f..b5e5967f 100644 --- a/CSharp/Libraries/UniversalEditor.UserInterface/UniversalEditor.UserInterface.csproj +++ b/CSharp/Libraries/UniversalEditor.UserInterface/UniversalEditor.UserInterface.csproj @@ -118,7 +118,6 @@ - @@ -131,6 +130,7 @@ + @@ -182,7 +182,6 @@ -