public override void doIt(MArgList argl) { SubscribeAssemblyResolvingEvent(); if (!String.IsNullOrEmpty(wpfTitle)) { // Check the existence of the window int wndExist = int.Parse(MGlobal.executeCommandStringResult($@"format -stringArg `control -q -ex ""{wpfTitle}""` ""^1s""")); if (wndExist > 0) { MGlobal.executeCommand($@"catch (`workspaceControl -e -visible true ""{hostTitle}""`);"); return; } } if (dynStartUp != null) { if (dynStartUp.DynView != null) { if (dynStartUp.DynView.IsVisible) { MGlobal.displayWarning("Dynamo is already open"); return; } else { dynWnd.Show(); } } } else { newDmStartup(); dynWnd = dynStartUp.DynView; // Create the window to dock dynWnd.Show(); // Extract the window handle of the window we want to dock IntPtr mWindowHandle = new System.Windows.Interop.WindowInteropHelper(dynWnd).Handle; int width = (int)dynWnd.Width; int height = (int)dynWnd.Height; var title = dynWnd.Title; wpfTitle = title + " Internal"; hostTitle = title; dynWnd.Title = wpfTitle; mayaWnd = new MForeignWindowWrapper(mWindowHandle, true); uint flagIdx = argl.flagIndex(flagName); if (flagIdx == MArgList.kInvalidArgIndex) { // Create a workspace-control to wrap the native window wrapper, and use it as the parent of this WPF window CreateWorkspaceControl(wpfTitle, hostTitle, width, height, false); } } }
void parseArgs(MArgList args) { createdUsed = (args.flagIndex(kCreateFlag, kCreateFlagLong) != MArgList.kInvalidArgIndex); editUsed = (args.flagIndex(kEditFlag, kEditFlagLong) != MArgList.kInvalidArgIndex); queryUsed = (args.flagIndex(kQueryFlag, kQueryFlagLong) != MArgList.kInvalidArgIndex); helpUsed = (args.flagIndex(kHelpFlag, kHelpFlagLong) != MArgList.kInvalidArgIndex); numLayersUsed = (args.flagIndex(kNumLayersFlag, kNumLayersFlagLong) != MArgList.kInvalidArgIndex); // If flags are used which require no other information, return now. // if (createdUsed || helpUsed) return; uint maxArg = args.length - 1; uint activeIndex = args.flagIndex(kActiveFlag, kActiveFlagLong); uint appendCameraIndex = args.flagIndex(kAppendCameraFlag, kAppendCameraFlagLong); uint appendCameraAndSetIndex = args.flagIndex(kAppendCameraAndSetFlag, kAppendCameraAndSetFlagLong); uint cameraIndex = args.flagIndex(kCameraFlag, kCameraFlagLong); uint deleteLayerIndex = args.flagIndex(kDeleteLayerFlag, kDeleteLayerFlagLong); uint layerIndex = args.flagIndex(kLayerFlag, kLayerFlagLong); uint layerTypeIndex = args.flagIndex(kLayerTypeFlag, kLayerTypeFlagLong); uint setIndex = args.flagIndex(kSetFlag, kSetFlagLong); activeUsed = (activeIndex != MArgList.kInvalidArgIndex); appendCameraUsed = (appendCameraIndex != MArgList.kInvalidArgIndex); appendCameraAndSetUsed = (appendCameraAndSetIndex != MArgList.kInvalidArgIndex); cameraUsed = (cameraIndex != MArgList.kInvalidArgIndex); deleteLayerUsed = (deleteLayerIndex != MArgList.kInvalidArgIndex); layerUsed = (layerIndex != MArgList.kInvalidArgIndex); layerTypeUsed = (layerTypeIndex != MArgList.kInvalidArgIndex); setUsed = (setIndex != MArgList.kInvalidArgIndex); // Process each flag. // bool maxArgUsed = false; if (activeUsed) { if (editUsed) { activeVal = args.asBool((activeIndex + 1)); if ((layerTypeIndex + 1) == maxArg) maxArgUsed = true; } } if (appendCameraUsed) { camName = args.asString((appendCameraIndex + 1)); if ((appendCameraIndex + 1) == maxArg) maxArgUsed = true; } if (appendCameraAndSetUsed) { camName = args.asString((appendCameraAndSetIndex + 1)); setName = args.asString((appendCameraAndSetIndex + 2)); if ((appendCameraAndSetIndex + 2) == maxArg) maxArgUsed = true; } if (cameraUsed) { if (editUsed) { camName = args.asString(cameraIndex + 1); if ((cameraIndex + 1) == maxArg) maxArgUsed = true; } } if (deleteLayerUsed) { cameraLayer = args.asInt(deleteLayerIndex + 1); if ((deleteLayerIndex + 1) == maxArg) maxArgUsed = true; } if (layerUsed) { cameraLayer = args.asInt(layerIndex + 1); if ((layerIndex + 1) == maxArg) maxArgUsed = true; } if (layerTypeUsed) { if (editUsed) { layerTypeVal = args.asString(layerTypeIndex + 1); if ((layerTypeIndex + 1) == maxArg) maxArgUsed = true; } } if (setUsed) { if (editUsed) { setName = args.asString(setIndex + 1); if ((setIndex + 1) == maxArg) maxArgUsed = true; } } // If all of the arguments have been used, get the cameraSet node from the selection list. // Otherwise, get it from the last argument. // if (maxArgUsed) MGlobal.getActiveSelectionList(list); else list.add(args.asString(maxArg)); }
void parseArgs(MArgList args) { createdUsed = (args.flagIndex(kCreateFlag, kCreateFlagLong) != MArgList.kInvalidArgIndex); editUsed = (args.flagIndex(kEditFlag, kEditFlagLong) != MArgList.kInvalidArgIndex); queryUsed = (args.flagIndex(kQueryFlag, kQueryFlagLong) != MArgList.kInvalidArgIndex); helpUsed = (args.flagIndex(kHelpFlag, kHelpFlagLong) != MArgList.kInvalidArgIndex); numLayersUsed = (args.flagIndex(kNumLayersFlag, kNumLayersFlagLong) != MArgList.kInvalidArgIndex); // If flags are used which require no other information, return now. // if (createdUsed || helpUsed) { return; } uint maxArg = args.length - 1; uint activeIndex = args.flagIndex(kActiveFlag, kActiveFlagLong); uint appendCameraIndex = args.flagIndex(kAppendCameraFlag, kAppendCameraFlagLong); uint appendCameraAndSetIndex = args.flagIndex(kAppendCameraAndSetFlag, kAppendCameraAndSetFlagLong); uint cameraIndex = args.flagIndex(kCameraFlag, kCameraFlagLong); uint deleteLayerIndex = args.flagIndex(kDeleteLayerFlag, kDeleteLayerFlagLong); uint layerIndex = args.flagIndex(kLayerFlag, kLayerFlagLong); uint layerTypeIndex = args.flagIndex(kLayerTypeFlag, kLayerTypeFlagLong); uint setIndex = args.flagIndex(kSetFlag, kSetFlagLong); activeUsed = (activeIndex != MArgList.kInvalidArgIndex); appendCameraUsed = (appendCameraIndex != MArgList.kInvalidArgIndex); appendCameraAndSetUsed = (appendCameraAndSetIndex != MArgList.kInvalidArgIndex); cameraUsed = (cameraIndex != MArgList.kInvalidArgIndex); deleteLayerUsed = (deleteLayerIndex != MArgList.kInvalidArgIndex); layerUsed = (layerIndex != MArgList.kInvalidArgIndex); layerTypeUsed = (layerTypeIndex != MArgList.kInvalidArgIndex); setUsed = (setIndex != MArgList.kInvalidArgIndex); // Process each flag. // bool maxArgUsed = false; if (activeUsed) { if (editUsed) { activeVal = args.asBool((activeIndex + 1)); if ((layerTypeIndex + 1) == maxArg) { maxArgUsed = true; } } } if (appendCameraUsed) { camName = args.asString((appendCameraIndex + 1)); if ((appendCameraIndex + 1) == maxArg) { maxArgUsed = true; } } if (appendCameraAndSetUsed) { camName = args.asString((appendCameraAndSetIndex + 1)); setName = args.asString((appendCameraAndSetIndex + 2)); if ((appendCameraAndSetIndex + 2) == maxArg) { maxArgUsed = true; } } if (cameraUsed) { if (editUsed) { camName = args.asString(cameraIndex + 1); if ((cameraIndex + 1) == maxArg) { maxArgUsed = true; } } } if (deleteLayerUsed) { cameraLayer = args.asInt(deleteLayerIndex + 1); if ((deleteLayerIndex + 1) == maxArg) { maxArgUsed = true; } } if (layerUsed) { cameraLayer = args.asInt(layerIndex + 1); if ((layerIndex + 1) == maxArg) { maxArgUsed = true; } } if (layerTypeUsed) { if (editUsed) { layerTypeVal = args.asString(layerTypeIndex + 1); if ((layerTypeIndex + 1) == maxArg) { maxArgUsed = true; } } } if (setUsed) { if (editUsed) { setName = args.asString(setIndex + 1); if ((setIndex + 1) == maxArg) { maxArgUsed = true; } } } // If all of the arguments have been used, get the cameraSet node from the selection list. // Otherwise, get it from the last argument. // if (maxArgUsed) { MGlobal.getActiveSelectionList(list); } else { list.add(args.asString(maxArg)); } }