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


C# Region.Union方法代码示例

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


在下文中一共展示了Region.Union方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MainForm_Load

 /// <summary>
 /// Called when the form loads
 /// </summary>
 /// <param name="sender">what triggered the event</param>
 /// <param name="e">event args</param>
 private void MainForm_Load(object sender, EventArgs e)
 {
     // make cool shape
     Region r = new Region();
     GraphicsPath gp = new GraphicsPath();
     gp.AddEllipse(new Rectangle(0, 0, this.Width, this.Height));
     r.MakeEmpty();
     r.Union(gp);
     gp = new GraphicsPath();
     gp.AddRectangle(new Rectangle(this.Width / 2, 0, this.Width / 2, this.Height / 2));
     r.Union(gp);
     this.Region = r;
 }
开发者ID:williammortl,项目名称:MiscCode,代码行数:18,代码来源:MainForm.cs

示例2: OnPaint

			protected override void OnPaint (PaintEventArgs pevent)
			{
				Console.WriteLine ("ourLabelTwoAreas pevents {0}, pos {1} - size {2}", pevent.ClipRectangle,
					Location, Size);

				Region reg = new Region (new Rectangle (20, 20, 10, 10));
				reg.Union (new Rectangle (5, 5, 10, 10));
				pevent.Graphics.Clip  = reg;
				pevent.Graphics.FillRectangle (Brushes.Red, pevent.ClipRectangle);
			}
开发者ID:nlhepler,项目名称:mono,代码行数:10,代码来源:clipping.cs

示例3: GetRegion

 private Region GetRegion(Bitmap _img)
 {
     var rgn = new Region();
     rgn.MakeEmpty();
     var rc = new Rectangle(0, 0, 0, 0);
     bool inimage = false;
     for (int y = 0; y < _img.Height; y++)
     {
         for (int x = 0; x < _img.Width; x++)
         {
             if (!inimage)
             {
                 // if pixel is not transparent
                 if (_img.GetPixel(x, y).A != 0)
                 {
                     inimage = true;
                     rc.X = x;
                     rc.Y = y;
                     rc.Height = 1;
                 }
             }
             else
             {
                 // if pixel is transparent
                 if (_img.GetPixel(x, y).A == 0)
                 {
                     inimage = false;
                     rc.Width = x - rc.X;
                     rgn.Union(rc);
                 }
             }
         }
         if (inimage)
         {
             inimage = false;
             rc.Width = _img.Width - rc.X;
             rgn.Union(rc);
         }
     }
     return rgn;
 }
开发者ID:prescottadam,项目名称:samples.CustomShapedForm,代码行数:41,代码来源:Form1.cs

示例4: IsOnScreen

        /// <summary>
        /// Returns whether the given rectangle, in screen coordinates, is visible in any screen's
        /// working area (the monitor's visible area minus task bars and docked windows)</summary>
        /// <param name="rect">Rectangle</param>
        /// <returns>Whether the given rectangle is visible</returns>
        public static bool IsOnScreen(Rectangle rect)
        {
            using (Region region = new Region())
            {
                region.MakeEmpty();
                foreach (Screen screen in Screen.AllScreens)
                    region.Union(screen.WorkingArea);

                rect.Inflate(-Margin, -Margin);
                return region.IsVisible(rect);
            }
        }
开发者ID:vincenthamm,项目名称:ATF,代码行数:17,代码来源:WinFormsUtil.cs

示例5: CombineAreas

        public Region CombineAreas()
        {
            Region region = new Region();
            region.MakeEmpty();

            foreach (Area area in Areas)
            {
                region.Union(area.Region);
            }

            region.Intersect(new Region(Crop.Bounds));

            return region;
        }
开发者ID:modulexcite,项目名称:ZScreen_Google_Code,代码行数:14,代码来源:AreaManager.cs

示例6: CreateRegion

 public static void CreateRegion(Control control, Rectangle bounds, int radius, RoundStyle roundStyle)
 {
     using (GraphicsPath path = GraphicsPathHelper.CreatePath(bounds, radius, roundStyle, true))
     {
         Region region = new Region(path);
         path.Widen(Pens.White);
         region.Union(path);
         if (control.Region != null)
         {
             control.Region.Dispose();
         }
         control.Region = region;
     }
 }
开发者ID:jxdong1013,项目名称:archivems,代码行数:14,代码来源:RegionHelper.cs

