public RhinoObject[] GetSelectedObjects(ObjectType filter) { var page_pointer = RhinoPageHooks.UnmanagedIRhinoPagePointerFromPage(this); var object_count = 0; var array_pointer = UnsafeNativeMethods.IRhinoPropertiesPanelPage_GetObjects(page_pointer, (uint)filter, ref object_count); var rc = new List <RhinoObject>(); for (var i = 0; i < object_count; i++) { var pointer = UnsafeNativeMethods.IRhinoPropertiesPanelPage_GetObjectsAt(array_pointer, i); if (pointer == IntPtr.Zero) { continue; } var rhino_object = RhinoObject.CreateRhinoObjectHelper(pointer); if (rhino_object != null) { rc.Add(rhino_object); } } UnsafeNativeMethods.IRhinoPropertiesPanelPage_GetObjectsClear(array_pointer); return(rc.ToArray()); }
/// <summary> /// Return true if any of the selected objects match the given type /// </summary> /// <typeparam name="T"></typeparam> /// <param name="allMustMatch"> /// If true then every selected object must match the object type /// otherwise; only a single object has to be of the specified type /// </param> /// <returns></returns> /// <since>6.7</since> public bool AnySelectedObject <T>(bool allMustMatch) where T : RhinoObject { var type = typeof(T); var filter = allMustMatch ? ObjectType.AnyObject : TypeFilter(type); var page_pointer = RhinoPageHooks.UnmanagedIRhinoPagePointerFromPage(this); var count = 0; var array_pointer = UnsafeNativeMethods.IRhinoPropertiesPanelPage_GetObjects(page_pointer, (uint)filter, ref count); for (var i = 0; i < count; i++) { var pointer = UnsafeNativeMethods.IRhinoPropertiesPanelPage_GetObjectsAt(array_pointer, i); if (pointer == IntPtr.Zero) { continue; } var obj = RhinoObject.CreateRhinoObjectHelper(pointer) as T; // If all objects must match and this object does not then return false if (allMustMatch && obj == null) { return(false); } // No requirement for all objects to match and this one does then just return true now if (!allMustMatch && obj != null) { return(true); } } return(allMustMatch && count > 0); }
/// <summary> /// Get selected objects of a given type /// </summary> /// <typeparam name="T"></typeparam> /// <returns></returns> /// <since>6.0</since> public T[] GetObjects <T>() where T : RhinoObject { var type = typeof(T); var filter = TypeFilter(type); var page_pointer = RhinoPageHooks.UnmanagedIRhinoPagePointerFromPage(Page); var object_count = 0; var array_pointer = UnsafeNativeMethods.IRhinoPropertiesPanelPage_GetObjects(page_pointer, (uint)filter, ref object_count); var rc = new List <T>(); for (var i = 0; i < object_count; i++) { var pointer = UnsafeNativeMethods.IRhinoPropertiesPanelPage_GetObjectsAt(array_pointer, i); if (pointer == IntPtr.Zero) { continue; } var rhino_object = RhinoObject.CreateRhinoObjectHelper(pointer) as T; if (rhino_object != null) { rc.Add(rhino_object); } } UnsafeNativeMethods.IRhinoPropertiesPanelPage_GetObjectsClear(array_pointer); return(rc.ToArray()); }
/// <summary> /// Currently only supported on Windows. Call this method to add a child /// page to a page after the parent dialog has been created. /// </summary> /// <param name="pageToAdd"></param> /// <since>6.0</since> public void AddChildPage(StackedDialogPage pageToAdd) { if (!Runtime.HostUtils.RunningOnWindows) { return; } var unmanaged_pointer = RhinoPageHooks.UnmanagedIRhinoPagePointerFromPage(this); if (unmanaged_pointer == IntPtr.Zero) { // The page array has not been processed yet so just append the page // to the end of the children list Children.Add(pageToAdd); return; } // // Unmanaged page has been created so create and add the new child page // // Use new IRhinoOptionsPageHost unmanaged interface to add the child page // Only allow adding child pages to OptionsDialogPages var pointer = pageToAdd is OptionsDialogPage ? RhinoPageHooks.NewIRhinoOptionsPagePointer(pageToAdd, RhinoPageHooks.RhinoDocRuntimeSerialNumberFromPage(this)) : IntPtr.Zero; // Not a OptionsDialogPage or was unable to allocate a unmanaged pointer if (pointer == IntPtr.Zero) { return; } // Add the child page to this objects IRhinoOptionsPageHost if (!RhinoPageHooks.AddChildPage(unmanaged_pointer, pointer)) { UnsafeNativeMethods.IRhinoOptionsPage_Delete(pointer); return; } // Put the new child page in the child array Children.Add(pageToAdd); }
/// <summary> /// For internal use only, provides access to unmanaged core /// </summary> /// <param name="pointer"></param> /// <returns></returns> /// <since>6.4</since> public static StackedDialogPage StackedDialogPageFromUnmanagedPointer(IntPtr pointer) => RhinoPageHooks.StackedDialogPageFromPointer(pointer);
public static IntPtr NewPropertiesPanelPagePointer(ObjectPropertiesPage page, uint rhinoDocRuntimeSn) => RhinoPageHooks.NewIRhinoPropertiesPanelPagePointer(page, rhinoDocRuntimeSn);
/// <summary> /// Call this method when the page is ready to modify the selected objects /// list. Rhino will suspend UpdatePageNotfictaion, call the passed action /// then restore UpdatePageNotfictaion. /// </summary> /// <param name="callbackAction"> /// Called when it is safe to modify objects. /// </param> /// <since>6.0</since> public void ModifyPage(Action <ObjectPropertiesPageEventArgs> callbackAction) { RhinoPageHooks.ObjectPropertiesModifyPage(this, callbackAction); }
public bool IncludesObjectsType(ObjectType objectTypes, bool allMustMatch) { var pointer = RhinoPageHooks.UnmanagedIRhinoPagePointerFromPage(Page); return(UnsafeNativeMethods.IRhinoPropertiesPanelPage_AnySelectedObjects(pointer, (uint)objectTypes, allMustMatch)); }