implement file properties dialog as Document Properties SettingsDialog
This commit is contained in:
parent
d31ccfafa1
commit
df046cc6c0
@ -1,104 +0,0 @@
|
||||
//
|
||||
// FilePropertiesDialog.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Becker <alcexhim@gmail.com>
|
||||
//
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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<IFileSystemObject>("item");
|
||||
|
||||
if (FilePropertiesDialog.ShowDialog(fso) == DialogResult.OK)
|
||||
{
|
||||
row.RowColumns[0].Value = fso.Name;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prompts the user to choose a filename, and then extracts the selected file in the current <see cref="FileSystemObjectModel" /> to a file on disk with the chosen filename.
|
||||
/// </summary>
|
||||
@ -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<SettingsProvider> list = new List<SettingsProvider>();
|
||||
|
||||
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<IFileSystemObject>("item");
|
||||
}
|
||||
}
|
||||
}
|
||||
list.Add(docprops);
|
||||
|
||||
return list.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,90 @@
|
||||
//
|
||||
// FileSystemEditorDocumentPropertiesSettingsProvider.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Becker <alcexhim@gmail.com>
|
||||
//
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -118,7 +118,6 @@
|
||||
<Compile Include="Editors\Binary\BinaryEditor.cs" />
|
||||
<Compile Include="Editors\Binary\FieldDefinitionPropertiesDialog.cs" />
|
||||
<Compile Include="Editors\Binary\FieldDefinition.cs" />
|
||||
<Compile Include="Editors\FileSystem\Dialogs\FilePropertiesDialog.cs" />
|
||||
<Compile Include="EditorView.cs" />
|
||||
<Compile Include="EditorViewChangingEvent.cs" />
|
||||
<Compile Include="EditorViewChangedEvent.cs" />
|
||||
@ -131,6 +130,7 @@
|
||||
<Compile Include="Panels\PropertyListPanel.Designer.cs" />
|
||||
<Compile Include="View.cs" />
|
||||
<Compile Include="Panels\DocumentExplorerPanel.cs" />
|
||||
<Compile Include="Editors\FileSystem\FileSystemEditorDocumentPropertiesSettingsProvider.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||
@ -182,7 +182,6 @@
|
||||
<Folder Include="Editors\PropertyList\" />
|
||||
<Folder Include="Controls\" />
|
||||
<Folder Include="Editors\Binary\" />
|
||||
<Folder Include="Editors\FileSystem\Dialogs\" />
|
||||
<Folder Include="Editors\Database\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user