示例7: BlockRegions

        static BlockRegions()
        {
            int n = Constants.PROJ_WIDTH / 4;

            WholeBlock = new Region();
            WholeBlock.MakeEmpty();
            for (int i = 0; i <= n; i++)
            {
                WholeBlock.Union(new Rectangle(n * 2 - 1 - 2 * i, i, i * 4 + 2, Constants.PROJ_HEIGHT - 2 * i));
            }
            WholeBlock.Intersect(new Rectangle(0, 0, Constants.PROJ_WIDTH, Constants.PROJ_HEIGHT));
            InnerBlock = new Region();
            InnerBlock.MakeEmpty();
            for (int i = 0; i <= n; i++)
            {
                InnerBlock.Union(new Rectangle(n * 2 - 1 - 2 * i, i + 1, i * 4 + 2, Constants.PROJ_HEIGHT - 2 - 2 * i));
            }
            InnerBlock.Intersect(new Rectangle(1, 1, Constants.PROJ_WIDTH - 2, Constants.PROJ_HEIGHT - 2));

            OuterBorder = WholeBlock.Clone();
            OuterBorder.Exclude(InnerBlock);

            Top = InnerBlock.Clone();
            Top.Translate(0, -Constants.BLOCK_HEIGHT);
            Top.Intersect(InnerBlock);

            Left = InnerBlock.Clone();
            Left.Exclude(Top);
            Top.Translate(0, 1);
            Left.Exclude(Top);
            Top.Translate(0, -1);

            Right = Left.Clone();
            Left.Intersect(new Rectangle(0, 0, Constants.PROJ_WIDTH / 2, Constants.PROJ_HEIGHT));
            Right.Intersect(new Rectangle(Constants.PROJ_WIDTH / 2 + 1, 0, Constants.PROJ_WIDTH / 2, Constants.PROJ_HEIGHT));

            InnerBorder = InnerBlock.Clone();
            InnerBorder.Exclude(Top);
            InnerBorder.Exclude(Left);
            InnerBorder.Exclude(Right);
        }
开发者ID:ZetaTwo,项目名称:Project-Easter-Egg,代码行数:41,代码来源:BlockRegions.cs

示例8: TestBounds

		public void TestBounds()
		{
			Bitmap bmp = new Bitmap (600, 800);
			Graphics dc = Graphics.FromImage (bmp);
			Rectangle rect1, rect2;
			Region rgn1, rgn2;
			RectangleF bounds;

			rect1 = new Rectangle (500, 30, 60, 80);
			rect2 = new Rectangle (520, 40, 60, 80);
			rgn1 = new Region(rect1);
			rgn2 = new Region(rect2);
			rgn1.Union(rgn2);

			bounds = rgn1.GetBounds (dc);

			Assert.AreEqual (500, bounds.X);
			Assert.AreEqual (30, bounds.Y);
			Assert.AreEqual (80, bounds.Width);
			Assert.AreEqual (90, bounds.Height);
		}
开发者ID:Profit0004,项目名称:mono,代码行数:21,代码来源:TestRegion.cs

示例9: Tick

        public void Tick()
        {
            System.Drawing.Region r = new System.Drawing.Region();
            int living = 0;
            var ruleset = ((RuleSet)cbRuleSet.SelectedItem);
            for (int x = 0; x <= zellen.GetUpperBound(0); x++)
            {
                for (int y = 0; y <= zellen.GetUpperBound(1); y++)
                {
                    zellen[x, y].Aenderung = ruleset.applyRuleset(zellen[x, y].Status, getLivingNeighbours(x, y));
                }
            }

            for (int x = 0; x <= zellen.GetUpperBound(0); x++)
            {
                for (int y = 0; y <= zellen.GetUpperBound(1); y++)
                {
                    if (zellen[x, y].Status != zellen[x, y].Aenderung)
                    {
                        zellen[x, y].hasChanged = true;
                        zellen[x, y].Status = zellen[x, y].Aenderung;
                        r.Union(canvas.getRectangle(x, y));
                    }
                    living += zellen[x, y].Status == ZellenStatus.Lebt ? 1 : 0;
                }
            }
            ticks++;
            lblTicks.Text = ticks.ToString();
            lblLivingCells.Text = living.ToString();
            canvas.Invalidate(r);
            if (cbLimit.Checked && ticks >= nupLimit.Value)
            {
                Stop();
            }
            if (cbEnableStats.Checked)
            {
                _stats.Add(new StatisticEntry(ticks, living));
            }
        }
