Skip to content

Commit

Permalink
more loading indicators
Browse files Browse the repository at this point in the history
added app manifest
added Hide button to info expander
fixed some styles

changed WindowsStartUp stuff,
maybe now windows defender won't say anidow is a virus
  • Loading branch information
Tensei committed May 31, 2021
1 parent 1d781d9 commit 95a0993
Show file tree
Hide file tree
Showing 21 changed files with 218 additions and 85 deletions.
4 changes: 2 additions & 2 deletions anidow/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
</s:ApplicationLoader.Bootstrapper>

<s:ApplicationLoader.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/AdonisUI;component/ColorSchemes/Dark.xaml" />
<ResourceDictionary Source="pack://application:,,,/AdonisUI.ClassicTheme;component/Resources.xaml" />
<ResourceDictionary Source="{x:Static adonisUi:ResourceLocator.DarkColorScheme}" />
<ResourceDictionary Source="{x:Static adonisUi:ResourceLocator.ClassicTheme}" />
<ResourceDictionary Source="pack://application:,,,/Styles/Expander.xaml" />
<ResourceDictionary Source="pack://application:,,,/Styles/TabControl.xaml" />
<ResourceDictionary Source="pack://application:,,,/Styles/ListViewItem.xaml" />
Expand Down
1 change: 1 addition & 0 deletions anidow/Bootstrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ protected override void ConfigureIoC(IStyletIoCBuilder builder)
builder.Bind<Assembly>().ToInstance(Assembly.GetExecutingAssembly());
var tracker = InitTracker();
builder.Bind<Tracker>().ToInstance(tracker);
builder.Bind<WindowsStartUp>().ToSelf();

var logViewModel = new LogViewModel();
InitLogger(logViewModel);
Expand Down
4 changes: 2 additions & 2 deletions anidow/Events/DownloadEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace Anidow.Events
{
public class DownloadEvent
{
public object Item { get; set; }
public Torrent Torrent { get; set; }
public object Item { get; init; }
public Torrent Torrent { get; init; }
}
}
35 changes: 24 additions & 11 deletions anidow/Helpers/WindowsStartUp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,30 @@

