Add block limit editor, various UI tweaks
This commit is contained in:
@@ -10,6 +10,9 @@ using NLog.Targets;
|
|||||||
|
|
||||||
namespace Torch.Server
|
namespace Torch.Server
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// NLog target that writes to a <see cref="FlowDocument"/>.
|
||||||
|
/// </summary>
|
||||||
[Target("flowDocument")]
|
[Target("flowDocument")]
|
||||||
public sealed class FlowDocumentTarget : TargetWithLayout
|
public sealed class FlowDocumentTarget : TargetWithLayout
|
||||||
{
|
{
|
||||||
|
@@ -86,30 +86,21 @@ quit";
|
|||||||
public void Run()
|
public void Run()
|
||||||
{
|
{
|
||||||
_server = new TorchServer(_config);
|
_server = new TorchServer(_config);
|
||||||
try
|
var init = Task.Run(() => _server.Init());
|
||||||
|
if (!_config.NoGui)
|
||||||
{
|
{
|
||||||
var init = Task.Run(() => _server.Init());
|
if (_config.Autostart)
|
||||||
if (!_config.NoGui)
|
init.ContinueWith(x => _server.Start());
|
||||||
{
|
|
||||||
if (_config.Autostart)
|
|
||||||
init.ContinueWith(x => _server.Start());
|
|
||||||
|
|
||||||
Log.Info("Showing UI");
|
Log.Info("Showing UI");
|
||||||
Console.SetOut(TextWriter.Null);
|
Console.SetOut(TextWriter.Null);
|
||||||
NativeMethods.FreeConsole();
|
NativeMethods.FreeConsole();
|
||||||
new TorchUI(_server).ShowDialog();
|
new TorchUI(_server).ShowDialog();
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
init.Wait();
|
|
||||||
_server.Start();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch
|
else
|
||||||
{
|
{
|
||||||
if (_server.IsRunning)
|
init.Wait();
|
||||||
_server.Stop();
|
_server.Start();
|
||||||
_server.Destroy();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,20 +1,31 @@
|
|||||||
using NLog;
|
#region
|
||||||
using Sandbox;
|
|
||||||
using Sandbox.Game.Multiplayer;
|
|
||||||
using Sandbox.Game.World;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Net;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using NLog;
|
||||||
|
using Sandbox;
|
||||||
|
using Sandbox.Engine.Networking;
|
||||||
|
using Sandbox.Game.Multiplayer;
|
||||||
|
using Sandbox.Game.World;
|
||||||
using Torch.API;
|
using Torch.API;
|
||||||
using Torch.API.Managers;
|
using Torch.API.Managers;
|
||||||
using Torch.API.Session;
|
using Torch.API.Session;
|
||||||
using Torch.Server.Managers;
|
using Torch.Server.Managers;
|
||||||
using Torch.Utils;
|
using Torch.Utils;
|
||||||
using VRage.Game;
|
using VRage;
|
||||||
|
using VRage.Dedicated;
|
||||||
|
using VRage.GameServices;
|
||||||
|
using VRage.Steam;
|
||||||
|
using Timer = System.Threading.Timer;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#pragma warning disable 618
|
#pragma warning disable 618
|
||||||
|
|
||||||
@@ -22,76 +33,14 @@ namespace Torch.Server
|
|||||||
{
|
{
|
||||||
public class TorchServer : TorchBase, ITorchServer
|
public class TorchServer : TorchBase, ITorchServer
|
||||||
{
|
{
|
||||||
//public MyConfigDedicated<MyObjectBuilder_SessionSettings> DedicatedConfig { get; set; }
|
|
||||||
/// <inheritdoc />
|
|
||||||
public float SimulationRatio
|
|
||||||
{
|
|
||||||
get => _simRatio;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_simRatio = value;
|
|
||||||
OnPropertyChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public TimeSpan ElapsedPlayTime
|
|
||||||
{
|
|
||||||
get => _elapsedPlayTime;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_elapsedPlayTime = value;
|
|
||||||
OnPropertyChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public Thread GameThread { get; private set; }
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public ServerState State
|
|
||||||
{
|
|
||||||
get => _state;
|
|
||||||
private set
|
|
||||||
{
|
|
||||||
_state = value;
|
|
||||||
OnPropertyChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public bool IsRunning
|
|
||||||
{
|
|
||||||
get => _isRunning;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_isRunning = value;
|
|
||||||
OnPropertyChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool _canRun;
|
private bool _canRun;
|
||||||
public bool CanRun { get => _canRun; set => SetValue(ref _canRun, value); }
|
|
||||||
|
|
||||||
private bool _hasRun;
|
|
||||||
|
|
||||||
public event Action<ITorchServer> Initialized;
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public InstanceManager DedicatedInstance { get; }
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public string InstanceName => Config?.InstanceName;
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public string InstancePath => Config?.InstancePath;
|
|
||||||
|
|
||||||
private bool _isRunning;
|
|
||||||
private ServerState _state;
|
|
||||||
private TimeSpan _elapsedPlayTime;
|
private TimeSpan _elapsedPlayTime;
|
||||||
|
private bool _hasRun;
|
||||||
|
private bool _isRunning;
|
||||||
private float _simRatio;
|
private float _simRatio;
|
||||||
private Timer _watchdog;
|
private ServerState _state;
|
||||||
private Stopwatch _uptime;
|
private Stopwatch _uptime;
|
||||||
|
private Timer _watchdog;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public TorchServer(TorchConfig config = null)
|
public TorchServer(TorchConfig config = null)
|
||||||
@@ -102,22 +51,50 @@ namespace Torch.Server
|
|||||||
Config = config ?? new TorchConfig();
|
Config = config ?? new TorchConfig();
|
||||||
|
|
||||||
var sessionManager = Managers.GetManager<ITorchSessionManager>();
|
var sessionManager = Managers.GetManager<ITorchSessionManager>();
|
||||||
sessionManager.AddFactory((x) => new MultiplayerManagerDedicated(this));
|
sessionManager.AddFactory(x => new MultiplayerManagerDedicated(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
//public MyConfigDedicated<MyObjectBuilder_SessionSettings> DedicatedConfig { get; set; }
|
||||||
|
/// <inheritdoc />
|
||||||
|
public float SimulationRatio { get => _simRatio; set => SetValue(ref _simRatio, value); }
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public TimeSpan ElapsedPlayTime { get => _elapsedPlayTime; set => SetValue(ref _elapsedPlayTime, value); }
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public Thread GameThread { get; private set; }
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public bool IsRunning { get => _isRunning; set => SetValue(ref _isRunning, value); }
|
||||||
|
|
||||||
|
public bool CanRun { get => _canRun; set => SetValue(ref _canRun, value); }
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public InstanceManager DedicatedInstance { get; }
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public string InstanceName => Config?.InstanceName;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
protected override uint SteamAppId => 244850;
|
protected override uint SteamAppId => 244850;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc />
|
||||||
protected override string SteamAppName => "SpaceEngineersDedicated";
|
protected override string SteamAppName => "SpaceEngineersDedicated";
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public ServerState State { get => _state; private set => SetValue(ref _state, value); }
|
||||||
|
|
||||||
|
public event Action<ITorchServer> Initialized;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public string InstancePath => Config?.InstancePath;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void Init()
|
public override void Init()
|
||||||
{
|
{
|
||||||
Log.Info("Initializing server");
|
Log.Info("Initializing server");
|
||||||
Sandbox.Engine.Platform.Game.IsDedicated = true;
|
MySandboxGame.IsDedicated = true;
|
||||||
base.Init();
|
base.Init();
|
||||||
|
|
||||||
Managers.GetManager<ITorchSessionManager>().SessionStateChanged += OnSessionStateChanged;
|
Managers.GetManager<ITorchSessionManager>().SessionStateChanged += OnSessionStateChanged;
|
||||||
GetManager<InstanceManager>().LoadInstance(Config.InstancePath);
|
GetManager<InstanceManager>().LoadInstance(Config.InstancePath);
|
||||||
CanRun = true;
|
CanRun = true;
|
||||||
@@ -125,15 +102,6 @@ namespace Torch.Server
|
|||||||
Log.Info($"Initialized server '{Config.InstanceName}' at '{Config.InstancePath}'");
|
Log.Info($"Initialized server '{Config.InstanceName}' at '{Config.InstancePath}'");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnSessionStateChanged(ITorchSession session, TorchSessionState newState)
|
|
||||||
{
|
|
||||||
if (newState == TorchSessionState.Unloading || newState == TorchSessionState.Unloaded)
|
|
||||||
{
|
|
||||||
_watchdog?.Dispose();
|
|
||||||
_watchdog = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void Start()
|
public override void Start()
|
||||||
{
|
{
|
||||||
@@ -173,7 +141,7 @@ namespace Torch.Server
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Restart the program.
|
/// Restart the program.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public override void Restart()
|
public override void Restart()
|
||||||
{
|
{
|
||||||
@@ -200,20 +168,24 @@ namespace Torch.Server
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnSessionStateChanged(ITorchSession session, TorchSessionState newState)
|
||||||
|
{
|
||||||
|
if (newState == TorchSessionState.Unloading || newState == TorchSessionState.Unloaded)
|
||||||
|
{
|
||||||
|
_watchdog?.Dispose();
|
||||||
|
_watchdog = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void Init(object gameInstance)
|
public override void Init(object gameInstance)
|
||||||
{
|
{
|
||||||
base.Init(gameInstance);
|
base.Init(gameInstance);
|
||||||
var game = gameInstance as MySandboxGame;
|
var game = gameInstance as MySandboxGame;
|
||||||
if (game != null && MySession.Static != null)
|
if (game != null && MySession.Static != null)
|
||||||
{
|
|
||||||
State = ServerState.Running;
|
State = ServerState.Running;
|
||||||
// SteamServerAPI.Instance.GameServer.SetKeyValue("SM", "Torch");
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
State = ServerState.Stopped;
|
State = ServerState.Stopped;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@@ -238,7 +210,7 @@ namespace Torch.Server
|
|||||||
private static void CheckServerResponding(object state)
|
private static void CheckServerResponding(object state)
|
||||||
{
|
{
|
||||||
var mre = new ManualResetEvent(false);
|
var mre = new ManualResetEvent(false);
|
||||||
((TorchServer) state).Invoke(() => mre.Set());
|
((TorchServer)state).Invoke(() => mre.Set());
|
||||||
if (!mre.WaitOne(TimeSpan.FromSeconds(Instance.Config.TickTimeout)))
|
if (!mre.WaitOne(TimeSpan.FromSeconds(Instance.Config.TickTimeout)))
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
@@ -250,10 +222,8 @@ namespace Torch.Server
|
|||||||
throw new TimeoutException($"Server watchdog detected that the server was frozen for at least {((TorchServer)state).Config.TickTimeout} seconds.");
|
throw new TimeoutException($"Server watchdog detected that the server was frozen for at least {((TorchServer)state).Config.TickTimeout} seconds.");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
Log.Debug("Server watchdog responded");
|
||||||
Log.Debug("Server watchdog responded");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string DumpFrozenThread(Thread thread, int traces = 3, int pause = 5000)
|
private static string DumpFrozenThread(Thread thread, int traces = 3, int pause = 5000)
|
||||||
@@ -267,6 +237,7 @@ namespace Torch.Server
|
|||||||
stacks.Add(dump);
|
stacks.Add(dump);
|
||||||
Thread.Sleep(pause);
|
Thread.Sleep(pause);
|
||||||
}
|
}
|
||||||
|
|
||||||
string commonPrefix = StringUtils.CommonSuffix(stacks);
|
string commonPrefix = StringUtils.CommonSuffix(stacks);
|
||||||
// Advance prefix to include the line terminator.
|
// Advance prefix to include the line terminator.
|
||||||
commonPrefix = commonPrefix.Substring(commonPrefix.IndexOf('\n') + 1);
|
commonPrefix = commonPrefix.Substring(commonPrefix.IndexOf('\n') + 1);
|
||||||
@@ -280,6 +251,7 @@ namespace Torch.Server
|
|||||||
result.AppendLine($"Suffix {i}");
|
result.AppendLine($"Suffix {i}");
|
||||||
result.AppendLine(stacks[i].Substring(0, stacks[i].Length - commonPrefix.Length));
|
result.AppendLine(stacks[i].Substring(0, stacks[i].Length - commonPrefix.Length));
|
||||||
}
|
}
|
||||||
|
|
||||||
return result.ToString();
|
return result.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -293,6 +265,7 @@ namespace Torch.Server
|
|||||||
{
|
{
|
||||||
// ignored
|
// ignored
|
||||||
}
|
}
|
||||||
|
|
||||||
var stack = new StackTrace(thread, true);
|
var stack = new StackTrace(thread, true);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -302,6 +275,7 @@ namespace Torch.Server
|
|||||||
{
|
{
|
||||||
// ignored
|
// ignored
|
||||||
}
|
}
|
||||||
|
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -13,7 +13,7 @@
|
|||||||
<UserControl.Resources>
|
<UserControl.Resources>
|
||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
<ResourceDictionary.MergedDictionaries>
|
<ResourceDictionary.MergedDictionaries>
|
||||||
<ResourceDictionary Source="Resources.xaml"/>
|
<ResourceDictionary Source="Resources.xaml" />
|
||||||
</ResourceDictionary.MergedDictionaries>
|
</ResourceDictionary.MergedDictionaries>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</UserControl.Resources>
|
</UserControl.Resources>
|
||||||
@@ -38,8 +38,8 @@
|
|||||||
<Label Content="{Binding WorldPath}" Padding="5,0,0,0" />
|
<Label Content="{Binding WorldPath}" Padding="5,0,0,0" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<Label Content="Size (KB): " Padding="0"/>
|
<Label Content="Size (KB): " Padding="0" />
|
||||||
<Label Content="{Binding WorldSizeKB}" Padding="0"/>
|
<Label Content="{Binding WorldSizeKB}" Padding="0" />
|
||||||
<Label Content="Last saved: " Padding="5,0,0,0" />
|
<Label Content="Last saved: " Padding="5,0,0,0" />
|
||||||
<Label Content="{Binding Checkpoint.LastSaveTime}" Padding="0" />
|
<Label Content="{Binding Checkpoint.LastSaveTime}" Padding="0" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
@@ -50,74 +50,77 @@
|
|||||||
</DockPanel>
|
</DockPanel>
|
||||||
<Grid Grid.Row="1">
|
<Grid Grid.Row="1">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="Auto" />
|
<ColumnDefinition Width="3*" />
|
||||||
<ColumnDefinition />
|
<ColumnDefinition Width="2*" />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Grid Grid.Column="0">
|
<Grid Grid.Column="0">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition />
|
<RowDefinition />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<ScrollViewer Grid.Row="0" Margin="3">
|
<StackPanel Orientation="Horizontal">
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Margin="3" DockPanel.Dock="Left">
|
||||||
<StackPanel Margin="3" DockPanel.Dock="Left">
|
<Label Content="Server Name" />
|
||||||
<Label Content="Server Name" />
|
<TextBox Text="{Binding ServerName}" Margin="3,0,3,3" Width="160" />
|
||||||
<TextBox Text="{Binding ServerName}" Margin="3,0,3,3" Width="160" />
|
<Label Content="World Name" />
|
||||||
<Label Content="World Name" />
|
<TextBox Text="{Binding WorldName}" Margin="3,0,3,3" Width="160" />
|
||||||
<TextBox Text="{Binding WorldName}" Margin="3,0,3,3" Width="160" />
|
<Label Content="Whitelist Group ID" />
|
||||||
<Label Content="Whitelist Group ID" />
|
<TextBox Margin="3,0,3,3" Width="160" Style="{StaticResource ValidatedTextBox}">
|
||||||
<TextBox Margin="3,0,3,3" Width="160" Style="{StaticResource ValidatedTextBox}">
|
<TextBox.Text>
|
||||||
<TextBox.Text>
|
<Binding Path="GroupId" UpdateSourceTrigger="PropertyChanged"
|
||||||
<Binding Path="GroupId" UpdateSourceTrigger="PropertyChanged"
|
ValidatesOnDataErrors="True" NotifyOnValidationError="True">
|
||||||
ValidatesOnDataErrors="True" NotifyOnValidationError="True">
|
<Binding.ValidationRules>
|
||||||
<Binding.ValidationRules>
|
<validationRules:NumberValidationRule />
|
||||||
<validationRules:NumberValidationRule/>
|
</Binding.ValidationRules>
|
||||||
</Binding.ValidationRules>
|
</Binding>
|
||||||
</Binding>
|
</TextBox.Text>
|
||||||
</TextBox.Text>
|
</TextBox>
|
||||||
</TextBox>
|
<Label Content="Server IP" />
|
||||||
<Label Content="Server IP" />
|
<StackPanel Orientation="Horizontal" Margin="3,0,3,3">
|
||||||
<StackPanel Orientation="Horizontal" Margin="3,0,3,3">
|
<TextBox Text="{Binding IP}" Width="100" Height="20" />
|
||||||
<TextBox Text="{Binding IP}" Width="100" Height="20" />
|
<Label Content=":" Width="12" />
|
||||||
<Label Content=":" Width="12" />
|
<TextBox Text="{Binding Port}" Width="48" Height="20" />
|
||||||
<TextBox Text="{Binding Port}" Width="48" Height="20" />
|
|
||||||
</StackPanel>
|
|
||||||
<CheckBox IsChecked="{Binding PauseGameWhenEmpty}" Content="Pause When Empty" Margin="3" />
|
|
||||||
</StackPanel>
|
|
||||||
<StackPanel Margin="3">
|
|
||||||
<Label Content="Mods" />
|
|
||||||
<TextBox Margin="3" Height="100" AcceptsReturn="true" VerticalScrollBarVisibility="Auto" Style="{StaticResource ValidatedTextBox}">
|
|
||||||
<TextBox.Text>
|
|
||||||
<Binding Path="Mods" UpdateSourceTrigger="PropertyChanged"
|
|
||||||
ValidatesOnDataErrors="True" NotifyOnValidationError="True"
|
|
||||||
Converter="{StaticResource ListConverterUInt64}">
|
|
||||||
<Binding.ValidationRules>
|
|
||||||
<validationRules:ListConverterValidationRule Type="system:UInt64" />
|
|
||||||
</Binding.ValidationRules>
|
|
||||||
</Binding>
|
|
||||||
</TextBox.Text>
|
|
||||||
</TextBox>
|
|
||||||
<Label Content="Administrators" />
|
|
||||||
<TextBox Text="{Binding Administrators, Converter={StaticResource ListConverterString}}" Margin="3"
|
|
||||||
Height="100" AcceptsReturn="true" VerticalScrollBarVisibility="Auto" />
|
|
||||||
<Label Content="Banned Players" />
|
|
||||||
<TextBox Margin="3" Height="100" AcceptsReturn="true" VerticalScrollBarVisibility="Auto" Style="{StaticResource ValidatedTextBox}">
|
|
||||||
<TextBox.Text>
|
|
||||||
<Binding Path="Banned" UpdateSourceTrigger="PropertyChanged"
|
|
||||||
ValidatesOnDataErrors="True" NotifyOnValidationError="True"
|
|
||||||
Converter="{StaticResource ListConverterUInt64}">
|
|
||||||
<Binding.ValidationRules>
|
|
||||||
<validationRules:ListConverterValidationRule Type="system:UInt64" />
|
|
||||||
</Binding.ValidationRules>
|
|
||||||
</Binding>
|
|
||||||
</TextBox.Text>
|
|
||||||
</TextBox>
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
<CheckBox IsChecked="{Binding PauseGameWhenEmpty}" Content="Pause When Empty" Margin="3" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</ScrollViewer>
|
<StackPanel Margin="3">
|
||||||
|
<Label Content="Mods" />
|
||||||
|
<TextBox Margin="3" Height="100" AcceptsReturn="true" VerticalScrollBarVisibility="Auto"
|
||||||
|
Style="{StaticResource ValidatedTextBox}">
|
||||||
|
<TextBox.Text>
|
||||||
|
<Binding Path="Mods" UpdateSourceTrigger="PropertyChanged"
|
||||||
|
ValidatesOnDataErrors="True" NotifyOnValidationError="True"
|
||||||
|
Converter="{StaticResource ListConverterUInt64}">
|
||||||
|
<Binding.ValidationRules>
|
||||||
|
<validationRules:ListConverterValidationRule Type="system:UInt64" />
|
||||||
|
</Binding.ValidationRules>
|
||||||
|
</Binding>
|
||||||
|
</TextBox.Text>
|
||||||
|
</TextBox>
|
||||||
|
<Label Content="Administrators" />
|
||||||
|
<TextBox Text="{Binding Administrators, Converter={StaticResource ListConverterString}}"
|
||||||
|
Margin="3"
|
||||||
|
Height="100" AcceptsReturn="true" VerticalScrollBarVisibility="Auto" />
|
||||||
|
<Label Content="Banned Players" />
|
||||||
|
<TextBox Margin="3" Height="100" AcceptsReturn="true" VerticalScrollBarVisibility="Auto"
|
||||||
|
Style="{StaticResource ValidatedTextBox}">
|
||||||
|
<TextBox.Text>
|
||||||
|
<Binding Path="Banned" UpdateSourceTrigger="PropertyChanged"
|
||||||
|
ValidatesOnDataErrors="True" NotifyOnValidationError="True"
|
||||||
|
Converter="{StaticResource ListConverterUInt64}">
|
||||||
|
<Binding.ValidationRules>
|
||||||
|
<validationRules:ListConverterValidationRule Type="system:UInt64" />
|
||||||
|
</Binding.ValidationRules>
|
||||||
|
</Binding>
|
||||||
|
</TextBox.Text>
|
||||||
|
</TextBox>
|
||||||
|
</StackPanel>
|
||||||
|
</StackPanel>
|
||||||
<Button Grid.Row="1" Content="Save Config" Margin="3" Click="Save_OnClick" />
|
<Button Grid.Row="1" Content="Save Config" Margin="3" Click="Save_OnClick" />
|
||||||
</Grid>
|
</Grid>
|
||||||
<views:PropertyGrid Grid.Column="1" Margin="3" DataContext="{Binding SessionSettings}"/>
|
<views:PropertyGrid Grid.Column="1" Margin="3" DataContext="{Binding SessionSettings}" />
|
||||||
|
<GridSplitter Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Stretch" ShowsPreview="True"
|
||||||
|
Width="2" Background="Gray" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
@@ -14,8 +14,8 @@
|
|||||||
<Grid Margin="3">
|
<Grid Margin="3">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
<RowDefinition Height="*" />
|
|
||||||
<RowDefinition/>
|
<RowDefinition/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<StackPanel Grid.Row="0">
|
<StackPanel Grid.Row="0">
|
||||||
<Label Content="{Binding FullName}" FontSize="16" />
|
<Label Content="{Binding FullName}" FontSize="16" />
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
</StackPanel>
|
</StackPanel>
|
||||||
<Label Content="Properties"/>
|
<Label Content="Properties"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<Expander Grid.Row="1" Header="Block Properties">
|
<Expander Grid.Row="1" Header="Block Properties" IsExpanded="true">
|
||||||
<ListView ItemsSource="{Binding Properties}" Margin="3" IsEnabled="True">
|
<ListView ItemsSource="{Binding Properties}" Margin="3" IsEnabled="True">
|
||||||
<ListView.ItemTemplate>
|
<ListView.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
|
@@ -16,8 +16,8 @@
|
|||||||
</UserControl.Resources>
|
</UserControl.Resources>
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition />
|
<ColumnDefinition Width="5*"/>
|
||||||
<ColumnDefinition MinWidth="300" Width="Auto" />
|
<ColumnDefinition Width="5*" />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Grid Grid.Column="0">
|
<Grid Grid.Column="0">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
@@ -92,5 +92,6 @@
|
|||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Frame Grid.Column="1" x:Name="EditorFrame" Margin="3" NavigationUIVisibility="Hidden" />
|
<Frame Grid.Column="1" x:Name="EditorFrame" Margin="3" NavigationUIVisibility="Hidden" />
|
||||||
|
<GridSplitter Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Stretch" ShowsPreview="True" Width="2" Background="Gray"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
@@ -55,13 +55,18 @@
|
|||||||
<TextBlock Text="{Binding ElapsedPlayTime, StringFormat=Uptime: {0:g}}"/>
|
<TextBlock Text="{Binding ElapsedPlayTime, StringFormat=Uptime: {0:g}}"/>
|
||||||
</Label.Content>
|
</Label.Content>
|
||||||
</Label>
|
</Label>
|
||||||
|
<Label x:Name="LabelPlayers">
|
||||||
|
<Label.Content>
|
||||||
|
<TextBlock ></TextBlock>
|
||||||
|
</Label.Content>
|
||||||
|
</Label>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<TabControl Grid.Row="2" Height="Auto" x:Name="TabControl" Margin="5,10,5,5">
|
<TabControl Grid.Row="2" Height="Auto" x:Name="TabControl" Margin="5,10,5,5">
|
||||||
<TabItem Header="Log">
|
<TabItem Header="Log">
|
||||||
<RichTextBox x:Name="ConsoleText" VerticalScrollBarVisibility="Visible" FontFamily="Consolas"/>
|
<RichTextBox x:Name="ConsoleText" VerticalScrollBarVisibility="Visible" FontFamily="Consolas"/>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem Header="Configuration">
|
<TabItem Header="Configuration">
|
||||||
<Grid IsEnabled="{Binding IsRunning, Converter={StaticResource InverseBool}}">
|
<Grid IsEnabled="{Binding CanRun}">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
<RowDefinition/>
|
<RowDefinition/>
|
||||||
@@ -72,7 +77,7 @@
|
|||||||
<ColumnDefinition/>
|
<ColumnDefinition/>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
</Grid>
|
</Grid>
|
||||||
<views:ConfigControl Grid.Row="1" x:Name="ConfigControl" Margin="3" DockPanel.Dock="Bottom" IsEnabled="{Binding IsRunning, Converter={StaticResource InverseBool}}"/>
|
<views:ConfigControl Grid.Row="1" x:Name="ConfigControl" Margin="3" DockPanel.Dock="Bottom" IsEnabled="{Binding CanRun}"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem Header="Chat/Players">
|
<TabItem Header="Chat/Players">
|
||||||
|
@@ -16,9 +16,9 @@ using System.Windows.Shapes;
|
|||||||
using NLog;
|
using NLog;
|
||||||
using Sandbox;
|
using Sandbox;
|
||||||
using Torch.API;
|
using Torch.API;
|
||||||
|
using Torch.API.Managers;
|
||||||
using Torch.Server.Managers;
|
using Torch.Server.Managers;
|
||||||
using MessageBoxResult = System.Windows.MessageBoxResult;
|
using MessageBoxResult = System.Windows.MessageBoxResult;
|
||||||
using Timer = System.Timers.Timer;
|
|
||||||
|
|
||||||
namespace Torch.Server
|
namespace Torch.Server
|
||||||
{
|
{
|
||||||
@@ -93,7 +93,7 @@ namespace Torch.Server
|
|||||||
if (_server?.State == ServerState.Running)
|
if (_server?.State == ServerState.Running)
|
||||||
_server.Stop();
|
_server.Stop();
|
||||||
|
|
||||||
Environment.Exit(0);
|
Process.GetCurrentProcess().Kill();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BtnRestart_Click(object sender, RoutedEventArgs e)
|
private void BtnRestart_Click(object sender, RoutedEventArgs e)
|
||||||
@@ -109,7 +109,7 @@ namespace Torch.Server
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
_config.InstancePath = name;
|
_config.InstancePath = name;
|
||||||
_server.GetManager<InstanceManager>().LoadInstance(_config.InstancePath);
|
_server.Managers.GetManager<InstanceManager>().LoadInstance(_config.InstancePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -257,6 +257,9 @@
|
|||||||
<Compile Include="Views\CollectionEditor.xaml.cs">
|
<Compile Include="Views\CollectionEditor.xaml.cs">
|
||||||
<DependentUpon>CollectionEditor.xaml</DependentUpon>
|
<DependentUpon>CollectionEditor.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Views\DictionaryEditor.xaml.cs">
|
||||||
|
<DependentUpon>DictionaryEditor.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Views\PropertyGrid.xaml.cs">
|
<Compile Include="Views\PropertyGrid.xaml.cs">
|
||||||
<DependentUpon>PropertyGrid.xaml</DependentUpon>
|
<DependentUpon>PropertyGrid.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
@@ -277,6 +280,10 @@
|
|||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</Page>
|
</Page>
|
||||||
|
<Page Include="Views\DictionaryEditor.xaml">
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</Page>
|
||||||
<Page Include="Views\PropertyGrid.xaml">
|
<Page Include="Views\PropertyGrid.xaml">
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
|
32
Torch/Views/DictionaryEditor.xaml
Normal file
32
Torch/Views/DictionaryEditor.xaml
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<Window x:Class="Torch.Views.DictionaryEditorDialog"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:views="clr-namespace:Torch.Views"
|
||||||
|
xmlns:objectModel="clr-namespace:System.Collections.ObjectModel;assembly=System"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Title="DictionaryEditorDialog" Height="300" Width="300">
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition />
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<DataGrid x:Name="ItemGrid" AutoGenerateColumns="false" CanUserAddRows="true" Grid.Row="0">
|
||||||
|
<DataGrid.Columns>
|
||||||
|
<DataGridTextColumn Width="5*" Header="Key" Binding="{Binding Key}"/>
|
||||||
|
<DataGridTextColumn Width="5*" Header="Value" Binding="{Binding Value}"/>
|
||||||
|
</DataGrid.Columns>
|
||||||
|
</DataGrid>
|
||||||
|
<Button Grid.Row="1" Content="Add New" Margin="5" Click="AddNew_OnClick"></Button>
|
||||||
|
<Grid Grid.Row="2">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition />
|
||||||
|
<ColumnDefinition />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Button Grid.Column="0" Content="Cancel" Margin="5" Click="Cancel_OnClick" />
|
||||||
|
<Button Grid.Column="1" Content="OK" Margin="5" Click="Ok_OnClick" />
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
109
Torch/Views/DictionaryEditor.xaml.cs
Normal file
109
Torch/Views/DictionaryEditor.xaml.cs
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
using NLog;
|
||||||
|
using Torch.Collections;
|
||||||
|
|
||||||
|
namespace Torch.Views
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for DictionaryEditorDialog.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class DictionaryEditorDialog : Window
|
||||||
|
{
|
||||||
|
public DictionaryEditorDialog()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
DataContext = Items;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ObservableCollection<IDictionaryItem> Items { get; } = new ObservableCollection<IDictionaryItem>();
|
||||||
|
private Type _itemType;
|
||||||
|
|
||||||
|
private Action _commitChanges;
|
||||||
|
|
||||||
|
public void Edit(IDictionary dict)
|
||||||
|
{
|
||||||
|
Items.Clear();
|
||||||
|
var dictType = dict.GetType();
|
||||||
|
_itemType = typeof(DictionaryItem<,>).MakeGenericType(dictType.GenericTypeArguments[0], dictType.GenericTypeArguments[1]);
|
||||||
|
|
||||||
|
foreach (var key in dict.Keys)
|
||||||
|
{
|
||||||
|
Items.Add((IDictionaryItem)Activator.CreateInstance(_itemType, key, dict[key]));
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemGrid.ItemsSource = Items;
|
||||||
|
|
||||||
|
_commitChanges = () =>
|
||||||
|
{
|
||||||
|
dict.Clear();
|
||||||
|
foreach (var item in Items)
|
||||||
|
{
|
||||||
|
dict[item.Key] = item.Value;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Cancel_OnClick(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Ok_OnClick(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
_commitChanges?.Invoke();
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface IDictionaryItem
|
||||||
|
{
|
||||||
|
object Key { get; set; }
|
||||||
|
object Value { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DictionaryItem<TKey, TValue> : ViewModel, IDictionaryItem
|
||||||
|
{
|
||||||
|
private TKey _key;
|
||||||
|
private TValue _value;
|
||||||
|
|
||||||
|
object IDictionaryItem.Key { get => _key; set => SetValue(ref _key, (TKey)value); }
|
||||||
|
object IDictionaryItem.Value { get => _value; set => SetValue(ref _value, (TValue)value); }
|
||||||
|
|
||||||
|
public TKey Key { get => _key; set => SetValue(ref _key, value); }
|
||||||
|
public TValue Value { get => _value; set => SetValue(ref _value, value); }
|
||||||
|
|
||||||
|
public DictionaryItem()
|
||||||
|
{
|
||||||
|
_key = default(TKey);
|
||||||
|
_value = default(TValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DictionaryItem(TKey key, TValue value)
|
||||||
|
{
|
||||||
|
_key = key;
|
||||||
|
_value = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddNew_OnClick(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
Items.Add((IDictionaryItem)Activator.CreateInstance(_itemType));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -15,6 +16,7 @@ using System.Windows.Media.Imaging;
|
|||||||
using System.Windows.Navigation;
|
using System.Windows.Navigation;
|
||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
using VRage.Game;
|
using VRage.Game;
|
||||||
|
using VRage.Serialization;
|
||||||
|
|
||||||
namespace Torch.Views
|
namespace Torch.Views
|
||||||
{
|
{
|
||||||
@@ -52,8 +54,8 @@ namespace Torch.Views
|
|||||||
var properties = t.GetProperties(BindingFlags.Instance | BindingFlags.Public);
|
var properties = t.GetProperties(BindingFlags.Instance | BindingFlags.Public);
|
||||||
|
|
||||||
var grid = new Grid();
|
var grid = new Grid();
|
||||||
grid.ColumnDefinitions.Add(new ColumnDefinition());
|
grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(2, GridUnitType.Star) });
|
||||||
grid.ColumnDefinitions.Add(new ColumnDefinition());
|
grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });
|
||||||
|
|
||||||
var curRow = 0;
|
var curRow = 0;
|
||||||
foreach (var property in properties.OrderBy(x => x.Name))
|
foreach (var property in properties.OrderBy(x => x.Name))
|
||||||
@@ -64,6 +66,7 @@ namespace Torch.Views
|
|||||||
grid.RowDefinitions.Add(new RowDefinition());
|
grid.RowDefinitions.Add(new RowDefinition());
|
||||||
|
|
||||||
var displayName = property.GetCustomAttribute<DisplayAttribute>()?.Name;
|
var displayName = property.GetCustomAttribute<DisplayAttribute>()?.Name;
|
||||||
|
var propertyType = property.PropertyType;
|
||||||
|
|
||||||
var text = new TextBlock
|
var text = new TextBlock
|
||||||
{
|
{
|
||||||
@@ -86,12 +89,12 @@ namespace Torch.Views
|
|||||||
};
|
};
|
||||||
valueControl.SetBinding(TextBlock.TextProperty, binding);
|
valueControl.SetBinding(TextBlock.TextProperty, binding);
|
||||||
}
|
}
|
||||||
else if (property.PropertyType == typeof(bool) || property.PropertyType == typeof(bool?))
|
else if (propertyType == typeof(bool) || propertyType == typeof(bool?))
|
||||||
{
|
{
|
||||||
valueControl = new CheckBox();
|
valueControl = new CheckBox();
|
||||||
valueControl.SetBinding(CheckBox.IsCheckedProperty, property.Name);
|
valueControl.SetBinding(CheckBox.IsCheckedProperty, property.Name);
|
||||||
}
|
}
|
||||||
else if (property.PropertyType.IsEnum)
|
else if (propertyType.IsEnum)
|
||||||
{
|
{
|
||||||
valueControl = new ComboBox
|
valueControl = new ComboBox
|
||||||
{
|
{
|
||||||
@@ -99,6 +102,28 @@ namespace Torch.Views
|
|||||||
};
|
};
|
||||||
valueControl.SetBinding(ComboBox.SelectedItemProperty, property.Name);
|
valueControl.SetBinding(ComboBox.SelectedItemProperty, property.Name);
|
||||||
}
|
}
|
||||||
|
else if (propertyType.IsGenericType && propertyType.GetGenericTypeDefinition() == typeof(Dictionary<,>))
|
||||||
|
{
|
||||||
|
var button = new Button
|
||||||
|
{
|
||||||
|
Content = "Edit Collection"
|
||||||
|
};
|
||||||
|
button.SetBinding(Button.DataContextProperty, property.Name);
|
||||||
|
button.Click += (sender, args) => EditDictionary(((Button)sender).DataContext);
|
||||||
|
|
||||||
|
valueControl = button;
|
||||||
|
}
|
||||||
|
else if (propertyType.IsGenericType && propertyType.GetGenericTypeDefinition() == typeof(SerializableDictionary<,>))
|
||||||
|
{
|
||||||
|
var button = new Button
|
||||||
|
{
|
||||||
|
Content = "Edit Collection"
|
||||||
|
};
|
||||||
|
button.SetBinding(Button.DataContextProperty, $"{property.Name}.Dictionary");
|
||||||
|
button.Click += (sender, args) => EditDictionary(((Button)sender).DataContext);
|
||||||
|
|
||||||
|
valueControl = button;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
valueControl = new TextBox();
|
valueControl = new TextBox();
|
||||||
@@ -118,6 +143,12 @@ namespace Torch.Views
|
|||||||
return grid;
|
return grid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void EditDictionary(object dict)
|
||||||
|
{
|
||||||
|
var dic = (IDictionary)dict;
|
||||||
|
new DictionaryEditorDialog().Edit(dic);
|
||||||
|
}
|
||||||
|
|
||||||
private void UpdateFilter(object sender, TextChangedEventArgs e)
|
private void UpdateFilter(object sender, TextChangedEventArgs e)
|
||||||
{
|
{
|
||||||
var filterText = ((TextBox)sender).Text;
|
var filterText = ((TextBox)sender).Text;
|
||||||
|
Reference in New Issue
Block a user