Ejemplo n.º 1
0
        /// <summary>
        /// Renders a label to the map.
        /// </summary>
        /// <param name="g">Graphics reference</param>
        /// <param name="LabelPoint">Label placement</param>
        /// <param name="Offset">Offset of label in screen coordinates</param>
        /// <param name="font">Font used for rendering</param>
        /// <param name="forecolor">Font forecolor</param>
        /// <param name="backcolor">Background color</param>
        /// <param name="halo">Color of halo</param>
        /// <param name="rotation">Text rotation in degrees</param>
        /// <param name="text">Text to render</param>
        /// <param name="map">Map reference</param>
        public static void DrawLabel(System.Drawing.Graphics g, System.Drawing.PointF LabelPoint, System.Drawing.PointF Offset, System.Drawing.Font font, System.Drawing.Color forecolor, System.Drawing.Brush backcolor, System.Drawing.Pen halo, float rotation, string text, SharpMap.Map map)
        {
            System.Drawing.SizeF fontSize = g.MeasureString(text, font); //Calculate the size of the text
            LabelPoint.X += Offset.X; LabelPoint.Y += Offset.Y; //add label offset
            if (rotation != 0 && rotation != float.NaN)
            {
                g.TranslateTransform(LabelPoint.X, LabelPoint.Y);
                g.RotateTransform(rotation);
                g.TranslateTransform(-fontSize.Width / 2, -fontSize.Height / 2);
                if (backcolor != null && backcolor != System.Drawing.Brushes.Transparent)
                    g.FillRectangle(backcolor, 0, 0, fontSize.Width * 0.74f + 1f, fontSize.Height * 0.74f);
                System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
                path.AddString(text, font.FontFamily, (int)font.Style, font.Size, new System.Drawing.Point(0, 0), null);
                if (halo != null)
                    g.DrawPath(halo, path);
                g.FillPath(new System.Drawing.SolidBrush(forecolor), path);
                //g.DrawString(text, font, new System.Drawing.SolidBrush(forecolor), 0, 0);
                g.Transform = map.MapTransform;
            }
            else
            {
                if (backcolor != null && backcolor != System.Drawing.Brushes.Transparent)
                    g.FillRectangle(backcolor, LabelPoint.X, LabelPoint.Y, fontSize.Width * 0.74f + 1, fontSize.Height * 0.74f);

                System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();

                path.AddString(text, font.FontFamily, (int)font.Style, font.Size, LabelPoint, null);
                if (halo != null)
                    g.DrawPath(halo, path);
                g.FillPath(new System.Drawing.SolidBrush(forecolor), path);
                //g.DrawString(text, font, new System.Drawing.SolidBrush(forecolor), LabelPoint.X, LabelPoint.Y);
            }
        }
Ejemplo n.º 2
0
        public override bool DrawString(
            System.Drawing.Graphics graphics,
            System.Drawing.FontFamily fontFamily,
            System.Drawing.FontStyle fontStyle,
            int fontSize,
            string strText,
            System.Drawing.Point ptDraw,
            System.Drawing.StringFormat strFormat)
        {
            using (GraphicsPath path = new GraphicsPath())
            {
                path.AddString(strText, fontFamily, (int)fontStyle, fontSize, ptDraw, strFormat);

                for (int i = 1; i <= m_nThickness; ++i)
                {
                    using (Pen pen = new Pen(m_clrOutline, i))
                    {
                        pen.LineJoin = LineJoin.Round;
                        graphics.DrawPath(pen, path);
                    }
                }

                if (m_bClrText)
                {
                    using (SolidBrush brush = new SolidBrush(m_clrText))
                    {
                        graphics.FillPath(brush, path);
                    }
                }
                else
                    graphics.FillPath(m_brushText, path);
            }
            return true;
        }
