Example #1
0
        protected override void DrawGraph(System.Drawing.Graphics g)
        {
            Rectangle.Height = Math.Max(80, Rectangle.Height);
            Rectangle.Width = Math.Max(40, Rectangle.Width);
            var rect = DrawRectangle.GetNormalizedRectangle(Rectangle);

            using (Pen pen = new Pen(PenColor, PenWidth))
            {
                var backRect = new Rectangle(rect.Left + 3, rect.Top + 3, rect.Width, rect.Height);
                g.FillRectangle(Brushes.LightGray, backRect);

                using (var brush = GetBrush(rect))
                {
                    var fillRect = new Rectangle(rect.Left, rect.Top, rect.Width, 20);
                    g.FillRectangle(brush, fillRect);
                }

                using (var brush = DrawRectangle.GetBackgroundBrush(rect, this.BackColor))
                {
                    var fillRect = new Rectangle(rect.Left, rect.Top + 20, rect.Width, rect.Height - 20);
                    g.FillRectangle(brush, fillRect);
                }

                var startPoint = new Point(Rectangle.Left, Rectangle.Top + 20);
                var endPoint = new Point(Rectangle.Right, Rectangle.Top + 20);
                g.DrawLine(pen, startPoint, endPoint);

                g.DrawRectangle(pen, rect);
            }
        }
        /// <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);
            }
        }
        public override void Paint(System.Drawing.Graphics g)
        {
            /*
            Matrix or = g.Transform;
            Matrix m = new Matrix();
            m.RotateAt(20, Rectangle.Location);
            g.MultiplyTransform(m, MatrixOrder.Append);
             */
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            //the shadow
            g.FillRectangle(ArtPallet.ShadowBrush, Rectangle.X + 5, Rectangle.Y + 5, Rectangle.Width, Rectangle.Height);
            //the actual bundle
            g.FillRectangle(ShapeBrush,Rectangle);
            //the edge of the bundle
            if(Hovered || IsSelected)
                g.DrawRectangle(ArtPallet.HighlightPen,Rectangle);
            else
                g.DrawRectangle(ArtPallet.BlackPen, Rectangle);
            //the connectors
            for(int k=0;k<Connectors.Count;k++)
            {
                Connectors[k].Paint(g);
            }

            //here we keep it really simple:
            if(!string.IsNullOrEmpty(Text))
                g.DrawString(Text, ArtPallet.DefaultFont, Brushes.Black, TextRectangle);
            //g.Transform = or;
        }
        public static void Draw3ColorBar(System.Drawing.Graphics dc, System.Drawing.RectangleF r, System.Windows.Forms.Orientation orientation, System.Drawing.Color c1, System.Drawing.Color c2,
            System.Drawing.Color c3)
        {
            // to draw a 3 color bar 2 gradient brushes are needed
            // one from c1 - c2 and c2 - c3
            var lr1 = r;
            var lr2 = r;
            float angle = 0;

            if (orientation == System.Windows.Forms.Orientation.Vertical)
            {
                angle = 270;

                lr1.Height = lr1.Height/2;
                lr2.Height = r.Height - lr1.Height;
                lr2.Y += lr1.Height;
            }
            if (orientation == System.Windows.Forms.Orientation.Horizontal)
            {
                angle = 0;

                lr1.Width = lr1.Width/2;
                lr2.Width = r.Width - lr1.Width;
                lr1.X = lr2.Right;
            }

            if (lr1.Height > 0 && lr1.Width > 0)
            {
                using (System.Drawing.Drawing2D.LinearGradientBrush lb2 = new System.Drawing.Drawing2D.LinearGradientBrush(lr2, c1, c2, angle, false),  lb1 = new System.Drawing.Drawing2D.LinearGradientBrush(lr1, c2, c3, angle, false) )
                {
                    dc.FillRectangle(lb1, lr1);
                    dc.FillRectangle(lb2, lr2);

                }

            }
            // with some sizes the first pixel in the gradient rectangle shows the opposite color
            // this is a workaround for that problem
            if (orientation == System.Windows.Forms.Orientation.Vertical)
            {
                using (System.Drawing.Pen pc2 = new System.Drawing.Pen(c2, 1), pc3 = new System.Drawing.Pen(c3, 1))
                {
                    dc.DrawLine(pc3, lr1.Left, lr1.Top, lr1.Right - 1, lr1.Top);
                    dc.DrawLine(pc2, lr2.Left, lr2.Top, lr2.Right - 1, lr2.Top);

                }
            }

            if (orientation == System.Windows.Forms.Orientation.Horizontal)
            {
                using (System.Drawing.Pen pc1 = new System.Drawing.Pen(c1, 1), pc2 = new System.Drawing.Pen(c2, 1), pc3 = new System.Drawing.Pen(c3, 1))
                {
                    dc.DrawLine(pc1, lr2.Left, lr2.Top, lr2.Left, lr2.Bottom - 1);
                    dc.DrawLine(pc2, lr2.Right, lr2.Top, lr2.Right, lr2.Bottom - 1);
                    dc.DrawLine(pc3, lr1.Right, lr1.Top, lr1.Right, lr1.Bottom - 1);

                }
            }
        }
