mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-18 02:10:21 +08:00
perf: 优化悬浮窗布局
This commit is contained in:
@@ -22,51 +22,49 @@
|
||||
VerticalAlignment="Top"
|
||||
Background="{DynamicResource RegionBrushOpacity75}"
|
||||
CornerRadius="8">
|
||||
<ScrollViewer
|
||||
x:Name="LogScrollViewer"
|
||||
HorizontalScrollBarVisibility="Disabled"
|
||||
VerticalScrollBarVisibility="Auto">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<ScrollViewer
|
||||
Grid.Row="1"
|
||||
HorizontalScrollBarVisibility="Disabled"
|
||||
VerticalScrollBarVisibility="Auto">
|
||||
<ItemsControl x:Name="LogItemsControl" ItemsSource="{Binding LogItemsSource}">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid MaxWidth="400">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<ScrollViewer
|
||||
x:Name="LogScrollViewer"
|
||||
HorizontalScrollBarVisibility="Disabled"
|
||||
VerticalScrollBarVisibility="Auto">
|
||||
<ItemsControl
|
||||
x:Name="LogItemsControl"
|
||||
d:ItemsSource="{d:SampleData ItemCount=10}"
|
||||
ItemsSource="{Binding LogItemsSource}">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- 时间 -->
|
||||
<controls:TextBlock
|
||||
Grid.Column="0"
|
||||
Margin="0,5,10,0"
|
||||
FontSize="11"
|
||||
Foreground="{DynamicResource TraceLogBrush}"
|
||||
Text="{Binding Time}" />
|
||||
<!-- 时间 -->
|
||||
<controls:TextBlock
|
||||
Grid.Column="0"
|
||||
Margin="0,5,10,5"
|
||||
VerticalAlignment="Bottom"
|
||||
FontSize="11"
|
||||
Foreground="{DynamicResource TraceLogBrush}"
|
||||
Text="{Binding Time}" />
|
||||
|
||||
<!-- 内容 -->
|
||||
<controls:TextBlock
|
||||
Grid.Column="1"
|
||||
Margin="0,5"
|
||||
HorizontalAlignment="Left"
|
||||
FontWeight="{Binding Weight}"
|
||||
ForegroundKey="{Binding Color}"
|
||||
Text="{Binding Content}"
|
||||
TextWrapping="Wrap" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
<!-- 内容 -->
|
||||
<controls:TextBlock
|
||||
Grid.Column="1"
|
||||
Margin="0,5"
|
||||
HorizontalAlignment="Left"
|
||||
FontWeight="{Binding Weight}"
|
||||
ForegroundKey="{Binding Color}"
|
||||
Text="{Binding Content}"
|
||||
TextWrapping="Wrap" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Window>
|
||||
|
||||
@@ -308,7 +308,7 @@ public partial class OverlayWindow : Window
|
||||
var bottomRight = transform.Transform(new Point(rect.right, rect.bottom));
|
||||
var newWidthWpf = Math.Max(0, bottomRight.X - topLeft.X);
|
||||
double horizontalMargin = border.Margin.Left + border.Margin.Right;
|
||||
border.MaxWidth = Math.Max(0, newWidthWpf - horizontalMargin);
|
||||
border.MaxWidth = Math.Clamp(newWidthWpf - horizontalMargin, 0, 250);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user