48 lines
1.5 KiB
C#
48 lines
1.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Input;
|
|
using VRage.Game;
|
|
|
|
namespace Torch.Server.ViewModels
|
|
{
|
|
public class BlockLimitViewModel : ViewModel
|
|
{
|
|
private SessionSettingsViewModel _sessionSettings;
|
|
private string _blockType;
|
|
private short _limit;
|
|
|
|
public string BlockType { get => _blockType; set { _blockType = value; OnPropertyChanged(); } }
|
|
public short Limit { get => _limit; set { _limit = value; OnPropertyChanged(); } }
|
|
|
|
public CommandBinding Delete { get; } = new CommandBinding(new DeleteCommand());
|
|
|
|
public BlockLimitViewModel(SessionSettingsViewModel sessionSettings, string blockType, short limit)
|
|
{
|
|
_sessionSettings = sessionSettings;
|
|
_blockType = blockType;
|
|
_limit = limit;
|
|
}
|
|
|
|
public class DeleteCommand : ICommand
|
|
{
|
|
/// <inheritdoc />
|
|
public bool CanExecute(object parameter)
|
|
{
|
|
return ((BlockLimitViewModel)parameter)._sessionSettings.BlockLimits.Contains(parameter);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public void Execute(object parameter)
|
|
{
|
|
((BlockLimitViewModel)parameter)._sessionSettings.BlockLimits.Remove((BlockLimitViewModel)parameter);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public event EventHandler CanExecuteChanged;
|
|
}
|
|
}
|
|
}
|