diff --git a/src/Views/AIAssistant.axaml b/src/Views/AIAssistant.axaml index d7111439..b4c496ea 100644 --- a/src/Views/AIAssistant.axaml +++ b/src/Views/AIAssistant.axaml @@ -4,16 +4,16 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:v="using:SourceGit.Views" xmlns:vm="using:SourceGit.ViewModels" - mc:Ignorable="d" d:DesignWidth="400" d:DesignHeight="120" + mc:Ignorable="d" d:DesignWidth="520" d:DesignHeight="400" x:Class="SourceGit.Views.AIAssistant" x:DataType="vm:AIAssistant" x:Name="ThisControl" Icon="/App.ico" Title="{DynamicResource Text.AIAssistant}" - Width="520" SizeToContent="Height" - CanResize="False" + Width="520" Height="400" + CanResize="True" WindowStartupLocation="CenterOwner"> - + + item.Click += (_, ev) => { - await App.ShowDialog(new ViewModels.AIAssistant(repo, dup, vm.Staged)); + DoOpenAIAssistant(repo, dup, vm.Staged); ev.Handled = true; }; @@ -637,5 +637,16 @@ namespace SourceGit.Views e.Handled = true; } + + private void DoOpenAIAssistant(ViewModels.Repository repo, AI.Service service, List changes) + { + var owner = TopLevel.GetTopLevel(this) as Window; + if (owner == null) + return; + + var assistant = new ViewModels.AIAssistant(repo, service, changes); + var view = new AIAssistant() { DataContext = assistant }; + view.Show(owner); + } } } diff --git a/src/Views/WorkingCopy.axaml.cs b/src/Views/WorkingCopy.axaml.cs index febc0853..ea7a215d 100644 --- a/src/Views/WorkingCopy.axaml.cs +++ b/src/Views/WorkingCopy.axaml.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.IO; using Avalonia.Controls; @@ -927,9 +928,9 @@ namespace SourceGit.Views if (services.Count == 1) { - ai.Click += async (_, e) => + ai.Click += (_, e) => { - await App.ShowDialog(new ViewModels.AIAssistant(repo, services[0], selectedStaged)); + DoOpenAIAssistant(repo, services[0], selectedStaged); e.Handled = true; }; } @@ -941,9 +942,9 @@ namespace SourceGit.Views var item = new MenuItem(); item.Header = service.Name; - item.Click += async (_, e) => + item.Click += (_, e) => { - await App.ShowDialog(new ViewModels.AIAssistant(repo, dup, selectedStaged)); + DoOpenAIAssistant(repo, dup, selectedStaged); e.Handled = true; }; @@ -1369,5 +1370,16 @@ namespace SourceGit.Views menu.Items.Add(custom); menu.Items.Add(new MenuItem() { Header = "-" }); } + + private void DoOpenAIAssistant(ViewModels.Repository repo, AI.Service serivce, List changes) + { + var owner = TopLevel.GetTopLevel(this) as Window; + if (owner == null) + return; + + var assistant = new ViewModels.AIAssistant(repo, serivce, changes); + var view = new AIAssistant() { DataContext = assistant }; + view.Show(owner); + } } }