namespace Anidow.Helpers
{
public static class WindowsStartUp
public class WindowsStartUp
{
private static readonly string StartUpFolder = Environment.GetFolderPath(Environment.SpecialFolder.Startup);

private static readonly string StartUpFile = Path.Combine(StartUpFolder, Application.ProductName + ".lnk");
private readonly Assembly _assembly;

public WindowsStartUp(Assembly assembly)
{
_assembly = assembly;
}

public static async Task Enable(Assembly assembly)
public async Task Enable()
{
var licenses = assembly.GetManifestResourceNames().Single(p => p.EndsWith("create-shortcut.ps1"));
await using var stream = assembly.GetManifestResourceStream(licenses);
var startUpFolder = Environment.GetFolderPath(Environment.SpecialFolder.Startup);
var startUpFile = Path.Combine(startUpFolder, Application.ProductName + ".lnk");

var licenses = _assembly.GetManifestResourceNames().Single(p => p.EndsWith("create-shortcut.ps1"));
await using var stream = _assembly.GetManifestResourceStream(licenses);
using var reader = new StreamReader(stream!);
var json = await reader.ReadToEndAsync();

var exeFile = Process.GetCurrentProcess().MainModule.FileName;
var wd = Path.GetDirectoryName(exeFile);

json = json.Replace("$args[0]", $"'{exeFile}'")
.Replace("$args[1]", $"'{StartUpFile}'")
.Replace("$args[1]", $"'{startUpFile}'")
.Replace("$args[2]", $"'{wd}'");

var tmpFile = Path.Combine(Path.GetTempPath(), "create-shortcut.ps1");
Expand All @@ -49,11 +54,14 @@ public static async Task Enable(Assembly assembly)
_ = process.WaitForExitAsync().ContinueWith(_ => File.Delete(tmpFile));
}

public static void Disable()
public void Disable()
{

var startUpFolder = Environment.GetFolderPath(Environment.SpecialFolder.Startup);
var startUpFile = Path.Combine(startUpFolder, Application.ProductName + ".lnk");
try
{
File.Delete(StartUpFile);
File.Delete(startUpFile);
}
catch (Exception e)
{
Expand All @@ -62,6 +70,11 @@ public static void Disable()
}
}

public static bool IsEnabled() => File.Exists(StartUpFile);
public bool IsEnabled()
{
var startUpFolder = Environment.GetFolderPath(Environment.SpecialFolder.Startup);
var startUpFile = Path.Combine(startUpFolder, Application.ProductName + ".lnk");
return File.Exists(startUpFile);
}
}
}
13 changes: 8 additions & 5 deletions anidow/Pages/AnimeBytesRssView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:model="clr-namespace:Anidow.Model"
xmlns:s="https://github.com/canton7/Stylet"
xmlns:shared="clr-namespace:Anidow.Pages.Components.Shared"
d:DataContext="{d:DesignInstance local:AnimeBytesRssViewModel}"
d:DesignHeight="450"
d:DesignWidth="800"
Expand Down Expand Up @@ -88,8 +89,7 @@
SelectedItem="{Binding ActiveItem}"
Visibility="{Binding CanSearch, Converter={x:Static s:BoolToVisibilityConverter.Instance}}">
<ListView.View>
<GridView AllowsColumnReorder="True"
ColumnHeaderContainerStyle="{StaticResource GridViewLeftContainerStyle}">
<GridView AllowsColumnReorder="True" ColumnHeaderContainerStyle="{StaticResource GridViewLeftContainerStyle}">
<GridViewColumn
extensions:GridViewSortExtension.PropertyName="Name"
listViewLayout:RangeColumn.IsFillColumn="true"
Expand Down Expand Up @@ -261,9 +261,7 @@
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBox
Text="{Binding ActiveItem.Folder, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
TextWrapping="Wrap" />
<TextBox Text="{Binding ActiveItem.Folder, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" TextWrapping="Wrap" />
<Button
Grid.Column="1"
Margin="8,0,0,0"
Expand Down Expand Up @@ -316,5 +314,10 @@
</StackPanel>
</Grid>
</Expander>

<shared:LoadingOverlay
Grid.Row="1"
Grid.RowSpan="2"
DataContext="{Binding CanGetItems}" />
</Grid>
</UserControl>
2 changes: 1 addition & 1 deletion anidow/Pages/AnimeBytesRssViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public async Task GetItems()
animeBytesFeedItem.CanTrack = !tracked.Contains(animeBytesFeedItem.GroupId);
}

await Execute.OnUIThreadAsync(() => Items.Add(animeBytesFeedItem));
await DispatcherUtil.DispatchAsync(() => Items.Add(animeBytesFeedItem));
}

_scrollViewer?.ScrollToTop();
Expand Down
7 changes: 6 additions & 1 deletion anidow/Pages/AnimeBytesSearchView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:model="clr-namespace:Anidow.Model"
xmlns:s="https://github.com/canton7/Stylet"
xmlns:shared="clr-namespace:Anidow.Pages.Components.Shared"
d:DataContext="{d:DesignInstance local:AnimeBytesSearchViewModel}"
d:DesignHeight="450"
d:DesignWidth="800"
Expand All @@ -21,7 +22,6 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<GroupBox
Margin="2,4,2,2"
Expand Down Expand Up @@ -377,5 +377,10 @@
</StackPanel>
</Grid>
</Expander>

<shared:LoadingOverlay
Grid.Row="1"
Grid.RowSpan="2"
DataContext="{Binding CanGetItems}" />
</Grid>
</UserControl>
5 changes: 4 additions & 1 deletion anidow/Pages/AnimeBytesSearchViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ public async Task GetItems()
}

Items.Clear();
Items.AddRange(response.Groups);
foreach (var anime in response.Groups)
{
await DispatcherUtil.DispatchAsync(() => Items.Add(anime));
}

