Notifications
Clear all

[Closed] 3 dotnet classes

Hey, glad to hear that this is being useful! As for using it in a rollout I guess you can, it’s just like a normal treeview (although I never tried it :D).

I dont have the DLL project here but I guess something like this would work:

--Destroy dialog if it already exists.
try(destroyDialog theRollout)catch()

--Create a rollout
rollout theRollout "The Rollout" width:300
(
	--Create the dotNet treeView control
	dotnetobject tvFolders "KClasses.dnFolders" height:200
	
	--Create a button for testing. 
	button testButton "Test"
	on testButton pressed do
	(
		clearListener()		--Clear the listener.
		format "Props
"	--Format a header so we know what we are looking at below. 
		showProperties tv	--Show the properties of the treeView control.
		format "
Methods
"	--Format a header so we know what we are looking at below. 
		showMethods tv		--Show the properties of the treeView control.
		format "
Events
"	--Format a header so we know what we are looking at below. 
		showEvents tv		--Show the properties of the treeView control.
	)

	on theRollout open do
	(
		tvFolders.ProcessTree(@"c:\KClasses_Test")
	)
)
createDialog theRollou

The example was taken from PEN Production Tutorials, I’ve just added the dnFolders stuff.

I’m not familiar with Hitchhiker, so I dont know what parameters .populate accepts but I guess that you already know that, you only needed to insert the dnFolders in your rollout. I hope this helps, keep in touch!

Cheers.

Hi jonah, artur,

Hitchiker’s populate method accepts a path string of a directory, so I would call this in whatever the directory tree’s click event is. You can then pass the eb.node.dirName argument directly to populate hh.

Thanks for the quick response Artur. The HitchHiker.populate property takes a path string. Simple.

I’ll take a rough pass on this see what I can come up with.

Ultimately, I would like to understand and write stuff like this from scratch. I have not, for instance, successfully written a treeView or dataGrid or any of it, completely on my own. I’ll get there though.

Edit: oops… left the Post open for a while there.

These look awesome, Artur! Finally I can play the star wars theme when a tool opens up.

So this works! as dotnetControl rather than dotnetObject

 I am probably missing something obvious but dotnet.addEventHandler does not seem to work with this as it's written. So is there a different way to create even handlers for dotnetControls? Do I use use the standard rollout handlers but reference "nodeMouseClick" somehow? 

Edit: Got It! Spend so much time making mistakes that I doubt my first instinct. Where is Yoda when I need him?

on tvFolders NodeMouseClick do
 (
     print "Click!!!"
 )
 On another note, the Processing time gets longer and longer every time I evaluate this script. Is this something to do with garbage collection or cleaning up after myself?

Edit:

on ro_Browser close do 
  (
   HitchHiker.housekeeping()
   tvFolders.dispose()
  )
 Cheers,
