Notifications
Clear all

[Closed] dotNet UI

As seen reference here.
http://lonerobot.net/?p=111

So with dot net it would be possible to allow a user to drag and drop an image onto a dotnet button.

Then in return it would change that buttons.tag property to the output path of the drag/drop image file.

 PEN

Yes, this should be completely possible.

so far I have this.
It is more so just a working UI. I now want to make the drag and drop part of this work.
I looked into the example done by lone robot. It seems to not execute right and at the same time i think it is to much for what I’m doing anyways. I just want to be able to drag and drop and image on the black label bar and it fill that labels.text property with the filepath


rollout rlShotTools "Shot Tools"
(
	--//Variables
	---------------------------------------------------
	local theFont = dotnetobject "System.Drawing.Font" "Arial" 8
	
	
	
	--//Functions
	---------------------------------------------------
	fn labelFactory ctrl txt = --//dotNet labels
	(
		local theLab = ctrl 
		theLab.Font = theFont
		theLab.BackColor = (dotNetClass "System.Drawing.Color").fromARGB 31 29 28
		theLab.ForeColor = (dotNetClass "System.Drawing.Color").fromARGB 255 255 255
		theLab.TextAlign = theLab.TextAlign.MiddleLeft
		theLab.Text = txt
		theLab
	)

	fn buttonFactory ctrl txt =
	(
		local theBut = ctrl
		theBut.Font = theFont
		theBut.flatStyle=theBut.flatStyle.flat
		theBut.flatAppearance.BorderSize = 1
		theBut.flatappearance.bordercolor = (dotNetClass "System.Drawing.Color").fromARGB 0 0 0
		theBut.BackColor = (dotNetClass "System.Drawing.Color").fromARGB 58 58 58 
		theBut.ForeColor = (dotNetClass "System.Drawing.Color").fromARGB 255 255 255
		theBut.flatappearance.mouseoverbackcolor = (dotNetClass "System.Drawing.Color").fromARGB 73 124 159 
		theBut.flatappearance.mousedownbackcolor = (dotNetClass "System.Drawing.Color").fromARGB 238 137 34
		theBut.TextAlign = theBut.TextAlign.MiddleCenter
		theBut.Text = txt
		theBut
	)
	
	
	
	--//UI Controls
	---------------------------------------------------
	dotNetControl lbImgLocation "Label" pos:[10,10] width:150 height:24
	dotNetControl btnImage "Button" pos:[10,40] width:150 height:24
	
	
	on rlShotTools open do (
		--//UI Controls
		ctrlLabels = #(lbImgLocation)
		ctrlLabelNames = #(" Image. . .")
		ctrlButtons = #(btnImage)
		ctrlButtonNames = #("Print Image Name")
		
		for i = 1 to ctrlLabels.count do labelFactory ctrlLabels[i] ctrlLabelNames[i]
		for i = 1 to ctrlButtons.count do buttonFactory ctrlButtons[i] ctrlButtonNames[i]
	)
)
createDialog rlShotTools 200 200 style:#(#style_SysMenu, #style_ToolWindow)

 lo1

If I remember correctly, dotnet controls hosted in a maxscript rollout can’t catch dragDrop events, they get intercepted by max. The example on lonerobot.net, as far as I could tell, is about dragging from controls, not to controls. Use a dotnet form instead.

Here is the final version of the Button Spacer.
Check it out. It has the max spinner implemented into it.

http://jokermartini.com/2011/11/spacer/

I’ll be posting more dotNet stuff soon as well.

For all you right-clickers out there, here you go!

I coded it in a way it allows the user to change their mind mid click. If you click and move the cursor away from the button and then release, it will not execute.
Check it out.

rollout rlMouseClicks "Mouse Clicks"
(
	dotNetControl btnMouse"button" pos:[10,10] width:110 height:110
	
	on btnMouse mouseUp sender arg do
	(
		if  (btnMouse.Bounds.Contains(arg.location)) do
		(
			if arg.button==arg.button.left do
			(
				print "do it left"
			)
			if arg.button==arg.button.right do
			(
				print "do it right"
			)
		)
	)
)
createDialog rlMouseClicks 150 150

This is a very useful tool. I was amazed at how easy it was compared to the old way.

I would like to display a thumbnail image in a rollout dialog using a .net label.

