Skip to content

Commit 8da7260

Browse files
committed
换成 ico
1 parent 79a6dd2 commit 8da7260

9 files changed

Lines changed: 77 additions & 37 deletions

File tree

DirectorPrompt.Tests/AvaloniaViewConstructionTests.cs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1+
using Avalonia.Controls;
12
using Avalonia.Headless.XUnit;
3+
using Avalonia.Interactivity;
4+
using Avalonia.LogicalTree;
5+
using Avalonia.Threading;
6+
using DirectorPrompt.ViewModels;
27
using DirectorPrompt.Views;
38
using DirectorPrompt.Views.Components;
49

@@ -19,4 +24,42 @@ public void PrimaryViewsAndControlsConstruct()
1924
Assert.NotNull(new PhaseEditControl());
2025
Assert.NotNull(new MessageRail());
2126
}
27+
28+
[AvaloniaFact]
29+
public void AddPhaseButtonExecutesWindowCommand()
30+
{
31+
var viewModel = new ProjectEditViewModel
32+
(
33+
null!,
34+
null!,
35+
null!,
36+
null!,
37+
null!,
38+
null!,
39+
null!,
40+
null!,
41+
null!
42+
);
43+
var attribute = new StateAttributeEditViewModel { IsEditing = true };
44+
var window = new ProjectEditWindow(viewModel);
45+
46+
viewModel.StateAttributes.Add(attribute);
47+
48+
window.FindControl<StackPanel>("StatePanel")!.IsVisible = true;
49+
window.Show();
50+
51+
var control = window.GetLogicalDescendants().OfType<PhaseEditControl>().First();
52+
var button = control.GetLogicalDescendants().OfType<Button>().First();
53+
var phases = control.FindControl<ItemsControl>("PhaseItems")!;
54+
55+
Assert.Same(attribute.Phases, phases.ItemsSource);
56+
57+
button.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
58+
Dispatcher.UIThread.RunJobs();
59+
60+
Assert.Single(attribute.Phases);
61+
Assert.Contains(control.GetLogicalDescendants().OfType<Control>(), descendant => descendant.DataContext is PhaseEditViewModel);
62+
63+
window.Close();
64+
}
2265
}

DirectorPrompt/Views/ChangelogWindow.axaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
xmlns:components="using:DirectorPrompt.Views.Components"
55
xmlns:windowing="using:FluentAvalonia.UI.Windowing"
66
Width="720" Height="640" MinWidth="480" MinHeight="360"
7-
Icon="/Assets/Images/Icon-NoBackground.png"
7+
Icon="/Assets/Images/Icon-NoBackground.ico"
88
WindowStartupLocation="CenterOwner" TransparencyLevelHint="Mica">
99
<Grid RowDefinitions="*,Auto" Margin="20">
1010
<ScrollViewer Grid.Row="0">

DirectorPrompt/Views/Components/PhaseEditControl.axaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
FontSize="11"
2828
Foreground="Gray"
2929
Margin="0,0,0,8" />
30-
<ItemsControl ItemsSource="{Binding Phases}">
30+
<ItemsControl x:Name="PhaseItems"
31+
ItemsSource="{Binding PhaseSource.Phases, RelativeSource={RelativeSource AncestorType=components:PhaseEditControl}}">
3132
<ItemsControl.ItemTemplate>
3233
<DataTemplate>
3334
<Border Margin="0,0,0,6"

DirectorPrompt/Views/Components/PhaseEditControl.axaml.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using Avalonia;
33
using Avalonia.Controls;
44
using Avalonia.Interactivity;
5-
using Avalonia.LogicalTree;
65
using Avalonia.Markup.Xaml;
76
using DirectorPrompt.Localization;
87
using DirectorPrompt.ViewModels;
@@ -38,13 +37,6 @@ public ICommand? DeletePhaseCommand
3837
set => SetValue(DeletePhaseCommandProperty, value);
3938
}
4039

