• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Drawing.Region类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Drawing.Region的典型用法代码示例。如果您正苦于以下问题:C# Region类的具体用法?C# Region怎么用?C# Region使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Region类属于System.Drawing命名空间,在下文中一共展示了Region类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Draw

        protected override void Draw(Graphics g)
        {
            if (points.Count > 2)
            {
                g.SmoothingMode = SmoothingMode.HighQuality;

                borderDotPen.DashOffset = (float)timer.Elapsed.TotalSeconds * 10;
                borderDotPen2.DashOffset = 5 + (float)timer.Elapsed.TotalSeconds * 10;

                using (Region region = new Region(regionFillPath))
                {
                    g.Clip = region;
                    g.FillRectangle(lightBackgroundBrush, ScreenRectangle0Based);
                    g.ResetClip();
                }

                g.DrawPath(borderDotPen, regionFillPath);
                g.DrawPath(borderDotPen2, regionFillPath);
                g.DrawLine(borderDotPen, points[points.Count - 1], points[0]);
                g.DrawLine(borderDotPen2, points[points.Count - 1], points[0]);
                g.DrawRectangleProper(borderPen, currentArea);
            }

            base.Draw(g);
        }
开发者ID:TreeSeed,项目名称:ShareX,代码行数:25,代码来源:FreeHandRegion.cs


示例2: Draw

        protected override void Draw(Graphics g)
        {
            if (points.Count > 2)
            {
                g.SmoothingMode = SmoothingMode.HighQuality;

                if (Config.UseDimming)
                {
                    using (Region region = new Region(regionFillPath))
                    {
                        g.Clip = region;
                        g.FillRectangle(lightBackgroundBrush, ScreenRectangle0Based);
                        g.ResetClip();
                    }
                }

                g.DrawPath(borderPen, regionFillPath);
                g.DrawPath(borderDotPen, regionFillPath);
                g.DrawLine(borderPen, points[points.Count - 1], points[0]);
                g.DrawLine(borderDotPen, points[points.Count - 1], points[0]);
                g.DrawRectangleProper(borderPen, currentArea);
            }

            base.Draw(g);
        }
开发者ID:andre-d,项目名称:ShareXYZ,代码行数:25,代码来源:FreeHandRegion.cs


示例3: RoundedCorner

        public Stream RoundedCorner(Stream imageStream)
        {
            var targetStream = new MemoryStream();
            var originalImage = Image.FromStream(imageStream);
            var targetImage = new Bitmap(57, 57);
            var g = Graphics.FromImage(targetImage);
            g.InterpolationMode = InterpolationMode.HighQualityBicubic;
            g.SmoothingMode = SmoothingMode.HighQuality;
            g.CompositingQuality = CompositingQuality.HighQuality;

            var rect = new Rectangle(0, 0, targetImage.Width, targetImage.Height);
            var rectPath = GetRoundPath(0, 0, targetImage.Width, targetImage.Height, targetImage.Width / 9f);

            var r = new Region(rectPath);
            g.Clip = r;
            Brush b = new SolidBrush(Color.FromArgb(30, 255, 255, 255));

            //图片缩放
            g.DrawImage(originalImage, rect, new Rectangle(0, 0, originalImage.Width, originalImage.Height), GraphicsUnit.Pixel);

            g.DrawPath(new Pen(b), rectPath);
            g.FillPie(b, -targetImage.Width * (0.309f), -targetImage.Height / 2f, targetImage.Width * (1 / 0.618f), targetImage.Height, 0, 360);
            //g.FillPath(b, rectPath);
            g.Dispose();
            targetImage.Save(targetStream, ImageFormat.Png);
            targetImage.Dispose();
            originalImage.Dispose();

            targetStream.Position = 0;

            return targetStream;
        }
开发者ID:coolcode,项目名称:app,代码行数:32,代码来源:ImageService.cs


示例4: DrawVertical

 public void DrawVertical(Graphics g, LiveSplitState state, float width, Region clipRegion)
 {
     using (var solidBrush = new SolidBrush(LineColor))
     {
         g.FillRectangle(solidBrush, 0.0f, 0.0f, width, VerticalHeight);
     }
 }
开发者ID:xarrez,项目名称:LiveSplit,代码行数:7,代码来源:LineComponent.cs


示例5: FormDashboard

 public FormDashboard()
 {
     InitializeComponent();
     // закругление углов формы
     border = GetRoundedRectanglePath(this.Bounds, new SizeF(5, 5));
     region = new Region(border);
 }
