panandzoom-nightly - Avalonia.Controls.ViewBox 2.3.0-build20191105-01

ViewBox control for Avalonia apps.

PM> Install-Package Avalonia.Controls.ViewBox -Version 2.3.0-build20191105-01 -Source https://www.myget.org/F/panandzoom-nightly/api/v3/index.json

Copy to clipboard

> nuget.exe install Avalonia.Controls.ViewBox -Version 2.3.0-build20191105-01 -Source https://www.myget.org/F/panandzoom-nightly/api/v3/index.json

Copy to clipboard

> dotnet add package Avalonia.Controls.ViewBox --version 2.3.0-build20191105-01 --source https://www.myget.org/F/panandzoom-nightly/api/v3/index.json

Copy to clipboard
<PackageReference Include="Avalonia.Controls.ViewBox" Version="2.3.0-build20191105-01" />
Copy to clipboard
source https://www.myget.org/F/panandzoom-nightly/api/v3/index.json

nuget Avalonia.Controls.ViewBox  ~> 2.3.0-build20191105-01
Copy to clipboard

> choco install Avalonia.Controls.ViewBox --version 2.3.0-build20191105-01 --source https://www.myget.org/F/panandzoom-nightly/api/v2

Copy to clipboard
Import-Module PowerShellGet
Register-PSRepository -Name "panandzoom-nightly" -SourceLocation "https://www.myget.org/F/panandzoom-nightly/api/v2"
Install-Module -Name "Avalonia.Controls.ViewBox" -RequiredVersion "2.3.0-build20191105-01" -Repository "panandzoom-nightly" -AllowPreRelease
Copy to clipboard

PanAndZoom

Gitter

Build status

NuGet MyGet

PanAndZoom control for WPF and Avalonia

NuGet

PanAndZoom is delivered as a NuGet package.

You can find the packages here NuGet for Avalonia and here NuGet for WPF or by using nightly build feed:

  • Add https://www.myget.org/F/panandzoom-nightly/api/v2 to your package sources
  • Update your package using PanAndZoom feed

You can install the package for Avalonia based projects like this:

Install-Package Avalonia.Controls.PanAndZoom -Pre

You can install the package for WPF based projects like this:

Install-Package Wpf.Controls.PanAndZoom -Pre

Package Dependencies

Package Sources

Resources

Using PanAndZoom

Avalonia

MainWindow.xaml

<Window x:Class="AvaloniaDemo.MainWindow"
        xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:paz="clr-namespace:Avalonia.Controls.PanAndZoom;assembly=Avalonia.Controls.PanAndZoom"
        UseLayoutRounding="True"
        Title="PanAndZoom Avalonia Demo" Height="640" Width="640">
    <Grid RowDefinitions="Auto,12,Auto,12,*,12" ColumnDefinitions="50,*,50">
        <StackPanel Orientation="Vertical" 
                    HorizontalAlignment="Center" Grid.Row="0" Grid.Column="1">
            <TextBlock Text="F - Fill"/>
            <TextBlock Text="U - Uniform"/>
            <TextBlock Text="R - Reset"/>
            <TextBlock Text="T - Toggle Stretch Mode"/>
            <TextBlock Text="Mouse Wheel - Zoom to Point"/>
            <TextBlock Text="Mouse Left Button Down - Pan"/>
        </StackPanel>
        <StackPanel Orientation="Horizontal" 
                    HorizontalAlignment="Center" Grid.Row="2" Grid.Column="1">
            <TextBlock Text="PanButton:" VerticalAlignment="Center"/>
            <ComboBox Items="{x:Static paz:ZoomBorder.ButtonNames}" 
                      SelectedItem="{Binding #zoomBorder.PanButton, Mode=TwoWay}" 
                      Margin="2">
            </ComboBox>
            <TextBlock Text="Stretch:" VerticalAlignment="Center"/>
            <ComboBox Items="{x:Static paz:ZoomBorder.StretchModes}" 
                      SelectedItem="{Binding #zoomBorder.Stretch, Mode=TwoWay}" 
                      Margin="2">
            </ComboBox>
            <TextBlock Text="ZoomSpeed:" VerticalAlignment="Center"/>
            <TextBox Text="{Binding #zoomBorder.ZoomSpeed, Mode=TwoWay}" 
                     TextAlignment="Center" Width="50" Margin="2"/>
            <CheckBox IsChecked="{Binding #zoomBorder.EnableInput}" 
                      Content="EnableInput" VerticalAlignment="Center"/>
        </StackPanel>
        <paz:ZoomBorder Name="zoomBorder" Stretch="None" ZoomSpeed="1.2" 
                        Background="SlateBlue" ClipToBounds="True" Focusable="True"
                        VerticalAlignment="Stretch" HorizontalAlignment="Stretch" 
                        Grid.Row="4" Grid.Column="1">
            <Canvas Background="LightGray" Width="300" Height="300">
                <Rectangle Canvas.Left="100" Canvas.Top="100" Width="50" Height="50" Fill="Red"/>
                <StackPanel Canvas.Left="100" Canvas.Top="200">
                    <TextBlock Text="Text1" Width="100" Background="Red" Foreground="WhiteSmoke"/>
                    <TextBlock Text="Text2" Width="100" Background="Red" Foreground="WhiteSmoke"/>
                </StackPanel>
            </Canvas>
        </paz:ZoomBorder>
    </Grid>
