-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from gosha20777/dev
Dev
- Loading branch information
Showing
5 changed files
with
97 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using System; | ||
using Avalonia.Controls.PanAndZoom; | ||
using Avalonia.Input; | ||
|
||
namespace RescuerLaApp.Models | ||
{ | ||
public class Zoomer | ||
{ | ||
private static ZoomBorder _zoomBorder = null; | ||
|
||
public static void Init(ZoomBorder zoomBorder) | ||
{ | ||
_zoomBorder = zoomBorder; | ||
} | ||
|
||
public static void Zoom(double scale) | ||
{ | ||
_zoomBorder?.ZoomTo(scale, 0, 0); | ||
} | ||
|
||
public static void MoveTo(double x, double y) | ||
{ | ||
_zoomBorder?.PanTo(0.1,0); | ||
} | ||
|
||
public static double GetZoomX() | ||
{ | ||
return _zoomBorder?.ZoomX ?? 1; | ||
} | ||
public static double GetZoomY() | ||
{ | ||
return _zoomBorder?.ZoomY ?? 1; | ||
} | ||
|
||
public static void Reset() | ||
{ | ||
_zoomBorder?.Reset(); | ||
} | ||
|
||
public static event EventHandler<KeyEventArgs> KeyDown | ||
{ | ||
add => _zoomBorder.KeyDown+=value; | ||
remove => _zoomBorder.KeyDown+=value; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,34 @@ | ||
using Avalonia; | ||
using Avalonia.Controls; | ||
using Avalonia.Controls.PanAndZoom; | ||
using Avalonia.Input; | ||
using Avalonia.Markup.Xaml; | ||
using RescuerLaApp.ViewModels; | ||
using ReactiveUI; | ||
using RescuerLaApp.Models; | ||
|
||
namespace RescuerLaApp.Views | ||
{ | ||
public sealed class MainWindow : ReactiveWindow<MainWindowViewModel> | ||
{ | ||
ZoomBorder z = new ZoomBorder(); | ||
public MainWindow() | ||
{ | ||
AvaloniaXamlLoader.Load(this); | ||
this.WhenActivated(disposables => { }); | ||
#if DEBUG | ||
this.AttachDevTools(); | ||
#endif | ||
Zoomer.Init(this.Find<ZoomBorder>("zoomBorder")); | ||
Zoomer.KeyDown += ZoomBorder_KeyDown; | ||
} | ||
|
||
private void ZoomBorder_KeyDown(object sender, KeyEventArgs e) | ||
{ | ||
if (e.Key == Key.R) | ||
{ | ||
Zoomer.Reset(); | ||
} | ||
} | ||
} | ||
} |