41-
private Panel Root =>
42-
this.GetLogicalDescendants().OfType<Panel>().First(control => control.Name == "RootPanel");
43-
44-
static PhaseEditControl() =>
45-
PhaseSourceProperty.Changed.AddClassHandler<PhaseEditControl>
46-
(static (control, _) => control.Root.DataContext = control.PhaseSource);
47-
4840
public PhaseEditControl() =>
4941
AvaloniaXamlLoader.Load(this);
5042

DirectorPrompt/Views/MainWindow.axaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
Height="800"
1616
MinWidth="960"
1717
MinHeight="600"
18-
Icon="/Assets/Images/Icon-NoBackground.png"
18+
Icon="/Assets/Images/Icon-NoBackground.ico"
1919
TransparencyLevelHint="Mica">
2020
<windowing:FAAppWindow.Styles>
2121
<Style Selector="Button.sidebar-toggle">
@@ -299,7 +299,7 @@
299299
Click="OnMoreButtonClick"
300300
Padding="6,2"
301301
VerticalAlignment="Top"
302-
IsEnabled="{Binding DataContext?.IsNotProcessing, RelativeSource={RelativeSource AncestorType=Window}}">
302+
IsEnabled="{Binding DataContext.IsNotProcessing, RelativeSource={RelativeSource AncestorType=Window}}">
303303
<fa:FASymbolIcon Symbol="MoreVertical" />
304304
<Button.ContextMenu>
305305
<ContextMenu>
@@ -389,7 +389,7 @@
389389
<Button
390390
Padding="12,6"
391391
Margin="0,0,4,0"
392-
Command="{Binding DataContext?.SaveEditCommand, RelativeSource={RelativeSource AncestorType=Window}}"
392+
Command="{Binding DataContext.SaveEditCommand, RelativeSource={RelativeSource AncestorType=Window}}"
393393
CommandParameter="{Binding}">
394394
<StackPanel Orientation="Horizontal" Spacing="6">
395395
<fa:FASymbolIcon Symbol="Save" />
@@ -399,7 +399,7 @@
399399
</Button>
400400
<Button
401401
Padding="12,6"
402-
Command="{Binding DataContext?.CancelEditCommand, RelativeSource={RelativeSource AncestorType=Window}}"
402+
Command="{Binding DataContext.CancelEditCommand, RelativeSource={RelativeSource AncestorType=Window}}"
403403
CommandParameter="{Binding}">
404404
<StackPanel Orientation="Horizontal" Spacing="6">
405405
<fa:FASymbolIcon Symbol="Dismiss" />
@@ -896,12 +896,12 @@
896896
Content="{Binding [Common.Save], Source={x:Static loc:Loc.Instance}}"
897897
Padding="12,6"
898898
Margin="0,0,4,0"
899-
Command="{Binding DataContext?.SaveMemoryEditCommand, RelativeSource={RelativeSource AncestorType=Window}}"
899+
Command="{Binding DataContext.SaveMemoryEditCommand, RelativeSource={RelativeSource AncestorType=Window}}"
900900
CommandParameter="{Binding}" />
901901
<Button
902902
Content="{Binding [Common.Cancel], Source={x:Static loc:Loc.Instance}}"
903903
Padding="12,6"
904-
Command="{Binding DataContext?.CancelMemoryEditCommand, RelativeSource={RelativeSource AncestorType=Window}}"
904+
Command="{Binding DataContext.CancelMemoryEditCommand, RelativeSource={RelativeSource AncestorType=Window}}"
905905
CommandParameter="{Binding}" />
906906
</StackPanel>
907907
</StackPanel>