Example #5
0
        /// <summary>
        /// 绘制方法
        /// </summary>
        /// <param name="g"></param>
        /// <param name="center"></param>
        /// <param name="zoom"></param>
        /// <param name="screen_size"></param>
        public override void Draw(System.Drawing.Graphics g, LatLngPoint center, int zoom, System.Drawing.Size screen_size)
        {
            if (Points != null && Points.Count >= 2)
            {
                g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                List<Point> l = new List<Point>();
                foreach (LatLngPoint p in Points)
                {
                    l.Add(MapHelper.GetScreenLocationByLatLng(p, center, zoom, screen_size));  //屏幕坐标
                }
                
                double total = 0; double step = 0;
                using (Pen pen = new Pen(Color.FromArgb(150, Color.OrangeRed), 4))
                {
                    for (int i = 0; i < l.Count - 1; ++i)
                    {
                        g.DrawLine(pen, l[i], l[i + 1]);
                        g.FillEllipse(Brushes.White, new Rectangle(new Point(l[i].X - 4, l[i].Y - 4), new Size(8, 8)));
                        g.DrawEllipse(Pens.OrangeRed, new Rectangle(new Point(l[i].X - 4, l[i].Y - 4), new Size(8, 8)));

                        if (i == 0)  //起点
                        {
                            g.FillRectangle(Brushes.White, new Rectangle(l[i].X + 3, l[i].Y, 35, 20));
                            g.DrawRectangle(Pens.DarkGray, new Rectangle(l[i].X + 3, l[i].Y, 35, 20));
                            g.DrawString("起点", new Font("微软雅黑", 9), Brushes.OrangeRed, new PointF(l[i].X + 6, l[i].Y + 2));

                            if (i == l.Count - 2)  //终点 只有两点的时候
                            {
                                step = MapHelper.GetDistanceByLatLng(Points[i], Points[i + 1]);
                                total += step;

                                g.FillRectangle(Brushes.White, new Rectangle(l[i + 1].X + 3, l[i + 1].Y, 90, 20));
                                g.DrawRectangle(Pens.DarkGray, new Rectangle(l[i + 1].X + 3, l[i + 1].Y, 90, 20));
                                g.DrawString("总长:" + Math.Round(total,2) + "公里", new Font("微软雅黑", 9), Brushes.OrangeRed, new PointF(l[i + 1].X + 10, l[i + 1].Y + 2));
                            }
                        }
                        else //其它点
                        {
                            step = MapHelper.GetDistanceByLatLng(Points[i-1], Points[i]);
                            total += step;

                            g.FillRectangle(Brushes.White, new Rectangle(l[i].X + 3, l[i].Y, 70, 20));
                            g.DrawRectangle(Pens.DarkGray, new Rectangle(l[i].X + 3, l[i].Y, 70, 20));
                            g.DrawString(Math.Round(step,2) + "公里", new Font("微软雅黑", 9), Brushes.OrangeRed, new PointF(l[i].X + 10, l[i].Y + 2));

                            if (i == l.Count - 2)  //终点
                            {
                                step = MapHelper.GetDistanceByLatLng(Points[i], Points[i + 1]);
                                total += step;
                                g.FillRectangle(Brushes.White, new Rectangle(l[i + 1].X + 3, l[i + 1].Y, 100, 20));
                                g.DrawRectangle(Pens.DarkGray, new Rectangle(l[i + 1].X + 3, l[i + 1].Y, 100, 20));
                                g.DrawString("总长:" + Math.Round(total, 2) + "公里", new Font("微软雅黑", 9), Brushes.OrangeRed, new PointF(l[i + 1].X + 10, l[i + 1].Y + 2));
                            }
                        }
                    }
                }
            }
        }
Example #6
0
        protected override void OnDraw(System.Drawing.Graphics graphics, System.Drawing.Color backgroundColor)
        {
            System.Drawing.SizeF size = graphics.MeasureString(lastFlow.ToString(),labelFont);
            graphics.FillRectangle(new System.Drawing.SolidBrush(backgroundColor), this.Location.X, this.Location.Y, size.Width, size.Height);
            lastFlow = Flow;

            base.OnDraw(graphics, backgroundColor);

            size = graphics.MeasureString(lastFlow.ToString(), labelFont);
            graphics.FillRectangle(new System.Drawing.SolidBrush(backgroundColor), this.Location.X, this.Location.Y, size.Width, size.Height);
            graphics.DrawRectangle(System.Drawing.Pens.Black, this.Location.X, this.Location.Y, size.Width, size.Height);
            graphics.DrawString(this.Flow.ToString(), labelFont, System.Drawing.Brushes.Black, this.Location);
        }
