Skip to content

Commit

Permalink
Release v2.0.2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
rocksdanister committed Jul 8, 2022
1 parent 2e68a2a commit 10d1a07
Show file tree
Hide file tree
Showing 15 changed files with 352 additions and 109 deletions.
46 changes: 45 additions & 1 deletion src/Lively/Lively.Common/Helpers/Files/FileOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;

Expand Down Expand Up @@ -203,5 +204,48 @@ public static void DirectoryCopy(string sourceDirName, string destDirName, bool
}
}
}

//ref: https://docs.microsoft.com/en-us/dotnet/standard/parallel-programming/how-to-write-a-simple-parallel-for-loop
public static long GetDirectorySize(string path)
{
long totalSize = 0;
var files = Directory.GetFiles(path, "*", SearchOption.AllDirectories);
Parallel.For(0, files.Length,
index => {
FileInfo fi = new FileInfo(files[index]);
long size = fi.Length;
Interlocked.Add(ref totalSize, size);
});
return totalSize;
}

//ref: https://stackoverflow.com/questions/14488796/does-net-provide-an-easy-way-convert-bytes-to-kb-mb-gb-etc
static readonly string[] SizeSuffixes =
{ "bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" };
public static string SizeSuffix(long value, int decimalPlaces = 1)
{
if (decimalPlaces < 0) { throw new ArgumentOutOfRangeException("decimalPlaces"); }
if (value < 0) { return "-" + SizeSuffix(-value, decimalPlaces); }
if (value == 0) { return string.Format("{0:n" + decimalPlaces + "} bytes", 0); }

// mag is 0 for bytes, 1 for KB, 2, for MB, etc.
int mag = (int)Math.Log(value, 1024);

// 1L << (mag * 10) == 2 ^ (10 * mag)
// [i.e. the number of bytes in the unit corresponding to mag]
decimal adjustedSize = (decimal)value / (1L << (mag * 10));

// make adjustment when the value is large enough that
// it would round up to 1000 or more
if (Math.Round(adjustedSize, decimalPlaces) >= 1000)
{
mag += 1;
adjustedSize /= 1024;
}

return string.Format("{0:n" + decimalPlaces + "} {1}",
adjustedSize,
SizeSuffixes[mag]);
}
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions src/Lively/Lively.UI.WinUI/Lively.UI.WinUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
</PropertyGroup>
<ItemGroup>
<None Remove="Assets\banner-lively-1080.jpg" />
<None Remove="Assets\icon-lively-48.png" />
<None Remove="Assets\icons8-github-96.png" />
<None Remove="Assets\icons8-mail-96.png" />
Expand All @@ -31,7 +32,6 @@
<None Remove="Views\Pages\AddWallpaperView.xaml" />
<None Remove="Views\Pages\ChooseDisplayView.xaml" />
<None Remove="Views\Pages\ControlPanelView.xaml" />
<None Remove="Views\Pages\GalleryView.xaml" />
<None Remove="Views\Pages\HelpView.xaml" />
<None Remove="Views\Pages\LibraryAboutView.xaml" />
<None Remove="Views\Pages\ScreensaverLayoutView.xaml" />
Expand Down Expand Up @@ -67,7 +67,7 @@
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" />
<PackageReference Include="Microsoft.Toolkit.Mvvm" Version="7.1.2" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.1.1" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.1.2" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.1" />
<PackageReference Include="NLog" Version="5.0.1" />
<PackageReference Include="SettingsUI" Version="2.1.1" />
Expand Down Expand Up @@ -126,6 +126,9 @@
<None Update="appicon.ico">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<Content Update="Assets\banner-lively-1080.jpg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Page Update="Views\Pages\ChooseDisplayView.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
Expand All @@ -144,9 +147,6 @@
<Page Update="Views\Pages\TrayMenuHelp.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Update="Views\Pages\GalleryView.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Update="Views\Pages\AddWallpaperDataView.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
Expand Down
36 changes: 36 additions & 0 deletions src/Lively/Lively.UI.WinUI/ViewModels/LibraryAboutViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Lively.Common;
using Lively.Common.Helpers.Files;
using Lively.Models;
using System;