开发者ID:sergewddm,项目名称:DSClient,代码行数:7,代码来源:FormDashboard.cs


示例6: BBControl

        public BBControl(int X, int Y, int dx, int dy)
        {
            InitializeComponent();
            this.Location = new Point(X, Y);
            Random rannd = new Random();
            this.dx = dx;
            this.dy = dy;
            while (dy == 0)
            {
                this.dy = rannd.Next(-50, 50);
            }
            while (dx == 0)
            {
                this.dx = rannd.Next(-50, 50);
            }
            Color color = Color.FromArgb(rannd.Next(255), rannd.Next(255), rannd.Next(255));
            while (color == Color.White)
            {
                color = Color.FromArgb(rannd.Next(255), rannd.Next(255), rannd.Next(255));
            }
            this.BackColor = color;
            this.Width = 2 * rannd.Next(2, 25);
            this.Height = this.Width;

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

            Button_Path.AddEllipse(0, 0, this.Width, this.Height);

            Region Button_Region = new Region(Button_Path);

            this.Region = Button_Region;

            thread = new Thread(DoWork);
            thread.Start();
        }
开发者ID:OstrovskiyMaxim,项目名称:.NETCourse,代码行数:35,代码来源:BBControl.cs


示例7: OnPaint

 protected override void OnPaint(PaintEventArgs e)
 {
     var iRegion = new Region(e.ClipRectangle);
     e.Graphics.FillRegion(new SolidBrush(BackColor), iRegion);
     if (Items.Count > 0)
     {
         for (int i = 0; i < Items.Count; ++i)
         {
             Rectangle irect = GetItemRectangle(i);
             if (e.ClipRectangle.IntersectsWith(irect))
             {
                 if ((SelectionMode == SelectionMode.One && SelectedIndex == i)
                             || (SelectionMode == SelectionMode.MultiSimple && SelectedIndices.Contains(i))
                             || (SelectionMode == SelectionMode.MultiExtended && SelectedIndices.Contains(i)))
                 {
                     OnDrawItem(new DrawItemEventArgs(e.Graphics, Font,
                         irect, i,
                         DrawItemState.Selected, ForeColor,
                         BackColor));
                 }
                 else
                 {
                     OnDrawItem(new DrawItemEventArgs(e.Graphics, Font,
                         irect, i,
                         DrawItemState.Default, ForeColor,
                         BackColor));
                 }
                 iRegion.Complement(irect);
             }
         }
     }
     base.OnPaint(e);
 }
开发者ID:IrateGod,项目名称:DevProLauncher,代码行数:33,代码来源:DoubleBufferedListBox.cs


示例8: ScreenRegionForm

        public ScreenRegionForm(Rectangle regionRectangle, bool activateWindow = true)
        {
            InitializeComponent();

            this.activateWindow = activateWindow;

            borderRectangle = regionRectangle.Offset(1);
            borderRectangle0Based = new Rectangle(0, 0, borderRectangle.Width, borderRectangle.Height);

            Location = borderRectangle.Location;
            int windowWidth = Math.Max(borderRectangle.Width, pInfo.Width);
            Size = new Size(windowWidth, borderRectangle.Height + pInfo.Height + 1);
            pInfo.Location = new Point(0, borderRectangle.Height + 1);

            Region region = new Region(ClientRectangle);
            region.Exclude(borderRectangle0Based.Offset(-1));
            region.Exclude(new Rectangle(0, borderRectangle.Height, windowWidth, 1));
            if (borderRectangle.Width < pInfo.Width)
            {
                region.Exclude(new Rectangle(borderRectangle.Width, 0, pInfo.Width - borderRectangle.Width, borderRectangle.Height));
            }
            else if (borderRectangle.Width > pInfo.Width)
            {
                region.Exclude(new Rectangle(pInfo.Width, borderRectangle.Height + 1, borderRectangle.Width - pInfo.Width, pInfo.Height));
            }
            Region = region;

            Timer = new Stopwatch();
        }
开发者ID:andre-d,项目名称:ShareXYZ,代码行数:29,代码来源:ScreenRegionForm.cs