Example #7
0
        // -------------------------------------------------        Draw
        public override void Draw(System.Drawing.Graphics grfx)
        {
            Size sizeDelete = Auxi_Geometry.RoundMeasureString(Funclet.FormParent, DELETE_STRING, Funclet.FormParent.Font);
            Size sizeType = Auxi_Geometry.RoundMeasureString(Funclet.FormParent, STR_STRING, Funclet.FormParent.Font);
            Size sizeFunct = Auxi_Geometry.RoundMeasureString(Funclet.FormParent, strs[0], Funclet.FormParent.Font);

            grfx.FillRectangle(brushStandard, area);
            int dy = area.Height/strs.Count;
            int cxL = area.Left + wLeftSpace;
            int cy;
            if (iHighlighted >= 0)
            {
                cy = area.Top + dy*iHighlighted;
                grfx.FillRectangle(brushHighlight,
                                   Rectangle.FromLTRB(area.Left, cy, area.Right, cy + area.Height / strs.Count));
            }
            int cxR_line = area.Right - wLeftSpace;

            grfx.DrawString(strs[0], Funclet.FormParent.Font, brushLeaves, new Point(area.Left + ((area.Width - sizeType.Width - sizeFunct.Width) / 2), area.Top));
            grfx.DrawString(STR_STRING,Funclet.FormParent.Font, brushModify, new Point(area.Right - sizeType.Width, area.Top));
            grfx.DrawRectangle(penBorder, new Rectangle(new Point(area.Right - sizeType.Width, area.Top), sizeType ));

            for (int i = 1; i < strs.Count; i++)
            {
                if (iRightConnections[i] == -1)
                {
                    grfx.DrawString(strs[i], Funclet.FormParent.Font, brushLeaves, new Point(cxL, area.Top + i * dy));
                }
                else
                {
                    grfx.DrawString(strs[i], Funclet.FormParent.Font, brushTexts, new Point(cxL, area.Top + i * dy));
                }

                if (strs.Count >= 3)
                {
                    grfx.DrawString(ADD_STRING, Funclet.FormParent.Font, brushModify, new Point(area.Left + 1, area.Top + i * dy));
                }

                if (strs.Count > 3)
                {
                    grfx.DrawString(DELETE_STRING, Funclet.FormParent.Font, brushModify, new Point(area.Right - sizeDelete.Width, area.Top + i * dy));
                }

                cy = area.Top + i*dy;
                grfx.DrawLine(penSeparator, area.Left, cy, area.Right, cy);
            }
            grfx.DrawRectangle(penBorder, area);
        }
Example #8
0
            public override void DrawBg(System.Drawing.Graphics g, System.Drawing.Rectangle rect, System.Drawing.Drawing2D.SmoothingMode smooth)
            {
                using (SolidBrush backBrush = new SolidBrush(BgColor))
                    g.FillRectangle(backBrush, rect);

                g.SmoothingMode = smooth;
            }
