예제 #1
0
        public GoBasicNode InsertNode(PointF pt, string title, GoShape shape = null, int userFlag = 0, Object userObj = null)
        {
            if (shape == null)
            {
                shape = new GoRectangle();
            }
            GoDocument doc = goView.Document;

            doc.StartTransaction();
            GoBasicNode n = new GoBasicNode();

            n.UserFlags  = userFlag;
            n.UserObject = userObj;
            n.LabelSpot  = GoObject.Middle;
            n.Text       = title;
            n.Shape      = shape;

            // specify the position and colors
            n.Location       = pt;
            n.Brush          = new SolidBrush(Color.White);
            n.Shape.PenColor = Color.Red;
            n.Shape.PenWidth = 2;
            // allow the user to edit the text in-place
            n.Label.Editable = true;
            doc.Add(n);
            doc.FinishTransaction("Insert node finished");
            return(n);
        }
예제 #2
0
        public override void Paint(Graphics g, GoView view)
        {
            base.Paint(g, view);
            GoStroke s = this;

            if (mySeg >= s.PointsCount - 1)
            {
                mySeg = 0;
            }
            PointF a   = s.GetPoint(mySeg);
            PointF b   = s.GetPoint(mySeg + 1);
            float  len = (float)Math.Sqrt((b.X - a.X) * (b.X - a.X) + (b.Y - a.Y) * (b.Y - a.Y));
            float  x   = b.X;
            float  y   = b.Y;

            if (myDist >= len)
            {
                mySeg++;
                myDist = 0;
            }
            else if (len >= 1)
            {
                x = a.X + (b.X - a.X) * myDist / len;
                y = a.Y + (b.Y - a.Y) * myDist / len;
            }
            GoShape.DrawEllipse(g, view, null, Brushes.Red, x - 3, y - 3, 7, 7);
        }
예제 #3
0
파일: TextNode.cs 프로젝트: Tubbz-alt/WvsGo
        // Just change the GoTextNode's background brush color,
        // rather than adding selection handles.
        public override void RemoveSelectionHandles(GoSelection selection)
        {
            GoShape shape = this.Background as GoShape;

            if (shape != null)
            {
                //shape.FillHalfGradient(myNwoodsNamespaceColor);
            }
        }
예제 #4
0
파일: TextNode.cs 프로젝트: Tubbz-alt/WvsGo
        // Just change the GoTextNode's background brush color,
        // rather than adding selection handles.
        public override void AddSelectionHandles(GoSelection selection, GoObject selectedObject)
        {
            GoShape shape = this.Background as GoShape;

            if (shape != null)
            {
                //shape.BrushStyle = GoBrushStyle.Solid;
                //shape.BrushColor = Color.DeepPink;
            }
        }
예제 #5
0
        /// <summary>
        /// The closest intersection point of a polygon with a line is the
        /// closest such point for each of its segments.
        /// </summary>
        /// <param name="p1"></param>
        /// <param name="p2"></param>
        /// <param name="result"></param>
        /// <returns></returns>
        /// <remarks>
        /// This currently does not always take into account any Pen width.
        /// </remarks>
        public override bool GetNearestIntersectionPoint(PointF p1, PointF p2, out PointF result)
        {
            RectangleF bounds = Bounds;
            float      num    = PenWidth / 2f;
            float      num2   = 1E+21f;
            PointF     pointF = default(PointF);

            checked
            {
                PointF result2;
                if (Style == GoPolygonStyle.Bezier)
                {
                    for (int i = 3; i < myPointsCount; i += 3)
                    {
                        PointF point  = GetPoint(i - 3);
                        PointF point2 = GetPoint(i - 2);
                        if (i + 3 >= myPointsCount)
                        {
                            i = myPointsCount - 1;
                        }
                        PointF point3 = GetPoint(i - 1);
                        PointF point4 = GetPoint(i);
                        if (GoStroke.BezierNearestIntersectionOnLine(point, point2, point3, point4, p1, p2, num, out result2))
                        {
                            float num3 = (result2.X - p1.X) * (result2.X - p1.X) + (result2.Y - p1.Y) * (result2.Y - p1.Y);
                            if (num3 < num2)
                            {
                                num2   = num3;
                                pointF = result2;
                            }
                        }
                    }
                }
                else
                {
                    for (int j = 0; j < PointsCount; j++)
                    {
                        PointF a = GoShape.ExpandPointOnEdge(GetPoint(j), bounds, num);
                        PointF b = GoShape.ExpandPointOnEdge(GetPoint((j + 1 < PointsCount) ? (j + 1) : 0), bounds, num);
                        if (GoStroke.NearestIntersectionOnLine(a, b, p1, p2, out result2))
                        {
                            float num4 = (result2.X - p1.X) * (result2.X - p1.X) + (result2.Y - p1.Y) * (result2.Y - p1.Y);
                            if (num4 < num2)
                            {
                                num2   = num4;
                                pointF = result2;
                            }
                        }
                    }
                }
                result = pointF;
                return(num2 < 1E+21f);
            }
        }