</Window>

MainWindow.xaml.cs

using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.PanAndZoom;
using Avalonia.Input;
using Avalonia.Markup.Xaml;

namespace AvaloniaDemo
{
    public class MainWindow : Window
    {
        private ZoomBorder zoomBorder;

        public MainWindow()
        {
            this.InitializeComponent();
            this.AttachDevTools();

            zoomBorder = this.Find<ZoomBorder>("zoomBorder");
            zoomBorder.KeyDown += ZoomBorder_KeyDown;
        }

        private void InitializeComponent()
        {
            AvaloniaXamlLoader.Load(this);
        }

        private void ZoomBorder_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.F)
            {
                zoomBorder.Fill();
            }

            if (e.Key == Key.U)
            {
                zoomBorder.Uniform();
            }

            if (e.Key == Key.R)
            {
                zoomBorder.Reset();
            }

            if (e.Key == Key.T)
            {
                zoomBorder.ToggleStretchMode();
                zoomBorder.AutoFit();
            }
        }
    }
}

WPF

MainWindow.xaml

<Window x:Class="WpfDemo.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:paz="clr-namespace:Wpf.Controls.PanAndZoom;assembly=Wpf.Controls.PanAndZoom"
        WindowStartupLocation="CenterScreen"
        UseLayoutRounding="True" SnapsToDevicePixels="True" TextOptions.TextFormattingMode="Display"
        Title="PanAndZoom WPF Demo" Height="640" Width="640">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="12"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="12"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="12"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="50"/>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="50"/>
        </Grid.ColumnDefinitions>
        <StackPanel Orientation="Vertical" 
                    HorizontalAlignment="Center" Grid.Row="0" Grid.Column="1">
            <TextBlock Text="F - Fill"/>
            <TextBlock Text="U - Uniform"/>
            <TextBlock Text="R - Reset"/>
            <TextBlock Text="T - Toggle Stretch Mode"/>
            <TextBlock Text="Mouse Wheel - Zoom to Point"/>
            <TextBlock Text="Mouse Left Button Down - Pan"/>
        </StackPanel>
        <StackPanel Orientation="Horizontal" 
                    HorizontalAlignment="Center" Grid.Row="2" Grid.Column="1">
            <TextBlock Text="PanButton:" VerticalAlignment="Center"/>
            <ComboBox ItemsSource="{Binding ElementName=zoomBorder, Path=ButtonNames}" 
                      SelectedItem="{Binding ElementName=zoomBorder, Path=PanButton}" 
                      Margin="2">
            </ComboBox>
            <TextBlock Text="Stretch:" VerticalAlignment="Center"/>
            <ComboBox ItemsSource="{Binding ElementName=zoomBorder, Path=StretchModes}" 
                      SelectedItem="{Binding ElementName=zoomBorder, Path=Stretch}" 
                      Margin="2">
            </ComboBox>
            <TextBlock Text="ZoomSpeed:" VerticalAlignment="Center"/>
            <TextBox Text="{Binding ElementName=zoomBorder, Path=ZoomSpeed}" 
                     TextAlignment="Center" Width="50" Margin="2"/>
            <CheckBox IsChecked="{Binding ElementName=zoomBorder, Path=EnableInput}" 
                      Content="EnableInput" VerticalAlignment="Center"/>
        </StackPanel>
        <paz:ZoomBorder Name="zoomBorder" Stretch="None" ZoomSpeed="1.2" 
                        Background="SlateBlue" ClipToBounds="True" Focusable="True"
                        VerticalAlignment="Stretch" HorizontalAlignment="Stretch" 
                        Grid.Row="4" Grid.Column="1">
            <Canvas Background="LightGray" Width="300" Height="300">
                <Rectangle Canvas.Left="100" Canvas.Top="100" Width="50" Height="50" Fill="Red"/>
                <StackPanel Canvas.Left="100" Canvas.Top="200">
                    <TextBlock Text="Text1" Width="100" Background="Red" Foreground="WhiteSmoke"/>
                    <TextBlock Text="Text2" Width="100" Background="Red" Foreground="WhiteSmoke"/>
                </StackPanel>
            </Canvas>
        </paz:ZoomBorder>
    </Grid>