开发者ID:Zakant,项目名称:GameofLife,代码行数:39,代码来源:frmMain.cs

示例10: DrawRegionOperations

        private void DrawRegionOperations()
        {
            g = this.CreateGraphics();
            // Создаем два прямоугольника
            Rectangle rect1 = new Rectangle(100, 100, 120, 120);
            Rectangle rect2 = new Rectangle(70, 70, 120, 120);
            // Создаем два региона
            Region rgn1 = new Region(rect1);
            Region rgn2 = new Region(rect2);
            // рисуем прямоугольники
            g.DrawRectangle(Pens.Green, rect1);
            g.DrawRectangle(Pens.Black, rect2);

            // обработаем перечисление и вызовем соответствующий метод
            switch (rgnOperation)
            {
                case RegionOperations.Union:
                    rgn1.Union(rgn2);
                    break;
                case RegionOperations.Complement:
                    rgn1.Complement(rgn2);
                    break;
                case RegionOperations.Intersect:
                    rgn1.Intersect(rgn2);
                    break;
                case RegionOperations.Exclude:
                    rgn1.Exclude(rgn2);
                    break;
                case RegionOperations.Xor:
                    rgn1.Xor(rgn2);
                    break;
                default:
                    break;
            }
            // Рисуем регион
            g.FillRegion(Brushes.Blue, rgn1);
            g.Dispose();
        }
开发者ID:xs2ranjeet,项目名称:13ns9-1spr,代码行数:38,代码来源:Form1.cs

示例11: DrawRegionOperation

        void DrawRegionOperation()
        {
            g = this.CreateGraphics();
            Rectangle rect1 = new Rectangle(100, 100, 120, 120);
            Rectangle rect2 = new Rectangle(70, 70, 120, 120);

            Region rgn1 = new Region(rect1);
            Region rgn2 = new Region(rect2);

            g.DrawRectangle(Pens.Blue, rect1);
            g.DrawRectangle(Pens.Red, rect2);

            switch(rgnOperation)
            {
                case RegionOperation.Union:
                    rgn1.Union(rgn2);
                    break;
                case RegionOperation.Complement:
                    rgn1.Complement(rgn2);
                    break;
                case RegionOperation.Intersect:
                    rgn1.Intersect(rgn2);
                    break;
                case RegionOperation.Exclude:
                    rgn1.Exclude(rgn2);
                    break;
                case RegionOperation.Xor:
                    rgn1.Xor(rgn2);
                    break;
                default:
                    break;

            }

            g.FillRegion(Brushes.Tomato, rgn1);

            g.Dispose();
        }
开发者ID:RoykoSerhiy,项目名称:visualStudio_projects,代码行数:38,代码来源:Form1.cs

示例12: Region

 public Region this[int c]
 {
     get {
     if (this.cgrom[c] == null)
     {
         int C = c * charHeight;
         Region r = new Region();
         r.MakeEmpty();
         for (int y = 0; y < charHeight; ++y)
         {
             byte row = this.cgrom_raw[C + y];
             for (int x = 0; x < charWidth && row != 0; ++x)
             {
                 if ((row & 0x80) == 0x80)
                     r.Union(new Rectangle(x, y, 1, 1));
                 row <<= 1;
             }
         }
         this.cgrom[c] = r;
     }
     return this.cgrom[c];
     }
 }
开发者ID:coderforlife,项目名称:lcd-emu,代码行数:23,代码来源:CGROM.cs