예제 #6
0
        /// <summary>
        /// The port is centered in the <see cref="P:Northwoods.Go.GoBasicNode.Shape" />; the <see cref="P:Northwoods.Go.GoBasicNode.Label" /> is positioned according
        /// to <see cref="P:Northwoods.Go.GoBasicNode.LabelSpot" /> relative to the shape.
        /// </summary>
        /// <param name="childchanged"></param>
        /// <remarks>
        /// When the <see cref="P:Northwoods.Go.GoBasicNode.LabelSpot" /> is <see cref="F:Northwoods.Go.GoObject.Middle" />
        /// and <see cref="P:Northwoods.Go.GoBasicNode.AutoResizes" /> is true,
        /// we automatically resize the shape to be somewhat larger than the label,
        /// and we size the port to be the same size as the shape.
        /// If <see cref="P:Northwoods.Go.GoBasicNode.AutoResizes" /> is false, the <see cref="P:Northwoods.Go.GoBasicNode.Label" /> is
        /// resized to fit within the <see cref="P:Northwoods.Go.GoBasicNode.Shape" />'s bounds minus the margins.
        /// Also the <see cref="P:Northwoods.Go.GoBasicNode.Label" />'s <see cref="T:Northwoods.Go.GoText" />.<see cref="P:Northwoods.Go.GoText.WrappingWidth" />
        /// is set to the same value as the label's width.
        /// When the <see cref="P:Northwoods.Go.GoBasicNode.LabelSpot" /> is not <see cref="F:Northwoods.Go.GoObject.Middle" />,
        /// the label is just positioned relative to the <see cref="P:Northwoods.Go.GoBasicNode.Shape" />
        /// according to the <see cref="P:Northwoods.Go.GoBasicNode.LabelSpot" />.
        /// This method does nothing if there is no <see cref="P:Northwoods.Go.GoBasicNode.Shape" />.
        /// </remarks>
        public override void LayoutChildren(GoObject childchanged)
        {
            if (base.Initializing)
            {
                return;
            }
            GoShape shape = Shape;

            if (shape == null)
            {
                return;
            }
            GoText label = Label;

            if (label != null)
            {
                if (LabelSpot == 1)
                {
                    PointF center            = shape.Center;
                    SizeF  middleLabelMargin = MiddleLabelMargin;
                    if (AutoResizes)
                    {
                        float num  = label.Width + middleLabelMargin.Width;
                        float num2 = label.Height + middleLabelMargin.Height;
                        shape.Bounds = new RectangleF(center.X - num / 2f, center.Y - num2 / 2f, num, num2);
                    }
                    else
                    {
                        float num3 = Math.Max(shape.Width - (middleLabelMargin.Width + middleLabelMargin.Width), 0f);
                        float num4 = Math.Max(shape.Height - (middleLabelMargin.Height + middleLabelMargin.Height), 0f);
                        label.Width         = num3;
                        label.WrappingWidth = num3;
                        label.UpdateSize();
                        float num5 = Math.Min(label.Height, num4);
                        float x    = shape.Left + middleLabelMargin.Width;
                        float y    = shape.Top + middleLabelMargin.Height + (num4 - num5) / 2f;
                        label.Bounds = new RectangleF(x, y, num3, num5);
                    }
                    label.Center = center;
                    if (Port != null)
                    {
                        Port.Bounds = shape.Bounds;
                    }
                }
                else
                {
                    label.SetSpotLocation(SpotOpposite(LabelSpot), shape, LabelSpot);
                }
            }
            if (Port != null)
            {
                Port.SetSpotLocation(1, shape, 1);
            }
        }
예제 #7
0
        /// <summary>
        /// The closest point of a parallelogram that intersects with a given line
        /// is the closest such point of each of its four line segments.
        /// </summary>
        /// <param name="p1"></param>
        /// <param name="p2"></param>
        /// <param name="result"></param>
        /// <returns></returns>
        public override bool GetNearestIntersectionPoint(PointF p1, PointF p2, out PointF result)
        {
            RectangleF bounds = Bounds;
            float      shift  = PenWidth / 2f;

            PointF[] points  = getPoints();
            PointF   pointF  = GoShape.ExpandPointOnEdge(points[0], bounds, shift);
            PointF   pointF2 = GoShape.ExpandPointOnEdge(points[1], bounds, shift);
            PointF   pointF3 = GoShape.ExpandPointOnEdge(points[2], bounds, shift);
            PointF   pointF4 = GoShape.ExpandPointOnEdge(points[3], bounds, shift);
            float    x       = p1.X;
            float    y       = p1.Y;
            float    num     = 1E+21f;
            PointF   pointF5 = default(PointF);

            if (GoStroke.NearestIntersectionOnLine(pointF, pointF2, p1, p2, out PointF result2))
            {
                float num2 = (result2.X - x) * (result2.X - x) + (result2.Y - y) * (result2.Y - y);
                if (num2 < num)
                {
                    num     = num2;
                    pointF5 = result2;
                }
            }
            if (GoStroke.NearestIntersectionOnLine(pointF2, pointF3, p1, p2, out result2))
            {
                float num3 = (result2.X - x) * (result2.X - x) + (result2.Y - y) * (result2.Y - y);
                if (num3 < num)
                {
                    num     = num3;
                    pointF5 = result2;
                }
            }
            if (GoStroke.NearestIntersectionOnLine(pointF3, pointF4, p1, p2, out result2))
            {
                float num4 = (result2.X - x) * (result2.X - x) + (result2.Y - y) * (result2.Y - y);
                if (num4 < num)
                {
                    num     = num4;
                    pointF5 = result2;
                }
            }
            if (GoStroke.NearestIntersectionOnLine(pointF4, pointF, p1, p2, out result2))
            {
                float num5 = (result2.X - x) * (result2.X - x) + (result2.Y - y) * (result2.Y - y);
                if (num5 < num)
                {
                    num     = num5;
                    pointF5 = result2;
                }
            }
            result = pointF5;
            return(num < 1E+21f);
        }
