source: trunk/Snippets/CropImage/MainForm.vb @ 111

Last change on this file since 111 was 109, checked in by roman, 12 years ago

ImageCropBox? VB.NET UserControl?

File size: 1.4 KB
Line 
1Imports System.Diagnostics
2Imports System.Drawing
3Imports System.Drawing.Imaging
4
5Public Class MainForm
6    Private WithEvents Box As ImageCropBox
7    Private DefaultText As String
8
9    Private Sub MainForm_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
10        DefaultText = Text
11        Box = New ImageCropBox
12        Box.MinimalSelectionSize = New Size(320, 240)
13        Box.Image = Bitmap.FromFile("D:\Projects\Alax.Info\Repository-Public\Snippets\CropImage\20120821_185619.jpg")
14        Controls.Add(Box)
15        Box.Dock = DockStyle.Fill
16        Dim CurrentScreen As Screen = Screen.FromControl(Me)
17        Width = CurrentScreen.WorkingArea.Width * 7 / 8
18        Height = CurrentScreen.WorkingArea.Height * 7 / 8
19        Left = (CurrentScreen.WorkingArea.Width - Width) / 2
20        Top = (CurrentScreen.WorkingArea.Height - Height) / 2
21    End Sub
22    Private Sub MainForm_KeyPress(sender As System.Object, e As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress
23        If e.KeyChar = Chr(27) Then Close()
24    End Sub
25    Private Sub MainForm_SelectionChanged(sender As System.Object, e As System.EventArgs) Handles Box.SelectionRectangleChanged
26        Text = String.Format("{0} - {1}", DefaultText, Box.SelectionRectangle)
27    End Sub
28    Private Sub Box_SelectionDoubleClick(sender As Object, e As System.EventArgs) Handles Box.SelectionDoubleClick
29        Me.Close()
30    End Sub
31End Class
Note: See TracBrowser for help on using the repository browser.