Пример #1
0
 /// <summary>
 /// Unlike most ports, this kind of port will draw a drop-shadow, if expected of the parent
 /// <see cref="T:Northwoods.Go.GoBoxNode" />.
 /// </summary>
 /// <param name="g"></param>
 /// <param name="view"></param>
 public override void Paint(Graphics g, GoView view)
 {
     if (Style != 0 && base.Parent != null && base.Parent.Shadowed)
     {
         RectangleF bounds       = Bounds;
         SizeF      shadowOffset = base.Parent.GetShadowOffset(view);
         if (Brush != null)
         {
             Brush shadowBrush = base.Parent.GetShadowBrush(view);
             GoShape.DrawRectangle(g, view, null, shadowBrush, bounds.X + shadowOffset.Width, bounds.Y + shadowOffset.Height, bounds.Width, bounds.Height);
         }
         else if (Pen != null)
         {
             Pen shadowPen = base.Parent.GetShadowPen(view, GoShape.GetPenWidth(Pen));
             GoShape.DrawRectangle(g, view, shadowPen, null, bounds.X + shadowOffset.Width, bounds.Y + shadowOffset.Height, bounds.Width, bounds.Height);
         }
     }
     base.Paint(g, view);
 }
Пример #2
0
        /// <summary>
        /// Create and determine the appearance of a small handle for an object.
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="selectedObj"></param>
        /// <param name="loc"></param>
        /// <param name="handleid"></param>
        /// <param name="filled"></param>
        /// <returns></returns>
        /// <remarks>
        /// This method uses <see cref="M:Northwoods.Go.GoObject.CreateResizeHandle(System.Int32)" /> to
        /// actually allocate the handle.
        /// The size of the handle, if not already non-zero, is determined by
        /// <see cref="P:Northwoods.Go.GoView.ResizeHandleSize" />.
        /// The pen and brush of the handle are determined by
        /// <see cref="P:Northwoods.Go.GoView.PrimarySelectionColor" /> and <see cref="P:Northwoods.Go.GoView.SecondarySelectionColor" />.
        /// 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.CreateBoundingHandle(Northwoods.Go.GoObject,Northwoods.Go.GoObject)" />
        public virtual IGoHandle CreateResizeHandle(GoObject obj, GoObject selectedObj, PointF loc, int handleid, bool filled)
        {
            IGoHandle goHandle = obj.CreateResizeHandle(handleid);

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

            if (goObject == null)
            {
                return(null);
            }
            GoView view  = View;
            SizeF  sizeF = goObject.Size;

            if (sizeF.Width <= 0f || sizeF.Height <= 0f)
            {
                sizeF = (view?.ResizeHandleSize ?? new SizeF(6f, 6f));
            }
            if (view != null)
            {
                sizeF.Width  /= view.WorldScale.Width;
                sizeF.Height /= view.WorldScale.Height;
            }
            goObject.Bounds = new RectangleF(loc.X - sizeF.Width / 2f, loc.Y - sizeF.Height / 2f, sizeF.Width, sizeF.Height);
            if (handleid == 0)
            {
                goObject.Selectable = false;
            }
            else
            {
                goObject.Selectable = true;
            }
            GoShape goShape = goObject as GoShape;

            if (goShape != null)
            {
                Color color = Color.LightGray;
                if (view != null)
                {
                    color = ((!Focused) ? view.NoFocusSelectionColor : ((Primary == null || Primary.SelectionObject != obj) ? view.SecondarySelectionColor : view.PrimarySelectionColor));
                }
                if (filled)
                {
                    float resizeHandlePenWidth = view.ResizeHandlePenWidth;
                    float num = (resizeHandlePenWidth == 0f) ? 0f : (resizeHandlePenWidth / view.WorldScale.Width);
                    if (myResizeHandlePen == null || GoShape.GetPenColor(myResizeHandlePen, myResizeHandlePenColor) != myResizeHandlePenColor || GoShape.GetPenWidth(myResizeHandlePen) != num)
                    {
                        myResizeHandlePen = GoShape.NewPen(myResizeHandlePenColor, num);
                    }
                    goShape.Pen = myResizeHandlePen;
                    if (myResizeHandleBrush == null || myResizeHandleBrush.Color != color)
                    {
                        myResizeHandleBrush = new SolidBrush(color);
                    }
                    goShape.Brush = myResizeHandleBrush;
                }
                else
                {
                    float resizeHandlePenWidth2 = view.ResizeHandlePenWidth;
                    float num2 = (resizeHandlePenWidth2 == 0f) ? 0f : ((resizeHandlePenWidth2 + 1f) / view.WorldScale.Width);
                    if (myResizeHandlePen == null || GoShape.GetPenColor(myResizeHandlePen, color) != color || GoShape.GetPenWidth(myResizeHandlePen) != num2)
                    {
                        myResizeHandlePen = GoShape.NewPen(color, num2);
                    }
                    goShape.Pen   = myResizeHandlePen;
                    goShape.Brush = null;
                }
            }
            AddHandle(obj, goHandle);
            return(goHandle);
        }
Пример #3
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);
        }