Exemple #1
0
 protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
 {
     drawingContext.DrawRectangle(Brushes.Red, null, new System.Windows.Rect(0, 0, 5, 5));
     drawingContext.DrawRectangle(Brushes.Red, null, new System.Windows.Rect(0, ActualHeight - 5, 5, 5));
     drawingContext.DrawRectangle(Brushes.Red, null, new System.Windows.Rect(ActualWidth - 5, 0, 5, 5));
     drawingContext.DrawRectangle(Brushes.Red, null, new System.Windows.Rect(ActualWidth - 5, ActualHeight - 5, 5, 5));
 }
 public override void Draw(System.Drawing.Graphics g) {
     if (Bounds.IsEmpty) return;
     GPoint p1 = map.FromLatLngToLocal(Bounds.LocationTopLeft);
     GPoint p2 = map.FromLatLngToLocal(Bounds.LocationRightBottom);
     Font font = new Font(FontFamily.GenericSansSerif, 30, FontStyle.Bold);
     SizeF fs = g.MeasureString(Title, font);
     int x1 = p1.X;
     int y1 = p1.Y;
     int x2 = p2.X;
     int y2 = p2.Y;
     Rectangle r1 = new Rectangle(x1, y1 - (int)fs.Height, x2 - x1, y2 - y1 + (int)fs.Height);
     if (sbTable != null) {
         tableHeight = (int)(map.Font.GetHeight(g) * (sbTable.Rows.Count + 1));
         tableWidth = 60 * 3;
         tableRect = new Rectangle(r1.Right, r1.Top + (int)fs.Height, tableWidth, tableHeight);
         r1.Width += tableWidth;
         r1.Height = (int)Math.Max(r1.Height, 2 * fs.Height + tableHeight);
         tableRect.Y = r1.Bottom - tableRect.Height - 1;
     }
     Rectangle r2 = r1;
     r2.Inflate(5, 5);
     Point p3 = new Point(r1.Left + (r1.Width - (int)fs.Width) / 2, r1.Top + 5);
     g.DrawString(Title, font, Brushes.Black, p3);
     g.DrawRectangle(penin, r1);
     g.DrawRectangle(penout, r2);
     
     //drawsbtjInfo(g, tableRect.Location);
 }
        public override void paint(System.Drawing.Graphics g)
        {
            threadName = Thread.CurrentThread.Name;

            try

            {

                //sleep thread based upon chosen speed
                Thread.Sleep(speed);

                //draw over object on screen in white
                g.DrawRectangle(new Pen(Color.White), xLoc, yLoc, width, height);

                //lock thread to update location
                lock (typeof(Thread))
                {
                        xLoc = xLoc + base.directionX;
                        yLoc = yLoc + base.directionY;
                        //check if it hits the edges of the screen
                        base.checkEdgeCollision();

                }

                //draw object in new location
                 g.DrawRectangle(new Pen(color), xLoc, yLoc, width, height);

            }
            catch(Exception e )
            {
                System.Console.WriteLine("Error in Thread Drawing" + e);
            }
        }
Exemple #4
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));
                            }
                        }
                    }
                }
            }
        }
        public void Render(System.Drawing.Graphics graphics)
        {
            Pen pen = new System.Drawing.Pen(System.Drawing.Color.Salmon);

            graphics.DrawLine(pen, 0, 0, 200, 0);
            graphics.DrawLine(pen, 0, 0, 0, 200);
            graphics.DrawRectangle(pen, 0, 0, 20, 20);
            graphics.DrawRectangle(pen, -20, -20, 20, 20);
        }
 protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
 {
     System.Windows.Media.Media3D.Size3D size = (agentBase as BusAgent).Size;
     drawingContext.PushTransform(new TranslateTransform(Location.X - size.X / 4 , Location.Y));
     drawingContext.PushTransform(new RotateTransform((agentBase as BusAgent).Angle));
     drawingContext.DrawRectangle(GetGroupColor(agentBase.Group), null, new Rect(-size.X / 4, -size.Y / 2, size.X, size.Y));
     drawingContext.DrawRectangle(Brushes.LightBlue, null, new Rect(size.X / 4 * 3 - 2, -size.Y / 2, 2, size.Y));
     drawingContext.Pop();
     drawingContext.Pop();
 }
