1
« en: Jueves 20 de Julio de 2017, 00:36 »
Imports System.Data
Imports System.Data.OleDb
Imports System.Windows.Forms
Imports System.ComponentModel
Imports System.Drawing
Imports System.EventArgs
Public Class Plano
Public XE1xi As Integer
Public YE1yi As Integer
Public XE1xf As Integer
Public YE1yf As Integer
Public XEaxi As Integer
Public YEayi As Integer
Public XEaxf As Integer
Public YEayf As Integer
Public XEbxi As Integer
Public YEbyi As Integer
Public XEbxf As Integer
Public YEbyf As Integer
Public XLtxi As Integer
Public YLtyi As Integer
Public XLtxf As Integer
Public YLtyf As Integer
Public i As Integer
Public cota() As String
Public ac As Integer
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
claveobra = "CasaIng.354"
Conección.ConnectionString = connString
Conección.Open()
facdes = 1.03
AddHandler PictureBox1.Paint, AddressOf picturebox1_Paint
Controls.Add(PictureBox1)
Str = "SELECT elemento FROM ejes where ClaveObra = '" & claveobra & "' group by Elemento "
cmd = New OleDbCommand(Str, Conección)
dr = cmd.ExecuteReader
While dr.Read()
ComboBox7.Items.Add(dr("elemento").ToString())
End While
dr.Close()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
claveobra = "CasaIng.354"
ac = 1
Xejetramo = 80
Yejetramo = 320
Str = "SELECT * FROM ejesplano where claveobra = '" & claveobra & "' and elemento = '" & ComboBox7.Text & "'"
cmd = New OleDbCommand(Str, Conección)
dr = cmd.ExecuteReader
While dr.Read()
'eje 1
Dim myLabelE1 As Label = New Label()
myLabelE1.Size = New Size(20, 20)
PictureBox1.Controls.Add(myLabelE1)
myLabelE1.Text = dr("ejeN").ToString()
'posicion Eje 1
Dim XE1 = Xejetramo - 60
Dim YE1 = Yejetramo - 245
myLabelE1.Location = New Point(XE1, YE1)
'coordenadas de la lina del eje 1
XE1xi = Xejetramo - 30
YE1yi = Yejetramo - 240
XE1xf = Xejetramo
YE1yf = Yejetramo - 240
'PictureBox1.CreateGraphics.DrawLine(Pens.Magenta, XE1xi, YE1yi, XE1xf, YE1yf)
'eje A
Dim myLabel1 As Label = New Label()
myLabel1.Size = New Size(20, 20)
PictureBox1.Controls.Add(myLabel1)
myLabel1.Text = dr("ejeLi").ToString()
'posicion eje A
Dim XEa = Xejetramo - 5
Dim YEa = Yejetramo - 300
myLabel1.Location = New Point(XEa, YEa)
'coordenadas de la linea eje A
XEaxi = Xejetramo
YEayi = Yejetramo - 280
XEaxf = Xejetramo
YEayf = Yejetramo - 240
' PictureBox1.CreateGraphics.DrawLine(Pens.Magenta, XEaxi, YEayi, XEaxf, YEayf)
End While
dr.Close()
Str = "SELECT * FROM ejesplano where claveobra = '" & claveobra & "' and elemento = '" & ComboBox7.Text & "'"
cmd = New OleDbCommand(Str, Conección)
dr = cmd.ExecuteReader
While dr.Read()
ReDim cota(2)
i = 1
cota(i) = dr("distancia").ToString()
Displanos = (cota(i) * 100)
Xejetramo = Xejetramo + (Displanos)
Yejetramo = 320
'eje B
Dim myLabel2 As Label = New Label()
myLabel2.Size = New Size(20, 20)
PictureBox1.Controls.Add(myLabel2)
myLabel2.Text = dr("ejeLf").ToString()
'posicion Eje B
Dim XEb = (Xejetramo - 5)
Dim YEb = Yejetramo - 300
myLabel2.Location = New Point(XEb, YEb)
'coordenadas de la linea eje B
XEbxi = Xejetramo
YEbyi = Yejetramo - 280
XEbxf = Xejetramo
YEbyf = Yejetramo - 240
'PictureBox1.CreateGraphics.DrawLine(Pens.Magenta, XEbxi, YEbyi, XEbxf, YEbyf)
'cota
Dim mylabel3 As Label = New Label()
mylabel3.Size = New Size(40, 20)
PictureBox1.Controls.Add(mylabel3)
mylabel3.Text = cota(i)
mylabel3.Text = CDbl(mylabel3.Text).ToString("N2")
'posicion de la cota
Dim Xdis = (Xejetramo - 15) - ((Displanos) / 2)
Dim Ydis = Yejetramo - 265
mylabel3.Location = New Point(Xdis, Ydis)
'coordenadas de la linea del tramo
XLtxi = Xejetramo - (Displanos)
YLtyi = Yejetramo - 240
XLtxf = Xejetramo
YLtyf = Yejetramo - 240
'PictureBox1.CreateGraphics.DrawLine(Pens.Magenta, XLtxi, YLtyi, XLtxf, YLtyf)
End While
dr.Close()
PictureBox1.Invalidate()
End Sub
Private Sub Plano_Scroll(sender As Object, e As ScrollEventArgs) Handles MyBase.Scroll
' PictureBox1.Invalidate()
End Sub
Private Sub PictureBox1_Paint(sender As Object, e As PaintEventArgs) Handles PictureBox1.Paint
Dim g As Graphics = e.Graphics
If ac = 1 Then
g.DrawLine(Pens.Magenta, XE1xi, YE1yi, XE1xf, YE1yf)
g.DrawLine(Pens.Blue, XEaxi, YEayi, XEaxf, YEayf)
g.DrawLine(Pens.Green, XEbxi, YEbyi, XEbxf, YEbyf)
g.DrawLine(Pens.Red, XLtxi, YLtyi, XLtxf, YLtyf)
End If
'PictureBox1.Invalidate()
End Sub
End Class