예제 #8
0
        /// <summary>
        /// Draw this handle according to the handle's style.
        /// </summary>
        /// <param name="g"></param>
        /// <param name="view"></param>
        /// <remarks>
        /// Handles never have shadows, but their outlines and fills
        /// can be specified by the <see cref="P:Northwoods.Go.GoShape.Pen" /> and
        /// <see cref="P:Northwoods.Go.GoShape.Brush" /> properties.
        /// Hollow handles (those with a <see cref="P:Northwoods.Go.GoHandle.GoObject" />.<c>NoHandle</c>
        /// <see cref="P:Northwoods.Go.GoHandle.HandleID" />), should have no <see cref="P:Northwoods.Go.GoShape.Brush" />.
        /// </remarks>
        public override void Paint(Graphics g, GoView view)
        {
            RectangleF bounds = Bounds;

            switch (Style)
            {
            case GoHandleStyle.None:
                break;

            default:
                GoShape.DrawRectangle(g, view, Pen, Brush, bounds.X, bounds.Y, bounds.Width, bounds.Height);
                break;

            case GoHandleStyle.Ellipse:
                GoShape.DrawEllipse(g, view, Pen, Brush, bounds.X, bounds.Y, bounds.Width, bounds.Height);
                break;

            case GoHandleStyle.Diamond:
            {
                PointF[] array2 = view.AllocTempPointArray(4);
                array2[0].X = bounds.X + bounds.Width / 2f;
                array2[0].Y = bounds.Y;
                array2[1].X = bounds.X + bounds.Width;
                array2[1].Y = bounds.Y + bounds.Height / 2f;
                array2[2].X = array2[0].X;
                array2[2].Y = bounds.Y + bounds.Height;
                array2[3].X = bounds.X;
                array2[3].Y = array2[1].Y;
                GoShape.DrawPolygon(g, view, Pen, Brush, array2);
                view.FreeTempPointArray(array2);
                break;
            }

            case GoHandleStyle.TriangleTopLeft:
            case GoHandleStyle.TriangleTopRight:
            case GoHandleStyle.TriangleBottomRight:
            case GoHandleStyle.TriangleBottomLeft:
            case GoHandleStyle.TriangleMiddleTop:
            case GoHandleStyle.TriangleMiddleRight:
            case GoHandleStyle.TriangleMiddleBottom:
            case GoHandleStyle.TriangleMiddleLeft:
            {
                PointF[] array = view.AllocTempPointArray(3);
                ComputeTrianglePoints(array);
                GoShape.DrawPolygon(g, view, Pen, Brush, array);
                view.FreeTempPointArray(array);
                break;
            }
            }
        }
예제 #9
0
 /// <summary>
 /// Create a GoBasicNode with just a port and a shape centered behind the port,
 /// but no label.
 /// </summary>
 /// <remarks>
 /// This calls <see cref="M:Northwoods.Go.GoBasicNode.CreatePort" /> and <see cref="M:Northwoods.Go.GoBasicNode.CreateShape(Northwoods.Go.GoPort)" />
 /// to get initial values for <see cref="P:Northwoods.Go.GoBasicNode.Port" /> and <see cref="P:Northwoods.Go.GoBasicNode.Shape" />.
 /// </remarks>
 public GoBasicNode()
 {
     base.InternalFlags |= 16908288;
     myPort              = CreatePort();
     myShape             = CreateShape(myPort);
     Add(myShape);
     Add(myPort);
     if (myPort != null)
     {
         myPort.PortObject = myShape;
     }
     base.PropertiesDelegatedToSelectionObject = true;
     base.Initializing = false;
     LayoutChildren(null);
 }
예제 #10
0
        /// <summary>
        /// Draw a possibly shadowed arc.
        /// </summary>
        /// <param name="g"></param>
        /// <param name="view"></param>
        public override void Paint(Graphics g, GoView view)
        {
            float      startAngle = StartAngle;
            float      sweepAngle = SweepAngle;
            RectangleF bounds     = Bounds;

            if (Shadowed)
            {
                SizeF shadowOffset = GetShadowOffset(view);
                if (Pen != null)
                {
                    Pen shadowPen = GetShadowPen(view, PenWidth);
                    GoShape.DrawArc(g, view, shadowPen, bounds.X + shadowOffset.Width, bounds.Y + shadowOffset.Height, bounds.Width, bounds.Height, startAngle, sweepAngle);
                }
            }
            GoShape.DrawArc(g, view, Pen, bounds.X, bounds.Y, bounds.Width, bounds.Height, startAngle, sweepAngle);
        }