Exemple #7
0
        protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
        {
            if (!SkipFill && _backgroundFillBrush != null)
            {
                drawingContext.DrawRectangle(_backgroundFillBrush, null, _monitorRect);
            }

            if (_backgroundImageBrush != null)
            {
                drawingContext.DrawRectangle(_backgroundImageBrush, null, _monitorRect);
            }
        }
 protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
 {
     if (!MbRect.IsEmpty)
     {
         drawingContext.DrawRectangle(m_Brush, m_Pen, m_MbRect);
     }
 }
		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 OnRender(System.Windows.Media.DrawingContext drawingContext)
        {
            base.OnRender(drawingContext);

            // drawingContext.DrawRectangle(Brushes.Transparent, null, new Rect(RenderSize));
            drawingContext.DrawRectangle(SelectionBackgound, SelectionBorder, new Rect(this.startPoint, this.endPoint));
        }
Exemple #11
0
		public static void DrawRectangle(System.Drawing.Graphics g, System.Drawing.Pen pen,  int x, int y, int width, int height)
		{
			// Fix for GDI issue
			width--;
			height--;
			g.DrawRectangle(pen,x,y,width,height);
		}
Exemple #12
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);
						}
					}
				}
			}
        }
Exemple #13
0
        protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
        {
            base.OnRender(drawingContext);

            SolidColorBrush blackBrush = new SolidColorBrush(Color.FromRgb(0, 0, 0));
            SolidColorBrush greenBrush = new SolidColorBrush(Color.FromRgb(0, 128, 0));
            SolidColorBrush redBrush = new SolidColorBrush(Color.FromRgb(200, 0, 0));
            Pen blackPen = new Pen(blackBrush, 1);
            Pen greenPen = new Pen(greenBrush, 1);
            Pen redPen = new Pen(redBrush, 1);

            drawingContext.DrawRectangle(null, blackPen, _size);

            if (Universe == null)
                return;

            foreach (FoodElement element in Universe.Food)
            {
                drawingContext.DrawEllipse(null, greenPen, new Point(element.CenterX, element.CenterY), element.Width, element.Width);
            }

            foreach (CreatureElement creature in Universe.Creatures)
            {
                drawingContext.DrawEllipse(null, redPen, new Point(creature.CenterX, creature.CenterY), creature.Width, creature.Width);
            }
        }
Exemple #14
0
        protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
        {
            if (editorModel == null) return;

               foreach (var c in model.Chunks)
               foreach (var r in GetRects(c))
               {
                   drawingContext.DrawRectangle(fills[(int)c.Mode], borderPen, r);
                   if (c.StartsNewEpisode)
                   {
                       var p = GetCoordinate(c.StartTime);
                       drawingContext.DrawLine(episode, p, new Point(p.X, p.Y + RowHeight));
                   }
               }

               if (model.SoundIntervals != null)
               {
               foreach (var i in model.SoundIntervals)
               {
                   if (!i.HasVoice)
                       DrawLine(drawingContext, border, i.StartTime, i.EndTime, RowHeight - 3);
               }
               }

            if (editorModel.WindowState.CurrentMode == EditorModes.Border && model.Borders!=null)
                foreach (var e in model.Borders)
                {
                    DrawLine(drawingContext, border, e.StartTime, e.EndTime, 3);
                }

            if (editorModel.WindowState.CurrentMode == EditorModes.Fixes)
                foreach (var e in model.SubtitleFixes)
                    DrawLine(drawingContext, fixes, e.StartTime, e.StartTime + e.Length, RowHeight / 2);
        }
Exemple #15
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);
            }
        }
Exemple #16
0
 public override void DrawSelOutline(System.Drawing.Graphics g, int panX, int panY)
 {
     int tempx1 = x1 - panX;
     int tempx2 = x2 - panX;
     int tempy1 = y1 - panY;
     int tempy2 = y2 - panY;
     g.DrawRectangle(selectionPen, tempx1, tempy1, tempx2 - tempx1, tempy2 - tempy1);
 }
        private void RenderCharacter(System.Drawing.Graphics grph, OCRRenderingData data, Character c)
        {
            float scaleFactor = 1.0f;

            grph.DrawRectangle(data.CharPen,
                scaleFactor * c.Left, scaleFactor * c.Top,
                scaleFactor * (c.Right - c.Left), scaleFactor * (c.Bottom - c.Top));
        }
 protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
 {
     TextDecoration profileText = Visual as TextDecoration;
     if (profileText.FillBackground && profileText.BackgroundColor.A > 0)
     {
         drawingContext.DrawRectangle(_backgroundBrush, null, _rectangle);
     }
     profileText.Format.RenderText(drawingContext, _fontBrush, profileText.Text, _rectangle);
 }
