This commit is contained in:
rabbitism
2024-02-25 17:32:44 +08:00
parent a948481f62
commit 101751b405
7 changed files with 50 additions and 26 deletions

View File

@@ -121,7 +121,8 @@
<Setter Property="Border.BorderBrush" Value="{DynamicResource IPv4BoxFocusBorderBrush}" />
</Style>
<Style Selector="^:disabled">
<Setter Property="Border.Background" Value="{DynamicResource IPv4BoxDisabledBackground}" />
<Setter Property="Background" Value="{DynamicResource IPv4BoxDisabledBackground}" />
<Setter Property="Foreground" Value="{DynamicResource SemiColorDisabledText}" />
</Style>
</ControlTheme>
</ResourceDictionary>

View File

@@ -115,6 +115,19 @@ public class IPv4Box: TemplatedControl
_presenters[1] = _secondText;
_presenters[2] = _thirdText;
_presenters[3] = _fourthText;
if (this.IPAddress != null)
{
var sections = IPAddress.ToString().Split('.');
for (int i = 0; i < 4; i++)
{
var presenter = _presenters[i];
if (presenter != null)
{
presenter.Text = sections[i];
}
}
ParseBytes(ShowLeadingZero);
}
}
protected override void OnKeyDown(KeyEventArgs e)

View File

@@ -3,6 +3,7 @@ using Avalonia.Controls;
using Avalonia.Controls.Metadata;
using Avalonia.Controls.Primitives;
using Avalonia.Input;
using Avalonia.Interactivity;
using Avalonia.Media;
using Avalonia.Media.Imaging;
@@ -149,6 +150,7 @@ public class ImageViewer: TemplatedControl
private void OnSourceChanged(AvaloniaPropertyChangedEventArgs args)
{
if(!IsLoaded) return;
IImage image = args.GetNewValue<IImage>();
Size size = image.Size;
double width = this.Bounds.Width;
@@ -184,7 +186,16 @@ public class ImageViewer: TemplatedControl
base.OnApplyTemplate(e);
_image = e.NameScope.Get<Image>(PART_Image);
_layer = e.NameScope.Get<VisualLayerManager>(PART_Layer);
if (Source is { } i)
if (Overlayer is { } c)
{
AdornerLayer.SetAdorner(this, c);
}
}
protected override void OnLoaded(RoutedEventArgs e)
{
base.OnLoaded(e);
if (Source is { } i && _image is { })
{
Size size = i.Size;
double width = Bounds.Width;
@@ -193,14 +204,9 @@ public class ImageViewer: TemplatedControl
_image.Height = size.Height;
Scale = GetScaleRatio(width/size.Width, height/size.Height, this.Stretch);
}
if (Overlayer is { } c)
{
AdornerLayer.SetAdorner(this, c);
}
}
protected override void OnPointerWheelChanged(PointerWheelEventArgs e)
{
base.OnPointerWheelChanged(e);