Ejemplo n.º 1
0
        /// <summary>
        /// </summary>
        /// <exception cref="ArgumentNullException"><para><paramref name="paintParams"/> is <see langword="null"/>.</para></exception>
        public void DrawShadow(NuGenPaintParams paintParams)
        {
            if (paintParams == null)
            {
                throw new ArgumentNullException("paintParams");
            }

            Graphics  g      = paintParams.Graphics;
            Rectangle bounds = paintParams.Bounds;

            int     alpha          = 0;
            Color   baseColor      = Color.Black;
            int     alphaStep      = 5;
            Padding deflatePadding = new Padding(1);

            using (NuGenGrfxMode mode = new NuGenGrfxMode(g))
            {
                NuGenControlPaint.SetGraphicsVeryHighQuality(g);

                using (Pen pen = new Pen(Color.FromArgb(alpha, baseColor)))
                {
                    for (int i = 0; i <= _shadowStepCount; i++)
                    {
                        NuGenControlPaint.DrawRoundRectangle(g, pen, bounds, _shadowRadius);
                        pen.Color = Color.FromArgb(alpha += alphaStep, baseColor);
                        bounds    = NuGenControlPaint.DeflateRectangle(bounds, deflatePadding);

                        if (i == 1)
                        {
                            alphaStep = 10;
                        }
                    }
                }
            }
        }
        /*
         * DrawShadow
         */

        /// <summary>
        /// </summary>
        /// <param name="paintParams"></param>
        /// <exception cref="ArgumentNullException">
        /// <para>
        ///		<paramref name="paintParams"/> is <see langword="null"/>.
        /// </para>
        /// </exception>
        public void DrawShadow(NuGenPaintParams paintParams)
        {
            if (paintParams == null)
            {
                throw new ArgumentNullException("paintParams");
            }

            Graphics  g      = paintParams.Graphics;
            Rectangle bounds = paintParams.Bounds;

            using (NuGenGrfxMode mode = new NuGenGrfxMode(g))
            {
                g.SmoothingMode   = SmoothingMode.AntiAlias;
                g.PixelOffsetMode = PixelOffsetMode.HighQuality;

                for (int i = 0; i < _shadowColorsCount; i++)
                {
                    using (Pen pen = new Pen(_shadowColors[i]))
                    {
                        NuGenControlPaint.DrawRoundRectangle(g, pen, bounds, _shadowColorsCount - i);
                    }

                    bounds.Inflate(-1, -1);
                }
            }
        }