</Window>

MainWindow.xaml.cs

using System.Windows;
using System.Windows.Input;

namespace WpfDemo
{
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            zoomBorder.KeyDown += ZoomBorder_KeyDown;
        }

        private void ZoomBorder_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.F)
            {
                zoomBorder.Fill();
            }

            if (e.Key == Key.U)
            {
                zoomBorder.Uniform();
            }

            if (e.Key == Key.R)
            {
                zoomBorder.Reset();
            }

            if (e.Key == Key.T)
            {
                zoomBorder.ToggleStretchMode();
                zoomBorder.AutoFit();
            }
        }
    }
}

Getting zoom ratio

To get current zoom ratio use ZoomX and ZoomY properties.

Getting pan offset

To get current pan offset use OffsetX and OffsetY properties.

Constrain zoom ratio

To constrain zoom ratio use MinZoomX, MaxZoomX, MinZoomY and MaxZoomY properties.

Constrain pan offset

To constrain pan offset use MinOffsetX, MaxOffsetX, MinOffsetY and MaxOffsetY properties.

Enable or disable constrains

To enable or disable contrains use EnableConstrains flag.

License

PanAndZoom is licensed under the MIT license.

  • .NETFramework 4.6.1
    • Avalonia (>= 0.9.0-preview1)
  • .NETStandard 2.0
    • Avalonia (>= 0.9.0-preview1)
  • .NETStandard 2.1
    • Avalonia (>= 0.9.0-preview1)
  • .NETFramework 4.6.1: 4.6.1.0
  • .NETStandard 2.0: 2.0.0.0
  • .NETStandard 2.1: 2.1.0.0

Owners

Wiesław Šoltés

Authors

Wiesław Šoltés

Project URL

https://github.com/wieslawsoltes/PanAndZoom

License

MIT

Tags

Avalonia ViewBox Control Xaml Managed C#

Info

0 total downloads
0 downloads for version 2.3.0-build20191105-01
Download (14.44 KB)
Found on the current feed only

Package history