示例13: OnMouseLeave

		void OnMouseLeave (object sender, EventArgs e)
		{
			Region region_to_invalidate = new Region ();
			region_to_invalidate.MakeEmpty ();
			bool dirty = false;
			if (ThemeEngine.Current.ScrollBarHasHoverArrowButtonStyle) {
				region_to_invalidate.Union (first_arrow_area);
				region_to_invalidate.Union (second_arrow_area);
				dirty = true;
			} else
				if (ThemeEngine.Current.ScrollBarHasHotElementStyles)
					if (first_button_entered) {
						region_to_invalidate.Union (first_arrow_area);
						dirty = true;
					} else if (second_button_entered) {
						region_to_invalidate.Union (second_arrow_area);
						dirty = true;
					}
			if (ThemeEngine.Current.ScrollBarHasHotElementStyles)
				if (thumb_entered) {
					region_to_invalidate.Union (thumb_pos);
					dirty = true;
				}
			first_button_entered = false;
			second_button_entered = false;
			thumb_entered = false;
			if (dirty)
				Invalidate (region_to_invalidate);
			region_to_invalidate.Dispose ();
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:30,代码来源:ScrollBar.cs

示例14: OnMouseEnter

		void OnMouseEnter (object sender, EventArgs e)
		{
			if (ThemeEngine.Current.ScrollBarHasHoverArrowButtonStyle) {
				Region region_to_invalidate = new Region (first_arrow_area);
				region_to_invalidate.Union (second_arrow_area);
				Invalidate (region_to_invalidate);
			}
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:8,代码来源:ScrollBar.cs

示例15: TakeWorkflowSnapShot

 internal static void TakeWorkflowSnapShot(WorkflowView workflowView, ViewPortData viewPortData)
 {
     Bitmap memoryBitmap = viewPortData.MemoryBitmap;
     using (Graphics graphics = Graphics.FromImage(memoryBitmap))
     {
         graphics.SmoothingMode = SmoothingMode.HighQuality;
         graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
         using (PaintEventArgs args = new PaintEventArgs(graphics, viewPortData.LogicalViewPort))
         {
             workflowView.ActiveLayout.OnPaint(args, viewPortData);
         }
         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;
         if (workflowView.RootDesigner != null)
         {
             using (Region region = new Region())
             {
                 using (GraphicsPath path = ActivityDesignerPaint.GetDesignerPath(workflowView.RootDesigner, false))
                 {
                     Region clip = graphics.Clip;
                     region.MakeEmpty();
                     region.Union(path);
                     graphics.Clip = region;
                     AmbientTheme ambientTheme = WorkflowTheme.CurrentTheme.AmbientTheme;
                     graphics.FillRectangle(ambientTheme.BackgroundBrush, workflowView.RootDesigner.Bounds);
                     if (ambientTheme.ShowGrid)
                     {
                         ActivityDesignerPaint.DrawGrid(graphics, workflowView.RootDesigner.Bounds);
                     }
                     graphics.Clip = clip;
                     try
                     {
                         using (PaintEventArgs args2 = new PaintEventArgs(graphics, viewPortData.LogicalViewPort))
                         {
                             ((IWorkflowDesignerMessageSink) workflowView.RootDesigner).OnPaint(args2, viewPortData.LogicalViewPort);
                         }
                     }
                     catch (Exception)
                     {
                     }
                 }
             }
         }
         using (PaintEventArgs args3 = new PaintEventArgs(graphics, workflowView.RootDesigner.Bounds))
         {
             using (WorkflowMessageDispatchData data = new WorkflowMessageDispatchData(workflowView, EventArgs.Empty))
             {
                 foreach (WorkflowDesignerMessageFilter filter in data.Filters)
                 {
                     try
                     {
                         if (((IWorkflowDesignerMessageSink) filter).OnPaint(args3, viewPortData.LogicalViewPort))
                         {
                             goto Label_0230;
                         }
                     }
                     catch (Exception)
                     {
                     }
                 }
             }
         }
     Label_0230:
         graphics.Transform = new Matrix();
         if (!viewPortData.ShadowDepth.IsEmpty)
         {
             Bitmap image = new Bitmap(memoryBitmap);
             using (Brush brush = new SolidBrush(Color.FromArgb(220, Color.White)))
             {
                 graphics.FillRectangle(brush, new Rectangle(Point.Empty, new Size((memoryBitmap.Size.Width - viewPortData.ShadowDepth.Width) - 1, (memoryBitmap.Size.Height - viewPortData.ShadowDepth.Height) - 1)));
             }
             ImageAttributes imageAttr = new ImageAttributes();
             imageAttr.SetColorKey(viewPortData.TransparentColor, viewPortData.TransparentColor, ColorAdjustType.Default);
             imageAttr.SetColorKey(viewPortData.TransparentColor, viewPortData.TransparentColor, ColorAdjustType.Bitmap);
             graphics.DrawImage(image, new Rectangle(-viewPortData.ShadowDepth.Width, -viewPortData.ShadowDepth.Height, memoryBitmap.Width, memoryBitmap.Height), 0, 0, memoryBitmap.Width, memoryBitmap.Height, GraphicsUnit.Pixel, imageAttr);
             image.Dispose();
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:83,代码来源:WorkflowView.cs


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