Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/Gpt.Labs/Gpt.Labs.csproj
  • Loading branch information
px-mnikonov committed Jun 26, 2023
2 parents 3bc1d1f + 514ea13 commit efceb9a
Show file tree
Hide file tree
Showing 92 changed files with 3,635 additions and 1,609 deletions.
9 changes: 5 additions & 4 deletions src/Gpt.Labs/ActivationPage.xaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
<Page
<labs:BasePage
x:Class="Gpt.Labs.ActivationPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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:controls="using:Gpt.Labs.Controls"
xmlns:labs="using:Gpt.Labs"
mc:Ignorable="d">

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid>
<controls:PageHeader Height="40" x:Name="AppTitleBar" x:FieldModifier="public" VerticalAlignment="Top" />

<Border x:Name="WizartInfoStepContainer" VerticalAlignment="Center" HorizontalAlignment="Center" Visibility="Collapsed">
</Border>

<UserControl Margin="24 88 24 24" x:Name="WizardFormContent" VerticalAlignment="Center" Grid.Row="0" Width="500" Visibility="Collapsed">
<UserControl Margin="24 88 24 24" x:Name="WizardFormContent" VerticalAlignment="Center" Grid.Row="0" Width="560" Visibility="Collapsed">
<Border Padding="0 16" Style="{StaticResource PivotItemContainerBorderStyle}">
<Grid>
<Grid.RowDefinitions>
Expand Down Expand Up @@ -44,4 +45,4 @@
<ProgressRing x:Name="Progress" IsActive="True" VerticalAlignment="Bottom" HorizontalAlignment="Center" Width="40" Height="40" Margin="24" Value="0" Visibility="Collapsed"></ProgressRing>

</Grid>
</Page>
</labs:BasePage>
7 changes: 2 additions & 5 deletions src/Gpt.Labs/ActivationPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Gpt.Labs.ViewModels.Base;
using Gpt.Labs.ViewModels;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Navigation;
using System.Threading.Tasks;
using Gpt.Labs.Helpers.Navigation;
Expand All @@ -11,7 +10,7 @@

namespace Gpt.Labs
{
public sealed partial class ActivationPage : Page
public sealed partial class ActivationPage : BasePage
{
#region Fields

Expand All @@ -27,7 +26,7 @@ public sealed partial class ActivationPage : Page

public ActivationPage()
{
this.ViewModel = new ActivationViewModel(this.ExecuteStepAndContinue);
this.ViewModel = new ActivationViewModel(() => this, this.ExecuteStepAndContinue);
this.InitializeComponent();

this.Loaded += OnActivationWizardLoaded;
Expand All @@ -54,8 +53,6 @@ protected override void OnNavigatedTo(NavigationEventArgs e)
base.OnNavigatedTo(e);

this.ViewModel.NavigationParameter = Query.Parse(e.Parameter);

SystemThemeHelper.ApplyTheme((FrameworkElement)App.Window.Content);
}

private async void OnActivationWizardLoaded(object sender, RoutedEventArgs e)
Expand Down
3 changes: 3 additions & 0 deletions src/Gpt.Labs/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
<converters:IntToDoubleConverter x:Key="IntToDoubleConverter" />
<converters:OpenAiSettingsStyleConverter x:Key="OpenAiSettingsStyleConverter" />
<converters:OpenAiMessageStyleConverter x:Key="OpenAiMessageStyleConverter" />
<converters:OpenAiChatStyleConverter x:Key="OpenAiChatStyleConverter" />
<converters:StringFormatConverter x:Key="StringFormatConverter" />
<converters:ChatTypeToCaptionConverter x:Key="ChatTypeToCaptionConverter" />
<converters:InvertBooleanConverter x:Key="InvertBooleanConverter" />
<converters:ListViewSelectionModeConverter x:Key="ListViewSelectionModeConverter" />
<converters:OpenAiKeyConverter x:Key="OpenAiKeyConverter" />
<converters:OpenAIImageSizeConverter x:Key="OpenAIImageSizeConverter" />
<converters:StringToVisibilityConverter x:Key="StringToVisibilityConverter" />

<ResourceDictionary.MergedDictionaries>
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
Expand All @@ -30,6 +32,7 @@
<ResourceDictionary Source="ms-appx:///Styles/TitledContentPanelResources.xaml"/>
<ResourceDictionary Source="ms-appx:///Styles/RadioButtonResources.xaml"/>
<ResourceDictionary Source="ms-appx:///Styles/OpenAiMessageResources.xaml"/>
<ResourceDictionary Source="ms-appx:///Styles/OpenAiChatResources.xaml"/>
<ResourceDictionary Source="ms-appx:///Styles/ContentDialodResources.xaml"/>
<ResourceDictionary Source="ms-appx:///Styles/OpenAiSettingsResources.xaml"/>
</ResourceDictionary.MergedDictionaries>
Expand Down
29 changes: 12 additions & 17 deletions src/Gpt.Labs/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Gpt.Labs.Helpers.Extensions;
using Gpt.Labs.Helpers;
using Gpt.Labs.Helpers.Extensions;
using Gpt.Labs.Helpers.Navigation;
using Microsoft.UI.Windowing;
using Microsoft.UI.Xaml;
Expand Down Expand Up @@ -27,45 +28,39 @@ public App()

#region Properties

public static Window Window { get; private set; }

public static ResourceLoader ResourceLoader { get; } = new ();

#endregion

protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
{
this.ActivateAsync(args.UWPLaunchActivatedEventArgs);

var appWindow = Window.GetAppWindow();
appWindow.Title = ResourceLoader.GetString("AppDisplayName");

if (AppWindowTitleBar.IsCustomizationSupported())
{
appWindow.TitleBar.ExtendsContentIntoTitleBar = true;
}
}


#region Private Methods

private void ActivateAsync(IActivatedEventArgs args)
{
Window = new MainWindow();
var window = WindowManager.CreateWindow();

if (!(Window.Content is Frame rootFrame))
if (!(window.Content is Frame rootFrame))
{
rootFrame = new Frame();
rootFrame.NavigationFailed += this.OnNavigationFailed;

Window.Content = rootFrame;
window.Content = rootFrame;
}

window.SetTitle(ResourceLoader.GetString("AppDisplayName"));
window.SetExtendsContentIntoTitleBar();
window.ApplyTheme();

if (rootFrame.Content == null)
{
var query = new Query
{
["IsTerminated"] = args.PreviousExecutionState == ApplicationExecutionState.Terminated
["IsTerminated"] = args.PreviousExecutionState == ApplicationExecutionState.Terminated,
["WindowId"] = window.WindowId
};

if (args is ProtocolActivatedEventArgs protocolArgs && protocolArgs.Uri != null)
Expand All @@ -76,7 +71,7 @@ private void ActivateAsync(IActivatedEventArgs args)
rootFrame.Navigate(typeof(ActivationPage), query.ToString(), new CommonNavigationTransitionInfo());
}

Window.Activate();
window.Activate();
}

private void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
Expand Down
Loading

0 comments on commit efceb9a

Please sign in to comment.