port from perforce
This commit is contained in:
35
intromat/Intromat/Actions/Hierarchy/CreateFileAction.cs
Normal file
35
intromat/Intromat/Actions/Hierarchy/CreateFileAction.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using DynamicData;
|
||||
using Intromat.Interfaces;
|
||||
using Intromat.ViewModels;
|
||||
|
||||
namespace Intromat.Actions.Hierarchy
|
||||
{
|
||||
public class CreateFileAction : IUndoItem
|
||||
{
|
||||
private readonly FileViewModel _file;
|
||||
private readonly FolderViewModel _parent;
|
||||
|
||||
public CreateFileAction(MainViewModel mainVm, FileViewModel file, ModuleViewModel module, FolderViewModel parent)
|
||||
{
|
||||
_file = file;
|
||||
_parent = parent;
|
||||
File = module;
|
||||
}
|
||||
|
||||
public IFile File { get; }
|
||||
|
||||
public void Redo()
|
||||
{
|
||||
_parent.Files.Add(_file);
|
||||
_parent.IsExpanded = true;
|
||||
_file.IsSelected = true;
|
||||
}
|
||||
|
||||
public void Undo()
|
||||
{
|
||||
_parent.Files.Remove(_file);
|
||||
_parent.IsSelected = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
34
intromat/Intromat/Actions/Hierarchy/CreateFolderAction.cs
Normal file
34
intromat/Intromat/Actions/Hierarchy/CreateFolderAction.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using DynamicData;
|
||||
using Intromat.Interfaces;
|
||||
using Intromat.ViewModels;
|
||||
|
||||
namespace Intromat.Actions.Hierarchy
|
||||
{
|
||||
public class CreateFolderAction : IUndoItem
|
||||
{
|
||||
private readonly FolderViewModel _folder;
|
||||
private readonly FolderViewModel _parent;
|
||||
|
||||
public CreateFolderAction(string name, ModuleViewModel module, FolderViewModel parent)
|
||||
{
|
||||
_folder = new FolderViewModel(module, parent, name);
|
||||
_parent = parent;
|
||||
File = module;
|
||||
}
|
||||
|
||||
public IFile File { get; }
|
||||
|
||||
public void Redo()
|
||||
{
|
||||
_parent.Folders.Add(_folder);
|
||||
_parent.IsExpanded = true;
|
||||
_folder.IsSelected = true;
|
||||
}
|
||||
|
||||
public void Undo()
|
||||
{
|
||||
_parent.Folders.Remove(_folder);
|
||||
_parent.IsSelected = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
33
intromat/Intromat/Actions/Hierarchy/DeleteFileAction.cs
Normal file
33
intromat/Intromat/Actions/Hierarchy/DeleteFileAction.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using DynamicData;
|
||||
using Intromat.Interfaces;
|
||||
using Intromat.ViewModels;
|
||||
|
||||
namespace Intromat.Actions.Hierarchy
|
||||
{
|
||||
public class DeleteFileAction : IUndoItem
|
||||
{
|
||||
private readonly FileViewModel _file;
|
||||
private readonly FolderViewModel _parent;
|
||||
|
||||
public DeleteFileAction(FileViewModel file)
|
||||
{
|
||||
_parent = file.Parent;
|
||||
File = _parent.Module;
|
||||
_file = file;
|
||||
}
|
||||
|
||||
public IFile File { get; }
|
||||
|
||||
public void Redo()
|
||||
{
|
||||
_parent.Files.Remove(_file);
|
||||
_parent.IsSelected = true;
|
||||
}
|
||||
|
||||
public void Undo()
|
||||
{
|
||||
_parent.Files.Add(_file);
|
||||
_file.IsSelected = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
33
intromat/Intromat/Actions/Hierarchy/DeleteFolderAction.cs
Normal file
33
intromat/Intromat/Actions/Hierarchy/DeleteFolderAction.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using DynamicData;
|
||||
using Intromat.Interfaces;
|
||||
using Intromat.ViewModels;
|
||||
|
||||
namespace Intromat.Actions.Hierarchy
|
||||
{
|
||||
public class DeleteFolderAction : IUndoItem
|
||||
{
|
||||
private readonly FolderViewModel _folder;
|
||||
private readonly FolderViewModel _parent;
|
||||
|
||||
public DeleteFolderAction(FolderViewModel folder)
|
||||
{
|
||||
File = folder.Module;
|
||||
_parent = (FolderViewModel)folder.Parent;
|
||||
_folder = folder;
|
||||
}
|
||||
|
||||
public IFile File { get; }
|
||||
|
||||
public void Redo()
|
||||
{
|
||||
_parent.Folders.Remove(_folder);
|
||||
_parent.IsSelected = true;
|
||||
}
|
||||
|
||||
public void Undo()
|
||||
{
|
||||
_parent.Folders.Add(_folder);
|
||||
_folder.IsSelected = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
31
intromat/Intromat/Actions/Hierarchy/DeleteModuleAction.cs
Normal file
31
intromat/Intromat/Actions/Hierarchy/DeleteModuleAction.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using Intromat.Interfaces;
|
||||
using Intromat.ViewModels;
|
||||
|
||||
namespace Intromat.Actions.Hierarchy
|
||||
{
|
||||
public class DeleteModuleAction : IUndoItem
|
||||
{
|
||||
private readonly ModuleViewModel _module;
|
||||
private readonly ProjectViewModel _parent;
|
||||
|
||||
public DeleteModuleAction(ModuleViewModel module)
|
||||
{
|
||||
File = _parent = (ProjectViewModel)module.Parent;
|
||||
_module = module;
|
||||
}
|
||||
|
||||
public IFile File { get; }
|
||||
|
||||
public void Redo()
|
||||
{
|
||||
_parent.Modules.Remove(_module);
|
||||
_parent.IsSelected = true;
|
||||
}
|
||||
|
||||
public void Undo()
|
||||
{
|
||||
_parent.Modules.Add(_module);
|
||||
_module.IsSelected = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
32
intromat/Intromat/Actions/Network/AddConnectionAction.cs
Normal file
32
intromat/Intromat/Actions/Network/AddConnectionAction.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using DynamicData;
|
||||
using Intromat.Interfaces;
|
||||
using Intromat.ViewModels;
|
||||
using NodeNetwork.ViewModels;
|
||||
|
||||
namespace Intromat.Actions.Network
|
||||
{
|
||||
public class AddConnectionAction : IUndoItem
|
||||
{
|
||||
private readonly CodeGenNetworkViewModel _network;
|
||||
private readonly ConnectionViewModel _connection;
|
||||
|
||||
public AddConnectionAction(DocumentViewModel document, CodeGenNetworkViewModel network, ConnectionViewModel connection)
|
||||
{
|
||||
File = document;
|
||||
_network = network;
|
||||
_connection = connection;
|
||||
}
|
||||
|
||||
public void Redo()
|
||||
{
|
||||
_network.Connections.Add(_connection);
|
||||
}
|
||||
|
||||
public void Undo()
|
||||
{
|
||||
_network.Connections.Remove(_connection);
|
||||
}
|
||||
|
||||
public IFile File { get; }
|
||||
}
|
||||
}
|
||||
32
intromat/Intromat/Actions/Network/AddNodeAction.cs
Normal file
32
intromat/Intromat/Actions/Network/AddNodeAction.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using DynamicData;
|
||||
using Intromat.Interfaces;
|
||||
using Intromat.ViewModels;
|
||||
using NodeNetwork.ViewModels;
|
||||
|
||||
namespace Intromat.Actions.Network
|
||||
{
|
||||
public class AddNodeAction : IUndoItem
|
||||
{
|
||||
private readonly CodeGenNetworkViewModel _network;
|
||||
private readonly NodeViewModel _node;
|
||||
|
||||
public AddNodeAction(DocumentViewModel document, CodeGenNetworkViewModel network, NodeViewModel node)
|
||||
{
|
||||
File = document;
|
||||
_network = network;
|
||||
_node = node;
|
||||
}
|
||||
|
||||
public void Redo()
|
||||
{
|
||||
_network.Nodes.Add(_node);
|
||||
}
|
||||
|
||||
public void Undo()
|
||||
{
|
||||
_network.Nodes.Remove(_node);
|
||||
}
|
||||
|
||||
public IFile File { get; }
|
||||
}
|
||||
}
|
||||
32
intromat/Intromat/Actions/Network/DeleteConnectionAction.cs
Normal file
32
intromat/Intromat/Actions/Network/DeleteConnectionAction.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using DynamicData;
|
||||
using Intromat.Interfaces;
|
||||
using Intromat.ViewModels;
|
||||
using NodeNetwork.ViewModels;
|
||||
|
||||
namespace Intromat.Actions.Network
|
||||
{
|
||||
public class DeleteConnectionAction : IUndoItem
|
||||
{
|
||||
private readonly CodeGenNetworkViewModel _network;
|
||||
private readonly ConnectionViewModel _connection;
|
||||
|
||||
public DeleteConnectionAction(DocumentViewModel document, CodeGenNetworkViewModel network, ConnectionViewModel connection)
|
||||
{
|
||||
File = document;
|
||||
_network = network;
|
||||
_connection = connection;
|
||||
}
|
||||
|
||||
public void Redo()
|
||||
{
|
||||
_network.Connections.Remove(_connection);
|
||||
}
|
||||
|
||||
public void Undo()
|
||||
{
|
||||
_network.Connections.Add(_connection);
|
||||
}
|
||||
|
||||
public IFile File { get; }
|
||||
}
|
||||
}
|
||||
32
intromat/Intromat/Actions/Network/DeleteNodeAction.cs
Normal file
32
intromat/Intromat/Actions/Network/DeleteNodeAction.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using DynamicData;
|
||||
using Intromat.Interfaces;
|
||||
using Intromat.ViewModels;
|
||||
using NodeNetwork.ViewModels;
|
||||
|
||||
namespace Intromat.Actions.Network
|
||||
{
|
||||
public class DeleteNodeAction : IUndoItem
|
||||
{
|
||||
private readonly CodeGenNetworkViewModel _network;
|
||||
private readonly NodeViewModel _node;
|
||||
|
||||
public DeleteNodeAction(DocumentViewModel document, CodeGenNetworkViewModel network, NodeViewModel node)
|
||||
{
|
||||
File = document;
|
||||
_network = network;
|
||||
_node = node;
|
||||
}
|
||||
|
||||
public void Redo()
|
||||
{
|
||||
_network.Nodes.Remove(_node);
|
||||
}
|
||||
|
||||
public void Undo()
|
||||
{
|
||||
_network.Nodes.Add(_node);
|
||||
}
|
||||
|
||||
public IFile File { get; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user