|
@@ -1,5 +1,7 @@
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
|
|
+using System.Collections.ObjectModel;
|
|
using System.ComponentModel;
|
|
using System.ComponentModel;
|
|
|
|
+using System.Linq;
|
|
using System.Windows.Input;
|
|
using System.Windows.Input;
|
|
using Avalonia;
|
|
using Avalonia;
|
|
using Avalonia.Controls;
|
|
using Avalonia.Controls;
|
|
@@ -48,9 +50,6 @@ internal partial class Viewport : UserControl, INotifyPropertyChanged
|
|
public static readonly StyledProperty<ICommand> MouseUpCommandProperty =
|
|
public static readonly StyledProperty<ICommand> MouseUpCommandProperty =
|
|
AvaloniaProperty.Register<Viewport, ICommand>(nameof(MouseUpCommand), null);
|
|
AvaloniaProperty.Register<Viewport, ICommand>(nameof(MouseUpCommand), null);
|
|
|
|
|
|
- private static readonly StyledProperty<Dictionary<ChunkResolution, WriteableBitmap>> BitmapsProperty =
|
|
|
|
- AvaloniaProperty.Register<Viewport, Dictionary<ChunkResolution, WriteableBitmap>>(nameof(Bitmaps), null);
|
|
|
|
-
|
|
|
|
public static readonly StyledProperty<bool> DelayedProperty =
|
|
public static readonly StyledProperty<bool> DelayedProperty =
|
|
AvaloniaProperty.Register<Viewport, bool>(nameof(Delayed), false);
|
|
AvaloniaProperty.Register<Viewport, bool>(nameof(Delayed), false);
|
|
|
|
|
|
@@ -84,6 +83,9 @@ internal partial class Viewport : UserControl, INotifyPropertyChanged
|
|
public static readonly StyledProperty<ICommand> MiddleMouseClickedCommandProperty =
|
|
public static readonly StyledProperty<ICommand> MiddleMouseClickedCommandProperty =
|
|
AvaloniaProperty.Register<Viewport, ICommand>(nameof(MiddleMouseClickedCommand), null);
|
|
AvaloniaProperty.Register<Viewport, ICommand>(nameof(MiddleMouseClickedCommand), null);
|
|
|
|
|
|
|
|
+ public ChunkSet ActiveChunkSet => Document.RenderedChunks[ActiveResolution];
|
|
|
|
+ public ChunkResolution ActiveResolution => CalculateResolution();
|
|
|
|
+
|
|
public ICommand? MiddleMouseClickedCommand
|
|
public ICommand? MiddleMouseClickedCommand
|
|
{
|
|
{
|
|
get => (ICommand?)GetValue(MiddleMouseClickedCommandProperty);
|
|
get => (ICommand?)GetValue(MiddleMouseClickedCommandProperty);
|
|
@@ -150,12 +152,6 @@ internal partial class Viewport : UserControl, INotifyPropertyChanged
|
|
set => SetValue(DelayedProperty, value);
|
|
set => SetValue(DelayedProperty, value);
|
|
}
|
|
}
|
|
|
|
|
|
- public Dictionary<ChunkResolution, WriteableBitmap>? Bitmaps
|
|
|
|
- {
|
|
|
|
- get => (Dictionary<ChunkResolution, WriteableBitmap>?)GetValue(BitmapsProperty);
|
|
|
|
- set => SetValue(BitmapsProperty, value);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
public ICommand? MouseDownCommand
|
|
public ICommand? MouseDownCommand
|
|
{
|
|
{
|
|
get => (ICommand?)GetValue(MouseDownCommandProperty);
|
|
get => (ICommand?)GetValue(MouseDownCommandProperty);
|
|
@@ -250,7 +246,9 @@ internal partial class Viewport : UserControl, INotifyPropertyChanged
|
|
Document?.Operations.AddOrUpdateViewport(GetLocation());
|
|
Document?.Operations.AddOrUpdateViewport(GetLocation());
|
|
|
|
|
|
if (oldRes != newRes)
|
|
if (oldRes != newRes)
|
|
- PropertyChanged?.Invoke(this, new(nameof(TargetBitmap)));
|
|
|
|
|
|
+ {
|
|
|
|
+ UpdateChunks(newRes);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -269,16 +267,16 @@ internal partial class Viewport : UserControl, INotifyPropertyChanged
|
|
Document?.Operations.AddOrUpdateViewport(GetLocation());
|
|
Document?.Operations.AddOrUpdateViewport(GetLocation());
|
|
|
|
|
|
if (oldRes != newRes)
|
|
if (oldRes != newRes)
|
|
- PropertyChanged?.Invoke(this, new(nameof(TargetBitmap)));
|
|
|
|
|
|
+ {
|
|
|
|
+ UpdateChunks(newRes);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- public Surface? TargetBitmap
|
|
|
|
|
|
+ private void UpdateChunks(ChunkResolution newRes)
|
|
{
|
|
{
|
|
- get
|
|
|
|
- {
|
|
|
|
- return Document?.Surfaces.TryGetValue(CalculateResolution(), out Surface? value) == true ? value : null;
|
|
|
|
- }
|
|
|
|
|
|
+ PropertyChanged?.Invoke(this, new(nameof(ActiveChunkSet)));
|
|
|
|
+ PropertyChanged?.Invoke(this, new(nameof(ActiveResolution)));
|
|
}
|
|
}
|
|
|
|
|
|
public double ReferenceLayerScale =>
|
|
public double ReferenceLayerScale =>
|
|
@@ -295,7 +293,7 @@ internal partial class Viewport : UserControl, INotifyPropertyChanged
|
|
static Viewport()
|
|
static Viewport()
|
|
{
|
|
{
|
|
DocumentProperty.Changed.Subscribe(OnDocumentChange);
|
|
DocumentProperty.Changed.Subscribe(OnDocumentChange);
|
|
- BitmapsProperty.Changed.Subscribe(OnBitmapsChange);
|
|
|
|
|
|
+ //ActiveChunkSetProperty.Changed.Subscribe(OnChunksChange);
|
|
ZoomViewportTriggerProperty.Changed.Subscribe(ZoomViewportTriggerChanged);
|
|
ZoomViewportTriggerProperty.Changed.Subscribe(ZoomViewportTriggerChanged);
|
|
CenterViewportTriggerProperty.Changed.Subscribe(CenterViewportTriggerChanged);
|
|
CenterViewportTriggerProperty.Changed.Subscribe(CenterViewportTriggerChanged);
|
|
}
|
|
}
|
|
@@ -304,8 +302,8 @@ internal partial class Viewport : UserControl, INotifyPropertyChanged
|
|
{
|
|
{
|
|
InitializeComponent();
|
|
InitializeComponent();
|
|
|
|
|
|
- Binding binding = new Binding { Source = this, Path = $"{nameof(Document)}.{nameof(Document.Surfaces)}" };
|
|
|
|
- this.Bind(BitmapsProperty, binding);
|
|
|
|
|
|
+ /*Binding binding = new Binding { Source = this, Path = $"{nameof(Document)}.{nameof(Document.Surfaces)}" };
|
|
|
|
+ this.Bind(ChunksProperty, binding);*/
|
|
|
|
|
|
MainImage!.Loaded += OnImageLoaded;
|
|
MainImage!.Loaded += OnImageLoaded;
|
|
MainImage.SizeChanged += OnMainImageSizeChanged;
|
|
MainImage.SizeChanged += OnMainImageSizeChanged;
|
|
@@ -317,7 +315,7 @@ internal partial class Viewport : UserControl, INotifyPropertyChanged
|
|
viewportGrid.AddHandler(PointerPressedEvent, Image_MouseDown, RoutingStrategies.Bubble);
|
|
viewportGrid.AddHandler(PointerPressedEvent, Image_MouseDown, RoutingStrategies.Bubble);
|
|
}
|
|
}
|
|
|
|
|
|
- public SurfaceControl? MainImage => (SurfaceControl?)((Grid?)((Border?)zoombox.AdditionalContent)?.Child)?.Children[1];
|
|
|
|
|
|
+ public ItemsControl? MainImage => (ItemsControl?)((Grid?)((Border?)zoombox.AdditionalContent)?.Child)?.Children[1];
|
|
public Grid BackgroundGrid => viewportGrid;
|
|
public Grid BackgroundGrid => viewportGrid;
|
|
|
|
|
|
private void ForceRefreshFinalImage()
|
|
private void ForceRefreshFinalImage()
|
|
@@ -346,10 +344,10 @@ internal partial class Viewport : UserControl, INotifyPropertyChanged
|
|
newDoc?.Operations.AddOrUpdateViewport(viewport.GetLocation());
|
|
newDoc?.Operations.AddOrUpdateViewport(viewport.GetLocation());
|
|
}
|
|
}
|
|
|
|
|
|
- private static void OnBitmapsChange(AvaloniaPropertyChangedEventArgs<Dictionary<ChunkResolution, WriteableBitmap>?> e)
|
|
|
|
|
|
+ private static void OnChunksChange(AvaloniaPropertyChangedEventArgs<Dictionary<ChunkResolution, Dictionary<VecI, Chunk>>?> e)
|
|
{
|
|
{
|
|
Viewport viewportObj = (Viewport)e.Sender;
|
|
Viewport viewportObj = (Viewport)e.Sender;
|
|
- viewportObj.PropertyChanged?.Invoke(viewportObj, new(nameof(TargetBitmap)));
|
|
|
|
|
|
+ //viewportObj.PropertyChanged?.Invoke(viewportObj, new(nameof(TargetBitmap)));
|
|
}
|
|
}
|
|
|
|
|
|
private ChunkResolution CalculateResolution()
|
|
private ChunkResolution CalculateResolution()
|