--Destroy dialog if it already exists.
     try(destroyDialog theRollout)catch()
     
     dotnet.loadAssembly (getDir #maxroot + "KClasses.dll")
     
     
     (
     		--Create a rollout
     		rollout theRollout "The Rollout" width:300
     		(
     			--Create the dotNet treeView control
     			dotnetcontrol tvFolders "KClasses.dnFolders" height:200
     			
     			on theRollout open do
     				(
     					tvFolders.height = (theRollout.height - 30)
     					tvFolders.width = (theRollout.width - 30)
     					
     					start=timestamp()
     					tvFolders.ProcessTree(@"\\server\data\assets")
     					end=timestamp()
     					format "Processing took % seconds
" ((end - start) / 1000.0)
     				)
     			on theRollout resized size do
     			(
     				tvFolders.height = (theRollout.height - 30)
     				tvFolders.width = (theRollout.width - 30)
     			)
     			
     		)
     		createDialog theRollout style:#(#style_resizing, #style_titleBar, #style_sysmenu)
     )

@Jason: I knew that midi stuff was going to be of use to someone! But to you… it makes perfect sense! You can add music to your games :bounce:

@Jonah: Hey Jonah, great work, glad you got it working, about the ProcessTree… I maybe doing something wrong that’s screwing up the speed and I dont remember if I managed the garbage collection in the DLL I think it needs to be done manually there, dunno, I have to check it out when I have some time. Maybe Pete can shed some light on this. Cheers!

1 Reply
(@lonerobot)
Joined: 11 months ago

Posts: 0

Hey Art, Jason
What methods have you done for midi? I wrote a thing recently to use a midi control library in max – i hooked up my Roland TD-4 drumkit via a midi>usb and made them control a load of viewport teapots – they scaled according to how hard I hit the drum. utterly useless but quite silly!

@Jonah: Hey Jonah, great work, glad you got it working, about the ProcessTree… I maybe doing something wrong that’s screwing up the speed and I dont remember if I managed the garbage collection in the DLL I think it needs to be done manually there, dunno, I have to check it out when I have some time. Maybe Pete can shed some light on this. Cheers!

Hitchhiker has a .housekeeping() method that will release any resources – i put this usually in the rollout close event. I try to keep track of the memory, when i developed hitchhiker i was careful to monitor the ram usage and it’s release on thumbnail generation. But these things can sometimes be tricky.

If the bottleneck is in the directory generation on large folder structures, you can employ a ‘JIT’ treeview to scan when the treenode calls its pre-expand node event – that way the folder structure displays very fast with zero bottleneck. Again, not sure how Art has set up his class.

Hey Pete, here’s the dnMidi class, very simple, just play and stop, no big deal

Public Class dnMIDI
    Declare Function mciSendString Lib "winmm" Alias "mciSendStringA" (ByVal _
    lpstrCommand As String, ByVal lpstrReturnString As String, _
    ByVal uReturnLength As Long, ByVal hwndCallback As IntPtr) As Long
    Public Shared Function PlayMIDI(ByVal file As String)
        Dim RetVal As Long
        RetVal = mciSendString("Open " + file + " type sequencer alias MidiFile", vbNullString, 0, IntPtr.Zero)
        RetVal = mciSendString("Play MidiFile notify", vbNullString, 0, IntPtr.Zero)
        Return True
    End Function
    Public Shared Function StopMIDI()
        Dim RetVal
        RetVal = mciSendString("Close MidiFile", vbNullString, 0, IntPtr.Zero)
        Return True
    End Function
End Class

Hitchhiker has a .housekeeping() method that will release any resources

What resources are you disposing? I’ve been having some memory issues with my thumbnail control even though I’ve been calling .dispose() on the images when I’m done with them.

1 Reply
 PEN
(@pen)
Joined: 11 months ago

Posts: 0

J, I have found that instead of adding images as a backGroundImage to a label it is better memory wise to paint it in with the paint handler. I don’t know if this helps you.

So as not to hijack this thread, I’ve added this one regarding my Asset Tool that uses both KClasses.dll and HitchHiker.dll

http://forums.cgsociety.org/showthread.php?p=6591029#post6591029

Hey guys, I’ve been searching the web and found a cool example written by a guy nicknamed Pino in the VBForuns about using the webcam, so all props go to the guy that wrote the original class! I’ve adapted it to my KClasses and we have a new class dnWebCam.

I dont have any webcam here but if you guys can take a look and see if this works it would be awesome

Here’s the file and the example to run:

(
	dotnet.LoadAssembly @"$scripts\KClasses.dll"
	
	-- Create Form
	local hForm = dotNetObject "MaxCustomControls.MaxForm"
	hForm.Size = dotNetObject "System.Drawing.Size" 640 480
	hForm.FormBorderStyle = (dotnetclass "System.Windows.Forms.FormBorderStyle").FixedToolWindow
	hForm.Text = "KClasses Example"
	hForm.ShowInTaskbar = False
	
	local picBox = dotNetObject "System.Windows.Forms.PictureBox"
	picBox.Size = dotNetObject "System.Drawing.Size" 320 240
	
	
	hForm.Controls.add(picBox)
	
	myCam = dotNetObject "KClasses.dnWebCam"
	pBHandle = picBox.Handle as integer
	myCam.InitCam pbHandle
	
	hForm.ShowModeless()
)
Page 3 / 5