Showing preview only (851K chars total). Download the full file or copy to clipboard to get everything.
Repository: cyotek/Cyotek.Windows.Forms.ImageBox
Branch: master
Commit: eaf19705e0b6
Files: 110
Total size: 809.5 KB
Directory structure:
gitextract_n7bu3m8j/
├── .editorconfig
├── .github/
│ └── workflows/
│ └── codeql-analysis.yml
├── .gitignore
├── .markdownlint.json
├── CHANGELOG.md
├── Cyotek.Windows.Forms.ImageBox/
│ ├── Cyotek.Windows.Forms.ImageBox.csproj
│ ├── Cyotek.Windows.Forms.ImageBox.nuspec
│ ├── ImageBox.cs
│ ├── ImageBoxActionSources.cs
│ ├── ImageBoxBorderStyle.cs
│ ├── ImageBoxCancelEventArgs.cs
│ ├── ImageBoxGridDisplayMode.cs
│ ├── ImageBoxGridScale.cs
│ ├── ImageBoxMouseWheelMessageFilter.cs
│ ├── ImageBoxMouseWheelMode.cs
│ ├── ImageBoxNativeMethods.cs
│ ├── ImageBoxPanDirection.cs
│ ├── ImageBoxPanMode.cs
│ ├── ImageBoxPanStyle.cs
│ ├── ImageBoxSelectionMode.cs
│ ├── ImageBoxSizeMode.cs
│ ├── ImageBoxZoomActions.cs
│ ├── ImageBoxZoomEventArgs.cs
│ ├── Properties/
│ │ └── AssemblyInfo.cs
│ ├── ScrollControl.cs
│ ├── ScrollProperties.cs
│ ├── VirtualScrollableControl.cs
│ ├── ZoomLevelCollection.cs
│ ├── ZoomLevelCollectionConverter.cs
│ └── cyopublic.snk
├── Cyotek.Windows.Forms.ImageBox.Demo/
│ ├── AboutDialog.cs
│ ├── AboutDialog.designer.cs
│ ├── AboutDialog.resx
│ ├── AnimatedGifDemoForm.Designer.cs
│ ├── AnimatedGifDemoForm.cs
│ ├── AnimatedGifDemoForm.resx
│ ├── BaseForm.Designer.cs
│ ├── BaseForm.cs
│ ├── BaseForm.resx
│ ├── Cyotek.Windows.Forms.ImageBox.Demo.csproj
│ ├── DisposedImageDemoForm.Designer.cs
│ ├── DisposedImageDemoForm.cs
│ ├── DisposedImageDemoForm.resx
│ ├── DragHandle.cs
│ ├── DragHandleAnchor.cs
│ ├── DragHandleCollection.cs
│ ├── DragTestForm.Designer.cs
│ ├── DragTestForm.cs
│ ├── DragTestForm.resx
│ ├── EventsListBox.cs
│ ├── FilteredPropertyGrid.cs
│ ├── GeneralDemoForm.Designer.cs
│ ├── GeneralDemoForm.cs
│ ├── GeneralDemoForm.resx
│ ├── GroupBox.cs
│ ├── ImageBoxEx.cs
│ ├── MainMenuForm.cs
│ ├── MainMenuForm.designer.cs
│ ├── MainMenuForm.resx
│ ├── MiniMapDemoForm.cs
│ ├── MiniMapDemoForm.designer.cs
│ ├── MiniMapDemoForm.resx
│ ├── OpenUrlDialog.Designer.cs
│ ├── OpenUrlDialog.cs
│ ├── OpenUrlDialog.resx
│ ├── PanStylesDemoForm.Designer.cs
│ ├── PanStylesDemoForm.cs
│ ├── PanStylesDemoForm.resx
│ ├── PixelGridForm.Designer.cs
│ ├── PixelGridForm.cs
│ ├── PixelGridForm.resx
│ ├── Program.cs
│ ├── Properties/
│ │ ├── AssemblyInfo.cs
│ │ ├── Resources.Designer.cs
│ │ └── Resources.resx
│ ├── PropertyGrid.cs
│ ├── ResizableSelectionDemoForm.Designer.cs
│ ├── ResizableSelectionDemoForm.cs
│ ├── ResizableSelectionDemoForm.resx
│ ├── Resources/
│ │ └── markdownpad-github.css
│ ├── ScaledAdornmentsDemoForm.Designer.cs
│ ├── ScaledAdornmentsDemoForm.cs
│ ├── ScaledAdornmentsDemoForm.resx
│ ├── SizeModeDemoForm.Designer.cs
│ ├── SizeModeDemoForm.cs
│ ├── SizeModeDemoForm.resx
│ ├── SwitchImageDuringZoomDemoForm.Designer.cs
│ ├── SwitchImageDuringZoomDemoForm.cs
│ ├── SwitchImageDuringZoomDemoForm.resx
│ ├── TextDemoForm.Designer.cs
│ ├── TextDemoForm.cs
│ ├── TextDemoForm.resx
│ ├── VirtualModeDemonstrationForm.Designer.cs
│ ├── VirtualModeDemonstrationForm.cs
│ ├── VirtualModeDemonstrationForm.resx
│ ├── app.manifest
│ ├── cyopublic.snk
│ └── packages.config
├── Cyotek.Windows.Forms.ImageBox.Design/
│ ├── Cyotek.Windows.Forms.ImageBox.Design.csproj
│ ├── ImageBoxDesigner.cs
│ └── Properties/
│ └── AssemblyInfo.cs
├── Cyotek.Windows.Forms.ImageBox.sln
├── LICENSE.txt
├── README.md
├── acknowledgements.md
├── build.cmd
├── nuget.config
└── res/
├── PanAll.cur
├── icon-16.pdn
└── icon-32.pdn
================================================
FILE CONTENTS
================================================
================================================
FILE: .editorconfig
================================================
; http://editorconfig.org/
; https://visualstudiogallery.msdn.microsoft.com/c8bccfe2-650c-4b42-bc5c-845e21f96328
root=true
[*]
end_of_line = crlf
trim_trailing_whitespace = true
insert_final_newline = true
charset = utf-8
[*.cs]
indent_style = space
indent_size = 2
================================================
FILE: .github/workflows/codeql-analysis.yml
================================================
name: "CodeQL"
on:
push:
branches: [master]
pull_request:
# The branches below must be a subset of the branches above
branches: [master]
schedule:
- cron: '0 7 * * 3'
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# Override automatic language detection by changing the below list
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
language: ['csharp']
# Learn more...
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2
# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
#- run: |
# make bootstrap
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
================================================
FILE: .gitignore
================================================
.vs/
bin/
obj/
_NCrunch_*
nuget/
packages/
maps/
*.ncrunch*
*.user
push.cmd
*.suo
*.ncrunchproject
================================================
FILE: .markdownlint.json
================================================
{
"MD001": false,
"MD024": false
}
================================================
FILE: CHANGELOG.md
================================================
# Cyotek ImageBox Change Log
## 1.4.0
### Added
* Added new `MouseWheelMode` property to control how the mouse
wheel is used to interact with the control. When set to `Zoom`
(default), the wheel will scroll the control in and out. When
set to `ScrollAndZoom`, the wheel scrolls the control
vertically. Holding down `Shift` will scroll horizontally, or
`Control` to zoom (#18).
## 1.3.1
### Fixed
* Panning only worked if the horizontal scrollbar was present (#45)
## 1.3
### Added
* Added `PanMode` property. This property allows you to determine if panning can be triggered by the left mouse button, the middle mouse button or both. This property replaces the `AutoPan` property.
* Added `AllowFreePan` property. This property determines if panning only occurs when the mouse button is pressed, or if pressing the mouse button starts free panning and pressing any other button cancels the pan. Free panning only applies when using the middle mouse button.
### Deprecated
* The `AutoPan` property has been deprecated and will be removed in a future version
## 1.2.2
### Fixed
* Any exception during image painting will now be caught, and the error text printed
in lieu of the image
* Fixed a crash that could occur when dragging a selection if the selection was empty
## 1.2
### Changed
* Reworked events to have less overhead
* Switched to semantic versioning
## 1.1.5.1
### Fixed
* Fixes the `FitRectangle` method from increasing the width or height of the
source rectangle if `X` or `Y` were negative (generally seen when the
`SelectionMode` is set to `Rectangle` and you draw outside the bounds of the
image area)
* Resizing the selection in the `ImageBoxEx` control now works correctly even if
the mouse passes outside the bounds of the image
## 1.1.5.0
### Added
* Added `AllowUnfocusedMouseWheel` property. If set to `true` the control will
support mouse wheel zooming even when it does not have focus
### Fixed
* The `fitToBounds` parameter of the `PointToImage` wasn't being used correctly
## 1.1.4.6
### Added
* Added new `MaximumSelectionSize` property to the demonstration `ImageBoxEx`
control that allows for more control over default selection
* Added new overloads to `ZoomIn` and `ZoomOut` to determine if the center point
should be preserved
### Changed
* Refactored zoom handling for mouse and keyboard to avoid duplicate
calculations
* Updated copyright year
### Fixed
* Zooming in or out using the default keybinds now preserves the center point
relative to the new zoom
* Fixed the **About** dialog in the demonstration program not loading the
default tab correctly
## 1.1.4.5
### Added
* `ImageBoxEx` example control now correctly allows you to move and resize
selection regions even when the control is zoomed
### Changed
* If the `InterpolationMode` property is set to `Default`, the `ImageBox`
control will now choose an appropriate mode based on the current zoom levels
## 1.1.4.4
### Added
* Added new `DrawBackground` virtual method. This allows you to override how the
`ImageBox` draws the image background without having to override the entire
`OnPaint` method
## 1.1.4.3
### Added
* Added a new `TextPadding` property and corresponding `DrawLabel` overload.
When this property is set, rendered text from the `Text` and `TextAlign`
properties is drawn with the appropriate padding. If the `TextBackColor`
property is set to something not fully transparent, then the background will
be filled in the original render spot, excluding the padding, allowing for
labels with wider background borders
## 1.1.4.2
### Added
* Added a new **Resizable Selection** demo. This demo makes use of a subclass of
the `ImageBox` to add native dragging and resizing of the region defined by
the `SelectionRegion` property
### Changed
* `DrawImage` now also ignores `OutOfMemoryException` exceptions
* Removed requirement for .NET 3.5 thanks to a commit from
[dahmage](https://github.com/dahmage)
* Added `GetScaledRectangle` overloads using `Point` and `Size` (and the float
variant) parameters
### Fixed
* Calling `SelectAll` caused a crash if a backing image wasn't present (even if
`VirtualMode` was set)
## 1.1.4.1
### Fixed
* Removed unnecessary `UpdateStyles` calls
* Changed the `ViewSize` property and `DrawImage` methods to handle disposed
images rather than bringing down an entire application
* Added `TextFormatFlags.NoPadding` to the flags used by `DrawLabel` to avoid a
slight gap on left aligned text
* Fixed a potential crash calling `GetSelectedImage`. Thanks to MutStarburst for
finding this bug
## 1.1.4.0
### Added
* Added NuGet package
* Added a new `SizeMode` property. This allows you to switch between `Normal`,
`Fit` and `Stretch` modes. Stretch is a new mode for the `ImageBox`, and acts
similar to existing `Fit` functionality except the aspect ratio is not
preserved
* Added a license file to hopefully cut down on questions about usage. The
`ImageBox` control is licensed under the MIT license, allowing you free reign
to use it in your projects, commercial or otherwise. See `license.txt` for the
full text
* Added a new `CenterPoint` property. This property returns the pixel at the
center of the current image viewport
* Added a bunch of missing XML comments documentation.
* Added new overloads for most methods that accepted a source `Rectangle`,
`Point` or `Size` to also accept `float` and `int` arguments.
* Added a new `Zoomed` method that uses new `ImageBoxZoomEventArgs` arguments.
This new event allows you to tell if the zoom was in or out, how it was
raised, and current and previous zoom values. Not hugely thrilled with how
aspects of this change has been internally implemented, so implementation
methods are private rather than virtual so I can change them without affecting
the signature
* Added new `CenterToImage` method which resets the viewport to be centered of
the image, in the same way as zooming via the keyboard used to work.
* Added support for animated GIF's, thanks to a contribution from
[Eggy](https://github.com/teamalpha5441). Note animations only play at
runtime, not design time
* The `Text` and `Font` properties are now available and, if set, will be
displayed in the control. You can use the `ForeColor`, `TextBackColor`,
`TextAlign`, `TextDisplayMode` and `ScaleText` properties to determine how the
text will be rendered
* A new `DrawLabel` method that performs text drawing is available for use by
custom implementations or virtual modes
* Added a new *Scaled Adornments* demonstration, showing how easy it is to add
custom drawing that is scaled and positioned appropriately
* Added a new *Switch Image During Zoom* demonstration, a demo with an unwieldy
name that shows how to switch out a low resolution image with a higher
detailed one as you zoom into an `ImageBox`
* Added new *Text* and *Size Mode* demonstrations
### Fixed
* Zooming in and out with the keyboard now keeps the view centered to the same
pixel that was centered prior to the zoom
* Zooming in and out with the keyboard is now correctly disabled if the
`AllowZoom` property is `False`, or the `SizeMode` property is a value other
than `Normal`. This means keyboard behaviour now matches mouse behaviour
* If the mouse wheel was rapidly spun (thus having a multiple of the base
delta), the `Zoom` property was only adjusted once
* Setting the `GridScale` property to `None` rendered the default `Small` grid.
Using a scale of `None` now correctly just fills the grid area with a solid
brush from the `GridColor` property
* The `MouseWheel` event is now available
* Layout changes no longer occur if the `AllowPainting` property is `false`
through use of the `BeginUpdate` method
* Fixed various documentation errors
### Removed
* The `SizeToFit` property has been marked as deprecated and should no longer be
used. The `SizeMode` property has a `Fit` value that should be used instead.
Setting the `SizeToFit` property will now manipulate `SizeMode` instead
## 1.1.3.0
### Added
* Added new *DragTestForm* demo
* Added new `Tiny` setting for `ImageBoxGridScale` which is half the size of
`Small`
### Changed
* The `Selecting` event now uses `ImageBoxCancelEventArgs` in order to provide
further information
### Fixed
* If the `Selecting` event was cancelled, it would continue to be re-raised with
every movement of the mouse while the button was pressed. Now the event is
only raised once, and if cancelled will not be raised again until the button
is released and a new drag initiated
## 1.1.2.2
### Changed
* Changed `PixelGridThreshold` into an instance property, and changed default
value to `5`
## 1.1.2.1
### Added
* Added missing `GetOffsetRectangle` overload which supports `Rectangle`
structs
### Fixed
* The `ZoomToFit` method didn't support virtual mode and crashed if called
## 1.1.2.0
### Added
* Added `IsPointInImage` method. This function returns if a given point is
within the image viewport, and is useful for combining with `PointToImage`
* Added `ImageBorderColor` property, allowing you to customize the color of the
image border
* Added a new `ImageBoxBorderStyle`, `FixedSingleGlowShadow`. This style allows
for a more smoother outer glow shadow instead of the existing clunky drop
shadow
* Added `ShowPixelGrid` and `PixelGridColor` properties. When set, a dotted
grid is displayed around pixels when zooming in on an image
* Added new overload to `PointToImage` which allows you to specify if the
function should map the given point to the nearest available edge(s) if the
point is outside the image boundaries
* Added `AllowDoubleClick` property. When set, the normal double click events
and overrides work as expected
* Additional documentation added via XML comments
### Fixed
* If the `GridDisplayMode` property is set to `Image` an explicit image border
is no longer drawn, instead the `ImageBorder` property is correctly honoured
* Fixes a problem where half the pixels of the first row/column were lost when
zooming. Thanks to Rotem for the fix
* The `GetImageViewport` method now correctly returns a width and height that
accounts for control size, padding and zoom levels
* Fixed incorrect attributes on `AutoSize` property
* Fixes "see also" documentation errors for events
## 1.1.1.0
### Changed
* Added `VirtualMode` and `VirtualSize` properties. These new properties allow
you to use all functionality of the ImageBox control without having to set
the `Image` property. You can also use the new `VirtualDraw` event to provide
custom drawing without having to override existing drawing functionality
### Fixed
* Fixed the image viewport sometimes being the incorrect size when zoomed in.
Thanks to WMJ for the fix
## 1.1.0.0
### Added
* Added a `ZoomLevels` property which allows you to configure the different zoom
levels supported by the control. Now instead of the control trying to guess
the next zoom level, it cycles appropriately through the defined levels.
*Currently ZoomLevels (apart from the default series) can only be set at runtime*
* New `CenterAt` and `ScrollTo` methods allow you to scroll to a given location
in the source image
* Split shortcut handling into two methods `ProcessScrollingShortcuts` for
handling arrow keys and `ProcessImageShortcuts` for handling pretty much
anything else
* Added `EnableShortcuts` property, allowing the built in keyboard support to be
disabled. When this property is true, `ProcessImageShortcuts` is not called,
allowing the control to still be scrolled via the keyboard, but not zoomed etc
* Added a new `GetSelectedImage` method which creates a new `Bitmap` based on
the current selection
* Added new `FitRectangle` method which takes a given rectangle and ensure it
fits within the image boundaries
* Added a new `ZoomToRegion` method. This will caculate and appropriate zoom
level and scrollbar positions to fit a given rectangle
* Added new `SelectionMode.Zoom`. When this mode is selected, drawing a region
will automatically zoom and position the control to fit the region, after
which the region is automatically cleared
### Changed
* Zooming with the mouse is now smoother, and the control attempts to keep the
area under the mouse before the zoom in the same area after the zoon.
* The `ZoomIncrement` property has been removed due to the introduction of the
new zoom levels
* Zooming can now be performed by the -/+ keys (`OemMinus` and `Oemplus`)
* When zooming (except via mouse action), if the `AutoCenter` property is set,
the control will always center the image even when scrollbars are present
* Nestable `BeginUpdate` and `EndUpdate` methods allow you to disable and enable
painting of the control, for example when changing multiple properties at once
* The `AllowClickZoom` property now defaults to `false`
* The `PointToImage` function no longer adds +1 to the result of the function
### Fixed
* Panning no longer tries to activate if no scrollbars are visible
* A new base class, `VirtualScrollableControl` is now used instead of
`ScrollableControl`. This removes completely the flicker issues present in
previous versions of the control
* The BorderStyle property has been moved to the `ScrollControl` class, so that
borders now correctly surround the control (including scrollbars) rather than
just the client area
* If the `AllowZoomClick` property is `true`, the control no longer magically
zooms after panning or selecting a region. Code previously in the
`OnMouseClick` override is now in `OnMouseUp`
* If both `AutoPan` and a valid `SelectionMode` are set, only selections are
processed, instead of the control tying to do both. As a result of this fix,
setting the `SelectionMode` property no longer resets `AutoPan`
* With the introduction of the `VirtualScrollableControl`, the `MouseWheel`
event is now raised as expected
### Known issues
* The `ScrollProperties` class hasn't been fully integrated with the
`ScrollControl`, setting properties on this class won't update the owner control
## 1.0.0.5
* Initial GitHub release
================================================
FILE: Cyotek.Windows.Forms.ImageBox/Cyotek.Windows.Forms.ImageBox.csproj
================================================
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{4159C8D3-C18D-4BED-8BE6-9BAD1B0CA4F6}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Cyotek.Windows.Forms</RootNamespace>
<AssemblyName>Cyotek.Windows.Forms.ImageBox</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>
</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\Cyotek.Windows.Forms.ImageBox.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>cyopublic.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>
<Compile Include="ImageBox.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="ImageBoxMouseWheelMessageFilter.cs" />
<Compile Include="ImageBoxMouseWheelMode.cs" />
<Compile Include="ImageBoxPanMode.cs" />
<Compile Include="ImageBoxPanStyle.cs" />
<Compile Include="ImageBoxZoomActions.cs" />
<Compile Include="ImageBoxActionSources.cs" />
<Compile Include="ImageBoxBorderStyle.cs" />
<Compile Include="ImageBoxCancelEventArgs.cs" />
<Compile Include="ImageBoxZoomEventArgs.cs" />
<Compile Include="ImageBoxGridDisplayMode.cs" />
<Compile Include="ImageBoxGridScale.cs" />
<Compile Include="ImageBoxSelectionMode.cs" />
<Compile Include="ImageBoxNativeMethods.cs" />
<Compile Include="ImageBoxSizeMode.cs" />
<Compile Include="ImageBoxPanDirection.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ScrollControl.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="ScrollProperties.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="VirtualScrollableControl.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="ZoomLevelCollection.cs" />
<Service Include="{94E38DFF-614B-4cbd-B67C-F211BB35CE8B}" />
</ItemGroup>
<ItemGroup>
<None Include="cyopublic.snk" />
<None Include="Cyotek.Windows.Forms.ImageBox.nuspec" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="ImageBox.bmp" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="..\res\PanAll.cur">
<Link>PanAll.cur</Link>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="..\res\PanAllSymbol.png">
<Link>PanAllSymbol.png</Link>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
================================================
FILE: Cyotek.Windows.Forms.ImageBox/Cyotek.Windows.Forms.ImageBox.nuspec
================================================
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>CyotekImageBox</id>
<version>$version$-beta.1</version>
<title>Cyotek ImageBox Control</title>
<authors>Cyotek</authors>
<owners>Cyotek</owners>
<licenseUrl>https://raw.githubusercontent.com/cyotek/Cyotek.Windows.Forms.ImageBox/master/license.txt</licenseUrl>
<projectUrl>http://cyotek.com/blog/tag/imagebox</projectUrl>
<iconUrl>http://static.cyotek.com/files/packageicons/imagebox-32x32.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>The ImageBox is a custom control for displaying images. It supports zooming, scrolling, panning, region selection, virtual modes, and much more.</description>
<summary>The ImageBox is a custom control for displaying images with built in support for zooming, scrolling, panning, region selection, virtual modes, and much more.</summary>
<releaseNotes />
<copyright>$copyright$</copyright>
<language>en-GB</language>
<tags>image picturebox form control imagebox cyotek</tags>
<frameworkAssemblies>
<frameworkAssembly assemblyName="System.Windows.Forms" targetFramework="" />
<frameworkAssembly assemblyName="System.Drawing" targetFramework="" />
</frameworkAssemblies>
</metadata>
</package>
================================================
FILE: Cyotek.Windows.Forms.ImageBox/ImageBox.cs
================================================
// Cyotek ImageBox
// http://cyotek.com/blog/tag/imagebox
// Copyright (c) 2010-2021 Cyotek Ltd.
// This work is licensed under the MIT License.
// See LICENSE.TXT for the full text
// Found this code useful?
// https://www.cyotek.com/contribute
using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.IO;
using System.Windows.Forms;
namespace Cyotek.Windows.Forms
{
/// <summary>
/// Component for displaying images with support for scrolling and zooming.
/// </summary>
[DefaultProperty("Image")]
[ToolboxBitmap(typeof(ImageBox), "ImageBox.bmp")]
[ToolboxItem(true)]
/* [Designer("Cyotek.Windows.Forms.Design.ImageBoxDesigner", Cyotek.Windows.Forms.ImageBox.Design.dll, PublicKeyToken=58daa28b0b2de221")] */
public class ImageBox : VirtualScrollableControl
{
#region Constants
private static readonly object _eventAllowClickZoomChanged = new object();
private static readonly object _eventAllowDoubleClickChanged = new object();
private static readonly object _eventAllowFreePanChanged = new object();
private static readonly object _eventAllowUnfocusedMouseWheelChanged = new object();
private static readonly object _eventAllowZoomChanged = new object();
private static readonly object _eventAutoCenterChanged = new object();
private static readonly object _eventAutoPanChanged = new object();
private static readonly object _eventDropShadowSizeChanged = new object();
private static readonly object _eventGridCellSizeChanged = new object();
private static readonly object _eventGridColorAlternateChanged = new object();
private static readonly object _eventGridColorChanged = new object();
private static readonly object _eventGridDisplayModeChanged = new object();
private static readonly object _eventGridScaleChanged = new object();
private static readonly object _eventImageBorderColorChanged = new object();
private static readonly object _eventImageBorderStyleChanged = new object();
private static readonly object _eventImageChanged = new object();
private static readonly object _eventInterpolationModeChanged = new object();
private static readonly object _eventInvertMouseChanged = new object();
private static readonly object _eventLimitSelectionToImageChanged = new object();
private static readonly object _eventMouseWheelModeChanged = new object();
private static readonly object _eventPanEnd = new object();
private static readonly object _eventPanModeChanged = new object();
private static readonly object _eventPanStart = new object();
private static readonly object _eventPixelGridColorChanged = new object();
private static readonly object _eventPixelGridThresholdChanged = new object();
private static readonly object _eventScaleTextChanged = new object();
private static readonly object _eventSelected = new object();
private static readonly object _eventSelecting = new object();
private static readonly object _eventSelectionColorChanged = new object();
private static readonly object _eventSelectionModeChanged = new object();
private static readonly object _eventSelectionRegionChanged = new object();
private static readonly object _eventShortcutsEnabledChanged = new object();
private static readonly object _eventShowPixelGridChanged = new object();
private static readonly object _eventSizeModeChanged = new object();
private static readonly object _eventSizeToFitChanged = new object();
private static readonly object _eventTextAlignChanged = new object();
private static readonly object _eventTextBackColorChanged = new object();
private static readonly object _eventTextDisplayModeChanged = new object();
private static readonly object _eventTextPaddingChanged = new object();
private static readonly object _eventVirtualDraw = new object();
private static readonly object _eventVirtualModeChanged = new object();
private static readonly object _eventVirtualSizeChanged = new object();
private static readonly object _eventZoomChanged = new object();
private static readonly object _eventZoomed = new object();
private static readonly object _eventZoomLevelsChanged = new object();
private const int _freePanTimerInterval = 250;
private const int _panAllDeadSize = 32;
private const int MaxZoom = 3500;
private const int MinZoom = 1;
private const int SelectionDeadZone = 5;
#endregion
#region Fields
private bool _allowClickZoom;
private bool _allowDoubleClick;
private bool _allowFreePan;
private bool _allowUnfocusedMouseWheel;
private bool _allowZoom;
private bool _autoCenter;
private Cursor _currentCursor;
private int _dropShadowSize;
private Timer _freePanTimer;
private int _gridCellSize;
private Color _gridColor;
private Color _gridColorAlternate;
private ImageBoxGridDisplayMode _gridDisplayMode;
private ImageBoxGridScale _gridScale;
private Bitmap _gridTile;
private Image _image;
private Color _imageBorderColor;
private ImageBoxBorderStyle _imageBorderStyle;
private InterpolationMode _interpolationMode;
private bool _invertMouse;
private bool _limitSelectionToImage;
private double _mouseDownStart;
private ImageBoxMouseWheelMode _mouseWheelMode;
private ImageBoxPanMode _panMode;
private ImageBoxPanStyle _panStyle;
private Color _pixelGridColor;
private int _pixelGridThreshold;
private bool _scaleText;
private Color _selectionColor;
private ImageBoxSelectionMode _selectionMode;
private RectangleF _selectionRegion;
private bool _shortcutsEnabled;
private bool _showPixelGrid;
private ImageBoxSizeMode _sizeMode;
private Point _startMousePosition;
private Point _startScrollPosition;
private ContentAlignment _textAlign;
private Color _textBackColor;
private ImageBoxGridDisplayMode _textDisplayMode;
private Padding _textPadding;
private Brush _texture;
private int _updateCount;
private bool _virtualMode;
private Size _virtualSize;
private int _zoom;
private ZoomLevelCollection _zoomLevels;
private bool _isSelecting;
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="ImageBox" /> class.
/// </summary>
public ImageBox()
{
this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw, true);
this.SetStyle(ControlStyles.StandardDoubleClick, false);
// ReSharper disable DoNotCallOverridableMethodsInConstructor
this.BeginUpdate();
_panMode = ImageBoxPanMode.Both;
_allowFreePan = true;
this.WheelScrollsControl = false;
this.AllowZoom = true;
this.MouseWheelMode = ImageBoxMouseWheelMode.Zoom;
this.LimitSelectionToImage = true;
this.DropShadowSize = 3;
this.ImageBorderStyle = ImageBoxBorderStyle.None;
this.BackColor = Color.White;
this.AutoSize = false;
this.AutoScroll = true;
this.GridScale = ImageBoxGridScale.Small;
this.GridDisplayMode = ImageBoxGridDisplayMode.Client;
this.GridColor = Color.Gainsboro;
this.GridColorAlternate = Color.White;
this.GridCellSize = 8;
this.InterpolationMode = InterpolationMode.NearestNeighbor;
this.AutoCenter = true;
this.SelectionColor = SystemColors.Highlight;
this.ActualSize();
this.ShortcutsEnabled = true;
this.ZoomLevels = ZoomLevelCollection.Default;
this.ImageBorderColor = SystemColors.ControlDark;
this.PixelGridColor = Color.DimGray;
this.PixelGridThreshold = 5;
this.TextAlign = ContentAlignment.MiddleCenter;
this.TextBackColor = Color.Transparent;
this.TextDisplayMode = ImageBoxGridDisplayMode.Client;
this.EndUpdate();
// ReSharper restore DoNotCallOverridableMethodsInConstructor
}
#endregion
#region Events
/// <summary>
/// Occurs when the AllowClickZoom property is changed.
/// </summary>
[Category("Property Changed")]
public event EventHandler AllowClickZoomChanged
{
add { this.Events.AddHandler(_eventAllowClickZoomChanged, value); }
remove { this.Events.RemoveHandler(_eventAllowClickZoomChanged, value); }
}
/// <summary>
/// Occurs when the AllowDoubleClick property value changes
/// </summary>
[Category("Property Changed")]
public event EventHandler AllowDoubleClickChanged
{
add { this.Events.AddHandler(_eventAllowDoubleClickChanged, value); }
remove { this.Events.RemoveHandler(_eventAllowDoubleClickChanged, value); }
}
/// <summary>
/// Occurs when the AllowFreePan property value changes
/// </summary>
[Category("Property Changed")]
public event EventHandler AllowFreePanChanged
{
add { this.Events.AddHandler(_eventAllowFreePanChanged, value); }
remove { this.Events.RemoveHandler(_eventAllowFreePanChanged, value); }
}
/// <summary>
/// Occurs when the AllowUnfocusedMouseWheel property value changes
/// </summary>
[Category("Property Changed")]
public event EventHandler AllowUnfocusedMouseWheelChanged
{
add { this.Events.AddHandler(_eventAllowUnfocusedMouseWheelChanged, value); }
remove { this.Events.RemoveHandler(_eventAllowUnfocusedMouseWheelChanged, value); }
}
/// <summary>
/// Occurs when the AllowZoom property is changed.
/// </summary>
[Category("Property Changed")]
public event EventHandler AllowZoomChanged
{
add { this.Events.AddHandler(_eventAllowZoomChanged, value); }
remove { this.Events.RemoveHandler(_eventAllowZoomChanged, value); }
}
/// <summary>
/// Occurs when the AutoCenter property is changed.
/// </summary>
[Category("Property Changed")]
public event EventHandler AutoCenterChanged
{
add { this.Events.AddHandler(_eventAutoCenterChanged, value); }
remove { this.Events.RemoveHandler(_eventAutoCenterChanged, value); }
}
/// <summary>
/// Occurs when the AutoPan property is changed.
/// </summary>
[Category("Property Changed")]
public event EventHandler AutoPanChanged
{
add { this.Events.AddHandler(_eventAutoPanChanged, value); }
remove { this.Events.RemoveHandler(_eventAutoPanChanged, value); }
}
/// <summary>
/// Occurs when the DropShadowSize property is changed.
/// </summary>
[Category("Property Changed")]
public event EventHandler DropShadowSizeChanged
{
add { this.Events.AddHandler(_eventDropShadowSizeChanged, value); }
remove { this.Events.RemoveHandler(_eventDropShadowSizeChanged, value); }
}
/// <summary>
/// Occurs when the GridSizeCell property is changed.
/// </summary>
[Category("Property Changed")]
public event EventHandler GridCellSizeChanged
{
add { this.Events.AddHandler(_eventGridCellSizeChanged, value); }
remove { this.Events.RemoveHandler(_eventGridCellSizeChanged, value); }
}
/// <summary>
/// Occurs when the GridColorAlternate property is changed.
/// </summary>
[Category("Property Changed")]
public event EventHandler GridColorAlternateChanged
{
add { this.Events.AddHandler(_eventGridColorAlternateChanged, value); }
remove { this.Events.RemoveHandler(_eventGridColorAlternateChanged, value); }
}
/// <summary>
/// Occurs when the GridColor property is changed.
/// </summary>
[Category("Property Changed")]
public event EventHandler GridColorChanged
{
add { this.Events.AddHandler(_eventGridColorChanged, value); }
remove { this.Events.RemoveHandler(_eventGridColorChanged, value); }
}
/// <summary>
/// Occurs when the GridDisplayMode property is changed.
/// </summary>
[Category("Property Changed")]
public event EventHandler GridDisplayModeChanged
{
add { this.Events.AddHandler(_eventGridDisplayModeChanged, value); }
remove { this.Events.RemoveHandler(_eventGridDisplayModeChanged, value); }
}
/// <summary>
/// Occurs when the GridScale property is changed.
/// </summary>
[Category("Property Changed")]
public event EventHandler GridScaleChanged
{
add { this.Events.AddHandler(_eventGridScaleChanged, value); }
remove { this.Events.RemoveHandler(_eventGridScaleChanged, value); }
}
/// <summary>
/// Occurs when the ImageBorderColor property value changes
/// </summary>
[Category("Property Changed")]
public event EventHandler ImageBorderColorChanged
{
add { this.Events.AddHandler(_eventImageBorderColorChanged, value); }
remove { this.Events.RemoveHandler(_eventImageBorderColorChanged, value); }
}
/// <summary>
/// Occurs when the ImageBorderStyle property is changed.
/// </summary>
[Category("Property Changed")]
public event EventHandler ImageBorderStyleChanged
{
add { this.Events.AddHandler(_eventImageBorderStyleChanged, value); }
remove { this.Events.RemoveHandler(_eventImageBorderStyleChanged, value); }
}
/// <summary>
/// Occurs when the Image property is changed.
/// </summary>
[Category("Property Changed")]
public event EventHandler ImageChanged
{
add { this.Events.AddHandler(_eventImageChanged, value); }
remove { this.Events.RemoveHandler(_eventImageChanged, value); }
}
/// <summary>
/// Occurs when the InterpolationMode property is changed.
/// </summary>
[Category("Property Changed")]
public event EventHandler InterpolationModeChanged
{
add { this.Events.AddHandler(_eventInterpolationModeChanged, value); }
remove { this.Events.RemoveHandler(_eventInterpolationModeChanged, value); }
}
/// <summary>
/// Occurs when the InvertMouse property is changed.
/// </summary>
[Category("Property Changed")]
public event EventHandler InvertMouseChanged
{
add { this.Events.AddHandler(_eventInvertMouseChanged, value); }
remove { this.Events.RemoveHandler(_eventInvertMouseChanged, value); }
}
/// <summary>
/// Occurs when the LimitSelectionToImage property is changed.
/// </summary>
[Category("Property Changed")]
public event EventHandler LimitSelectionToImageChanged
{
add { this.Events.AddHandler(_eventLimitSelectionToImageChanged, value); }
remove { this.Events.RemoveHandler(_eventLimitSelectionToImageChanged, value); }
}
/// <summary>
/// Occurs when the MouseWheelMode property value changes
/// </summary>
[Category("Property Changed")]
public event EventHandler MouseWheelModeChanged
{
add { this.Events.AddHandler(_eventMouseWheelModeChanged, value); }
remove { this.Events.RemoveHandler(_eventMouseWheelModeChanged, value); }
}
/// <summary>
/// Occurs when panning the control completes.
/// </summary>
[Category("Action")]
public event EventHandler PanEnd
{
add { this.Events.AddHandler(_eventPanEnd, value); }
remove { this.Events.RemoveHandler(_eventPanEnd, value); }
}
/// <summary>
/// Occurs when the PanMode property value changes
/// </summary>
[Category("Property Changed")]
public event EventHandler PanModeChanged
{
add { this.Events.AddHandler(_eventPanModeChanged, value); }
remove { this.Events.RemoveHandler(_eventPanModeChanged, value); }
}
/// <summary>
/// Occurs when panning the control starts.
/// </summary>
[Category("Action")]
public event EventHandler PanStart
{
add { this.Events.AddHandler(_eventPanStart, value); }
remove { this.Events.RemoveHandler(_eventPanStart, value); }
}
/// <summary>
/// Occurs when the PixelGridColor property value changes
/// </summary>
[Category("Property Changed")]
public event EventHandler PixelGridColorChanged
{
add { this.Events.AddHandler(_eventPixelGridColorChanged, value); }
remove { this.Events.RemoveHandler(_eventPixelGridColorChanged, value); }
}
/// <summary>
/// Occurs when the PixelGridThreshold property value changes
/// </summary>
[Category("Property Changed")]
public event EventHandler PixelGridThresholdChanged
{
add { this.Events.AddHandler(_eventPixelGridThresholdChanged, value); }
remove { this.Events.RemoveHandler(_eventPixelGridThresholdChanged, value); }
}
/// <summary>
/// Occurs when the ScaleText property value changes
/// </summary>
[Category("Property Changed")]
public event EventHandler ScaleTextChanged
{
add { this.Events.AddHandler(_eventScaleTextChanged, value); }
remove { this.Events.RemoveHandler(_eventScaleTextChanged, value); }
}
/// <summary>
/// Occurs when a selection region has been defined
/// </summary>
[Category("Action")]
public event EventHandler<EventArgs> Selected
{
// TODO: The event signature is wrong and should just be EventHandler - breaking change however. Do in the 2.0 scroll changes branch.
add { this.Events.AddHandler(_eventSelected, value); }
remove { this.Events.RemoveHandler(_eventSelected, value); }
}
/// <summary>
/// Occurs when the user starts to define a selection region.
/// </summary>
[Category("Action")]
public event EventHandler<ImageBoxCancelEventArgs> Selecting
{
add { this.Events.AddHandler(_eventSelecting, value); }
remove { this.Events.RemoveHandler(_eventSelecting, value); }
}
/// <summary>
/// Occurs when the SelectionColor property is changed.
/// </summary>
[Category("Property Changed")]
public event EventHandler SelectionColorChanged
{
add { this.Events.AddHandler(_eventSelectionColorChanged, value); }
remove { this.Events.RemoveHandler(_eventSelectionColorChanged, value); }
}
/// <summary>
/// Occurs when the SelectionMode property is changed.
/// </summary>
[Category("Property Changed")]
public event EventHandler SelectionModeChanged
{
add { this.Events.AddHandler(_eventSelectionModeChanged, value); }
remove { this.Events.RemoveHandler(_eventSelectionModeChanged, value); }
}
/// <summary>
/// Occurs when the SelectionRegion property is changed.
/// </summary>
[Category("Property Changed")]
public event EventHandler SelectionRegionChanged
{
add { this.Events.AddHandler(_eventSelectionRegionChanged, value); }
remove { this.Events.RemoveHandler(_eventSelectionRegionChanged, value); }
}
/// <summary>
/// Occurs when the ShortcutsEnabled property value changes
/// </summary>
[Category("Property Changed")]
public event EventHandler ShortcutsEnabledChanged
{
add { this.Events.AddHandler(_eventShortcutsEnabledChanged, value); }
remove { this.Events.RemoveHandler(_eventShortcutsEnabledChanged, value); }
}
/// <summary>
/// Occurs when the ShowPixelGrid property value changes
/// </summary>
[Category("Property Changed")]
public event EventHandler ShowPixelGridChanged
{
add { this.Events.AddHandler(_eventShowPixelGridChanged, value); }
remove { this.Events.RemoveHandler(_eventShowPixelGridChanged, value); }
}
/// <summary>
/// Occurs when the SizeMode property value changes
/// </summary>
[Category("Property Changed")]
public event EventHandler SizeModeChanged
{
add { this.Events.AddHandler(_eventSizeModeChanged, value); }
remove { this.Events.RemoveHandler(_eventSizeModeChanged, value); }
}
/// <summary>
/// Occurs when the SizeToFit property is changed.
/// </summary>
[Category("Property Changed")]
public event EventHandler SizeToFitChanged
{
add { this.Events.AddHandler(_eventSizeToFitChanged, value); }
remove { this.Events.RemoveHandler(_eventSizeToFitChanged, value); }
}
/// <summary>
/// Occurs when the TextAlign property value changes
/// </summary>
[Category("Property Changed")]
public event EventHandler TextAlignChanged
{
add { this.Events.AddHandler(_eventTextAlignChanged, value); }
remove { this.Events.RemoveHandler(_eventTextAlignChanged, value); }
}
/// <summary>
/// Occurs when the TextBackColor property value changes
/// </summary>
[Category("Property Changed")]
public event EventHandler TextBackColorChanged
{
add { this.Events.AddHandler(_eventTextBackColorChanged, value); }
remove { this.Events.RemoveHandler(_eventTextBackColorChanged, value); }
}
/// <summary>
/// Occurs when the TextDisplayMode property value changes
/// </summary>
[Category("Property Changed")]
public event EventHandler TextDisplayModeChanged
{
add { this.Events.AddHandler(_eventTextDisplayModeChanged, value); }
remove { this.Events.RemoveHandler(_eventTextDisplayModeChanged, value); }
}
/// <summary>
/// Occurs when the TextPadding property value changes
/// </summary>
[Category("Property Changed")]
public event EventHandler TextPaddingChanged
{
add { this.Events.AddHandler(_eventTextPaddingChanged, value); }
remove { this.Events.RemoveHandler(_eventTextPaddingChanged, value); }
}
/// <summary>
/// Occurs when virtual painting should occur
/// </summary>
[Category("Appearance")]
public event PaintEventHandler VirtualDraw
{
add { this.Events.AddHandler(_eventVirtualDraw, value); }
remove { this.Events.RemoveHandler(_eventVirtualDraw, value); }
}
/// <summary>
/// Occurs when the VirtualMode property value changes
/// </summary>
[Category("Property Changed")]
public event EventHandler VirtualModeChanged
{
add { this.Events.AddHandler(_eventVirtualModeChanged, value); }
remove { this.Events.RemoveHandler(_eventVirtualModeChanged, value); }
}
/// <summary>
/// Occurs when the VirtualSize property value changes
/// </summary>
[Category("Property Changed")]
public event EventHandler VirtualSizeChanged
{
add { this.Events.AddHandler(_eventVirtualSizeChanged, value); }
remove { this.Events.RemoveHandler(_eventVirtualSizeChanged, value); }
}
/// <summary>
/// Occurs when the Zoom property is changed.
/// </summary>
[Category("Property Changed")]
public event EventHandler ZoomChanged
{
add { this.Events.AddHandler(_eventZoomChanged, value); }
remove { this.Events.RemoveHandler(_eventZoomChanged, value); }
}
/// <summary>
/// Occurs when then a zoom action is performed.
/// </summary>
[Category("Action")]
public event EventHandler<ImageBoxZoomEventArgs> Zoomed
{
add { this.Events.AddHandler(_eventZoomed, value); }
remove { this.Events.RemoveHandler(_eventZoomed, value); }
}
/// <summary>
/// Occurs when the ZoomLevels property is changed
/// </summary>
[Category("Property Changed")]
public event EventHandler ZoomLevelsChanged
{
add { this.Events.AddHandler(_eventZoomLevelsChanged, value); }
remove { this.Events.RemoveHandler(_eventZoomLevelsChanged, value); }
}
#endregion
#region Static Methods
/// <summary>
/// Creates a bitmap image containing a 2x2 grid using the specified cell size and colors.
/// </summary>
/// <param name="cellSize">Size of the cell.</param>
/// <param name="cellColor">Cell color.</param>
/// <param name="alternateCellColor">Alternate cell color.</param>
/// <returns></returns>
public static Bitmap CreateCheckerBoxTile(int cellSize, Color cellColor, Color alternateCellColor)
{
Bitmap result;
int width;
int height;
// draw the tile
width = cellSize * 2;
height = cellSize * 2;
result = new Bitmap(width, height);
using (Graphics g = Graphics.FromImage(result))
{
using (Brush brush = new SolidBrush(cellColor))
{
g.FillRectangle(brush, new Rectangle(cellSize, 0, cellSize, cellSize));
g.FillRectangle(brush, new Rectangle(0, cellSize, cellSize, cellSize));
}
using (Brush brush = new SolidBrush(alternateCellColor))
{
g.FillRectangle(brush, new Rectangle(0, 0, cellSize, cellSize));
g.FillRectangle(brush, new Rectangle(cellSize, cellSize, cellSize, cellSize));
}
}
return result;
}
/// <summary>
/// Creates a checked tile texture using default values.
/// </summary>
/// <returns></returns>
public static Bitmap CreateCheckerBoxTile()
{
return CreateCheckerBoxTile(8, Color.Gainsboro, Color.WhiteSmoke);
}
private static Cursor GetPanAllCursor()
{
Type type;
type = typeof(ImageBox);
return new Cursor(type.Assembly.GetManifestResourceStream(type.Namespace + ".PanAll.cur"));
}
private static Bitmap GetPanAllSymbol()
{
Type type;
type = typeof(ImageBox);
using (Stream stream = type.Assembly.GetManifestResourceStream(type.Namespace + ".PanAllSymbol.png"))
{
return new Bitmap(stream);
}
}
private static void LoadPanResources()
{
if (_panAllCursor == null)
{
_panAllCursor = GetPanAllCursor();
}
if (_panAllSymbol == null)
{
_panAllSymbol = GetPanAllSymbol();
}
}
#endregion
#region Properties
/// <summary>
/// Gets or sets a value indicating whether clicking the control with the mouse will automatically zoom in or out.
/// </summary>
/// <value>
/// <c>true</c> if clicking the control allows zooming; otherwise, <c>false</c>.
/// </value>
[DefaultValue(false)]
[Category("Behavior")]
public virtual bool AllowClickZoom
{
get { return _allowClickZoom; }
set
{
if (_allowClickZoom != value)
{
_allowClickZoom = value;
this.OnAllowClickZoomChanged(EventArgs.Empty);
}
}
}
/// <summary>
/// Gets or sets a value indicating whether the DoubleClick event can be raised.
/// </summary>
/// <value><c>true</c> if the DoubleClick event can be raised; otherwise, <c>false</c>.</value>
[Category("Behavior")]
[DefaultValue(false)]
public virtual bool AllowDoubleClick
{
get { return _allowDoubleClick; }
set
{
if (this.AllowDoubleClick != value)
{
_allowDoubleClick = value;
this.OnAllowDoubleClickChanged(EventArgs.Empty);
}
}
}
/// <summary>
/// Gets or sets a value indicating whether free panning can be used
/// </summary>
/// <value>
/// <c>true</c> if free panning can be used, otherwise <c>false</c>.
/// </value>
[Category("Behavior")]
[DefaultValue(true)]
public virtual bool AllowFreePan
{
get { return _allowFreePan; }
set
{
if (_allowFreePan != value)
{
_allowFreePan = value;
this.OnAllowFreePanChanged(EventArgs.Empty);
}
}
}
/// <summary>
/// Gets or sets a value indicating whether the mouse wheel is processed event if the <see cref="ImageBox"/> doesn't have focus.
/// </summary>
/// <value>
/// <c>true</c> if the mouse wheel is processed regardless of focus, otherwise <c>false</c> to only process the mouse wheel when the control has focus.
/// </value>
/// <remarks>Setting this problem to <c>true</c> could cause conflicting behavior with other controls that also make use of the mouse wheel.</remarks>
[Category("Behavior")]
[DefaultValue(false)]
public virtual bool AllowUnfocusedMouseWheel
{
get { return _allowUnfocusedMouseWheel; }
set
{
if (this.AllowUnfocusedMouseWheel != value)
{
_allowUnfocusedMouseWheel = value;
this.OnAllowUnfocusedMouseWheelChanged(EventArgs.Empty);
}
}
}
/// <summary>
/// Gets or sets a value indicating whether the user can change the zoom level.
/// </summary>
/// <value>
/// <c>true</c> if the zoom level can be changed; otherwise, <c>false</c>.
/// </value>
[Category("Behavior")]
[DefaultValue(true)]
public virtual bool AllowZoom
{
get { return _allowZoom; }
set
{
if (this.AllowZoom != value)
{
_allowZoom = value;
this.OnAllowZoomChanged(EventArgs.Empty);
}
}
}
/// <summary>
/// Gets or sets a value indicating whether the image is centered where possible.
/// </summary>
/// <value>
/// <c>true</c> if the image should be centered where possible; otherwise, <c>false</c>.
/// </value>
[DefaultValue(true)]
[Category("Appearance")]
public virtual bool AutoCenter
{
get { return _autoCenter; }
set
{
if (_autoCenter != value)
{
_autoCenter = value;
this.OnAutoCenterChanged(EventArgs.Empty);
}
}
}
/// <summary>
/// Gets or sets if the mouse can be used to pan the control.
/// </summary>
/// <value>
/// <c>true</c> if the control can be auto panned; otherwise, <c>false</c>.
/// </value>
/// <remarks>If this property is set, the SizeToFit property cannot be used.</remarks>
[DefaultValue(true)]
[Category("Behavior")]
[Obsolete("Use the PanMode property instead", false)]
//[Browsable(false)]
public virtual bool AutoPan
{
get { return (_panMode & ImageBoxPanMode.Left) != 0; }
set
{
if (this.AutoPan != value)
{
this.PanMode = value ? _panMode & ImageBoxPanMode.Left : _panMode & ~ImageBoxPanMode.Left;
this.OnAutoPanChanged(EventArgs.Empty);
}
}
}
/// <summary>
/// Gets or sets a value indicating whether the container enables the user to scroll to any content placed outside of its visible boundaries.
/// </summary>
/// <value>
/// <c>true</c> if the container enables auto-scrolling; otherwise, <c>false</c>.
/// </value>
[DefaultValue(true)]
public override bool AutoScroll
{
get { return base.AutoScroll; }
set { base.AutoScroll = value; }
}
/// <summary>
/// Gets or sets the minimum size of the auto-scroll.
/// </summary>
/// <value></value>
/// <returns>
/// A <see cref="T:System.Drawing.Size" /> that determines the minimum size of the virtual area through which the user can scroll.
/// </returns>
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public new Size AutoScrollMinSize
{
get { return base.AutoScrollMinSize; }
set { base.AutoScrollMinSize = value; }
}
/// <summary>
/// Specifies if the control should auto size to fit the image contents.
/// </summary>
/// <value></value>
/// <returns>
/// <c>true</c> if enabled; otherwise, <c>false</c>
/// </returns>
[Browsable(true)]
[EditorBrowsable(EditorBrowsableState.Always)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
[DefaultValue(false)]
public override bool AutoSize
{
get { return base.AutoSize; }
set
{
if (base.AutoSize != value)
{
base.AutoSize = value;
this.AdjustLayout();
}
}
}
/// <summary>
/// Gets or sets the background color for the control.
/// </summary>
/// <value></value>
/// <returns>
/// A <see cref="T:System.Drawing.Color" /> that represents the background color of the control. The default is the value of the
/// <see
/// cref="P:System.Windows.Forms.Control.DefaultBackColor" />
/// property.
/// </returns>
[DefaultValue(typeof(Color), "White")]
public override Color BackColor
{
get { return base.BackColor; }
set { base.BackColor = value; }
}
/// <summary>
/// Gets or sets the background image displayed in the control.
/// </summary>
/// <value></value>
/// <returns>
/// An <see cref="T:System.Drawing.Image" /> that represents the image to display in the background of the control.
/// </returns>
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public override Image BackgroundImage
{
get { return base.BackgroundImage; }
set { base.BackgroundImage = value; }
}
/// <summary>
/// Gets or sets the background image layout as defined in the <see cref="T:System.Windows.Forms.ImageLayout" /> enumeration.
/// </summary>
/// <value>The background image layout.</value>
/// <returns>
/// One of the values of <see cref="T:System.Windows.Forms.ImageLayout" /> (
/// <see
/// cref="F:System.Windows.Forms.ImageLayout.Center" />
/// , <see cref="F:System.Windows.Forms.ImageLayout.None" />,
/// <see
/// cref="F:System.Windows.Forms.ImageLayout.Stretch" />
/// , <see cref="F:System.Windows.Forms.ImageLayout.Tile" />, or
/// <see
/// cref="F:System.Windows.Forms.ImageLayout.Zoom" />
/// ). <see cref="F:System.Windows.Forms.ImageLayout.Tile" /> is the default value.
/// </returns>
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public override ImageLayout BackgroundImageLayout
{
get { return base.BackgroundImageLayout; }
set { base.BackgroundImageLayout = value; }
}
/// <summary>
/// Gets the point at the center of the currently displayed image viewport.
/// </summary>
/// <value>The point at the center of the current image viewport.</value>
[Browsable(false)]
public Point CenterPoint
{
get
{
Rectangle viewport;
viewport = this.GetImageViewPort();
return new Point(viewport.Width / 2, viewport.Height / 2);
}
}
/// <summary>
/// Gets or sets the cursor that is displayed when the mouse pointer is over the control.
/// </summary>
/// <value>
/// A <see cref="T:System.Windows.Forms.Cursor" /> that represents the cursor to display when the
/// mouse pointer is over the control.
/// </value>
/// <seealso cref="P:System.Windows.Forms.Control.Cursor"/>
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public override Cursor Cursor
{
get { return base.Cursor; }
set { base.Cursor = value; }
}
/// <summary>
/// Gets or sets the size of the drop shadow.
/// </summary>
/// <value>The size of the drop shadow.</value>
[Category("Appearance")]
[DefaultValue(3)]
public virtual int DropShadowSize
{
get { return _dropShadowSize; }
set
{
if (this.DropShadowSize != value)
{
_dropShadowSize = value;
this.OnDropShadowSizeChanged(EventArgs.Empty);
}
}
}
/// <summary>
/// Gets or sets the size of the grid cells.
/// </summary>
/// <value>The size of the grid cells.</value>
[Category("Appearance")]
[DefaultValue(8)]
public virtual int GridCellSize
{
get { return _gridCellSize; }
set
{
if (_gridCellSize != value)
{
_gridCellSize = value;
this.OnGridCellSizeChanged(EventArgs.Empty);
}
}
}
/// <summary>
/// Gets or sets the color of primary cells in the grid.
/// </summary>
/// <value>The color of primary cells in the grid.</value>
[Category("Appearance")]
[DefaultValue(typeof(Color), "Gainsboro")]
public virtual Color GridColor
{
get { return _gridColor; }
set
{
if (_gridColor != value)
{
_gridColor = value;
this.OnGridColorChanged(EventArgs.Empty);
}
}
}
/// <summary>
/// Gets or sets the color of alternate cells in the grid.
/// </summary>
/// <value>The color of alternate cells in the grid.</value>
[Category("Appearance")]
[DefaultValue(typeof(Color), "White")]
public virtual Color GridColorAlternate
{
get { return _gridColorAlternate; }
set
{
if (_gridColorAlternate != value)
{
_gridColorAlternate = value;
this.OnGridColorAlternateChanged(EventArgs.Empty);
}
}
}
/// <summary>
/// Gets or sets the grid display mode.
/// </summary>
/// <value>The grid display mode.</value>
[DefaultValue(ImageBoxGridDisplayMode.Client)]
[Category("Appearance")]
public virtual ImageBoxGridDisplayMode GridDisplayMode
{
get { return _gridDisplayMode; }
set
{
if (_gridDisplayMode != value)
{
_gridDisplayMode = value;
this.OnGridDisplayModeChanged(EventArgs.Empty);
}
}
}
/// <summary>
/// Gets or sets the grid scale.
/// </summary>
/// <value>The grid scale.</value>
[DefaultValue(typeof(ImageBoxGridScale), "Small")]
[Category("Appearance")]
public virtual ImageBoxGridScale GridScale
{
get { return _gridScale; }
set
{
if (_gridScale != value)
{
_gridScale = value;
this.OnGridScaleChanged(EventArgs.Empty);
}
}
}
/// <summary>
/// Gets or sets the image.
/// </summary>
/// <value>The image.</value>
[Category("Appearance")]
[DefaultValue(null)]
public virtual Image Image
{
get { return _image; }
set
{
if (_image != value)
{
// disable animations
if (this.IsAnimating)
{
ImageAnimator.StopAnimate(this.Image, this.OnFrameChangedHandler);
}
_image = value;
this.OnImageChanged(EventArgs.Empty);
}
}
}
/// <summary>
/// Gets or sets the color of the image border.
/// </summary>
/// <value>The color of the image border.</value>
[Category("Appearance")]
[DefaultValue(typeof(Color), "ControlDark")]
public virtual Color ImageBorderColor
{
get { return _imageBorderColor; }
set
{
if (this.ImageBorderColor != value)
{
_imageBorderColor = value;
this.OnImageBorderColorChanged(EventArgs.Empty);
}
}
}
/// <summary>
/// Gets or sets the image border style.
/// </summary>
/// <value>The image border style.</value>
[Category("Appearance")]
[DefaultValue(typeof(ImageBoxBorderStyle), "None")]
public virtual ImageBoxBorderStyle ImageBorderStyle
{
get { return _imageBorderStyle; }
set
{
if (this.ImageBorderStyle != value)
{
_imageBorderStyle = value;
this.OnImageBorderStyleChanged(EventArgs.Empty);
}
}
}
/// <summary>
/// Gets or sets the interpolation mode.
/// </summary>
/// <value>The interpolation mode.</value>
[Category("Appearance")]
[DefaultValue(InterpolationMode.NearestNeighbor)]
public virtual InterpolationMode InterpolationMode
{
get { return _interpolationMode; }
set
{
if (value == InterpolationMode.Invalid)
{
value = InterpolationMode.Default;
}
if (_interpolationMode != value)
{
_interpolationMode = value;
this.OnInterpolationModeChanged(EventArgs.Empty);
}
}
}
/// <summary>
/// Gets or sets a value indicating whether the mouse should be inverted when panning the control.
/// </summary>
/// <value>
/// <c>true</c> if the mouse should be inverted when panning the control; otherwise, <c>false</c>.
/// </value>
[DefaultValue(false)]
[Category("Behavior")]
public virtual bool InvertMouse
{
get { return _invertMouse; }
set
{
if (_invertMouse != value)
{
_invertMouse = value;
this.OnInvertMouseChanged(EventArgs.Empty);
}
}
}
/// <summary>
/// Gets a value indicating whether the image is currently being displayed at 100% zoom
/// </summary>
/// <value><c>true</c> if the image is currently being displayed at 100% zoom; otherwise, <c>false</c>.</value>
[Browsable(false)]
public virtual bool IsActualSize
{
get { return this.Zoom == 100; }
}
/// <summary>
/// Gets a value indicating whether this control is panning.
/// </summary>
/// <value>
/// <c>true</c> if this control is panning; otherwise, <c>false</c>.
/// </value>
[DefaultValue(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[Browsable(false)]
public virtual bool IsPanning
{
get { return _panStyle != ImageBoxPanStyle.None; }
protected set { this.ProcessPanEvents(value ? ImageBoxPanStyle.Standard : ImageBoxPanStyle.None); }
}
/// <summary>
/// Gets or sets a value indicating whether this a selection region is currently being drawn.
/// </summary>
/// <value>
/// <c>true</c> if a selection region is currently being drawn; otherwise, <c>false</c>.
/// </value>
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public virtual bool IsSelecting
{
get
{
return _isSelecting;
}
protected set
{
_isSelecting = value;
}
}
/// <summary>
/// Gets or sets a value indicating whether selection regions should be limited to the image boundaries.
/// </summary>
/// <value>
/// <c>true</c> if selection regions should be limited to image boundaries; otherwise, <c>false</c>.
/// </value>
[Category("Behavior")]
[DefaultValue(true)]
public virtual bool LimitSelectionToImage
{
get { return _limitSelectionToImage; }
set
{
if (this.LimitSelectionToImage != value)
{
_limitSelectionToImage = value;
this.OnLimitSelectionToImageChanged(EventArgs.Empty);
}
}
}
/// <summary>
/// Gets or sets the how the mouse wheel is handled
/// </summary>
/// <value>
/// The mouse wheel mode.
/// </value>
[Category("Behavior")]
[DefaultValue(typeof(ImageBoxMouseWheelMode), "Zoom")]
public virtual ImageBoxMouseWheelMode MouseWheelMode
{
get { return _mouseWheelMode; }
set
{
if (_mouseWheelMode != value)
{
_mouseWheelMode = value;
this.OnMouseWheelModeChanged(EventArgs.Empty);
}
}
}
/// <summary>
/// Gets or sets the how panning is initiated using the mouse
/// </summary>
/// <value>
/// The pan mode.
/// </value>
[Category("Behavior")]
[DefaultValue(typeof(ImageBoxPanMode), "Both")]
public virtual ImageBoxPanMode PanMode
{
get { return _panMode; }
set
{
if (_panMode != value)
{
_panMode = value;
this.OnPanModeChanged(EventArgs.Empty);
}
}
}
/// <summary>
/// Gets or sets the color of the pixel grid.
/// </summary>
/// <value>The color of the pixel grid.</value>
[Category("Appearance")]
[DefaultValue(typeof(Color), "DimGray")]
public virtual Color PixelGridColor
{
get { return _pixelGridColor; }
set
{
if (this.PixelGridColor != value)
{
_pixelGridColor = value;
this.OnPixelGridColorChanged(EventArgs.Empty);
}
}
}
/// <summary>
/// Gets or sets the minimum size of zoomed pixel's before the pixel grid will be drawn
/// </summary>
/// <value>The pixel grid threshold.</value>
[Category("Behavior")]
[DefaultValue(5)]
public virtual int PixelGridThreshold
{
get { return _pixelGridThreshold; }
set
{
if (this.PixelGridThreshold != value)
{
_pixelGridThreshold = value;
this.OnPixelGridThresholdChanged(EventArgs.Empty);
}
}
}
/// <summary>
/// Gets or sets a value indicating whether the font size of text is scaled according to the current zoom level.
/// </summary>
/// <value><c>true</c> if the size of text is scaled according to the current zoom level; otherwise, <c>false</c>.</value>
[Category("Appearance")]
[DefaultValue(false)]
public virtual bool ScaleText
{
get { return _scaleText; }
set
{
if (this.ScaleText != value)
{
_scaleText = value;
this.OnScaleTextChanged(EventArgs.Empty);
}
}
}
/// <summary>
/// Gets or sets the color of selection regions.
/// </summary>
/// <value>
/// The color of selection regions.
/// </value>
[Category("Appearance")]
[DefaultValue(typeof(Color), "Highlight")]
public virtual Color SelectionColor
{
get { return _selectionColor; }
set
{
if (this.SelectionColor != value)
{
_selectionColor = value;
this.OnSelectionColorChanged(EventArgs.Empty);
}
}
}
/// <summary>
/// Gets or sets the selection mode.
/// </summary>
/// <value>
/// The selection mode.
/// </value>
[Category("Behavior")]
[DefaultValue(typeof(ImageBoxSelectionMode), "None")]
public virtual ImageBoxSelectionMode SelectionMode
{
get { return _selectionMode; }
set
{
if (this.SelectionMode != value)
{
_selectionMode = value;
this.OnSelectionModeChanged(EventArgs.Empty);
}
}
}
/// <summary>
/// Gets or sets the selection region.
/// </summary>
/// <value>
/// The selection region.
/// </value>
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public virtual RectangleF SelectionRegion
{
get { return _selectionRegion; }
set
{
if (this.SelectionRegion != value)
{
_selectionRegion = value;
this.OnSelectionRegionChanged(EventArgs.Empty);
}
}
}
/// <summary>
/// Gets or sets a value indicating whether the defined shortcuts are enabled.
/// </summary>
/// <value>
/// <c>true</c> to enable the shortcuts; otherwise, <c>false</c>.
/// </value>
[Category("Behavior")]
[DefaultValue(true)]
public virtual bool ShortcutsEnabled
{
get { return _shortcutsEnabled; }
set
{
if (this.ShortcutsEnabled != value)
{
_shortcutsEnabled = value;
this.OnShortcutsEnabledChanged(EventArgs.Empty);
}
}
}
/// <summary>
/// Gets or sets a value indicating whether a pixel grid is displayed when the control is zoomed.
/// </summary>
/// <value><c>true</c> if a pixel grid is displayed when the control is zoomed; otherwise, <c>false</c>.</value>
[Category("Appearance")]
[DefaultValue(false)]
public virtual bool ShowPixelGrid
{
get { return _showPixelGrid; }
set
{
if (this.ShowPixelGrid != value)
{
_showPixelGrid = value;
this.OnShowPixelGridChanged(EventArgs.Empty);
}
}
}
/// <summary>
/// Gets or sets the size mode of images hosted in the control.
/// </summary>
/// <value>The size mode.</value>
[Category("Behavior")]
[DefaultValue(typeof(ImageBoxSizeMode), "Normal")]
public virtual ImageBoxSizeMode SizeMode
{
get { return _sizeMode; }
set
{
if (this.SizeMode != value)
{
_sizeMode = value;
this.OnSizeModeChanged(EventArgs.Empty);
}
}
}
/// <summary>
/// Gets or sets a value indicating whether the control should automatically size to fit the image contents.
/// </summary>
/// <value>
/// <c>true</c> if the control should size to fit the image contents; otherwise, <c>false</c>.
/// </value>
[DefaultValue(false)]
[Category("Appearance")]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[Obsolete("This property is deprecated and will be removed in a future version of the component. Implementors should use the SizeMode property instead.")]
public virtual bool SizeToFit
{
get { return this.SizeMode == ImageBoxSizeMode.Fit; }
set
{
if (this.SizeMode == ImageBoxSizeMode.Fit != value)
{
this.SizeMode = value ? ImageBoxSizeMode.Fit : ImageBoxSizeMode.Normal;
this.OnSizeToFitChanged(EventArgs.Empty);
if (value)
{
this.AutoPan = false;
}
else
{
this.ActualSize();
}
}
}
}
/// <summary>
/// Gets or sets the alignment of the text on the control.
/// </summary>
/// <value>One of the <see cref="ContentAlignment"/> values. The default is <c>MiddleCenter</c>.</value>
[Category("Appearance")]
[DefaultValue(typeof(ContentAlignment), "MiddleCenter")]
public virtual ContentAlignment TextAlign
{
get { return _textAlign; }
set
{
if (this.TextAlign != value)
{
_textAlign = value;
this.OnTextAlignChanged(EventArgs.Empty);
}
}
}
/// <summary>
/// Gets or sets the color of the text background.
/// </summary>
/// <value>The color of the text background.</value>
[Category("Appearance")]
[DefaultValue(typeof(Color), "Transparent")]
public virtual Color TextBackColor
{
get { return _textBackColor; }
set
{
if (this.TextBackColor != value)
{
_textBackColor = value;
this.OnTextBackColorChanged(EventArgs.Empty);
}
}
}
/// <summary>
/// Gets or sets the text display mode.
/// </summary>
/// <value>The text display mode.</value>
[Category("Appearance")]
[DefaultValue(typeof(ImageBoxGridDisplayMode), "Client")]
public virtual ImageBoxGridDisplayMode TextDisplayMode
{
get { return _textDisplayMode; }
set
{
if (this.TextDisplayMode != value)
{
_textDisplayMode = value;
this.OnTextDisplayModeChanged(EventArgs.Empty);
}
}
}
/// <summary>
/// Gets or sets the text padding.
/// </summary>
/// <value>
/// The text padding.
/// </value>
[Category("Appearance")]
[DefaultValue(typeof(Padding), "0, 0, 0, 0")]
public virtual Padding TextPadding
{
get { return _textPadding; }
set
{
if (this.TextPadding != value)
{
_textPadding = value;
this.OnTextPaddingChanged(EventArgs.Empty);
}
}
}
/// <summary>
/// Gets or sets a value indicating whether the control acts as a virtual image box.
/// </summary>
/// <value>
/// <c>true</c> if the control acts as a virtual image box; otherwise, <c>false</c>.
/// </value>
/// <remarks>
/// When this property is set to <c>true</c>, the Image property is ignored in favor of the VirtualSize property. In addition, the VirtualDraw event is raised to allow custom painting of the image area.
/// </remarks>
[Category("Behavior")]
[DefaultValue(false)]
public virtual bool VirtualMode
{
get { return _virtualMode; }
set
{
if (this.VirtualMode != value)
{
_virtualMode = value;
this.OnVirtualModeChanged(EventArgs.Empty);
}
}
}
/// <summary>
/// Gets or sets the size of the virtual image.
/// </summary>
/// <value>The size of the virtual image.</value>
[Category("Appearance")]
[DefaultValue(typeof(Size), "0, 0")]
public virtual Size VirtualSize
{
get { return _virtualSize; }
set
{
if (this.VirtualSize != value)
{
_virtualSize = value;
this.OnVirtualSizeChanged(EventArgs.Empty);
}
}
}
/// <summary>
/// Gets or sets the zoom.
/// </summary>
/// <value>The zoom.</value>
[DefaultValue(100)]
[Category("Appearance")]
public virtual int Zoom
{
get { return _zoom; }
set { this.SetZoom(value, value > this.Zoom ? ImageBoxZoomActions.ZoomIn : ImageBoxZoomActions.ZoomOut, ImageBoxActionSources.Unknown); }
}
/// <summary>
/// Gets the zoom factor.
/// </summary>
/// <value>The zoom factor.</value>
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public virtual double ZoomFactor
{
get { return (double)this.Zoom / 100; }
}
/// <summary>
/// Gets or sets the zoom levels.
/// </summary>
/// <value>The zoom levels.</value>
[Browsable(false) /*Category("Behavior"), DefaultValue(typeof(ZoomLevelCollection), "7, 10, 15, 20, 25, 30, 50, 70, 100, 150, 200, 300, 400, 500, 600, 700, 800, 1200, 1600")*/]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public virtual ZoomLevelCollection ZoomLevels
{
get { return _zoomLevels; }
set
{
if (this.ZoomLevels != value)
{
_zoomLevels = value;
this.OnZoomLevelsChanged(EventArgs.Empty);
}
}
}
/// <summary>
/// Gets a value indicating whether painting of the control is allowed.
/// </summary>
/// <value>
/// <c>true</c> if painting of the control is allowed; otherwise, <c>false</c>.
/// </value>
protected virtual bool AllowPainting
{
get { return _updateCount == 0; }
}
/// <summary>
/// Gets or sets a value indicating whether the current image is animated.
/// </summary>
/// <value><c>true</c> if the current image is animated; otherwise, <c>false</c>.</value>
protected bool IsAnimating { get; set; }
/// <summary>
/// Gets the height of the scaled image.
/// </summary>
/// <value>The height of the scaled image.</value>
protected virtual int ScaledImageHeight
{
get { return Convert.ToInt32(this.ViewSize.Height * this.ZoomFactor); }
}
/// <summary>
/// Gets the width of the scaled image.
/// </summary>
/// <value>The width of the scaled image.</value>
protected virtual int ScaledImageWidth
{
get { return Convert.ToInt32(this.ViewSize.Width * this.ZoomFactor); }
}
/// <summary>
/// Gets the size of the view.
/// </summary>
/// <value>The size of the view.</value>
protected virtual Size ViewSize
{
get { return this.VirtualMode ? this.VirtualSize : this.GetImageSize(); }
}
/// <summary>
/// Gets or sets a value indicating whether a drag operation was cancelled.
/// </summary>
/// <value><c>true</c> if the drag operation was cancelled; otherwise, <c>false</c>.</value>
protected bool WasDragCancelled { get; set; }
#endregion
#region Methods
/// <summary>
/// Resets the zoom to 100%.
/// </summary>
public virtual void ActualSize()
{
this.PerformActualSize(ImageBoxActionSources.Unknown);
}
/// <summary>
/// Disables any redrawing of the image box
/// </summary>
public virtual void BeginUpdate()
{
_updateCount++;
}
/// <summary>
/// Centers the given point in the image in the center of the control
/// </summary>
/// <param name="imageLocation">The point of the image to attempt to center.</param>
public virtual void CenterAt(Point imageLocation)
{
this.ScrollTo(imageLocation, new Point(this.ClientSize.Width / 2, this.ClientSize.Height / 2));
}
/// <summary>
/// Centers the given point in the image in the center of the control
/// </summary>
/// <param name="x">The X co-ordinate of the point to center.</param>
/// <param name="y">The Y co-ordinate of the point to center.</param>
public void CenterAt(int x, int y)
{
this.CenterAt(new Point(x, y));
}
/// <summary>
/// Centers the given point in the image in the center of the control
/// </summary>
/// <param name="x">The X co-ordinate of the point to center.</param>
/// <param name="y">The Y co-ordinate of the point to center.</param>
public void CenterAt(float x, float y)
{
this.CenterAt(new Point((int)x, (int)y));
}
/// <summary>
/// Resets the viewport to show the center of the image.
/// </summary>
public virtual void CenterToImage()
{
this.AutoScrollPosition = new Point((this.AutoScrollMinSize.Width - this.ClientSize.Width) / 2, (this.AutoScrollMinSize.Height - this.ClientSize.Height) / 2);
}
/// <summary>
/// Enables the redrawing of the image box
/// </summary>
public virtual void EndUpdate()
{
if (_updateCount > 0)
{
_updateCount--;
}
if (this.AllowPainting)
{
this.Invalidate();
}
}
/// <summary>
/// Fits a given <see cref="T:System.Drawing.Rectangle" /> to match image boundaries
/// </summary>
/// <param name="rectangle">The rectangle.</param>
/// <returns>
/// A <see cref="T:System.Drawing.Rectangle" /> structure remapped to fit the image boundaries
/// </returns>
public Rectangle FitRectangle(Rectangle rectangle)
{
int x;
int y;
int w;
int h;
x = rectangle.X;
y = rectangle.Y;
w = rectangle.Width;
h = rectangle.Height;
if (x < 0)
{
x = 0;
}
if (y < 0)
{
y = 0;
}
if (x + w > this.ViewSize.Width)
{
w = this.ViewSize.Width - x;
}
if (y + h > this.ViewSize.Height)
{
h = this.ViewSize.Height - y;
}
return new Rectangle(x, y, w, h);
}
/// <summary>
/// Fits a given <see cref="T:System.Drawing.RectangleF" /> to match image boundaries
/// </summary>
/// <param name="rectangle">The rectangle.</param>
/// <returns>
/// A <see cref="T:System.Drawing.RectangleF" /> structure remapped to fit the image boundaries
/// </returns>
public RectangleF FitRectangle(RectangleF rectangle)
{
float x;
float y;
float w;
float h;
x = rectangle.X;
y = rectangle.Y;
w = rectangle.Width;
h = rectangle.Height;
if (x < 0)
{
w -= -x;
x = 0;
}
if (y < 0)
{
h -= -y;
y = 0;
}
if (x + w > this.ViewSize.Width)
{
w = this.ViewSize.Width - x;
}
if (y + h > this.ViewSize.Height)
{
h = this.ViewSize.Height - y;
}
return new RectangleF(x, y, w, h);
}
/// <summary>
/// Gets the image view port.
/// </summary>
/// <returns></returns>
public virtual Rectangle GetImageViewPort()
{
Rectangle viewPort;
if (!this.ViewSize.IsEmpty)
{
Rectangle innerRectangle;
Point offset;
int width;
int height;
innerRectangle = this.GetInsideViewPort(true);
if (!this.HScroll && !this.VScroll) // if no scrolling is present, tinker the view port so that the image and any applicable borders all fit inside
{
innerRectangle.Inflate(-this.GetImageBorderOffset(), -this.GetImageBorderOffset());
}
if (this.SizeMode != ImageBoxSizeMode.Stretch)
{
if (this.AutoCenter)
{
int x;
int y;
x = !this.HScroll ? (innerRectangle.Width - (this.ScaledImageWidth + this.Padding.Horizontal)) / 2 : 0;
y = !this.VScroll ? (innerRectangle.Height - (this.ScaledImageHeight + this.Padding.Vertical)) / 2 : 0;
offset = new Point(x, y);
}
else
{
offset = Point.Empty;
}
width = Math.Min(this.ScaledImageWidth - Math.Abs(this.AutoScrollPosition.X), innerRectangle.Width);
height = Math.Min(this.ScaledImageHeight - Math.Abs(this.AutoScrollPosition.Y), innerRectangle.Height);
}
else
{
offset = Point.Empty;
width = innerRectangle.Width;
height = innerRectangle.Height;
}
viewPort = new Rectangle(offset.X + innerRectangle.Left, offset.Y + innerRectangle.Top, width, height);
}
else
{
viewPort = Rectangle.Empty;
}
return viewPort;
}
/// <summary>
/// Gets the inside view port, excluding any padding.
/// </summary>
/// <returns></returns>
public Rectangle GetInsideViewPort()
{
return this.GetInsideViewPort(false);
}
/// <summary>
/// Gets the inside view port.
/// </summary>
/// <param name="includePadding">
/// if set to <c>true</c> [include padding].
/// </param>
/// <returns></returns>
public virtual Rectangle GetInsideViewPort(bool includePadding)
{
int left;
int top;
int width;
int height;
left = 0;
top = 0;
width = this.ClientSize.Width;
height = this.ClientSize.Height;
if (includePadding)
{
left += this.Padding.Left;
top += this.Padding.Top;
width -= this.Padding.Horizontal;
height -= this.Padding.Vertical;
}
return new Rectangle(left, top, width, height);
}
/// <summary>
/// Returns the source <see cref="T:System.Drawing.Point" /> repositioned to include the current image offset and scaled by the current zoom level
/// </summary>
/// <param name="source">The source <see cref="Point"/> to offset.</param>
/// <returns>A <see cref="Point"/> which has been repositioned to match the current zoom level and image offset</returns>
public virtual Point GetOffsetPoint(Point source)
{
PointF offset;
offset = this.GetOffsetPoint(new PointF(source.X, source.Y));
return new Point((int)offset.X, (int)offset.Y);
}
/// <summary>
/// Returns the source co-ordinates repositioned to include the current image offset and scaled by the current zoom level
/// </summary>
/// <param name="x">The source X co-ordinate.</param>
/// <param name="y">The source Y co-ordinate.</param>
/// <returns>A <see cref="Point"/> which has been repositioned to match the current zoom level and image offset</returns>
public Point GetOffsetPoint(int x, int y)
{
return this.GetOffsetPoint(new Point(x, y));
}
/// <summary>
/// Returns the source co-ordinates repositioned to include the current image offset and scaled by the current zoom level
/// </summary>
/// <param name="x">The source X co-ordinate.</param>
/// <param name="y">The source Y co-ordinate.</param>
/// <returns>A <see cref="Point"/> which has been repositioned to match the current zoom level and image offset</returns>
public PointF GetOffsetPoint(float x, float y)
{
return this.GetOffsetPoint(new PointF(x, y));
}
/// <summary>
/// Returns the source <see cref="T:System.Drawing.PointF" /> repositioned to include the current image offset and scaled by the current zoom level
/// </summary>
/// <param name="source">The source <see cref="PointF"/> to offset.</param>
/// <returns>A <see cref="PointF"/> which has been repositioned to match the current zoom level and image offset</returns>
public virtual PointF GetOffsetPoint(PointF source)
{
Rectangle viewport;
PointF scaled;
int offsetX;
int offsetY;
viewport = this.GetImageViewPort();
scaled = this.GetScaledPoint(source);
offsetX = viewport.Left + this.Padding.Left + this.AutoScrollPosition.X;
offsetY = viewport.Top + this.Padding.Top + this.AutoScrollPosition.Y;
return new PointF(scaled.X + offsetX, scaled.Y + offsetY);
}
/// <summary>
/// Returns the source <see cref="T:System.Drawing.RectangleF" /> scaled according to the current zoom level and repositioned to include the current image offset
/// </summary>
/// <param name="source">The source <see cref="RectangleF"/> to offset.</param>
/// <returns>A <see cref="RectangleF"/> which has been resized and repositioned to match the current zoom level and image offset</returns>
public virtual RectangleF GetOffsetRectangle(RectangleF source)
{
RectangleF viewport;
RectangleF scaled;
float offsetX;
float offsetY;
viewport = this.GetImageViewPort();
scaled = this.GetScaledRectangle(source);
offsetX = viewport.Left + this.Padding.Left + this.AutoScrollPosition.X;
offsetY = viewport.Top + this.Padding.Top + this.AutoScrollPosition.Y;
return new RectangleF(new PointF(scaled.Left + offsetX, scaled.Top + offsetY), scaled.Size);
}
/// <summary>
/// Returns the source rectangle scaled according to the current zoom level and repositioned to include the current image offset
/// </summary>
/// <param name="x">The X co-ordinate of the source rectangle.</param>
/// <param name="y">The Y co-ordinate of the source rectangle.</param>
/// <param name="width">The width of the rectangle.</param>
/// <param name="height">The height of the rectangle.</param>
/// <returns>A <see cref="Rectangle"/> which has been resized and repositioned to match the current zoom level and image offset</returns>
public Rectangle GetOffsetRectangle(int x, int y, int width, int height)
{
return this.GetOffsetRectangle(new Rectangle(x, y, width, height));
}
/// <summary>
/// Returns the source rectangle scaled according to the current zoom level and repositioned to include the current image offset
/// </summary>
/// <param name="x">The X co-ordinate of the source rectangle.</param>
/// <param name="y">The Y co-ordinate of the source rectangle.</param>
/// <param name="width">The width of the rectangle.</param>
/// <param name="height">The height of the rectangle.</param>
/// <returns>A <see cref="RectangleF"/> which has been resized and repositioned to match the current zoom level and image offset</returns>
public RectangleF GetOffsetRectangle(float x, float y, float width, float height)
{
return this.GetOffsetRectangle(new RectangleF(x, y, width, height));
}
/// <summary>
/// Returns the source <see cref="T:System.Drawing.Rectangle" /> scaled according to the current zoom level and repositioned to include the current image offset
/// </summary>
/// <param name="source">The source <see cref="Rectangle"/> to offset.</param>
/// <returns>A <see cref="Rectangle"/> which has been resized and repositioned to match the current zoom level and image offset</returns>
public virtual Rectangle GetOffsetRectangle(Rectangle source)
{
Rectangle viewport;
Rectangle scaled;
int offsetX;
int offsetY;
viewport = this.GetImageViewPort();
scaled = this.GetScaledRectangle(source);
offsetX = viewport.Left + this.Padding.Left + this.AutoScrollPosition.X;
offsetY = viewport.Top + this.Padding.Top + this.AutoScrollPosition.Y;
return new Rectangle(new Point(scaled.Left + offsetX, scaled.Top + offsetY), scaled.Size);
}
/// <summary>
/// Retrieves the size of a rectangular area into which a control can be fitted.
/// </summary>
/// <param name="proposedSize">The custom-sized area for a control.</param>
/// <returns>
/// An ordered pair of type <see cref="T:System.Drawing.Size" /> representing the width and height of a rectangle.
/// </returns>
public override Size GetPreferredSize(Size proposedSize)
{
Size size;
if (!this.ViewSize.IsEmpty)
{
int width;
int height;
// get the size of the image
width = this.ScaledImageWidth;
height = this.ScaledImageHeight;
// add an offset based on padding
width += this.Padding.Horizontal;
height += this.Padding.Vertical;
// add an offset based on the border style
width += this.GetImageBorderOffset();
height += this.GetImageBorderOffset();
size = new Size(width, height);
}
else
{
size = base.GetPreferredSize(proposedSize);
}
return size;
}
/// <summary>
/// Returns the source <see cref="T:System.Drawing.Point" /> scaled according to the current zoom level
/// </summary>
/// <param name="x">The X co-ordinate of the point to scale.</param>
/// <param name="y">The Y co-ordinate of the point to scale.</param>
/// <returns>A <see cref="Point"/> which has been scaled to match the current zoom level</returns>
public Point GetScaledPoint(int x, int y)
{
return this.GetScaledPoint(new Point(x, y));
}
/// <summary>
/// Returns the source <see cref="T:System.Drawing.Point" /> scaled according to the current zoom level
/// </summary>
/// <param name="x">The X co-ordinate of the point to scale.</param>
/// <param name="y">The Y co-ordinate of the point to scale.</param>
/// <returns>A <see cref="Point"/> which has been scaled to match the current zoom level</returns>
public PointF GetScaledPoint(float x, float y)
{
return this.GetScaledPoint(new PointF(x, y));
}
/// <summary>
/// Returns the source <see cref="T:System.Drawing.Point" /> scaled according to the current zoom level
/// </summary>
/// <param name="source">The source <see cref="Point"/> to scale.</param>
/// <returns>A <see cref="Point"/> which has been scaled to match the current zoom level</returns>
public virtual Point GetScaledPoint(Point source)
{
return new Point((int)(source.X * this.ZoomFactor), (int)(source.Y * this.ZoomFactor));
}
/// <summary>
/// Returns the source <see cref="T:System.Drawing.PointF" /> scaled according to the current zoom level
/// </summary>
/// <param name="source">The source <see cref="PointF"/> to scale.</param>
/// <returns>A <see cref="PointF"/> which has been scaled to match the current zoom level</returns>
public virtual PointF GetScaledPoint(PointF source)
{
return new PointF((float)(source.X * this.ZoomFactor), (float)(source.Y * this.ZoomFactor));
}
/// <summary>
/// Returns the source rectangle scaled according to the current zoom level
/// </summary>
/// <param name="x">The X co-ordinate of the source rectangle.</param>
/// <param name="y">The Y co-ordinate of the source rectangle.</param>
/// <param name="width">The width of the rectangle.</param>
/// <param name="height">The height of the rectangle.</param>
/// <returns>A <see cref="Rectangle"/> which has been scaled to match the current zoom level</returns>
public Rectangle GetScaledRectangle(int x, int y, int width, int height)
{
return this.GetScaledRectangle(new Rectangle(x, y, width, height));
}
/// <summary>
/// Returns the source rectangle scaled according to the current zoom level
/// </summary>
/// <param name="x">The X co-ordinate of the source rectangle.</param>
/// <param name="y">The Y co-ordinate of the source rectangle.</param>
/// <param name="width">The width of the rectangle.</param>
/// <param name="height">The height of the rectangle.</param>
/// <returns>A <see cref="RectangleF"/> which has been scaled to match the current zoom level</returns>
public RectangleF GetScaledRectangle(float x, float y, float width, float height)
{
return this.GetScaledRectangle(new RectangleF(x, y, width, height));
}
/// <summary>
/// Returns the source rectangle scaled according to the current zoom level
/// </summary>
/// <param name="location">The location of the source rectangle.</param>
/// <param name="size">The size of the source rectangle.</param>
/// <returns>A <see cref="Rectangle"/> which has been scaled to match the current zoom level</returns>
public Rectangle GetScaledRectangle(Point location, Size size)
{
return this.GetScaledRectangle(new Rectangle(location, size));
}
/// <summary>
/// Returns the source rectangle scaled according to the current zoom level
/// </summary>
/// <param name="location">The location of the source rectangle.</param>
/// <param name="size">The size of the source rectangle.</param>
/// <returns>A <see cref="Rectangle"/> which has been scaled to match the current zoom level</returns>
public RectangleF GetScaledRectangle(PointF location, SizeF size)
{
return this.GetScaledRectangle(new RectangleF(location, size));
}
/// <summary>
/// Returns the source <see cref="T:System.Drawing.Rectangle" /> scaled according to the current zoom level
/// </summary>
/// <param name="source">The source <see cref="Rectangle"/> to scale.</param>
/// <returns>A <see cref="Rectangle"/> which has been scaled to match the current zoom level</returns>
public virtual Rectangle GetScaledRectangle(Rectangle source)
{
return new Rectangle((int)(source.Left * this.ZoomFactor), (int)(source.Top * this.ZoomFactor), (int)(source.Width * this.ZoomFactor), (int)(source.Height * this.ZoomFactor));
}
/// <summary>
/// Returns the source <see cref="T:System.Drawing.RectangleF" /> scaled according to the current zoom level
/// </summary>
/// <param name="source">The source <see cref="RectangleF"/> to scale.</param>
/// <returns>A <see cref="RectangleF"/> which has been scaled to match the current zoom level</returns>
public virtual RectangleF GetScaledRectangle(RectangleF source)
{
return new RectangleF((float)(source.Left * this.ZoomFactor), (float)(source.Top * this.ZoomFactor), (float)(source.Width * this.ZoomFactor), (float)(source.Height * this.ZoomFactor));
}
/// <summary>
/// Returns the source size scaled according to the current zoom level
/// </summary>
/// <param name="width">The width of the size to scale.</param>
/// <param name="height">The height of the size to scale.</param>
/// <returns>A <see cref="SizeF"/> which has been resized to match the current zoom level</returns>
public SizeF GetScaledSize(float width, float height)
{
return this.GetScaledSize(new SizeF(width, height));
}
/// <summary>
/// Returns the source size scaled according to the current zoom level
/// </summary>
/// <param name="width">The width of the size to scale.</param>
/// <param name="height">The height of the size to scale.</param>
/// <returns>A <see cref="Size"/> which has been resized to match the current zoom level</returns>
public Size GetScaledSize(int width, int height)
{
return this.GetScaledSize(new Size(width, height));
}
/// <summary>
/// Returns the source <see cref="T:System.Drawing.SizeF" /> scaled according to the current zoom level
/// </summary>
/// <param name="source">The source <see cref="SizeF"/> to scale.</param>
/// <returns>A <see cref="SizeF"/> which has been resized to match the current zoom level</returns>
public virtual SizeF GetScaledSize(SizeF source)
{
return new SizeF((float)(source.Width * this.ZoomFactor), (float)(source.Height * this.ZoomFactor));
}
/// <summary>
/// Returns the source <see cref="T:System.Drawing.Size" /> scaled according to the current zoom level
/// </summary>
/// <param name="source">The source <see cref="Size"/> to scale.</param>
/// <returns>A <see cref="Size"/> which has been resized to match the current zoom level</returns>
public virtual Size GetScaledSize(Size source)
{
return new Size((int)(source.Width * this.ZoomFactor), (int)(source.Height * this.ZoomFactor));
}
/// <summary>
/// Creates an image based on the current selection region
/// </summary>
/// <returns>An image containing the selection contents if a selection if present, otherwise null</returns>
/// <remarks>The caller is responsible for disposing of the returned image</remarks>
public Image GetSelectedImage()
{
Image result;
result = null;
if (!this.SelectionRegion.IsEmpty)
{
Rectangle rect;
rect = this.FitRectangle(new Rectangle((int)this.SelectionRegion.X, (int)this.SelectionRegion.Y, (int)this.SelectionRegion.Width, (int)this.SelectionRegion.Height));
if (rect.Width > 0 && rect.Height > 0)
{
result = new Bitmap(rect.Width, rect.Height);
using (Graphics g = Graphics.FromImage(result))
{
g.DrawImage(this.Image, new Rectangle(Point.Empty, rect.Size), rect, GraphicsUnit.Pixel);
}
}
}
return result;
}
/// <summary>
/// Gets the source image region.
/// </summary>
/// <returns></returns>
public virtual RectangleF GetSourceImageRegion()
{
RectangleF region;
if (!this.ViewSize.IsEmpty)
{
if (this.SizeMode != ImageBoxSizeMode.Stretch)
{
float sourceLeft;
float sourceTop;
float sourceWidth;
float sourceHeight;
Rectangle viewPort;
viewPort = this.GetImageViewPort();
sourceLeft = (float)(-this.AutoScrollPosition.X / this.ZoomFactor);
sourceTop = (float)(-this.AutoScrollPosition.Y / this.ZoomFactor);
sourceWidth = (float)(viewPort.Width / this.ZoomFactor);
sourceHeight = (float)(viewPort.Height / this.ZoomFactor);
region = new RectangleF(sourceLeft, sourceTop, sourceWidth, sourceHeight);
}
else
{
region = new RectangleF(PointF.Empty, this.ViewSize);
}
}
else
{
region = RectangleF.Empty;
}
return region;
}
/// <summary>
/// Determines whether the specified point is located within the image view port
/// </summary>
/// <param name="point">The point.</param>
/// <returns>
/// <c>true</c> if the specified point is located within the image view port; otherwise, <c>false</c>.
/// </returns>
public virtual bool IsPointInImage(Point point)
{
return this.GetImageViewPort().
Contains(point);
}
/// <summary>
/// Determines whether the specified point is located within the image view port
/// </summary>
/// <param name="x">The X co-ordinate of the point to check.</param>
/// <param name="y">The Y co-ordinate of the point to check.</param>
/// <returns>
/// <c>true</c> if the specified point is located within the image view port; otherwise, <c>false</c>.
/// </returns>
public bool IsPointInImage(int x, int y)
{
return this.IsPointInImage(new Point(x, y));
}
/// <summary>
/// Determines whether the specified point is located within the image view port
/// </summary>
/// <param name="x">The X co-ordinate of the point to check.</param>
/// <param name="y">The Y co-ordinate of the point to check.</param>
/// <returns>
/// <c>true</c> if the specified point is located within the image view port; otherwise, <c>false</c>.
/// </returns>
public bool IsPointInImage(float x, float y)
{
return this.IsPointInImage(new Point((int)x, (int)y));
}
/// <summary>
/// Converts the given client size point to represent a coordinate on the source image.
/// </summary>
/// <param name="point">The source point.</param>
/// <returns><c>Point.Empty</c> if the point could not be matched to the source image, otherwise the new translated point</returns>
public Point PointToImage(Point point)
{
return this.PointToImage(point, false);
}
/// <summary>
/// Converts the given client size point to represent a coordinate on the source image.
/// </summary>
/// <param name="x">The X co-ordinate of the point to convert.</param>
/// <param name="y">The Y co-ordinate of the point to convert.</param>
/// <returns><c>Point.Empty</c> if the point could not be matched to the source image, otherwise the new translated point</returns>
public Point PointToImage(float x, float y)
{
return this.PointToImage(x, y, false);
}
/// <summary>
/// Converts the given client size point to represent a coordinate on the source image.
/// </summary>
/// <param name="x">The X co-ordinate of the point to convert.</param>
/// <param name="y">The Y co-ordinate of the point to convert.</param>
/// <param name="fitToBounds">
/// if set to <c>true</c> and the point is outside the bounds of the source image, it will be mapped to the nearest edge.
/// </param>
/// <returns><c>Point.Empty</c> if the point could not be matched to the source image, otherwise the new translated point</returns>
public Point PointToImage(float x, float y, bool fitToBounds)
{
return this.PointToImage(new Point((int)x, (int)y), fitToBounds);
}
/// <summary>
/// Converts the given client size point to represent a coordinate on the source image.
/// </summary>
/// <param name="x">The X co-ordinate of the point to convert.</param>
/// <param name="y">The Y co-ordinate of the point to convert.</param>
/// <returns><c>Point.Empty</c> if the point could not be matched to the source image, otherwise the new translated point</returns>
public Point PointToImage(int x, int y)
{
return this.PointToImage(x, y, false);
}
/// <summary>
/// Converts the given client size point to represent a coordinate on the source image.
/// </summary>
/// <param name="x">The X co-ordinate of the point to convert.</param>
/// <param name="y">The Y co-ordinate of the point to convert.</param>
/// <param name="fitToBounds">
/// if set to <c>true</c> and the point is outside the bounds of the source image, it will be mapped to the nearest edge.
/// </param>
/// <returns><c>Point.Empty</c> if the point could not be matched to the source image, otherwise the new translated point</returns>
public Point PointToImage(int x, int y, bool fitToBounds)
{
return this.PointToImage(new Point(x, y), fitToBounds);
}
/// <summary>
/// Converts the given client size point to represent a coordinate on the source image.
/// </summary>
/// <param name="point">The source point.</param>
/// <param name="fitToBounds">
/// if set to <c>true</c> and the point is outside the bounds of the source image, it will be mapped to the nearest edge.
/// </param>
/// <returns><c>Point.Empty</c> if the point could not be matched to the source image, otherwise the new translated point</returns>
public virtual Point PointToImage(Point point, bool fitToBounds)
{
Rectangle viewport;
int x;
int y;
viewport = this.GetImageViewPort();
if (!fitToBounds || viewport.Contains(point))
{
if (this.AutoScrollPosition != Point.Empty)
{
point = new Point(point.X - this.AutoScrollPosition.X, point.Y - this.AutoScrollPosition.Y);
}
x = (int)((point.X - viewport.X) / this.ZoomFactor);
y = (int)((point.Y - viewport.Y) / this.ZoomFactor);
if (fitToBounds)
{
if (x < 0)
{
x = 0;
}
else if (x > this.ViewSize.Width)
{
x = this.ViewSize.Width;
}
if (y < 0)
{
y = 0;
}
else if (y > this.ViewSize.Height)
{
y = this.ViewSize.Height;
}
}
}
else
{
x = 0; // Return Point.Empty if we couldn't match
y = 0;
}
return new Point(x, y);
}
/// <summary>
/// Scrolls the control to the given point in the image, offset at the specified display point
/// </summary>
/// <param name="x">The X co-ordinate of the point to scroll to.</param>
/// <param name="y">The Y co-ordinate of the point to scroll to.</param>
/// <param name="relativeX">The X co-ordinate relative to the <c>x</c> parameter.</param>
/// <param name="relativeY">The Y co-ordinate relative to the <c>y</c> parameter.</param>
public void ScrollTo(int x, int y, int relativeX, int relativeY)
{
this.ScrollTo(new Point(x, y), new Point(relativeX, relativeY));
}
/// <summary>
/// Scrolls the control to the given point in the image, offset at the specified display point
/// </summary>
/// <param name="x">The X co-ordinate of the point to scroll to.</param>
/// <param name="y">The Y co-ordinate of the point to scroll to.</param>
/// <param name="relativeX">The X co-ordinate relative to the <c>x</c> parameter.</param>
/// <param name="relativeY">The Y co-ordinate relative to the <c>y</c> parameter.</param>
public void ScrollTo(float x, float y, float relativeX, float relativeY)
{
this.ScrollTo(new Point((int)x, (int)y), new Point((int)relativeX, (int)relativeY));
}
/// <summary>
/// Scrolls the control to the given point in the image, offset at the specified display point
/// </summary>
/// <param name="imageLocation">The point of the image to attempt to scroll to.</param>
/// <param name="relativeDisplayPoint">The relative display point to offset scrolling by.</param>
public virtual void ScrollTo(Point imageLocation, Point relativeDisplayPoint)
{
int x;
int y;
x = (int)(imageLocation.X * this.ZoomFactor) - relativeDisplayPoint.X;
y = (int)(imageLocation.Y * this.ZoomFactor) - relativeDisplayPoint.Y;
this.AutoScrollPosition = new Point(x, y);
}
/// <summary>
/// Creates a selection region which encompasses the entire image
/// </summary>
/// <exception cref="System.InvalidOperationException">Thrown if no image is currently set</exception>
public virtual void SelectAll()
{
this.SelectionRegion = new RectangleF(PointF.Empty, this.ViewSize);
}
/// <summary>
/// Clears any existing selection region
/// </summary>
public virtual void SelectNone()
{
this.SelectionRegion = RectangleF.Empty;
}
/// <summary>
/// Zooms into the image
/// </summary>
public virtual void ZoomIn()
{
this.ZoomIn(true);
}
/// <summary>
/// Zooms into the image
/// </summary>
/// <param name="preservePosition"><c>true</c> if the current scrolling position should be preserved relative to the new zoom level, <c>false</c> to reset.</param>
public virtual void ZoomIn(bool preservePosition)
{
this.PerformZoomIn(ImageBoxActionSources.Unknown, preservePosition);
}
/// <summary>
/// Zooms out of the image
/// </summary>
public virtual void ZoomOut()
{
this.ZoomOut(true);
}
/// <summary>
/// Zooms out of the image
/// </summary>
/// <param name="preservePosition"><c>true</c> if the current scrolling position should be preserved relative to the new zoom level, <c>false</c> to reset.</param>
public virtual void ZoomOut(bool preservePosition)
{
this.PerformZoomOut(ImageBoxActionSources.Unknown, preservePosition);
}
/// <summary>
/// Zooms to the maximum size for displaying the entire image within the bounds of the control.
/// </summary>
public virtual void ZoomToFit()
{
if (!this.ViewSize.IsEmpty)
{
Rectangle innerRectangle;
double zoom;
double aspectRatio;
this.AutoScrollMinSize = Size.Empty;
innerRectangle = this.GetInsideViewPort(true);
if (this.ViewSize.Width > this.ViewSize.Height)
{
aspectRatio = (double)innerRectangle.Width / this.ViewSize.Width;
zoom = aspectRatio * 100.0;
if (innerRectangle.Height < this.ViewSize.Height * zoom / 100.0)
{
aspectRatio = (double)innerRectangle.Height / this.ViewSize.Height;
zoom = aspectRatio * 100.0;
}
}
else
{
aspectRatio = (double)innerRectangle.Height / this.ViewSize.Height;
zoom = aspectRatio * 100.0;
if (innerRectangle.Width < this.ViewSize.Width * zoom / 100.0)
{
aspectRatio = (double)innerRectangle.Width / this.ViewSize.Width;
zoom = aspectRatio * 100.0;
}
}
this.Zoom = (int)Math.Round(Math.Floor(zoom));
}
}
/// <summary>
/// Adjusts the view port to fit the given region
/// </summary>
/// <param name="x">The X co-ordinate of the selection region.</param>
/// <param name="y">The Y co-ordinate of the selection region.</param>
/// <param name="width">The width of the selection region.</param>
/// <param name="height">The height of the selection region.</param>
public void ZoomToRegion(float x, float y, float width, float height)
{
this.ZoomToRegion(new RectangleF(x, y, width, height));
}
/// <summary>
/// Adjusts the view port to fit the given region
/// </summary>
/// <param name="x">The X co-ordinate of the selection region.</param>
/// <param name="y">The Y co-ordinate of the selection region.</param>
/// <param name="width">The width of the selection region.</param>
/// <param name="height">The height of the selection region.</param>
public void ZoomToRegion(int x, int y, int width, int height)
{
this.ZoomToRegion(new RectangleF(x, y, width, height));
}
/// <summary>
/// Adjusts the view port to fit the given region
/// </summary>
/// <param name="rectangle">The rectangle to fit the view port to.</param>
public virtual void ZoomToRegion(RectangleF rectangle)
{
double ratioX;
double ratioY;
double zoomFactor;
int cx;
int cy;
ratioX = this.ClientSize.Width / rectangle.Width;
ratioY = this.ClientSize.Height / rectangle.Height;
zoomFactor = Math.Min(ratioX, ratioY);
cx = (int)(rectangle.X + rectangle.Width / 2);
cy = (int)(rectangle.Y + rectangle.Height / 2);
this.Zoom = (int)(zoomFactor * 100);
this.CenterAt(new Point(cx, cy));
}
/// <summary>
/// Adjusts the layout.
/// </summary>
protected virtual void AdjustLayout()
{
if (this.AllowPainting)
{
if (this.AutoSize)
{
this.AdjustSize();
}
else if (this.SizeMode != ImageBoxSizeMode.Normal)
{
this.ZoomToFit();
}
else if (this.AutoScroll)
{
this.AdjustViewPort();
}
this.Invalidate();
}
}
/// <summary>
/// Adjusts the scroll.
/// </summary>
/// <param name="x">The x.</param>
/// <param name="y">The y.</param>
protected virtual void AdjustScroll(int x, int y)
{
Point scrollPosition;
scrollPosition = new Point(this.HorizontalScroll.Value + x, this.VerticalScroll.Value + y);
this.UpdateScrollPosition(scrollPosition);
}
/// <summary>
/// Adjusts the size.
/// </summary>
protected virtual void AdjustSize()
{
if (this.AutoSize && this.Dock == DockStyle.None)
{
this.Size = this.PreferredSize;
}
}
/// <summary>
/// Adjusts the view port.
/// </summary>
protected virtual void AdjustViewPort()
{
if (this.AutoScroll && !this.ViewSize.IsEmpty)
{
this.AutoScrollMinSize = new Size(this.ScaledImageWidth + this.Padding.Horizontal, this.ScaledImageHeight + this.Padding.Vertical);
}
}
/// <summary>
/// Creates the grid tile image.
/// </summary>
/// <param name="cellSize">Size of the cell.</param>
/// <param name="firstColor">The first color.</param>
/// <param name="secondColor">Color of the second.</param>
/// <returns></returns>
protected virtual Bitmap CreateGridTileImage(int cellSize, Color firstColor, Color secondColor)
{
float scale;
// rescale the cell size
switch (this.GridScale)
{
case ImageBoxGridScale.Medium:
scale = 1.5F;
break;
case ImageBoxGridScale.Large:
scale = 2;
break;
case ImageBoxGridScale.Tiny:
scale = 0.5F;
break;
default:
scale = 1;
break;
}
cellSize = (int)(cellSize * scale);
return CreateCheckerBoxTile(cellSize, firstColor, secondColor);
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (this.IsAnimating)
{
ImageAnimator.StopAnimate(this.Image, this.OnFrameChangedHandler);
}
if (_texture != null)
{
_texture.Dispose();
_texture = null;
}
if (_gridTile != null)
{
_gridTile.Dispose();
_gridTile = null;
}
this.KillTimer();
}
base.Dispose(disposing);
}
/// <summary>
/// Draws the background of the control.
/// </summary>
/// <param name="e">The <see cref="PaintEventArgs"/> instance containing the event data.</param>
protected virtual void DrawBackground(PaintEventArgs e)
{
Rectangle innerRectangle;
innerRectangle = this.GetInsideViewPort();
using (SolidBrush brush = new SolidBrush(this.BackColor))
{
e.Graphics.FillRectangle(brush, innerRectangle);
}
if (_texture != null && this.GridDisplayMode != ImageBoxGridDisplayMode.None)
{
switch (this.GridDisplayMode)
{
case ImageBoxGridDisplayMode.Image:
Rectangle fillRectangle;
fillRectangle = this.GetImageViewPort();
e.Graphics.FillRectangle(_texture, fillRectangle);
break;
case ImageBoxGridDisplayMode.Client:
e.Graphics.FillRectangle(_texture, innerRectangle);
break;
}
}
}
/// <summary>
/// Draws a drop shadow.
/// </summary>
/// <param name="g">The graphics. </param>
/// <param name="viewPort"> The view port. </param>
protected virtual void DrawDropShadow(Graphics g, Rectangle viewPort)
{
Rectangle rightEdge;
Rectangle bottomEdge;
rightEdge = new Rectangle(viewPort.Right + 1, viewPort.Top + this.DropShadowSize, this.DropShadowSize, viewPort.Height);
bottomEdge = new Rectangle(viewPort.Left + this.DropShadowSize, viewPort.Bottom + 1, viewPort.Width + 1, this.DropShadowSize);
using (Brush brush = new SolidBrush(this.ImageBorderColor))
{
g.FillRectangles(brush, new[]
{
rightEdge,
bottomEdge
});
}
}
/// <summary>
/// Draws a glow shadow.
/// </summary>
/// <param name="g">The graphics.</param>
/// <param name="viewPort">The view port.</param>
protected virtual void DrawGlowShadow(Graphics g, Rectangle viewPort)
{
// Glow code adapted from http://www.codeproject.com/Articles/372743/gGlowBox-Create-a-glow-effect-around-a-focused-con
g.SetClip(viewPort, CombineMode.Exclude); // make sure the inside glow doesn't appear
using (GraphicsPath path = new GraphicsPath())
{
int glowSize;
int feather;
path.AddRectangle(viewPort);
glowSize = this.DropShadowSize * 3;
feather = 50;
for (int i = 1; i <= glowSize; i += 2)
{
int alpha;
alpha = feather - feather / glowSize * i;
using (Pen pen = new Pen(Color.FromArgb(alpha, this.ImageBorderColor), i)
{
LineJoin = LineJoin.Round
})
{
g.DrawPath(pen, path);
}
}
}
}
/// <summary>
/// Draws the image.
/// </summary>
/// <param name="g">The g.</param>
protected virtual void DrawImage(Graphics g)
{
InterpolationMode currentInterpolationMode;
PixelOffsetMode currentPixelOffsetMode;
currentInterpolationMode = g.InterpolationMode;
currentPixelOffsetMode = g.PixelOffsetMode;
g.InterpolationMode = this.GetInterpolationMode();
// disable pixel offsets. Thanks to Rotem for the info.
// http://stackoverflow.com/questions/14070311/why-is-graphics-drawimage-cropping-part-of-my-image/14070372#14070372
g.PixelOffsetMode = PixelOffsetMode.HighQuality;
try
{
// Animation. Thanks to teamalpha5441 for the contribution
if (this.IsAnimating && !this.DesignMode)
{
ImageAnimator.UpdateFrames(this.Image);
}
g.DrawImage(this.Image, this.GetImageViewPort(), this.GetSourceImageRegion(), GraphicsUnit.Pixel);
}
catch (Exception ex)
{
TextRenderer.DrawText(g, ex.Message, this.Font, this.ClientRectangle, this.ForeColor, this.BackColor, TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter | TextFormatFlags.WordBreak | TextFormatFlags.NoPadding | TextFormatFlags.NoPrefix);
}
g.PixelOffsetMode = currentPixelOffsetMode;
g.InterpolationMode = currentInterpolationMode;
}
/// <summary>
/// Draws a border around the image.
/// </summary>
/// <param name="graphics"> The graphics. </param>
protected virtual void DrawImageBorder(Graphics graphics)
{
if (this.ImageBorderStyle != ImageBoxBorderStyle.None)
{
Rectangle viewPort;
graphics.SetClip(this.GetInsideViewPort()); // make sure the image border doesn't overwrite the control border
viewPort = this.GetImageViewPort();
viewPort = new Rectangle(viewPort.Left - 1, viewPort.Top - 1, viewPort.Width + 1, viewPort.Height + 1);
using (Pen borderPen = new Pen(this.ImageBorderColor))
{
graphics.DrawRectangle(borderPen, viewPort);
}
switch (this.ImageBorderStyle)
{
case ImageBoxBorderStyle.FixedSingleDropShadow:
this.DrawDropShadow(graphics, viewPort);
break;
case ImageBoxBorderStyle.FixedSingleGlowShadow:
this.DrawGlowShadow(graphics, viewPort);
break;
}
graphics.ResetClip();
}
}
/// <summary>
/// Draws the specified text within the specified bounds using the specified device context.
/// </summary>
/// <param name="graphics">The device context in which to draw the text.</param>
/// <param name="text">The text to draw.</param>
/// <param name="bounds">The <see cref="Rectangle"/> that represents the bounds of the text.</param>
protected void DrawLabel(Graphics graphics, string text, Rectangle bounds)
{
this.DrawLabel(graphics, text, this.Font, this.ForeColor, this.TextBackColor, this.TextAlign, bounds);
}
/// <summary>
/// Draws the specified text within the specified bounds using the specified device context and font.
/// </summary>
/// <param name="graphics">The device context in which to draw the text.</param>
/// <param name="text">The text to draw.</param>
/// <param name="font">The <see cref="Font"/> to apply to the drawn text.</param>
/// <param name="bounds">The <see cref="Rectangle"/> that represents the bounds of the text.</param>
protected void DrawLabel(Graphics graphics, string text, Font font, Rectangle bounds)
{
this.DrawLabel(graphics, text, font, this.ForeColor, this.TextBackColor, this.TextAlign, bounds);
}
/// <summary>
/// Draws the specified text within the specified bounds using the specified device context, font, and color.
/// </summary>
/// <param name="graphics">The device context in which to draw the text.</param>
/// <param name="text">The text to draw.</param>
/// <param name="font">The <see cref="Font"/> to apply to the drawn text.</param>
/// <param name="foreColor">The <see cref="Color"/> to apply to the text.</param>
/// <param name="bounds">The <see cref="Rectangle"/> that represents the bounds of the text.</param>
protected void DrawLabel(Graphics graphics, string text, Font font, Color foreColor, Rectangle bounds)
{
this.DrawLabel(graphics, text, font, foreColor, this.TextBackColor, this.TextAlign, bounds);
}
/// <summary>
/// Draws the specified text within the specified bounds using the specified device context, font, color, and back color.
/// </summary>
/// <param name="graphics">The device context in which to draw the text.</param>
/// <param name="text">The text to draw.</param>
/// <param name="font">The <see cref="Font"/> to apply to the drawn text.</param>
/// <param name="foreColor">The <see cref="Color"/> to apply to the text.</param>
/// <param name="backColor">The <see cref="Color"/> to apply to the area represented by <c>bounds</c>.</param>
/// <param name="bounds">The <see cref="Rectangle"/> that represents the bounds of the text.</param>
protected void DrawLabel(Graphics graphics, string text, Font font, Color foreColor, Color backColor, Rectangle bounds)
{
this.DrawLabel(graphics, text, font, foreColor, backColor, this.TextAlign, bounds);
}
/// <summary>
/// Draws the specified text within the specified bounds using the specified device context, font, color, back color, and formatting instructions.
/// </summary>
/// <param name="graphics">The device context in which to draw the text.</param>
/// <param name="text">The text to draw.</param>
/// <param name="font">The <see cref="Font"/> to apply to the drawn text.</param>
/// <param name="foreColor">The <see cref="Color"/> to apply to the text.</param>
/// <param name="backColor">The <see cref="Color"/> to apply to the area represented by <c>bounds</c>.</param>
/// <param name="textAlign">The <see cref="ContentAlignment"/> to apply to the text.</param>
/// <param name="bounds">The <see cref="Rectangle"/> that represents the bounds of the text.</param>
protected void DrawLabel(Graphics graphics, string text, Font font, Color foreColor, Color backColor, ContentAlignment textAlign, Rectangle bounds)
{
this.DrawLabel(graphics, text, font, foreColor, backColor, textAlign, bounds, this.ScaleText);
}
/// <summary>
/// Draws the specified text within the specified bounds using the specified device context, font, color, back color, and formatting instructions.
/// </summary>
/// <param name="graphics">The device context in which to draw the text.</param>
/// <param name="text">The text to draw.</param>
/// <param name="font">The <see cref="Font"/> to apply to the drawn text.</param>
/// <param name="foreColor">The <see cref="Color"/> to apply to the text.</param>
/// <param name="backColor">The <see cref="Color"/> to apply to the area represented by <c>bounds</c>.</param>
/// <param name="textAlign">The <see cref="ContentAlignment"/> to apply to the text.</param>
/// <param name="bounds">The <see cref="Rectangle"/> that represents the bounds of the text.</param>
/// <param name="scaleText">If set to <c>true</c> the font size is scaled according to the current zoom level.</param>
protected virtual void DrawLabel(Graphics graphics, string text, Font font, Color foreColor, Color backColor, ContentAlignment textAlign, Rectangle bounds, bool scaleText)
{
this.DrawLabel(graphics, text, font, foreColor, backColor, textAlign, bounds, scaleText, Padding.Empty);
}
/// <summary>
/// Draws the specified text within the specified bounds using the specified device context, font, color, back color, and formatting instructions.
/// </summary>
/// <param name="graphics">The device context in which to draw the text.</param>
/// <param name="text">The text to draw.</param>
/// <param name="font">The <see cref="Font"/> to apply to the drawn text.</param>
/// <param name="foreColor">The <see cref="Color"/> to apply to the text.</param>
/// <param name="backColor">The <see cref="Color"/> to apply to the area represented by <c>bounds</c>.</param>
/// <param name="textAlign">The <see cref="ContentAlignment"/> to apply to the text.</param>
/// <param name="bounds">The <see cref="Rectangle"/> that represents the bounds of the text.</param>
/// <param name="scaleText">If set to <c>true</c> the font size is scaled according to the current zoom level.</param>
/// <param name="padding">Padding to apply around the text</param>
protected virtual void DrawLabel(Graphics graphics, string text, Font font, Color foreColor, Color backColor, ContentAlignment textAlign, Rectangle bounds, bool scaleText, Padding padding)
{
TextFormatFlags flags;
if (scaleText)
{
font = new Font(font.FontFamily, (float)(font.Size * this.ZoomFactor), font.Style);
}
flags = TextFormatFlags.NoPrefix | TextFormatFlags.WordEllipsis | TextFormatFlags.WordBreak | TextFormatFlags.NoPadding;
switch (textAlign)
{
case ContentAlignment.TopLeft:
case ContentAlignment.MiddleLeft:
case ContentAlignment.BottomLeft:
flags |= TextFormatFlags.Left;
break;
case ContentAlignment.TopRight:
case ContentAlignment.MiddleRight:
case ContentAlignment.BottomRight:
flags |= TextFormatFlags.Right;
break;
default:
flags |= TextFormatFlags.HorizontalCenter;
break;
}
switch (textAlign)
{
case ContentAlignment.TopCenter:
case ContentAlignment.TopLeft:
case ContentAlignment.TopRight:
flags |= TextFormatFlags.Top;
break;
case ContentAlignment.BottomCenter:
case ContentAlignment.BottomLeft:
case ContentAlignment.BottomRight:
flags |= TextFormatFlags.Bottom;
break;
default:
flags |= TextFormatFlags.VerticalCenter;
break;
}
if (padding.Horizontal != 0 || padding.Vertical != 0)
{
Size size;
int x;
int y;
int width;
int height;
size = TextRenderer.MeasureText(graphics, text, font, bounds.Size, flags);
width = size.Width;
height = size.Height;
switch (textAlign)
{
case ContentAlignment.TopLeft:
x = bounds.Left + padding.Left;
y = bounds.Top + padding.Top;
break;
case ContentAlignment.TopCenter:
x = bounds.Left + padding.Left + ((bounds.Width - width) / 2 - padding.Right);
y = bounds.Top + padding.Top;
break;
case ContentAlignment.TopRight:
x = bounds.Right - (padding.Right + width);
y = bounds.Top + padding.Top;
break;
case ContentAlignment.MiddleLeft:
x = bounds.Left + padding.Left;
y = bounds.Top + padding.Top + (bounds.Height - height) / 2;
break;
case ContentAlignment.MiddleCenter:
x = bounds.Left + padding.Left + ((bounds.Width - width) / 2 - padding.Right);
y = bounds.Top + padding.Top + (bounds.Height - height) / 2;
break;
case ContentAlignment.MiddleRight:
x = bounds.Right - (padding.Right + width);
y = bounds.Top + padding.Top + (bounds.Height - height) / 2;
break;
case ContentAlignment.BottomLeft:
x = bounds.Left + padding.Left;
y = bounds.Bottom - (padding.Bottom + height);
break;
case ContentAlignment.BottomCenter:
x = bounds.Left + padding.Left + ((bounds.Width - width) / 2 - padding.Right);
y = bounds.Bottom - (padding.Bottom + height);
break;
case ContentAlignment.BottomRight:
x = bounds.Right - (padding.Right + width);
y = bounds.Bottom - (padding.Bottom + height);
break;
default:
throw new ArgumentOutOfRangeException(nameof(textAlign));
}
if (backColor != Color.Empty && backColor.A > 0)
{
using (Brush brush = new SolidBrush(backColor))
{
graphics.FillRectangle(brush, x - padding.Left, y - padding.Top, width + padding.Horizontal, height + padding.Vertical);
}
}
bounds = new Rectangle(x, y, width, height);
//bounds = new Rectangle(bounds.Left + padding.Left, bounds.Top + padding.Top, bounds.Width - padding.Horizontal, bounds.Height - padding.Vertical);
}
TextRenderer.DrawText(graphics, text, font, bounds, foreColor, backColor, flags);
if (scaleText)
{
font.Dispose();
}
}
/// <summary>
/// Draws a pixel grid.
/// </summary>
/// <param name="g">The graphics to draw the grid to.</param>
protected virtual void DrawPixelGrid(Graphics g)
{
float pixelSize;
pixelSize = (float)this.ZoomFactor;
if (pixelSize > this.PixelGridThreshold)
{
Rectangle viewport;
float offsetX;
float offsetY;
viewport = this.GetImageViewPort();
offsetX = Math.Abs(this.AutoScrollPosition.X) % pixelSize;
offsetY = Math.Abs(this.AutoScrollPosition.Y) % pixelSize;
using (Pen pen = new Pen(this.PixelGridColor)
{
DashStyle = DashStyle.Dot
})
{
for (float x = viewport.Left + pixelSize - offsetX; x < viewport.Right; x += pixelSize)
{
g.DrawLine(pen, x, viewport.Top, x, viewport.Bottom);
}
for (float y = viewport.Top + pixelSize - offsetY; y < viewport.Bottom; y += pixelSize)
{
g.DrawLine(pen, viewport.Left, y, viewport.Right, y);
}
g.DrawRectangle(pen, viewport);
}
}
}
/// <summary>
/// Draws the selection region.
/// </summary>
/// <param name="e">
/// The <see cref="System.Windows.Forms.PaintEventArgs" /> instance containing the event data.
/// </param>
protected virtual void DrawSelection(PaintEventArgs e)
{
RectangleF rect;
e.Graphics.SetClip(this.GetInsideViewPort(true));
rect = this.GetOffsetRectangle(this.SelectionRegion);
using (Brush brush = new SolidBrush(Color.FromArgb(128, this.SelectionColor)))
{
e.Graphics.FillRectangle(brush, rect);
}
using (Pen pen = new Pen(this.SelectionColor))
{
e.Graphics.DrawRectangle(pen, rect.X, rect.Y, rect.Width, rect.Height);
}
e.Graphics.ResetClip();
}
/// <summary>
/// Draws the text.
/// </summary>
/// <param name="e">The <see cref="PaintEventArgs"/> instance containing the event data.</param>
protected virtual void DrawText(PaintEventArgs e)
{
Rectangle bounds;
bounds = this.TextDisplayMode == ImageBoxGridDisplayMode.Client ? this.GetInsideViewPort() : this.GetImageViewPort();
this.DrawLabel(e.Graphics, this.Text, this.Font, this.ForeColor, this.TextBackColor, this.TextAlign, bounds, this.ScaleText, this.TextPadding);
}
/// <summary>
/// Completes an ongoing selection or drag operation.
/// </summary>
protected virtual void EndDrag()
{
this.IsSelecting = false;
this.OnSelected(EventArgs.Empty);
}
/// <summary>
/// Gets a cursor suitable for the current state of the control
/// </summary>
/// <param name="location">The mouse cursor position in client co-ordinates.</param>
/// <returns>
/// A <see cref="Cursor"/> object suitable for the current state of the control
/// </returns>
protected virtual Cursor GetCursor(Point location)
{
Cursor cursor;
switch (_panStyle)
{
case ImageBoxPanStyle.None:
cursor = Cursors.Default;
break;
case ImageBoxPanStyle.Standard:
cursor = Cursors.SizeAll;
break;
case ImageBoxPanStyle.Free:
switch (this.GetPanDirection(location))
{
case ImageBoxPanDirection.None:
cursor = _panAllCursor;
break;
case ImageBoxPanDirection.Up:
cursor = Cursors.PanNorth;
break;
case ImageBoxPanDirection.Down:
cursor = Cursors.PanSouth;
break;
case ImageBoxPanDirection.Left:
cursor = Cursors.PanWest;
break;
case ImageBoxPanDirection.Right:
cursor = Cursors.PanEast;
break;
default:
cursor = _panAllCursor;
break;
}
break;
default:
cursor = Cursors.Default;
break;
}
return cursor;
}
/// <summary>
/// Gets an offset based on the current image border style.
/// </summary>
/// <returns></returns>
protected virtual int GetImageBorderOffset()
{
int offset;
switch (this.ImageBorderStyle)
{
case ImageBoxBorderStyle.FixedSingle:
offset = 1;
break;
case ImageBoxBorderStyle.FixedSingleDropShadow:
offset = this.DropShadowSize + 1;
break;
default:
offset = 0;
break;
}
return offset;
}
/// <summary>
/// Gets the interpolation mode used to render the image.
/// </summary>
/// <returns>
/// The interpolation mode.
/// </returns>
/// <remarks>Returns the value of the <see cref="InterpolationMode"/> property, unless this is set to <code>InterpolationMode.Default</code>, in which case it will use <code>InterpolationMode.HighQualityBicubic</code> for zoomed images otherwise <code>InterpolationMode.NearestNeighbor</code>.</remarks>
protected virtual InterpolationMode GetInterpolationMode()
{
InterpolationMode mode;
mode = this.InterpolationMode;
if (mode == InterpolationMode.Default)
{
// ReSharper disable once ConvertIfStatementToConditionalTernaryExpression
if (this.Zoom < 100)
{
// TODO: Check to see if we should cherry pick other modes depending on how much the image is actually zoomed
mode = InterpolationMode.HighQualityBicubic;
}
else
{
mode = InterpolationMode.NearestNeighbor;
}
}
return mode;
}
/// <summary>
/// Determines whether the specified key is a regular input key or a special key that requires preprocessing.
/// </summary>
/// <param name="keyData">
/// One of the <see cref="T:System.Windows.Forms.Keys" /> values.
/// </param>
/// <returns>
/// true if the specified key is a regular input key; otherwise, false.
/// </returns>
protected override bool IsInputKey(Keys keyData)
{
bool result;
if ((keyData & Keys.Right) == Keys.Right | (keyData & Keys.Left) == Keys.Left | (keyData & Keys.Up) == Keys.Up | (keyData & Keys.Down) == Keys.Down)
{
result = true;
}
else
{
result = base.IsInputKey(keyData);
}
return result;
}
/// <summary>
/// Raises the <see cref="AllowClickZoomChanged" /> event.
/// </summary>
/// <param name="e">
/// The <see cref="System.EventArgs" /> instance containing the event data.
/// </param>
protected virtual void OnAllowClickZoomChanged(EventArgs e)
{
EventHandler handler;
handler = (EventHandler)this.Events[_eventAllowClickZoomChanged];
handler?.Invoke(this, e);
}
/// <summary>
/// Raises the <see cref="AllowDoubleClickChanged" /> event.
/// </summary>
/// <param name="e">
/// The <see cref="EventArgs" /> instance containing the event data.
/// </param>
protected virtual void OnAllowDoubleClickChanged(EventArgs e)
{
EventHandler handler;
this.SetStyle(ControlStyles.StandardDoubleClick, this.AllowDoubleClick);
handler = (EventHandler)this.Events[_eventAllowDoubleClickChanged];
handler?.Invoke(this, e);
}
/// <summary>
/// Raises the <see cref="AllowFreePanChanged" /> event.
/// </summary>
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
protected virtual void OnAllowFreePanChanged(EventArgs e)
{
EventHandler handler;
handler = (EventHandler)this.Events[_eventAllowFreePanChanged];
handler?.Invoke(this, e);
}
/// <summary>
/// Raises the <see cref="AllowUnfocusedMouseWheelChanged" /> event.
/// </summary>
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
protected virtual void OnAllowUnfocusedMouseWheelChanged(EventArgs e)
{
EventHandler handler;
if (this.AllowUnfocusedMouseWheel)
{
// TODO: Not doing any reference counting so there's
// currently no way of disabling the message filter
// after the first time it has been enabled
ImageBoxMouseWheelMessageFilter.Active = true;
}
handler = (EventHandler)this.Events[_eventAllowUnfocusedMouseWheelChanged];
handler?.Invoke(this, e);
}
/// <summary>
/// Raises the <see cref="AllowZoomChanged" /> event.
/// </summary>
/// <param name="e">
/// The <see cref="System.EventArgs" /> instance containing the event data.
/// </param>
protected virtual void OnAllowZoomChanged(EventArgs e)
{
EventHandler handler;
handler = (EventHandler)this.Events[_eventAllowZoomChanged];
handler?.Invoke(this, e);
}
/// <summary>
/// Raises the <see cref="AutoCenterChanged" /> event.
/// </summary>
/// <param name="e">
/// The <see cref="System.EventArgs" /> instance containing the event data.
/// </param>
protected virtual void OnAutoCenterChanged(EventArgs e)
{
EventHandler handler;
this.Invalidate();
handler = (EventHandler)this.Events[_eventAutoCenterChanged];
handler?.Invoke(this, e);
}
/// <summary>
/// Raises the <see cref="AutoPanChanged" /> event.
/// </summary>
/// <param name="e">
/// The <see cref="System.EventArgs" /> instance containing the event data.
/// </param>
protected virtual void OnAutoPanChanged(EventArgs e)
{
EventHandler handler;
handler = (EventHandler)this.Events[_eventAutoPanChanged];
handler?.Invoke(this, e);
}
/// <summary>
/// Raises the <see cref="System.Windows.Forms.Control.BackColorChanged" /> event.
/// </summary>
/// <param name="e">
/// An <see cref="T:System.EventArgs" /> that contains the event data.
/// </param>
protected override void OnBackColorChanged(EventArgs e)
{
base.OnBackColorChanged(e);
this.Invalidate();
}
/// <summary>
/// Raises the <see cref="ScrollControl.BorderStyleChanged" /> event.
/// </summary>
/// <param name="e">
/// The <see cref="EventArgs" /> instance containing the event data.
/// </param>
protected override void OnBorderStyleChanged(EventArgs e)
{
base.OnBorderStyleChanged(e);
this.AdjustLayout();
}
/// <summary>
/// Raises the <see cref="System.Windows.Forms.Control.DockChanged" /> event.
/// </summary>
/// <param name="e">
/// An <see cref="T:System.EventArgs" /> that contains the event data.
/// </param>
protected override void OnDockChanged(EventArgs e)
{
base.OnDockChanged(e);
if (this.Dock != DockStyle.None)
{
this.AutoSize = false;
}
}
/// <summary>
/// Raises the <see cref="DropShadowSizeChanged" /> event.
/// </summary>
/// <param name="e">
/// The <see cref="EventArgs" /> instance containing the event data.
/// </param>
protected virtual void OnDropShadowSizeChanged(EventArgs e)
{
EventHandler handler;
this.Invalidate();
handler = (EventHandler)this.Events[_eventDropShadowSizeChanged];
handler?.Invoke(this, e);
}
/// <summary>
/// Raises the <see cref="E:System.Windows.Forms.Control.FontChanged" /> event.
/// </summary>
/// <param name="e">An <see cref="T:System.EventArgs" /> that contains the event data.</param>
protected override void OnFontChanged(EventArgs e)
{
base.OnFontChanged(e);
this.Invalidate();
}
/// <summary>
/// Raises the <see cref="E:System.Windows.Forms.Control.ForeColorChanged" /> event.
/// </summary>
/// <param name="e">An <see cref="T:System.EventArgs" /> that contains the event data.</param>
protected override void OnForeColorChanged(EventArgs e)
{
base.OnForeColorChanged(e);
this.Invalidate();
}
/// <summary>
/// Raises the <see cref="GridCellSizeChanged" /> event.
/// </summary>
/// <param name="e">
/// The <see cref="System.EventArgs" /> instance containing the event data.
/// </param>
protected virtual void OnGridCellSizeChanged(EventArgs e)
{
EventHandler handler;
this.InitializeGridTile();
handler = (EventHandler)this.Events[_eventGridCellSizeChanged];
handler?.Invoke(this, e);
}
/// <summary>
/// Raises the <see cref="GridColorAlternateChanged" /> event.
/// </summary>
/// <param name="e">
/// The <see cref="System.EventArgs" /> instance containing the event data.
/// </param>
protected virtual void OnGridColorAlternateChanged(EventArgs e)
{
EventHandler handler;
this.InitializeGridTile();
handler = (EventHandler)this.Events[_eventGridColorAlternateChanged];
handler?.Invoke(this, e);
}
/// <summary>
/// Raises the <see cref="GridColorChanged" /> event.
/// </summary>
/// <param name="e">
/// The <see cref="System.EventArgs" /> instance containing the event data.
/// </param>
protected virtual void OnGridColorChanged(EventArgs e)
{
EventHandler handler;
this.InitializeGridTile();
handler = (EventHandler)this.Events[_eventGridColorChanged];
handler?.Invoke(this, e);
}
/// <summary>
/// Raises the <see cref="GridDisplayModeChanged" /> event.
/// </summary>
/// <param name="e">
/// The <see cref="System.EventArgs" /> instance containing the event data.
/// </param>
protected virtual void OnGridDisplayModeChanged(EventArgs e)
{
EventHandler handler;
this.InitializeGridTile();
this.Invalidate();
handler = (EventHandler)this.Events[_eventGridDisplayModeChanged];
handler?.Invoke(this, e);
}
/// <summary>
/// Raises the <see cref="GridScaleChanged" /> event.
/// </summary>
/// <param name="e">
/// The <see cref="System.EventArgs" /> instance containing the event data.
/// </param>
protected virtual void OnGridScaleChanged(EventArgs e)
{
EventHandler handler;
this.InitializeGridTile();
handler = (EventHandler)this.Events[_eventGridScaleChanged];
handler?.Invoke(this, e);
}
/// <summary>
/// Raises the <see cref="ImageBorderColorChanged" /> event.
/// </summary>
/// <param name="e">
/// The <see cref="EventArgs" /> instance containing the event data.
/// </param>
protected virtual void OnImageBorderColorChanged(EventArgs e)
{
EventHandler handler;
this.Invalidate();
handler = (EventHandler)this.Events[_eventImageBorderColorChanged];
handler?.Invoke(this, e);
}
/// <summary>
/// Raises the <see cref="ImageBorderStyleChanged" /> event.
/// </summary>
/// <param name="e">
/// The <see cref="EventArgs" /> instance containing the event data.
/// </param>
protected virtual void OnImageBorderStyleChanged(EventArgs e)
{
EventHandler handler;
this.Invalidate();
handler = (EventHandler)this.Events[_eventImageBorderStyleChanged];
handler?.Invoke(this, e);
}
/// <summary>
/// Raises the <see cref="ImageChanged" /> event.
/// </summary>
/// <param name="e">
/// The <see cref="System.EventArgs" /> instance containing the event data.
/// </param>
protected virtual void OnImageChanged(EventArgs e)
{
EventHandler handler;
this.IsAnimating = false;
if (this.Image != null)
{
try
{
this.IsAnimating = ImageAnimator.CanAnimate(this.Image);
if (this.IsAnimating)
{
ImageAnimator.Animate(this.Image, this.OnFrameChangedHandler);
}
}
catch (ArgumentException)
{
// probably a disposed image, ignore
}
}
this.AdjustLayout();
handler = (EventHandler)this.Events[_eventImageChanged];
handler?.Invoke(this, e);
}
/// <summary>
/// Raises the <see cref="InterpolationModeChanged" /> event.
/// </summary>
/// <param name="e">
/// The <see cref="System.EventArgs" /> instance containing the event data.
/// </param>
protected virtual void OnInterpolationModeChanged(EventArgs e)
{
EventHandler handler;
this.Invalidate();
handler = (EventHandler)this.Events[_eventInterpolationModeChanged];
handler?.Invoke(this, e);
}
/// <summary>
/// Raises the <see cref="InvertMouseChanged" /> event.
/// </summary>
/// <param name="e">
/// The <see cref="System.EventArgs" /> instance containing the event data.
/// </param>
protected virtual void OnInvertMouseChanged(EventArgs e)
{
EventHandler handler;
handler = (EventHandler)this.Events[_eventInvertMouseChanged];
handler?.Invoke(this, e);
}
/// <summary>
/// Raises the <see cref="System.Windows.Forms.Control.KeyDown" /> event.
/// </summary>
/// <param name="e">
/// A <see cref="T:System.Windows.Forms.KeyEventArgs" /> that contains the event data.
/// </param>
protected override void OnKeyDown(KeyEventArgs e)
{
base.OnKeyDown(e);
this.ProcessScrollingShortcuts(e);
if (this.ShortcutsEnabled && this.AllowZoom && this.SizeMode == ImageBoxSizeMode.Normal)
{
this.ProcessImageShortcuts(e);
}
}
/// <summary>
/// Raises the <see cref="LimitSelectionToImageChanged" /> event.
/// </summary>
/// <param name="e">
/// The <see cref="System.EventArgs" /> instance containing the event data.
/// </param>
protected virtual void OnLimitSelectionToImageChanged(EventArgs e)
{
EventHandler handler;
handler = (EventHandler)this.Events[_eventLimitSelectionToImageChanged];
handler?.Invoke(this, e);
}
/// <summary>
/// Raises the <see cref="System.Windows.Forms.Control.MouseDown" /> event.
/// </summary>
/// <param name="e">
/// A <see cref="T:System.Windows.Forms.MouseEventArgs" /> that contains the event data.
/// </param>
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
if (!this.Focused)
{
this.Focus();
}
if (e.Button != MouseButtons.None)
{
if (_panStyle == ImageBoxPanStyle.Free)
{
// already panning, abort
this.ProcessPanEvents(ImageBoxPanStyle.None);
}
else
{
_mouseDownStart = NativeMethods.GetTickCount();
if (AllowFreePan && e.Button is MouseButtons.Middle)
{
this.ProcessPanning(e);
}
}
}
this.SetCursor(e.Location);
}
/// <summary>
/// Raises the <see cref="System.Windows.Forms.Control.MouseMove" /> event.
/// </summary>
/// <param name="e">
/// A <see cref="T:System.Windows.Forms.MouseEventArgs" /> that contains the event data.
/// </param>
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
if (e.Button != MouseButtons.None)
{
this.ProcessPanning(e);
this.ProcessSelection(e);
}
this.SetCursor(e.Location);
}
/// <summary>
/// Raises the <see cref="System.Windows.Forms.Control.MouseUp" /> event.
/// </summary>
/// <param name="e">
/// A <see cref="T:System.Windows.Forms.MouseEventArgs" /> that contains the event data.
/// </param>
protected override void OnMouseUp(MouseEventArgs e)
{
bool doNotProcessClick;
base.OnMouseUp(e);
doNotProcessClick = _panStyle != ImageBoxPanStyle.None || this.IsSelecting;
if (_panStyle == ImageBoxPanStyle.Standard || _panStyle == ImageBoxPanStyle.Free && NativeMethods.GetTickCount() > (_mouseDownStart + SystemInformation.DoubleClickTime))
{
this.ProcessPanEvents(ImageBoxPanStyle.None);
}
if (this.IsSelecting)
{
this.EndDrag();
}
this.WasDragCancelled = false;
if (!doNotProcessClick && this.AllowZoom && this.AllowClickZoom && _panStyle == ImageBoxPanStyle.None && this.SizeMode == ImageBoxSizeMode.Normal)
{
if (e.Button == MouseButtons.Left && ModifierKeys == Keys.None)
{
this.ProcessMouseZoom(true, e.Location);
}
else if (e.Button == MouseButtons.Right || e.Button == MouseButtons.Left && ModifierKeys != Keys.None)
{
this.ProcessMouseZoom(false, e.Location);
}
}
}
/// <summary>
/// Raises the <see cref="System.Windows.Forms.Control.MouseWheel" /> event.
/// </summary>
/// <param name="e">
/// A <see cref="T:System.Windows.Forms.MouseEventArgs" /> that contains the event data.
/// </param>
protected override void OnMouseWheel(MouseEventArgs e)
{
base.OnMouseWheel(e);
if (MouseWheelMode == ImageBoxMouseWheelMode.Zoom)
{
DoMouseWheelZoom(e);
}
else if (MouseWheelMode == ImageBoxMouseWheelMode.ScrollAndZoom)
{
if (ModifierKeys == Keys.Control)
{
DoMouseWheelZoom(e);
}
else if (VScroll && ModifierKeys == Keys.None)
{
int scrollDelta = SystemInformation.MouseWheelScrollLines * VerticalScroll.SmallChange;
ScrollTo(HorizontalScroll.Value, VerticalScroll.Value + ((e.Delta > 0) ? -scrollDelta : scrollDelta));
}
else if (HScroll && ModifierKeys == Keys.Shift)
{
int scrollDelta = SystemInformation.MouseWheelScrollLines * HorizontalScroll.SmallChange;
ScrollTo(HorizontalScroll.Value + ((e.Delta > 0) ? -scrollDelta : scrollDelta), VerticalScroll.Value);
}
}
}
/// <summary>
/// Raises the <see cref="MouseWheelModeChanged" /> event.
/// </summary>
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
protected virtual void OnMouseWheelModeChanged(EventArgs e)
{
EventHandler handler;
handler = (EventHandler)this.Events[_eventMouseWheelModeChanged];
handler?.Invoke(this, e);
}
/// <summary>
/// Raises the <see cref="System.Windows.Forms.Control.PaddingChanged" /> event.
/// </summary>
/// <param name="e">
/// An <see cref="T:System.EventArgs" /> that contains the event data.
/// </param>
protected override void OnPaddingChanged(EventArgs e)
{
base.OnPaddingChanged(e);
this.AdjustLayout();
}
/// <summary>
/// Raises the <see cref="System.Windows.Forms.Control.Paint" /> event.
/// </summary>
/// <param name="e">
/// A <see cref="T:System.Windows.Forms.PaintEventArgs" /> that contains the event data.
/// </param>
protected override void OnPaint(PaintEventArgs e)
{
if (this.AllowPainting)
{
// draw the background
this.DrawBackground(e);
// draw the image
if (!this.ViewSize.IsEmpty)
{
this.DrawImageBorder(e.Graphics);
}
if (this.VirtualMode)
{
this.OnVirtualDraw(e);
}
else if (this.Image != null)
{
this.DrawImage(e.Graphics);
}
// draw the grid
if (this.ShowPixelGrid && !this.VirtualMode)
{
this.DrawPixelGrid(e.Graphics);
}
// draw the selection
if (this.SelectionRegion != Rectangle.Empty)
{
this.DrawSelection(e);
}
// text
if (!string.IsNullOrEmpty(this.Text) && this.TextDisplayMode != ImageBoxGridDisplayMode.None)
{
this.DrawText(e);
}
if (_panStyle == ImageBoxPanStyle.Free)
{
this.DrawPanAllSymbol(e);
}
base.OnPaint(e);
}
}
/// <summary>
/// Raises the <see cref="PanEnd" /> event.
/// </summary>
/// <param name="e">
/// The <see cref="System.EventArgs" /> instance containing the event data.
/// </param>
protected virtual void OnPanEnd(EventArgs e)
{
EventHandler handler;
handler = (EventHandler)this.Events[_eventPanEnd];
handler?.Invoke(this, e);
}
/// <summary>
/// Raises the <see cref="PanModeChanged" /> event.
/// </summary>
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
protected virtual void OnPanModeChanged(EventArgs e)
{
EventHandler handler;
handler = (EventHandler)this.Events[_eventPanModeChanged];
handler?.Invoke(this, e);
}
/// <summary>
/// Raises the <see cref="PanStart" /> event.
/// </summary>
/// <param name="e">
/// The <see cref="System.ComponentModel.CancelEventArgs" /> instance containing the event data.
/// </param>
protected virtual void OnPanStart(CancelEventArgs e)
{
EventHandler handler;
handler = (EventHandler)this.Events[_eventPanStart];
handler?.Invoke(this, e);
}
/// <summary>
/// Raises the <see cref="System.Windows.Forms.Control.ParentChanged" /> event.
/// </summary>
/// <param name="e">
/// An <see cref="T:System.EventArgs" /> that contains the event data.
/// </param>
protected override void OnParentChanged(EventArgs e)
{
base.OnParentChanged(e);
this.AdjustLayout();
}
/// <summary>
/// Raises the <see cref="PixelGridColorChanged" /> event.
/// </summary>
/// <param name="e">
/// The <see cref="EventArgs" /> instance containing the event data.
/// </param>
protected virtual void OnPixelGridColorChanged(EventArgs e)
{
EventHandler handler;
this.Invalidate();
handler = (EventHandler)this.Events[_eventPixelGridColorChanged];
handler?.Invoke(this, e);
}
/// <summary>
/// Raises the <see cref="PixelGridThresholdChanged" /> event.
/// </summary>
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
protected virtual void OnPixelGridThresholdChanged(EventArgs e)
{
EventHandler handler;
handler = (EventHandler)this.Events[_eventPixelGridThresholdChanged];
handler?.Invoke(this, e);
}
/// <summary>
/// Raises the <see cref="System.Windows.Forms.Control.Resize" /> event.
/// </summary>
/// <param name="e">
/// An <see cref="T:System.EventArgs" /> that contains the event data.
/// </param>
protected override void OnResize(EventArgs e)
{
this.AdjustLayout();
base.OnResize(e);
}
/// <summary>
/// Raises the <see cref="ScaleTextChanged" /> event.
/// </summary>
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
protected virtual void OnScaleTextChanged(EventArgs e)
{
EventHandler handler;
this.Invalidate();
handler = (EventHandler)this.Events[_eventScaleTextChanged];
handler?.Invoke(this, e);
}
/// <summary>
/// Raises the <see cref="System.Windows.Forms.ScrollableControl.Scroll" /> event.
/// </summary>
/// <param name="se">
/// A <see cref="T:System.Windows.Forms.ScrollEventArgs" /> that contains the event data.
/// </param>
protected override void OnScroll(ScrollEventArgs se)
{
this.Invalidate();
base.OnScroll(se);
}
/// <summary>
/// Raises the <see cref="Selected" /> event.
/// </summary>
/// <param name="e">
/// The <see cref="System.EventArgs" /> instance containing the event data.
/// </param>
protected virtual void OnSelected(EventArgs e)
{
EventHandler<EventArgs> handler;
switch (this.SelectionMode)
{
case ImageBoxSelectionMode.Zoom:
if (this.SelectionRegion.Width > SelectionDeadZone && this.SelectionRegion.Height > SelectionDeadZone)
{
this.ZoomToRegion(this.SelectionRegion);
this.SelectNone();
}
break;
}
handler = (EventHandler<EventArgs>)this.Events[_eventSelected];
handler?.Invoke(this, e);
}
/// <summary>
/// Raises the <see cref="Selecting" /> event.
/// </summary>
/// <param name="e">
/// The <see cref="System.EventArgs" /> instance containing the event data.
/// </param>
protected virtual void OnSelecting(ImageBoxCancelEventArgs e)
{
EventHandler<ImageBoxCancelEventArgs> handler;
handler = (EventHandler<ImageBoxCancelEventArgs>)this.Events[_eventSelecting];
handler?.Invoke(this, e);
}
/// <summary>
/// Raises the <see cref="SelectionColorChanged" /> event.
/// </summary>
/// <param name="e">
/// The <see cref="System.EventArgs" /> instance containing the event data.
/// </param>
protected virtual void OnSelectionColorChanged(EventArgs e)
{
EventHandler handler;
handler = (EventHandler)this.Events[_eventSelectionColorChanged];
handler?.Invoke(this, e);
}
/// <summary>
/// Raises the <see cref="SelectionModeChanged" /> event.
/// </summary>
/// <param name="e">
/// The <see cref="System.EventArgs" /> instance containing the event data.
/// </param>
protected virtual void OnSelectionModeChanged(EventArgs e)
{
EventHandler handler;
handler = (EventHandler)this.Events[_eventSelectionModeChanged];
handler?.Invoke(this, e);
}
/// <summary>
/// Raises the <see cref="SelectionRegionChanged" /> event.
/// </summary>
/// <param name="e">
/// The <see cref="System.EventArgs" /> instance containing the event data.
/// </param>
protected virtual void OnSelectionRegionChanged(EventArgs e)
{
EventHandler handler;
this.Invalidate();
handler = (EventHandler)this.Events[_eventSelectionRegionChanged];
handler?.Invoke(this, e);
}
/// <summary>
/// Raises the <see cref="ShortcutsEnabledChanged" /> event.
/// </summary>
/// <param name="e">
/// The <see cref="EventArgs" /> instance containing the event data.
/// </param>
protected virtual void OnShortcutsEnabledChanged(EventArgs e)
{
EventHandler handler;
handler = (EventHandler)this.Events[_eventShortcutsEnabledChanged];
handler?.Invoke(this, e);
}
/// <summary>
/// Raises the <see cref="ShowPixelGridChanged" /> event.
/// </summary>
/// <param name="e">
/// The <see cref="EventArgs" /> instance containing the event data.
/// </param>
protected virtual void OnShowPixelGridChanged(EventArgs e)
{
EventHandler handler;
this.Invalidate();
handler = (EventHandler)this.Events[_eventShowPixelGridChanged];
handler?.Invoke(this, e);
}
/// <summary>
/// Raises the <see cref="SizeModeChanged" /> event.
/// </summary>
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
protected virtual void OnSizeModeChanged(EventArgs e)
{
EventHandler handler;
this.AdjustLayout();
handler = (EventHandler)this.Events[_eventSizeModeChanged];
handler?.Invoke(this, e);
}
/// <summary>
/// Raises the <see cref="SizeToFitChanged" /> event.
/// </summary>
/// <param name="e">
/// The <see cref="System.EventArgs" /> instance containing the event data.
/// </param>
protected virtual void OnSizeToFitChanged(EventArgs e)
{
EventHandler handler;
this.AdjustLayout();
handler = (EventHandler)this.Events[_eventSizeToFitChanged];
handler?.Invoke(this, e);
}
/// <summary>
/// Raises the <see cref="TextAlignChanged" /> event.
/// </summary>
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
protected virtual void OnTextAlignChanged(EventArgs e)
{
EventHandler handler;
this.Invalidate();
handler = (EventHandler)this.Events[_eventTextAlignChanged];
handler?.Invoke(this, e);
}
/// <summary>
/// Raises the <see cref="TextBackColorChanged" /> event.
/// </summary>
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
protected virtual void OnTextBackColorChanged(EventArgs e)
{
EventHandler handler;
this.Invalidate();
handler = (EventHandler)this.Events[_eventTextBackColorChanged];
handler?.Invoke(this, e);
}
/// <summary>
/// Raises the <see cref="E:System.Windows.Forms.Control.TextChanged" /> event.
/// </summary>
/// <param name="e">An <see cref="T:System.EventArgs" /> that contains the event data.</param>
protected override void OnTextChanged(EventArgs e)
{
base.OnTextChanged(e);
this.Invalidate();
}
/// <summary>
/// Raises the <see cref="TextDisplayModeChanged" /> event.
/// </summary>
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
protected virtual void OnTextDisplayModeChanged(EventArgs e)
{
EventHandler handler;
this.Invalidate();
handler = (EventHandler)this.Events[_eventTextDisplayModeChanged];
handler?.Invoke(this, e);
}
/// <summary>
/// Raises the <see cref="TextPaddingChanged" /> event.
/// </summary>
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
protected virtual void OnTextPaddingChanged(EventArgs e)
{
EventHandler handler;
handler = (EventHandler)this.Events[_eventTextPaddingChanged];
this.Invalidate();
handler?.Invoke(this, e);
}
/// <summary>
/// Raises the <see cref="VirtualDraw" /> event.
/// </summary>
/// <param name="e">
/// The <see cref="PaintEventArgs" /> instance containing the event data.
/// </param>
protected virtual void OnVirtualDraw(PaintEventArgs e)
{
PaintEventHandler handler;
handler = (PaintEventHandler)this.Events[_eventVirtualDraw];
handler?.Invoke(this, e);
}
/// <summary>
/// Raises the <see cref="VirtualModeChanged" /> event.
/// </summary>
/// <param name="e">
/// The <see cref="EventArgs" /> instance containing the event data.
/// </param>
protected virtual void OnVirtualModeChanged(EventArgs e)
{
EventHandler handler;
this.AdjustLayout();
handler = (EventHandler)this.Events[_eventVirtualModeChanged];
handler?.Invoke(this, e);
}
/// <summary>
/// Raises the <see cref="VirtualSizeChanged" /> event.
/// </summary>
/// <param name="e">
/// The <see cref="EventArgs" /> instance containing the event data.
/// </param>
protected virtual void OnVirtualSizeChanged(EventArgs e)
{
EventHandler handler;
this.AdjustLayout();
handler = (EventHandler)this.Events[_eventVirtualSizeChanged];
handler?.Invoke(this, e);
}
/// <summary>
/// Raises the <see cref="ZoomChanged" /> event.
/// </summary>
/// <param name="e">
/// The <see cref="System.EventArgs" /> instance containing the event data.
/// </param>
protected virtual void OnZoomChanged(EventArgs e)
{
EventHandler handler;
this.AdjustLayout();
handler = (EventHandler)this.Events[_eventZoomChanged];
handler?.Invoke(this, e);
}
/// <summary>
/// Raises the <see cref="Zoomed" /> event.
/// </summary>
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
protected virtual void OnZoomed(ImageBoxZoomEventArgs e)
{
EventHandler<ImageBoxZoomEventArgs> handler;
handler = (EventHandler<ImageBoxZoomEventArgs>)this.Events[_eventZoomed];
handler?.Invoke(this, e);
}
/// <summary>
/// Raises the <see cref="ZoomLevelsChanged" /> event.
/// </summary>
/// <param name="e">
/// The <see cref="EventArgs" /> instance containing the event data.
/// </param>
protected virtual void OnZoomLevelsChanged(EventArgs e)
{
EventHandler handler;
handler = (EventHandler)this.Events[_eventZoomLevelsChanged];
handler?.Invoke(this, e);
}
/// <summary>
/// Processes shortcut keys for zooming and selection
/// </summary>
/// <param name="e">
/// The <see cref="KeyEventArgs" /> instance containing the event data.
/// </param>
protected virtual void ProcessImageShortcuts(KeyEventArgs e)
{
Point currentPixel;
int currentZoom;
Point relativePoint;
relativePoint = this.CenterPoint;
currentPixel = this.PointToImage(relativePoint);
currentZoom = this.Zoom;
switch (e.KeyCode)
{
case Keys.Home:
if (this.AllowZoom)
{
this.PerformActualSize(ImageBoxActionSources.User);
}
break;
case Keys.PageDown:
case Keys.Oemplus:
if (this.AllowZoom)
{
this.PerformZoomIn(ImageBoxActionSources.User, true);
}
break;
case Keys.PageUp:
case Keys.OemMinus:
if (this.AllowZoom)
{
this.PerformZoomOut(ImageBoxActionSources.User, true);
}
break;
}
if (this.Zoom != currentZoom)
{
this.ScrollTo(currentPixel, relativePoint);
}
}
/// <summary>
/// Processes zooming with the mouse. Attempts to keep the pre-zoom image pixel under the mouse after the zoom has completed.
/// </summary>
/// <param name="isZoomIn">
/// if set to <c>true</c> zoom in, otherwise zoom out.
/// </param>
/// <param name="cursorPosition">The cursor position.</param>
protected virtual void ProcessMouseZoom(bool isZoomIn, Point cursorPosition)
{
this.PerformZoom(isZoomIn ? ImageBoxZoomActions.ZoomIn : ImageBoxZoomActions.ZoomOut, ImageBoxActionSources.User, true, cursorPosition);
}
/// <summary>
/// Performs mouse based panning
/// </summary>
/// <param name="e">
/// The <see cref="MouseEventArgs" /> instance containing the event data.
/// </param>
protected virtual void ProcessPanning(MouseEventArgs e)
{
if (this.CanPan(e.Button))
{
if (_panStyle == ImageBoxPanStyle.None && (this.HScroll || this.VScroll))
{
_startMousePosition = e.Location;
this.ProcessPanEvents(e.Button == MouseButtons.Middle && _allowFreePan ? ImageBoxPanStyle.Free : ImageBoxPanStyle.Standard);
}
}
if (_panStyle == ImageBoxPanStyle.Standard)
{
int x;
int y;
Point position;
if (!this.InvertMouse)
{
x = -_startScrollPosition.X + (_startMousePosition.X - e.Location.X);
y = -_startScrollPosition.Y + (_startMousePosition.Y - e.Location.Y);
}
else
{
x = -(_startScrollPosition.X + (_startMousePosition.X - e.Location.X));
y = -(_startScrollPosition.Y + (_startMousePosition.Y - e.Location.Y));
}
position = new Point(x, y);
this.UpdateScrollPosition(position);
}
}
/// <summary>
/// Processes shortcut keys for scrolling
/// </summary>
/// <param name="e">
/// The <see cref="KeyEventArgs" /> instance containing the event data.
/// </param>
protected virtual void ProcessScrollingShortcuts(KeyEventArgs e)
{
switch (e.KeyCode)
{
case Keys.Left:
this.AdjustScroll(-(e.Modifiers == Keys.None ? this.HorizontalScroll.SmallChange : this.HorizontalScroll.LargeChange), 0);
break;
case Keys.Right:
this.AdjustScroll(e.Modifiers == Keys.None ? this.HorizontalScroll.SmallChange : this.HorizontalScroll.LargeChange, 0);
break;
case Keys.Up:
this.AdjustScroll(0, -(e.Modifiers == Keys.None ? this.VerticalScroll.SmallChange : this.VerticalScroll.LargeChange));
break;
case Keys.Down:
this.AdjustScroll(0, e.Modifiers == Keys.None ? this.VerticalScroll.SmallChange : this.VerticalScroll.LargeChange);
break;
}
}
/// <summary>
/// Performs mouse based region selection
/// </summary>
/// <param name="e">
/// The <see cref="MouseEventArgs" /> instance containing the event data.
/// </param>
protected virtual void ProcessSelection(MouseEventArgs e)
{
if (this.SelectionMode != ImageBoxSelectionMode.None && e.Button == MouseButtons.Left && !this.WasDragCancelled)
{
if (!this.IsSelecting)
{
this.StartDrag(e);
}
if (this.IsSelecting)
{
float x;
float y;
float w;
float h;
Point imageOffset;
RectangleF selection;
imageOffset = this.GetImageViewPort().
Location;
if (e.X < _startMousePosition.X)
{
x = e.X;
w = _startMousePosition.X - e.X;
}
else
{
x = _startMousePosition.X;
w = e.X - _startMousePosition.X;
}
if (e.Y < _startMousePosition.Y)
{
y = e.Y;
h = _startMousePosition.Y - e.Y;
}
else
{
y = _startMousePosition.Y;
h = e.Y - _startMousePosition.Y;
}
x = x - imageOffset.X - this.AutoScrollPosition.X;
y = y - imageOffset.Y - this.AutoScrollPosition.Y;
x = x / (float)this.ZoomFactor;
y = y / (float)this.ZoomFactor;
w = w / (float)this.ZoomFactor;
h = h / (float)this.ZoomFactor;
if (w != 0 && h != 0)
{
selection = new RectangleF(x, y, w, h);
if (this.LimitSelectionToImage)
{
selection = this.FitRectangle(selection);
}
this.SelectionRegion = selection;
}
}
}
}
/// <summary>
/// Resets the <see cref="SizeMode"/> property whilsts retaining the original <see cref="Zoom"/>.
/// </summary>
protected void RestoreSizeMode()
{
if (this.SizeMode != ImageBoxSizeMode.Normal)
{
int previousZoom;
previousZoom = this.Zoom;
this.SizeMode = ImageBoxSizeMode.Normal;
this.Zoom = previousZoom; // Stop the zoom getting reset to 100% before calculating the new zoom
}
}
/// <summary>
/// Initializes a selection or drag operation.
/// </summary>
/// <param name="e">The <see cref="MouseEventArgs"/> instance containing the event data.</param>
protected virtual void StartDrag(MouseEventArgs e)
{
ImageBoxCancelEventArgs args;
args = new ImageBoxCancelEventArgs(e.Location);
this.OnSelecting(args);
this.WasDragCancelled = args.Cancel;
this.IsSelecting = !args.Cancel;
if (this.IsSelecting)
{
this.SelectNone();
_startMousePosition = e.Location;
}
}
/// <summary>
/// Updates the scroll position.
/// </summary>
/// <param name="position">The position.</param>
protected virtual void UpdateScrollPosition(Point position)
{
this.AutoScrollPosition = position;
this.Invalidate();
this.OnScroll(new ScrollEventArgs(ScrollEventType.EndScroll, 0));
}
private bool CanPan(MouseButtons button)
{
return (this.HScroll || this.VScroll) && (_panMode & (ImageBoxPanMode)button) != 0 && !this.ViewSize.IsEmpty && (_selectionMode == ImageBoxSelectionMode.None || button != MouseButtons.Left);
}
private void CreateTimer()
{
_freePanTimer = new Timer
{
Enabled = true,
Interval = _freePanTimerInterval
};
_freePanTimer.Tick += this.FreePanTimerTickHandler;
_freePanTimer.Start();
}
private void DoMouseWheelZoom(MouseEventArgs e)
{
if (this.AllowZoom && this.SizeMode == ImageBoxSizeMode.Normal)
{
// The MouseWheel event can contain multiple "spins" of the wheel so we need to adjust accordingly
int spins = Math.Abs(e.Delta / SystemInformation.MouseWheelScrollDelta);
// TODO: Really should update the source method to handle multiple increments rather than calling it multiple times
for (int i = 0; i < spins; i++)
{
this.ProcessMouseZoom(e.Delta > 0, e.Location);
}
}
}
private void DrawPanAllSymbol(PaintEventArgs e)
{
Graphics g;
int x;
int y;
g = e.Graphics;
x = _startMousePosition.X - (_panAllSymbol.Width >> 1);
y = _startMousePosition.Y - (_panAllSymbol.Height >> 1);
g.DrawImage(_panAllSymbol, x, y);
}
private void FreePanTimerTickHandler(object sender, EventArgs e)
{
Point location;
ImageBoxPanDirection direction;
int distance;
int ox;
int oy;
location = this.PointToClient(MousePosition);
direction = this.GetPanDirection(location);
distance = this.GetDistance(_startMousePosition.X, _startMousePosition.Y, location.X, location.Y);
ox = 0;
oy = 0;
switch (direction)
{
case ImageBoxPanDirection.Up:
oy = -distance;
break;
case ImageBoxPanDirection.Down:
oy = +distance;
break;
case ImageBoxPanDirection.Left:
ox = -distance;
break;
case ImageBoxPanDirection.Right:
ox = +distance;
break;
}
if (ox != 0 || oy != 0)
{
this.AdjustScroll(ox, oy);
}
}
/// <summary>
/// Gets the distance between two points.
/// </summary>
/// <param name="x1">The first x value.</param>
/// <param name="y1">The first y value.</param>
/// <param name="x2">The second x value.</param>
/// <param name="y2">The second y value.</param>
/// <returns>
/// The distance.
/// </returns>
private int GetDistance(int x1, int y1, int x2, int y2)
{
int dx;
int dy;
double distance;
dx = x2 - x1;
dy = y2 - y1;
distance = Math.Sqrt(dx * dx + dy * dy);
return Convert.ToInt32(distance);
}
/// <summary>
/// Gets the distance between two values.
/// </summary>
/// <param name="x1">The first value.</param>
/// <param name="x2">The second value.</param>
/// <returns>
/// The distance.
/// </returns>
private int GetDistance(int x1, int x2)
{
int dx;
double distance;
dx = x2 - x1;
distance = Math.Sqrt(dx * dx);
return Convert.ToInt32(distance);
}
/// <summary>
/// Gets the size of the image.
/// </summary>
/// <remarks>If an error occurs, for example due to the image being disposed, an empty size is returned</remarks>
/// <returns>Size.</returns>
private Size GetImageSize()
{
Size result;
// HACK: This whole thing stinks. Hey MS, how about an IsDisposed property for images?
if (this.Image != null)
{
try
{
result = this.Image.Size;
}
catch
{
result = Size.Empty;
}
}
else
{
result = Size.Empty;
}
return result;
}
private ImageBoxPanDirection GetPanDirection(Point location)
{
ImageBoxPanDirection result;
int x;
int y;
x = location.X - _startMousePosition.X;
y = location.Y - _startMousePosition.Y;
if (x >= -_panAllDeadSize && x <= _panAllDeadSize && y >= -_panAllDeadSize && y <= _panAllDeadSize)
{
result = ImageBoxPanDirection.None;
}
else
{
int distanceX;
distanceX = location.X - _startMousePosition.X;
if (-y > Math.Abs(distanceX))
{
result = ImageBoxPanDirection.Up;
}
else if (y > Math.Abs(distanceX))
{
result = ImageBoxPanDirection.Down;
}
else
{
result = distanceX < 0 ? ImageBoxPanDirection.Left : ImageBoxPanDirection.Right;
}
}
return result;
}
/// <summary>
/// Returns an appropriate zoom level based on the specified action, relative to the current zoom level.
/// </summary>
/// <param name="action">The action to determine the zoom level.</param>
/// <exception cref="System.ArgumentOutOfRangeException">Thrown if an unsupported action is specified.</exception>
private int GetZoomLevel(ImageBoxZoomActions action)
{
int result;
switch (action)
{
case ImageBoxZoomActions.None:
result = this.Zoom;
break;
case ImageBoxZoomActions.ZoomIn:
result = this.ZoomLevels.NextZoom(this.Zoom);
break;
case ImageBoxZoomActions.ZoomOut:
result = this.ZoomLevels.PreviousZoom(this.Zoom);
break;
case ImageBoxZoomActions.ActualSize:
result = 100;
break;
default:
throw new ArgumentOutOfRangeException(nameof(action));
}
return result;
}
/// <summary>
/// Initializes the grid tile.
/// </summary>
private void InitializeGridTile()
{
_texture?.Dispose();
_gridTile?.Dispose();
if (this.GridDisplayMode != ImageBoxGridDisplayMode.None && this.GridCellSize != 0)
{
if (this.GridScale != ImageBoxGridScale.None)
{
_gridTile = this.CreateGridTileImage(this.GridCellSize, this.GridColor, this.GridColorAlternate);
_texture = new TextureBrush(_gridTile);
}
else
{
_texture = new SolidBrush(this.GridColor);
}
}
this.Invalidate();
}
private void KillTimer()
{
if (_freePanTimer != null)
{
_freePanTimer.Stop();
_freePanTimer.Tick -= this.FreePanTimerTickHandler;
_freePanTimer.Dispose();
_freePanTimer = null;
}
}
/// <summary>
/// Called when the animation frame changes.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="eventArgs">The <see cref="EventArgs"/> instance containing the event data.</param>
private void OnFrameChangedHandler(object sender, EventArgs eventArgs)
{
this.Invalidate();
}
/// <summary>
/// Resets the zoom to 100%.
/// </summary>
/// <param name="source">The source that initiated the action.</param>
private void PerformActualSize(ImageBoxActionSources source)
{
this.SizeMode = ImageBoxSizeMode.Normal;
this.SetZoom(100, ImageBoxZoomActions.ActualSize | (this.Zoom < 100 ? ImageBoxZoomActions.ZoomIn : ImageBoxZoomActions.ZoomOut), source);
}
/// <summary>
/// Performs a zoom action.
/// </summary>
/// <param name="action">The action to perform.</param>
/// <param name="source">The source that initiated the action.</param>
/// <param name="preservePosition"><c>true</c> if the current scrolling position should be preserved relative to the new zoom level, <c>false</c> to reset.</param>
private void PerformZoom(ImageBoxZoomActions action, ImageBoxActionSources source, bool preservePosition)
{
this.PerformZoom(action, source, preservePosition, this.CenterPoint);
}
/// <summary>
/// Performs a zoom action.
/// </summary>
/// <param name="action">The action to perform.</param>
/// <param name="source">The source that initiated the action.</param>
/// <param name="preservePosition"><c>true</c> if the current scrolling position should be preserved relative to the new zoom level, <c>false</c> to reset.</param>
/// <param name="relativePoint">A <see cref="Point"/> describing the current center of the control.</param>
private void PerformZoom(ImageBoxZoomActions action, ImageBoxActionSources source, bool preservePosition, Point relativePoint)
{
Point currentPixel;
int currentZoom;
int newZoom;
currentPixel = this.PointToImage(relativePoint);
currentZoom = this.Zoom;
newZoom = this.GetZoomLevel(action);
this.RestoreSizeMode();
this.SetZoom(newZoom, action, source);
if (preservePosition && this.Zoom != currentZoom)
{
this.ScrollTo(currentPixel, relativePoint);
}
}
/// <summary>
/// Zooms into the image
/// </summary>
/// <param name="source">The source that initiated the action.</param>
/// <param name="preservePosition"><c>true</c> if the current scrolling position should be preserved relative to the new zoom level, <c>false</c> to reset.</param>
private void PerformZoomIn(ImageBoxActionSources source, bool preservePosition)
{
this.PerformZoom(ImageBoxZoomActions.ZoomIn, source, preservePosition);
}
/// <summary>
/// Zooms out of the image
/// </summary>
/// <param name="source">The source that initiated the action.</param>
/// <param name="preservePosition"><c>true</c> if the current scrolling position should be preserved relative to the new zoom level, <c>false</c> to reset.</param>
private void PerformZoomOut(ImageBoxActionSources source, bool preservePosition)
{
this.PerformZoom(ImageBoxZoomActions.ZoomOut, source, preservePosition);
}
/// <summary>
/// Raises either the PanStart or PanEnd events
/// </summary>
/// <param name="panStyle">The new pan style.</param>
private void ProcessPanEvents(ImageBoxPanStyle panStyle)
{
if (_panStyle != panStyle)
{
this.KillTimer();
if (panStyle == ImageBoxPanStyle.None)
{
_panStyle = ImageBoxPanStyle.None;
this.Invalidate();
this.OnPanEnd(EventArgs.Empty);
}
else
{
CancelEventArgs args;
args = new CancelEventArgs();
this.OnPanStart(args);
if (!args.Cancel)
{
_panStyle = panStyle;
if (panStyle == ImageBoxPanStyle.Free)
{
ImageBox.LoadPanResources();
this.CreateTimer();
}
_startScrollPosition = this.AutoScrollPosition;
}
this.Invalidate();
}
}
}
/// <summary>
/// Sets the mouse cursor based on the current control state
/// </summary>
/// <param name="location">The location of the mouse in client co-ordinates.</param>
private void SetCursor(Point location)
{
Cursor cursor;
cursor = this.GetCursor(location);
if (_currentCursor != cursor)
{
_currentCursor = cursor;
// have to use this.Cursor and not Cursor.Current
// otherwise the cursor gets reset back to Default
// after clicking to initiate Free Pan
// As a result, the Cursor property has been hidden
// to discourage users setting it manually
this.Cursor = cursor;
}
}
/// <summary>
/// Updates the current zoom.
/// </summary>
/// <param name="value">The new zoom value.</param>
/// <param name="actions">The zoom actions that caused the value to be updated.</param>
/// <param name="source">The source of the zoom operation.</param>
private void SetZoom(int value, ImageBoxZoomActions actions, ImageBoxActionSources source)
{
int previousZoom;
previousZoom = this.Zoom;
if (value < MinZoom)
{
value = MinZoom;
}
else if (value > MaxZoom)
{
value = MaxZoom;
}
if (_zoom != value)
{
_zoom = value;
this.OnZoomChanged(EventArgs.Empty);
this.OnZoomed(new ImageBoxZoomEventArgs(actions, source, previousZoom, this.Zoom));
}
}
#endregion
#region Other
private static Cursor _panAllCursor;
private static Bitmap _panAllSymbol;
#endregion
}
}
================================================
FILE: Cyotek.Windows.Forms.ImageBox/ImageBoxActionSources.cs
================================================
using System;
namespace Cyotek.Windows.Forms
{
// Cyotek ImageBox
// Copyright (c) 2010-2015 Cyotek Ltd.
// http://cyotek.com
// http://cyotek.com/blog/tag/imagebox
// Licensed under the MIT License. See license.txt for the full text.
// If you use this control in your applications, attribution, donations or contributions are welcome.
/// <summary>
/// Specifies the source of an action being performed.
/// </summary>
[Flags]
public enum ImageBoxActionSources
{
/// <summary>
/// Unknown source.
/// </summary>
Unknown = 0,
/// <summary>
/// A user initialized the action.
/// </summary>
User = 1
}
}
================================================
FILE: Cyotek.Windows.Forms.ImageBox/ImageBoxBorderStyle.cs
================================================
namespace Cyotek.Windows.Forms
{
// Cyotek ImageBox
// Copyright (c) 2010-2015 Cyotek Ltd.
// http://cyotek.com
// http://cyotek.com/blog/tag/imagebox
// Licensed under the MIT License. See license.txt for the full text.
// If you use this control in your applications, attribution, donations or contributions are welcome.
/// <summary>
/// Specifies the border styles of an image
/// </summary>
public enum ImageBoxBorderStyle
{
/// <summary>
/// No border.
/// </summary>
None,
/// <summary>
/// A fixed, single-line border.
/// </summary>
FixedSingle,
/// <summary>
/// A fixed, single-line border with a solid drop shadow.
/// </summary>
FixedSingleDropShadow,
/// <summary>
/// A fixed, single-line border with a soft outer glow.
/// </summary>
FixedSingleGlowShadow
}
}
================================================
FILE: Cyotek.Windows.Forms.ImageBox/ImageBoxCancelEventArgs.cs
================================================
using System.ComponentModel;
using System.Drawing;
namespace Cyotek.Windows.Forms
{
// Cyotek ImageBox
// Copyright (c) 2010-2015 Cyotek Ltd.
// http://cyotek.com
// http://cyotek.com/blog/tag/imagebox
// Licensed under the MIT License. See license.txt for the full text.
// If you use this control in your applications, attribution, donations or contributions are welcome.
/// <summary>
/// Provides data for a cancelable event.
/// </summary>
public class ImageBoxCancelEventArgs : CancelEventArgs
{
#region Public Constructors
/// <summary>
/// Initializes a new instance of the <see cref="ImageBoxCancelEventArgs"/> class.
/// </summary>
/// <param name="location">The location of the action being performed.</param>
public ImageBoxCancelEventArgs(Point location)
: this()
{
this.Location = location;
}
#endregion
#region Protected Constructors
/// <summary>
/// Initializes a new instance of the <see cref="ImageBoxCancelEventArgs"/> class.
/// </summary>
protected ImageBoxCancelEventArgs()
{ }
#endregion
#region Public Properties
/// <summary>
/// Gets or sets the location of the action being performed.
/// </summary>
/// <value>The location of the action being performed.</value>
public Point Location { get; protected set; }
#endregion
}
}
================================================
FILE: Cyotek.Windows.Forms.ImageBox/ImageBoxGridDisplayMode.cs
================================================
namespace Cyotek.Windows.Forms
{
// Cyotek ImageBox
// Copyright (c) 2010-2015 Cyotek Ltd.
// http://cyotek.com
// http://cyotek.com/blog/tag/imagebox
// Licensed under the MIT License. See license.txt for the full text.
// If you use this control in your applications, attribution, donations or contributions are welcome.
/// <summary>
/// Specifies the display styles for the background texture grid
/// </summary>
public enum ImageBoxGridDisplayMode
{
/// <summary>
/// No background.
/// </summary>
None,
/// <summary>
/// Background is displayed in the control's client area.
/// </summary>
Client,
/// <summary>
/// Background is displayed only in the image region.
/// </summary>
Image
}
}
================================================
FILE: Cyotek.Windows.Forms.ImageBox/ImageBoxGridScale.cs
================================================
namespace Cyotek.Windows.Forms
{
// Cyotek ImageBox
// Copyright (c) 2010-2015 Cyotek Ltd.
// http://cyotek.com
// http://cyotek.com/blog/tag/imagebox
// Licensed under the MIT License. See license.txt for the full text.
// If you use this control in your applications, attribution, donations or contributions are welcome.
/// <summary>
/// Specifies the size of the background texture grid.
/// </summary>
public enum ImageBoxGridScale
{
/// <summary>
/// Displays a solid color
/// </summary>
None,
/// <summary>
/// Half of the default size.
/// </summary>
Tiny,
/// <summary>
/// Default size.
/// </summary>
Small,
/// <summary>
/// 50% increase of default size.
/// </summary>
Medium,
/// <summary>
/// 100% increase of default size.
/// </summary>
Large
}
}
================================================
FILE: Cyotek.Windows.Forms.ImageBox/ImageBoxMouseWheelMessageFilter.cs
================================================
using System;
using System.Drawing;
using System.Windows.Forms;
#if USEWIN32PINVOKELIB
using Cyotek.Win32;
#endif
// Cyotek ImageBox
// Copyright (c) 2010-2015 Cyotek Ltd.
// http://cyotek.com
// http://cyotek.com/blog/tag/imagebox
// Licensed under the MIT License. See license.txt for the full text.
// If you use this control in your applications, attribution, donations or contributions are welcome.
// This code is derived from http://stackoverflow.com/a/13292894/148962 and http://stackoverflow.com/a/11034674/148962
namespace Cyotek.Windows.Forms
{
/// <summary>
/// A message filter for WM_MOUSEWHEEL and WM_MOUSEHWHEEL. This class cannot be inherited.
/// </summary>
/// <seealso cref="T:System.Windows.Forms.IMessageFilter"/>
internal sealed class ImageBoxMouseWheelMessageFilter : IMessageFilter
{
#region Member Declarations
private static ImageBoxMouseWheelMessageFilter _instance;
private static bool _active;
#endregion
#region Constructors
/// <summary>
/// Constructor that prevents a default instance of this class from being created.
/// </summary>
private ImageBoxMouseWheelMessageFilter()
{ }
#endregion
#region Static Properties
/// <summary>
/// Gets or sets a value indicating whether the filter is active
/// </summary>
/// <value>
/// <c>true</c> if the message filter is active, <c>false</c> if not.
/// </value>
public static bool Active
{
get { return _active; }
set
{
if (_active != value)
{
_active = value;
if (_active)
{
if (_instance == null)
{
_instance = new ImageBoxMouseWheelMessageFilter();
}
Application.AddMessageFilter(_instance);
}
else
{
if (_instance != null)
{
Application.RemoveMessageFilter(_instance);
}
}
}
}
}
#endregion
#region IMessageFilter Interface
/// <summary>
/// Filters out a message before it is dispatched.
/// </summary>
/// <param name="m"> [in,out] The message to be dispatched. You cannot modify this message. </param>
/// <returns>
/// <c>true</c> to filter the message and stop it from being dispatched; <c>false</c> to allow the message to
/// continue to the next filter or control.
/// </returns>
/// <seealso cref="M:System.Windows.Forms.IMessageFilter.PreFilterMessage(Message@)"/>
bool IMessageFilter.PreFilterMessage(ref Message m)
{
bool result;
switch (m.Msg)
{
case NativeMethods.WM_MOUSEWHEEL: // 0x020A
case NativeMethods.WM_MOUSEHWHEEL: // 0x020E
IntPtr hControlUnderMouse;
hControlUnderMouse = NativeMethods.WindowFromPoint(new Point((int)m.LParam));
if (hControlUnderMouse == m.HWnd)
{
gitextract_n7bu3m8j/
├── .editorconfig
├── .github/
│ └── workflows/
│ └── codeql-analysis.yml
├── .gitignore
├── .markdownlint.json
├── CHANGELOG.md
├── Cyotek.Windows.Forms.ImageBox/
│ ├── Cyotek.Windows.Forms.ImageBox.csproj
│ ├── Cyotek.Windows.Forms.ImageBox.nuspec
│ ├── ImageBox.cs
│ ├── ImageBoxActionSources.cs
│ ├── ImageBoxBorderStyle.cs
│ ├── ImageBoxCancelEventArgs.cs
│ ├── ImageBoxGridDisplayMode.cs
│ ├── ImageBoxGridScale.cs
│ ├── ImageBoxMouseWheelMessageFilter.cs
│ ├── ImageBoxMouseWheelMode.cs
│ ├── ImageBoxNativeMethods.cs
│ ├── ImageBoxPanDirection.cs
│ ├── ImageBoxPanMode.cs
│ ├── ImageBoxPanStyle.cs
│ ├── ImageBoxSelectionMode.cs
│ ├── ImageBoxSizeMode.cs
│ ├── ImageBoxZoomActions.cs
│ ├── ImageBoxZoomEventArgs.cs
│ ├── Properties/
│ │ └── AssemblyInfo.cs
│ ├── ScrollControl.cs
│ ├── ScrollProperties.cs
│ ├── VirtualScrollableControl.cs
│ ├── ZoomLevelCollection.cs
│ ├── ZoomLevelCollectionConverter.cs
│ └── cyopublic.snk
├── Cyotek.Windows.Forms.ImageBox.Demo/
│ ├── AboutDialog.cs
│ ├── AboutDialog.designer.cs
│ ├── AboutDialog.resx
│ ├── AnimatedGifDemoForm.Designer.cs
│ ├── AnimatedGifDemoForm.cs
│ ├── AnimatedGifDemoForm.resx
│ ├── BaseForm.Designer.cs
│ ├── BaseForm.cs
│ ├── BaseForm.resx
│ ├── Cyotek.Windows.Forms.ImageBox.Demo.csproj
│ ├── DisposedImageDemoForm.Designer.cs
│ ├── DisposedImageDemoForm.cs
│ ├── DisposedImageDemoForm.resx
│ ├── DragHandle.cs
│ ├── DragHandleAnchor.cs
│ ├── DragHandleCollection.cs
│ ├── DragTestForm.Designer.cs
│ ├── DragTestForm.cs
│ ├── DragTestForm.resx
│ ├── EventsListBox.cs
│ ├── FilteredPropertyGrid.cs
│ ├── GeneralDemoForm.Designer.cs
│ ├── GeneralDemoForm.cs
│ ├── GeneralDemoForm.resx
│ ├── GroupBox.cs
│ ├── ImageBoxEx.cs
│ ├── MainMenuForm.cs
│ ├── MainMenuForm.designer.cs
│ ├── MainMenuForm.resx
│ ├── MiniMapDemoForm.cs
│ ├── MiniMapDemoForm.designer.cs
│ ├── MiniMapDemoForm.resx
│ ├── OpenUrlDialog.Designer.cs
│ ├── OpenUrlDialog.cs
│ ├── OpenUrlDialog.resx
│ ├── PanStylesDemoForm.Designer.cs
│ ├── PanStylesDemoForm.cs
│ ├── PanStylesDemoForm.resx
│ ├── PixelGridForm.Designer.cs
│ ├── PixelGridForm.cs
│ ├── PixelGridForm.resx
│ ├── Program.cs
│ ├── Properties/
│ │ ├── AssemblyInfo.cs
│ │ ├── Resources.Designer.cs
│ │ └── Resources.resx
│ ├── PropertyGrid.cs
│ ├── ResizableSelectionDemoForm.Designer.cs
│ ├── ResizableSelectionDemoForm.cs
│ ├── ResizableSelectionDemoForm.resx
│ ├── Resources/
│ │ └── markdownpad-github.css
│ ├── ScaledAdornmentsDemoForm.Designer.cs
│ ├── ScaledAdornmentsDemoForm.cs
│ ├── ScaledAdornmentsDemoForm.resx
│ ├── SizeModeDemoForm.Designer.cs
│ ├── SizeModeDemoForm.cs
│ ├── SizeModeDemoForm.resx
│ ├── SwitchImageDuringZoomDemoForm.Designer.cs
│ ├── SwitchImageDuringZoomDemoForm.cs
│ ├── SwitchImageDuringZoomDemoForm.resx
│ ├── TextDemoForm.Designer.cs
│ ├── TextDemoForm.cs
│ ├── TextDemoForm.resx
│ ├── VirtualModeDemonstrationForm.Designer.cs
│ ├── VirtualModeDemonstrationForm.cs
│ ├── VirtualModeDemonstrationForm.resx
│ ├── app.manifest
│ ├── cyopublic.snk
│ └── packages.config
├── Cyotek.Windows.Forms.ImageBox.Design/
│ ├── Cyotek.Windows.Forms.ImageBox.Design.csproj
│ ├── ImageBoxDesigner.cs
│ └── Properties/
│ └── AssemblyInfo.cs
├── Cyotek.Windows.Forms.ImageBox.sln
├── LICENSE.txt
├── README.md
├── acknowledgements.md
├── build.cmd
├── nuget.config
└── res/
├── PanAll.cur
├── icon-16.pdn
└── icon-32.pdn
SYMBOL INDEX (608 symbols across 66 files)
FILE: Cyotek.Windows.Forms.ImageBox.Demo/AboutDialog.cs
class AboutDialog (line 22) | internal partial class AboutDialog : BaseForm
method AboutDialog (line 26) | public AboutDialog()
method ShowAboutDialog (line 35) | internal static void ShowAboutDialog()
method OnFontChanged (line 56) | protected override void OnFontChanged(EventArgs e)
method OnLoad (line 63) | protected override void OnLoad(EventArgs e)
method OnResize (line 91) | protected override void OnResize(EventArgs e)
method AddReadme (line 98) | private void AddReadme(string fileName)
method closeButton_Click (line 110) | private void closeButton_Click(object sender, EventArgs e)
method docsTabControl_Selecting (line 115) | private void docsTabControl_Selecting(object sender, TabControlCancelE...
method footerGroupBox_Paint (line 120) | private void footerGroupBox_Paint(object sender, PaintEventArgs e)
method GetFullReadmePath (line 126) | private string GetFullReadmePath(string fileName)
method LoadDocumentForTab (line 131) | private void LoadDocumentForTab(TabPage page)
method PositionTabControl (line 180) | private void PositionTabControl()
method webLinkLabel_Click (line 185) | private void webLinkLabel_Click(object sender, EventArgs e)
FILE: Cyotek.Windows.Forms.ImageBox.Demo/AboutDialog.designer.cs
class AboutDialog (line 3) | partial class AboutDialog
method Dispose (line 14) | protected override void Dispose(bool disposing)
method InitializeComponent (line 29) | private void InitializeComponent()
FILE: Cyotek.Windows.Forms.ImageBox.Demo/AnimatedGifDemoForm.Designer.cs
class AnimatedGifDemoForm (line 3) | partial class AnimatedGifDemoForm
method Dispose (line 14) | protected override void Dispose(bool disposing)
method InitializeComponent (line 29) | private void InitializeComponent()
FILE: Cyotek.Windows.Forms.ImageBox.Demo/AnimatedGifDemoForm.cs
class AnimatedGifDemoForm (line 14) | internal partial class AnimatedGifDemoForm : BaseForm
method AnimatedGifDemoForm (line 18) | public AnimatedGifDemoForm()
method aboutToolStripMenuItem_Click (line 27) | private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
method closeToolStripMenuItem_Click (line 32) | private void closeToolStripMenuItem_Click(object sender, EventArgs e)
FILE: Cyotek.Windows.Forms.ImageBox.Demo/BaseForm.Designer.cs
class BaseForm (line 3) | partial class BaseForm
method Dispose (line 14) | protected override void Dispose(bool disposing)
method InitializeComponent (line 29) | private void InitializeComponent()
FILE: Cyotek.Windows.Forms.ImageBox.Demo/BaseForm.cs
class BaseForm (line 16) | internal partial class BaseForm : Form
method BaseForm (line 20) | public BaseForm()
method OnLoad (line 29) | protected override void OnLoad(EventArgs e)
method OnShown (line 39) | protected override void OnShown(EventArgs e)
method FormatPoint (line 50) | protected string FormatPoint(Point point)
method FormatRectangle (line 55) | protected string FormatRectangle(RectangleF rect)
FILE: Cyotek.Windows.Forms.ImageBox.Demo/DisposedImageDemoForm.Designer.cs
class DisposedImageDemoForm (line 3) | partial class DisposedImageDemoForm
method Dispose (line 14) | protected override void Dispose(bool disposing)
method InitializeComponent (line 29) | private void InitializeComponent()
FILE: Cyotek.Windows.Forms.ImageBox.Demo/DisposedImageDemoForm.cs
class DisposedImageDemoForm (line 15) | internal partial class DisposedImageDemoForm : BaseForm
method DisposedImageDemoForm (line 25) | public DisposedImageDemoForm()
method OnLoad (line 34) | protected override void OnLoad(EventArgs e)
method aboutToolStripMenuItem_Click (line 48) | private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
method closeToolStripMenuItem_Click (line 53) | private void closeToolStripMenuItem_Click(object sender, EventArgs e)
FILE: Cyotek.Windows.Forms.ImageBox.Demo/DragHandle.cs
class DragHandle (line 14) | internal class DragHandle
method DragHandle (line 18) | public DragHandle(DragHandleAnchor anchor)
method DragHandle (line 28) | protected DragHandle()
FILE: Cyotek.Windows.Forms.ImageBox.Demo/DragHandleAnchor.cs
type DragHandleAnchor (line 12) | internal enum DragHandleAnchor
FILE: Cyotek.Windows.Forms.ImageBox.Demo/DragHandleCollection.cs
class DragHandleCollection (line 16) | internal class DragHandleCollection : IEnumerable<DragHandle>
method DragHandleCollection (line 26) | public DragHandleCollection()
method GetEnumerator (line 63) | public IEnumerator<DragHandle> GetEnumerator()
method HitTest (line 68) | public DragHandleAnchor HitTest(Point point)
method GetEnumerator (line 96) | IEnumerator IEnumerable.GetEnumerator()
FILE: Cyotek.Windows.Forms.ImageBox.Demo/DragTestForm.Designer.cs
class DragTestForm (line 3) | partial class DragTestForm
method Dispose (line 14) | protected override void Dispose(bool disposing)
method InitializeComponent (line 29) | private void InitializeComponent()
FILE: Cyotek.Windows.Forms.ImageBox.Demo/DragTestForm.cs
class DragTestForm (line 16) | internal partial class DragTestForm : BaseForm
method DragTestForm (line 30) | public DragTestForm()
method aboutToolStripMenuItem_Click (line 41) | private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
method closeToolStripMenuItem_Click (line 46) | private void closeToolStripMenuItem_Click(object sender, EventArgs e)
method imageBox_MouseDown (line 51) | private void imageBox_MouseDown(object sender, MouseEventArgs e)
method imageBox_MouseMove (line 63) | private void imageBox_MouseMove(object sender, MouseEventArgs e)
method imageBox_MouseUp (line 95) | private void imageBox_MouseUp(object sender, MouseEventArgs e)
method imageBox_Selecting (line 100) | private void imageBox_Selecting(object sender, ImageBoxCancelEventArgs e)
method imageBox_SelectionRegionChanged (line 108) | private void imageBox_SelectionRegionChanged(object sender, EventArgs e)
method imageBox_VirtualDraw (line 117) | private void imageBox_VirtualDraw(object sender, PaintEventArgs e)
FILE: Cyotek.Windows.Forms.ImageBox.Demo/EventsListBox.cs
class EventsListBox (line 17) | internal class EventsListBox : ListBox
method AddEvent (line 21) | public void AddEvent(Control sender, string eventName)
method AddEvent (line 26) | public void AddEvent(Control sender, string eventName, IDictionary<str...
FILE: Cyotek.Windows.Forms.ImageBox.Demo/FilteredPropertyGrid.cs
class FilteredPropertyGrid (line 13) | internal class FilteredPropertyGrid : PropertyGrid
method FilteredPropertyGrid (line 34) | public FilteredPropertyGrid()
method HideAttribute (line 144) | private void HideAttribute(Attribute attribute)
method HideProperty (line 163) | private void HideProperty(PropertyDescriptor property)
method RefreshProperties (line 172) | private void RefreshProperties()
method ShowAttribute (line 231) | private void ShowAttribute(Attribute attribute)
method ShowProperty (line 250) | private void ShowProperty(PropertyDescriptor property)
class ObjectWrapper (line 263) | private sealed class ObjectWrapper : ICustomTypeDescriptor
method ObjectWrapper (line 277) | internal ObjectWrapper(object obj)
method GetAttributes (line 313) | public AttributeCollection GetAttributes()
method GetClassName (line 320) | public string GetClassName()
method GetComponentName (line 327) | public string GetComponentName()
method GetConverter (line 334) | public TypeConverter GetConverter()
method GetDefaultEvent (line 341) | public EventDescriptor GetDefaultEvent()
method GetDefaultProperty (line 348) | public PropertyDescriptor GetDefaultProperty()
method GetEditor (line 356) | public object GetEditor(Type editorBaseType)
method GetEvents (line 361) | public EventDescriptorCollection GetEvents(Attribute[] attributes)
method GetEvents (line 366) | public EventDescriptorCollection GetEvents()
method GetProperties (line 371) | public PropertyDescriptorCollection GetProperties(Attribute[] attrib...
method GetProperties (line 376) | public PropertyDescriptorCollection GetProperties()
method GetPropertyOwner (line 381) | public object GetPropertyOwner(PropertyDescriptor pd)
FILE: Cyotek.Windows.Forms.ImageBox.Demo/GeneralDemoForm.Designer.cs
class GeneralDemoForm (line 3) | partial class GeneralDemoForm
method Dispose (line 14) | protected override void Dispose(bool disposing)
method InitializeComponent (line 33) | private void InitializeComponent()
FILE: Cyotek.Windows.Forms.ImageBox.Demo/GeneralDemoForm.cs
class GeneralDemoForm (line 20) | internal partial class GeneralDemoForm : BaseForm
method GeneralDemoForm (line 30) | public GeneralDemoForm()
method OnLoad (line 39) | protected override void OnLoad(EventArgs e)
method aboutToolStripMenuItem_Click (line 50) | private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
method actualSizeToolStripButton_Click (line 55) | private void actualSizeToolStripButton_Click(object sender, EventArgs e)
method copyToolStripMenuItem_Click (line 60) | private void copyToolStripMenuItem_Click(object sender, EventArgs e)
method DrawBox (line 73) | private void DrawBox(Graphics graphics, Color color, RectangleF rectan...
method exitToolStripMenuItem_Click (line 94) | private void exitToolStripMenuItem_Click(object sender, EventArgs e)
method FillZoomLevels (line 99) | private void FillZoomLevels()
method fromURLToolStripMenuItem_Click (line 109) | private void fromURLToolStripMenuItem_Click(object sender, EventArgs e)
method imageBox_MouseLeave (line 120) | private void imageBox_MouseLeave(object sender, EventArgs e)
method imageBox_MouseMove (line 125) | private void imageBox_MouseMove(object sender, MouseEventArgs e)
method imageBox_Paint (line 130) | private void imageBox_Paint(object sender, PaintEventArgs e)
method imageBox_Resize (line 145) | private void imageBox_Resize(object sender, EventArgs e)
method imageBox_Scroll (line 150) | private void imageBox_Scroll(object sender, ScrollEventArgs e)
method imageBox_Selected (line 155) | private void imageBox_Selected(object sender, EventArgs e)
method imageBox_SelectionRegionChanged (line 160) | private void imageBox_SelectionRegionChanged(object sender, EventArgs e)
method imageBox_ZoomChanged (line 165) | private void imageBox_ZoomChanged(object sender, EventArgs e)
method imageBox_ZoomLevelsChanged (line 170) | private void imageBox_ZoomLevelsChanged(object sender, EventArgs e)
method openFromFileToolStripMenuItem_Click (line 175) | private void openFromFileToolStripMenuItem_Click(object sender, EventA...
method OpenImage (line 196) | private void OpenImage(Image image)
method OpenImageFromUrl (line 205) | private void OpenImageFromUrl(string url)
method selectAllToolStripMenuItem_Click (line 227) | private void selectAllToolStripMenuItem_Click(object sender, EventArgs e)
method selectNoneToolStripMenuItem_Click (line 232) | private void selectNoneToolStripMenuItem_Click(object sender, EventArg...
method showImageRegionToolStripButton_Click (line 237) | private void showImageRegionToolStripButton_Click(object sender, Event...
method UpdateCursorPosition (line 242) | private void UpdateCursorPosition(Point location)
method UpdatePreviewImage (line 258) | private void UpdatePreviewImage()
method UpdateStatusBar (line 270) | private void UpdateStatusBar()
method zoomInToolStripButton_Click (line 278) | private void zoomInToolStripButton_Click(object sender, EventArgs e)
method zoomLevelsToolStripComboBox_SelectedIndexChanged (line 283) | private void zoomLevelsToolStripComboBox_SelectedIndexChanged(object s...
method zoomOutToolStripButton_Click (line 292) | private void zoomOutToolStripButton_Click(object sender, EventArgs e)
FILE: Cyotek.Windows.Forms.ImageBox.Demo/GroupBox.cs
class GroupBox (line 16) | [ToolboxItem(true)]
method GroupBox (line 50) | public GroupBox()
method Dispose (line 125) | protected override void Dispose(bool disposing)
method OnPaint (line 139) | protected override void OnPaint(PaintEventArgs e)
method OnSystemColorsChanged (line 211) | protected override void OnSystemColorsChanged(EventArgs e)
method CleanUpResources (line 336) | private void CleanUpResources()
method CreateResources (line 352) | private void CreateResources()
FILE: Cyotek.Windows.Forms.ImageBox.Demo/ImageBoxEx.cs
class ImageBoxEx (line 17) | internal class ImageBoxEx : ImageBox
method ImageBoxEx (line 63) | public ImageBoxEx()
method CancelResize (line 236) | public void CancelResize()
method StartMove (line 242) | public void StartMove()
method DrawDragHandle (line 262) | protected virtual void DrawDragHandle(Graphics graphics, DragHandle ha...
method OnDragHandleSizeChanged (line 298) | protected virtual void OnDragHandleSizeChanged(EventArgs e)
method OnMaximumSelectionSizeChanged (line 314) | protected virtual void OnMaximumSelectionSizeChanged(EventArgs e)
method OnMinimumSelectionSizeChanged (line 327) | protected virtual void OnMinimumSelectionSizeChanged(EventArgs e)
method OnMouseDown (line 342) | protected override void OnMouseDown(MouseEventArgs e)
method OnMouseMove (line 370) | protected override void OnMouseMove(MouseEventArgs e)
method OnMouseUp (line 409) | protected override void OnMouseUp(MouseEventArgs e)
method OnPaint (line 429) | protected override void OnPaint(PaintEventArgs e)
method OnPanStart (line 451) | protected override void OnPanStart(CancelEventArgs e)
method OnResize (line 467) | protected override void OnResize(EventArgs e)
method OnScroll (line 480) | protected override void OnScroll(ScrollEventArgs se)
method OnSelecting (line 493) | protected override void OnSelecting(ImageBoxCancelEventArgs e)
method OnSelectionMoved (line 504) | protected virtual void OnSelectionMoved(EventArgs e)
method OnSelectionMoving (line 517) | protected virtual void OnSelectionMoving(CancelEventArgs e)
method OnSelectionRegionChanged (line 532) | protected override void OnSelectionRegionChanged(EventArgs e)
method OnSelectionResized (line 543) | protected virtual void OnSelectionResized(EventArgs e)
method OnSelectionResizing (line 556) | protected virtual void OnSelectionResizing(CancelEventArgs e)
method OnZoomChanged (line 571) | protected override void OnZoomChanged(EventArgs e)
method ProcessDialogKey (line 585) | protected override bool ProcessDialogKey(Keys keyData)
method SetCursor (line 610) | protected virtual void SetCursor(Point point)
method CancelMove (line 666) | private void CancelMove()
method CompleteMove (line 672) | private void CompleteMove()
method CompleteResize (line 678) | private void CompleteResize()
method HitTest (line 684) | private DragHandleAnchor HitTest(Point cursorPosition)
method IsOutsideDragZone (line 689) | private bool IsOutsideDragZone(Point location)
method PositionDragHandles (line 702) | private void PositionDragHandles()
method ProcessSelectionMove (line 761) | private void ProcessSelectionMove(Point cursorPosition)
method ProcessSelectionResize (line 791) | private void ProcessSelectionResize(Point cursorPosition)
method ResetDrag (line 882) | private void ResetDrag()
method StartResize (line 890) | private void StartResize(DragHandleAnchor anchor)
FILE: Cyotek.Windows.Forms.ImageBox.Demo/MainMenuForm.cs
class MainMenuForm (line 17) | internal partial class MainMenuForm : AboutDialog
method MainMenuForm (line 21) | public MainMenuForm()
method OnLoad (line 30) | protected override void OnLoad(EventArgs e)
method OnShown (line 56) | protected override void OnShown(EventArgs e)
method animatedGifDemoButton_Click (line 63) | private void animatedGifDemoButton_Click(object sender, EventArgs e)
method dragTestDemoButton_Click (line 68) | private void dragTestDemoButton_Click(object sender, EventArgs e)
method imageBoxDemoButton_Click (line 73) | private void imageBoxDemoButton_Click(object sender, EventArgs e)
method minimapDemoButton_Click (line 78) | private void minimapDemoButton_Click(object sender, EventArgs e)
method panDemoButton_Click (line 83) | private void panDemoButton_Click(object sender, EventArgs e)
method pixelGridDemoButton_Click (line 88) | private void pixelGridDemoButton_Click(object sender, EventArgs e)
method resizableSelectionDemoButton_Click (line 93) | private void resizableSelectionDemoButton_Click(object sender, EventAr...
method scaledAdornmentsDemoButton_Click (line 98) | private void scaledAdornmentsDemoButton_Click(object sender, EventArgs e)
method ShowDemo (line 103) | private void ShowDemo<T>()
method sizeModeDemoButton_Click (line 114) | private void sizeModeDemoButton_Click(object sender, EventArgs e)
method switchImageDuringZoomDemoButton_Click (line 119) | private void switchImageDuringZoomDemoButton_Click(object sender, Even...
method textDemoButton_Click (line 124) | private void textDemoButton_Click(object sender, EventArgs e)
method virtualModeDemoButton_Click (line 129) | private void virtualModeDemoButton_Click(object sender, EventArgs e)
FILE: Cyotek.Windows.Forms.ImageBox.Demo/MainMenuForm.designer.cs
class MainMenuForm (line 3) | partial class MainMenuForm
method Dispose (line 14) | protected override void Dispose(bool disposing)
method InitializeComponent (line 29) | private void InitializeComponent()
FILE: Cyotek.Windows.Forms.ImageBox.Demo/MiniMapDemoForm.cs
class MiniMapDemoForm (line 20) | internal partial class MiniMapDemoForm : BaseForm
method MiniMapDemoForm (line 32) | public MiniMapDemoForm()
method OnLoad (line 41) | protected override void OnLoad(EventArgs e)
method aboutToolStripMenuItem_Click (line 50) | private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
method closeToolStripMenuItem_Click (line 55) | private void closeToolStripMenuItem_Click(object sender, EventArgs e)
method miniMapImageBox_Paint (line 60) | private void miniMapImageBox_Paint(object sender, PaintEventArgs e)
method RefreshMiniMap (line 73) | private void RefreshMiniMap()
method splitContainer_SplitterMoved (line 119) | private void splitContainer_SplitterMoved(object sender, SplitterEvent...
method UpdateMiniMap (line 124) | private void UpdateMiniMap()
method zoomImageBox_ImageChanged (line 190) | private void zoomImageBox_ImageChanged(object sender, EventArgs e)
method zoomImageBox_Resize (line 195) | private void zoomImageBox_Resize(object sender, EventArgs e)
method zoomImageBox_Scroll (line 200) | private void zoomImageBox_Scroll(object sender, ScrollEventArgs e)
method zoomImageBox_Zoomed (line 205) | private void zoomImageBox_Zoomed(object sender, ImageBoxZoomEventArgs e)
FILE: Cyotek.Windows.Forms.ImageBox.Demo/MiniMapDemoForm.designer.cs
class MiniMapDemoForm (line 3) | partial class MiniMapDemoForm
method Dispose (line 14) | protected override void Dispose(bool disposing)
method InitializeComponent (line 29) | private void InitializeComponent()
FILE: Cyotek.Windows.Forms.ImageBox.Demo/OpenUrlDialog.Designer.cs
class OpenUrlDialog (line 3) | partial class OpenUrlDialog
method Dispose (line 14) | protected override void Dispose(bool disposing)
method InitializeComponent (line 29) | private void InitializeComponent()
FILE: Cyotek.Windows.Forms.ImageBox.Demo/OpenUrlDialog.cs
class OpenUrlDialog (line 16) | internal sealed partial class OpenUrlDialog : BaseForm
method OpenUrlDialog (line 20) | public OpenUrlDialog()
method cancelButton_Click (line 37) | private void cancelButton_Click(object sender, EventArgs e)
method okButton_Click (line 43) | private void okButton_Click(object sender, EventArgs e)
method ValidateUrl (line 61) | private bool ValidateUrl(string url)
FILE: Cyotek.Windows.Forms.ImageBox.Demo/PanStylesDemoForm.Designer.cs
class PanStylesDemoForm (line 3) | partial class PanStylesDemoForm
method Dispose (line 14) | protected override void Dispose(bool disposing)
method InitializeComponent (line 29) | private void InitializeComponent()
FILE: Cyotek.Windows.Forms.ImageBox.Demo/PanStylesDemoForm.cs
class PanStylesDemoForm (line 17) | internal partial class PanStylesDemoForm : BaseForm
method PanStylesDemoForm (line 21) | public PanStylesDemoForm()
method OnLoad (line 30) | protected override void OnLoad(EventArgs e)
method aboutToolStripMenuItem_Click (line 48) | private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
method closeToolStripMenuItem_Click (line 53) | private void closeToolStripMenuItem_Click(object sender, EventArgs e)
method imageBox_PanEnd (line 58) | private void imageBox_PanEnd(object sender, EventArgs e)
method imageBox_PanStart (line 63) | private void imageBox_PanStart(object sender, EventArgs e)
FILE: Cyotek.Windows.Forms.ImageBox.Demo/PixelGridForm.Designer.cs
class PixelGridForm (line 3) | partial class PixelGridForm
method Dispose (line 14) | protected override void Dispose(bool disposing)
method InitializeComponent (line 29) | private void InitializeComponent()
FILE: Cyotek.Windows.Forms.ImageBox.Demo/PixelGridForm.cs
class PixelGridForm (line 14) | internal partial class PixelGridForm : BaseForm
method PixelGridForm (line 18) | public PixelGridForm()
method OnLoad (line 27) | protected override void OnLoad(EventArgs e)
method aboutToolStripMenuItem_Click (line 38) | private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
method closeToolStripMenuItem_Click (line 43) | private void closeToolStripMenuItem_Click(object sender, EventArgs e)
FILE: Cyotek.Windows.Forms.ImageBox.Demo/Program.cs
class Program (line 15) | internal static class Program
method Main (line 22) | [STAThread]
FILE: Cyotek.Windows.Forms.ImageBox.Demo/Properties/Resources.Designer.cs
class Resources (line 22) | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resource...
method Resources (line 31) | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Mic...
FILE: Cyotek.Windows.Forms.ImageBox.Demo/PropertyGrid.cs
class PropertyGrid (line 15) | internal class PropertyGrid : System.Windows.Forms.PropertyGrid
method FindItem (line 19) | public GridItem FindItem(string itemLabel)
method SelectItem (line 61) | public void SelectItem(string itemLabel)
FILE: Cyotek.Windows.Forms.ImageBox.Demo/ResizableSelectionDemoForm.Designer.cs
class ResizableSelectionDemoForm (line 3) | partial class ResizableSelectionDemoForm
method Dispose (line 14) | protected override void Dispose(bool disposing)
method InitializeComponent (line 29) | private void InitializeComponent()
FILE: Cyotek.Windows.Forms.ImageBox.Demo/ResizableSelectionDemoForm.cs
class ResizableSelectionDemoForm (line 18) | internal partial class ResizableSelectionDemoForm : BaseForm
method ResizableSelectionDemoForm (line 22) | public ResizableSelectionDemoForm()
method OnLoad (line 35) | protected override void OnLoad(EventArgs e)
method SetStatus (line 59) | private void SetStatus(string message)
method UpdateCursorPosition (line 64) | private void UpdateCursorPosition(Point location)
method UpdateStatusBar (line 78) | private void UpdateStatusBar()
method aboutToolStripMenuItem_Click (line 89) | private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
method closeToolStripMenuItem_Click (line 94) | private void closeToolStripMenuItem_Click(object sender, EventArgs e)
method enabledCheckedListBox_ItemCheck (line 99) | private void enabledCheckedListBox_ItemCheck(object sender, ItemCheckE...
method imageBox_MouseLeave (line 110) | private void imageBox_MouseLeave(object sender, EventArgs e)
method imageBox_MouseMove (line 115) | private void imageBox_MouseMove(object sender, MouseEventArgs e)
method imageBox_Resize (line 120) | private void imageBox_Resize(object sender, EventArgs e)
method imageBox_Scroll (line 125) | private void imageBox_Scroll(object sender, ScrollEventArgs e)
method imageBox_Selected (line 130) | private void imageBox_Selected(object sender, EventArgs e)
method imageBox_Selecting (line 136) | private void imageBox_Selecting(object sender, ImageBoxCancelEventArgs e)
method imageBox_SelectionMoved (line 149) | private void imageBox_SelectionMoved(object sender, EventArgs e)
method imageBox_SelectionMoving (line 156) | private void imageBox_SelectionMoving(object sender, CancelEventArgs e)
method imageBox_SelectionRegionChanged (line 168) | private void imageBox_SelectionRegionChanged(object sender, EventArgs e)
method imageBox_SelectionResized (line 173) | private void imageBox_SelectionResized(object sender, EventArgs e)
method imageBox_SelectionResizing (line 180) | private void imageBox_SelectionResizing(object sender, CancelEventArgs e)
method imageBox_VirtualDraw (line 192) | private void imageBox_VirtualDraw(object sender, PaintEventArgs e)
method imageBox_Zoomed (line 206) | private void imageBox_Zoomed(object sender, ImageBoxZoomEventArgs e)
method selectAllToolStripMenuItem_Click (line 211) | private void selectAllToolStripMenuItem_Click(object sender, EventArgs e)
method selectNoneToolStripMenuItem_Click (line 216) | private void selectNoneToolStripMenuItem_Click(object sender, EventArg...
method visibleCheckedListBox_ItemCheck (line 221) | private void visibleCheckedListBox_ItemCheck(object sender, ItemCheckE...
FILE: Cyotek.Windows.Forms.ImageBox.Demo/ScaledAdornmentsDemoForm.Designer.cs
class ScaledAdornmentsDemoForm (line 3) | partial class ScaledAdornmentsDemoForm
method Dispose (line 14) | protected override void Dispose(bool disposing)
method InitializeComponent (line 29) | private void InitializeComponent()
FILE: Cyotek.Windows.Forms.ImageBox.Demo/ScaledAdornmentsDemoForm.cs
class ScaledAdornmentsDemoForm (line 20) | internal partial class ScaledAdornmentsDemoForm : BaseForm
method ScaledAdornmentsDemoForm (line 32) | public ScaledAdornmentsDemoForm()
method OnLoad (line 41) | protected override void OnLoad(EventArgs e)
method aboutToolStripMenuItem_Click (line 55) | private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
method AddLandmark (line 60) | private void AddLandmark(Point point)
method closeToolStripMenuItem_Click (line 67) | private void closeToolStripMenuItem_Click(object sender, EventArgs e)
method imageBox_MouseClick (line 72) | private void imageBox_MouseClick(object sender, MouseEventArgs e)
method imageBox_MouseLeave (line 84) | private void imageBox_MouseLeave(object sender, EventArgs e)
method imageBox_MouseMove (line 89) | private void imageBox_MouseMove(object sender, MouseEventArgs e)
method imageBox_Paint (line 94) | private void imageBox_Paint(object sender, PaintEventArgs e)
method scaleAdornmentsCheckBox_CheckedChanged (line 133) | private void scaleAdornmentsCheckBox_CheckedChanged(object sender, Eve...
method UpdateCursorPosition (line 138) | private void UpdateCursorPosition(Point location)
FILE: Cyotek.Windows.Forms.ImageBox.Demo/SizeModeDemoForm.Designer.cs
class SizeModeDemoForm (line 3) | partial class SizeModeDemoForm
method Dispose (line 14) | protected override void Dispose(bool disposing)
method InitializeComponent (line 29) | private void InitializeComponent()
FILE: Cyotek.Windows.Forms.ImageBox.Demo/SizeModeDemoForm.cs
class SizeModeDemoForm (line 14) | internal partial class SizeModeDemoForm : BaseForm
method SizeModeDemoForm (line 18) | public SizeModeDemoForm()
method aboutToolStripMenuItem_Click (line 27) | private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
method closeToolStripMenuItem_Click (line 32) | private void closeToolStripMenuItem_Click(object sender, EventArgs e)
FILE: Cyotek.Windows.Forms.ImageBox.Demo/SwitchImageDuringZoomDemoForm.Designer.cs
class SwitchImageDuringZoomDemoForm (line 3) | partial class SwitchImageDuringZoomDemoForm
method InitializeComponent (line 16) | private void InitializeComponent()
FILE: Cyotek.Windows.Forms.ImageBox.Demo/SwitchImageDuringZoomDemoForm.cs
class SwitchImageDuringZoomDemoForm (line 18) | internal partial class SwitchImageDuringZoomDemoForm : BaseForm
method SwitchImageDuringZoomDemoForm (line 28) | public SwitchImageDuringZoomDemoForm()
method Dispose (line 41) | protected override void Dispose(bool disposing)
method OnLoad (line 62) | protected override void OnLoad(EventArgs e)
method AddLayer (line 119) | private void AddLayer(string name, int lowerZoom, int upperZoom)
method FindNearestLayer (line 137) | private int FindNearestLayer(int zoom)
method GetMapFileName (line 159) | private string GetMapFileName(string name)
method GetMapImage (line 164) | private Image GetMapImage(string name)
method SetMessage (line 189) | private void SetMessage(string message)
method SetStatus (line 196) | private void SetStatus(string message)
method UpdateCursorPosition (line 204) | private void UpdateCursorPosition(Point location)
method UpdateMap (line 218) | private void UpdateMap()
method UpdateZoomLabel (line 268) | private void UpdateZoomLabel()
method aboutToolStripMenuItem_Click (line 277) | private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
method closeToolStripMenuItem_Click (line 282) | private void closeToolStripMenuItem_Click(object sender, EventArgs e)
method imageBox_MouseLeave (line 287) | private void imageBox_MouseLeave(object sender, EventArgs e)
method imageBox_MouseMove (line 292) | private void imageBox_MouseMove(object sender, MouseEventArgs e)
method imageBox_ZoomChanged (line 297) | private void imageBox_ZoomChanged(object sender, EventArgs e)
method imageBox_Zoomed (line 302) | private void imageBox_Zoomed(object sender, ImageBoxZoomEventArgs e)
method refreshMapTimer_Tick (line 331) | private void refreshMapTimer_Tick(object sender, EventArgs e)
method resetMessageTimer_Tick (line 338) | private void resetMessageTimer_Tick(object sender, EventArgs e)
type MapLayerData (line 348) | private struct MapLayerData
FILE: Cyotek.Windows.Forms.ImageBox.Demo/TextDemoForm.Designer.cs
class TextDemoForm (line 3) | partial class TextDemoForm
method Dispose (line 14) | protected override void Dispose(bool disposing)
method InitializeComponent (line 29) | private void InitializeComponent()
FILE: Cyotek.Windows.Forms.ImageBox.Demo/TextDemoForm.cs
class TextDemoForm (line 14) | internal partial class TextDemoForm : BaseForm
method TextDemoForm (line 18) | public TextDemoForm()
method OnLoad (line 27) | protected override void OnLoad(EventArgs e)
method aboutToolStripMenuItem_Click (line 39) | private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
method closeToolStripMenuItem_Click (line 44) | private void closeToolStripMenuItem_Click(object sender, EventArgs e)
FILE: Cyotek.Windows.Forms.ImageBox.Demo/VirtualModeDemonstrationForm.Designer.cs
class VirtualModeDemonstrationForm (line 3) | partial class VirtualModeDemonstrationForm
method Dispose (line 14) | protected override void Dispose(bool disposing)
method InitializeComponent (line 29) | private void InitializeComponent()
FILE: Cyotek.Windows.Forms.ImageBox.Demo/VirtualModeDemonstrationForm.cs
class VirtualModeDemonstrationForm (line 16) | internal partial class VirtualModeDemonstrationForm : BaseForm
method VirtualModeDemonstrationForm (line 20) | public VirtualModeDemonstrationForm()
method OnLoad (line 29) | protected override void OnLoad(EventArgs e)
method aboutToolStripMenuItem_Click (line 40) | private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
method closeToolStripMenuItem_Click (line 45) | private void closeToolStripMenuItem_Click(object sender, EventArgs e)
method imageBox_VirtualDraw (line 50) | private void imageBox_VirtualDraw(object sender, PaintEventArgs e)
FILE: Cyotek.Windows.Forms.ImageBox.Design/ImageBoxDesigner.cs
class ImageBoxDesigner (line 28) | public class ImageBoxDesigner : ControlDesigner
method Initialize (line 82) | public override void Initialize(IComponent component)
method Dispose (line 100) | protected override void Dispose(bool disposing)
method DockVerbHandler (line 138) | private void DockVerbHandler(object sender, EventArgs e)
method SetDock (line 146) | private void SetDock(DockStyle dock)
method UndockVerbHandler (line 190) | private void UndockVerbHandler(object sender, EventArgs e)
method OnComponentChanged (line 204) | private void OnComponentChanged(object sender, ComponentChangedEventAr...
FILE: Cyotek.Windows.Forms.ImageBox/ImageBox.cs
class ImageBox (line 24) | [DefaultProperty("Image")]
method ImageBox (line 236) | public ImageBox()
method CreateCheckerBoxTile (line 741) | public static Bitmap CreateCheckerBoxTile(int cellSize, Color cellColo...
method CreateCheckerBoxTile (line 774) | public static Bitmap CreateCheckerBoxTile()
method GetPanAllCursor (line 779) | private static Cursor GetPanAllCursor()
method GetPanAllSymbol (line 788) | private static Bitmap GetPanAllSymbol()
method LoadPanResources (line 800) | private static void LoadPanResources()
method ActualSize (line 1900) | public virtual void ActualSize()
method BeginUpdate (line 1908) | public virtual void BeginUpdate()
method CenterAt (line 1917) | public virtual void CenterAt(Point imageLocation)
method CenterAt (line 1927) | public void CenterAt(int x, int y)
method CenterAt (line 1937) | public void CenterAt(float x, float y)
method CenterToImage (line 1945) | public virtual void CenterToImage()
method EndUpdate (line 1953) | public virtual void EndUpdate()
method FitRectangle (line 1973) | public Rectangle FitRectangle(Rectangle rectangle)
method FitRectangle (line 2015) | public RectangleF FitRectangle(RectangleF rectangle)
method GetImageViewPort (line 2056) | public virtual Rectangle GetImageViewPort()
method GetInsideViewPort (line 2115) | public Rectangle GetInsideViewPort()
method GetInsideViewPort (line 2127) | public virtual Rectangle GetInsideViewPort(bool includePadding)
method GetOffsetPoint (line 2155) | public virtual Point GetOffsetPoint(Point source)
method GetOffsetPoint (line 2170) | public Point GetOffsetPoint(int x, int y)
method GetOffsetPoint (line 2181) | public PointF GetOffsetPoint(float x, float y)
method GetOffsetPoint (line 2191) | public virtual PointF GetOffsetPoint(PointF source)
method GetOffsetRectangle (line 2211) | public virtual RectangleF GetOffsetRectangle(RectangleF source)
method GetOffsetRectangle (line 2234) | public Rectangle GetOffsetRectangle(int x, int y, int width, int height)
method GetOffsetRectangle (line 2247) | public RectangleF GetOffsetRectangle(float x, float y, float width, fl...
method GetOffsetRectangle (line 2257) | public virtual Rectangle GetOffsetRectangle(Rectangle source)
method GetPreferredSize (line 2279) | public override Size GetPreferredSize(Size proposedSize)
method GetScaledPoint (line 2316) | public Point GetScaledPoint(int x, int y)
method GetScaledPoint (line 2327) | public PointF GetScaledPoint(float x, float y)
method GetScaledPoint (line 2337) | public virtual Point GetScaledPoint(Point source)
method GetScaledPoint (line 2347) | public virtual PointF GetScaledPoint(PointF source)
method GetScaledRectangle (line 2360) | public Rectangle GetScaledRectangle(int x, int y, int width, int height)
method GetScaledRectangle (line 2373) | public RectangleF GetScaledRectangle(float x, float y, float width, fl...
method GetScaledRectangle (line 2384) | public Rectangle GetScaledRectangle(Point location, Size size)
method GetScaledRectangle (line 2395) | public RectangleF GetScaledRectangle(PointF location, SizeF size)
method GetScaledRectangle (line 2405) | public virtual Rectangle GetScaledRectangle(Rectangle source)
method GetScaledRectangle (line 2415) | public virtual RectangleF GetScaledRectangle(RectangleF source)
method GetScaledSize (line 2426) | public SizeF GetScaledSize(float width, float height)
method GetScaledSize (line 2437) | public Size GetScaledSize(int width, int height)
method GetScaledSize (line 2447) | public virtual SizeF GetScaledSize(SizeF source)
method GetScaledSize (line 2457) | public virtual Size GetScaledSize(Size source)
method GetSelectedImage (line 2467) | public Image GetSelectedImage()
method GetSourceImageRegion (line 2497) | public virtual RectangleF GetSourceImageRegion()
method IsPointInImage (line 2539) | public virtual bool IsPointInImage(Point point)
method IsPointInImage (line 2553) | public bool IsPointInImage(int x, int y)
method IsPointInImage (line 2566) | public bool IsPointInImage(float x, float y)
method PointToImage (line 2576) | public Point PointToImage(Point point)
method PointToImage (line 2587) | public Point PointToImage(float x, float y)
method PointToImage (line 2601) | public Point PointToImage(float x, float y, bool fitToBounds)
method PointToImage (line 2612) | public Point PointToImage(int x, int y)
method PointToImage (line 2626) | public Point PointToImage(int x, int y, bool fitToBounds)
method PointToImage (line 2639) | public virtual Point PointToImage(Point point, bool fitToBounds)
method ScrollTo (line 2694) | public void ScrollTo(int x, int y, int relativeX, int relativeY)
method ScrollTo (line 2706) | public void ScrollTo(float x, float y, float relativeX, float relativeY)
method ScrollTo (line 2716) | public virtual void ScrollTo(Point imageLocation, Point relativeDispla...
method SelectAll (line 2731) | public virtual void SelectAll()
method SelectNone (line 2739) | public virtual void SelectNone()
method ZoomIn (line 2747) | public virtual void ZoomIn()
method ZoomIn (line 2756) | public virtual void ZoomIn(bool preservePosition)
method ZoomOut (line 2764) | public virtual void ZoomOut()
method ZoomOut (line 2773) | public virtual void ZoomOut(bool preservePosition)
method ZoomToFit (line 2781) | public virtual void ZoomToFit()
method ZoomToRegion (line 2827) | public void ZoomToRegion(float x, float y, float width, float height)
method ZoomToRegion (line 2839) | public void ZoomToRegion(int x, int y, int width, int height)
method ZoomToRegion (line 2848) | public virtual void ZoomToRegion(RectangleF rectangle)
method AdjustLayout (line 2869) | protected virtual void AdjustLayout()
method AdjustScroll (line 2895) | protected virtual void AdjustScroll(int x, int y)
method AdjustSize (line 2907) | protected virtual void AdjustSize()
method AdjustViewPort (line 2918) | protected virtual void AdjustViewPort()
method CreateGridTileImage (line 2933) | protected virtual Bitmap CreateGridTileImage(int cellSize, Color first...
method Dispose (line 2966) | protected override void Dispose(bool disposing)
method DrawBackground (line 2997) | protected virtual void DrawBackground(PaintEventArgs e)
method DrawDropShadow (line 3031) | protected virtual void DrawDropShadow(Graphics g, Rectangle viewPort)
method DrawGlowShadow (line 3054) | protected virtual void DrawGlowShadow(Graphics g, Rectangle viewPort)
method DrawImage (line 3090) | protected virtual void DrawImage(Graphics g)
method DrawImageBorder (line 3127) | protected virtual void DrawImageBorder(Graphics graphics)
method DrawLabel (line 3163) | protected void DrawLabel(Graphics graphics, string text, Rectangle bou...
method DrawLabel (line 3175) | protected void DrawLabel(Graphics graphics, string text, Font font, Re...
method DrawLabel (line 3188) | protected void DrawLabel(Graphics graphics, string text, Font font, Co...
method DrawLabel (line 3202) | protected void DrawLabel(Graphics graphics, string text, Font font, Co...
method DrawLabel (line 3217) | protected void DrawLabel(Graphics graphics, string text, Font font, Co...
method DrawLabel (line 3233) | protected virtual void DrawLabel(Graphics graphics, string text, Font ...
method DrawLabel (line 3250) | protected virtual void DrawLabel(Graphics graphics, string text, Font ...
method DrawPixelGrid (line 3374) | protected virtual void DrawPixelGrid(Graphics g)
method DrawSelection (line 3416) | protected virtual void DrawSelection(PaintEventArgs e)
method DrawText (line 3441) | protected virtual void DrawText(PaintEventArgs e)
method EndDrag (line 3453) | protected virtual void EndDrag()
method GetCursor (line 3466) | protected virtual Cursor GetCursor(Point location)
method GetImageBorderOffset (line 3513) | protected virtual int GetImageBorderOffset()
method GetInterpolationMode (line 3541) | protected virtual InterpolationMode GetInterpolationMode()
method IsInputKey (line 3573) | protected override bool IsInputKey(Keys keyData)
method OnAllowClickZoomChanged (line 3595) | protected virtual void OnAllowClickZoomChanged(EventArgs e)
method OnAllowDoubleClickChanged (line 3610) | protected virtual void OnAllowDoubleClickChanged(EventArgs e)
method OnAllowFreePanChanged (line 3625) | protected virtual void OnAllowFreePanChanged(EventArgs e)
method OnAllowUnfocusedMouseWheelChanged (line 3638) | protected virtual void OnAllowUnfocusedMouseWheelChanged(EventArgs e)
method OnAllowZoomChanged (line 3661) | protected virtual void OnAllowZoomChanged(EventArgs e)
method OnAutoCenterChanged (line 3676) | protected virtual void OnAutoCenterChanged(EventArgs e)
method OnAutoPanChanged (line 3693) | protected virtual void OnAutoPanChanged(EventArgs e)
method OnBackColorChanged (line 3708) | protected override void OnBackColorChanged(EventArgs e)
method OnBorderStyleChanged (line 3721) | protected override void OnBorderStyleChanged(EventArgs e)
method OnDockChanged (line 3734) | protected override void OnDockChanged(EventArgs e)
method OnDropShadowSizeChanged (line 3750) | protected virtual void OnDropShadowSizeChanged(EventArgs e)
method OnFontChanged (line 3765) | protected override void OnFontChanged(EventArgs e)
method OnForeColorChanged (line 3776) | protected override void OnForeColorChanged(EventArgs e)
method OnGridCellSizeChanged (line 3789) | protected virtual void OnGridCellSizeChanged(EventArgs e)
method OnGridColorAlternateChanged (line 3806) | protected virtual void OnGridColorAlternateChanged(EventArgs e)
method OnGridColorChanged (line 3823) | protected virtual void OnGridColorChanged(EventArgs e)
method OnGridDisplayModeChanged (line 3840) | protected virtual void OnGridDisplayModeChanged(EventArgs e)
method OnGridScaleChanged (line 3858) | protected virtual void OnGridScaleChanged(EventArgs e)
method OnImageBorderColorChanged (line 3875) | protected virtual void OnImageBorderColorChanged(EventArgs e)
method OnImageBorderStyleChanged (line 3892) | protected virtual void OnImageBorderStyleChanged(EventArgs e)
method OnImageChanged (line 3909) | protected virtual void OnImageChanged(EventArgs e)
method OnInterpolationModeChanged (line 3944) | protected virtual void OnInterpolationModeChanged(EventArgs e)
method OnInvertMouseChanged (line 3961) | protected virtual void OnInvertMouseChanged(EventArgs e)
method OnKeyDown (line 3976) | protected override void OnKeyDown(KeyEventArgs e)
method OnLimitSelectionToImageChanged (line 3994) | protected virtual void OnLimitSelectionToImageChanged(EventArgs e)
method OnMouseDown (line 4009) | protected override void OnMouseDown(MouseEventArgs e)
method OnMouseMove (line 4044) | protected override void OnMouseMove(MouseEventArgs e)
method OnMouseUp (line 4063) | protected override void OnMouseUp(MouseEventArgs e)
method OnMouseWheel (line 4101) | protected override void OnMouseWheel(MouseEventArgs e)
method OnMouseWheelModeChanged (line 4132) | protected virtual void OnMouseWheelModeChanged(EventArgs e)
method OnPaddingChanged (line 4147) | protected override void OnPaddingChanged(EventArgs e)
method OnPaint (line 4159) | protected override void OnPaint(PaintEventArgs e)
method OnPanEnd (line 4213) | protected virtual void OnPanEnd(EventArgs e)
method OnPanModeChanged (line 4226) | protected virtual void OnPanModeChanged(EventArgs e)
method OnPanStart (line 4241) | protected virtual void OnPanStart(CancelEventArgs e)
method OnParentChanged (line 4256) | protected override void OnParentChanged(EventArgs e)
method OnPixelGridColorChanged (line 4268) | protected virtual void OnPixelGridColorChanged(EventArgs e)
method OnPixelGridThresholdChanged (line 4283) | protected virtual void OnPixelGridThresholdChanged(EventArgs e)
method OnResize (line 4298) | protected override void OnResize(EventArgs e)
method OnScaleTextChanged (line 4309) | protected virtual void OnScaleTextChanged(EventArgs e)
method OnScroll (line 4326) | protected override void OnScroll(ScrollEventArgs se)
method OnSelected (line 4339) | protected virtual void OnSelected(EventArgs e)
method OnSelecting (line 4365) | protected virtual void OnSelecting(ImageBoxCancelEventArgs e)
method OnSelectionColorChanged (line 4380) | protected virtual void OnSelectionColorChanged(EventArgs e)
method OnSelectionModeChanged (line 4395) | protected virtual void OnSelectionModeChanged(EventArgs e)
method OnSelectionRegionChanged (line 4410) | protected virtual void OnSelectionRegionChanged(EventArgs e)
method OnShortcutsEnabledChanged (line 4427) | protected virtual void OnShortcutsEnabledChanged(EventArgs e)
method OnShowPixelGridChanged (line 4442) | protected virtual void OnShowPixelGridChanged(EventArgs e)
method OnSizeModeChanged (line 4457) | protected virtual void OnSizeModeChanged(EventArgs e)
method OnSizeToFitChanged (line 4474) | protected virtual void OnSizeToFitChanged(EventArgs e)
method OnTextAlignChanged (line 4489) | protected virtual void OnTextAlignChanged(EventArgs e)
method OnTextBackColorChanged (line 4504) | protected virtual void OnTextBackColorChanged(EventArgs e)
method OnTextChanged (line 4519) | protected override void OnTextChanged(EventArgs e)
method OnTextDisplayModeChanged (line 4530) | protected virtual void OnTextDisplayModeChanged(EventArgs e)
method OnTextPaddingChanged (line 4545) | protected virtual void OnTextPaddingChanged(EventArgs e)
method OnVirtualDraw (line 4562) | protected virtual void OnVirtualDraw(PaintEventArgs e)
method OnVirtualModeChanged (line 4577) | protected virtual void OnVirtualModeChanged(EventArgs e)
method OnVirtualSizeChanged (line 4594) | protected virtual void OnVirtualSizeChanged(EventArgs e)
method OnZoomChanged (line 4611) | protected virtual void OnZoomChanged(EventArgs e)
method OnZoomed (line 4626) | protected virtual void OnZoomed(ImageBoxZoomEventArgs e)
method OnZoomLevelsChanged (line 4641) | protected virtual void OnZoomLevelsChanged(EventArgs e)
method ProcessImageShortcuts (line 4656) | protected virtual void ProcessImageShortcuts(KeyEventArgs e)
method ProcessMouseZoom (line 4705) | protected virtual void ProcessMouseZoom(bool isZoomIn, Point cursorPos...
method ProcessPanning (line 4716) | protected virtual void ProcessPanning(MouseEventArgs e)
method ProcessScrollingShortcuts (line 4757) | protected virtual void ProcessScrollingShortcuts(KeyEventArgs e)
method ProcessSelection (line 4785) | protected virtual void ProcessSelection(MouseEventArgs e)
method RestoreSizeMode (line 4853) | protected void RestoreSizeMode()
method StartDrag (line 4869) | protected virtual void StartDrag(MouseEventArgs e)
method UpdateScrollPosition (line 4891) | protected virtual void UpdateScrollPosition(Point position)
method CanPan (line 4898) | private bool CanPan(MouseButtons button)
method CreateTimer (line 4903) | private void CreateTimer()
method DoMouseWheelZoom (line 4916) | private void DoMouseWheelZoom(MouseEventArgs e)
method DrawPanAllSymbol (line 4931) | private void DrawPanAllSymbol(PaintEventArgs e)
method FreePanTimerTickHandler (line 4945) | private void FreePanTimerTickHandler(object sender, EventArgs e)
method GetDistance (line 4992) | private int GetDistance(int x1, int y1, int x2, int y2)
method GetDistance (line 5013) | private int GetDistance(int x1, int x2)
method GetImageSize (line 5029) | private Size GetImageSize()
method GetPanDirection (line 5054) | private ImageBoxPanDirection GetPanDirection(Point location)
method GetZoomLevel (line 5095) | private int GetZoomLevel(ImageBoxZoomActions action)
method InitializeGridTile (line 5123) | private void InitializeGridTile()
method KillTimer (line 5144) | private void KillTimer()
method OnFrameChangedHandler (line 5160) | private void OnFrameChangedHandler(object sender, EventArgs eventArgs)
method PerformActualSize (line 5169) | private void PerformActualSize(ImageBoxActionSources source)
method PerformZoom (line 5181) | private void PerformZoom(ImageBoxZoomActions action, ImageBoxActionSou...
method PerformZoom (line 5193) | private void PerformZoom(ImageBoxZoomActions action, ImageBoxActionSou...
method PerformZoomIn (line 5217) | private void PerformZoomIn(ImageBoxActionSources source, bool preserve...
method PerformZoomOut (line 5227) | private void PerformZoomOut(ImageBoxActionSources source, bool preserv...
method ProcessPanEvents (line 5236) | private void ProcessPanEvents(ImageBoxPanStyle panStyle)
method SetCursor (line 5279) | private void SetCursor(Point location)
method SetZoom (line 5304) | private void SetZoom(int value, ImageBoxZoomActions actions, ImageBoxA...
FILE: Cyotek.Windows.Forms.ImageBox/ImageBoxActionSources.cs
type ImageBoxActionSources (line 17) | [Flags]
FILE: Cyotek.Windows.Forms.ImageBox/ImageBoxBorderStyle.cs
type ImageBoxBorderStyle (line 15) | public enum ImageBoxBorderStyle
FILE: Cyotek.Windows.Forms.ImageBox/ImageBoxCancelEventArgs.cs
class ImageBoxCancelEventArgs (line 18) | public class ImageBoxCancelEventArgs : CancelEventArgs
method ImageBoxCancelEventArgs (line 26) | public ImageBoxCancelEventArgs(Point location)
method ImageBoxCancelEventArgs (line 39) | protected ImageBoxCancelEventArgs()
FILE: Cyotek.Windows.Forms.ImageBox/ImageBoxGridDisplayMode.cs
type ImageBoxGridDisplayMode (line 15) | public enum ImageBoxGridDisplayMode
FILE: Cyotek.Windows.Forms.ImageBox/ImageBoxGridScale.cs
type ImageBoxGridScale (line 15) | public enum ImageBoxGridScale
FILE: Cyotek.Windows.Forms.ImageBox/ImageBoxMouseWheelMessageFilter.cs
class ImageBoxMouseWheelMessageFilter (line 25) | internal sealed class ImageBoxMouseWheelMessageFilter : IMessageFilter
method ImageBoxMouseWheelMessageFilter (line 40) | private ImageBoxMouseWheelMessageFilter()
method PreFilterMessage (line 94) | bool IMessageFilter.PreFilterMessage(ref Message m)
FILE: Cyotek.Windows.Forms.ImageBox/ImageBoxMouseWheelMode.cs
type ImageBoxMouseWheelMode (line 6) | public enum ImageBoxMouseWheelMode
FILE: Cyotek.Windows.Forms.ImageBox/ImageBoxNativeMethods.cs
class NativeMethods (line 24) | internal partial class NativeMethods // partial for when linking this fi...
type SIF (line 30) | [Flags]
method NativeMethods (line 110) | private NativeMethods()
method GetScrollInfo (line 117) | [DllImport("user32.dll", SetLastError = true)]
method GetTickCount (line 120) | [DllImport("kernel32.dll")]
method GetWindowLong (line 123) | [DllImport("user32.dll", SetLastError = true)]
method SetScrollInfo (line 126) | [DllImport("user32.dll")]
method SetWindowLong (line 129) | [DllImport("user32.dll")]
method WindowFromPoint (line 132) | [DllImport("user32.dll")]
method SendMessage (line 135) | [DllImport("user32.dll", SetLastError = false)]
class SCROLLINFO (line 142) | [StructLayout(LayoutKind.Sequential, Pack = 1)]
method SCROLLINFO (line 159) | public SCROLLINFO()
FILE: Cyotek.Windows.Forms.ImageBox/ImageBoxPanDirection.cs
type ImageBoxPanDirection (line 3) | internal enum ImageBoxPanDirection
FILE: Cyotek.Windows.Forms.ImageBox/ImageBoxPanMode.cs
type ImageBoxPanMode (line 9) | [Flags]
FILE: Cyotek.Windows.Forms.ImageBox/ImageBoxPanStyle.cs
type ImageBoxPanStyle (line 7) | internal enum ImageBoxPanStyle
FILE: Cyotek.Windows.Forms.ImageBox/ImageBoxSelectionMode.cs
type ImageBoxSelectionMode (line 15) | public enum ImageBoxSelectionMode
FILE: Cyotek.Windows.Forms.ImageBox/ImageBoxSizeMode.cs
type ImageBoxSizeMode (line 15) | public enum ImageBoxSizeMode
FILE: Cyotek.Windows.Forms.ImageBox/ImageBoxZoomActions.cs
type ImageBoxZoomActions (line 17) | [Flags]
FILE: Cyotek.Windows.Forms.ImageBox/ImageBoxZoomEventArgs.cs
class ImageBoxZoomEventArgs (line 17) | public class ImageBoxZoomEventArgs : EventArgs
method ImageBoxZoomEventArgs (line 28) | public ImageBoxZoomEventArgs(ImageBoxZoomActions actions, ImageBoxActi...
method ImageBoxZoomEventArgs (line 44) | protected ImageBoxZoomEventArgs()
FILE: Cyotek.Windows.Forms.ImageBox/ScrollControl.cs
class ScrollControl (line 18) | [ToolboxItem(false)]
method ScrollControl (line 42) | public ScrollControl()
method OnEnabledChanged (line 140) | protected override void OnEnabledChanged(EventArgs e)
method OnMouseDown (line 153) | protected override void OnMouseDown(MouseEventArgs e)
method OnMouseWheel (line 169) | protected override void OnMouseWheel(MouseEventArgs e)
method WndProc (line 228) | [DebuggerStepThrough]
method ScrollTo (line 537) | public void ScrollTo(int x, int y)
method GetEventType (line 553) | protected ScrollEventType GetEventType(IntPtr wParam)
method OnBorderStyleChanged (line 586) | protected virtual void OnBorderStyleChanged(EventArgs e)
method OnPageSizeChanged (line 606) | protected virtual void OnPageSizeChanged(EventArgs e)
method OnScroll (line 626) | protected virtual void OnScroll(ScrollEventArgs e)
method OnScrollSizeChanged (line 647) | protected virtual void OnScrollSizeChanged(EventArgs e)
method OnStepSizeChanged (line 667) | protected virtual void OnStepSizeChanged(EventArgs e)
method ScrollTo (line 684) | protected virtual void ScrollTo(ScrollOrientation scrollbar, int value)
method UpdateHorizontalScroll (line 715) | protected virtual void UpdateHorizontalScroll()
method UpdateHorizontalScrollbar (line 733) | protected virtual void UpdateHorizontalScrollbar()
method UpdateScrollbars (line 764) | protected void UpdateScrollbars()
method UpdateVerticalScroll (line 773) | protected virtual void UpdateVerticalScroll()
method UpdateVerticalScrollbar (line 791) | protected virtual void UpdateVerticalScrollbar()
method WmScroll (line 825) | protected virtual void WmScroll(ref Message msg)
method GetScrollInfo (line 912) | private NativeMethods.SCROLLINFO GetScrollInfo(ScrollOrientation scrol...
method SetScrollInfo (line 934) | private int SetScrollInfo(ScrollOrientation scrollbar, NativeMethods.S...
FILE: Cyotek.Windows.Forms.ImageBox/ScrollProperties.cs
class ScrollControl (line 7) | partial class ScrollControl
class HScrollProperties (line 14) | public class HScrollProperties : ScrollProperties
method HScrollProperties (line 22) | public HScrollProperties(ScrollControl container)
class ScrollProperties (line 32) | public abstract class ScrollProperties
method ScrollProperties (line 46) | protected ScrollProperties(ScrollControl container)
class VScrollProperties (line 121) | public class VScrollProperties : ScrollProperties
method VScrollProperties (line 129) | public VScrollProperties(ScrollControl container)
FILE: Cyotek.Windows.Forms.ImageBox/VirtualScrollableControl.cs
class VirtualScrollableControl (line 13) | [ToolboxItem(false)]
method VirtualScrollableControl (line 33) | public VirtualScrollableControl()
method OnResize (line 81) | protected override void OnResize(EventArgs e)
method OnScroll (line 125) | protected override void OnScroll(ScrollEventArgs e)
method OnVisibleChanged (line 149) | protected override void OnVisibleChanged(EventArgs e)
method ScrollControlIntoView (line 310) | public void ScrollControlIntoView(Control activeControl)
method AdjustPositionToSize (line 334) | protected Point AdjustPositionToSize(Point position)
method OnAutoScrollChanged (line 368) | protected virtual void OnAutoScrollChanged(EventArgs e)
method OnAutoScrollMarginChanged (line 386) | protected virtual void OnAutoScrollMarginChanged(EventArgs e)
method OnAutoScrollMinSizeChanged (line 404) | protected virtual void OnAutoScrollMinSizeChanged(EventArgs e)
method OnAutoScrollPositionChanged (line 425) | protected virtual void OnAutoScrollPositionChanged(EventArgs e)
method AdjustScrollbars (line 444) | private void AdjustScrollbars()
method ScrollByOffset (line 484) | private void ScrollByOffset(Size offset)
FILE: Cyotek.Windows.Forms.ImageBox/ZoomLevelCollection.cs
class ZoomLevelCollection (line 19) | public class ZoomLevelCollection : IList<int>
method ZoomLevelCollection (line 26) | public ZoomLevelCollection()
method ZoomLevelCollection (line 36) | public ZoomLevelCollection(IEnumerable<int> collection)
method Add (line 122) | public void Add(int item)
method AddRange (line 132) | public void AddRange(IEnumerable<int> collection)
method Clear (line 148) | public void Clear()
method Contains (line 158) | public bool Contains(int item)
method CopyTo (line 168) | public void CopyTo(int[] array, int arrayIndex)
method FindNearest (line 180) | public int FindNearest(int zoomLevel)
method GetEnumerator (line 201) | public IEnumerator<int> GetEnumerator()
method IndexOf (line 211) | public int IndexOf(int item)
method Insert (line 222) | public void Insert(int index, int item)
method NextZoom (line 232) | public int NextZoom(int zoomLevel)
method PreviousZoom (line 250) | public int PreviousZoom(int zoomLevel)
method Remove (line 268) | public bool Remove(int item)
method RemoveAt (line 277) | public void RemoveAt(int index)
method ToArray (line 286) | public int[] ToArray()
method GetEnumerator (line 304) | IEnumerator IEnumerable.GetEnumerator()
FILE: Cyotek.Windows.Forms.ImageBox/ZoomLevelCollectionConverter.cs
class ZoomLevelCollectionConverter (line 14) | public class ZoomLevelCollectionConverter
method CanConvertFrom (line 17) | public override bool CanConvertFrom(ITypeDescriptorContext context, Ty...
method CanConvertTo (line 22) | public override bool CanConvertTo(ITypeDescriptorContext context, Type...
method ConvertFrom (line 27) | public override object ConvertFrom(ITypeDescriptorContext context, Cul...
method ConvertTo (line 56) | public override object ConvertTo(ITypeDescriptorContext context, Cultu...
Condensed preview — 110 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (866K chars).
[
{
"path": ".editorconfig",
"chars": 268,
"preview": "; http://editorconfig.org/\n; https://visualstudiogallery.msdn.microsoft.com/c8bccfe2-650c-4b42-bc5c-845e21f96328\n\nroot=t"
},
{
"path": ".github/workflows/codeql-analysis.yml",
"chars": 2333,
"preview": "name: \"CodeQL\"\n\non:\n push:\n branches: [master]\n pull_request:\n # The branches below must be a subset of the bran"
},
{
"path": ".gitignore",
"chars": 99,
"preview": ".vs/\nbin/\nobj/\n_NCrunch_*\nnuget/\npackages/\nmaps/\n\n*.ncrunch*\n*.user\npush.cmd\n*.suo\n*.ncrunchproject"
},
{
"path": ".markdownlint.json",
"chars": 38,
"preview": "{\n \"MD001\": false,\n \"MD024\": false\n}"
},
{
"path": "CHANGELOG.md",
"chars": 14231,
"preview": "# Cyotek ImageBox Change Log\n\n## 1.4.0\n\n### Added\n\n* Added new `MouseWheelMode` property to control how the mouse\n whee"
},
{
"path": "Cyotek.Windows.Forms.ImageBox/Cyotek.Windows.Forms.ImageBox.csproj",
"chars": 4301,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"4.0\" DefaultTargets=\"Build\" xmlns=\"http://schemas.microso"
},
{
"path": "Cyotek.Windows.Forms.ImageBox/Cyotek.Windows.Forms.ImageBox.nuspec",
"chars": 1463,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<package xmlns=\"http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd\">\n <"
},
{
"path": "Cyotek.Windows.Forms.ImageBox/ImageBox.cs",
"chars": 167607,
"preview": "// Cyotek ImageBox\n// http://cyotek.com/blog/tag/imagebox\n\n// Copyright (c) 2010-2021 Cyotek Ltd.\n\n// This work is licen"
},
{
"path": "Cyotek.Windows.Forms.ImageBox/ImageBoxActionSources.cs",
"chars": 668,
"preview": "using System;\n\nnamespace Cyotek.Windows.Forms\n{\n // Cyotek ImageBox\n // Copyright (c) 2010-2015 Cyotek Ltd.\n // http"
},
{
"path": "Cyotek.Windows.Forms.ImageBox/ImageBoxBorderStyle.cs",
"chars": 881,
"preview": "namespace Cyotek.Windows.Forms\n{\n // Cyotek ImageBox\n // Copyright (c) 2010-2015 Cyotek Ltd.\n // http://cyotek.com\n "
},
{
"path": "Cyotek.Windows.Forms.ImageBox/ImageBoxCancelEventArgs.cs",
"chars": 1393,
"preview": "using System.ComponentModel;\nusing System.Drawing;\n\nnamespace Cyotek.Windows.Forms\n{\n // Cyotek ImageBox\n // Copyrigh"
},
{
"path": "Cyotek.Windows.Forms.ImageBox/ImageBoxGridDisplayMode.cs",
"chars": 783,
"preview": "namespace Cyotek.Windows.Forms\n{\n // Cyotek ImageBox\n // Copyright (c) 2010-2015 Cyotek Ltd.\n // http://cyotek.com\n "
},
{
"path": "Cyotek.Windows.Forms.ImageBox/ImageBoxGridScale.cs",
"chars": 889,
"preview": "namespace Cyotek.Windows.Forms\n{\n // Cyotek ImageBox\n // Copyright (c) 2010-2015 Cyotek Ltd.\n // http://cyotek.com\n "
},
{
"path": "Cyotek.Windows.Forms.ImageBox/ImageBoxMouseWheelMessageFilter.cs",
"chars": 4141,
"preview": "using System;\nusing System.Drawing;\nusing System.Windows.Forms;\n#if USEWIN32PINVOKELIB\nusing Cyotek.Win32;\n#endif\n\n// C"
},
{
"path": "Cyotek.Windows.Forms.ImageBox/ImageBoxMouseWheelMode.cs",
"chars": 527,
"preview": "namespace Cyotek.Windows.Forms\n{\n /// <summary>\n /// Specifies the way the mouse wheel is handled for the <see cref=\"I"
},
{
"path": "Cyotek.Windows.Forms.ImageBox/ImageBoxNativeMethods.cs",
"chars": 3948,
"preview": "// Cyotek ImageBox\n// http://cyotek.com/blog/tag/imagebox\n\n// Copyright (c) 2010-2021 Cyotek Ltd.\n\n// This work is licen"
},
{
"path": "Cyotek.Windows.Forms.ImageBox/ImageBoxPanDirection.cs",
"chars": 133,
"preview": "namespace Cyotek.Windows.Forms\n{\n internal enum ImageBoxPanDirection\n {\n None,\n\n Up,\n\n Down,\n\n Left,\n\n "
},
{
"path": "Cyotek.Windows.Forms.ImageBox/ImageBoxPanMode.cs",
"chars": 786,
"preview": "using System;\nusing System.Windows.Forms;\n\nnamespace Cyotek.Windows.Forms\n{\n /// <summary>\n /// Specifies constants t"
},
{
"path": "Cyotek.Windows.Forms.ImageBox/ImageBoxPanStyle.cs",
"chars": 178,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace Cyotek.Windows.Forms\n{\n internal enum Im"
},
{
"path": "Cyotek.Windows.Forms.ImageBox/ImageBoxSelectionMode.cs",
"chars": 684,
"preview": "namespace Cyotek.Windows.Forms\n{\n // Cyotek ImageBox\n // Copyright (c) 2010-2015 Cyotek Ltd.\n // http://cyotek.com\n "
},
{
"path": "Cyotek.Windows.Forms.ImageBox/ImageBoxSizeMode.cs",
"chars": 961,
"preview": "namespace Cyotek.Windows.Forms\n{\n // Cyotek ImageBox\n // Copyright (c) 2010-2015 Cyotek Ltd.\n // http://cyotek.com\n "
},
{
"path": "Cyotek.Windows.Forms.ImageBox/ImageBoxZoomActions.cs",
"chars": 842,
"preview": "using System;\n\nnamespace Cyotek.Windows.Forms\n{\n // Cyotek ImageBox\n // Copyright (c) 2010-2015 Cyotek Ltd.\n // http"
},
{
"path": "Cyotek.Windows.Forms.ImageBox/ImageBoxZoomEventArgs.cs",
"chars": 2197,
"preview": "using System;\n\nnamespace Cyotek.Windows.Forms\n{\n // Cyotek ImageBox\n // Copyright (c) 2010-2015 Cyotek Ltd.\n // http"
},
{
"path": "Cyotek.Windows.Forms.ImageBox/Properties/AssemblyInfo.cs",
"chars": 781,
"preview": "using System;\nusing System.Reflection;\nusing System.Runtime.InteropServices;\n\n// TODO: Next major version reset Assembly"
},
{
"path": "Cyotek.Windows.Forms.ImageBox/ScrollControl.cs",
"chars": 26711,
"preview": "using System;\nusing System.ComponentModel;\nusing System.Diagnostics;\nusing System.Drawing;\nusing System.Windows.Forms;\n"
},
{
"path": "Cyotek.Windows.Forms.ImageBox/ScrollProperties.cs",
"chars": 4468,
"preview": "using System.ComponentModel;\n\n// Original ScrollControl code by Scott Crawford (http://sukiware.com/)\n\nnamespace Cyotek"
},
{
"path": "Cyotek.Windows.Forms.ImageBox/VirtualScrollableControl.cs",
"chars": 13573,
"preview": "using System;\nusing System.ComponentModel;\nusing System.Drawing;\nusing System.Windows.Forms;\n\n// Original VirtualScroll"
},
{
"path": "Cyotek.Windows.Forms.ImageBox/ZoomLevelCollection.cs",
"chars": 9943,
"preview": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\n\nnamespace Cyotek.Windows.Forms\n{\n // Cyotek"
},
{
"path": "Cyotek.Windows.Forms.ImageBox/ZoomLevelCollectionConverter.cs",
"chars": 3251,
"preview": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.ComponentModel;\nusing System.Com"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/AboutDialog.cs",
"chars": 5613,
"preview": "using System;\nusing System.Diagnostics;\nusing System.Drawing;\nusing System.IO;\nusing System.Reflection;\nusing System.Win"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/AboutDialog.designer.cs",
"chars": 8068,
"preview": "namespace Cyotek.Windows.Forms.Demo\n{\n partial class AboutDialog\n {\n /// <summary>\n /// Required designer variab"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/AboutDialog.resx",
"chars": 5887,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root>\n <!-- \n Microsoft ResX Schema \n \n Version 2.0\n \n The prima"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/AnimatedGifDemoForm.Designer.cs",
"chars": 7284,
"preview": "namespace Cyotek.Windows.Forms.Demo\n{\n partial class AnimatedGifDemoForm\n {\n /// <summary>\n /// Required design"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/AnimatedGifDemoForm.cs",
"chars": 828,
"preview": "using System;\n\nnamespace Cyotek.Windows.Forms.Demo\n{\n // Cyotek ImageBox\n // Copyright (c) 2010-2015 Cyotek Ltd.\n //"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/AnimatedGifDemoForm.resx",
"chars": 6088,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root>\n <!-- \n Microsoft ResX Schema \n \n Version 2.0\n \n The prim"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/BaseForm.Designer.cs",
"chars": 1384,
"preview": "namespace Cyotek.Windows.Forms.Demo\n{\n partial class BaseForm\n {\n /// <summary>\n /// Required designer variable"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/BaseForm.cs",
"chars": 1281,
"preview": "using System;\nusing System.Drawing;\nusing System.Windows.Forms;\n\nnamespace Cyotek.Windows.Forms.Demo\n{\n // Cyotek Imag"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/BaseForm.resx",
"chars": 5696,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root>\n <!-- \n Microsoft ResX Schema \n \n Version 2.0\n \n The prim"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/Cyotek.Windows.Forms.ImageBox.Demo.csproj",
"chars": 12687,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"4.0\" DefaultTargets=\"Build\" xmlns=\"http://schemas.microso"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/DisposedImageDemoForm.Designer.cs",
"chars": 5512,
"preview": "namespace Cyotek.Windows.Forms.Demo\n{\n partial class DisposedImageDemoForm\n {\n /// <summary>\n /// Required desi"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/DisposedImageDemoForm.cs",
"chars": 1146,
"preview": "using System;\nusing System.Drawing;\n\nnamespace Cyotek.Windows.Forms.Demo\n{\n // Cyotek ImageBox\n // Copyright (c) 2010"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/DisposedImageDemoForm.resx",
"chars": 6088,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root>\n <!-- \n Microsoft ResX Schema \n \n Version 2.0\n \n The prim"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/DragHandle.cs",
"chars": 930,
"preview": "using System.Drawing;\n\nnamespace Cyotek.Windows.Forms.Demo\n{\n // Cyotek ImageBox\n // Copyright (c) 2010-2015 Cyotek L"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/DragHandleAnchor.cs",
"chars": 530,
"preview": "namespace Cyotek.Windows.Forms.Demo\n{\n // Cyotek ImageBox\n // Copyright (c) 2010-2015 Cyotek Ltd.\n // http://cyotek."
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/DragHandleCollection.cs",
"chars": 2892,
"preview": "using System.Collections;\nusing System.Collections.Generic;\nusing System.Drawing;\n\nnamespace Cyotek.Windows.Forms.Demo\n"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/DragTestForm.Designer.cs",
"chars": 8317,
"preview": "namespace Cyotek.Windows.Forms.Demo\n{\n partial class DragTestForm\n {\n /// <summary>\n /// Required designer vari"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/DragTestForm.cs",
"chars": 3681,
"preview": "using System;\nusing System.Drawing;\nusing System.Windows.Forms;\n\nnamespace Cyotek.Windows.Forms.Demo\n{\n // Cyotek Imag"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/DragTestForm.resx",
"chars": 6774,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root>\n <!-- \n Microsoft ResX Schema \n \n Version 2.0\n \n The prim"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/EventsListBox.cs",
"chars": 1566,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.Windows.Forms;\n\nnamespace Cyotek.Window"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/FilteredPropertyGrid.cs",
"chars": 12528,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.ComponentModel;\n\n// Derived from https://www.codeproject.co"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/GeneralDemoForm.Designer.cs",
"chars": 31513,
"preview": "namespace Cyotek.Windows.Forms.Demo\n{\n partial class GeneralDemoForm\n {\n /// <summary>\n /// Required designer v"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/GeneralDemoForm.cs",
"chars": 7908,
"preview": "using System;\nusing System.Drawing;\nusing System.Drawing.Drawing2D;\nusing System.IO;\nusing System.Net;\nusing System.Wind"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/GeneralDemoForm.resx",
"chars": 7469,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root>\n <!-- \n Microsoft ResX Schema \n \n Version 2.0\n \n The prima"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/GroupBox.cs",
"chars": 9637,
"preview": "using System;\nusing System.ComponentModel;\nusing System.ComponentModel.Design;\nusing System.Drawing;\nusing System.Drawin"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/ImageBoxEx.cs",
"chars": 26982,
"preview": "using System;\nusing System.ComponentModel;\nusing System.Drawing;\nusing System.Windows.Forms;\n\nnamespace Cyotek.Windows."
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/MainMenuForm.cs",
"chars": 3185,
"preview": "// Cyotek ImageBox\n// http://cyotek.com/blog/tag/imagebox\n\n// Copyright (c) 2010-2021 Cyotek Ltd.\n\n// This work is licen"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/MainMenuForm.designer.cs",
"chars": 14008,
"preview": "namespace Cyotek.Windows.Forms.Demo\n{\n partial class MainMenuForm\n {\n /// <summary>\n /// Required designer vari"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/MainMenuForm.resx",
"chars": 14046,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root>\n <!-- \n Microsoft ResX Schema \n \n Version 2.0\n \n The prim"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/MiniMapDemoForm.cs",
"chars": 6578,
"preview": "// Cyotek ImageBox\n// Copyright (c) 2010-2017 Cyotek Ltd.\n// http://cyotek.com\n// http://cyotek.com/blog/tag/imagebox\n\n"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/MiniMapDemoForm.designer.cs",
"chars": 9176,
"preview": "namespace Cyotek.Windows.Forms.Demo\n{\n partial class MiniMapDemoForm\n {\n /// <summary>\n /// Required designer v"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/MiniMapDemoForm.resx",
"chars": 6088,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root>\n <!-- \n Microsoft ResX Schema \n \n Version 2.0\n \n The prim"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/OpenUrlDialog.Designer.cs",
"chars": 4673,
"preview": "namespace Cyotek.Windows.Forms.Demo\n{\n partial class OpenUrlDialog\n {\n /// <summary>\n /// Required designer var"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/OpenUrlDialog.cs",
"chars": 1557,
"preview": "using System;\nusing System.ComponentModel;\nusing System.Windows.Forms;\n\n// Cyotek ImageBox\n// Copyright (c) 2010-2017 C"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/OpenUrlDialog.resx",
"chars": 5696,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root>\n <!-- \n Microsoft ResX Schema \n \n Version 2.0\n \n The prim"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/PanStylesDemoForm.Designer.cs",
"chars": 10386,
"preview": "namespace Cyotek.Windows.Forms.Demo\n{\n partial class PanStylesDemoForm\n {\n /// <summary>\n /// Required designer "
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/PanStylesDemoForm.cs",
"chars": 1494,
"preview": "// Cyotek ImageBox\n// http://cyotek.com/blog/tag/imagebox\n\n// Copyright (c) 2021 Cyotek Ltd.\n\n// This work is licensed u"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/PanStylesDemoForm.resx",
"chars": 7067,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root>\n <!-- \n Microsoft ResX Schema \n \n Version 2.0\n \n The prim"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/PixelGridForm.Designer.cs",
"chars": 7293,
"preview": "namespace Cyotek.Windows.Forms.Demo\n{\n partial class PixelGridForm\n {\n /// <summary>\n /// Required designer var"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/PixelGridForm.cs",
"chars": 996,
"preview": "using System;\n\nnamespace Cyotek.Windows.Forms.Demo\n{\n // Cyotek ImageBox\n // Copyright (c) 2010-2015 Cyotek Ltd.\n //"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/PixelGridForm.resx",
"chars": 6088,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root>\n <!-- \n Microsoft ResX Schema \n \n Version 2.0\n \n The prim"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/Program.cs",
"chars": 763,
"preview": "using System;\nusing System.Windows.Forms;\n\nnamespace Cyotek.Windows.Forms.Demo\n{\n // Cyotek ImageBox\n // Copyright (c"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/Properties/AssemblyInfo.cs",
"chars": 642,
"preview": "using System;\nusing System.Reflection;\nusing System.Runtime.InteropServices;\n\n[assembly: AssemblyTitle(\"Cyotek ImageBox"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/Properties/Resources.Designer.cs",
"chars": 11753,
"preview": "//------------------------------------------------------------------------------\n// <auto-generated>\n// This code w"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/Properties/Resources.resx",
"chars": 11638,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root>\n <!-- \n Microsoft ResX Schema \n \n Version 2.0\n \n The prim"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/PropertyGrid.cs",
"chars": 1765,
"preview": "using System.Collections.Generic;\nusing System.Windows.Forms;\n\nnamespace Cyotek.Windows.Forms.Demo\n{\n // Cyotek ImageB"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/ResizableSelectionDemoForm.Designer.cs",
"chars": 24605,
"preview": "namespace Cyotek.Windows.Forms.Demo\n{\n partial class ResizableSelectionDemoForm\n {\n /// <summary>\n /// Required"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/ResizableSelectionDemoForm.cs",
"chars": 7367,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.ComponentModel;\nusing System.Drawing;\nusing System.Windows"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/ResizableSelectionDemoForm.resx",
"chars": 6558,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root>\n <!-- \n Microsoft ResX Schema \n \n Version 2.0\n \n The prim"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/Resources/markdownpad-github.css",
"chars": 4975,
"preview": "/* GitHub stylesheet for MarkdownPad (http://markdownpad.com) */\n/* Author: Nicolas Hery - http://nicolashery.com */\n/*"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/ScaledAdornmentsDemoForm.Designer.cs",
"chars": 10372,
"preview": "namespace Cyotek.Windows.Forms.Demo\n{\n partial class ScaledAdornmentsDemoForm\n {\n /// <summary>\n /// Required d"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/ScaledAdornmentsDemoForm.cs",
"chars": 3785,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Drawing;\nusing System.Drawing.Dr"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/ScaledAdornmentsDemoForm.resx",
"chars": 6760,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root>\n <!-- \n Microsoft ResX Schema \n \n Version 2.0\n \n The prim"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/SizeModeDemoForm.Designer.cs",
"chars": 11251,
"preview": "namespace Cyotek.Windows.Forms.Demo\n{\n partial class SizeModeDemoForm\n {\n /// <summary>\n /// Required designer "
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/SizeModeDemoForm.cs",
"chars": 817,
"preview": "using System;\n\nnamespace Cyotek.Windows.Forms.Demo\n{\n // Cyotek ImageBox\n // Copyright (c) 2010-2015 Cyotek Ltd.\n //"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/SizeModeDemoForm.resx",
"chars": 95045,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root>\n <!-- \n Microsoft ResX Schema \n \n Version 2.0\n \n The prim"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/SwitchImageDuringZoomDemoForm.Designer.cs",
"chars": 9205,
"preview": "namespace Cyotek.Windows.Forms.Demo\n{\n partial class SwitchImageDuringZoomDemoForm\n {\n /// <summary>\n /// Requi"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/SwitchImageDuringZoomDemoForm.cs",
"chars": 9278,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.Drawing;\nusing System.IO;\nusing System.Windows.Forms;\n\nnam"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/SwitchImageDuringZoomDemoForm.resx",
"chars": 6491,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root>\n <!-- \n Microsoft ResX Schema \n \n Version 2.0\n \n The prim"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/TextDemoForm.Designer.cs",
"chars": 7321,
"preview": "namespace Cyotek.Windows.Forms.Demo\n{\n partial class TextDemoForm\n {\n /// <summary>\n /// Required designer vari"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/TextDemoForm.cs",
"chars": 1098,
"preview": "using System;\n\nnamespace Cyotek.Windows.Forms.Demo\n{\n // Cyotek ImageBox\n // Copyright (c) 2010-2015 Cyotek Ltd.\n //"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/TextDemoForm.resx",
"chars": 6088,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root>\n <!-- \n Microsoft ResX Schema \n \n Version 2.0\n \n The prim"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/VirtualModeDemonstrationForm.Designer.cs",
"chars": 7216,
"preview": "namespace Cyotek.Windows.Forms.Demo\n{\n partial class VirtualModeDemonstrationForm\n {\n /// <summary>\n /// Requir"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/VirtualModeDemonstrationForm.cs",
"chars": 2054,
"preview": "using System;\nusing System.Drawing;\nusing System.Windows.Forms;\n\nnamespace Cyotek.Windows.Forms.Demo\n{\n // Cyotek Imag"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/VirtualModeDemonstrationForm.resx",
"chars": 6088,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root>\n <!-- \n Microsoft ResX Schema \n \n Version 2.0\n \n The prim"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/app.manifest",
"chars": 2389,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<asmv1:assembly manifestVersion=\"1.0\" xmlns=\"urn:schemas-microsoft-com:asm.v1\" x"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Demo/packages.config",
"chars": 298,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<packages>\n <package id=\"CommonMark.NET\" version=\"0.9.0\" targetFramework=\"net35"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Design/Cyotek.Windows.Forms.ImageBox.Design.csproj",
"chars": 2589,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"4.0\" DefaultTargets=\"Build\" xmlns=\"http://schemas.microso"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Design/ImageBoxDesigner.cs",
"chars": 7183,
"preview": "using System;\nusing System.ComponentModel;\nusing System.ComponentModel.Design;\nusing System.Windows.Forms;\nusing System"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.Design/Properties/AssemblyInfo.cs",
"chars": 645,
"preview": "using System;\nusing System.Reflection;\nusing System.Runtime.InteropServices;\n\n[assembly: AssemblyTitle(\"Cyotek ImageBox"
},
{
"path": "Cyotek.Windows.Forms.ImageBox.sln",
"chars": 2607,
"preview": "\nMicrosoft Visual Studio Solution File, Format Version 12.00\n# Visual Studio 14\nVisualStudioVersion = 14.0.25420.1\nMini"
},
{
"path": "LICENSE.txt",
"chars": 1081,
"preview": "The MIT License (MIT)\n\nCopyright © 2010-2022 Cyotek Ltd.\n\nPermission is hereby granted, free of charge, to any person ob"
},
{
"path": "README.md",
"chars": 1856,
"preview": "# Cyotek ImageBox Control\n\n## About\n\nThe `ImageBox` is a lightweight owner drawn control for displaying images. It\nsuppo"
},
{
"path": "acknowledgements.md",
"chars": 1816,
"preview": "# Acknowledgements\n\n## Graphics\n\n### Toolbar Icons\nToolbar icons from [Fugue Icons](http://p.yusukekamiyamane.com/).\n\n##"
},
{
"path": "build.cmd",
"chars": 755,
"preview": "@ECHO OFF\n\nSETLOCAL\n\nCALL ..\\..\\..\\build\\set35vars.bat\n\n%msbuildexe% Cyotek.Windows.Forms.ImageBox.sln /p:Configuration="
},
{
"path": "nuget.config",
"chars": 105,
"preview": "<configuration>\n <config>\n <add key=\"repositoryPath\" value=\"packages\" />\n </config>\n</configuration>"
}
]
// ... and 5 more files (download for full content)
About this extraction
This page contains the full source code of the cyotek/Cyotek.Windows.Forms.ImageBox GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 110 files (809.5 KB), approximately 234.5k tokens, and a symbol index with 608 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.