Exemple #1
0
        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());
        }
Exemple #2
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());
        }
Exemple #3
0
        /// <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);
        }
Exemple #4
0
        /// <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);
        }
Exemple #5
0
        public bool IncludesObjectsType(ObjectType objectTypes, bool allMustMatch)
        {
            var pointer = RhinoPageHooks.UnmanagedIRhinoPagePointerFromPage(Page);

            return(UnsafeNativeMethods.IRhinoPropertiesPanelPage_AnySelectedObjects(pointer, (uint)objectTypes, allMustMatch));
        }