Exemple #19
0
        protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
        {
            MFD mfd = Visual as MFD;

            if (mfd != null)
            {
                drawingContext.DrawRectangle(_bezel, null, _bezelRectangle);
            }
        }
 protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
 {
     if (_display != null)
     {
         if (_display.TextureMemory != null && _display.TextureMemory.IsDataAvailable)
         {
             drawingContext.DrawRectangle(CreateImageBrush(), null, _displayRect);
         }
         else if (_display.IsRunning)
         {
             drawingContext.DrawRectangle(Brushes.Black, null, _displayRect);
         }
         else if (_defaultImage != null)
         {
             drawingContext.DrawRectangle(_defaultImage, null, _displayRect);
         }
     }
 }
        protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
        {
            System.Windows.Media.Matrix m = PresentationSource.FromVisual(this)
                .CompositionTarget.TransformToDevice;
            double dpiFactor = 1 / m.M11;

            var pen = new System.Windows.Media.Pen(System.Windows.Media.Brushes.Red, 4.0*dpiFactor);
            var rect = new Rect(0, 0, this.Width, this.Height);
            drawingContext.DrawRectangle(System.Windows.Media.Brushes.Transparent, pen, rect);
        }
Exemple #22
0
 protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
 {
     drawingContext.DrawRectangle(background, new Pen(Brushes.White, 1), new Rect(new Point(0, 0), DesiredSize));
     drawingContext.DrawText(new FormattedText(this.Message, CultureInfo.CurrentUICulture, FlowDirection.LeftToRight,
         new Typeface("SegoeUI"),
         20.0,
         foreground),
         new Point(10, 10));
     base.OnRender(drawingContext);
 }
Exemple #23
0
 public void TryDrawLink(System.Drawing.Point currentPoint, System.Drawing.Graphics graphics, PolygonsContainer data)
 {
     NullablePoint linkPoint = isNearVertex(currentPoint, data.GetAllPoints());
     if (linkPoint != null)
     {
         graphics.DrawRectangle(new System.Drawing.Pen(POINT_LINK_COLOR, POINT_LINK_LINE_WIDTH),
             linkPoint.X - POINT_LINK_RECT_WIDTH / 2,
             linkPoint.Y - POINT_LINK_RECT_WIDTH / 2,
             POINT_LINK_RECT_WIDTH, POINT_LINK_RECT_WIDTH);
     }
 }
Exemple #24
0
        protected override void OnRender(System.Windows.Media.DrawingContext dc)
        {
            base.OnRender(dc);

            if (this.playground == null)
            {
                return;
            }

            var xlength = this.playground.GetLength(1);
            var ylength = this.playground.GetLength(0);

            if (ylength == 0 || xlength == 0)
            {
                return;
            }

            double cellHeight = ActualHeight / xlength;
            double cellWidth = ActualWidth / ylength;

            cellHeight = Math.Floor(cellHeight);
            cellWidth = Math.Floor(cellWidth);

            if (cellHeight == 0 || cellWidth == 0)
            {
                FormattedText text = new FormattedText("Auflösung falsch gewählt", CultureInfo.InvariantCulture,FlowDirection.LeftToRight, new Typeface("Arial"),12,Brushes.Black);
                dc.DrawText(text,new Point(25, 25));
                return;
            }

            for (int x = 0; x < ylength; x++)
            {
                for (int y = 0; y < xlength; y++)
                {
                    var rect = new Rect(x*cellWidth, y*cellHeight, cellWidth, cellHeight);
                    if (this.playground[x, y] == true)
                    {
                        dc.DrawRectangle(Brushes.Blue, new Pen(), rect);
                    }
                }
            }

            for (int x = 0; x <= ylength; x++)
            {
                var drawingWidth = ylength*cellWidth;
                dc.DrawLine(new Pen(Brushes.LightGray, 1), new Point(0, x * cellHeight), new Point(drawingWidth, x * cellHeight));
            }

            for (int y = 0; y <= xlength; y++)
            {
                var drawingLength = xlength * cellHeight;
                dc.DrawLine(new Pen(Brushes.LightGray, 1), new Point(y * cellWidth, 0), new Point(y * cellWidth, drawingLength));
            }
        }