_scrollViewer?.ScrollToTop();
ActiveItem = null!;
Expand Down
10 changes: 9 additions & 1 deletion anidow/Pages/Components/Shared/EpisodeInformationActions.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
<ColumnDefinition Width="*" />
<ColumnDefinition Width="8" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="8" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>

<controls:SplitButton
Expand Down Expand Up @@ -60,12 +62,18 @@
Content="Delete" />-->
<Button
Grid.Column="2"
Command="{s:Action HideItem}"
CommandParameter="{Binding ActiveItem}"
Content="Hide"
Style="{DynamicResource {x:Static adonisUi:Styles.AccentButton}}" />
<Button
Grid.Column="4"
Command="{s:Action ToggleWatch}"
CommandParameter="{Binding ActiveItem}"
Content="Toggle Watched"
Style="{DynamicResource {x:Static adonisUi:Styles.AccentButton}}" />
<Button
Grid.Column="4"
Grid.Column="6"
Command="{s:Action Watch}"
CommandParameter="{Binding ActiveItem}"
Content="Watch"
Expand Down
18 changes: 7 additions & 11 deletions anidow/Pages/Components/Tracked/TrackedCardViewItem.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,24 @@
xmlns:s="https://github.com/canton7/Stylet"
Width="140"
Height="190"
Margin="2.5,8,2.5,0"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">
<Grid SnapsToDevicePixels="True">
<Border
Margin="2.5,8,2.5,0"
Background="{DynamicResource {x:Static adonisUi:Brushes.Layer1BackgroundBrush}}"
BorderThickness="2"
MouseDown="{s:Action CardEditAnime}">
<Grid Background="{DynamicResource {x:Static adonisUi:Brushes.Layer1BackgroundBrush}}" MouseLeftButtonDown="{s:Action CardEditAnime}">
<Border>
<Border.Style>
<Style TargetType="Border">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="BorderBrush" Value="{DynamicResource {x:Static adonisUi:Brushes.AccentHighlightBrush}}" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="BorderThickness" Value="2" />
</Trigger>
<Trigger Property="IsMouseOver" Value="False">
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="BorderThickness" Value="2" />
</Trigger>
<DataTrigger Binding="{Binding TrackedViewSelected}" Value="True">
<Setter Property="BorderBrush" Value="{DynamicResource {x:Static adonisUi:Brushes.AccentHighlightBrush}}" />
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
Expand All @@ -42,12 +38,11 @@
</Grid.RowDefinitions>
<Image
Grid.RowSpan="2"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
RenderOptions.BitmapScalingMode="HighQuality"
Source="{Binding CoverData.FilePath, IsAsync=True}"
Stretch="UniformToFill"
Visibility="{Binding CoverData.File, Converter={x:Static converters:IsNullToVisibilityConverter.Instance}}" />

<StackPanel
Grid.Row="0"
Margin="8"
Expand Down Expand Up @@ -92,6 +87,7 @@
Points="0,0 20,0, 0,20"
ToolTip="{Binding Status, Mode=OneWay}" />
</Grid>

</Border>
</Grid>

Expand Down
2 changes: 1 addition & 1 deletion anidow/Pages/Components/Tracked/TrackedOverViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ protected override void OnDeactivate()

