finish porting welcome pages

This commit is contained in:
Hongtao Zhang 2024-01-18 22:22:24 -06:00
parent 4c7b5921e6
commit 9555007690
30 changed files with 150 additions and 143 deletions

View file

@ -66,6 +66,7 @@ namespace Flow.Launcher.Core.Resource
public void ChangeLanguage(string languageCode)
{
return;
languageCode = languageCode.NonNull();
Language language = GetLanguageByLanguageCode(languageCode);
ChangeLanguage(language);
@ -73,6 +74,7 @@ namespace Flow.Launcher.Core.Resource
private Language GetLanguageByLanguageCode(string languageCode)
{
return new Language("a", "b");
var lowercase = languageCode.ToLower();
var language = AvailableLanguages.GetAvailableLanguages().FirstOrDefault(o => o.LanguageCode.ToLower() == lowercase);
if (language == null)

View file

@ -93,6 +93,7 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<AvaloniaResource Include="Resources\*.ttf"/>
<AvaloniaResource Include="Images\*.png"/>
</ItemGroup>
<ItemGroup>
@ -130,6 +131,18 @@
</Content>
</ItemGroup>
<ItemGroup>
<Folder Include="Views\" />
</ItemGroup>
<ItemGroup>
<AdditionalFiles Include="Views\WelcomePages\WelcomePage1.axaml" />
<AdditionalFiles Include="Views\WelcomePages\WelcomePage2.axaml" />
<AdditionalFiles Include="Views\WelcomePages\WelcomePage3.axaml" />
<AdditionalFiles Include="Views\WelcomePages\WelcomePage4.axaml" />
<AdditionalFiles Include="Views\WelcomePages\WelcomePage5.axaml" />
</ItemGroup>
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="taskkill /f /fi &quot;IMAGENAME eq Flow.Launcher.exe&quot;" />
</Target>

View file

@ -1,18 +0,0 @@
using Flow.Launcher.Infrastructure.UserSettings;
namespace Flow.Launcher.ViewModel.WelcomePages
{
public class WelcomePage5ViewModel : PageViewModelBase
{
public override bool CanNavigateNext { get; protected set; }
public override bool CanNavigatePrevious { get; protected set; }
public override string PageTitle { get; }
public WelcomePage5ViewModel(Settings settings)
{
Settings = settings;
}
public Settings Settings { get; set; }
}
}

View file

@ -1,8 +1,8 @@
using Flow.Launcher.Plugin;
using ReactiveUI;
namespace Flow.Launcher.ViewModel.WelcomePages
namespace Flow.Launcher.ViewModels.WelcomePages
{
public abstract class PageViewModelBase : BaseModel
public abstract class PageViewModelBase : ReactiveObject
{
/// <summary>
/// Gets if the user can navigate to the next page

View file

@ -2,7 +2,7 @@
using Flow.Launcher.Core.Resource;
using Flow.Launcher.Infrastructure.UserSettings;
namespace Flow.Launcher.ViewModel.WelcomePages
namespace Flow.Launcher.ViewModels.WelcomePages
{
public class WelcomePage1ViewModel : PageViewModelBase
{

View file

@ -1,14 +1,11 @@
using Avalonia.Interactivity;
using Flow.Launcher.Helper;
using Flow.Launcher.Infrastructure.Hotkey;
using Flow.Launcher.Infrastructure.UserSettings;
using Flow.Launcher.Infrastructure.UserSettings;
namespace Flow.Launcher.ViewModel.WelcomePages
namespace Flow.Launcher.ViewModels.WelcomePages
{
public class WelcomePage2ViewModel : PageViewModelBase
{
public override bool CanNavigateNext { get; protected set; }
public override bool CanNavigatePrevious { get; protected set; }
public override bool CanNavigateNext { get; protected set; } = true;
public override bool CanNavigatePrevious { get; protected set; } = true;
public override string PageTitle { get; }
public Settings Settings { get; set; }

View file

@ -1,11 +1,11 @@
using Flow.Launcher.Infrastructure.UserSettings;
namespace Flow.Launcher.ViewModel.WelcomePages
namespace Flow.Launcher.ViewModels.WelcomePages
{
public class WelcomePage3ViewModel : PageViewModelBase
{
public override bool CanNavigateNext { get; protected set; }
public override bool CanNavigatePrevious { get; protected set; }
public override bool CanNavigateNext { get; protected set; } = true;
public override bool CanNavigatePrevious { get; protected set; } = true;
public override string PageTitle { get; }
public WelcomePage3ViewModel(Settings settings)

View file

@ -1,11 +1,11 @@
using Flow.Launcher.Infrastructure.UserSettings;
namespace Flow.Launcher.ViewModel.WelcomePages
namespace Flow.Launcher.ViewModels.WelcomePages
{
public class WelcomePage4ViewModel : PageViewModelBase
{
public override bool CanNavigateNext { get; protected set; }
public override bool CanNavigatePrevious { get; protected set; }
public override bool CanNavigateNext { get; protected set; } = true;
public override bool CanNavigatePrevious { get; protected set; } = true;
public override string PageTitle { get; }
public WelcomePage4ViewModel(Settings settings)

View file

@ -0,0 +1,69 @@
using Flow.Launcher.Infrastructure;
using Flow.Launcher.Infrastructure.UserSettings;
using Microsoft.Win32;
namespace Flow.Launcher.ViewModels.WelcomePages
{
public class WelcomePage5ViewModel : PageViewModelBase
{
public override bool CanNavigateNext { get; protected set; } = false;
public override bool CanNavigatePrevious { get; protected set; } = true;
public override string PageTitle { get; }
public WelcomePage5ViewModel(Settings settings)
{
Settings = settings;
}
public bool AutoStartup
{
get
{
return Settings.StartFlowLauncherOnSystemStartup;
}
set
{
if (value)
{
SetStartup();
}
else
{
RemoveStartup();
}
Settings.StartFlowLauncherOnSystemStartup = value;
}
}
public bool HideOnStartup
{
get
{
return Settings.HideOnStartup;
}
set
{
Settings.HideOnStartup = value;
}
}
public Settings Settings { get; set; }
private const string StartupPath = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run";
private void RemoveStartup()
{
using var key = Registry.CurrentUser.OpenSubKey(StartupPath, true);
key?.DeleteValue(Constant.FlowLauncher, false);
Settings.StartFlowLauncherOnSystemStartup = false;
}
private void SetStartup()
{
using var key = Registry.CurrentUser.OpenSubKey(StartupPath, true);
key?.SetValue(Constant.FlowLauncher, Constant.ExecutablePath);
Settings.StartFlowLauncherOnSystemStartup = true;
}
}
}

View file

@ -2,7 +2,7 @@
using System.Windows.Input;
using Flow.Launcher.Infrastructure.UserSettings;
using Flow.Launcher.Plugin;
using Flow.Launcher.ViewModel.WelcomePages;
using Flow.Launcher.ViewModels.WelcomePages;
using ReactiveUI;
namespace Flow.Launcher.ViewModel

View file

@ -1,10 +1,10 @@
<UserControl
x:Class="Flow.Launcher.WelcomePages.WelcomePage1"
x:Class="Flow.Launcher.Views.WelcomePages.WelcomePage1View"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:welcomePages="clr-namespace:Flow.Launcher.ViewModel.WelcomePages"
xmlns:welcomePages="clr-namespace:Flow.Launcher.ViewModels.WelcomePages"
x:DataType="welcomePages:WelcomePage1ViewModel"
mc:Ignorable="d">
<!-- <Page.Resources> -->
@ -121,7 +121,7 @@
Canvas.Left="140"
Width="60"
Height="60"
Source="../../images/app.png" />
Source="/Images/app.png" />
<TextBlock
Canvas.Left="205"
Margin="12,0,0,0"
@ -143,7 +143,7 @@
Canvas.Bottom="0"
Width="60"
Height="60"
Source="../../images/wizard.png" />
Source="/Images/wizard.png" />
<StackPanel Width="550" Margin="24,20,24,20">
<StackPanel Margin="0,0,24,0">

View file

@ -1,12 +1,12 @@
using Avalonia.Controls;
using PropertyChanged;
namespace Flow.Launcher.WelcomePages
namespace Flow.Launcher.Views.WelcomePages
{
[DoNotNotify]
public partial class WelcomePage1 : UserControl
public partial class WelcomePage1View : UserControl
{
public WelcomePage1()
public WelcomePage1View()
{
InitializeComponent();
}

View file

@ -1,11 +1,11 @@
<UserControl
x:Class="Flow.Launcher.WelcomePages.WelcomePage2"
x:Class="Flow.Launcher.Views.WelcomePages.WelcomePage2View"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:welcomePages="clr-namespace:Flow.Launcher.ViewModel.WelcomePages"
xmlns:launcher="clr-namespace:Flow.Launcher"
xmlns:welcomePages="clr-namespace:Flow.Launcher.ViewModels.WelcomePages"
x:DataType="welcomePages:WelcomePage2ViewModel"
mc:Ignorable="d">
<!-- <Page.Resources> -->

View file

@ -4,12 +4,13 @@ using Avalonia.Media;
using Flow.Launcher.Helper;
using Flow.Launcher.Infrastructure.Hotkey;
using Flow.Launcher.Infrastructure.UserSettings;
using Flow.Launcher.ViewModels.WelcomePages;
using PropertyChanged;
namespace Flow.Launcher.WelcomePages
namespace Flow.Launcher.Views.WelcomePages
{
[DoNotNotify]
public partial class WelcomePage2 : UserControl
public partial class WelcomePage2View : UserControl
{
private Settings Settings { get; set; }
@ -17,12 +18,12 @@ namespace Flow.Launcher.WelcomePages
private string tbMsgTextOriginal;
public WelcomePage2()
public WelcomePage2View()
{
InitializeComponent();
hotkeyControl.SetHotkeyAsync(Settings.Hotkey, false);
}
private void HotkeyControl_OnGotFocus(object sender, RoutedEventArgs args)
{
HotKeyMapper.RemoveHotkey(Settings.Hotkey);

View file

@ -1,10 +1,10 @@
<UserControl
x:Class="Flow.Launcher.WelcomePages.WelcomePage3"
x:Class="Flow.Launcher.Views.WelcomePages.WelcomePage3View"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:welcomePages="clr-namespace:Flow.Launcher.ViewModel.WelcomePages"
xmlns:welcomePages="clr-namespace:Flow.Launcher.ViewModels.WelcomePages"
x:DataType="welcomePages:WelcomePage1ViewModel"
mc:Ignorable="d">
<!-- <Page.Resources> -->
@ -48,7 +48,7 @@
Width="300"
Height="100"
Margin="0,0,0,0"
Source="../../images/page_img02.png" />
Source="/Images/page_img01.png" />
</StackPanel>
</Border>

View file

@ -1,15 +1,13 @@
using System;
using System.Windows.Navigation;
using Avalonia.Controls;
using Avalonia.Controls;
using Flow.Launcher.Infrastructure.UserSettings;
using PropertyChanged;
namespace Flow.Launcher.WelcomePages
namespace Flow.Launcher.Views.WelcomePages
{
[DoNotNotify]
public partial class WelcomePage3 : UserControl
public partial class WelcomePage3View : UserControl
{
public WelcomePage3()
public WelcomePage3View()
{
InitializeComponent();
}

View file

@ -1,10 +1,10 @@
<UserControl
x:Class="Flow.Launcher.WelcomePages.WelcomePage4"
x:Class="Flow.Launcher.Views.WelcomePages.WelcomePage4View"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:welcomePages="clr-namespace:Flow.Launcher.ViewModel.WelcomePages"
xmlns:welcomePages="clr-namespace:Flow.Launcher.ViewModels.WelcomePages"
x:DataType="welcomePages:WelcomePage4ViewModel"
mc:Ignorable="d">
<!-- <Page.Resources> -->
@ -79,7 +79,7 @@
Width="450"
Height="280"
Margin="0,0,0,0"
Source="../../images/page_img01.png" />
Source="/Images/page_img01.png" />
</Canvas>
</StackPanel>
</Border>

View file

@ -1,15 +1,13 @@
using System;
using System.Windows.Navigation;
using Avalonia.Controls;
using Avalonia.Controls;
using Flow.Launcher.Infrastructure.UserSettings;
using PropertyChanged;
namespace Flow.Launcher.WelcomePages
namespace Flow.Launcher.Views.WelcomePages
{
[DoNotNotify]
public partial class WelcomePage4 : UserControl
public partial class WelcomePage4View : UserControl
{
public WelcomePage4()
public WelcomePage4View()
{
InitializeComponent();
}

View file

@ -1,10 +1,10 @@
<UserControl
x:Class="Flow.Launcher.WelcomePages.WelcomePage5"
x:Class="Flow.Launcher.Views.WelcomePages.WelcomePage5View"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:welcomePages="clr-namespace:Flow.Launcher.ViewModel.WelcomePages"
xmlns:welcomePages="clr-namespace:Flow.Launcher.ViewModels.WelcomePages"
x:DataType="welcomePages:WelcomePage5ViewModel"
mc:Ignorable="d">
<!-- <Page.Resources> -->
@ -68,7 +68,7 @@
Canvas.Left="225"
Width="100"
Height="100"
Source="../../images/app.png" />
Source="/Images/app.png" />
</Canvas>
</StackPanel>
</Border>
@ -86,17 +86,13 @@
TextWrapping="WrapWithOverflow" />
<StackPanel Margin="0,30,0,0" Orientation="Horizontal">
<CheckBox
IsCheckedChanged="OnAutoStartupChecked"
Content="{DynamicResource startFlowLauncherOnSystemStartup}"
IsChecked="{Binding Settings.StartFlowLauncherOnSystemStartup}"
Unchecked="OnAutoStartupUncheck" />
IsChecked="{Binding AutoStartup}" />
</StackPanel>
<StackPanel Margin="0,0,0,0" Orientation="Horizontal">
<CheckBox
Checked="OnHideOnStartupChecked"
Content="{DynamicResource hideOnStartup}"
IsChecked="{Binding Settings.HideOnStartup}"
Unchecked="OnHideOnStartupUnchecked" />
IsChecked="{Binding HideOnStartup}" />
</StackPanel>
</StackPanel>

View file

@ -0,0 +1,18 @@
using Avalonia.Controls;
using Avalonia.Interactivity;
using Flow.Launcher.Infrastructure;
using Flow.Launcher.Infrastructure.UserSettings;
using Microsoft.Win32;
using PropertyChanged;
namespace Flow.Launcher.Views.WelcomePages
{
[DoNotNotify]
public partial class WelcomePage5View : UserControl
{
public WelcomePage5View()
{
InitializeComponent();
}
}
}

View file

@ -1,56 +0,0 @@
using Avalonia.Controls;
using Avalonia.Interactivity;
using Flow.Launcher.Infrastructure;
using Flow.Launcher.Infrastructure.UserSettings;
using Microsoft.Win32;
using PropertyChanged;
namespace Flow.Launcher.WelcomePages
{
[DoNotNotify]
public partial class WelcomePage5 : UserControl
{
private const string StartupPath = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run";
public Settings Settings { get; set; }
public bool HideOnStartup { get; set; }
public WelcomePage5()
{
InitializeComponent();
}
private void OnAutoStartupChecked(object sender, RoutedEventArgs e)
{
SetStartup();
}
private void OnAutoStartupUncheck(object sender, RoutedEventArgs e)
{
RemoveStartup();
}
private void RemoveStartup()
{
using var key = Registry.CurrentUser.OpenSubKey(StartupPath, true);
key?.DeleteValue(Constant.FlowLauncher, false);
Settings.StartFlowLauncherOnSystemStartup = false;
}
private void SetStartup()
{
using var key = Registry.CurrentUser.OpenSubKey(StartupPath, true);
key?.SetValue(Constant.FlowLauncher, Constant.ExecutablePath);
Settings.StartFlowLauncherOnSystemStartup = true;
}
private void OnHideOnStartupChecked(object sender, RoutedEventArgs e)
{
Settings.HideOnStartup = true;
}
private void OnHideOnStartupUnchecked(object sender, RoutedEventArgs e)
{
Settings.HideOnStartup = false;
}
}
}

View file

@ -17,18 +17,7 @@ namespace Flow.Launcher
DataContext = new ViewModel.WelcomeWindowViewModel(settings);
InitializeComponent();
BackButton.IsEnabled = false;
this.settings = settings;
}
private NavigationTransitionInfo _transitionInfo = new SlideNavigationTransitionInfo()
{
Effect = SlideNavigationTransitionEffect.FromRight
};
private NavigationTransitionInfo _backTransitionInfo = new SlideNavigationTransitionInfo()
{
Effect = SlideNavigationTransitionEffect.FromLeft
};
}
}