ZenWorkspace

 

Remarks Properties Methods Events Samples

ED
avaliable
RT
not used

Remarks:Top

This ClassModule represents the actual workspace in the editor.

There are several events to react on actions of the projects within the workspace.

Properties:Top

ActiveDocument Application Name
Parent Symbols VBE

Methods:Top

ActivateProject CloseWorkspace CopyProject
CreateBackup CreateProjecteBackup CreateWorkspace
InsertProject LoadProject LoadProjectByName
LoadWorkspace RemoveProject RestoreBackup
RestoreProjectBackup SaveWorkspace SetStartProject
UnloadProject UnloadedProjects[GET]  

Events:Top

Exit OnElementCreated OnElementDeleted
OnElementDoubleClicked OnExit OnObjectCreated
OnPostBuild OnPostTransport OnPreBuild
OnPreTransport OnProjectLoaded OnRTConnect
OnRTConnectionFailed OnRTConnectionTerminated OnStartup
Startup    

Samples:Top

Option Explicit
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Const VK_LSHIFT = &HA0
Private Const VK_RSHIFT = &HA1

Private Sub ZenWorkspace_OnPostBuild(ByVal obProject As IProject)
	Debug.Print "Runtimefiles for project '" & obProject.Name & "' are created!"
End Sub

Private Sub ZenWorkspace_OnPostTransport(ByVal obProject As IProject, ByVal bSuccess As Boolean)
	Debug.Print "Runtimefiles for project '" & obProject.Name & "' were transported succesfully (" & bSuccess & ")!"
End Sub

Private Sub ZenWorkspace_OnPreBuild(ByVal obProject As IProject)
	Debug.Print "Runtimefiles for project '" & obProject.Name & "' will be created!"
End Sub

Private Sub ZenWorkspace_OnPreTransport(ByVal obProject As IProject)
	Debug.Print "Runtimefiles for project '" & obProject.Name & "' will be transported!"
End Sub

Private Sub ZenWorkspace_OnProjectLoaded(ByVal obProject As IProject)
	Debug.Print "Project '" & obProject.Name & "' is loaded!"
End Sub

Private Sub ZenWorkspace_Startup()
	If GetAsyncKeyState(VK_LSHIFT) <> 0 Then
		SaveSetting "zenOn", "StartupScreen", "ShowOnStartup", "YES"
	End If
	If GetAsyncKeyState(VK_RSHIFT) <> 0 Then
		SaveSetting "zenOn", "StartupScreen", "ShowOnStartup", "YES"
	End If
	If GetSetting("zenOn", "StartupScreen", "ShowOnStartup", "YES") = "YES" Then
		frmStartup.Show
	End If
	'check vba references...
	Call CheckVBAReferences
End Sub

Private Sub ZenWorkspace_OnElementCreated(ByVal obElement As Element)
	Dim obMpElem As CD_ManipulationElement

	Set obMpElem = New CD_ManipulationElement
	Set obMpElem.Parent = Me
	Debug.Print "Element of Type " & obElement.Type & " created."

	''>> The codeline below will set defaults to elements when they are created.
	'obMpElem.SetDefault obElement
	''>> The Defaultsettings are located in the classmodule "CD_ManipulationElement"
End Sub

Private Sub ZenWorkspace_OnElementDoubleClicked(ByVal obElement As Element)
	'Show Symbol Wizard for linked Symbols,
	'if the symbol has outlined properties.
	If obElement.Type = 130 Then
		'symbol...
		If SymbolHasProps(obElement) = True Then
			'start wizard...
			frmSymbol.InitWizard obElement
			frmSymbol.Show
		End If
	End If
End Sub

