Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sharkboy-j committed Sep 22, 2022
2 parents 37f3ba3 + 5d8c7ce commit 49adaec
Show file tree
Hide file tree
Showing 9 changed files with 431 additions and 113 deletions.
3 changes: 2 additions & 1 deletion src/Kebler.Core/Models/Enums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ public enum MessageBoxDilogButtonsResult
public enum RemoveResult
{
Ok,
Error
Error,
Cancel
}

public enum ReponseResult
Expand Down
1 change: 1 addition & 0 deletions src/Kebler.Models/DefaultSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class DefaultSettings
public CultureInfo Language { get; set; } = new CultureInfo("en");
public bool IsAddTorrentWindowShow { get; set; }
public int UpdateTime { get; set; } = 5000;
public int BackgroundUpdateTimeMS { get; set; } = 25000;
public int TorrentPeerLimit { get; set; } = 25;
public double CategoriesWidth { get; set; } = 150;
public double MoreInfoHeight { get; set; } = 202;
Expand Down
66 changes: 54 additions & 12 deletions src/Kebler.Styles/Themes/Styles/DataGrid.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,47 @@
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="DataGridColumnHeader">
<Border
Name="BackgroundBorder"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
SnapsToDevicePixels="True"
UseLayoutRounding="True">
<ContentPresenter
Margin="5,0"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Border>
<Grid Margin="{TemplateBinding Padding}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>

<Border
Name="BackgroundBorder"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
SnapsToDevicePixels="True"
UseLayoutRounding="True">
<ContentPresenter
Margin="5,0"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Border>
<Thumb
x:Name="PART_RightHeaderGripper" Grid.Column="0"
Grid.ColumnSpan="2"
Margin="0,0,-4,0"
HorizontalAlignment="Right"
Width="9" BorderThickness="0"
Cursor="SizeWE">
<Thumb.Style>
<Style TargetType="{x:Type Thumb}">
<Setter Property="SnapsToDevicePixels" Value="true" />
<Setter Property="OverridesDefaultStyle" Value="true" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Thumb}">
<Ellipse x:Name="Ellipse" Fill="Transparent" StrokeThickness="1"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Thumb.Style>
</Thumb>
</Grid>

</ControlTemplate>
</Setter.Value>
</Setter>
Expand All @@ -43,6 +72,7 @@
<Setter Property="UseLayoutRounding" Value="True" />
<Setter Property="Margin" Value="0" />
<Setter Property="BorderThickness" Value="0" />

<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridRow}">
Expand Down Expand Up @@ -87,6 +117,17 @@
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="ItemsControl.AlternationIndex" Value="0">
<Setter Property="Background" Value="Transparent" />
</Trigger>
<Trigger Property="ItemsControl.AlternationIndex" Value="1">
<Setter Property="Background" Value="#0CC8C8C8" />
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="{DynamicResource Item.SelectedActive.Background}" />
</Trigger>
</Style.Triggers>
</Style>

<Style TargetType="DataGridCell">
Expand Down Expand Up @@ -140,6 +181,7 @@
<Setter Property="GridLinesVisibility" Value="Horizontal" />
<Setter Property="IsReadOnly" Value="True" />
<Setter Property="SelectionMode" Value="Single" />
<Setter Property="AlternationCount" Value="2" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="DataGrid">
Expand Down
20 changes: 10 additions & 10 deletions src/Kebler/Dialogs/RemoveTorrentDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@
<ItemsControl Name="Container" Background="{DynamicResource TextBox.Static.Background}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<ListBoxItem
<TextBlock
Margin="0,2"
VerticalAlignment="Center"
Content="{Binding}"
Text="{Binding}"
FontSize="13"
FontWeight="Normal"
Foreground="White"
Expand Down Expand Up @@ -97,23 +97,23 @@
HorizontalAlignment="Right"
VerticalAlignment="Center"
Visibility="{Binding IsWorking, Converter={StaticResource BoolToVisibilityConverter}, FallbackValue=Visible}" />

<Button
Grid.Column="1"
Width="Auto"
Padding="10,0,10,0"
HorizontalAlignment="Center"
Click="Cancel"
Content="{lex:BLoc BTNS_No}" />
<Button
Grid.Column="3"
Padding="10,0,10,0"
HorizontalAlignment="Center"
Click="Add"
IsDefault="True"
Content="{lex:BLoc BTNS_Yes}"
Visibility="{Binding IsWorking, Converter={StaticResource ReverseBoolToVisibilityConverter}, FallbackValue=Visible}" />

<Button
Grid.Column="3"
Width="Auto"
Padding="10,0,10,0"
HorizontalAlignment="Center"
Click="Cancel"
Content="{lex:BLoc BTNS_No}" />

<Button
Grid.Column="3"
Padding="10,0,10,0"
Expand Down
40 changes: 24 additions & 16 deletions src/Kebler/Dialogs/RemoveTorrentDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using Caliburn.Micro;
using Kebler.Core.Domain.Intrfaces;
using Kebler.Core.Models;
using Kebler.TransmissionTorrentClient;
Expand Down Expand Up @@ -39,14 +40,17 @@ public RemoveTorrentDialog(IEnumerable<string> names, uint[] toRm, ref IRemoteTo
DataContext = this;
}

public bool WithData => RemoveWithDataCheckBox.IsChecked != null && (bool) RemoveWithDataCheckBox.IsChecked;
public bool WithData => RemoveWithDataCheckBox.IsChecked != null && (bool)RemoveWithDataCheckBox.IsChecked;
public bool IsWorking { get; set; }


private void Cancel(object sender, RoutedEventArgs e)
{
Container.ItemsSource = null;
Container = null;
IsWorking = false;
DialogResult = false;
Result = Enums.RemoveResult.Cancel;
_cancellationTokenSource.Cancel();
Close();
}
Expand All @@ -59,26 +63,30 @@ private void Stop(object sender, RoutedEventArgs e)

public async void Add(object sender, RoutedEventArgs e)
{
IsWorking = true;
var with = WithData;
await Task.Factory.StartNew(async () =>

try
{
Log.Info("Start removing: " + string.Join(", ", _toRemove));
while (true)
IsWorking = true;
var with = WithData;

await Task.Factory.StartNew(async () =>
{
if (Dispatcher.HasShutdownStarted)
return;
Result = await _transmissionClient.TorrentRemoveAsync(_toRemove, _cancellationToken, with);
Log.Info("RM response: " + Result);
if (Result == Enums.RemoveResult.Ok)
Log.Info("Start removing: " + string.Join(", ", _toRemove));
while (true)
{
DialogResult = true;
break;
if (Dispatcher.HasShutdownStarted)
return;
Result = await _transmissionClient.TorrentRemoveAsync(_toRemove, _cancellationToken, with);
Log.Info("RM response: " + Result);
}
}, _cancellationToken);
}
finally
{
Container.ItemsSource = null;
Container = null;
}

await Task.Delay(500, _cancellationToken);
}
}, _cancellationToken);
Close();
}

Expand Down
Loading

0 comments on commit 49adaec

Please sign in to comment.