예제 #11
0
        /// <summary>
        /// Draw a plus/minus/zero inside a rectangle.
        /// </summary>
        /// <param name="g"></param>
        /// <param name="view"></param>
        /// <remarks>
        /// If <see cref="P:Northwoods.Go.GoCollapsibleHandle.Bordered" /> is true, this draws a rounded rectangle.
        /// Then it calls <see cref="M:Northwoods.Go.GoCollapsibleHandle.PaintHandle(System.Drawing.Graphics,Northwoods.Go.GoView)" />.
        /// </remarks>
        public override void Paint(Graphics g, GoView view)
        {
            RectangleF bounds = Bounds;
            SizeF      corner = Corner;

            if (Bordered)
            {
                Pen pen = GoShape.NewPen(GoShape.GetPenColor(Pen, Color.Black), 1f);
                GoShape.DrawRoundedRectangle(g, view, pen, Brush, bounds.X, bounds.Y, bounds.Width, bounds.Height, corner.Width, corner.Height);
                pen.Dispose();
            }
            else
            {
                GoShape.DrawRoundedRectangle(g, view, null, Brush, bounds.X, bounds.Y, bounds.Width, bounds.Height, corner.Width, corner.Height);
            }
            PaintHandle(g, view);
        }
예제 #12
0
파일: FlowBlock.cs 프로젝트: lhmson/FlowArt
        public virtual void InitShape(string content, GoShape shape, Color bColor, Color pColor, float topMarginX, float topMarginY, float bottomMarginX, float bottomMarginY)
        {
            bool solidColor = false;

            if (solidColor)
            {
                shape.BrushColor = bColor;
                shape.PenColor   = pColor;
            }
            else
            {
                shape.FillSimpleGradient(bColor, Lighter(bColor), MiddleTop);
                shape.PenColor = Darker(bColor);
            }
            this.TopLeftMargin     = new SizeF(topMarginX, topMarginY);
            this.BottomRightMargin = new SizeF(bottomMarginX, bottomMarginY);
            this.Background        = shape;
            this.Text = content;
        }
예제 #13
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);
 }
예제 #14
0
        public virtual void InitShape(GoShape shape, Color bColor, Color pColor, float tmx, float tmy, float bmx, float bmy)
        {
            bool solidColor = false;

            if (solidColor)
            {
                shape.BrushColor = bColor;
                shape.PenColor   = pColor;
            }
            else
            {
                shape.FillSimpleGradient(bColor, Lighter(bColor), GoObject.MiddleTop);//MiddleTop = 32
                shape.PenColor = Darker(bColor);
            }
            GraphNode.TopLeftMargin     = new SizeF(tmx, tmy);
            GraphNode.BottomRightMargin = new SizeF(bmx, bmy);
            GraphNode.Background        = shape;
            GraphNode.Text = GraphNode.Kind;
        }
예제 #15
0
        /// <summary>
        /// If any part is removed from this group,
        /// be sure to remove any references in local fields.
        /// </summary>
        /// <param name="obj"></param>
        public override bool Remove(GoObject obj)
        {
            bool result = base.Remove(obj);

            if (obj == myShape)
            {
                myShape = null;
                return(result);
            }
            if (obj == myLabel)
            {
                myLabel = null;
                return(result);
            }
            if (obj == myPort)
            {
                myPort = null;
            }
            return(result);
        }
예제 #16
0
        static void Main(string[] args)
        {
            boardShape = new GoShape(9);
            game       = new Go(boardShape);
            int mostRecent = AdaptiveGameAI.Program.GetMostRecent();

            AI = new Player(game, GameBase.Color.Black, AdaptiveGameAI.Program.savePath + mostRecent + ".dat");

            Tests();

            while (!game.Ended())
            {
                GoPosition p = (GoPosition)AI.Play();
                Console.WriteLine(AdaptiveGameAI.Program.Output(GameBase.Color.Black, p, game, true));
                if (!game.Ended())
                {
                    p = HumanPlay();
                    Console.WriteLine(AdaptiveGameAI.Program.Output(GameBase.Color.White, p, game, true));
                }
            }
        }
예제 #17
0
        /// <summary>
        /// Draw a possibly shadowed ellipse.
        /// </summary>
        /// <param name="g"></param>
        /// <param name="view"></param>
        public override void Paint(Graphics g, GoView view)
        {
            Brush      brush  = Brush;
            RectangleF bounds = Bounds;

            if (Shadowed)
            {
                SizeF shadowOffset = GetShadowOffset(view);
                if (brush != null)
                {
                    Brush shadowBrush = GetShadowBrush(view);
                    GoShape.DrawEllipse(g, view, null, shadowBrush, bounds.X + shadowOffset.Width, bounds.Y + shadowOffset.Height, bounds.Width, bounds.Height);
                }
                else if (Pen != null)
                {
                    Pen shadowPen = GetShadowPen(view, PenWidth);
                    GoShape.DrawEllipse(g, view, shadowPen, null, bounds.X + shadowOffset.Width, bounds.Y + shadowOffset.Height, bounds.Width, bounds.Height);
                }
            }
            GoShape.DrawEllipse(g, view, Pen, brush, bounds.X, bounds.Y, bounds.Width, bounds.Height);
        }