DirectorPrompt/Views/ProjectEditWindow.axaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
Height="720"
1616
MinWidth="800"
1717
MinHeight="600"
18-
Icon="/Assets/Images/Icon-NoBackground.png"
18+
Icon="/Assets/Images/Icon-NoBackground.ico"
1919
TransparencyLevelHint="Mica">
2020
<Grid>
2121
<Grid.RowDefinitions>
@@ -243,7 +243,7 @@
243243
VerticalAlignment="Center" />
244244
<Button Grid.Column="1"
245245
Padding="6,4"
246-
Command="{Binding DataContext?.AddKnowledgeEntryCommand, RelativeSource={RelativeSource AncestorType=Window}}"
246+
Command="{Binding DataContext.AddKnowledgeEntryCommand, RelativeSource={RelativeSource AncestorType=Window}}"
247247
CommandParameter="{Binding}">
248248
<StackPanel Orientation="Horizontal" Spacing="6">
249249
<fa:FASymbolIcon Symbol="Add" />
@@ -622,7 +622,7 @@
622622
Margin="8,0,0,0" />
623623
</StackPanel>
624624
<components:PathComboBox
625-
ItemsSource="{Binding DataContext?.AvailableNumericAttributes, RelativeSource={RelativeSource AncestorType=ItemsControl}}"
625+
ItemsSource="{Binding DataContext.AvailableNumericAttributes, RelativeSource={RelativeSource AncestorType=ItemsControl}}"
626626
SelectedItem="{Binding AttributeName}"
627627
HorizontalAlignment="Stretch" />
628628
<StackPanel Orientation="Horizontal"
@@ -683,8 +683,8 @@
683683

684684
<components:PhaseEditControl
685685
PhaseSource="{Binding}"
686-
AddPhaseCommand="{Binding DataContext?.AddPhaseCommand, RelativeSource={RelativeSource AncestorType=Window}}"
687-
DeletePhaseCommand="{Binding DataContext?.DeletePhaseCommand, RelativeSource={RelativeSource AncestorType=Window}}" />
686+
AddPhaseCommand="{Binding DataContext.AddPhaseCommand, RelativeSource={RelativeSource AncestorType=Window}}"
687+
DeletePhaseCommand="{Binding DataContext.DeletePhaseCommand, RelativeSource={RelativeSource AncestorType=Window}}" />
688688

689689
</StackPanel>
690690
</StackPanel>
@@ -1116,7 +1116,7 @@
11161116
Margin="8,0,0,0" />
11171117
</StackPanel>
11181118
<components:PathComboBox
1119-
ItemsSource="{Binding DataContext?.AvailableNumericAttributes, RelativeSource={RelativeSource AncestorType=ItemsControl}}"
1119+
ItemsSource="{Binding DataContext.AvailableNumericAttributes, RelativeSource={RelativeSource AncestorType=ItemsControl}}"
11201120
SelectedItem="{Binding AttributeName}"
11211121
HorizontalAlignment="Stretch" />
11221122
<StackPanel
@@ -1183,8 +1183,8 @@
11831183

11841184
<components:PhaseEditControl
11851185
PhaseSource="{Binding}"
1186-
AddPhaseCommand="{Binding DataContext?.AddPhaseCommand, RelativeSource={RelativeSource AncestorType=Window}}"
1187-
DeletePhaseCommand="{Binding DataContext?.DeletePhaseCommand, RelativeSource={RelativeSource AncestorType=Window}}" />
1186+
AddPhaseCommand="{Binding DataContext.AddPhaseCommand, RelativeSource={RelativeSource AncestorType=Window}}"
1187+
DeletePhaseCommand="{Binding DataContext.DeletePhaseCommand, RelativeSource={RelativeSource AncestorType=Window}}" />
11881188
</StackPanel>
11891189
</StackPanel>
11901190
</Expander>

DirectorPrompt/Views/PromptDialog.axaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
CanResize="False"
99
ShowAsDialog="True"
1010
ShowInTaskbar="False"
11-
Icon="/Assets/Images/Icon-NoBackground.png"
11+
Icon="/Assets/Images/Icon-NoBackground.ico"
1212
WindowStartupLocation="CenterOwner"
1313
TransparencyLevelHint="Mica">
1414
<Grid RowDefinitions="Auto,Auto,Auto">

0 commit comments

Comments
 (0)