Quantcast
Channel: MicroStation Programming Forum - Recent Threads
Viewing all articles
Browse latest Browse all 7260

RE: [CONNECT C# Addin] Detect key press inside Dynamic input

$
0
0

Right now I'm doing some simple testing to help out one of my co-programmers.

I'm dynamically drawing a simple line, enter datapoint, rubberband temporary line while waiting for second data point. While waiting for second data point would like to be able to detect up/down arrow keys to change the thickness of the line.

My current code does nothing in the OnModifierKeyTransition method, just have a statement there so I could put a watch point on it.

Here's the code:

Imports Bentley.DgnPlatformNET

Imports Bentley.DgnPlatformNET.Elements

Imports Bentley.GeometryNET

Imports Bentley.MstnPlatformNET

Namespace MSAddin1

ClassDynamicLine

InheritsDgnElementSetTool

Private m_points AsList(OfDPoint3d)

PrivateSubNew()

MyBase.New()

m_points = NewList(OfDPoint3d)()

EndSub

ProtectedOverridesSub OnRestartTool()

InstallNewInstance()

EndSub

PublicSharedSub InstallNewInstance()

Dim dLine AsNewDynamicLine()

dLine.InstallTool()

EndSub

'after tool is installed, create prompt for user input

ProtectedOverridesSub OnPostInstall()

NotificationManager.OutputPrompt("Enter data points to define line. Reset to complete")

EndSub

'handle user data button click

ProtectedOverridesFunction OnDataButton(ev AsDgnButtonEvent) AsBoolean

m_points.Add(ev.Point)

MyBase.BeginDynamics()

ReturnFalse

EndFunction

ProtectedOverridesFunction OnModifierKeyTransition(wentDown AsBoolean, key AsInteger) AsBoolean

Dim i AsInteger = 0

ReturnFalse

EndFunction

'if more than one point is in queue, draw line between points

ProtectedOverridesSub OnDynamicFrame(ev AsDgnButtonEvent)

If m_points.Count > 0 Then

Dim points AsDPoint3d() = NewDPoint3d(m_points.Count) {}

For i AsInteger = 0 To m_points.Count - 1

points(i) = m_points(i)

Next

points(points.Length - 1) = ev.Point

Dim element AsNewLineStringElement(Session.Instance.GetActiveDgnModel(), Nothing, points)

Dim redrawElems AsNewRedrawElems()

redrawElems.SetDynamicsViewsFromActiveViewSet(Bentley.MstnPlatformNET.Session.GetActiveViewport())

redrawElems.DrawMode = DgnDrawMode.TempDraw

redrawElems.DrawPurpose = DrawPurpose.Dynamics

redrawElems.DoRedraw(element)

EndIf

EndSub

'when reset button is pressed add the element(s) to the model, turn off dynmaics

ProtectedOverridesFunction OnResetButton(ev AsDgnButtonEvent) AsBoolean

If m_points.Count > 2 Then

Dim points AsDPoint3d() = NewDPoint3d(m_points.Count) {}

For i AsInteger = 0 To m_points.Count - 1

points(i) = m_points(i)

Next

points(points.Length - 1) = ev.Point

Dim element AsNewLineStringElement(Session.Instance.GetActiveDgnModel(), Nothing, points)

element.AddToModel()

m_points.Clear()

Else

m_points.Clear()

EndIf

MyBase.EndDynamics()

ReturnFalse

EndFunction

'''<summary>

''' Required method because of Inheritance

'''</summary>

'''<param name="element"></param>

'''<returns></returns>

PublicOverridesFunction OnElementModify(element AsElement) AsStatusInt

ReturnStatusInt.[Error]

EndFunction

 

EndClass

EndNamespace


Viewing all articles
Browse latest Browse all 7260

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>