예제 #18
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);
        }
예제 #19
0
 /// <summary>
 /// Create a GoBasicNode with a port and a label and a <see cref="T:Northwoods.Go.GoDrawing" /> shape,
 /// initialized to have the figure <paramref name="fig" /> and a Middle <see cref="P:Northwoods.Go.GoBasicNode.LabelSpot" />.
 /// </summary>
 /// <param name="fig">a <see cref="T:Northwoods.Go.GoFigure" /> enumeration value</param>
 /// <remarks>
 /// This constructor basically does the following, but more efficiently:
 /// <pre><code>
 /// GoBasicNode n = new GoBasicNode();
 /// n.LabelSpot = GoObject.Middle;
 /// n.Text = "";
 /// n.Shape = new GoDrawing(fig);
 /// </code></pre>
 /// </remarks>
 public GoBasicNode(GoFigure fig)
 {
     base.InternalFlags |= 16908288;
     myLabelSpot         = 1;
     myShape             = new GoDrawing(fig);
     myShape.Selectable  = false;
     myShape.Resizable   = false;
     myShape.Reshapable  = false;
     myShape.Brush       = GoShape.Brushes_White;
     myPort              = CreatePort();
     myPort.Style        = GoPortStyle.None;
     myLabel             = CreateLabel("");
     Add(myShape);
     Add(myPort);
     Add(myLabel);
     if (myPort != null)
     {
         myPort.PortObject = myShape;
     }
     base.PropertiesDelegatedToSelectionObject = true;
     base.Initializing = false;
     LayoutChildren(null);
 }
예제 #20
0
        /// <summary>
        /// Make sure the Control in the view exists and is positioned and sized correctly.
        /// </summary>
        /// <param name="g"></param>
        /// <param name="view"></param>
        /// <remarks>
        /// This ignores the <see cref="P:Northwoods.Go.GoObject.Shadowed" /> property.
        /// Controls are not created for <see cref="T:Northwoods.Go.GoOverview" /> views--instead
        /// they are drawn as light gray rectangles.
        /// </remarks>
        public override void Paint(Graphics g, GoView view)
        {
            if (view is GoOverview)
            {
                RectangleF bounds = Bounds;
                GoShape.DrawRectangle(g, view, GoShape.Pens_Black, GoShape.Brushes_LightGray, bounds.X, bounds.Y, bounds.Width, bounds.Height);
                return;
            }
            Control control = GetControl(view);

            if (control != null)
            {
                RectangleF bounds2 = Bounds;
                Rectangle  bounds3 = view.ConvertDocToView(bounds2);
                if (!(control is GoText.ComboBoxControl))
                {
                    control.Bounds = bounds3;
                }
                if (!control.Visible)
                {
                    control.Visible = true;
                }
            }
        }
예제 #21
0
 public override void Paint(Graphics g, GoView view)
 {
     GoShape.DrawPath(g, view, Pen, Brush, GetPath());
 }
예제 #22
0
파일: TextNode.cs 프로젝트: Tubbz-alt/WvsGo
        public void GenerateShortInfo(object value)
        {
            GoShape shape = this.Background as GoShape;

            if (value is string)
            {
                string obj = (string)value;

                Text            = obj;
                Label.Multiline = false;
                Label.Bold      = true;
                if (shape != null)
                {
                    shape.FillHalfGradient(myNwoodsNamespaceColor);
                }
            }
            else if (value is Scan)
            {
                var obj = (Scan)value;
                Text            = $"{obj.StartURL}{Environment.NewLine}[{obj.WebServer}  {obj.Banner}  {obj.Technologies}]";
                Label.Multiline = true;
                Label.Bold      = true;
                if (shape != null)
                {
                    shape.FillHalfGradient(myClassPenColor);
                }
            }
            else if (value is SiteFile)
            {
                var obj = (SiteFile)value;
                Text            = $"[{obj.Name}]    {obj.URL}";
                Label.Multiline = false;
                Label.Bold      = false;
                if (shape != null)
                {
                    shape.BrushColor = Color.DarkGray;
                }
            }
            else if (value is ReportItem)
            {
                var obj = (ReportItem)value;
                if (obj.CVEList.Count > 0)
                {
                    Text = $"漏洞位置:[{obj.Affects}] 漏洞名称:{obj.Name}{Environment.NewLine}[{obj.Severity}] [{obj.Type}] CVE:{obj.CVEList[0].Id}";
                }
                else
                {
                    Text = $"[{obj.Severity}] [{obj.Type}] {obj.Name}";
                }

                Label.Multiline = true;
                if (shape != null)
                {
                    switch (obj.Severity)
                    {
                    case "high":
                        shape.BrushColor = Color.Red;
                        break;

                    case "medium":
                        shape.BrushColor = Color.Yellow;
                        break;

                    case "low":
                        shape.BrushColor = Color.Blue;
                        break;

                    case "info":
                        shape.BrushColor = Color.Green;
                        break;
                    }
                }
            }
        }
