protected override bool OnClickStart(ScreenPoint cursorPos, Line cursorRay)
        {
            IDocObject selection    = null;
            IDocObject preselection = InteractionContext.Preselection;
            var        desFace      = preselection as DesignFace;

            if (desFace != null)
            {
                WriteBlock.ExecuteTask("Create Sphere Set", () => selection = SphereSet.Create(desFace, count, strength, radius, color).Subject);
            }
            else
            {
                SphereSet sphereSet = SphereSet.GetWrapper(preselection as CustomObject);
                if (sphereSet != null)
                {
                    selection = sphereSet.Subject;

                    CountSlider.Value    = sphereSet.Count;
                    StrengthSlider.Value = sphereSet.Strength;
                    ColorComboBox.Value  = sphereSet.Color;
                    RadiusSlider.Value   = sphereSet.Radius;
                }
            }

            Window.ActiveContext.Selection = new[] { selection };
            return(false);
        }
        protected override bool OnMouseMove(ScreenPoint cursorPos, Line cursorRay, MouseButtons button)
        {
            if (button != MouseButtons.None)
            {
                return(false);
            }

            IDocObject preselection = InteractionContext.Preselection;
            DesignFace desFace      = null;

            SphereSet existingSphereSet = SphereSet.GetWrapper(preselection as CustomObject);

            if (existingSphereSet != null)
            {
                desFace = existingSphereSet.DesFace;
            }
            if (desFace == null)
            {
                desFace = preselection as DesignFace;
            }
            if (desFace == null) // selection filtering is not applied if you (pre)select in the tree
            {
                return(false);
            }

            if (SphereSet.AllSphereSets.Where(s => s.DesFace == desFace).Count() > 0)
            {
                return(false);
            }

            Body body = desFace.Shape.Body;

            GraphicStyle style = null;

            if (existingSphereSet == null)
            {
                style = new GraphicStyle {
                    EnableDepthBuffer = true,
                    FillColor         = color
                };

                Rendering = Graphic.Create(style, null, SphereSet.GetGraphics(SphereSet.GetInitialPositions(body, count, true), radius));
            }

            return(false); // if we return true, the preselection won't update
        }