Skip to content
This repository was archived by the owner on Aug 25, 2024. It is now read-only.

Commit d0fa3fa

Browse files
committed
add max records in settings, rm dep of xctk
1 parent ea3bb55 commit d0fa3fa

File tree

8 files changed

+174
-28
lines changed

8 files changed

+174
-28
lines changed

build/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class BuildContext : FrostingContext
3434
public Lazy<SolutionParserResult> DefaultSln { get; set; }
3535
public const string DeployFramework = "net7.0-windows";
3636
public string PublishDir = ".dist";
37-
public string PublishVersion = "0.2.3";
37+
public string PublishVersion = "0.2.4";
3838

3939
public BuildContext(ICakeContext context)
4040
: base(context)
@@ -105,7 +105,7 @@ public override void Run(BuildContext context)
105105
});
106106
context.CreateDirectory(dstDir);
107107
var files = context
108-
.GetFiles(@$"{srcDir}/**/(*(c|C)lipboard*.(png|json|dll)|*.png|plugin.json|(*simulator|Xceed.Wpf.Toolkit.NET5).dll)");
108+
.GetFiles(@$"{srcDir}/**/(*(c|C)lipboard*.(png|json|dll)|*.png|plugin.json|(*simulator).dll)");
109109
foreach (var f in files)
110110
context.Information($"Adding: {f}");
111111
context.ZipCompress(

src/ClipboardR.Core/Settings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public class Settings
77
public string ConfigFile = null!;
88

99
public bool CacheImages { get; set; } = false;
10-
public uint MaxDataCount { get; set; } = 10000;
10+
public int MaxDataCount { get; set; } = 10000;
1111

1212
public void Save()
1313
{

src/ClipboardR.Panels/ClipboardR.Panels.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
</ItemGroup>
2626

2727
<ItemGroup>
28-
<PackageReference Include="Extended.Wpf.Toolkit" Version="4.5.0" />
2928
<PackageReference Include="Flow.Launcher.Plugin" Version="4.0.2" />
3029
</ItemGroup>
3130

src/ClipboardR.Panels/SettingsPanel.xaml

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6-
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
76
xmlns:local="clr-namespace:ClipboardR.Panels"
87
mc:Ignorable="d"
98
d:DesignHeight="120" d:DesignWidth="400"
@@ -20,7 +19,7 @@
2019
</Grid.RowDefinitions>
2120
<Grid.ColumnDefinitions>
2221
<ColumnDefinition Width="Auto"/>
23-
<ColumnDefinition Width="Auto"/>
22+
<ColumnDefinition Width="10"/>
2423
<ColumnDefinition Width="Auto"/>
2524
</Grid.ColumnDefinitions>
2625
<CheckBox
@@ -33,21 +32,14 @@
3332
HorizontalAlignment="Center"
3433
VerticalAlignment="Center"
3534
FontSize="14"/>
36-
<Label
37-
Grid.Row="0" Grid.Column="1"
38-
Content="Max Record Count: "
39-
FontSize="14"
40-
HorizontalAlignment="Right"
41-
VerticalAlignment="Center"/>
42-
<xctk:UIntegerUpDown
43-
x:Name="UpDownMaxRecCount"
35+
<local:SpinBox
36+
x:Name="SpinBoxMaxRec"
4437
Grid.Row="0" Grid.Column="2"
45-
Width="80"
46-
HorizontalAlignment="Left"
47-
VerticalAlignment="Center"
4838
FontSize="14"
49-
Value="{Binding settings.MaxDataCount}"
50-
ValueChanged="UpDownMaxRecCount_OnValueChanged"
39+
PrefixText="Max Records: "
40+
SpinnerMax="100000"
41+
Value="{Binding MaxDataCount}"
42+
ValueChanged="SpinBoxMaxRec_OnValueChanged"
5143
/>
5244
<Button
5345
x:Name="BtnRestartFlow"
@@ -59,8 +51,7 @@
5951
Click="BtnRestartFlow_OnClick"
6052
FontSize="18"/>
6153
<Label
62-
Grid.Row="1" Grid.Column="1"
63-
Grid.ColumnSpan="2"
54+
Grid.Row="1" Grid.Column="2"
6455
Content="Flow.Launcher to apply"
6556
HorizontalAlignment="Left"
6657
VerticalAlignment="Center"

src/ClipboardR.Panels/SettingsPanel.xaml.cs

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,47 @@
44
using System.Windows.Input;
55
using Flow.Launcher.Plugin;
66
using ClipboardR.Core;
7-
using Xceed.Wpf.Toolkit;
87

98
namespace ClipboardR.Panels;
109

1110
public partial class SettingsPanel : UserControl
1211
{
1312
public Settings settings { get; set; }
1413
private PluginInitContext _context { get; set; }
14+
15+
public static readonly DependencyProperty MaxDataCountProperty = DependencyProperty.Register(
16+
nameof(MaxDataCount), typeof(int), typeof(SettingsPanel), new PropertyMetadata(default(int)));
17+
18+
public int MaxDataCount
19+
{
20+
get => settings.MaxDataCount;
21+
set
22+
{
23+
SetValue(MaxDataCountProperty, value);
24+
settings.MaxDataCount = value;
25+
SpinBoxMaxRec.Value = value;
26+
}
27+
}
28+
1529
public SettingsPanel(Settings settings, PluginInitContext ctx)
1630
{
1731
this.settings = settings;
1832
_context = ctx;
1933
InitializeComponent();
34+
MaxDataCount = settings.MaxDataCount;
35+
}
36+
37+
/// <summary>
38+
/// Note: For Test UI Only !!!
39+
/// Any interaction with Flow.Launcher will cause exit
40+
/// </summary>
41+
public SettingsPanel()
42+
{
43+
this.settings = new Settings(){ConfigFile = "test.json"};
44+
_context = new PluginInitContext();
45+
InitializeComponent();
46+
MaxDataCount = settings.MaxDataCount;
47+
// SpinBoxMaxRec.ValueChanged += i => MessageBox.Show($"{i}");
2048
}
2149

2250
private void CkBoxCacheImages_OnChecked(object sender, RoutedEventArgs e)
@@ -25,14 +53,13 @@ private void CkBoxCacheImages_OnChecked(object sender, RoutedEventArgs e)
2553
settings.CacheImages = c.IsChecked ?? false;
2654
}
2755

28-
private void UpDownMaxRecCount_OnValueChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
56+
private void BtnRestartFlow_OnClick(object sender, RoutedEventArgs e)
2957
{
30-
if (sender is UIntegerUpDown { Value: { } } u)
31-
settings.MaxDataCount = u.Value.Value;
58+
_context.API.RestartApp();
3259
}
3360

34-
private void BtnRestartFlow_OnClick(object sender, RoutedEventArgs e)
61+
private void SpinBoxMaxRec_OnValueChanged(int v)
3562
{
36-
_context.API.RestartApp();
63+
MaxDataCount = v;
3764
}
3865
}

src/ClipboardR.Panels/SpinBox.xaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<UserControl x:Class="ClipboardR.Panels.SpinBox"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:local="clr-namespace:ClipboardR.Panels"
7+
DataContext="{Binding RelativeSource={RelativeSource Self}}"
8+
mc:Ignorable="d"
9+
d:DesignHeight="40" d:DesignWidth="200">
10+
<Grid>
11+
<Grid.ColumnDefinitions>
12+
<ColumnDefinition Width="Auto" />
13+
<ColumnDefinition Width="*" />
14+
<ColumnDefinition Width="20" />
15+
</Grid.ColumnDefinitions>
16+
<Label
17+
x:Name="Prefix"
18+
Grid.Row="0"
19+
Grid.Column="0"
20+
Content="{Binding PrefixText}"
21+
HorizontalContentAlignment="Center"
22+
VerticalContentAlignment="Center"
23+
/>
24+
<TextBox
25+
x:Name="ValueBox"
26+
Grid.Row="0"
27+
Grid.Column="1"
28+
HorizontalContentAlignment="Left"
29+
VerticalContentAlignment="Center"
30+
Text="{Binding ElementName=SpinnerScr, Path=Value, StringFormat={}{0:####0}}"
31+
PreviewTextInput="ValueBox_OnPreviewTextInput"
32+
TextChanged="ValueBox_OnTextChanged"
33+
/>
34+
<ScrollBar
35+
Grid.Column="2"
36+
x:Name="SpinnerScr"
37+
Background="Transparent"
38+
Focusable="True"
39+
Grid.Row="0"
40+
Minimum="1"
41+
Maximum="{Binding SpinnerMax}"
42+
Orientation="Vertical"
43+
SmallChange="1"
44+
TabIndex="1"
45+
Visibility="Visible"
46+
>
47+
<ScrollBar.RenderTransform>
48+
<RotateTransform Angle="180"/>
49+
</ScrollBar.RenderTransform>
50+
<ScrollBar.RenderTransformOrigin>
51+
<Point X="0.5" Y="0.5"></Point>
52+
</ScrollBar.RenderTransformOrigin>
53+
</ScrollBar>
54+
</Grid>
55+
</UserControl>
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
using System;
2+
using System.Text.RegularExpressions;
3+
using System.Windows;
4+
using System.Windows.Controls;
5+
using System.Windows.Input;
6+
7+
namespace ClipboardR.Panels;
8+
9+
public partial class SpinBox : UserControl
10+
{
11+
private static readonly Regex NumRegex = new Regex("[^0-9]+");
12+
public static readonly DependencyProperty PrefixTextProperty = DependencyProperty.Register(
13+
nameof(PrefixText), typeof(string), typeof(SpinBox), new PropertyMetadata(default(string)));
14+
15+
public string PrefixText
16+
{
17+
get => (string)GetValue(PrefixTextProperty);
18+
set => SetValue(PrefixTextProperty, value);
19+
}
20+
21+
public static readonly DependencyProperty SpinnerMaxProperty = DependencyProperty.Register(
22+
nameof(SpinnerMax), typeof(int), typeof(SpinBox), new PropertyMetadata(default(int)));
23+
24+
public int SpinnerMax
25+
{
26+
get => (int)SpinnerScr.Maximum;
27+
set => SetValue(SpinnerMaxProperty, value);
28+
}
29+
30+
public static readonly DependencyProperty ValueProperty = DependencyProperty.Register(
31+
nameof(Value), typeof(int), typeof(SpinBox), new PropertyMetadata(default(int)));
32+
33+
public int Value
34+
{
35+
get => (int)SpinnerScr.Value;
36+
set
37+
{
38+
SetValue(ValueProperty, value);
39+
SpinnerScr.Value = value;
40+
}
41+
}
42+
43+
public delegate void OnValueChanged(int v);
44+
public event OnValueChanged? ValueChanged;
45+
46+
public SpinBox(string prefixText)
47+
{
48+
PrefixText = prefixText;
49+
InitializeComponent();
50+
}
51+
52+
public SpinBox()
53+
{
54+
PrefixText = "";
55+
InitializeComponent();
56+
}
57+
58+
private void ValueBox_OnPreviewTextInput(object sender, TextCompositionEventArgs e)
59+
{
60+
e.Handled = NumRegex.IsMatch(e.Text);
61+
if (int.TryParse(e.Text, out int a))
62+
e.Handled = e.Handled && a <= SpinnerScr.Maximum;
63+
}
64+
65+
private void ValueBox_OnTextChanged(object sender, TextChangedEventArgs e)
66+
{
67+
if (string.IsNullOrEmpty(ValueBox.Text)) return;
68+
if (!int.TryParse(ValueBox.Text, out var v)) return;
69+
if (v > SpinnerScr.Maximum)
70+
ValueBox.Text = $"{SpinnerScr.Maximum}";
71+
SpinnerScr.Value = v;
72+
ValueChanged?.Invoke((int)SpinnerScr.Value);
73+
}
74+
}

src/ClipboardR/Main.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class ClipboardR : IPlugin, IDisposable, ISettingProvider, ISavable
2222
private DirectoryInfo ClipCacheDir { get; set; } = null!;
2323
private string _defaultIconPath = null!;
2424
private string _defaultPinIconPath = null!;
25-
private uint _maxDataCount = 10000;
25+
private int _maxDataCount = 10000;
2626
private const string PinUnicode = "📌";
2727
private Settings _settings = null!;
2828
private string _settingsPath = null!;

0 commit comments

Comments
 (0)