Function SymbolHasProps(zELE As Element) As Boolean
	Dim v As Variant
	Dim i As Integer
	Dim s As String
	'check DynProperties of Symbol...
	v = zELE.DynPropertiesEnum("")
	For i = 0 To UBound(v)
		s = v(i)
		s = Mid(s, 1, InStr(1, s, ",") - 1)
		If InStr(1, s, "\") <> 0 Then
			SymbolHasProps = True
			Exit Function
		End If
	Next i
End Function

Private Sub ZenWorkspace_OnObjectCreated(ByVal obObject As Object)
'this Event is fired, when a new object is created within a project...
Dim strObjectType As String
Dim obTemplate As Template
Dim obPicture As DynPicture
Dim obFunction As RtFunction
Dim obElement As Element
Dim obUser As User
Dim obRema As Rema
Dim obScript As Script
Dim obEdLimit As EdLimit
Dim obRGMRecipe As RGMRecipe
Dim obRecipe As Recipe
Dim obVarAssignment As VarAssignment
Dim obVariable As Variable
Dim obTimeFunction As TimeFunction
Dim ErrH As Label
On Error GoTo ErrH
	'depending to the type of the created object, different actions can be done...
	strObjectType = TypeName(obObject)
	Select Case strObjectType
		Case "ITemplate"
			Set obTemplate = obObject
			Debug.Print "Template created......> " & obTemplate.Name
			Debug.Print "----- in Project......> " & obTemplate.Parent.Parent.Name
		Case "IDynPicture"
			Set obPicture = obObject
			Debug.Print "Picture created.......> " & obPicture.Name
			Debug.Print "---- in Project.......> " & obPicture.Parent.Parent.Name
		Case "IRtFunction"
			Set obFunction = obObject
			Debug.Print "Function created......> " & obFunction.Name
			Debug.Print "----- in Project......> " & obFunction.Parent.Parent.Name
		Case "IElement"
			Set obElement = obObject
			Debug.Print "Element created.......> " & obElement.Name
			Debug.Print "---- in Picture.......> " & obElement.Parent.Parent.Name
			Debug.Print "---- in Project.......> " & obElement.Parent.Parent.Parent.Parent.Name
		Case "IScript"
			Set obScript = obObject
			Debug.Print "Script created........> " & obScript.Name
			Debug.Print "--- in Project........> " & obScript.Parent.Parent.Name
		Case "IRema"
			Set obRema = obObject
			Debug.Print "REMA created..........> " & obRema.Name
			Debug.Print "- in Project..........> " & obRema.Parent.Parent.Name
		Case "IUser"
			Set obUser = obObject
			Debug.Print "User created..........> " & obUser.Name
			Debug.Print "- in Project..........> " & obUser.Parent.Parent.Name
		Case "IEdLimit"
			Set obEdLimit = obObject
			Debug.Print "Limit created.........> "
			Debug.Print "---- Variable.........> " & obEdLimit.Parent.Name
			Debug.Print "-- in Project.........> " & obEdLimit.Parent.Parent.Parent.Name
		Case "IRGMRecipe"
			Set obRGMRecipe = obObject
			Debug.Print "RMG Recipe created....> " & obRGMRecipe.DynProperties("RecipeName")
			Debug.Print "----- in RGM Group....> " & obRGMRecipe.Parent.DynProperties("Name")
			Debug.Print "------- in Project....> " & obRGMRecipe.Parent.Parent.Parent.Name
		Case "IRecipe"
			Set obRecipe = obObject
			Debug.Print "Recipe created........> " & obRecipe.Name
			Debug.Print "--- in Project........> " & obRecipe.Parent.Parent.Name
		Case "ITimeFunction"
			Set obTimeFunction = obObject
			Debug.Print "TimeFunction created..> " & obTimeFunction.Name
			Debug.Print "--------- in Project..> " & obTimeFunction.Parent.Parent.Name
		Case "IVarAssignment"
			Set obVarAssignment = obObject
			Debug.Print "VarAssignment created.> " & obVarAssignment.Name
			Debug.Print "---------- in Project.> " & obVarAssignment.Parent.Parent.Name
		Case "IVariable"
			Set obVariable = obObject
			Debug.Print "Variable created......> " & obVariable.Name
			Debug.Print "----- in Project......> " & obVariable.Parent.Parent.Name
		Case Else
			Debug.Print strObjectType
	End Select
	Exit Sub
ErrH:
	Debug.Print "[ERROR] " & Err.Number & " - " & Err.Description
	Resume Next
End Sub