add super intelligent save button cuz torch is trash

This commit is contained in:
zznty
2022-10-23 21:27:06 +07:00
parent de7e9e616f
commit d16cdd11a1
4 changed files with 41 additions and 3 deletions

View File

@@ -0,0 +1,18 @@
<UserControl x:Class="TorchRemote.Plugin.ConfigControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:TorchRemote.Plugin"
xmlns:views="clr-namespace:Torch.Views;assembly=Torch"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<views:PropertyGrid Margin="3" />
<Button Grid.Row="1" Margin="5" Content="Save" Click="ButtonBase_OnClick" />
</Grid>
</UserControl>

View File

@@ -0,0 +1,21 @@
using System.Windows;
using System.Windows.Controls;
using Torch;
namespace TorchRemote.Plugin;
public partial class ConfigControl : UserControl
{
private readonly Persistent<Config> _persistent;
public ConfigControl(Persistent<Config> persistent)
{
_persistent = persistent;
InitializeComponent();
}
private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
{
_persistent.Save();
}
}

View File

@@ -25,9 +25,8 @@ public class Plugin : TorchPluginBase, IWpfPlugin
.AddFactory(s => new ChatMonitorManager(s.Torch)); .AddFactory(s => new ChatMonitorManager(s.Torch));
} }
public UserControl GetControl() => new PropertyGrid public UserControl GetControl() => new ConfigControl(_config)
{ {
Margin = new(3),
DataContext = _config.Data DataContext = _config.Data
}; };
} }

View File

@@ -2,5 +2,5 @@
<PluginManifest xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <PluginManifest xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Name>Torch Remote</Name> <Name>Torch Remote</Name>
<Guid>284017F3-9682-4841-A544-EB04DB8CB9BA</Guid> <Guid>284017F3-9682-4841-A544-EB04DB8CB9BA</Guid>
<Version>v1.0.5</Version> <Version>v1.0.6</Version>
</PluginManifest> </PluginManifest>