在Vb.net中绘制给定点的垂直线 [英] Drawing Perpendicular Line of given point in Vb.net

查看:288
本文介绍了在Vb.net中绘制给定点的垂直线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在vb.net中开发一个应用程序并且希望在平行线上绘制垂直线

但是如果有人知道怎么做但不能做请帮助

预付款

喜欢





http://tinypic.com/r/6h5nqt/5 [ ^ ]



但如果有人知道该怎么做请不行帮助

在此先感谢





我使用代码来创建该行是... ...........

Hi
I am developing an application in vb.net and want to draw perpendicular line against a parallel line
Like but not able to do if anyone know how to do please help
Thanks in Advance
like


http://tinypic.com/r/6h5nqt/5[^]

but not able to do if anyone know how to do please help
Thanks in Advance


I am using the code to for creating the line is..............

Public Class Form2
   
    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        picRegion.Image = Image.FromFile("C:/ss.jpg")

    End Sub
    Private m_BufferGraphics As Graphics
    Private m_Drawing As Boolean
    Private m_BufferBitmap As Bitmap
    Private m_X1 As Integer
    Private m_Y1 As Integer
    Private m_X2 As Integer
    Private m_Y2 As Integer
    Private m_X3 As Integer
    Private m_Y3 As Integer
    Private m_X4 As Integer
    Private m_Y4 As Integer
    Private Sub PictureBox1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picRegion.MouseDown
        If e.Button <> MouseButtons.Left Then Exit Sub
        m_Drawing = True
        SaveSnapshot()
        m_X1 = e.X
        m_Y1 = e.Y
    End Sub

    Private Sub SaveSnapshot()
        Dim new_bitmap As Bitmap
        new_bitmap = New Bitmap(Me.picRegion.Image.Size.Width, Me.picRegion.Image.Size.Height, Me.picRegion.CreateGraphics())
        m_BufferGraphics = Graphics.FromImage(picRegion.Image)
        m_BufferBitmap = new_bitmap
    End Sub

    Private Sub PrivewForm(ByVal gr As Graphics)
        If Not (m_BufferBitmap Is Nothing) Then gr.DrawImage(m_BufferBitmap, 0, 0)
    End Sub

    Private Sub PictureBox1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picRegion.MouseMove
        If Not m_Drawing Then Exit Sub
        m_X2 = e.X
        m_Y2 = e.Y
        PrivewForm(Me.picRegion.CreateGraphics())
        Me.picRegion.Refresh()
        Dim pen As New Pen(Color.Crimson, 3)
        Me.picRegion.CreateGraphics().DrawLine(pen, m_X1, m_Y1, m_X2, m_Y2)
        PrivewForm(Me.picRegion.CreateGraphics())

        'perpendicular line
      

    End Sub
  
    Private Sub PictureBox1_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picRegion.MouseUp
        If Not m_Drawing Then Exit Sub
        m_Drawing = False
        m_X2 = e.X
        m_Y2 = e.Y
        Dim pen2 As New Pen(Color.Crimson, 3)
        m_BufferGraphics.DrawLine(pen2, m_X1, m_Y1, e.X, e.Y)
        Me.picRegion.Refresh()
        If m_Y1 = m_Y2 Then
            m_X3 = m_X1
            m_Y3 = m_Y1 - 15
            m_X4 = m_X1
            m_Y4 = m_Y1 + 15
            Dim pen31 As New Pen(Color.Cyan, 3)
            m_BufferGraphics.DrawLine(pen31, m_X3, m_Y3, m_X4, m_Y4)
            Me.picRegion.Refresh()

            m_X3 = m_X2
            m_Y3 = m_Y2 - 15
            m_X4 = m_X2
            m_Y4 = m_Y2 + 15
            Dim pen32 As New Pen(Color.Cyan, 3)
            m_BufferGraphics.DrawLine(pen32, m_X3, m_Y3, m_X4, m_Y4)
            Me.picRegion.Refresh()
        
        End If

    End Sub
End Class



鼠标启动事件我有用法如果m_Y1 = m_Y2,这个条件是仅当一条线是水平的但是如果线不是水平的垂直线没有产生。

对不起英文


in mouse up event where i have usage If m_Y1 = m_Y2 , this condition is only when a line is horizontal but if line is not horizontal perpendicular line is not generating.
sorry for bad English

推荐答案

这是用于为管件装配程序绘制偏心减速器的代码的一部分

此部件在打印预览中我的程序的一部分以及其他代码的分配。

这是参考。

http://msdn.microsoft.com/en-us/library/aa983677(v=VS.71).aspx [ ^ ]

它使用GDI +

注意值。



它产生两条角线和两条垂直线来产生形状。 br $>


This is part of the code I used to draw a Eccentric reducer for a pipefitting program
This parts was in the print preview section of my program along with allot of other code.
This was the reference.
http://msdn.microsoft.com/en-us/library/aa983677(v=VS.71).aspx[^]
It uses GDI+
Notice the Values.

It produces two angle lines and two verticle lines to produce the shape.

Dim p0 As System.Drawing.Point
Dim p1 As System.Drawing.Point
Dim p2 As System.Drawing.Point
Dim p3 As System.Drawing.Point


p0.X = 500
p0.Y = 200
p1.X = 500
p1.Y = 100
p2.X = 720
p2.Y = 44
p3.X = 720
p3.Y = 250

e.Graphics.DrawLine(myPen, p0, p1)
e.Graphics.DrawLine(myPen, p1, p2)
e.Graphics.DrawLine(myPen, p2, p3)
e.Graphics.DrawLine(myPen, p3, p0)


如果你只是停留在它的数学方面...尝试谷歌 [<一个HREF =http://www.google.com/#gs_rn=23&gs_ri=psy-ab&gs_mss=find%20perpendicular%20line%20gi&cp=31&gs_id=4o&xhr=t&q=find+垂直+线+给定+ 2个+点&安培; es_nrs =真安培; PF = p与M. sclient = PSY-AB&安培; OQ =找到+垂直+线+给定+ T&安培; gs_l =安培; PBX = 1&安培; BAV = on.2, or.r_qf。& bvm = bv.49967636,d.aWM& fp = 93b0cd4be5d7facd& biw = 1152& bih = 734target =_ blanktitle =New Window> ^ ]寻求帮助。< br $> b $ b

这个谷歌搜索结果 [< a href =http://www.wyzant.com/help/math/geometry/lines_and_angles/parallel_and_perpendiculartarget =_ blanktitle =新窗口> ^ 实际上发布的图表/图片很不错。



希望这会有所帮助。
If you're just stuck on the math side of it...try google[^] for help.

This google result[^] actually posts graphs/pictures which is nice.

Hope this helps.


这篇关于在Vb.net中绘制给定点的垂直线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