public void CardEditAnime(object sender, MouseButtonEventArgs _)
{
var anime = (Anime)((Border)sender).DataContext;
var anime = (Anime)((Grid)sender).DataContext;
ChangeActiveItem(anime, false);
_eventAggregator.Publish(new OpenAnimeEditEvent{Anime = anime});
}
Expand Down
29 changes: 3 additions & 26 deletions anidow/Pages/FolderFilesView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@
</GroupStyle>
</ListView.GroupStyle>-->
<ListView.View>
<GridView AllowsColumnReorder="True"
ColumnHeaderContainerStyle="{StaticResource GridViewLeftContainerStyle}">
<GridView AllowsColumnReorder="True" ColumnHeaderContainerStyle="{StaticResource GridViewLeftContainerStyle}">
<GridViewColumn
extensions:GridViewSortExtension.PropertyName="File.Name"
listViewLayout:RangeColumn.IsFillColumn="true"
Expand Down Expand Up @@ -152,30 +151,8 @@
<GridViewColumn
Width="70"
listViewLayout:FixedColumn.Width="70"
HeaderContainerStyle="{StaticResource GridViewCenteredContainerStyle}">
<GridViewColumn.CellTemplate>
<DataTemplate DataType="models:FolderFilesModel">
<Grid>
<Button
Width="66"
Command="{s:Action Watch}"
CommandParameter="{Binding File}"
Content="Watch"
Style="{StaticResource ColumnButton}"
ToolTip="Watch"
Visibility="{Binding CanOpenFile, Converter={x:Static s:BoolToVisibilityConverter.Instance}}" />
<Button
Width="66"
Command="{s:Action OpenFolder}"
CommandParameter="{Binding File.FullName}"
Content="{iconPacks:FontAwesome FolderOpenSolid}"
Style="{StaticResource ColumnButton}"
ToolTip="Open Folder"
Visibility="{Binding IsDirectory, Converter={x:Static s:BoolToVisibilityConverter.Instance}}" />
</Grid>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
CellTemplate="{StaticResource WatchOpenFile}"
HeaderContainerStyle="{StaticResource GridViewCenteredContainerStyle}" />
</GridView>
</ListView.View>
</ListView>
Expand Down
6 changes: 6 additions & 0 deletions anidow/Pages/HistoryView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:models="clr-namespace:Anidow.Database.Models"
xmlns:s="https://github.com/canton7/Stylet"
xmlns:shared="clr-namespace:Anidow.Pages.Components.Shared"
xmlns:system="clr-namespace:System;assembly=System.Runtime"
d:DataContext="{d:DesignInstance local:HistoryViewModel}"
d:DesignHeight="450"
Expand Down Expand Up @@ -376,5 +377,10 @@
</Grid>
</Grid>
</Expander>

<shared:LoadingOverlay
Grid.Row="1"
Grid.RowSpan="2"
DataContext="{Binding CanLoadEpisodes}" />
</Grid>
</UserControl>
9 changes: 6 additions & 3 deletions anidow/Pages/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ public async void Handle(DownloadEvent message)
};

await using var db = new TrackContext();
if (message.Item is AnimeBytesTorrentItem ab1)
if (message.Item is AnimeBytesTorrentItem abti)
{
var anime = await db.Anime.FirstOrDefaultAsync(a => a.GroupId == ab1.GroupId);
var anime = await db.Anime.FirstOrDefaultAsync(a => a.GroupId == abti.GroupId);
if (anime != null)
{
item.AnimeId = anime.GroupId;
Expand Down Expand Up @@ -395,7 +395,10 @@ private async Task LoadEpisodes()
.ToListAsync();

Items.Clear();
Items.AddRange(episodes.OrderBy(e => e.Released));
foreach (var episode in episodes.OrderBy(e => e.Released))
{
await DispatcherUtil.DispatchAsync(() => Items.Add(episode));
}
ActiveItem = null;
#if DEBUG
Items.Add(new Episode
Expand Down
3 changes: 3 additions & 0 deletions anidow/Pages/NyaaView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:model="clr-namespace:Anidow.Model"
xmlns:s="https://github.com/canton7/Stylet"
xmlns:shared="clr-namespace:Anidow.Pages.Components.Shared"
d:DataContext="{d:DesignInstance local:NyaaViewModel}"
d:DesignHeight="450"
d:DesignWidth="800"
Expand Down Expand Up @@ -235,5 +236,7 @@

</Grid>
</Expander>

<shared:LoadingOverlay Grid.Row="1" Grid.RowSpan="2" DataContext="{Binding CanGetItems}"/>
</Grid>
</UserControl>

0 comments on commit 95a0993

Please sign in to comment.