Ejemplo n.º 3
0
 private void RenderBorder(System.Drawing.Graphics g, Rectangle bounds)
 {
     if (RoundStyle == RoundStyle.None)
     {
         ControlPaint.DrawBorder(
             g,
             bounds,
             ColorTable.Border,
             ButtonBorderStyle.Solid);
     }
     else
     {
         using (SmoothingModeGraphics sg = new SmoothingModeGraphics(g))
         {
             using (GraphicsPath path = GraphicsPathHelper.CreatePath(
                 bounds, Radius, RoundStyle, true))
             {
                 using (Pen pen = new Pen(ColorTable.Border))
                 {
                     g.DrawPath(pen, path);
                 }
             }
         }
     }
 }
        public override void Draw(System.Drawing.Graphics gc, Render.RenderParameter r, Render.RenderHint editState, Render.IDrawVisitor drawMethods, PointD mousePosition)
        {
            if (m_Param.Path != null)
            {
                /*if (editState.GetAttributes() == States.StateAttributes.Start)
                {
                    if (r.StrokeFill != null)
                        gc.FillPath(r.StrokeFill, (Tools.Model.VectorPath) m_Param.Path);
                    gc.DrawPath(r.StrokeOutline, (Tools.Model.VectorPath)m_Param.Path);
                }
                else*/ if (editState == Render.RenderHint.Start)
                {
                    Pen dashPen = (Pen)r.StrokeOutline.Clone();
                    dashPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
                    if (m_Param.Path.PointCount > 0)
                    {
                        PointD firstPoint = (PointD)m_Param.Path.GetFirstPoint();
                        gc.DrawEllipse(dashPen, (float)firstPoint.X - Tools.Render.DrawHelper.TARGET_SIZE / 2.0f, (float)firstPoint.Y - Tools.Render.DrawHelper.TARGET_SIZE / 2.0f, (float)Tools.Render.DrawHelper.TARGET_SIZE, (float)Tools.Render.DrawHelper.TARGET_SIZE);

                        if (r.StrokeFill != null)
                            gc.FillPath(r.StrokeFill, (Tools.Model.VectorPath)m_Param.Path);
                        gc.DrawPath(r.StrokeOutline, (Tools.Model.VectorPath)m_Param.Path);

                        DrawRegionRepresentation(gc, r, drawMethods, mousePosition);
                    }
                }
                /*else if (editState.GetAttributes() == States.StateAttributes.Change)
                {
                    drawMethods.DrawNegativeSpace(gc, m_Param, r);
                    drawMethods.DrawPositiveSpace(gc, m_Param, r);
                    if (editState is States.RegionChange)
                    {
                        DrawRegionRepresentation(gc, r, mousePosition);

                        ((States.RegionChange)editState).Handles.DrawHandles(gc, m_Param, r);
                    }
                }*/
                else if (editState == Render.RenderHint.Feedback)
                {
                    drawMethods.DrawNegativeSpace(gc, m_Param.Path.InternalPath, r);
                    drawMethods.DrawPositiveSpace(gc, m_Param.Path.InternalPath, r);
                    if (!(this is ConveyorBeltFilter))
                        DrawRegionRepresentation(gc, r,drawMethods, mousePosition);

                }
                else
                {
                    drawMethods.DrawNegativeSpace(gc, m_Param.Path.InternalPath, r);
                    drawMethods.DrawPositiveSpace(gc, m_Param.Path.InternalPath, r);
                    DrawRegionRepresentation(gc, r, drawMethods, mousePosition);

                        // TODO ((States.IFilterHandles)editState).Handles.DrawHandles(gc, m_Param, r);

                }
                drawMethods.DrawHandles(gc, this, r);
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Renders a LineString to the map.
 /// </summary>
 /// <param name="g">Graphics reference</param>
 /// <param name="line">LineString to render</param>
 /// <param name="pen">Pen style used for rendering</param>
 /// <param name="map">Map reference</param>
 public static void DrawLineString(System.Drawing.Graphics g, Geometries.LineString line, System.Drawing.Pen pen, SharpMap.Map map)
 {
     if (line.Vertices.Count > 1)
     {
         System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
         gp.AddLines(line.TransformToImage(map));
         g.DrawPath(pen, gp);
     }
 }
Ejemplo n.º 6
0
		/// <summary>
		/// Renders a LineString to the map.
		/// </summary>
		/// <param name="g">Graphics reference</param>
		/// <param name="line">LineString to render</param>
		/// <param name="pen">Pen style used for rendering</param>
		/// <param name="map">Map reference</param>
		public static void DrawLineString(System.Drawing.Graphics g, ILineString line, System.Drawing.Pen pen, SharpMap.Map map)
		{
			if (line.Coordinates.Length > 1)
			{
				System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
				gp.AddLines(Transform.TransformToImage(line, map));
				g.DrawPath(pen, gp);
			}
		}
        public static void DrawFrame(System.Drawing.Graphics dc, System.Drawing.RectangleF r, float cornerRadius, System.Drawing.Color color)
        {
            var pen = new System.Drawing.Pen(color);
            if (cornerRadius <= 0)
            {
                dc.DrawRectangle(pen, ColorPickerUtil.Rect(r));
                return;
            }
            cornerRadius = (float)System.Math.Min(cornerRadius, System.Math.Floor(r.Width) - 2);
            cornerRadius = (float)System.Math.Min(cornerRadius, System.Math.Floor(r.Height) - 2);

            var path = new System.Drawing.Drawing2D.GraphicsPath();
            path.AddArc(r.X, r.Y, cornerRadius, cornerRadius, 180, 90);
            path.AddArc(r.Right - cornerRadius, r.Y, cornerRadius, cornerRadius, 270, 90);
            path.AddArc(r.Right - cornerRadius, r.Bottom - cornerRadius, cornerRadius, cornerRadius, 0, 90);
            path.AddArc(r.X, r.Bottom - cornerRadius, cornerRadius, cornerRadius, 90, 90);
            path.CloseAllFigures();
            dc.DrawPath(pen, path);
        }
        public override bool DrawString(
            System.Drawing.Graphics graphics,
            System.Drawing.FontFamily fontFamily,
            System.Drawing.FontStyle fontStyle,
            int fontSize,
            string strText,
            System.Drawing.Point ptDraw,
            System.Drawing.StringFormat strFormat)
        {
            using (GraphicsPath path = new GraphicsPath())
            {
                path.AddString(strText, fontFamily, (int)fontStyle, fontSize, ptDraw, strFormat);

                List<Color> list = new List<Color>();
                CalculateGradient(
                    m_clrOutline1,
                    m_clrOutline2,
                    m_nThickness,
                    list);

                for (int i = m_nThickness; i >= 1; --i)
                {
                    using (Pen pen1 = new Pen(list[i - 1], i))
                    {
                        pen1.LineJoin = LineJoin.Round;
                        graphics.DrawPath(pen1, path);
                    }
                }

                if (m_bClrText)
                {
                    using (SolidBrush brush = new SolidBrush(m_clrText))
                    {
                        graphics.FillPath(brush, path);
                    }
                }
                else
                    graphics.FillPath(m_brushText, path);
            }
            return true;
        }
        public override bool DrawString(
            System.Drawing.Graphics graphics,
            System.Drawing.FontFamily fontFamily,
            System.Drawing.FontStyle fontStyle,
            int fontSize,
            string strText,
            System.Drawing.Point ptDraw,
            System.Drawing.StringFormat strFormat)
        {
            using (GraphicsPath path = new GraphicsPath())
            {
                path.AddString(strText, fontFamily, (int)fontStyle, fontSize, ptDraw, strFormat);

                using (Pen pen = new Pen(m_clrOutline, m_nThickness))
                {
                    pen.LineJoin = LineJoin.Round;
                    graphics.DrawPath(pen, path);
                }
            }
            return true;
        }
Ejemplo n.º 10
0
		public void Render(Character character, System.Drawing.Graphics g, int width, int height)
		{
			//MinimumX = -1000; MaximumX = 1000; GranularityX = 2;

			Width = width - 16; Height = height - 24;
			MinimumY = MaximumY = 0f;
			string[] rotations;
			float[] graphData = BuildGraphData(character, out MinimumY, out MaximumY, out rotations);
			MinimumY = 0f;//(float)Math.Floor(MinimumY / 10f) * 10f;
			MaximumY = 5f;//(float)Math.Ceiling(MaximumY / 10f) * 10f;
			//RangeX = MaximumX - MinimumX;
			//RangeY = MaximumY - MinimumY;
			ConversionX = (width - 16f) / (MaximumX - MinimumX);
			ConversionY = (height - 24f) / (MaximumY - MinimumY);

			PointF[] points = new PointF[graphData.Length + 2];
			points[0] = GetScreenPoint(MinimumX, 0);
			points[points.Length - 1] = GetScreenPoint(MaximumX, 0);
			byte[] types = new byte[points.Length];
			types[0] = (byte)PathPointType.Start;
			types[types.Length - 1] = (byte)PathPointType.Line;
			float x = 0, integralY = 0f; 
			for (int i = 1; i <= graphData.Length; i++)
			{
				x = MinimumX + (float)(i - 1) / (float)GranularityX;
				integralY = 0f;
				if (i < graphData.Length - 1) integralY = (graphData[i] - graphData[i - 1]);
				points[i] = GetScreenPoint(x, integralY);
				types[i] = (byte)PathPointType.Line;
			}

			GraphicsPath pathData = new GraphicsPath(points, types, FillMode.Winding);

			g.FillPath(BrushStat, pathData);
			g.DrawPath(PenStat, pathData);
		}
        public override bool GdiDrawString(
            System.Drawing.Graphics pGraphics,
            LOGFONT pLogFont,
            string pszText,
            System.Drawing.Point ptDraw)
        {
            using (GraphicsPath pPath = new GraphicsPath(System.Drawing.Drawing2D.FillMode.Winding))
            {
                bool b = GDIPath.GetStringPath(
                    pGraphics,
                    pPath,
                    pszText,
                    pLogFont,
                    ptDraw);

                if (false == b)
                {
                    return false;
                }

                using (Pen pen = new Pen(m_clrOutline, m_nThickness))
                {
                    if (m_bRoundedEdge)
                        pen.LineJoin = LineJoin.Round;
                    pGraphics.DrawPath(pen, pPath);
                }
            }
            return true;
        }
Ejemplo n.º 12
0
    protected void PaintXErrorBars(System.Drawing.Graphics g, IPlotArea layer, Altaxo.Graph.Gdi.Plot.Data.Processed2DPlotData pdata)
    {

      // Plot error bars for the independent variable (x)
      PlotRangeList rangeList = pdata.RangeList;
      PointF[] ptArray = pdata.PlotPointsInAbsoluteLayerCoordinates;
      INumericColumn posErrCol = _positiveErrorColumn.Document;
      INumericColumn negErrCol = _negativeErrorColumn.Document;

      if (posErrCol == null && negErrCol == null)
        return; // nothing to do if both error columns are null

      System.Drawing.Drawing2D.GraphicsPath errorBarPath = new System.Drawing.Drawing2D.GraphicsPath();

      Region oldClippingRegion = g.Clip;
      Region newClip = (Region)oldClippingRegion.Clone();

      foreach (PlotRange r in rangeList)
      {
        int lower = r.LowerBound;
        int upper = r.UpperBound;
        int offset = r.OffsetToOriginal;
        for (int j = lower; j < upper; j++)
        {
          AltaxoVariant x = pdata.GetXPhysical(j + offset);
          Logical3D lm = layer.GetLogical3D(pdata, j + offset);
          lm.RX += _cachedLogicalShiftOfIndependent;
          if (lm.IsNaN)
            continue;

          Logical3D lh = lm;
          Logical3D ll = lm;
          bool lhvalid = false;
          bool llvalid = false;
          if (posErrCol != null)
          {
            lh.RX = layer.XAxis.PhysicalVariantToNormal(x + Math.Abs(posErrCol[j + offset]));
            lhvalid = !lh.IsNaN;
          }
          if (negErrCol != null)
          {
            ll.RX = layer.XAxis.PhysicalVariantToNormal(x - Math.Abs(negErrCol[j + offset]));
            llvalid = !ll.IsNaN;
          }
          if (!(lhvalid || llvalid))
            continue; // nothing to do for this point if both pos and neg logical point are invalid.

          // now paint the error bar
          if (_symbolGap) // if symbol gap, then clip the painting, exclude a rectangle of size symbolSize x symbolSize
          {
            double xlm, ylm;
            layer.CoordinateSystem.LogicalToLayerCoordinates(lm, out xlm, out ylm);
            newClip.Union(oldClippingRegion);
            newClip.Exclude(new RectangleF((float)(xlm - _symbolSize / 2), (float)(ylm - _symbolSize / 2), _symbolSize, _symbolSize));
            g.Clip = newClip;
          }

          if (lhvalid && llvalid)
          {
            errorBarPath.Reset();
            layer.CoordinateSystem.GetIsoline(errorBarPath, ll, lm);
            layer.CoordinateSystem.GetIsoline(errorBarPath, lm, lh);
            g.DrawPath(_strokePen, errorBarPath);
          }
          else if (llvalid)
          {
            layer.CoordinateSystem.DrawIsoline(g, _strokePen, ll, lm);
          }
          else if (lhvalid)
          {
            layer.CoordinateSystem.DrawIsoline(g, _strokePen, lm, lh);
          }


          // now the end bars
          if (_showEndBars)
          {
            if (lhvalid)
            {
              PointF outDir;
              layer.CoordinateSystem.GetNormalizedDirection(lm, lh, 1, new Logical3D(0, 1), out outDir);
              outDir.X *= _symbolSize / 2;
              outDir.Y *= _symbolSize / 2;
              double xlay, ylay;
              layer.CoordinateSystem.LogicalToLayerCoordinates(lh, out xlay, out ylay);
              // Draw a line from x,y to 
              g.DrawLine(_strokePen, (float)(xlay - outDir.X), (float)(ylay - outDir.Y), (float)(xlay + outDir.X), (float)(ylay + outDir.Y));
            }

            if (llvalid)
            {
              PointF outDir;
              layer.CoordinateSystem.GetNormalizedDirection(lm, ll, 1, new Logical3D(0, 1), out outDir);
              outDir.X *= _symbolSize / 2;
              outDir.Y *= _symbolSize / 2;
              double xlay, ylay;
              layer.CoordinateSystem.LogicalToLayerCoordinates(ll, out xlay, out ylay);
              // Draw a line from x,y to 
              g.DrawLine(_strokePen, (float)(xlay - outDir.X), (float)(ylay - outDir.Y), (float)(xlay + outDir.X), (float)(ylay + outDir.Y));
            }

          }
        }
      }

      g.Clip = oldClippingRegion;
    }
Ejemplo n.º 13
0
        internal static void DrawGradientRoundRect(
            System.Drawing.Graphics g,
            Rectangle rect,
            Color begin,
            Color end,
            Color border,
            Color innerBorder,
            Blend blend,
            LinearGradientMode mode,
            int radios,
            RoundStyle roundStyle,
            bool drawBorder,
            bool drawInnderBorder)
        {
            using (GraphicsPath path = GraphicsPathHelper.CreatePath(
                rect, radios, roundStyle, true))
            {
                using (LinearGradientBrush brush = new LinearGradientBrush(
                      rect, begin, end, mode))
                {
                    brush.Blend = blend;
                    g.FillPath(brush, path);
                }

                if (drawBorder)
                {
                    using (Pen pen = new Pen(border))
                    {
                        g.DrawPath(pen, path);
                    }
                }
            }

            if (drawInnderBorder)
            {
                rect.Inflate(-1, -1);
                using (GraphicsPath path = GraphicsPathHelper.CreatePath(
                    rect, radios, roundStyle, true))
                {
                    using (Pen pen = new Pen(innerBorder))
                    {
                        g.DrawPath(pen, path);
                    }
                }
            }
        }
Ejemplo n.º 14
0
		protected internal void DrawInsertMarker(System.Drawing.Graphics g)
		{
            IOwner owner = GetOwner() as IOwner;
            if (m_DesignInsertMarker == eDesignInsertPosition.None || !this.Visible || !this.Displayed || !(owner != null && owner.DragInProgress || this.DesignMode))
                return;

            Color lineColor = ColorScheme.GetColor("834DD5");
            Color fillColor = ColorScheme.GetColor("CCCFF8");

            int size = 4;
            int lineThickness = 1;
            int padding = 2;

			if(IsDesignMarkHorizontal)
			{
                Point start = new Point(m_Rect.X, m_Rect.Y + padding), end = new Point(m_Rect.X, m_Rect.Bottom - (padding + 1));
                if (m_DesignInsertMarker == eDesignInsertPosition.After)
                {
                    start = new Point(m_Rect.Right - size * 2, m_Rect.Y + padding);
                    end = new Point(m_Rect.Right - size * 2, m_Rect.Bottom - (padding+1));
                }

                using (SolidBrush fillBrush = new SolidBrush(fillColor))
                {
                    using (Pen pen = new Pen(lineColor, 1))
                    {
                        using (GraphicsPath path = new GraphicsPath())
                        {
                            path.AddLine(start.X, start.Y + size, start.X + size, start.Y);
                            path.AddLine(start.X + size * 2, start.Y + size, start.X + (size * 2 - (size - lineThickness)), start.Y + size);
                            path.AddLine(end.X + (size * 2 - (size - lineThickness)), end.Y - size, end.X + size * 2, end.Y - size);
                            path.AddLine(end.X + size, end.Y, end.X, end.Y - size);
                            path.AddLine(end.X + (size - lineThickness), end.Y - size, start.X + (size - lineThickness), start.Y + size);
                            path.CloseAllFigures();

                            g.FillPath(fillBrush, path);
                            g.DrawPath(pen, path);
                        }
                    }
                }
			}
			else
			{
                Point start = new Point(m_Rect.X + padding, m_Rect.Y), end = new Point(m_Rect.Right - (padding+1), m_Rect.Y);
                if (m_DesignInsertMarker == eDesignInsertPosition.After)
                {
                    start = new Point(m_Rect.X + padding, m_Rect.Bottom - (size * 2 + 1));
                    end = new Point(m_Rect.Right - (padding + 1), m_Rect.Bottom - (size * 2 + 1));
                }

                using (SolidBrush fillBrush = new SolidBrush(fillColor))
                {
                    using (Pen pen = new Pen(lineColor, 1))
                    {
                        using (GraphicsPath path = new GraphicsPath())
                        {
                            path.AddLine(start.X, start.Y + size, start.X + size, start.Y);
                            path.AddLine(start.X + size, start.Y + (size - lineThickness), end.X - size, end.Y + (size - lineThickness));
                            path.AddLine(end.X - size, end.Y, end.X, end.Y + size);
                            path.AddLine(end.X - size, end.Y + size * 2, end.X - size, end.Y + (size*2 - (size-padding)));
                            path.AddLine(start.X + size, start.Y + (size * 2 - (size - padding)), start.X + size, start.Y + size * 2);

                            path.CloseAllFigures();

                            g.FillPath(fillBrush, path);
                            g.DrawPath(pen, path);
                        }
                    }
                }
                //if(m_DesignInsertMarker==eDesignInsertPosition.Before)
                //{
                //    p[0].X=m_Rect.Left+1;
                //    p[0].Y=m_Rect.Top;
                //    p[1].X=m_Rect.Left+1;
                //    p[1].Y=m_Rect.Top+4;
                //    g.DrawLines(pen,p);

                //    p[0].X=m_Rect.Left+1;
                //    p[0].Y=m_Rect.Top+2;
                //    p[1].X=m_Rect.Right-1;
                //    p[1].Y=m_Rect.Top+2;
                //    g.DrawLines(pen,p);

                //    p[0].X=m_Rect.Right-1;
                //    p[0].Y=m_Rect.Top;
                //    p[1].X=m_Rect.Right-1;
                //    p[1].Y=m_Rect.Top+4;
                //    g.DrawLines(pen,p);
                //}
                //else
                //{
                //    p[0].X=m_Rect.Left+1;
                //    p[0].Y=m_Rect.Bottom-4;
                //    p[1].X=m_Rect.Left+1;
                //    p[1].Y=m_Rect.Bottom;
                //    g.DrawLines(pen,p);

                //    p[0].X=m_Rect.Left+1;
                //    p[0].Y=m_Rect.Bottom-2;
                //    p[1].X=m_Rect.Right-1;
                //    p[1].Y=m_Rect.Bottom-2;
                //    g.DrawLines(pen,p);

                //    p[0].X=m_Rect.Right-1;
                //    p[0].Y=m_Rect.Bottom-4;
                //    p[1].X=m_Rect.Right-1;
                //    p[1].Y=m_Rect.Bottom;
                //    g.DrawLines(pen,p);
                //}
			}
            //g.SmoothingMode = sm;
		}
Ejemplo n.º 15
0
		/// <summary>This method will paint the group title.</summary>
		/// <param name="g">The paint event graphics object.</param>
		private void PaintGroupText(System.Drawing.Graphics g)
		{
			//Check if string has something-------------
			if(this.GroupTitle==string.Empty){return;}
			//------------------------------------------

			//Set Graphics smoothing mode to Anit-Alias-- 
			g.SmoothingMode = SmoothingMode.AntiAlias;
			//-------------------------------------------

			//Declare Variables------------------
			SizeF StringSize = g.MeasureString(this.GroupTitle, this.Font);
			Size StringSize2 = StringSize.ToSize();
			if(this.GroupImage!=null){StringSize2.Width+=18;}
			int ArcWidth = this.RoundCorners;
			int ArcHeight = this.RoundCorners;
			int ArcX1 = 20;
			int ArcX2 = (StringSize2.Width+34) - (ArcWidth + 1);
			int ArcY1 = 0;
			int ArcY2 = 24 - (ArcHeight + 1);
			System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
			System.Drawing.Brush BorderBrush = new SolidBrush(this.BorderColor);
			System.Drawing.Pen BorderPen = new Pen(BorderBrush, this.BorderThickness);
			System.Drawing.Drawing2D.LinearGradientBrush BackgroundGradientBrush = null;
			System.Drawing.Brush BackgroundBrush = (this.PaintGroupBox) ? new SolidBrush(this.CustomGroupBoxColor) : new SolidBrush(this.BackgroundColor);
			System.Drawing.SolidBrush TextColorBrush = new SolidBrush(this.ForeColor);
			System.Drawing.SolidBrush ShadowBrush = null;
			System.Drawing.Drawing2D.GraphicsPath ShadowPath  = null;
			//-----------------------------------

			//Check if shadow is needed----------
			if(this.ShadowControl)
			{
				ShadowBrush = new SolidBrush(this.ShadowColor);
				ShadowPath = new System.Drawing.Drawing2D.GraphicsPath();
				ShadowPath.AddArc(ArcX1+(this.ShadowThickness-1), ArcY1+(this.ShadowThickness-1), ArcWidth, ArcHeight, 180, Tools.GroupBoxConstants.SweepAngle); // Top Left
                ShadowPath.AddArc(ArcX2 + (this.ShadowThickness - 1), ArcY1 + (this.ShadowThickness - 1), ArcWidth, ArcHeight, 270, Tools.GroupBoxConstants.SweepAngle); //Top Right
                ShadowPath.AddArc(ArcX2 + (this.ShadowThickness - 1), ArcY2 + (this.ShadowThickness - 1), ArcWidth, ArcHeight, 360, Tools.GroupBoxConstants.SweepAngle); //Bottom Right
                ShadowPath.AddArc(ArcX1 + (this.ShadowThickness - 1), ArcY2 + (this.ShadowThickness - 1), ArcWidth, ArcHeight, 90, Tools.GroupBoxConstants.SweepAngle); //Bottom Left
				ShadowPath.CloseAllFigures();

				//Paint Rounded Rectangle------------
				g.FillPath(ShadowBrush, ShadowPath);
				//-----------------------------------
			}
			//-----------------------------------

			//Create Rounded Rectangle Path------
            path.AddArc(ArcX1, ArcY1, ArcWidth, ArcHeight, 180, Tools.GroupBoxConstants.SweepAngle); // Top Left
            path.AddArc(ArcX2, ArcY1, ArcWidth, ArcHeight, 270, Tools.GroupBoxConstants.SweepAngle); //Top Right
            path.AddArc(ArcX2, ArcY2, ArcWidth, ArcHeight, 360, Tools.GroupBoxConstants.SweepAngle); //Bottom Right
            path.AddArc(ArcX1, ArcY2, ArcWidth, ArcHeight, 90, Tools.GroupBoxConstants.SweepAngle); //Bottom Left
			path.CloseAllFigures(); 
			//-----------------------------------

			//Check if Gradient Mode is enabled--
			if(this.PaintGroupBox)
			{
				//Paint Rounded Rectangle------------
				g.FillPath(BackgroundBrush, path);
				//-----------------------------------
			}
			else
			{
				if(this.BackgroundGradientMode==GroupBoxGradientMode.None)
				{
					//Paint Rounded Rectangle------------
					g.FillPath(BackgroundBrush, path);
					//-----------------------------------
				}
				else
				{
					BackgroundGradientBrush = new LinearGradientBrush(new Rectangle(0,0,this.Width,this.Height), this.BackgroundColor, this.BackgroundGradientColor, (LinearGradientMode)this.BackgroundGradientMode);
				
					//Paint Rounded Rectangle------------
					g.FillPath(BackgroundGradientBrush, path);
					//-----------------------------------
				}
			}
			//-----------------------------------

			//Paint Borded-----------------------
			g.DrawPath(BorderPen, path);
			//-----------------------------------

			//Paint Text-------------------------
			int CustomStringWidth = (this.GroupImage!=null) ? 44 : 28;
			g.DrawString(this.GroupTitle, this.Font, TextColorBrush, CustomStringWidth, 5);
			//-----------------------------------

			//Draw GroupImage if there is one----
			if(this.GroupImage!=null)
			{
				g.DrawImage(this.GroupImage, 28,4, 16, 16);
			}
			//-----------------------------------

			//Destroy Graphic Objects------------
			if(path!=null){path.Dispose();}
			if(BorderBrush!=null){BorderBrush.Dispose();}
			if(BorderPen!=null){BorderPen.Dispose();}
			if(BackgroundGradientBrush!=null){BackgroundGradientBrush.Dispose();}
			if(BackgroundBrush!=null){BackgroundBrush.Dispose();}
			if(TextColorBrush!=null){TextColorBrush .Dispose();}
			if(ShadowBrush!=null){ShadowBrush.Dispose();}
			if(ShadowPath!=null){ShadowPath.Dispose();}
			//-----------------------------------
		}
Ejemplo n.º 16
0
        private void PaintTabBorder(System.Drawing.Graphics graph, int index, System.Drawing.Drawing2D.GraphicsPath path)
        {
            Pen borderPen = new Pen(SystemColors.ControlDark);
            if (index == this.SelectedIndex)
            {
                borderPen = new Pen(VisualThemedColors.ToolBorder);
            }

            graph.DrawPath(borderPen, path);
            borderPen.Dispose();
        }
 public override void DrawOutline(System.Drawing.Graphics gc, Render.RenderParameter r)
 {
     if (m_Param.Path != null)
         gc.DrawPath(r.RegionOutline, (Tools.Model.VectorPath)m_Param.Path);
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Draws the outline of a rounded rectangle.
 /// </summary>
 public static void DrawRoundedRectangle(System.Drawing.Graphics graphics, Pen pen, int x, int y, int width, int height, int radius)
 {
     using (GraphicsPath path = GetRoundedRectanglePath(x, y, width, height, radius))
     {
         graphics.DrawPath(pen, path);
     }
 }
Ejemplo n.º 19
0
        public override bool GdiDrawString(
            System.Drawing.Graphics pGraphics,
            LOGFONT pLogFont,
            string pszText,
            System.Drawing.Rectangle rtDraw)
        {
            using (GraphicsPath pPath = new GraphicsPath(System.Drawing.Drawing2D.FillMode.Winding))
            {
                bool b = GDIPath.GetStringPath(
                    pGraphics,
                    pPath,
                    pszText,
                    pLogFont,
                    rtDraw);

                if (false == b)
                {
                    return false;
                }

                using (Pen pen2 = new Pen(m_clrOutline2, m_nThickness1 + m_nThickness2))
                {
                    pen2.LineJoin = LineJoin.Round;
                    pGraphics.DrawPath(pen2, pPath);
                }
                using (Pen pen1 = new Pen(m_clrOutline1, m_nThickness1))
                {
                    pen1.LineJoin = LineJoin.Round;
                    pGraphics.DrawPath(pen1, pPath);
                }

                if (m_bClrText)
                {
                    using (SolidBrush brush = new SolidBrush(m_clrText))
                    {
                        pGraphics.FillPath(brush, pPath);
                    }
                }
                else
                {
                    pGraphics.FillPath(m_brushText, pPath);
                }
            }
            return true;
        }
Ejemplo n.º 20
0
 public void DrawOutline(System.Drawing.Graphics gc, Render.RenderParameter r)
 {
     try
     {
         if (m_visibleThickPath != null)
         {
             gc.DrawPath(r.RegionOutline, m_visibleThickPath);
         }
         if (m_Param.Path != null)
         {
             gc.DrawPath(r.RegionOutline, (Tools.Model.VectorPath)m_Param.Path);
         }
     }
     catch
     {
     }
 }
Ejemplo n.º 21
0
        public void Draw(System.Drawing.Graphics gc, Render.RenderParameter r, Render.RenderHint editState, Render.IDrawVisitor drawMethods, PointD mousePosition)
        {
            if (m_Param.Path != null && m_Param.Path.PointCount >= 2)
            {
                try
                {
                    if (m_visibleThickPath != null)
                    {
                        if (r.RegionInsideFill != null)
                            gc.FillPath(r.RegionInsideFill, m_visibleThickPath);
                        gc.DrawPath(r.RegionOutline, m_visibleThickPath);
                    }
                    gc.DrawPath(r.RegionOutline, (Tools.Model.VectorPath)m_Param.Path);
                }
                catch
                {
                    // don't know what happened here
                }

                if (editState ==  Render.RenderHint.Start)
                {
                    Pen dashPen = (Pen)r.RegionOutline.Clone();
                    dashPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
                    if (m_Param.Path.PointCount > 0)
                    {
                        PointD firstPoint = mousePosition; // TODO ((States.LineHover)editState).FirstPoint;
                        gc.DrawEllipse(dashPen, (float)firstPoint.X - Tools.Render.DrawHelper.TARGET_SIZE / 2.0f, (float)firstPoint.Y - Tools.Render.DrawHelper.TARGET_SIZE / 2.0f, (float)Tools.Render.DrawHelper.TARGET_SIZE, (float)Tools.Render.DrawHelper.TARGET_SIZE);
                    }

                    /*
                    PointD normal;
                    double radius;
                    NormalOfPoint(mousePosition, out normal, out radius);
                    gc.DrawLine(r.ActivePen, (Point)mousePosition, (Point)(mousePosition - normal * radius));
                     */

                }
                else
                {
                    DrawArrowForces(gc, r, drawMethods);
                }

                    drawMethods.DrawHandles(gc, this, r);
                    // TODO ((States.IFilterHandles)editState).Handles.DrawHandles(gc, m_Param, r);

            }
        }
Ejemplo n.º 22
0
		private static System.Object mutex_TabRect_DrawTabRect = new System.Object[0];						// 1.0.003
		internal static void TabRect_DrawTabRect(															// 1.0.003
			TdhTabCtl theTabCtl, 																	// 1.0.003
			System.Drawing.Point ptMouse, 																	// 1.0.003
			System.Windows.Forms.TabPage theTabPage, int idxTabPage, bool asActive, 						// 1.0.010
			System.Drawing.Graphics gfx, System.Drawing.RectangleF tabRectDraw 								// 1.0.003
		)																									// 1.0.003
		{																									// 1.0.003
			lock (mutex_TabRect_DrawTabRect)								// Just-in-case					// 1.0.003
			{																								// 1.0.003
				#region Draw the TabRect Background and Buttons
				System.Drawing.Drawing2D.GraphicsPath _Path = new System.Drawing.Drawing2D.GraphicsPath();
				_Path.AddRectangle(tabRectDraw);
				using (
					System.Drawing.Drawing2D.LinearGradientBrush _Brush = 
						new System.Drawing.Drawing2D.LinearGradientBrush(
						tabRectDraw, 
						System.Drawing.SystemColors.Control, 
						System.Drawing.SystemColors.ControlLight, 
						System.Drawing.Drawing2D.LinearGradientMode.Vertical) 
						)
				{
					if (asActive)							// Is this the active TabPage?					// 1.0.003
					{																						// 1.0.003						
						#region Draw the TabRect background (active TabPage)
						System.Drawing.Drawing2D.ColorBlend _ColorBlend = new System.Drawing.Drawing2D.ColorBlend(3);
						_ColorBlend.Colors = new System.Drawing.Color[]
							{
								//System.Drawing.SystemColors.ControlLightLight, 
								//System.Drawing.Color.FromArgb(255, System.Drawing.SystemColors.Control), 
								//System.Drawing.SystemColors.ControlLight, 
								//System.Drawing.SystemColors.Control

//								System.Drawing.SystemColors.ControlLightLight,								// 1.0.001
//								//System.Drawing.Color.FromArgb(255, System.Drawing.SystemColors.ControlLight),// 1.0.001
//								System.Drawing.SystemColors.ControlLight,									// 1.0.001
//								System.Drawing.SystemColors.ControlDark,									// 1.0.001
//								System.Drawing.SystemColors.ControlLightLight								// 1.0.001

								System.Drawing.Color.FromArgb(255, 170, 213, 243),							// 1.0.001
								System.Drawing.Color.FromArgb(255, 170, 213, 243),							// 1.0.001
								System.Drawing.Color.FromArgb(255, 170, 213, 243),							// 1.0.001
								//System.Drawing.Color.FromArgb(255, 44, 137, 191),							// 1.0.001
								System.Drawing.Color.FromArgb(255, 44, 137, 191)							// 1.0.001
							};
						_ColorBlend.Positions = new float[] { 0f, .4f, 0.5f, 1f };
						_Brush.InterpolationColors = _ColorBlend;
						gfx.FillPath(_Brush, _Path);														// 1.0.003
						using (Pen pen = new Pen(SystemColors.ActiveBorder))
						{
							gfx.DrawPath(pen, _Path);														// 1.0.003
						}
						#endregion 
					}																						// 1.0.003
					else																					// 1.0.003
					{																						// 1.0.003
						#region Draw the TabRect background (inactive TabPage)
						ColorBlend _ColorBlend = new ColorBlend(3);
						_ColorBlend.Colors = new System.Drawing.Color[]
							{
								//System.Drawing.SystemColors.ControlLightLight, 
								//System.Drawing.Color.FromArgb(255, System.Drawing.SystemColors.ControlLight), 
								//System.Drawing.SystemColors.ControlDark, 
								//System.Drawing.SystemColors.ControlLightLight 

//								System.Drawing.SystemColors.ControlDarkDark,								// 1.0.001
//								System.Drawing.SystemColors.ControlLightLight,								// 1.0.001
//								System.Drawing.SystemColors.ControlLightLight,								// 1.0.001
//								System.Drawing.SystemColors.ControlLight									// 1.0.001

								System.Drawing.SystemColors.ControlLightLight,								// 1.0.001
								System.Drawing.Color.FromArgb(255, System.Drawing.SystemColors.ControlLight), // 1.0.001
								//System.Drawing.SystemColors.ControlLightLight,							 // 1.0.001
								System.Drawing.SystemColors.ControlLight,									// 1.0.001
								System.Drawing.SystemColors.ControlDark										// 1.0.001
							};
						_ColorBlend.Positions = new float[] { 0f, .4f, 0.5f, 1f };
						_Brush.InterpolationColors = _ColorBlend;
						gfx.FillPath(_Brush, _Path);														// 1.0.003
						using (System.Drawing.Pen pen = new System.Drawing.Pen(System.Drawing.SystemColors.ActiveBorder))
						{
							gfx.DrawPath(pen, _Path);														// 1.0.003
						}
						#endregion 
					}																						// 1.0.003

					#region Draw Buttons this TabRect
					if( (theTabPage.GetType() == typeof(TdhTabPage))								// 1.0.010
						|| theTabPage.GetType().IsSubclassOf(typeof(TdhTabPage))					// 1.0.010
					)																						// 1.0.010
					{																						// 1.0.010
						TabRect_DrawButtons(																// 1.0.001
							theTabCtl, ptMouse,																// 1.0.003
							gfx, 																			// 1.0.003
							tabRectDraw, idxTabPage, asActive, !asActive									// 1.0.003
							);																				// 1.0.001
					}																						// 1.0.010
					#endregion 
				}
				_Path.Dispose();
				#endregion 

				#region Draw [theTabPage.Text] on the TabRect
				int textOffset = 0;																			// 1.0.001
				if (theTabCtl.Font.Size <= 8.25f)		// Size: 8											// 1.0.003
				{																							// 1.0.001
					textOffset = 5;																			// 1.0.001
				}																							// 1.0.001
				else																						// 1.0.001
				if (theTabCtl.Font.Size <= 9f)			// Size: 9											// 1.0.003
				{																							// 1.0.001
					textOffset = 4;																			// 1.0.001
				}																							// 1.0.001
				else																						// 1.0.001
				if (theTabCtl.Font.Size <= 9.75f)		// Size: 10											// 1.0.003
				{																							// 1.0.001
					textOffset = 3;																			// 1.0.001
				}																							// 1.0.001
				else																						// 1.0.001
				if (theTabCtl.Font.Size < 11.25f)		// Size: 11											// 1.0.003
				{																							// 1.0.001
					textOffset = 2;																			// 1.0.001
				}																							// 1.0.001
				else																						// 1.0.001
				if (theTabCtl.Font.Size < 12f)			// Size: 12											// 1.0.003
				{																							// 1.0.001
					textOffset = 1;																			// 1.0.001
				}																							// 1.0.001
				System.Drawing.RectangleF textRect = new System.Drawing.RectangleF(							// 1.0.001
					tabRectDraw.X,																			// 1.0.001
					tabRectDraw.Y + textOffset,																// 1.0.001
					tabRectDraw.Width,																		// 1.0.001
					tabRectDraw.Height - textOffset);														// 1.0.001

				string str = " "+ theTabPage.Text.Trim();													// 1.0.010
				System.Drawing.StringFormat stringFormat = new System.Drawing.StringFormat();
				stringFormat.Alignment = System.Drawing.StringAlignment.Near;								// 1.0.001
				gfx.DrawString(																				// 1.0.003
					str, 
					theTabCtl.Font,																			// 1.0.003
					new System.Drawing.SolidBrush(theTabPage.ForeColor),									// 1.0.010
					textRect,																				// 1.0.001
					stringFormat);
				#endregion 
			}																								// 1.0.003
		}																									// 1.0.003
Ejemplo n.º 23
0
        /// <summary>
        /// Renders a polygon to the map.
        /// </summary>
        /// <param name="g">Graphics reference</param>
        /// <param name="pol">Polygon to render</param>
        /// <param name="brush">Brush used for filling (null or transparent for no filling)</param>
        /// <param name="pen">Outline pen style (null if no outline)</param>
        /// <param name="clip">Specifies whether polygon clipping should be applied</param>
        /// <param name="map">Map reference</param>
        public static void DrawPolygon(System.Drawing.Graphics g, SharpMap.Geometries.Polygon pol, System.Drawing.Brush brush, System.Drawing.Pen pen, bool clip, SharpMap.Map map)
        {
            if (pol.ExteriorRing == null)
                return;
            if (pol.ExteriorRing.Vertices.Count > 2)
            {
                //Use a graphics path instead of DrawPolygon. DrawPolygon has a problem with several interior holes
                System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();

                //Add the exterior polygon
                if (!clip)
                    gp.AddPolygon(pol.ExteriorRing.TransformToImage(map));
                else
                    gp.AddPolygon(clipPolygon(pol.ExteriorRing.TransformToImage(map), map.Size.Width, map.Size.Height));

                //Add the interior polygons (holes)
                for (int i = 0; i < pol.InteriorRings.Count; i++)
                    if (!clip)
                        gp.AddPolygon(pol.InteriorRings[i].TransformToImage(map));
                    else
                        gp.AddPolygon(clipPolygon(pol.InteriorRings[i].TransformToImage(map), map.Size.Width, map.Size.Height));

                // Only render inside of polygon if the brush isn't null or isn't transparent
                if (brush != null && brush != System.Drawing.Brushes.Transparent)
                    g.FillPath(brush, gp);
                // Create an outline if a pen style is available
                if (pen != null)
                    g.DrawPath(pen, gp);
            }
        }
 public override void DrawOutline(System.Drawing.Graphics gc, Render.RenderParameter r)
 {
     if (m_Param.Path != null)
     {
         if (m_Param.Path is Tools.Model.VectorPath)
         {
             gc.DrawPath(r.RegionOutline, (Tools.Model.VectorPath)m_Param.Path);
         }
         else if (m_Param.Path is Tools.Model.BitmapPath)
         {
             using (Pen dashPen = (Pen) r.RegionOutline.Clone())
             {
                 dashPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
                 gc.DrawPath(dashPen, ((Tools.Model.BitmapPath)m_Param.Path).LineTrace);
             }
         }
     }
 }
Ejemplo n.º 25
0
        void DrawTab(System.Drawing.Graphics g, TabVS2005 tab)
        {
            var rectTabOrigin = GetTabRectangle(tab);
            if (rectTabOrigin.IsEmpty)
                return;

            var dockState = tab.Content.DockHandler.DockState;
            var content = tab.Content;

            var path = GetTabOutline(tab, false, true);

            var startColor = DockPanel.Skin.AutoHideStripSkin.TabGradient.StartColor;
            var endColor = DockPanel.Skin.AutoHideStripSkin.TabGradient.EndColor;
            var gradientMode = DockPanel.Skin.AutoHideStripSkin.TabGradient.LinearGradientMode;
            g.FillPath(new LinearGradientBrush(rectTabOrigin, startColor, endColor, gradientMode), path);
            g.DrawPath(PenTabBorder, path);

            // Set no rotate for drawing icon and text
            var matrixRotate = g.Transform;
            g.Transform = MatrixIdentity;

            // Draw the icon
            var rectImage = rectTabOrigin;
            rectImage.X += ImageGapLeft;
            rectImage.Y += ImageGapTop;
            var imageHeight = rectTabOrigin.Height - ImageGapTop - ImageGapBottom;
            var imageWidth = ImageWidth;
            if (imageHeight > ImageHeight)
                imageWidth = ImageWidth * (imageHeight / ImageHeight);
            rectImage.Height = imageHeight;
            rectImage.Width = imageWidth;
            rectImage = GetTransformedRectangle(dockState, rectImage);
            g.DrawIcon(((Form)content).Icon, RtlTransform(rectImage, dockState));

            // Draw the text
            var rectText = rectTabOrigin;
            rectText.X += ImageGapLeft + imageWidth + ImageGapRight + TextGapLeft;
            rectText.Width -= ImageGapLeft + imageWidth + ImageGapRight + TextGapLeft;
            rectText = RtlTransform(GetTransformedRectangle(dockState, rectText), dockState);

            var textColor = DockPanel.Skin.AutoHideStripSkin.TabGradient.TextColor;

            if (dockState == DockState.DockLeftAutoHide || dockState == DockState.DockRightAutoHide)
                g.DrawString(content.DockHandler.TabText, TextFont, new SolidBrush(textColor), rectText, StringFormatTabVertical);
            else
                g.DrawString(content.DockHandler.TabText, TextFont, new SolidBrush(textColor), rectText, StringFormatTabHorizontal);

            // Set rotate back
            g.Transform = matrixRotate;
        }
 protected override void Draw(System.Drawing.Graphics dc, string title, string text, Rectangle rect, Rectangle titleRect, Rectangle bodyRect, Image img, int iconWidth)
 {
     Rectangle borderRect = new Rectangle(rect.X + borderThickness / 2, rect.Y + borderThickness / 2, rect.Width - borderThickness, rect.Height - borderThickness);
     dc.FillPath(backBrush, GetCapsule(borderRect, CornerRadius));
     dc.DrawPath(borderPen, GetCapsule(borderRect, CornerRadius));
     StringFormat format = new StringFormat(StringFormatFlags.NoWrap);
     format.Trimming = StringTrimming.EllipsisCharacter;
     dc.DrawString(title, titleFont, titleForeBrush,
         new RectangleF(Padding.Left + iconWidth, Padding.Top, Math.Min(titleRect.Width, bodyRect.Width), titleRect.Height), format);
     dc.DrawString(text, font, foreBrush,
         new RectangleF(Padding.Left + iconWidth, Padding.Top + titleRect.Height, bodyRect.Width, bodyRect.Height),
         new StringFormat());
 }
Ejemplo n.º 27
0
		/// <summary>This method will paint the control.</summary>
		/// <param name="g">The paint event graphics object.</param>
		private void PaintBack(System.Drawing.Graphics g)
		{
			//Set Graphics smoothing mode to Anit-Alias-- 
			g.SmoothingMode = SmoothingMode.AntiAlias;
			//-------------------------------------------

			//Declare Variables------------------
			int ArcWidth = this.RoundCorners * 2;
			int ArcHeight = this.RoundCorners * 2;
			int ArcX1 = 0;
			int ArcX2 = (this.ShadowControl) ? (this.Width - (ArcWidth + 1))-this.ShadowThickness : this.Width - (ArcWidth + 1);
			int ArcY1 = 10;
			int ArcY2 = (this.ShadowControl) ? (this.Height - (ArcHeight + 1))-this.ShadowThickness : this.Height - (ArcHeight + 1);
			System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
			System.Drawing.Brush BorderBrush = new SolidBrush(this.BorderColor);
			System.Drawing.Pen BorderPen = new Pen(BorderBrush, this.BorderThickness);
			System.Drawing.Drawing2D.LinearGradientBrush BackgroundGradientBrush = null;
			System.Drawing.Brush BackgroundBrush = new SolidBrush(this.BackgroundColor);
			System.Drawing.SolidBrush ShadowBrush = null;
			System.Drawing.Drawing2D.GraphicsPath ShadowPath  = null;
			//-----------------------------------

			//Check if shadow is needed----------
			if(this.ShadowControl)
			{
				ShadowBrush = new SolidBrush(this.ShadowColor);
				ShadowPath = new System.Drawing.Drawing2D.GraphicsPath();
                ShadowPath.AddArc(ArcX1 + this.ShadowThickness, ArcY1 + this.ShadowThickness, ArcWidth, ArcHeight, 180, Tools.GroupBoxConstants.SweepAngle); // Top Left
                ShadowPath.AddArc(ArcX2 + this.ShadowThickness, ArcY1 + this.ShadowThickness, ArcWidth, ArcHeight, 270, Tools.GroupBoxConstants.SweepAngle); //Top Right
                ShadowPath.AddArc(ArcX2 + this.ShadowThickness, ArcY2 + this.ShadowThickness, ArcWidth, ArcHeight, 360, Tools.GroupBoxConstants.SweepAngle); //Bottom Right
                ShadowPath.AddArc(ArcX1 + this.ShadowThickness, ArcY2 + this.ShadowThickness, ArcWidth, ArcHeight, 90, Tools.GroupBoxConstants.SweepAngle); //Bottom Left
				ShadowPath.CloseAllFigures();

				//Paint Rounded Rectangle------------
				g.FillPath(ShadowBrush, ShadowPath);
				//-----------------------------------
			}
			//-----------------------------------

			//Create Rounded Rectangle Path------
            path.AddArc(ArcX1, ArcY1, ArcWidth, ArcHeight, 180, Tools.GroupBoxConstants.SweepAngle); // Top Left
            path.AddArc(ArcX2, ArcY1, ArcWidth, ArcHeight, 270, Tools.GroupBoxConstants.SweepAngle); //Top Right
            path.AddArc(ArcX2, ArcY2, ArcWidth, ArcHeight, 360, Tools.GroupBoxConstants.SweepAngle); //Bottom Right
            path.AddArc(ArcX1, ArcY2, ArcWidth, ArcHeight, 90, Tools.GroupBoxConstants.SweepAngle); //Bottom Left
			path.CloseAllFigures(); 
			//-----------------------------------

			//Check if Gradient Mode is enabled--
			if(this.BackgroundGradientMode==GroupBoxGradientMode.None)
			{
				//Paint Rounded Rectangle------------
				g.FillPath(BackgroundBrush, path);
				//-----------------------------------
			}
			else
			{
				BackgroundGradientBrush = new LinearGradientBrush(new Rectangle(0,0,this.Width,this.Height), this.BackgroundColor, this.BackgroundGradientColor, (LinearGradientMode)this.BackgroundGradientMode);
				
				//Paint Rounded Rectangle------------
				g.FillPath(BackgroundGradientBrush, path);
				//-----------------------------------
			}
			//-----------------------------------

			//Paint Borded-----------------------
			g.DrawPath(BorderPen, path);
			//-----------------------------------

			//Destroy Graphic Objects------------
			if(path!=null){path.Dispose();}
			if(BorderBrush!=null){BorderBrush.Dispose();}
			if(BorderPen!=null){BorderPen.Dispose();}
			if(BackgroundGradientBrush!=null){BackgroundGradientBrush.Dispose();}
			if(BackgroundBrush!=null){BackgroundBrush.Dispose();}
			if(ShadowBrush!=null){ShadowBrush.Dispose();}
			if(ShadowPath!=null){ShadowPath.Dispose();}
			//-----------------------------------
		}
Ejemplo n.º 28
0
		/// <summary>
		/// Paints the shape on the canvas
		/// </summary>
		/// <param name="g"></param>
		/// 

		public override void Paint(System.Drawing.Graphics g)
		{
			g.SmoothingMode = SmoothingMode.AntiAlias;
			Rectangle toggleNode = Rectangle.Empty; //the [+] [-]
			Point[] pts = new Point[12]
				{
					new Point(rectangle.X,rectangle.Y), //0
					new Point(rectangle.X+bshift,rectangle.Y), //1
					new Point(rectangle.Right-bshift,rectangle.Y), //2
					new Point(rectangle.Right,rectangle.Y), //3
					new Point(rectangle.Right,rectangle.Y+bshift), //4
					new Point(rectangle.Right,rectangle.Bottom-bshift), //5
					new Point(rectangle.Right,rectangle.Bottom), //6
					new Point(rectangle.Right-bshift,rectangle.Bottom), //7
					new Point(rectangle.X+bshift,rectangle.Bottom), //8
					new Point(rectangle.X,rectangle.Bottom), //9
					new Point(rectangle.X,rectangle.Bottom - bshift), //10
					new Point(rectangle.X,rectangle.Y+bshift), //11				
			};
			path = new GraphicsPath();
			path.AddBezier(pts[11],pts[0],pts[0],pts[1]);
			path.AddLine(pts[1],pts[2]);
			path.AddBezier(pts[2],pts[3],pts[3],pts[4]);
			path.AddLine(pts[4],pts[5]);
			path.AddBezier(pts[5],pts[6],pts[6],pts[7]);
			path.AddLine(pts[7],pts[8]);
			path.AddBezier(pts[8],pts[9],pts[9],pts[10]);
			path.AddLine(pts[10],pts[11]);
			path.CloseFigure();
			region = new Region(path);

			shapeBrush = new LinearGradientBrush(rectangle,this.shapeColor,Color.WhiteSmoke,0f);
			
			// start Draw Shadow
			shadow = region.Clone();
			shadow.Translate(5, 5);
			

			//add the amount of children
			if (childNodes.Count > 0)
			{
				plus = " [" + childNodes.Count + "]";				
			}
			else
			{
				plus = "";
			}
			
			g.FillRegion(new SolidBrush(Color.Gainsboro), shadow);
			//g.DrawPath(new Pen(Color.Gainsboro,1), shadow);
			//End Draw Shadow

			g.FillRegion(shapeBrush, region);
			
			
            
			if (hovered || isSelected)			
				pen = thickPen;				
			else			
				pen = blackPen;				
			
			g.DrawPath(pen, path);
		
			if (text != string.Empty)
			{
				//g.DrawString(text + plus,font,Brushes.Black, rectangle.X+5,rectangle.Y+5);
				g.DrawString(text,font,Brushes.Black, rectangle.X+5,rectangle.Y+5);
			}

		

			//draw the [+] expansion shape
			if (childNodes.Count > 0)
			{
				switch(site.LayoutDirection)
				{
				
					case TreeDirection.Vertical:
						toggleNode = new Rectangle(Left + this.Width/2 - 5, Bottom, 10, 10);
						break;
					case TreeDirection.Horizontal:
						toggleNode = new Rectangle(Right , Top +Height/2-5 , 10, 10);
						break;
				}
				
                
				//Draw [ ]
				g.FillRectangle(new SolidBrush(Color.White), toggleNode);
				g.DrawRectangle(blackPen, toggleNode);
                
				//Draw -
				g.DrawLine(blackPen, (toggleNode.X + 2), (toggleNode.Y + (toggleNode.Height / 2)), (toggleNode.X + (toggleNode.Width - 2)), (toggleNode.Y + (toggleNode.Height / 2)) );
                
				if (!this.Expanded)
				{
					//Draw |
					g.DrawLine(blackPen, (toggleNode.X + (toggleNode.Width /2)), (toggleNode.Y + 2), (toggleNode.X + (toggleNode.Width /2)), (toggleNode.Y + (toggleNode.Height - 2)));
				}
			}
		}
Ejemplo n.º 29
0
 protected virtual void OnNCPaint(System.Drawing.Graphics g)
 {
     System.Drawing.Rectangle windowRect = new System.Drawing.Rectangle(new System.Drawing.Point(0, 0), base.Size);
     System.Drawing.Rectangle rectangle2 = this.OnNCCalcSize(windowRect);
     rectangle2.Offset(-windowRect.get_Left(), -windowRect.get_Top());
     g.ExcludeClip(rectangle2);
     windowRect.Offset(-windowRect.get_Left(), -windowRect.get_Top());
     System.Drawing.Brush brush = new System.Drawing.SolidBrush(this.BackColor);
     g.FillRectangle(brush, windowRect);
     brush.Dispose();
     System.Drawing.Pen pen = new System.Drawing.Pen(this.ForeColor, 2f);
     g.DrawPath(pen, this.path);
     pen.Dispose();
 }
Ejemplo n.º 30
0
        public override bool DrawString(
            System.Drawing.Graphics graphics,
            System.Drawing.FontFamily fontFamily,
            System.Drawing.FontStyle fontStyle,
            int fontSize,
            string strText,
            System.Drawing.Rectangle rtDraw,
            System.Drawing.StringFormat strFormat)
        {
            using (GraphicsPath path = new GraphicsPath())
            {
                path.AddString(strText, fontFamily, (int)fontStyle, fontSize, rtDraw, strFormat);

                using (Pen pen2 = new Pen(m_clrOutline2, m_nThickness1 + m_nThickness2))
                {
                    pen2.LineJoin = LineJoin.Round;
                    graphics.DrawPath(pen2, path);
                }
                using (Pen pen1 = new Pen(m_clrOutline1, m_nThickness1))
                {
                    pen1.LineJoin = LineJoin.Round;
                    graphics.DrawPath(pen1, path);
                }

                if (m_bClrText)
                {
                    using (SolidBrush brush = new SolidBrush(m_clrText))
                    {
                        graphics.FillPath(brush, path);
                    }
                }
                else
                    graphics.FillPath(m_brushText, path);
            }
            return true;
        }