1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197
| Imports CADImport
Imports System.IO
Imports System.Drawing.Imaging
Public Class Form1
Inherits System.Windows.Forms.Form
Private Const OnMouseScroll As Integer = 522
'Private lForm As Form2 = New Form2
Private pos As Point = New Point
Private curClRect As Rectangle
Private wh As Single
Private CADParams As CADIterate
Private TextFile As ArrayList = New ArrayList
Private cX, cY As Integer
Private det1 As Boolean
Private Orb3D As Orbit3D = New Orbit3D
Public Shared FCADImage As CADImage
Private scale As Single = 1
Private ScaleRect As SFPoint
Private layouts As ArrayList = New ArrayList
'Private aboutFrm As AboutForm = New AboutForm
Private vPt As SFPoint
Private old_x, old_y As Integer
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu
Friend WithEvents MenuItem1 As System.Windows.Forms.MenuItem
Friend WithEvents MenuItem2 As System.Windows.Forms.MenuItem
Friend WithEvents OpenFileDialog1 As System.Windows.Forms.OpenFileDialog
Friend WithEvents MenuItem3 As System.Windows.Forms.MenuItem
Friend WithEvents MenuItem4 As System.Windows.Forms.MenuItem
Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox
Friend WithEvents pnlLayout As System.Windows.Forms.Panel
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.MainMenu1 = New System.Windows.Forms.MainMenu
Me.MenuItem1 = New System.Windows.Forms.MenuItem
Me.MenuItem2 = New System.Windows.Forms.MenuItem
Me.MenuItem3 = New System.Windows.Forms.MenuItem
Me.MenuItem4 = New System.Windows.Forms.MenuItem
Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog
Me.pnlLayout = New System.Windows.Forms.Panel
Me.PictureBox1 = New System.Windows.Forms.PictureBox
Me.pnlLayout.SuspendLayout()
Me.SuspendLayout()
'
'MainMenu1
'
Me.MainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem1})
'
'MenuItem1
'
Me.MenuItem1.Index = 0
Me.MenuItem1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem2, Me.MenuItem3, Me.MenuItem4})
Me.MenuItem1.Text = "&File"
'
'MenuItem2
'
Me.MenuItem2.Index = 0
Me.MenuItem2.Text = "&Open"
'
'MenuItem3
'
Me.MenuItem3.Index = 1
Me.MenuItem3.Text = "-"
'
'MenuItem4
'
Me.MenuItem4.Index = 2
Me.MenuItem4.Text = "&Exit"
'
'OpenFileDialog1
'
Me.OpenFileDialog1.Filter = "*.dxf | *.dxf"
'
'pnlLayout
'
Me.pnlLayout.Controls.Add(Me.PictureBox1)
Me.pnlLayout.Location = New System.Drawing.Point(24, 32)
Me.pnlLayout.Name = "pnlLayout"
Me.pnlLayout.Size = New System.Drawing.Size(744, 416)
Me.pnlLayout.TabIndex = 0
'
'PictureBox1
'
Me.PictureBox1.Location = New System.Drawing.Point(8, 8)
Me.PictureBox1.Name = "PictureBox1"
Me.PictureBox1.Size = New System.Drawing.Size(720, 400)
Me.PictureBox1.TabIndex = 0
Me.PictureBox1.TabStop = False
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(800, 622)
Me.Controls.Add(Me.pnlLayout)
Me.Menu = Me.MainMenu1
Me.Name = "Form1"
Me.Text = "Form1"
Me.pnlLayout.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click
PictureBox1.Visible = False 'nécessaire
pos = New Point
If OpenFileDialog1.ShowDialog() <> DialogResult.OK Then
PictureBox1.Visible = True
Return
End If
If (OpenFileDialog1.FileName <> Nothing) Then
'Scale = 1
FCADImage = Nothing
FCADImage = New CADImage
FCADImage.Load(OpenFileDialog1.FileName)
End If
Orb3D.cADImage = FCADImage
Orb3D.visible = False
Orb3D.Disable3dOrbit()
PictureBox1.Visible = True
End Sub
Private Sub Initial3DOrbit()
Orb3D.Parent = Me.pictureBox1
End Sub
Private Sub pictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
If FCADImage Is Nothing Then
Return
End If
Try
Dim tmp As Rectangle = New Rectangle
tmp = curClRect ' indispensable
tmp.Width = CInt(tmp.Width * scale)
tmp.Height = CInt(tmp.Height * scale)
tmp.X += pos.X ' pas indispensable
tmp.Y += pos.Y ' pas indispensable
FCADImage.Draw(e.Graphics, New RectangleF(tmp.X, tmp.Y, tmp.Width, tmp.Height))
Catch
PictureBox1.Visible = False
End Try
End Sub
Private Sub MenuItem4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem4.Click
End
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
wh = 1.0F
curClRect = Me.ClientRectangle
End Sub
End Class |
Partager