예제 #23
0
        /// <summary>
        /// The appearance of this handle depends on the <see cref="P:Northwoods.Go.IGoCollapsible.Collapsible" />
        /// and <see cref="P:Northwoods.Go.IGoCollapsible.IsExpanded" /> properties.
        /// </summary>
        /// <param name="g"></param>
        /// <param name="view"></param>
        /// <remarks>
        /// If the parent is not <see cref="P:Northwoods.Go.IGoCollapsible.Collapsible" />,
        /// this draws a circle inside the rectangle.
        /// Otherwise, the appearance depends on the value of <see cref="P:Northwoods.Go.GoCollapsibleHandle.Style" />.
        /// </remarks>
        protected virtual void PaintHandle(Graphics g, GoView view)
        {
            IGoCollapsible goCollapsible = FindCollapsible();

            if (goCollapsible == null)
            {
                return;
            }
            RectangleF bounds = Bounds;

            if (goCollapsible.Collapsible)
            {
                float num  = bounds.X + bounds.Width / 2f;
                float num2 = bounds.Y + bounds.Height / 2f;
                switch (Style)
                {
                case GoCollapsibleHandleStyle.PlusMinus:
                {
                    float num9  = Bordered ? (bounds.Width / 4f) : 0f;
                    float num10 = Bordered ? (bounds.Height / 4f) : 0f;
                    GoShape.DrawLine(g, view, Pen, bounds.X + num9, num2, bounds.X + bounds.Width - num9, num2);
                    if (!goCollapsible.IsExpanded)
                    {
                        GoShape.DrawLine(g, view, Pen, num, bounds.Y + num10, num, bounds.Y + bounds.Height - num10);
                    }
                    break;
                }

                case GoCollapsibleHandleStyle.TriangleRight:
                {
                    float    num7   = Bordered ? (bounds.Width / 6f) : 0f;
                    float    num8   = Bordered ? (bounds.Height / 6f) : 0f;
                    PointF[] array3 = view.AllocTempPointArray(3);
                    if (goCollapsible.IsExpanded)
                    {
                        array3[0].X = bounds.X + num7;
                        array3[0].Y = bounds.Y + num8;
                        array3[1].X = bounds.X + bounds.Width - num7;
                        array3[1].Y = num2;
                        array3[2].X = bounds.X + num7;
                        array3[2].Y = bounds.Y + bounds.Height - num8;
                    }
                    else
                    {
                        array3[0].X = bounds.X + num7;
                        array3[0].Y = bounds.Y + num8;
                        array3[1].X = bounds.X + bounds.Width - num7;
                        array3[1].Y = bounds.Y + num8;
                        array3[2].X = num;
                        array3[2].Y = bounds.Y + bounds.Height - num8;
                    }
                    SolidBrush solidBrush2 = new SolidBrush(GoShape.GetPenColor(Pen, Color.Black));
                    GoShape.DrawPolygon(g, view, null, solidBrush2, array3);
                    solidBrush2.Dispose();
                    view.FreeTempPointArray(array3);
                    break;
                }

                case GoCollapsibleHandleStyle.TriangleUp:
                {
                    float    num5   = Bordered ? (bounds.Width / 6f) : 0f;
                    float    num6   = Bordered ? (bounds.Height / 6f) : 0f;
                    PointF[] array2 = view.AllocTempPointArray(3);
                    if (goCollapsible.IsExpanded)
                    {
                        array2[0].X = bounds.X + num5;
                        array2[0].Y = bounds.Y + bounds.Height - num6;
                        array2[1].X = bounds.X + bounds.Width - num5;
                        array2[1].Y = bounds.Y + bounds.Height - num6;
                        array2[2].X = num;
                        array2[2].Y = bounds.Y + num6;
                    }
                    else
                    {
                        array2[0].X = bounds.X + num5;
                        array2[0].Y = bounds.Y + num6;
                        array2[1].X = bounds.X + bounds.Width - num5;
                        array2[1].Y = bounds.Y + num6;
                        array2[2].X = num;
                        array2[2].Y = bounds.Y + bounds.Height - num6;
                    }
                    SolidBrush solidBrush = new SolidBrush(GoShape.GetPenColor(Pen, Color.Black));
                    GoShape.DrawPolygon(g, view, null, solidBrush, array2);
                    solidBrush.Dispose();
                    view.FreeTempPointArray(array2);
                    break;
                }

                case GoCollapsibleHandleStyle.ChevronUp:
                {
                    float    num3  = Bordered ? (bounds.Width / 6f) : 0f;
                    float    num4  = Bordered ? (bounds.Height / 6f) : 0f;
                    PointF[] array = view.AllocTempPointArray(3);
                    if (goCollapsible.IsExpanded)
                    {
                        array[0].X = bounds.X + num3;
                        array[0].Y = num2;
                        array[1].X = num;
                        array[1].Y = bounds.Y + num4;
                        array[2].X = bounds.X + bounds.Width - num3;
                        array[2].Y = num2;
                        GoShape.DrawLines(g, view, Pen, array);
                        array[0].X = bounds.X + num3;
                        array[0].Y = bounds.Y + bounds.Height - num4;
                        array[1].X = num;
                        array[1].Y = num2;
                        array[2].X = bounds.X + bounds.Width - num3;
                        array[2].Y = bounds.Y + bounds.Height - num4;
                        GoShape.DrawLines(g, view, Pen, array);
                    }
                    else
                    {
                        array[0].X = bounds.X + num3;
                        array[0].Y = bounds.Y + num4;
                        array[1].X = num;
                        array[1].Y = num2;
                        array[2].X = bounds.X + bounds.Width - num3;
                        array[2].Y = bounds.Y + num4;
                        GoShape.DrawLines(g, view, Pen, array);
                        array[0].X = bounds.X + num3;
                        array[0].Y = num2;
                        array[1].X = num;
                        array[1].Y = bounds.Y + bounds.Height - num4;
                        array[2].X = bounds.X + bounds.Width - num3;
                        array[2].Y = num2;
                        GoShape.DrawLines(g, view, Pen, array);
                    }
                    view.FreeTempPointArray(array);
                    break;
                }
                }
            }
            else
            {
                GoShape.DrawEllipse(g, view, Pen, null, bounds.X + bounds.Width / 4f, bounds.Y + bounds.Height / 4f, bounds.Width / 2f, bounds.Height / 2f);
            }
        }