Exemple #25
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);
 }
        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 override void Draw(System.Drawing.Graphics g)
        {
            base.Draw(g);
            //Rectangle left = new Rectangle(base.ContentRectangle.X, base.ContentRectangle.Y, 3, base.ContentRectangle.Height);
            //Rectangle top = new Rectangle(base.ContentRectangle.X, base.ContentRectangle.Y, base.ContentRectangle.Width, 3);
            //Rectangle right = new Rectangle(base.ContentRectangle.X + base.ContentRectangle.Width, base.ContentRectangle.Y, 3, base.ContentRectangle.Height);
            //Rectangle bottom = new Rectangle(base.ContentRectangle.X, base.ContentRectangle.Y + base.ContentRectangle.Height, base.ContentRectangle.Width, 3);

            //Color q = Color.FromArgb(50, Color.Black);
            //Color b = Color.FromArgb(0, Color.Black);

            Color drawColor = Color.FromArgb(BaseColor.A, BaseColor.R + 10, BaseColor.G + 10, BaseColor.B + 10);

            Rectangle rect = new Rectangle(ContentRectangle.X - 1, ContentRectangle.Y - 1, ContentRectangle.Width + 1, ContentRectangle.Height + 1);

            g.DrawRectangle(new Pen(Color.FromArgb(150, drawColor), 1), rect);
            rect = new Rectangle(rect.X, rect.Y, rect.Width + 1, rect.Height + 1);
            g.DrawRectangle(new Pen(Color.FromArgb(100, drawColor), 1), rect);
            rect = new Rectangle(rect.X, rect.Y, rect.Width + 1, rect.Height + 1);
            g.DrawRectangle(new Pen(Color.FromArgb(50, drawColor), 1), rect);
        }
        /// <summary>
        /// Paints the shape on the canvas
        /// </summary>
        /// <param name="g"></param>
        public override void Paint(System.Drawing.Graphics g)
        {
            SetBrush();
            //			//the shadow effect
            //			Rectangle shadowRec = rectangle;
            //			shadowRec.Offset(5,5);
            //			g.FillRectangle(Brushes.Gainsboro,shadowRec);

            g.FillRectangle(shapeBrush,rectangle);

            if(hovered || isSelected)
                g.DrawRectangle(new Pen(Color.Red,2F),rectangle);
            else
                g.DrawRectangle(blackPen,rectangle);
            //add the amount of children
            if(childNodes.Count>0) plus = " [" + childNodes.Count + "]";
            else plus = "";

            if(text !=string.Empty)
                g.DrawString(text + plus,font,Brushes.Black, rectangle.X+5,rectangle.Y+5);
        }
        protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
        {
            Rect adornedElementRect = new Rect(this.AdornedElement.DesiredSize);

            if (this.AdornedElement is FrameworkElement)
            {
                adornedElementRect.Width = ((FrameworkElement)this.AdornedElement).ActualWidth;
                adornedElementRect.Height = ((FrameworkElement)this.AdornedElement).ActualHeight;
            }

            drawingContext.DrawRectangle(null, new Pen(Brushes.Red, 1), adornedElementRect);
        }
Exemple #30
0
		private void Render (System.Windows.Media.DrawingContext dc)
		{
			if (BackgroundColorSet) {
				SolidColorBrush mySolidColorBrush = new SolidColorBrush ();
				mySolidColorBrush.Color = BackgroundColor.ToWpfColor ();
				Rect myRect = new Rect (0, 0, Widget.ActualWidth, Widget.ActualHeight);
				dc.DrawRectangle (mySolidColorBrush, null, myRect);
			}
			
			var ctx = new Xwt.WPFBackend.DrawingContext (dc, Widget.GetScaleFactor ());
            ctx.Context.PushClip(new RectangleGeometry(new Rect(0, 0, Widget.ActualWidth, Widget.ActualHeight)));
            CanvasEventSink.OnDraw(ctx, new Rectangle(0, 0, Widget.ActualWidth, Widget.ActualHeight));
		}