Example #9
0
        public override void Draw(System.Drawing.Graphics g)
        {
            #if DEBUG
            Console.WriteLine("Zone");
            #endif
            GraphicsState gState = g.Save();
            //Matrix scaleM = new Matrix();
            //scaleM.Scale(1, 1);

            //scaleM.TransformPoints(arrPoints);

            base.translationMatrix.Reset();
            base.translationMatrix.Translate(this.Position.X, this.Position.Y);
            g.MultiplyTransform(base.translationMatrix, MatrixOrder.Prepend);
            g.FillRectangle(Brushes.Blue, 0, 0, 500, 250);
            //g.FillRectangle(Brushes.Blue, 0, 0, 500, 250);

            foreach (IDrawable e in cards)
            {
                if (e.Visible)
                {
                    e.Draw(g);
                }
            }
            g.Restore(gState);
        }
        protected override void Paint(System.Drawing.Graphics g, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
        {
            try
            {
                int progressVal = (int)value;
                if(progressVal < 0) progressVal = 0;
                if(progressVal > 100) progressVal = 100;
                float percentage = ((float)progressVal / 100.0f);

                Brush backColorBrush = new SolidBrush(cellStyle.BackColor);
                Brush foreColorBrush = new SolidBrush(cellStyle.ForeColor);
                Brush barColorBrush = new SolidBrush(GetColorBetween(cellStyle.BackColor,
                    cellStyle.ForeColor, progressVal == 100 ? 0.2f : 0.3f));

                base.Paint(g, clipBounds, cellBounds,
                    rowIndex, cellState, value, formattedValue, errorText,
                    cellStyle, advancedBorderStyle, (paintParts & ~DataGridViewPaintParts.ContentForeground));

                var s = progressVal.ToString() + "%";
                var sz = g.MeasureString(s, cellStyle.Font);
                int dy = (cellBounds.Height - this.DataGridView.RowTemplate.Height) / 2;

                g.FillRectangle(barColorBrush, cellBounds.X + 2, cellBounds.Y + 2, Convert.ToInt32((percentage * cellBounds.Width - 4)), cellBounds.Height - 4);
                g.DrawString(s, cellStyle.Font, foreColorBrush, cellBounds.X + (cellBounds.Width / 2) - sz.Width / 2 - 5, cellBounds.Y + 2 + dy);
            }
            catch (Exception e) { }
        }
Example #11
0
        /// <summary>
        /// Draw the gridlines.
        /// </summary>
        /// <param name="graphics">Reference to the GDI+ drawing surface.</param>
		public void Draw(System.Drawing.Graphics graphics)
		{
			using (Pen graphAreaPen = new Pen(m_ParentGraph.GridlineColor))
			{
				graphAreaPen.DashStyle = DashStyle.Dash;
				using (Brush graphAreaBrush = new SolidBrush(m_ParentGraph.GraphAreaColor))
				{
					graphics.FillRectangle(graphAreaBrush, m_ParentGraph.GraphArea);
					graphics.DrawRectangle(graphAreaPen, m_ParentGraph.GraphArea);

					if ((m_ParentGraph.Gridlines & GridStyles.Horizontal) == GridStyles.Horizontal)
					{
						graphics.SetClip(m_ParentGraph.GraphArea);

						int gridSize = m_ParentGraph.GraphArea.Height / m_ParentGraph.GraduationsY;
						for (int i = 0; i < m_ParentGraph.GraphArea.Height; i += gridSize)
						{
							graphics.DrawLine(graphAreaPen, m_ParentGraph.GraphArea.Left, m_ParentGraph.GraphArea.Top + i, m_ParentGraph.GraphArea.Right, m_ParentGraph.GraphArea.Top + i);
						}
					}

					if ((m_ParentGraph.Gridlines & GridStyles.Vertical) == GridStyles.Vertical)
					{
						graphics.SetClip(m_ParentGraph.GraphArea);

						int gridSize = m_ParentGraph.GraphArea.Width / m_ParentGraph.GraduationsX;
						for (int i = 0; i < m_ParentGraph.GraphArea.Width; i += gridSize)
						{
							graphics.DrawLine(graphAreaPen, m_ParentGraph.GraphArea.Left + i, m_ParentGraph.GraphArea.Bottom, m_ParentGraph.GraphArea.Left + i, m_ParentGraph.GraphArea.Top);
						}
					}
				}
			}
        }
Example #12
0
        protected override void Paint(System.Drawing.Graphics g, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
        {
            try
            {
                int progressVal = (int)value;
                float percentage = ((float)progressVal / 100.0f); // Need to convert to float before division; otherwise C# returns int which is 0 for anything but 100%.
                Brush backColorBrush = new SolidBrush(cellStyle.BackColor);
                Brush foreColorBrush = new SolidBrush(cellStyle.ForeColor);
                // Draws the cell grid
                base.Paint(g, clipBounds, cellBounds,
                 rowIndex, cellState, value, formattedValue, errorText,
                 cellStyle, advancedBorderStyle, (paintParts & ~DataGridViewPaintParts.ContentForeground));
                if (percentage > 0.0)
                {
                    // Draw the progress bar and the text
                    g.FillRectangle(new SolidBrush(Color.FromArgb(203, 235, 108)), cellBounds.X + 2, cellBounds.Y + 2, Convert.ToInt32((percentage * cellBounds.Width - 4)), cellBounds.Height - 4);
                    g.DrawString(progressVal.ToString() + "%", cellStyle.Font, foreColorBrush, cellBounds.X + (cellBounds.Width / 2) - 5, cellBounds.Y + 2);

                }
                else
                {
                    g.DrawString("Ожидание...", cellStyle.Font, foreColorBrush, cellBounds.X + (cellBounds.Width / 2) - 25, cellBounds.Y + 2);
                }
            }
            catch (Exception e) { }
        }
Example #13
0
	public void  paint(System.Drawing.Graphics g, System.Windows.Forms.Control c)
	{
		//UPGRADE_TODO: The equivalent in .NET for method 'java.awt.Graphics.getFont' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
		System.Drawing.Font font = SupportClass.GraphicsManager.manager.GetFont(g);
		System.Drawing.Font metrics = SupportClass.GraphicsManager.manager.GetFont(g);
		//UPGRADE_TODO: Class 'java.awt.font.FontRenderContext' was converted to 'System.Windows.Forms.Control' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
		//UPGRADE_ISSUE: Constructor 'java.awt.font.FontRenderContext.FontRenderContext' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javaawtfontFontRenderContextFontRenderContext_javaawtgeomAffineTransform_boolean_boolean'"
           System.Drawing.Text.TextRenderingHint frc = TextRenderingHint.AntiAlias; //  new FontRenderContext(null, false, false);
		System.Drawing.Size size = c.Size;
		SupportClass.GraphicsManager.manager.SetColor(g, c.BackColor);
		g.FillRectangle(SupportClass.GraphicsManager.manager.GetPaint(g), 0, 0, size.Width, size.Height);
		SupportClass.GraphicsManager.manager.SetColor(g, c.ForeColor);
		g.DrawRectangle(SupportClass.GraphicsManager.manager.GetPen(g), 0, 0, size.Width - 1, size.Height - 1);
		if (strs != null)
		{
			int y = 0;
			for (int i = 0; i < strs.Length; i++)
			{
				// TODO: use render hint? frc
				y += (int) g.MeasureString(strs[i], font).Height + 2;
				//UPGRADE_TODO: Method 'java.awt.Graphics.drawString' was converted to 'System.Drawing.Graphics.DrawString' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaawtGraphicsdrawString_javalangString_int_int'"
				g.DrawString(strs[i], SupportClass.GraphicsManager.manager.GetFont(g), SupportClass.GraphicsManager.manager.GetBrush(g), 3, y - SupportClass.GraphicsManager.manager.GetFont(g).GetHeight());
				//g.drawString(strs[i],3,(metrics.getHeight())*(i+1));
			}
		}
	}
        protected override void Paint(System.Drawing.Graphics g, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
        {
            Tuple<int, string> updateInfo = (Tuple<int, string>)value;
            int progressVal = updateInfo.Item1;
            string message = updateInfo.Item2;

            float percentage = ((float)progressVal / 100.0f); // Need to convert to float before division; otherwise C# returns int which is 0 for anything but 100%.
            Brush backColorBrush = new SolidBrush(cellStyle.BackColor);
            Brush foreColorBrush = new SolidBrush(cellStyle.ForeColor);
            // Draws the cell grid
            base.Paint(g, clipBounds, cellBounds,
             rowIndex, cellState, value, formattedValue, errorText,
             cellStyle, advancedBorderStyle, (paintParts & ~DataGridViewPaintParts.ContentForeground));

            
            if (percentage > 0.0)
            {
                // Draw the progress bar and the text
                g.FillRectangle(new SolidBrush(Color.FromArgb(163, 189, 242)), cellBounds.X + 2, cellBounds.Y + 2, Convert.ToInt32((percentage * cellBounds.Width - 4)), cellBounds.Height - 4);
                g.DrawString(message, cellStyle.Font, foreColorBrush, cellBounds.X + 6, cellBounds.Y + 2);
            }
            else
            {
                // draw the text
                if (this.DataGridView.CurrentRow.Index == rowIndex)
                    g.DrawString(message, cellStyle.Font, new SolidBrush(cellStyle.SelectionForeColor), cellBounds.X + 6, cellBounds.Y + 2);
                else
                    g.DrawString(message, cellStyle.Font, foreColorBrush, cellBounds.X + 6, cellBounds.Y + 2);
            }
        }
        public void Draw(System.Drawing.Graphics graphics, System.Drawing.Rectangle bounds)
        {
            float length = (float)this.manager.Progress / 100.0f;

			using (LinearGradientBrush complete = new LinearGradientBrush(bounds, Color.LightBlue, Color.Blue, LinearGradientMode.Horizontal))
            using (SolidBrush incomplete = new SolidBrush(Color.White))
            using(StringFormat format = new StringFormat())
            using(SolidBrush text = new SolidBrush(Color.Black))
            {
				complete.SetSigmaBellShape(1.0f, 0.25f);
                format.Alignment = StringAlignment.Center;
				graphics.FillRectangle(complete, bounds.X, bounds.Y + borderHeight, bounds.Width * length, bounds.Height - 2 * borderHeight);
				graphics.FillRectangle(incomplete, bounds.X + (bounds.Width * length), bounds.Y + borderHeight, bounds.Width - bounds.Width * length, bounds.Height - 2 * borderHeight);
                graphics.DrawString(string.Format("{0:0.00} %",this.manager.Progress), new Font(FontFamily.GenericSansSerif, 7), text, bounds, format); 
            }
        }
Example #16
0
        public override void Paint(System.Drawing.Graphics g)
        {
            if(g == null)
                throw new ArgumentNullException("The Graphics object is 'null'.");

            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            //the shadow
            g.FillRectangle(ArtPallet.ShadowBrush, Rectangle.X + 5, Rectangle.Y + 5, Rectangle.Width, Rectangle.Height);
            //the container
            g.FillRectangle(ShapeBrush,Rectangle);
            //the edge
            if(Hovered || IsSelected)
                g.DrawRectangle(new Pen(Color.Red,2F),Rectangle);
            //the text
            if(!string.IsNullOrEmpty(Text ))
                g.DrawString(Text, ArtPallet.DefaultFont, Brushes.Black, Rectangle);
        }
Example #17
0
        public void Draw(System.Drawing.Graphics g)
        {
            GraphicsState gs = g.Save();

            g.FillRectangle(new SolidBrush(Color.FromArgb(127, Color.LightBlue)), HighlightRectangle);

            g.Restore(gs);
        }
Example #18
0
 public override void Draw(System.Drawing.Graphics g)
 {
     System.Drawing.SolidBrush solidBrush = new System.Drawing.SolidBrush(Color);
     System.Drawing.PointF upperLeftPoint = new System.Drawing.PointF((float)(Center.X - Width / 2), (float)(Center.Y - Height / 2));
     System.Drawing.SizeF rectSize = new System.Drawing.SizeF((float)Width, (float)Height);
     System.Drawing.RectangleF rect = new System.Drawing.RectangleF(upperLeftPoint, rectSize);
     g.FillRectangle(solidBrush, rect);
     solidBrush.Dispose();
 }
Example #19
0
            public override void DrawHeaderBg(System.Drawing.Graphics g, System.Drawing.Rectangle rect)
            {
                if (HeaderBgGradient)
                {
                    using (LinearGradientBrush aGB = new LinearGradientBrush(rect, HeaderBgColor, HeaderBgColor2, LinearGradientMode.Vertical))
                        g.FillRectangle(aGB, rect);
                }
                else
                {
                    using (SolidBrush backBrush = new SolidBrush(HeaderBgColor))
                        g.FillRectangle(backBrush, rect);
                }

                if (HasHorizontalLine)
                {
                    using (Pen aPen = new Pen(GridColor))
                        g.DrawLine(aPen, rect.Left, rect.Bottom, rect.Right, rect.Bottom);
                }
            }
        public void Draw(System.Drawing.Graphics myGraphics)
        {
            System.Drawing.Brush myBrush = new System.Drawing.SolidBrush(this.color);

            myGraphics.FillRectangle(myBrush,
                                     this.position.get_x()-this.width/2,
                                     this.position.get_y()-this.height/2,
              this.width,
              this.height);
        }
Example #21
0
 public override void Draw(System.Drawing.Graphics g, int panX, int panY)
 {
     int tempx1 = x1 - panX;
     int tempx2 = x2 - panX;
     int tempy1 = y1 - panY;
     int tempy2 = y2 - panY;
     if (needFilling)
         g.FillRectangle(filling, tempx1, tempy1, tempx2 - tempx1, tempy2 - tempy1);
     if (needOutline)
         g.DrawRectangle(outline, tempx1, tempy1, tempx2 - tempx1, tempy2 - tempy1);
 }
Example #22
0
 public void Draw(System.Drawing.Graphics vrpContext)
 {
     int namevalue;
     int x;
     FontFamily fontFamily = new FontFamily("Arial");
     vrpContext.FillRectangle(new SolidBrush(ColorProp),
       Rectangle);
     namevalue = Name.Length * 4;
     x = (Rectangle.X + (Rectangle.Width) / 2) - namevalue;
     vrpContext.DrawString(this.Name,new Font(fontFamily,16,FontStyle.Regular,GraphicsUnit.Pixel),new SolidBrush(Color.Black),new PointF(x,Rectangle.Y +( Rectangle.Height)/2));
 }
Example #23
0
 public void Draw(System.Drawing.Graphics g, System.Drawing.PointF Where, double ScaleFactor = 1)
 {
     Size Size = this.Size;
     Size.Width *= ScaleFactor;
     Size.Height *= ScaleFactor;
     Where.X *= (float)ScaleFactor;
     Where.Y *= (float)ScaleFactor;
     System.Drawing.Pen penBlack = new System.Drawing.Pen(System.Drawing.Color.Black, 1);
     //Рисуем прямоугольник
     System.Drawing.Brush brushGradient = new System.Drawing.Drawing2D.LinearGradientBrush(
         new System.Drawing.PointF(Where.X, Where.Y),
         new System.Drawing.PointF(Where.X + (float)Size.Width - 1, Where.Y + (float)Size.Height - 1),
         Xwt.Ext.CanvasSystemDrawing.DrawingExtensions.ToWindowsColor(this.Color),
         Xwt.Ext.CanvasSystemDrawing.DrawingExtensions.ToWindowsColor(this.Color.BlendWith(Colors.White, 0.8))
     );
     g.FillRectangle(brushGradient, Where.X, Where.Y, (float)Size.Width - 1, (float)Size.Height - 1);
     float Factor = (this.DrawDescription) ? 3 : 2;
     if (!DrawImg || Img == null)
     {
         g.DrawString(this.Text,
             new System.Drawing.Font(Font.Family, (float)Font.Size),
             new System.Drawing.SolidBrush(System.Drawing.Color.Black),
             new System.Drawing.RectangleF(Where.X,
                 Where.Y + ((float)Size.Height - 1) / Factor - (float)Font.Size / 2,
                 (float)Size.Width - 1,
                 (float)Size.Height - 1),
             new System.Drawing.StringFormat() { Alignment = System.Drawing.StringAlignment.Center }
             );
         if (DrawDescription)
             g.DrawString(this.Description,
                 new System.Drawing.Font(DescriptionFont.Family, (float)DescriptionFont.Size),
                 new System.Drawing.SolidBrush(System.Drawing.Color.Black),
                 new System.Drawing.RectangleF(Where.X,
                     Where.Y + 2 * ((float)Size.Height - 1) / 3 - (float)Font.Size / 2,
                     (float)Size.Width - 1,
                     (float)Size.Height - 1),
                 new System.Drawing.StringFormat() { Alignment = System.Drawing.StringAlignment.Center }
                 );
     }
     else
     {
         g.DrawImage(Img, new System.Drawing.Rectangle((int)(Where.X + 0 * Size.Width / 8f) + 1, (int)(Where.Y + 0 * Size.Height / 10f) + 1, (int)(8 * Size.Width / 8f) - 1, (int)(8 * Size.Height / 8f) - 1));
         g.DrawAdaptiveString(this.Text,
                              new System.Drawing.Font(Font.Family, (float)Font.Size),
                              new System.Drawing.SolidBrush(System.Drawing.Color.Black),
                              new System.Drawing.RectangleF(Where.X,
                                                            Where.Y + ((float)Size.Height - 1) * 0.865f,
                                                            (float)Size.Width - 1,
                                                            (float)Size.Height * 0.13f),
                              new System.Drawing.StringFormat() { Alignment = System.Drawing.StringAlignment.Center }
                              );
     }
     g.DrawRectangle(new System.Drawing.Pen(System.Drawing.Color.Gray), Where.X, Where.Y, (float)Size.Width - 1, (float)Size.Height - 1);
 }
 protected override void Paint(System.Drawing.Graphics graphics, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
 {
     Point cursorPos = this.DataGridView.PointToClient(Cursor.Position);
     //if (cellBounds.Contains(cursorPos))
     if (Selected)
         base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);
     else
     {
         graphics.FillRectangle(Brushes.LightGray, cellBounds);
     }
 }
        public void DrawBackground(System.Drawing.Graphics graphics, System.Drawing.Rectangle bounds, System.Drawing.Color backColor)
        {
            graphics.FillRectangle(new SolidBrush(backColor), bounds);

            using (Pen borderPen = new Pen(_ProfessionalColorTable.ToolStripBorder, 1))
            {
                bounds.Width--;
                bounds.Height--;

                graphics.DrawRectangle(borderPen, bounds);
            }
        }
        public void Draw(System.Drawing.Graphics graphics, System.Drawing.Rectangle bounds)
        {
            float width = (float)bounds.Width / args.Piece.BlockCount;
            RectangleF brushDimensions = new RectangleF(0, 0, width, bounds.Height);
            using (LinearGradientBrush requestedBrush = new LinearGradientBrush(brushDimensions, Color.LightBlue, Color.Blue, LinearGradientMode.Vertical))
            using (LinearGradientBrush receivedBrush = new LinearGradientBrush(brushDimensions, Color.LightGoldenrodYellow, Color.Goldenrod, LinearGradientMode.Vertical))
            using (LinearGradientBrush writtenBrush = new LinearGradientBrush(brushDimensions, Color.LightGreen, Color.LimeGreen, LinearGradientMode.Vertical))
            using (LinearGradientBrush notRequestedBrush = new LinearGradientBrush(brushDimensions, Color.LightSalmon, Color.Red, LinearGradientMode.Vertical))
            using (LinearGradientBrush pendingHashCheck = new LinearGradientBrush(brushDimensions, Color.BurlyWood, Color.Brown, LinearGradientMode.Vertical))
            {
                requestedBrush.SetSigmaBellShape(0.25f);
                receivedBrush.SetSigmaBellShape(0.25f);
                writtenBrush.SetSigmaBellShape(0.25f);
                notRequestedBrush.SetSigmaBellShape(0.25f);
                pendingHashCheck.SetSigmaBellShape(0.25f);

                Rectangle rect = bounds;
                
                for (int i = 0; i < this.args.Piece.BlockCount; i++)
                {
                    RectangleF newArea = new RectangleF(rect.X + (width * i), rect.Y + borderHeight, width, rect.Height - 2 * borderHeight);
                    if (this.args.Piece.AllBlocksReceived)
                        graphics.FillRectangle(pendingHashCheck, newArea);

                    else if (args.Piece[i].Written)
                        graphics.FillRectangle(writtenBrush, newArea);

                    else if (args.Piece[i].Received)
                        graphics.FillRectangle(receivedBrush, newArea);

                    else if (args.Piece[i].Requested)
                        graphics.FillRectangle(requestedBrush, newArea);

                    else
                        graphics.FillRectangle(notRequestedBrush, newArea);
                }
            }
        }
Example #27
0
        /// <summary>
        /// 绘制方法
        /// </summary>
        /// <param name="g"></param>
        /// <param name="center"></param>
        /// <param name="zoom"></param>
        /// <param name="screen_size"></param>
        public override void Draw(System.Drawing.Graphics g, LatLngPoint center, int zoom, System.Drawing.Size screen_size)
        {
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            Point theScreenLeftTop = MapHelper.GetScreenLocationByLatLng(LeftTop, center, zoom, screen_size);  //矩形左上角屏幕坐标
            Point theScreenRightBottom = MapHelper.GetScreenLocationByLatLng(RightBottom, center, zoom, screen_size);  //矩形右下角屏幕坐标

            int width = Math.Abs(theScreenRightBottom.X - theScreenLeftTop.X);
            int height = Math.Abs(theScreenRightBottom.Y - theScreenLeftTop.Y);
            Rectangle r = new Rectangle(Math.Min(theScreenLeftTop.X, theScreenRightBottom.X), Math.Min(theScreenLeftTop.Y, theScreenRightBottom.Y), width, height);
            if (new Rectangle(new Point(0, 0), screen_size).IntersectsWith(r))
            {
                using (SolidBrush sb = new SolidBrush(Color.FromArgb(15, Color.DarkBlue)))
                {
                    g.FillRectangle(sb, r);
                }
                using (Pen pen = new Pen(Color.FromArgb(150,Color.DarkBlue), 2))
                {
                    g.DrawRectangle(pen, r);
                }
            }

            double d1 = MapHelper.GetDistanceByLatLng(LeftTop, new LatLngPoint(LeftTop.Lng, RightBottom.Lat));
            double d2 = MapHelper.GetDistanceByLatLng(LeftTop, new LatLngPoint(RightBottom.Lng, LeftTop.Lat));
            double d3 = MapHelper.GetDistanceByLatLng(new LatLngPoint(LeftTop.Lng, RightBottom.Lat), RightBottom);
            double d4 = MapHelper.GetDistanceByLatLng(new LatLngPoint(RightBottom.Lng, LeftTop.Lat), RightBottom);

            using (Font f = new Font("微软雅黑", 9))
            {
                g.FillRectangle(Brushes.DarkBlue, new Rectangle(theScreenLeftTop.X, (theScreenLeftTop.Y + theScreenRightBottom.Y) / 2 - 10, 60, 20));
                g.DrawString(Math.Round(d1, 2).ToString() + "km", f, Brushes.White, new PointF(theScreenLeftTop.X + 5, (theScreenLeftTop.Y + theScreenRightBottom.Y) / 2 - 8));
                g.FillRectangle(Brushes.DarkBlue, new Rectangle((theScreenLeftTop.X + theScreenRightBottom.X) / 2 - 30, theScreenLeftTop.Y, 60, 20));
                g.DrawString(Math.Round(d2, 2).ToString() + "km", f, Brushes.White, new PointF((theScreenLeftTop.X + theScreenRightBottom.X) / 2 - 30 + 5, theScreenLeftTop.Y + 2));
                g.FillRectangle(Brushes.DarkBlue, new Rectangle((theScreenLeftTop.X + theScreenRightBottom.X) / 2 - 30, theScreenRightBottom.Y - 20, 60, 20));
                g.DrawString(Math.Round(d3, 2).ToString() + "km", f, Brushes.White, new PointF((theScreenLeftTop.X + theScreenRightBottom.X) / 2 - 30 + 5, theScreenRightBottom.Y + 4 - 20));
                g.FillRectangle(Brushes.DarkBlue, new Rectangle(theScreenRightBottom.X - 60, (theScreenLeftTop.Y + theScreenRightBottom.Y) / 2 - 10, 60, 20));
                g.DrawString(Math.Round(d4, 2).ToString() + "km", f, Brushes.White, new PointF(theScreenRightBottom.X - 60 + 3, (theScreenLeftTop.Y + theScreenRightBottom.Y) / 2 - 10));
            }
        }
Example #28
0
        /// <summary>
        /// Paints the shape on the canvas
        /// </summary>
        /// <param name="g"></param>
        public override void Paint(System.Drawing.Graphics g)
        {
            g.FillRectangle(shapeBrush,rectangle);
            if(hovered || isSelected)
                g.DrawRectangle(new Pen(Color.Red,2F),rectangle);

            //well, a lot should be said here like
            //the fact that one should measure the text before drawing it,
            //resize the width and height if the text if bigger than the rectangle,
            //alignment can be set and changes the drawing as well...
            //here we keep it really simple:
            if(text !=string.Empty)
                g.DrawString(text,font,Brushes.Black, rectangle.X+10,rectangle.Y+10);
        }
        public static void Draw2ColorBar(System.Drawing.Graphics dc, System.Drawing.RectangleF r, System.Windows.Forms.Orientation orientation, System.Drawing.Color c1, System.Drawing.Color c2)
        {
            var lr1 = r;
            float angle = 0;

            if (orientation == System.Windows.Forms.Orientation.Vertical)
            {angle = 270;}
            if (orientation == System.Windows.Forms.Orientation.Horizontal)
            {angle = 0;}

            if (lr1.Height > 0 && lr1.Width > 0)
            {
                using (var lb1 = new System.Drawing.Drawing2D.LinearGradientBrush(lr1, c1, c2, angle, false))
                {dc.FillRectangle(lb1, lr1);}
            }
        }
Example #30
0
        public override void Paint(System.Drawing.Graphics g)
        {
            NodeCount = 0;

            if (osmTree != null)
            {
                foreach (Node node in osmTree.Nodes)
                {
                    if (NodeCount < maxNodeCount)
                    {

                        Coordinate objectCoord = new Coordinate(node.Lat, node.Lon);

                        if ((leftBottom.Longitude < objectCoord.Longitude) && (objectCoord.Longitude < rightTop.Longitude)
                            && ((leftBottom.Latitude < objectCoord.Latitude) && (objectCoord.Latitude < rightTop.Latitude)))
                        {
                            Point drawAt = CalculateScreenPos(objectCoord);

                            if ((node.DrawIcon != null) && (node.DrawIcon.Length > 0))
                            {
                                DrawIcon(g, node.DrawIcon, drawAt);
                            }
                            else
                            {
                                g.FillRectangle(Brushes.Gray, drawAt.X - 2, drawAt.Y - 2, 5, 5);
                            }

                            if ((node.DrawText!= null )&&(node.DrawText.Length > 0))
                            {
                                DrawStringWhiteShadow(g, node.DrawText, Brushes.Black, drawAt);
                            }

                            NodeCount++;
                        }
                    }
                    else
                    {
                        Point drawAt = CalculateScreenPos(centerCoord);
                        g.DrawString(Descripton + " max node count reached!", SystemFonts.StatusFont, Brushes.Red, drawAt);

                        break;
                    }

                }
            }
        }