示例#1
0
        /// <summary>
        /// Create and determine the appearance of a large handle around an object.
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="selectedObj"></param>
        /// <returns></returns>
        /// <remarks>
        /// This method uses <see cref="M:Northwoods.Go.GoObject.CreateBoundingHandle" /> to
        /// actually allocate the handle and to set the size and location of the
        /// handle, as determined by the bounding rectangle of <paramref name="obj" />.
        /// The pen of the handle is determined by
        /// <see cref="P:Northwoods.Go.GoView.PrimarySelectionColor" /> and
        /// <see cref="P:Northwoods.Go.GoView.SecondarySelectionColor" />; the brush is set to null.
        /// The new handle is associated with the <paramref name="obj" /> and its
        /// <see cref="P:Northwoods.Go.IGoHandle.SelectedObject" /> property is set to
        /// <paramref name="selectedObj" />.
        /// </remarks>
        /// <seealso cref="M:Northwoods.Go.GoSelection.CreateResizeHandle(Northwoods.Go.GoObject,Northwoods.Go.GoObject,System.Drawing.PointF,System.Int32,System.Boolean)" />
        public virtual IGoHandle CreateBoundingHandle(GoObject obj, GoObject selectedObj)
        {
            IGoHandle goHandle = obj.CreateBoundingHandle();

            if (goHandle == null)
            {
                return(null);
            }
            goHandle.SelectedObject = selectedObj;
            GoObject goObject = goHandle.GoObject;

            if (goObject == null)
            {
                return(null);
            }
            goObject.Selectable = false;
            GoShape goShape = goObject as GoShape;

            if (goShape != null)
            {
                Color  color = Color.LightGray;
                GoView view  = View;
                if (view != null)
                {
                    color = ((!Focused) ? view.NoFocusSelectionColor : ((Primary == null || Primary.SelectionObject != obj) ? view.SecondarySelectionColor : view.PrimarySelectionColor));
                }
                float boundingHandlePenWidth = view.BoundingHandlePenWidth;
                float num = (boundingHandlePenWidth == 0f) ? 0f : (boundingHandlePenWidth / view.WorldScale.Width);
                if (myBoundingHandlePen == null || GoShape.GetPenColor(myBoundingHandlePen, color) != color || GoShape.GetPenWidth(myBoundingHandlePen) != num)
                {
                    myBoundingHandlePen = GoShape.NewPen(color, num);
                }
                goShape.Pen   = myBoundingHandlePen;
                goShape.Brush = null;
            }
            AddHandle(obj, goHandle);
            return(goHandle);
        }