implement Delete on SolutionExplorerPanel - very inefficient; needs UWT treemodelrow delete support

This commit is contained in:
Michael Becker 2019-11-13 10:44:55 -05:00
parent 97eb6dadd7
commit de65fecdd7
No known key found for this signature in database
GPG Key ID: 389DFF5D73781A12
2 changed files with 46 additions and 2 deletions

View File

@ -19,6 +19,8 @@ using UniversalEditor.UserInterface.Dialogs;
using MBS.Framework.UserInterface;
using MBS.Framework.UserInterface.Input.Keyboard;
using MBS.Framework.Drawing;
using UniversalEditor.UserInterface.Panels;
using MBS.Framework.UserInterface.Controls;
namespace UniversalEditor.UserInterface
{
@ -315,8 +317,18 @@ namespace UniversalEditor.UserInterface
Application.AttachCommandEventHandler("EditDelete", delegate(object sender, EventArgs e)
{
Editor editor = LastWindow.GetCurrentEditor();
if (editor == null) return;
editor.Delete();
if (editor != null)
{
editor.Delete();
}
else
{
Control ctl = LastWindow.ActiveControl;
if (ctl is ListView && ctl.Parent is SolutionExplorerPanel)
{
(ctl.Parent as SolutionExplorerPanel).Delete();
}
}
});
Application.AttachCommandEventHandler("EditUndo", delegate(object sender, EventArgs e)
{

View File

@ -208,6 +208,7 @@ namespace UniversalEditor.UserInterface.Panels
// - if it is a special folder named "Properties/Resources", the resource editor shall be shown
ProjectObjectModel project = e.Row.GetExtraData<ProjectObjectModel>("project");
ProjectFile file = e.Row.GetExtraData<ProjectFile>("file");
ProjectFolder folder = e.Row.GetExtraData<ProjectFolder>("folder");
if (project != null)
{
MessageDialog.ShowDialog(String.Format("Opening project properties for {0}", e.Row.RowColumns[0].Value), "Info", MessageDialogButtons.OK);
@ -216,6 +217,10 @@ namespace UniversalEditor.UserInterface.Panels
{
Engine.CurrentEngine.LastWindow.OpenFile(file.SourceFileName);
}
else if (folder != null)
{
return;
}
else
{
MessageDialog.ShowDialog(String.Format("Activated row {0}", e.Row.RowColumns[0].Value), "Info", MessageDialogButtons.OK);
@ -331,5 +336,32 @@ namespace UniversalEditor.UserInterface.Panels
}
}
/// <summary>
/// Deletes the selected item in the Solution Explorer panel.
/// </summary>
public void Delete()
{
if (tvSolutionExplorer.SelectedRows.Count > 0)
{
/*
// does not work - we need to fix this in UWT
while (tvSolutionExplorer.SelectedRows.Count > 0)
{
tmSolutionExplorer.Rows.Remove(tvSolutionExplorer.SelectedRows[0]);
}
*/
ProjectFolder folder = tvSolutionExplorer.SelectedRows[0].GetExtraData<ProjectFolder>("folder");
ProjectFile file = tvSolutionExplorer.SelectedRows[0].GetExtraData<ProjectFile>("file");
if (file != null)
{
file.Parent.Files.Remove(file);
}
if (folder != null)
{
folder.Parent.Folders.Remove(folder);
}
UpdateSolutionExplorer();
}
}
}
}