产品中心
联系我们

销售热线:0755-28441200 

销售热线:0755-89368951 

传真:0755-28441200


新闻中心
MIL中画虚线代码matrox imaging library
发布日期:【2014-09-08 00:00】 来源:【未知】 作者:【admin】 浏览次数【】次 【打印】【返回
MIL中画虚线代码matrox imaging library
MIL中画线用的控件是GraphicContext,你要在DISPLAY中画直线可以,但要画虚线,它是不支持的,代码只好自己写了。我们以画虚线矩形为例,代码如下(VB.NET 2008代码)

 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
      
        AxMDisplay1.ClearOverlay()
        DrawDotLine(30, 10, 400, 100)‘开始XY,结束XY坐标 改变此值即可画出用户所需的位置
       
    End Sub
    Private Sub DrawDotLine(Startx As Integer ,Starty As Integer ,Endx As Integer ,Endy As Integer )
        Dim I As Integer
        For I = Startx To Endx Step 5 '顶横
            AxMGraphicContext1.DrawingRegion.StartX = I
            AxMGraphicContext1.DrawingRegion.StartY = Starty
            AxMGraphicContext1.DrawingRegion.EndX = IIf((I + 2) > Endx, I, I + 2)
            AxMGraphicContext1.DrawingRegion.EndY = Starty
            AxMGraphicContext1.LineSegment()
        Next
        For I = Starty To Endy Step 5 '左竖
            AxMGraphicContext1.DrawingRegion.StartX = Startx
            AxMGraphicContext1.DrawingRegion.StartY = I
            AxMGraphicContext1.DrawingRegion.EndX = Startx
            AxMGraphicContext1.DrawingRegion.EndY = IIf((I + 2) > Endy, Endy, I + 2)
            AxMGraphicContext1.LineSegment()
        Next
        'MsgBox(Startx & "  " & Endy)

        For I = Startx To Endx Step 5 '底横
            AxMGraphicContext1.DrawingRegion.StartX = I '+ Startx
            AxMGraphicContext1.DrawingRegion.StartY = Endy
            AxMGraphicContext1.DrawingRegion.EndX = IIf((I + 2) > Endx, Endx, I + 2)
            AxMGraphicContext1.DrawingRegion.EndY = Endy
            AxMGraphicContext1.LineSegment()
        Next
        For I = Starty To Endy Step 5 '右竖
            AxMGraphicContext1.DrawingRegion.StartX = Endx
            AxMGraphicContext1.DrawingRegion.StartY = I
            AxMGraphicContext1.DrawingRegion.EndX = Endx
            AxMGraphicContext1.DrawingRegion.EndY = IIf((I + 2) > Endy, Endy, I + 2)

            AxMGraphicContext1.LineSegment()
        Next

    End Sub


地址:深圳市龙岗区南湾街道平吉大道9号华熠大厦A1010   电话:0755-28441200,传真:0755-28441200
Copyright © 2013 深圳市汇龙影像科技有限公司 All Right Reserved.粤ICP备14000400号-1