66 lines
1.7 KiB
C#
66 lines
1.7 KiB
C#
using System;
|
|
using Intromat.Views;
|
|
using NodeNetwork.ViewModels;
|
|
using ReactiveUI;
|
|
using Splat;
|
|
|
|
namespace Intromat.ViewModels
|
|
{
|
|
public enum EPortType
|
|
{
|
|
None,
|
|
Execution,
|
|
Integer,
|
|
String,
|
|
Boolean,
|
|
Float,
|
|
Texture,
|
|
Mesh,
|
|
}
|
|
|
|
public class CodeGenPortViewModel : PortViewModel
|
|
{
|
|
private EPortType _portType;
|
|
private bool _isPortVisible;
|
|
|
|
static CodeGenPortViewModel()
|
|
{
|
|
Locator.CurrentMutable.Register(() => new CodeGenPortView(), typeof(IViewFor<CodeGenPortViewModel>));
|
|
}
|
|
|
|
public CodeGenPortViewModel()
|
|
{
|
|
IsPortVisibleChanged = this.WhenAnyValue(vm => vm.IsPortVisible);
|
|
}
|
|
|
|
public EPortType PortType
|
|
{
|
|
get => _portType;
|
|
set => this.RaiseAndSetIfChanged(ref _portType, value);
|
|
}
|
|
|
|
public bool IsPortVisible
|
|
{
|
|
get => _isPortVisible;
|
|
set => this.RaiseAndSetIfChanged(ref _isPortVisible, value);
|
|
}
|
|
|
|
public IObservable<bool> IsPortVisibleChanged { get; }
|
|
|
|
public override void OnDragFromPort()
|
|
{
|
|
var document = ((CodeGenNetworkViewModel)Parent.Parent.Parent).Document;
|
|
var undoRedo = document.MainViewModel.UndoRedo;
|
|
undoRedo.PushGroup(document);
|
|
base.OnDragFromPort();
|
|
}
|
|
|
|
public override void OnDropOnPort()
|
|
{
|
|
var document = ((CodeGenNetworkViewModel)Parent.Parent.Parent).Document;
|
|
var undoRedo = document.MainViewModel.UndoRedo;
|
|
base.OnDropOnPort();
|
|
undoRedo.PopGroup();
|
|
}
|
|
}
|
|
} |