示例9: ContainsPoint

        /// <summary>
        /// Проверяет попадание точки в фигуру
        /// </summary>
        /// <param name="p"></param>
        /// <returns>-1 - нет попадания, 0 - есть попадание, 1 и более - номер опорной точки в которую попал курсор</returns>
        public override int ContainsPoint(Point p)
        {
            if (this.IsSelected)
            {
                for (int i = 1; i <= KeyPoints.Length; i++)
                {
                    if (PaintHelper.GetKeyPointWhiteRect(KeyPoints[i - 1]).Contains(p))
                        return i;
                }
            }

            var path = new GraphicsPath();
            Pen pen = new Pen(DrawSettings.Color, DrawSettings.Thickness);

            Rectangle rect = NormalRectToSquare(PaintHelper.NormalizeRect(StartPoint, EndPoint));
            path.AddEllipse(rect);
            path.Widen(pen);

            Region region = new Region(path);
            pen.Dispose();
            if(region.IsVisible(p))
                return 0;

            Point center = new Point(rect.X + rect.Width / 2, rect.Y + rect.Height / 2);
            double radius = rect.Width / 2;
            float dx = p.X - center.X;
            float dy = p.Y - center.Y;
            if (Math.Sqrt(dx * dx + dy * dy) <= radius)
                return 0;
            return -1;
        }
开发者ID:tsiganoff,项目名称:PFSOFT_Test,代码行数:36,代码来源:Circle.cs


示例10: Draw

        protected override void Draw(Graphics g)
        {
            regionFillPath = new GraphicsPath();

            for (int i = 0; i < nodes.Count - 1; i++)
            {
                regionFillPath.AddLine(nodes[i].Position, nodes[i + 1].Position);
            }

            if (nodes.Count > 2)
            {
                regionFillPath.CloseFigure();

                using (Region region = new Region(regionFillPath))
                {
                    g.ExcludeClip(region);
                    g.FillRectangle(shadowBrush, 0, 0, Width, Height);
                    g.ResetClip();
                }

                g.DrawRectangleProper(borderPen, currentArea);
            }
            else
            {
                g.FillRectangle(shadowBrush, 0, 0, Width, Height);
            }

            if (nodes.Count > 1)
            {
                g.DrawPath(borderPen, regionFillPath);
            }

            base.Draw(g);
        }
开发者ID:modulexcite,项目名称:ZScreen_Google_Code,代码行数:34,代码来源:PolygonRegion.cs


示例11: RegionData_Null

		public void RegionData_Null ()
		{
			RegionData data = new Region ().GetRegionData ();
			data.Data = null;
			Assert.IsNull (data.Data, "Data");
			Region region = new Region (data);
		}
开发者ID:nlhepler,项目名称:mono,代码行数:7,代码来源:RegionDataTest.cs


示例12: DrawPointerDown

		private void DrawPointerDown(Graphics g)
		{
			Point[] points = new Point[] { new Point(ThumbBounds.Left + (ThumbBounds.Width / 2), ThumbBounds.Bottom - 1), new Point(ThumbBounds.Left, (ThumbBounds.Bottom - (ThumbBounds.Width / 2)) - 1), ThumbBounds.Location, new Point(ThumbBounds.Right - 1, ThumbBounds.Top), new Point(ThumbBounds.Right - 1, (ThumbBounds.Bottom - (ThumbBounds.Width / 2)) - 1), new Point(ThumbBounds.Left + (ThumbBounds.Width / 2), ThumbBounds.Bottom - 1) };
			GraphicsPath path = new GraphicsPath();
			path.AddLines(points);
			Region region = new Region(path);
			g.Clip = region;

			if (ThumbState == 3 || !base.Enabled)
				ControlPaint.DrawButton(g, ThumbBounds, ButtonState.All);
			else
				g.Clear(SystemColors.Control);

			g.ResetClip();
			region.Dispose();
			path.Dispose();
			Point[] pointArray2 = new Point[] { points[0], points[1], points[2], points[3] };
			g.DrawLines(SystemPens.ControlLightLight, pointArray2);
			pointArray2 = new Point[] { points[3], points[4], points[5] };
			g.DrawLines(SystemPens.ControlDarkDark, pointArray2);
			points[0].Offset(0, -1);
			points[1].Offset(1, 0);
			points[2].Offset(1, 1);
			points[3].Offset(-1, 1);
			points[4].Offset(-1, 0);
			points[5] = points[0];
			pointArray2 = new Point[] { points[0], points[1], points[2], points[3] };
			g.DrawLines(SystemPens.ControlLight, pointArray2);
			pointArray2 = new Point[] { points[3], points[4], points[5] };
			g.DrawLines(SystemPens.ControlDark, pointArray2);
		}
开发者ID:JamesH001,项目名称:SX1231,代码行数:31,代码来源:FusionTrackBar.cs


