/* martroyx 03//17//2010 */ ( global DialogShow local DialogShowTitle = "MarTroYx Show Dialog" local vr_IsReady = false local vr_MaxDomain = dotnetclass "System.AppDomain" local vr_ExecPath = getFilenamePath( getSourceFileName() ) local vr_AssemblyName = "DialogHelper_Rev01" global vr_DialogHelper = undefined local vr_DialogList = #() --//-- for f in vr_MaxDomain.CurrentDomain.GetAssemblies() do ( if (filterstring f.fullname ",")[1] == vr_AssemblyName then (vr_IsReady = true; exit) ) --//-- if not vr_IsReady then ( CProvider = dotnetobject "Microsoft.CSharp.CSharpCodeProvider" CParams = dotnetobject "System.CodeDom.Compiler.CompilerParameters" StrBuild = Dotnetobject "System.Text.StringBuilder" --//-- CParams.GenerateInMemory = true CParams.CompilerOptions = "" --//-- CParams.ReferencedAssemblies.Add("System.dll") CParams.ReferencedAssemblies.Add("System.Xml.dll") CParams.ReferencedAssemblies.Add("System.Data.dll") --//-- StrBuild.Append("using System;\n") StrBuild.Append("using System.Text;\n") StrBuild.Append("using System.Runtime.InteropServices;\n") StrBuild.Append("using System.Collections.Generic;\n") --//-- StrBuild.Append("namespace "+vr_AssemblyName+"\n") StrBuild.Append("{\n") StrBuild.Append("public class HelperObject\n") StrBuild.Append("{\n") StrBuild.Append("public HelperObject()\n") StrBuild.Append("{\n") StrBuild.Append("}\n") --//-- StrBuild.Append("public void ShowDialog( IntPtr hwnd, int bEnable )\n") StrBuild.Append("{\n") StrBuild.Append("ShowWindow(hwnd, bEnable);\n") StrBuild.Append("}\n") --//-- StrBuild.Append("public bool IsDialogVisible( IntPtr hwnd )\n") StrBuild.Append("{\n") StrBuild.Append("return IsWindowVisible( hwnd );\n") StrBuild.Append("}\n") --//-- StrBuild.Append("[DllImport(\"user32.dll\")]\n") StrBuild.Append("private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);\n") --//-- StrBuild.Append("[DllImport(\"user32.dll\")]\n") StrBuild.Append("private static extern bool IsWindowVisible(IntPtr hWnd);\n") --//-- StrBuild.Append("}\n") StrBuild.Append("}\n") --//-- result = CProvider.CompileAssemblyFromSource CParams #(StrBuild.tostring()) --//-- for f in 0 to result.errors.count - 1 do ( print (result.errors.item[f].ErrorText) ) --//-- vr_IsReady = result.errors.count == 0 ) --//-- if vr_IsReady then ( vr_DialogHelper = dotnetobject ( vr_AssemblyName + ".HelperObject" ) ) --//-- if vr_DialogHelper != undefined then ( try (destroydialog DialogShow) catch() --//-- rollout DialogShow DialogShowTitle ( dotnetcontrol DialogList "System.Windows.Forms.CheckedListBox" height:244 pos:[5,5] width:(DialogShow.width-10) dotnetcontrol UpdateBt "System.Windows.Forms.Button" height:36 offset:[-8,0] width:(DialogShow.width-10) --//-- fn UpdateDialogList = ( local vr_TempDialogList = windows.getChildrenHWND 0 parent:#max --//-- for f in vr_TempDialogList.count to 1 by -1 do ( local Added = false local Dname = vr_TempDialogList[f][5]as string --; print Dname local Fname = #( "MAXScript Listener", "Environment and Effects", "Render To Texture", "Track View*", "Render Setup*", "Particle View", "Parameter Editor", "Parameter Collector", "Light Lister", "Schematic View*", "Map Channel Info", "Bone Tools", "Reaction Manager", "Motion Mixer", "*, frame*", "Render Surface Map", "Material Editor*", "Material/Map Browser", "Video Post", "Batch Render" ) --//----//----//----//----//----//----//-- for i in 1 to Fname.count where not Added do ( if matchpattern Dname pattern:Fname[i] ignoreCase:true then ( append vr_DialogList vr_TempDialogList[f] DialogList.items.Add Dname true Added = true ) --//-- ) --//-- ) --//-- ) --//-- fn ResetVisible = ( for f in 1 to vr_DialogList.count do ( local DPtr = dotnetobject "System.IntPtr" vr_DialogList[f][1] --//-- if not vr_DialogHelper.IsDialogVisible(DPtr) then ( vr_DialogHelper.ShowDialog DPtr 1 ) --//-- ) --//-- vr_DialogList = #() DialogList.items.Clear() ) --//-- on UpdateBt click s e do ( ResetVisible() UpdateDialogList() ) --//-- on DialogList SelectedIndexChanged s e do ( local Idx = s.SelectedIndex --//-- if Idx != -1 then ( for f in 1 to vr_DialogList.count do ( local DPtr = dotnetobject "System.IntPtr" vr_DialogList[f][1] --//-- if Idx+1 == f then ( s.SetItemChecked (f-1) true vr_DialogHelper.ShowDialog DPtr 1 ) else ( s.SetItemChecked (f-1) false vr_DialogHelper.ShowDialog DPtr 0 ) --//-- ) --//-- ) --//-- ) --//-- on DialogShow open do ( UpdateDialogList() ) --//-- on DialogShow close do ( ResetVisible() gc() ) --//-- ) --//-- createdialog DialogShow 260 300 style:#( #style_sysmenu, #style_titlebar, #style_toolwindow ) --//-- DialogShow.UpdateBt.text = "Refresh()" ) --//-- ok )