当前位置: 首页>>代码示例>>C#>>正文


C# Drawing.Region类代码示例

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


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


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