Skip to content

Commit 432c257

Browse files
committed
feat(Avalonia): add Hastebin uploader settings
1 parent 1f9ee94 commit 432c257

2 files changed

Lines changed: 61 additions & 0 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<UserControl
2+
x:Class="SnapX.Avalonia.Views.Settings.Views.TextUploaders.HastebinUploaderSettingsView"
3+
x:DataType="txt:Hastebin"
4+
xmlns="https://github.com/avaloniaui"
5+
xmlns:controls="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
6+
xmlns:txt="clr-namespace:SnapX.Core.Upload.Text;assembly=SnapX.Core"
7+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
8+
9+
<StackPanel Spacing="4">
10+
<controls:SettingsExpanderItem Content="Custom Domain" Description="Use a different API if you need, otherwise leave default. Hastebin Topal is NOT supported.">
11+
<controls:SettingsExpanderItem.Footer>
12+
<TextBox
13+
Name="txtCustomURL"
14+
Watermark="https://pastie.io"
15+
Width="200" />
16+
</controls:SettingsExpanderItem.Footer>
17+
</controls:SettingsExpanderItem>
18+
19+
<controls:SettingsExpanderItem Content="Syntax highlighting">
20+
<controls:SettingsExpanderItem.Footer>
21+
<TextBox
22+
Name="txtSyntaxHightlight"
23+
Watermark="hs"
24+
Width="200" />
25+
</controls:SettingsExpanderItem.Footer>
26+
</controls:SettingsExpanderItem>
27+
<controls:SettingsExpanderItem Content="Paste Options">
28+
<controls:SettingsExpanderItem.Footer>
29+
<CheckBox Content="Use file extension for syntax highlighting (except .txt)" Name="cbUseFileExtension" />
30+
</controls:SettingsExpanderItem.Footer>
31+
</controls:SettingsExpanderItem>
32+
</StackPanel>
33+
</UserControl>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
using Avalonia.Controls;
3+
using SnapX.Core.Upload.Text;
4+
5+
namespace SnapX.Avalonia.Views.Settings.Views.TextUploaders;
6+
7+
public partial class HastebinUploaderSettingsView : UserControl
8+
{
9+
public HastebinUploaderSettingsView()
10+
{
11+
InitializeComponent();
12+
}
13+
14+
protected override void OnDataContextChanged(EventArgs e)
15+
{
16+
base.OnDataContextChanged(e);
17+
18+
if (DataContext is not Hastebin) return;
19+
var config = SnapX.Core.SnapXL.UploadersConfig;
20+
cbUseFileExtension.IsChecked = config.HastebinUseFileExtension;
21+
cbUseFileExtension.IsCheckedChanged += (Sender, Args) => config.HastebinUseFileExtension = cbUseFileExtension.IsChecked ?? false;
22+
23+
txtSyntaxHightlight.Text = config.HastebinSyntaxHighlighting;
24+
txtSyntaxHightlight.TextChanged += (Sender, Args) => config.HastebinSyntaxHighlighting = txtSyntaxHightlight.Text;
25+
txtCustomURL.Text = config.HastebinCustomDomain;
26+
txtCustomURL.TextChanged += (Sender, Args) => config.HastebinCustomDomain = txtCustomURL.Text;
27+
}
28+
}

0 commit comments

Comments
 (0)