Does anyone have any example code of a .jpg thumbnail or something being display that I would be able to look at and see how it is done. I seem to being not getting it right.

http://forums.cgsociety.org/showpost.php?p=7169258&postcount=90

Thanks

Alright so I’ve come across some examples and whatnot here on the internet and found a very cool solution to what I’m after.
I’m sure it has been done before. Anywho this is what I have so far and I would like to get some other peoples thoughts and improvements on this as it is developed and see what everyone things.

I’m building a tool which allows a user to target a directory with the fileformat as follows.

foldername: “mtlTesting”
files:
AluminiumNotebook.jpg
AluminiumNotebook.mat
Basketball.jpg
Basketball.mat
Cammo.jpg
Cammo.mat
MetalOilDirty.jpg
MetalOilDirty.mat

From there the users can see the available materials with their corresponding preview in the columns. Now what I would like to add is when the user clicks the window on the left it opens in a seperate window the full size image and when the user clicks on the name in the right column it adds the mat to the active material slot.

What i need help on is 1.Id like to see what everyones thoughts are so far on what is there as it is a combination of stuff i found put together. 2.Linking the image to the full size one to open a full size picture. 3. How to give the text and action when the use clicks on it. I know how to make a material appear in the editor, I’m just not sure how to make the text have a clickable action.
Lastly if there are any imrprovments or things I should look out for. A few I’m already thinking of are what is there is a material but no image what would be displayed.

When you guys test this just change the directory variable at the top of the screen to make it work for you guys.

Thanks


try(destroyDialog ::roll_imatges)catch()
rollout roll_imatges "Materials" 
(
	local	dir_imatges = @"C:\Users\IEVFX\Desktop	rash\mtlTesting"
	
  	button btn_scan "Directory" width:220 height:24 pos:[10,10]
  	dotNetControl lv_imatges "System.Windows.Forms.ListView" pos:[10,40] width:220 height:400
   	
	fn myCallback = ( return false )
	
 	fn carrega_imatges paths_imatges = (
   		fn callback_abort = ( dotnetObject "System.Drawing.Image+GetThumbnailImageAbort" myCallback())
   		local ptr_callback_abort = dotNetClass "System.IntPtr"
   		Llista_Imatges	= dotNetObject "System.Windows.Forms.ImageList"
   		Llista_Imatges.ColorDepth = Llista_Imatges.ColorDepth.Depth24Bit
   		Llista_Imatges.ImageSize = dotNetObject "System.Drawing.Size" 90 90
 		for path_imatge in paths_imatges do (
   			thumb = dotNetObject "System.Drawing.Bitmap" path_imatge
  			-- Calling GetThumbnailImage this way doesn't work :(
   			-- thumb = thumb.GetThumbnailImage 160 120 (callback_abort()) (ptr_callback_abort.Zero)
   			Llista_Imatges.images.add thumb
   		)
   		return Llista_Imatges
   	)
	
 	fn inicialitzaListView lv = (
   		lv.View = (dotNetClass "System.Windows.Forms.View").Details
   		lv.borderstyle = (dotnetclass "System.Windows.Forms.BorderStyle").fixedsingle
   		lv.showitemtooltips = true
   		lv.gridlines = true
   		lv.checkboxes = false
   		lv.labeledit = false
   		lv.Columns.add "Image" 90
   		lv.Columns.add "Name" 130
   	)
	
 	fn ompleListView lv llista_imatges = (
   		lv.Clear()
   		lv.Columns.add "Image" 90
   		lv.Columns.add "Name" 130
   		lv.SmallImageList = carrega_imatges llista_imatges
  		for i = 1 to llista_imatges.count do (
   			imatge = llista_imatges[i]
   			ListViewOps.AddLvItem lv pTextItems:#("",(getFilenameFile imatge)) pImgIndex:(i-1)
   		)
   	)
	
 	on btn_scan pressed do (
   		dir_imatges = getSavePath caption:"Choose image dir:"
   		if dir_imatges != undefined do (
   			btn_scan.text = dir_imatges
   			fitxers_jpg = getFiles (dir_imatges + "\\*.jpg")
   			ompleListView lv_imatges fitxers_jpg
   		)
   	)
	
	on roll_imatges open do (
   		inicialitzaListView lv_imatges
		
		--//Initial Directory on open
		if dir_imatges != undefined do (
   			btn_scan.text = dir_imatges
   			fitxers_jpg = getFiles (dir_imatges + "\\*.jpg")
   			ompleListView lv_imatges fitxers_jpg
   		)
   	)	
)
createDialog roll_imatges 240 450 style:#(#style_SysMenu, #style_ToolWindow)