예제 #24
0
        /// <summary>
        /// This method is called by <see cref="M:Northwoods.Go.GoButton.Paint(System.Drawing.Graphics,Northwoods.Go.GoView)" /> to display any button state,
        /// such as whether it is "pressed".
        /// </summary>
        /// <param name="g"></param>
        /// <param name="view"></param>
        protected virtual void PaintButton(Graphics g, GoView view)
        {
            RectangleF bounds = Bounds;
            Pen        pen;
            Pen        pen2;
            Pen        pen3;
            Pen        pen4;

            if (ActionActivated)
            {
                pen  = GoShape.SystemPens_ControlDarkDark;
                pen2 = GoShape.SystemPens_ControlLightLight;
                pen3 = GoShape.SystemPens_ControlDark;
                pen4 = GoShape.SystemPens_Control;
            }
            else
            {
                pen  = GoShape.SystemPens_ControlLightLight;
                pen2 = GoShape.SystemPens_ControlDarkDark;
                pen3 = GoShape.SystemPens_Control;
                pen4 = GoShape.SystemPens_ControlDark;
            }
            PointF[] array = view.AllocTempPointArray(3);
            float    num   = 0.5f;
            float    num2  = 0.5f;

            if (base.Document != null)
            {
                num  /= base.Document.WorldScale.Width;
                num2 /= base.Document.WorldScale.Height;
            }
            PointF pointF  = new PointF(bounds.X + num, bounds.Y + num2);
            PointF pointF2 = new PointF(bounds.X + bounds.Width - num, bounds.Y + num2);
            PointF pointF3 = new PointF(bounds.X + num, bounds.Y + bounds.Height - num2);
            PointF pointF4 = new PointF(bounds.X + bounds.Width - num, bounds.Y + bounds.Height - num2);

            array[0] = pointF2;
            array[1] = pointF;
            array[2] = pointF3;
            GoShape.DrawLines(g, view, pen3, array);
            array[0].Y -= num2;
            array[1]    = pointF4;
            array[2].X -= num;
            GoShape.DrawLines(g, view, pen4, array);
            pointF.X  -= num * 2f;
            pointF.Y  -= num2 * 2f;
            pointF2.X += num * 2f;
            pointF2.Y -= num2 * 2f;
            pointF4.X += num * 2f;
            pointF4.Y += num2 * 2f;
            pointF3.X -= num * 2f;
            pointF3.Y += num2 * 2f;
            array[0]   = pointF2;
            array[1]   = pointF;
            array[2]   = pointF3;
            GoShape.DrawLines(g, view, pen, array);
            array[0].Y -= num2;
            array[1]    = pointF4;
            array[2].X -= num;
            GoShape.DrawLines(g, view, pen2, array);
            view.FreeTempPointArray(array);
        }