Ejemplo n.º 3
0
 private void DrawNodeOutline(Graphics g, Pen pen, Rectangle nodeRect, Single roundRadius)
 {
     if (roundRadius > 0)
     {
         NuGenControlPaint.DrawRoundRectangle(g, pen, nodeRect, roundRadius);
     }
     else
     {
         g.DrawRectangle(pen, nodeRect);
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// </summary>
        /// <exception cref="ArgumentNullException">
        ///	<para>
        ///		<paramref name="g"/> is <see langword="null"/>.
        /// </para>
        /// </exception>
        public void DrawRoundBorder(Graphics g, Rectangle bounds, NuGenControlState state, NuGenRoundRectangleStyle style)
        {
            if (g == null)
            {
                throw new ArgumentNullException("g");
            }

            using (Pen pen = this.GetBorderPen(state))
            {
                NuGenControlPaint.DrawRoundRectangle(g, pen, bounds, _roundRectangleRadius, style);
            }
        }
Ejemplo n.º 5
0
        private void _pictureBox_Paint(Object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            if (_selectedProgram != null)
            {
                if (_selectedProgram.Nodes.Count > 0)
                {
                    g.SmoothingMode   = SmoothingMode.HighQuality;
                    g.PixelOffsetMode = PixelOffsetMode.HighQuality;
                    g.ScaleTransform(_scale, _scale);

                    // Draw connections
                    for (Int32 i = 0; i < _selectedProgram.Nodes.Count; i++)
                    {
                        NodeBase node = _selectedProgram.Nodes[i];
                        node.DrawConnections(g, Color.White, _selectedPort);
                    }

                    // Draw nodes
                    for (Int32 i = 0; i < _selectedProgram.Nodes.Count; i++)
                    {
                        NodeBase node = _selectedProgram.Nodes[i];
                        node.DrawNode(g, _roundRadius, Object.ReferenceEquals(node, _selectedNode));

                        // Draw _selectedPort/Input.
                        for (Int32 j = 0; j < node.InputsLength; j++)
                        {
                            if (node.GetInput(j) == _selectedPort)
                            {
                                NuGenControlPaint.DrawRoundRectangle(g, Pens.White, node.InputRectCollection[j], 3);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 6
0
        public override void DrawNode(Graphics g, Single roundRadius, System.Boolean selected)
        {
            Int32 x      = ClientRectangle.X;
            Int32 y      = ClientRectangle.Y;
            Int32 width  = ClientRectangle.Width;
            Int32 height = ClientRectangle.Height;

            Rectangle[] rectArray = new Rectangle[3]
            {
                new Rectangle(x + 1, y + 1, width, height)
                , new Rectangle(x + 2, y + 2, width, height)
                , new Rectangle(x + 3, y + 3, width, height)
            };

            foreach (Rectangle rect in rectArray)
            {
                if (roundRadius > 0)
                {
                    NuGenControlPaint.FillRoundRectangle(g, _nodeBrush, rect, roundRadius);
                }
                else
                {
                    g.FillRectangle(_nodeBrush, rect);
                }
            }

            /* Header */

            using (LinearGradientBrush lgb = new LinearGradientBrush(HeaderRectangle, HeaderBackColor, Color.White, LinearGradientMode.Horizontal))
            {
                if (roundRadius > 0)
                {
                    NuGenControlPaint.FillRoundRectangle(g, lgb, HeaderRectangle, roundRadius, NuGenRoundRectangleStyle.TopRound);
                }
                else
                {
                    g.FillRectangle(lgb, HeaderRectangle);
                }
            }

            using (SolidBrush sb = new SolidBrush(HeaderForeColor))
            {
                g.DrawString(Header, HeaderFont, sb, HeaderRectangle.X + 2, HeaderRectangle.Y + 2);
            }

            /* Body */

            using (LinearGradientBrush lgb = new LinearGradientBrush(BodyRectangle, BodyBackColor, Color.White, LinearGradientMode.Vertical))
            {
                if (roundRadius > 0)
                {
                    NuGenControlPaint.FillRoundRectangle(g, lgb, BodyRectangle, roundRadius, NuGenRoundRectangleStyle.BottomRound);
                }
                else
                {
                    g.FillRectangle(lgb, BodyRectangle);
                }
            }

            /* Inputs and Outputs */

            using (SolidBrush sb = new SolidBrush(BodyForeColor))
            {
                for (Int32 i = 0; i < OutputsLength; i++)
                {
                    Rectangle currentRect = OutputRectCollection[i];
                    g.DrawString("<", BodyFont, sb, currentRect.X, currentRect.Y);
                }

                for (Int32 i = 0; i < InputsLength; i++)
                {
                    Rectangle currentRect = InputRectCollection[i];
                    g.DrawString(">", BodyFont, sb, currentRect.X, currentRect.Y);
                }
            }

            /* Result */

            Object result = GetData();

            if (result != null)
            {
                using (SolidBrush sb = new SolidBrush(BodyForeColor))
                {
                    Int32 resultX = BodyRectangle.X + BodyRectangle.Width / 2;
                    Int32 resultY = InputRectCollection[0].Y;

                    using (StringFormat sf = new StringFormat())
                    {
                        sf.Alignment = StringAlignment.Center;
                        switch (DisplayFormat)
                        {
                        case ValueDisplayFormat.CultureSpecific:
                        {
                            g.DrawString(ResultCultureSpecific, BodyFont, sb, resultX, resultY, sf);
                            break;
                        }

                        case ValueDisplayFormat.FixedPoint:
                        {
                            g.DrawString(ResultFixedPoint, BodyFont, sb, resultX, resultY, sf);
                            break;
                        }

                        case ValueDisplayFormat.Scientific:
                        {
                            g.DrawString(ResultScientific, BodyFont, sb, resultX, resultY, sf);
                            break;
                        }

                        default:
                        {
                            g.DrawString(Result, BodyFont, sb, resultX, resultY, sf);
                            break;
                        }
                        }
                    }
                }
            }

            /* Outline */

            if (selected)
            {
                using (Pen pen = new Pen(OutlineColor, 2))
                {
                    if (roundRadius > 0)
                    {
                        NuGenControlPaint.DrawRoundRectangle(g, pen, ClientRectangle, roundRadius);
                    }
                    else
                    {
                        g.DrawRectangle(pen, ClientRectangle);
                    }
                }
            }
            else
            {
                using (Pen pen = new Pen(OutlineColor, 1))
                {
                    if (roundRadius > 0)
                    {
                        NuGenControlPaint.DrawRoundRectangle(g, pen, ClientRectangle, roundRadius);
                    }
                    else
                    {
                        g.DrawRectangle(pen, ClientRectangle);
                    }
                }
            }
        }