So I’ve got the image displaying when you click on the image but it displays when you click on the text to which doesn’t help haha. I need the text to have its own click state.

I’ve also noticed that i need to change the way I filter the materials. Right now I gather the images. What i need to do is gather the .mat files and proceed with and If/then statement where if it has an image with the same file name then display that corresponding img, otherwise just be blank.

updated code so far:


try(destroyDialog ::roll_imatges)catch()
rollout roll_imatges "Materials" 
(
	local	dir_imatges = @"C:\Users\IEVFX\Desktop	rash\mtlTesting"
	
  	button btn_scan "Directory" width:220 height:24 pos:[10,10]
  	dotNetControl lv_imatges "System.Windows.Forms.ListView" pos:[10,40] width:220 height:400
   	
	fn myCallback = ( return false )
	
 	fn carrega_imatges paths_imatges = (
   		fn callback_abort = ( dotnetObject "System.Drawing.Image+GetThumbnailImageAbort" myCallback())
   		local ptr_callback_abort = dotNetClass "System.IntPtr"
   		Llista_Imatges	= dotNetObject "System.Windows.Forms.ImageList"
   		Llista_Imatges.ColorDepth = Llista_Imatges.ColorDepth.Depth24Bit
   		Llista_Imatges.ImageSize = dotNetObject "System.Drawing.Size" 90 90
 		for path_imatge in paths_imatges do (
   			thumb = dotNetObject "System.Drawing.Bitmap" path_imatge
  			-- Calling GetThumbnailImage this way doesn't work :(
   			-- thumb = thumb.GetThumbnailImage 160 120 (callback_abort()) (ptr_callback_abort.Zero)
   			Llista_Imatges.images.add thumb
   		)
   		return Llista_Imatges
   	)
	
 	fn inicialitzaListView lv = (
   		lv.View = (dotNetClass "System.Windows.Forms.View").Details
   		lv.borderstyle = (dotnetclass "System.Windows.Forms.BorderStyle").fixedsingle
   		lv.showitemtooltips = true
   		lv.gridlines = true
   		lv.checkboxes = false
   		lv.labeledit = false
   		lv.Columns.add "Image" 90
   		lv.Columns.add "Name" 130
   	)
	
 	fn ompleListView lv llista_imatges = (
   		lv.Clear()
   		lv.Columns.add "Image" 90
   		lv.Columns.add "Name" 130
   		lv.SmallImageList = carrega_imatges llista_imatges
  		for i = 1 to llista_imatges.count do (
   			imatge = llista_imatges[i]
   			ListViewOps.AddLvItem lv pTextItems:#("",(getFilenameFile imatge)) pImgIndex:(i-1)
   		)
   	)
	
 	on btn_scan pressed do (
   		dir_imatges = getSavePath caption:"Choose image dir:"
   		if dir_imatges != undefined do (
   			btn_scan.text = dir_imatges
   			fitxers_jpg = getFiles (dir_imatges + "\\*.jpg")
   			ompleListView lv_imatges fitxers_jpg
   		)
   	)
	
	on lv_imatges mouseDown arg do
	(
		clearListener()
		showProperties arg
		print "---"
		hit=(lv_imatges.HitTest (dotNetObject "System.Drawing.Point" arg.x arg.y))
		showProperties hit
		if hit.item != undefined do
		(
			print hit.item.text
			showProperties hit.item.subItems
			print hit.item.subItems.count
			print hit.item.subItems.item[1].text
			img = openBitmap(dir_imatges + "\\" + (hit.item.subItems.item[1].text)+".jpg")
			display img
		)
	)
	
	on roll_imatges open do (
   		inicialitzaListView lv_imatges
		
		--//Initial Directory on open
		if dir_imatges != undefined do (
   			btn_scan.text = dir_imatges
   			fitxers_jpg = getFiles (dir_imatges + "\\*.jpg")
   			ompleListView lv_imatges fitxers_jpg
   		)
   	)	
)
createDialog roll_imatges 240 450 style:#(#style_SysMenu, #style_ToolWindow)

Page 8 / 18