namespace Lively.UI.WinUI.ViewModels
{
internal class LibraryAboutViewModel
{
public LibraryAboutViewModel(ILibraryModel obj)
{
Title = obj.Title;
Desc = obj.Desc;
Author = obj.Author;
SrcWebsite = obj.SrcWebsite;
Type = obj.LivelyInfo.Type;
Contact = obj.LivelyInfo.Contact;
IsInstalled = !obj.LivelyInfo.IsAbsolutePath;

try
{
DirectorySize = FileOperations.SizeSuffix(FileOperations.GetDirectorySize(obj.LivelyInfoFolderPath), 2);
}
catch { }
}

public string Title { get; }
public string Desc { get; }
public string Author { get; }
public Uri SrcWebsite { get; }
public WallpaperType Type { get; }
public string Contact { get; }
public bool IsInstalled { get; }
public string DirectorySize { get; } = "--";
}
}
27 changes: 24 additions & 3 deletions src/Lively/Lively.UI.WinUI/Views/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
x:Class="Lively.UI.WinUI.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:animations="using:CommunityToolkit.WinUI.UI.Animations"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:Lively.UI.WinUI"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Expand Down Expand Up @@ -112,11 +113,27 @@
x:Uid="ActiveWallpapers"
Click="ControlPanelButton_Click">
<AppBarButton.Icon>
<FontIcon Glyph="&#xE7F4;" />
<FontIcon x:Name="controlPanelMonitor" Glyph="&#xE7F4;">
<animations:Explicit.Animations>
<animations:AnimationSet x:Name="activeWallpaperOffsetAnimation">
<animations:OffsetAnimation
From="0,0,0"
To="0,-5,0"
Duration="0:0:01" />
<animations:OffsetAnimation
From="0,-5,0"
To="0,0,0"
Duration="0:0:01" />
</animations:AnimationSet>
</animations:Explicit.Animations>
</FontIcon>
</AppBarButton.Icon>
</AppBarButton>
<AppBarSeparator />
<AppBarButton Name="audioBtn">
<AppBarButton
Name="audioBtn"
MaxWidth="50"
LabelPosition="Collapsed">
<AppBarButton.Flyout>
<Flyout>
<Slider
Expand All @@ -130,7 +147,11 @@
</AppBarButton.Icon>
</AppBarButton>
<AppBarSeparator />
<AppBarButton Name="coffeeBtn" Click="AppBarCoffeeBtn_Click">
<AppBarButton
Name="coffeeBtn"
MaxWidth="50"
Click="AppBarCoffeeBtn_Click"
LabelPosition="Collapsed">
<AppBarButton.Icon>
<FontIcon Glyph="&#xEB51;" />
</AppBarButton.Icon>
Expand Down
7 changes: 6 additions & 1 deletion src/Lively/Lively.UI.WinUI/Views/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Lively.UI.WinUI.ViewModels;
using Lively.UI.WinUI.Views.Pages;
using Lively.UI.WinUI.Views.Pages.ControlPanel;
using Lively.UI.WinUI.Views.Pages.Gallery;
using Lively.UI.WinUI.Views.Pages.Settings;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.UI.Xaml;
Expand Down Expand Up @@ -159,7 +160,11 @@ private void DesktopCore_WallpaperChanged(object sender, EventArgs e)
userSettings.Save<ISettingsModel>();
}
NativeMethods.SetForegroundWindow(this.GetWindowHandleEx());
//this.Activate();
//If its duplicate mode fire the animation more than once.
if (userSettings.Settings.WallpaperArrangement != WallpaperArrangement.duplicate || desktopCore.Wallpapers.Count < 2)
{
activeWallpaperOffsetAnimation.Start();
}
}
controlPanelLabel.Label = $"{desktopCore.Wallpapers.Count} {i18n.GetString("ActiveWallpapers/Label")}";
});
Expand Down
119 changes: 119 additions & 0 deletions src/Lively/Lively.UI.WinUI/Views/Pages/Gallery/GalleryLoginView.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
<Page
x:Class="Lively.UI.WinUI.Views.Pages.Gallery.GalleryLoginView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:animations="using:CommunityToolkit.WinUI.UI.Animations"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:Lively.UI.WinUI.Views.Pages.Gallery"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<Page.Resources>
<AcrylicBrush
x:Key="DragAcrylicBrush"
FallbackColor="{ThemeResource SystemAltMediumColor}"
TintColor="{ThemeResource SystemAltMediumColor}"
TintOpacity="1.0" />
</Page.Resources>