예제 #25
0
        /// <summary>
        /// The closest point of a cylinder that intersects with a given line
        /// is the closest such point of each two line segments and two ellipses.
        /// </summary>
        /// <param name="p1"></param>
        /// <param name="p2"></param>
        /// <param name="result"></param>
        /// <returns></returns>
        public override bool GetNearestIntersectionPoint(PointF p1, PointF p2, out PointF result)
        {
            RectangleF bounds = Bounds;
            float      shift  = PenWidth / 2f;

            PointF[]   points = getPoints();
            PointF     a      = GoShape.ExpandPointOnEdge(points[0], bounds, shift);
            PointF     b      = GoShape.ExpandPointOnEdge(points[1], bounds, shift);
            PointF     a2     = GoShape.ExpandPointOnEdge(points[2], bounds, shift);
            PointF     b2     = GoShape.ExpandPointOnEdge(points[3], bounds, shift);
            float      num    = 1E+21f;
            PointF     pointF = default(PointF);
            RectangleF rect;
            RectangleF rect2;
            float      startAngle;
            float      startAngle2;

            if (Orientation == Orientation.Vertical)
            {
                rect        = new RectangleF(bounds.X, bounds.Y, bounds.Width, MinorRadius * 2f);
                rect2       = new RectangleF(bounds.X, bounds.Y + bounds.Height - MinorRadius * 2f, bounds.Width, MinorRadius * 2f);
                startAngle  = 180f;
                startAngle2 = 0f;
            }
            else
            {
                rect        = new RectangleF(bounds.X, bounds.Y, MinorRadius * 2f, bounds.Height);
                rect2       = new RectangleF(bounds.X + bounds.Width - MinorRadius * 2f, bounds.Y, MinorRadius * 2f, bounds.Height);
                startAngle  = 90f;
                startAngle2 = 270f;
            }
            if (GoEllipse.NearestIntersectionOnArc(rect, p1, p2, out PointF result2, startAngle, 180f))
            {
                float num2 = (result2.X - p1.X) * (result2.X - p1.X) + (result2.Y - p1.Y) * (result2.Y - p1.Y);
                if (num2 < num)
                {
                    num    = num2;
                    pointF = result2;
                }
            }
            if (Orientation == Orientation.Horizontal)
            {
                if (GoEllipse.NearestIntersectionOnArc(rect2, p1, p2, out result2, 270f, 90f))
                {
                    float num3 = (result2.X - p1.X) * (result2.X - p1.X) + (result2.Y - p1.Y) * (result2.Y - p1.Y);
                    if (num3 < num)
                    {
                        num    = num3;
                        pointF = result2;
                    }
                }
                if (GoEllipse.NearestIntersectionOnArc(rect2, p1, p2, out result2, 0f, 90f))
                {
                    float num4 = (result2.X - p1.X) * (result2.X - p1.X) + (result2.Y - p1.Y) * (result2.Y - p1.Y);
                    if (num4 < num)
                    {
                        num    = num4;
                        pointF = result2;
                    }
                }
            }
            else if (GoEllipse.NearestIntersectionOnArc(rect2, p1, p2, out result2, startAngle2, 180f))
            {
                float num5 = (result2.X - p1.X) * (result2.X - p1.X) + (result2.Y - p1.Y) * (result2.Y - p1.Y);
                if (num5 < num)
                {
                    num    = num5;
                    pointF = result2;
                }
            }
            if (GoStroke.NearestIntersectionOnLine(a, b, p1, p2, out result2))
            {
                float num6 = (result2.X - p1.X) * (result2.X - p1.X) + (result2.Y - p1.Y) * (result2.Y - p1.Y);
                if (num6 < num)
                {
                    num    = num6;
                    pointF = result2;
                }
            }
            if (GoStroke.NearestIntersectionOnLine(a2, b2, p1, p2, out result2))
            {
                float num7 = (result2.X - p1.X) * (result2.X - p1.X) + (result2.Y - p1.Y) * (result2.Y - p1.Y);
                if (num7 < num)
                {
                    num    = num7;
                    pointF = result2;
                }
            }
            result = pointF;
            return(num < 1E+21f);
        }
예제 #26
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);
        }
예제 #27
0
파일: TextNode.cs 프로젝트: Tubbz-alt/WvsGo
        public void GenerateLongInfo(object value)
        {
            GoShape shape = this.Background as GoShape;

            if (value is string)
            {
                string obj = (string)value;

                Text            = obj;
                Label.Multiline = false;
                Label.Bold      = true;
                if (shape != null)
                {
                    shape.FillHalfGradient(myNwoodsNamespaceColor);
                }
            }
            else if (value is Scan)
            {
                var obj = (Scan)value;

                Text            = $"目标URL:{obj.StartURL}{Environment.NewLine} OS:{obj.Os} WebServer:{obj.WebServer} Banner:{obj.Banner} Technologies:{obj.Technologies}]{Environment.NewLine}";
                Label.Multiline = true;
                Label.Bold      = true;
                if (shape != null)
                {
                    shape.FillHalfGradient(myClassPenColor);
                }
            }
            else if (value is SiteFile)
            {
                var obj = (SiteFile)value;
                Text            = $"[{obj.Name}]   {obj.URL}";
                Label.Multiline = false;
                Label.Bold      = false;
                if (shape != null)
                {
                    shape.FillHalfGradient(mySystemNamespaceBrushColor);
                }
            }
            else if (value is ReportItem)
            {
                var obj = (ReportItem)value;
                if (obj.CVEList.Count > 0)
                {
                    Text = $"漏洞位置:[{obj.Affects}] 漏洞名称:{obj.Name}{Environment.NewLine}[{obj.Severity}] [{obj.Type}] CVE:{obj.CVEList[0].Id}{Environment.NewLine} 请求:{obj.TechnicalDetails.Request}{Environment.NewLine}应答:{obj.TechnicalDetails.Response}";
                }
                else
                {
                    Text = $"[{obj.Severity}] [{obj.Type}] {obj.Name}{Environment.NewLine} 请求:{obj.TechnicalDetails.Request}{Environment.NewLine}应答:{obj.TechnicalDetails.Response}";
                }

                Label.Multiline = true;
                if (shape != null)
                {
                    switch (obj.Severity)
                    {
                    case "high":
                        shape.FillHalfGradient(Color.Red);
                        break;

                    case "medium":
                        shape.FillHalfGradient(Color.Yellow);
                        break;

                    case "low":
                        shape.FillHalfGradient(Color.Blue);
                        break;

                    case "info":
                        shape.FillHalfGradient(Color.Green);
                        break;
                    }
                }
            }
        }