port from perforce
This commit is contained in:
34
intromat/Intromat/Actions/Hierarchy/CreateModuleAction.cs
Normal file
34
intromat/Intromat/Actions/Hierarchy/CreateModuleAction.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System.IO;
|
||||
using Intromat.Interfaces;
|
||||
using Intromat.ViewModels;
|
||||
|
||||
namespace Intromat.Actions.Hierarchy
|
||||
{
|
||||
public class CreateModuleAction : IUndoItem
|
||||
{
|
||||
private readonly ModuleViewModel _module;
|
||||
private readonly ProjectViewModel _parent;
|
||||
|
||||
public CreateModuleAction(string name, ProjectViewModel parent)
|
||||
{
|
||||
var modulePath = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(parent.FullPath)!, name, $"{name}.imodule"));
|
||||
_module = new ModuleViewModel(parent, name, modulePath);
|
||||
File = _parent = parent;
|
||||
}
|
||||
|
||||
public IFile File { get; }
|
||||
|
||||
public void Redo()
|
||||
{
|
||||
_parent.Modules.Add(_module);
|
||||
_parent.IsExpanded = true;
|
||||
_module.IsSelected = true;
|
||||
}
|
||||
|
||||
public void Undo()
|
||||
{
|
||||
_parent.Modules.Remove(_module);
|
||||
_parent.IsSelected = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user