<Grid Margin="-5">
<!--
<Grid.Background>
<ImageBrush ImageSource="ms-appx:///Assets/banner-lively-1080.jpg" Stretch="UniformToFill" />
</Grid.Background>
-->
<Image
x:Name="bgImage"
Source="ms-appx:///Assets/banner-lively-1080.jpg"
Stretch="UniformToFill">
<animations:Implicit.ShowAnimations>
<animations:TranslationAnimation
From="0,-100,0"
To="0"
Duration="0:0:1" />
<animations:OpacityAnimation
From="0"
To="1.0"
Duration="0:0:1" />
</animations:Implicit.ShowAnimations>
</Image>
<Page Background="{ThemeResource SystemAltMediumColor}" />


<StackPanel
x:Name="mainPanel"
Margin="50"
HorizontalAlignment="Center"
VerticalAlignment="Top">
<animations:Implicit.ShowAnimations>
<animations:TranslationAnimation
From="0,50,0"
To="0"
Duration="0:0:1" />
<animations:OpacityAnimation
From="0"
To="1.0"
Duration="0:0:1" />
</animations:Implicit.ShowAnimations>
<Grid>
<PersonPicture
x:Name="personPicture"
Margin="0,0,0,5"
ProfilePicture="{Binding Picture, Mode=OneWay}" />
<ProgressRing
x:Name="loadingProgressRing"
Width="100"
Height="100"
IsActive="False"
IsIndeterminate="True" />
</Grid>
<TextBlock
x:Name="mainText"
x:Uid="ComingSoon"
HorizontalAlignment="Center"
FontSize="24"
FontWeight="SemiBold">
<animations:Implicit.Animations>
<animations:TranslationAnimation
ImplicitTarget="Size"
From="0"
To="0,25,0"
Duration="0:0:1" />
</animations:Implicit.Animations>
</TextBlock>
<StackPanel
x:Name="loginPanel"
Margin="0,10,0,0"
HorizontalAlignment="Center"
Visibility="Collapsed">
<animations:Implicit.HideAnimations>
<animations:OpacityAnimation To="0" Duration="0:0:1" />
</animations:Implicit.HideAnimations>
<animations:Implicit.ShowAnimations>
<animations:OpacityAnimation To="1" Duration="0:0:1" />
</animations:Implicit.ShowAnimations>
<Button
Width="175"
Height="35"
Margin="0"
Command="{Binding AuthGoogleCommand}">
<StackPanel Orientation="Horizontal">
<BitmapIcon Foreground="{ThemeResource SystemControlBackgroundBaseHighBrush}" UriSource="ms-appx:///Assets/icons8-google-96.png" />
<TextBlock Margin="5,0,0,0" VerticalAlignment="Center">Google</TextBlock>
</StackPanel>
</Button>
<Button
Width="175"
Height="35"
Margin="0,5,0,0"
Command="{Binding AuthGithubCommand}"
Visibility="Visible">
<StackPanel Orientation="Horizontal">
<BitmapIcon Foreground="{ThemeResource SystemControlBackgroundBaseHighBrush}" UriSource="ms-appx:///Assets/icons8-github-96.png" />
<TextBlock Margin="5,0,0,0" VerticalAlignment="Center">Github</TextBlock>
</StackPanel>
</Button>
</StackPanel>
</StackPanel>
</Grid>
</Page>
Original file line number Diff line number Diff line change
@@ -1,34 +1,31 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;
using Microsoft.Extensions.DependencyInjection;
using Lively.UI.WinUI.ViewModels;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;

// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.

namespace Lively.UI.WinUI.Views.Pages
namespace Lively.UI.WinUI.Views.Pages.Gallery
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class GalleryView : Page
public sealed partial class GalleryLoginView : Page
{
public GalleryView()
public GalleryLoginView()
{
this.InitializeComponent();
this.DataContext = App.Services.GetRequiredService<LibraryViewModel>();
}
}
}
Loading

0 comments on commit 10d1a07

Please sign in to comment.