示例13: ctor_GraphicsPath

		public void ctor_GraphicsPath () {
			GraphicsPath path = new GraphicsPath ();
			path.AddRectangle (rect);
			Region r1 = new Region (path);
			r1.Xor (r);
			Assert.IsTrue (r1.IsEmpty (t.Graphics));
		}
开发者ID:nlhepler,项目名称:mono,代码行数:7,代码来源:Region.cs


示例14: Form1_Load

 private void Form1_Load(object sender, EventArgs e)
 {
     // Cut the form
     System.Drawing.Drawing2D.GraphicsPath myPath = new System.Drawing.Drawing2D.GraphicsPath();
     myPath.AddPolygon(new Point[] { new Point(0, 0), new Point(0, this.Height), new Point(this.Width, 0) });
     Region myRegion = new Region(myPath); this.Region = myRegion;
 }
开发者ID:Helixanon,项目名称:labs,代码行数:7,代码来源:Form1.cs


示例15: MeasureTextWidth

   private int MeasureTextWidth(TreeNode tn)
   {
      if (tn == null | tn.TreeView == null)
         return 0;

      TreeView tree = tn.TreeView;
      String text = this.GetText(tn);
      if (text == null || text == "")
         return 0;

      Graphics g = Graphics.FromHwnd(tree.Handle);

      using (Font font = new Font(tree.Font, tn.FontStyle))
      {
         using (StringFormat format = new StringFormat(StringFormat.GenericDefault))
         {
            RectangleF rect = new RectangleF(0, 0, 1000, 1000);
            CharacterRange[] ranges = { new CharacterRange(0, text.Length) };
            Region[] regions = new Region[1];

            format.SetMeasurableCharacterRanges(ranges);
            format.FormatFlags = StringFormatFlags.MeasureTrailingSpaces;

            regions = g.MeasureCharacterRanges(text, font, rect, format);
            rect = regions[0].GetBounds(g);

            return (int)rect.Right + 3 + (int)(text.Length * 0.25);
         }
      }
   }
开发者ID:Sugz,项目名称:Outliner-3.0,代码行数:30,代码来源:TreeNodeText.cs


