|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Controls.Primitives;
namespace ZoomAndPanSample
{
/// <summary>
/// Interaction logic for OverviewWindow.xaml
/// </summary>
public partial class OverviewWindow : Window
{
public OverviewWindow()
{
InitializeComponent();
}
/// <summary>
/// Event raised when the size of the ZoomAndPanControl changes.
/// </summary>
private void overview_SizeChanged(object sender, SizeChangedEventArgs e)
{
//
// Update the scale so that the entire content fits in the window.
//
overview.ScaleToFit();
}
/// <summary>
/// Event raised when the user drags the overview zoom rect.
/// </summary>
private void overviewZoomRectThumb_DragDelta(object sender, DragDeltaEventArgs e)
{
//
// Update the position of the overview rect as the user drags it around.
//
double newContentOffsetX = Math.Min(Math.Max(0.0, Canvas.GetLeft(overviewZoomRectThumb) + e.HorizontalChange), DataModel.Instance.ContentWidth - DataModel.Instance.ContentViewportWidth);
Canvas.SetLeft(overviewZoomRectThumb, newContentOffsetX);
double newContentOffsetY = Math.Min(Math.Max(0.0, Canvas.GetTop(overviewZoomRectThumb) + e.VerticalChange), DataModel.Instance.ContentHeight - DataModel.Instance.ContentViewportHeight);
Canvas.SetTop(overviewZoomRectThumb, newContentOffsetY);
}
/// <summary>
/// Event raised on mouse down.
/// </summary>
private void Window_MouseDown(object sender, MouseButtonEventArgs e)
{
//
// Update the position of the overview rect to the point that was clicked.
//
Point clickedPoint = e.GetPosition(content);
double newX = clickedPoint.X - (overviewZoomRectThumb.Width / 2);
double newY = clickedPoint.Y - (overviewZoomRectThumb.Height / 2);
Canvas.SetLeft(overviewZoomRectThumb, newX);
Canvas.SetTop(overviewZoomRectThumb, newY);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Software craftsman | Author | Writing rapidfullstackdevelopment.com - Posting about how to survive and flourish as a software developer
Follow on Twitter for news and updates: https://twitter.com/codecapers
I'm writing a new book: Rapid Fullstack Development. Learn from my years of experience and become a better developer.
My second book, Bootstrapping Microservices, is a practical and project-based guide to building distributed applications with microservices.
My first book Data Wrangling with JavaScript is a comprehensive overview of working with data in JavaScript.
Data-Forge Notebook is my notebook-style application for data transformation, analysis and transformation in JavaScript.
I have a long history in software development with many years in apps, web apps, backends, serious games, simulations and VR. Making technology work for business is what I do: building bespoke software solutions that span multiple platforms.
I have years of experience managing development teams, preparing technical strategies and creation of software products. I can explain complicated technology to senior management. I have delivered cutting-edge products in fast-paced and high-pressure environments. I know how to focus and prioritize to get the important things done.
Author
- Rapid Fullstack Development
- Bootstrapping Microservices
- Data Wrangling with JavaScript
Creator of Market Wizard
- https://www.market-wizard.com.au/
Creator of Data-Forge and Data-Forge Notebook
- http://www.data-forge-js.com
- http://www.data-forge-notebook.com
Web
- www.codecapers.com.au
Open source
- https://github.com/ashleydavis
- https://github.com/data-forge
- https://github.com/data-forge-notebook
Skills
- Quickly building MVPs for startups
- Understanding how to get the most out of technology for business
- Developing technical strategies
- Management and coaching of teams & projects
- Microservices, devops, mobile and fullstack software development