Version Size Last updated Downloads Mirrored?
2.3.0-build20191105-01 14.44 KB Tue, 05 Nov 2019 07:34:21 GMT 0
2.3.0-build20191023-01 14.45 KB Wed, 23 Oct 2019 06:50:40 GMT 0
2.3.0-build20191015-01 14.44 KB Tue, 15 Oct 2019 16:51:46 GMT 0
2.3.0-build20191003-01 14.46 KB Thu, 03 Oct 2019 15:13:04 GMT 0
2.3.0-build20191001-04 14.46 KB Tue, 01 Oct 2019 18:52:31 GMT 0
2.3.0-build20191001-03 14.46 KB Tue, 01 Oct 2019 13:00:08 GMT 0
2.3.0-build20191001-02 14.46 KB Tue, 01 Oct 2019 10:00:22 GMT 0
2.3.0-build20191001-01 14.61 KB Tue, 01 Oct 2019 08:35:04 GMT 0
2.3.0-build20190925-05 14.61 KB Wed, 25 Sep 2019 20:54:53 GMT 0
2.3.0-build20190925-04 14.61 KB Wed, 25 Sep 2019 20:08:23 GMT 0
2.3.0-build20190925-03 14.6 KB Wed, 25 Sep 2019 20:06:27 GMT 0
2.3.0-build20190925-02 14.62 KB Wed, 25 Sep 2019 19:56:01 GMT 0
2.3.0-build20190925-01 14.58 KB Wed, 25 Sep 2019 18:16:42 GMT 0
2.2.1-build20190923-01 9.87 KB Mon, 23 Sep 2019 17:35:22 GMT 0
2.2.1-build20190819-02 9.87 KB Mon, 19 Aug 2019 08:29:04 GMT 0
2.2.1-build20190819-01 9.86 KB Mon, 19 Aug 2019 08:28:31 GMT 0
2.2.1-build20190811-01 9.86 KB Sun, 11 Aug 2019 12:54:00 GMT 0
2.2.1-build20190809-03 9.87 KB Fri, 09 Aug 2019 13:59:01 GMT 0
2.2.0-build20190809-02 9.86 KB Fri, 09 Aug 2019 07:51:12 GMT 0
2.1.0-build20190809-01 9.87 KB Fri, 09 Aug 2019 07:45:42 GMT 0
2.1.0-build20190808-01 9.91 KB Thu, 08 Aug 2019 08:52:01 GMT 0
2.1.0-build20190604-01 9.91 KB Tue, 04 Jun 2019 16:10:08 GMT 0
2.1.0-build20190525-01 9.91 KB Sat, 25 May 2019 19:12:18 GMT 0
2.1.0-build20190518-01 9.91 KB Sat, 18 May 2019 21:23:20 GMT 0
2.1.0-build20190514-01 9.91 KB Tue, 14 May 2019 06:12:54 GMT 0
2.1.0-build20190511-01 9.9 KB Sat, 11 May 2019 12:23:22 GMT 0
2.1.0-build20190507-01 9.91 KB Tue, 07 May 2019 17:31:54 GMT 0
2.1.0-build20190506-01 9.91 KB Mon, 06 May 2019 16:40:26 GMT 0
2.1.0-build20190504-01 9.91 KB Sat, 04 May 2019 11:50:25 GMT 0
2.1.0-build20190503-01 6 KB Fri, 03 May 2019 16:20:38 GMT 0
2.1.0-build20190429-01 6 KB Mon, 29 Apr 2019 06:43:04 GMT 0
2.1.0-build20190427-01 6 KB Sat, 27 Apr 2019 10:28:49 GMT 0
2.1.0-build20190424-01 6 KB Wed, 24 Apr 2019 06:06:39 GMT 0
2.1.0-build20190423-02 6 KB Tue, 23 Apr 2019 07:40:36 GMT 0
2.1.0-build20190423-01 6 KB Tue, 23 Apr 2019 06:44:50 GMT 0
2.1.0-build20190419-02 5.99 KB Fri, 19 Apr 2019 11:06:54 GMT 0
2.1.0-build20190419-01 5.98 KB Fri, 19 Apr 2019 10:37:06 GMT 0
2.1.0-build20190416-02 5.98 KB Tue, 16 Apr 2019 16:39:18 GMT 0
2.0.0-build20190404-02 5.97 KB Thu, 04 Apr 2019 06:15:36 GMT 0
2.0.0-build20190404-01 5.96 KB Thu, 04 Apr 2019 06:07:10 GMT 0
2.0.0-build20190403-02 5.99 KB Wed, 03 Apr 2019 10:24:40 GMT 0
2.0.0-build20190403-01 5.98 KB Wed, 03 Apr 2019 07:08:52 GMT 0
2.0.0-build20190326-02 5.98 KB Tue, 26 Mar 2019 17:41:10 GMT 0
2.0.0-build20190326-01 5.98 KB Tue, 26 Mar 2019 17:46:14 GMT 0
2.0.0-build20190303-07 5.99 KB Sun, 03 Mar 2019 18:15:51 GMT 0
2.0.0-build20190303-06 5.98 KB Sun, 03 Mar 2019 17:34:23 GMT 0
2.0.0-build20190303-05 5.98 KB Sun, 03 Mar 2019 17:33:32 GMT 0
2.0.0-build20190303-04 5.98 KB Sun, 03 Mar 2019 17:31:56 GMT 0
1.0.4-build20190303-03 5.99 KB Sun, 03 Mar 2019 10:25:00 GMT 0
1.0.4-build20190303-02 5.99 KB Sun, 03 Mar 2019 10:08:47 GMT 0
1.0.4-build20190303-01 5.99 KB Sun, 03 Mar 2019 09:02:53 GMT 0
1.0.4-build20190226-01 5.99 KB Tue, 26 Feb 2019 09:33:29 GMT 0
1.0.3-build20190222-01 6 KB Fri, 22 Feb 2019 14:57:29 GMT 0