示例16: OnPaint

 public override void OnPaint(PaintEventArgs e, ViewPortData viewPortData)
 {
     Graphics graphics = e.Graphics;
     Bitmap memoryBitmap = viewPortData.MemoryBitmap;
     Rectangle rect = new Rectangle(Point.Empty, memoryBitmap.Size);
     graphics.FillRectangle(AmbientTheme.WorkspaceBackgroundBrush, rect);
     if (((base.parentView.RootDesigner != null) && (base.parentView.RootDesigner.Bounds.Width >= 0)) && (base.parentView.RootDesigner.Bounds.Height >= 0))
     {
         GraphicsContainer container = graphics.BeginContainer();
         Matrix matrix = new Matrix();
         matrix.Scale(viewPortData.Scaling.Width, viewPortData.Scaling.Height, MatrixOrder.Prepend);
         Point[] pts = new Point[] { viewPortData.LogicalViewPort.Location };
         matrix.TransformPoints(pts);
         matrix.Translate((float) (-pts[0].X + viewPortData.ShadowDepth.Width), (float) (-pts[0].Y + viewPortData.ShadowDepth.Height), MatrixOrder.Append);
         graphics.Transform = matrix;
         using (Region region = new Region(ActivityDesignerPaint.GetDesignerPath(base.parentView.RootDesigner, false)))
         {
             Region clip = graphics.Clip;
             graphics.Clip = region;
             AmbientTheme ambientTheme = WorkflowTheme.CurrentTheme.AmbientTheme;
             graphics.FillRectangle(Brushes.White, base.parentView.RootDesigner.Bounds);
             if (ambientTheme.WorkflowWatermarkImage != null)
             {
                 ActivityDesignerPaint.DrawImage(graphics, ambientTheme.WorkflowWatermarkImage, base.parentView.RootDesigner.Bounds, new Rectangle(Point.Empty, ambientTheme.WorkflowWatermarkImage.Size), ambientTheme.WatermarkAlignment, 0.25f, false);
             }
             graphics.Clip = clip;
         }
         graphics.EndContainer(container);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:30,代码来源:DefaultWorkflowLayout.cs


示例17: DrawHorizontal

 public void DrawHorizontal(Graphics g, LiveSplitState state, float height, Region clipRegion)
 {
     using (var solidBrush = new SolidBrush(LineColor))
     {
         g.FillRectangle(solidBrush, 0.0f, 0.0f, HorizontalWidth, height);
     }
 }
开发者ID:PrototypeAlpha,项目名称:LiveSplit,代码行数:7,代码来源:LineComponent.cs


示例18: GraphicsIsVisibleRectangleF

        public void GraphicsIsVisibleRectangleF(Graphics g)
        {
            Pen myPen = new Pen(Color.FromArgb(196, 0xC3, 0xC9, 0xCF), (float)0.6);
            SolidBrush myBrush = new SolidBrush(Color.FromArgb(127, 0xDD, 0xDD, 0xF0));

            // Create the first rectangle and draw it to the screen in blue.
            g.DrawRectangle(myPen, regionRect1);
            g.FillRectangle (myBrush, regionRect1);

            // Create the second rectangle and draw it to the screen in red.
            myPen.Color = Color.FromArgb(196, 0xF9, 0xBE, 0xA6);
            myBrush.Color = Color.FromArgb(127, 0xFF, 0xE0, 0xE0);

            g.DrawRectangle(myPen, Rectangle.Round(regionRectF2));
            g.FillRectangle (myBrush, Rectangle.Round (regionRectF2));

            // Create a region using the first rectangle.
            Region myRegion = new Region(regionRect1);

            // Determine if myRect is contained in the region.
            bool contained = myRegion.IsVisible(regionRect2);

            // Display the result.
            Font myFont = new Font("Arial", 8);
            SolidBrush txtBrush = new SolidBrush(Color.Black);
            g.DrawString("contained = " + contained.ToString(),
                myFont,
                txtBrush,
                new PointF(regionRectF2.Right + 10, regionRectF2.Top));

            regionRect1.Y += 120;
            regionRectF2.Y += 120;
            regionRectF2.X += 41;

            myPen.Color = Color.FromArgb (196, 0xC3, 0xC9, 0xCF);
            myBrush.Color = Color.FromArgb(127, 0xDD, 0xDD, 0xF0);

            // Create the first rectangle and draw it to the screen in blue.
            g.DrawRectangle(myPen, regionRect1);
            g.FillRectangle (myBrush, regionRect1);

            // Create the second rectangle and draw it to the screen in red.
            myPen.Color = Color.FromArgb(196, 0xF9, 0xBE, 0xA6);
            myBrush.Color = Color.FromArgb(127, 0xFF, 0xE0, 0xE0);

            g.DrawRectangle(myPen, Rectangle.Round(regionRectF2));
            g.FillRectangle (myBrush, Rectangle.Round (regionRectF2));

            // Create a region using the first rectangle.
            myRegion = new Region(regionRect1);

            // Determine if myRect is contained in the region.
            contained = myRegion.IsVisible(regionRectF2);

            // Display the result.
            g.DrawString("contained = " + contained.ToString(),
                myFont,
                txtBrush,
                new PointF(regionRectF2.Right + 10, regionRectF2.Top));
        }
开发者ID:mono,项目名称:sysdrawing-coregraphics,代码行数:60,代码来源:DrawingView.cs


示例19: ClipTest_2

		public void ClipTest_2() {
			Region r = new Region(new Rectangle(10, 10, 60, 60));
			t.Graphics.Clip = r;
			Assert.IsTrue(r.Equals(t.Graphics.Clip, t.Graphics));

			Pen redPen   = new Pen(Color.Red, 3);
			Pen greenPen = new Pen(Color.Green, 3);
			// Create points that define curve.
			Point point1 = new Point( 50,  50);
			Point point2 = new Point(100,  25);
			Point point3 = new Point(200,   5);
			Point point4 = new Point(250,  50);
			Point point5 = new Point(300, 100);
			Point point6 = new Point(350, 200);
			Point point7 = new Point(250, 250);
			Point[] curvePoints = {
									  point1,
									  point2,
									  point3,
									  point4,
									  point5,
									  point6,
									  point7
								  };
			// Draw lines between original points to screen.
			t.Graphics.DrawLines(redPen, curvePoints);
			t.Show ();
			Assert.IsTrue(t.PDCompare(TOLERANCE));
		}
开发者ID:kumpera,项目名称:mono,代码行数:29,代码来源:Graphics.cs


示例20: Invalidate

 public void Invalidate(Region region)
 {
     if (this.behaviorService != null)
     {
         this.behaviorService.Invalidate(region);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:Adorner.cs



注:本文中的System.Drawing.Region类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Drawing.Size类代码示例发布时间:2022-05-26
下一篇:
C# Drawing.RectangleF类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap