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

Last change on this file since 937 was 120, checked in by roman, 9 years ago
File size: 1.5 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(80, 60)
13        Box.PreserveAspectRatio = True
14        Box.Image = Bitmap.FromFile("D:\Projects\Alax.Info\Repository-Public\Snippets\CropImage\20120821_185619 (720x480).jpg")
15        Controls.Add(Box)
16        Box.Dock = DockStyle.Fill
17        Dim CurrentScreen As Screen = Screen.FromControl(Me)
18        Width = CurrentScreen.WorkingArea.Width * 7 / 8
19        Height = CurrentScreen.WorkingArea.Height * 7 / 8
20        Left = (CurrentScreen.WorkingArea.Width - Width) / 2
21        Top = (CurrentScreen.WorkingArea.Height - Height) / 2
22    End Sub
23    Private Sub MainForm_KeyPress(sender As System.Object, e As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress
24        If e.KeyChar = Chr(27) Then Close()
25    End Sub
26    Private Sub MainForm_SelectionChanged(sender As System.Object, e As System.EventArgs) Handles Box.SelectionRectangleChanged
27        Text = String.Format("{0} - {1}", DefaultText, Box.SelectionRectangle)
28    End Sub
29    Private Sub Box_SelectionDoubleClick(sender As Object, e As System.EventArgs) Handles Box.SelectionDoubleClick
30        Me.Close()
31    End Sub
32End Class
Note: See TracBrowser for help on using the repository browser.