Access C# .DLL Control?

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 07 July 2011   #1
Question Access C# .DLL Control?

Hey,

I've started getting into C#, and have started learning how to implement it into 3ds max.

I found a thumbnail tool I want to modify/use, and I have been able to compile it and load the .dll and UI in Max just fine. It works just the same in max as it does in VS or as a standalone.

So, now I am wondering how I might be able to access a control in my dll/dotnetcontrol so I can possibly feed it a folder location, or preferrably, an array of image paths.


In my MainForm, I have a




privateThumbnailController m_Controller;

in a Public MainForm() function(?) I have




m_Controller = new ThumbnailController();
m_Controller.OnStart += new ThumbnailControllerEventHandler(m_Controller_OnSta  rt);
m_Controller.OnAdd += new  ThumbnailControllerEventHandler(m_Controller_OnAdd  );



So my question is, in max can I do something like,

m_Controller.AddFolder("PATH");

I'm showing my UI in max right now by making a rollout, then doing


dotNetControl tib_control "marlie.TumbnailDotnet.mainform" pos:[0,0] width:651 
height:542  


then for the Rollout Open, I just do tib_control.show()


Hopefully that make sense....


Thanks!



__________________
http://matthewlichy.com


Last edited by Kickflipkid687 : 07 July 2011 at 08:19 PM.
 
Old 07 July 2011   #2
you have to add ThumbnailController to rollout (not mainform):

 dotnetcontroller tib_control "marlie.TumbnailDotnet.ThumbnailController" pos:[0,0] width:651 
 height:542  

and on rollout open event call AddFolder method:

on <rollout> open do (tib_control.AddFolder "PATH")
 
Old 07 July 2011   #3
When I try to add the controller and not the mainform, I get an system exception...?


 
dotnet.loadassembly "C:\Program Files\Autodesk\3ds Max 
2011\marlie.TumbnailDotnet.dll"
 
 
rollout textureinfobrowser_rollout "TextureInfoBrowser" 
width:651 height:542 
(
 --dotNetControl tib_control 
"marlie.TumbnailDotnet.mainform" pos:[0,0] width:651 height:542  
 
 dotnetcontrol tib_control "marlie.TumbnailDotnet.ThumbnailController" 
pos:[0,0] width:651 height:542  
 
 
 on textureinfobrowser_rollout open do 
 
 (
  tib_control.show()
  --setDialogpos 
textureinfobrowser_rollout [0,0]
  destroydialog 
textureinfobrowser_rollout
  --tib_control.m_Controller.AddFolder("C:\Users\a-malich\Desktop\Textures\\");
 )
)
createdialog 
textureinfobrowser_rollout style:#(#style_resizing, #style_titlebar, 
#style_border, #style_sysmenu)



Edit:



privateThumbnailController m_Controller;

Would that be why? Should I make a public function to allow access to it, in the main form?


Edit:

So I tried doing




dotNetControl tib_control 
"marlie.TumbnailDotnet.m_Controller" pos:[0,0] width:651 height:542  

 
 on textureinfobrowser_rollout open do 

 (
  --tib_control.show()
  --setDialogpos 
textureinfobrowser_rollout [0,0]
  destroydialog 
textureinfobrowser_rollout
  tib_control.AddFolder("C:\Users\a-malich\Desktop\Textures\\");
 )


Which then said


---------------------------
MAXScript Rollout Handler 
Exception
---------------------------
-- Unknown property: "AddFolder" in 
dotNetControl:tib_control:(null)
---------------------------
OK   

---------------------------
__________________
http://matthewlichy.com


Last edited by Kickflipkid687 : 07 July 2011 at 12:00 AM.
 
Old 07 July 2011   #4
I tried something here a programmer recommended, which was to make a public function in the mainform.cs and it worked

I did,





public void mControllerFolder(string folderPath)
 
 {
 
 
this.flowLayoutPanelMain.Controls.Clear();
 m_Controller.AddFolder(folderPath);
 
 
this.buttonCancel.Enabled = true;
 
 
this.buttonBrowseFolder.Enabled = false;
  }
 


Then in Max, I did


 
dotNetControl tib_control 
"marlie.TumbnailDotnet.mainform" pos:[0,0] width:651 height:542  
 
 
 on textureinfobrowser_rollout open do 
 
 (
  tib_control.show()
  tib_control.mControllerFolder("C:\Users\a-malich\Desktop\Textures");  
  destroydialog 
textureinfobrowser_rollout
  )



Now I just need to find out if I can somehow take an array of image paths and put them into a folder for my code to read. I don't want to copy the images to a temp folder.

The code reads images from a folder right now, so that it can send the folder as a backroundworker I believe. I'm not sure if I could feed in an array of image paths instead? I guess its the same thing, but I'm not sure.






private void AddFolder(object folderPath)
 
 
{
 
 
string path = (string)folderPath;
 
 
if (this.OnStart != null)
 
 
 {
 
 
 
this.OnStart(this, new ThumbnailControllerEventArgs(null));
 
 
 
  }
 
 
 
 
this.AddFolderIntern(path);
 
 
 
 if (this.OnEnd != null)
 
 
 
  {
 
 
this.OnEnd(this, new ThumbnailControllerEventArgs(null));
 
 
 
			}
 
 
 
 
 
			CancelScanning = false; 
 
		}
 
 
private void AddFolderIntern(string folderPath)
 
 
 
		{
 
 
 
if (CancelScanning) return;
 
 
 
// not using AllDirectories
 
 
 
string[] files = Directory.GetFiles(folderPath);
 
 
foreach(string file in files)
 
			{
 
 
if (CancelScanning) break;
 
 
Image img = null;
 
 
try
 
				{
					img = Image.FromFile(file); 
 
				}
 
catch
 
 
				{
 
// do nothing
 
 
				}
 
if (img != null)
 
				{
this.OnAdd(this, new ThumbnailControllerEventArgs(file));
 
					img.Dispose();
 
				}
			}
 



Edit: Sorry for the horrible formatting... stupid copy/paste
__________________
http://matthewlichy.com


Last edited by Kickflipkid687 : 07 July 2011 at 03:37 PM.
 
Old 07 July 2011   #5
Ok, so the same guy here wrote a couple functions quick for me to support a string array.

Then in my mainform I had to add




public void AddFiles(string[] files) 


  {


		m_Controller.AddFiles(files); 

	 }



So now in max I can just do,



 tib_control.show()
  local stringArray = #()
   stringArray = #("C:\Users\a-malich\Desktop\Textures\1266801488.jpg","C:\Users\a-malich\Desktop\Textures\Carpet0020_2_S.jpg")
  tib_control.Addfiles(stringArray)  
__________________
http://matthewlichy.com

 
Old 07 July 2011   #6
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 02:54 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.