當前位置: 首頁>>代碼示例>>C#>>正文


C# Region.Exclude方法代碼示例

本文整理匯總了C#中System.Drawing.Region.Exclude方法的典型用法代碼示例。如果您正苦於以下問題:C# Region.Exclude方法的具體用法?C# Region.Exclude怎麽用?C# Region.Exclude使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Drawing.Region的用法示例。


在下文中一共展示了Region.Exclude方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: 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

示例2: IsOverLayed

        /// <summary>
        /// Does a hit test for specified control (is point of control visible to user)
        /// </summary>
        /// <param name="ctrlRect">the rectangle (usually Bounds) of the control</param>
        /// <param name="ctrlHandle">the handle for the control</param>
        /// <returns>boolean value indicating if ctrlRect is overlayed by another control </returns>
        public static bool IsOverLayed( Rectangle ctrlRect, IntPtr ctrlHandle )
        {
            // clear results
            enumedwindowPtrs.Clear();
            enumedwindowRects.Clear();

            // Create callback and start enumeration
            callBackPtr = new CallBackPtr( EnumCallBack );
            EnumDesktopWindows( IntPtr.Zero, callBackPtr, 0 );

            // Go from last to first window, and substract them from the ctrlRect area
            Region r = new Region( ctrlRect );

            bool StartClipping = false;
            for( int i = enumedwindowRects.Count - 1; i >= 0; i-- )
            {
                if( StartClipping )
                {
                    r.Exclude( enumedwindowRects[i] );
                }

                if( enumedwindowPtrs[i] == ctrlHandle ) StartClipping = true;
            }

            //Creating a list of points scattered on the edges of the window.
            IList<System.Drawing.Point> pointList = new List<System.Drawing.Point>();
            pointList.Add( new System.Drawing.Point( ctrlRect.X, ctrlRect.Y ) );
            pointList.Add( new System.Drawing.Point( ctrlRect.X + ctrlRect.Width - 2, ctrlRect.Y ) );
            pointList.Add( new System.Drawing.Point( ctrlRect.X + ctrlRect.Width - 2, ctrlRect.Y + ctrlRect.Height - 2 ) );
            pointList.Add( new System.Drawing.Point( ctrlRect.X, ctrlRect.Y + ctrlRect.Height - 2 ) );

            //TODO : choose the scale considering the width and height of the window.
            int scale = 50;
            int xOffset = 0;
            int yOffset = 0;
            int offset = 2;
            for( int x = 0; x <= scale; x++ )
            {
                for( int y = 0; y <= scale; y++ )
                {
                    if( y == scale ) yOffset = offset;
                    else yOffset = 0;

                    if( x == scale ) xOffset = offset;
                    else xOffset = 0;

                    pointList.Add( new System.Drawing.Point( ctrlRect.X + ctrlRect.Width / scale * x - xOffset, ctrlRect.Y + ctrlRect.Height / scale * y - yOffset ) );
                }
            }

            //Checking if theses points are visible by the user
            foreach( var item in pointList )
            {
                if( !r.IsVisible( item ) ) return true;
            }

            return false;
        }
開發者ID:Nementon,項目名稱:ck-desktop,代碼行數:64,代碼來源:WindowHelper.cs

示例3: ScreenRegionForm

        public ScreenRegionForm(Rectangle regionRectangle)
        {
            InitializeComponent();

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

            Location = borderRectangle.Location;
            Size = new Size(borderRectangle.Width, borderRectangle.Height + pInfo.Height);
            pInfo.Location = new Point(Width - pInfo.Width, Height - pInfo.Height);

            Region region = new Region(ClientRectangle);
            region.Exclude(borderRectangle0Based.RectangleOffset(-1));
            region.Exclude(new Rectangle(0, pInfo.Location.Y, pInfo.Location.X, pInfo.Height));
            Region = region;

            Timer = new Stopwatch();
        }
開發者ID:Edison6351,項目名稱:ShareX,代碼行數:18,代碼來源:ScreenRegionForm.cs

示例4: Form1_Load

        private void Form1_Load(object sender, EventArgs e)
        {
            rect = new Rectangle(Point.Empty, this.Size);
            region = new Region(rect);

            rect.Inflate(-1 * (this.Width - 3), -1 * (this.Height - 3));
            region.Exclude(rect);

            this.Region = region;
            this.Owner = Program.GUIref;
        }
開發者ID:sdrobs,項目名稱:vendfriend,代碼行數:11,代碼來源:popout-grid.cs

示例5: 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

示例6: ScreenRegionForm

        public ScreenRegionForm(Rectangle regionRectangle)
        {
            InitializeComponent();

            Location = new Point(regionRectangle.X - 1, regionRectangle.Y - 1);
            Size = new Size(regionRectangle.Width + 2, regionRectangle.Height + 2);

            Rectangle rect = ClientRectangle;
            Region region = new Region(rect);
            rect.Inflate(-1, -1);
            region.Exclude(rect);
            Region = region;
        }
開發者ID:dmitriydel,項目名稱:sharexmod,代碼行數:13,代碼來源:ScreenRegionForm.cs

示例7: ApplyRegion

        public void ApplyRegion()
        {
            var r = new Region(new Rectangle(0, 0, MaskImage.Width, MaskImage.Height));

            for (int y = 0; y < MaskImage.Height; y++) {
                for (int x = 0; x < MaskImage.Width; x++) {
                    if (MaskImage.GetPixel(x, y) == TransparencyKey) {
                        r.Exclude(new Rectangle(x, y, 1, 1));
                    }
                }
            }

            Control.Region = r;
            Control.BackgroundImage = MaskImage;
        }
開發者ID:hksonngan,項目名稱:sharptracing,代碼行數:15,代碼來源:RegionHandler.cs

示例8: ScreenRecordForm

        public ScreenRecordForm(Rectangle regionRectangle, bool activateWindow = true, float duration = 0)
        {
            InitializeComponent();
            niTray.Icon = ShareXResources.Icon;

            this.activateWindow = activateWindow;
            this.duration = duration;

            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();
            UpdateTimer();

            RecordResetEvent = new ManualResetEvent(false);

            ChangeState(ScreenRecordState.Waiting);
        }
開發者ID:raymondle,項目名稱:ShareX,代碼行數:36,代碼來源:ScreenRecordForm.cs

示例9: PaintNonItemRegion

 private void PaintNonItemRegion()
 {
     using (Graphics g = Graphics.FromHwnd(this.Handle))
     using (Region r = new Region(this.ClientRectangle))
     {
         for (int i = 0; i < this.Items.Count; i++)
         {
             Rectangle itemRect = this.GetItemRectangle(i);
             r.Exclude(itemRect);
         }
         using (var brush = new SolidBrush(this.BackColor))
         {
             g.FillRegion(SystemBrushes.Window, r);
         }
     }
 }
開發者ID:wow4all,項目名稱:evemu_server,代碼行數:16,代碼來源:NoFlickerListBox.cs

示例10: DrawFinalImage

		private void DrawFinalImage()
		{
			using (var g = Graphics.FromImage(FinalComposedImage))
			{
				g.DrawImage(BackgroundImage, new Rectangle(0, 0, m_width, m_height));
				g.DrawImage(ContentImage, new Rectangle(0, 0, m_width, m_height));

				if (SelectedSubTexture != null)
				{
					Region rgn = new Region(new Rectangle(0, 0, m_width, m_height));
					rgn.Exclude(new Rectangle(SelectedSubTexture.Left, SelectedSubTexture.Top,
											  SelectedSubTexture.Width, SelectedSubTexture.Height));
					g.FillRegion(m_maskBrush, rgn);
				}
			}
		}
開發者ID:galaxyyao,項目名稱:TouhouGrave,代碼行數:16,代碼來源:View.Draw.cs

示例11: doDraw

        private void doDraw(Graphics g)
        {
            Region baseR = new Region(new Rectangle(0, 0, this.pbParent.Width, this.pbParent.Height));

            foreach (KeyValuePair<String, drawObject> item in drawObjects) {
                if (item.Key.Substring(0, 5) == "table") {
                    baseR.Exclude(Rectangle.Round(item.Value.loc));
                }
            }

            g.FillRegion(new SolidBrush(this.pbParent.BackColor), baseR);

            foreach (KeyValuePair<String, drawObject> item in drawObjects) {
                item.Value.draw(g);
            }
        }
開發者ID:K-4U,項目名稱:ese_project4y5,代碼行數:16,代碼來源:drawer.cs

示例12: Clipping

        /// <summary>
        /// Initialize a new instance of the Clipping class.
        /// </summary>
        /// <param name="graphics">Graphics context.</param>
        /// <param name="path">Path to clip.</param>
        /// <param name="exclude">Exclude path from clipping.</param>
        public Clipping(Graphics graphics, GraphicsPath path, bool exclude)
        {
            // Cache graphics instance
            _graphics = graphics;

            // Save the existing clipping region
            _previousRegion = _graphics.Clip;

            // Add clipping of path to existing clipping region
            _newRegion = _previousRegion.Clone();

            if (exclude)
                _newRegion.Exclude(path);
            else
                _newRegion.Intersect(path);

            _graphics.Clip = _newRegion;
        }
開發者ID:ComponentFactory,項目名稱:Krypton,代碼行數:24,代碼來源:Clipping.cs

示例13: OnPaint

 protected override void OnPaint(PaintEventArgs e)
 {
     switch (cBAreo.CheckState)
     {
     case CheckState.Checked:
     e.Graphics.Clear(Color.Black);                  //將窗體整個背景繪製成黑色
     break;
     case CheckState.Indeterminate:
     Rectangle rect = this.ClientRectangle;
     rect.Inflate(-20, -20);
     Region region = new Region(rect);
     rect.Inflate(-20, -20);
     region.Exclude(rect);                           //獲取非Areo區域部分區域
     e.Graphics.FillRegion(Brushes.Black, region);   //窗體部分非Areo區域全透明
     e.Graphics.FillRegion(Brushes.Black, regionAreo);//將窗體Areo邊框繪製成黑色
     break;
     }
 }
開發者ID:dalinhuang,項目名稱:wdeqawes-efrwserd-rgtedrtf,代碼行數:18,代碼來源:FormAreoRegion.cs

示例14: OnPaint

 protected override void OnPaint(PaintEventArgs e)
 {
     if (Areo.IsAreoEnabled())                        //檢測係統是否開啟Areo功能
     {
     switch (cBAreo.CheckState)
     {
     case CheckState.Checked:
         e.Graphics.Clear(Color.Black);          //將窗體整個背景繪製成黑色
         break;
     case CheckState.Indeterminate:
         Region region = new Region(this.ClientRectangle);
         Rectangle rect = this.ClientRectangle;
         rect.Inflate(-50, -50);
         region.Exclude(rect);
         e.Graphics.FillRegion(Brushes.Black, region);//將窗體Areo邊框繪製成黑色
         break;
     }
     }
 }
開發者ID:dalinhuang,項目名稱:wdeqawes-efrwserd-rgtedrtf,代碼行數:19,代碼來源:FormAreoBorder.cs

示例15: FormTest

        public FormTest()
        {
            this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint, true);

            InitializeComponent();
            FileManager.FileManager.Initialize();
            deviceTreeList = FileManager.FileManager.GetDeviceList();
            InitTreeView(deviceTreeList, this.tree);
            InitTreeView(deviceTreeList, this.treeView1);
            InitTreeView(deviceTreeList, this.treeViewAlarm);
            checkBox_analyze.Checked = false;
            checkBox_cruise.Checked = false;
            checkBox_record.Checked = false;
            Rectangle rect = video1.Bounds;
            rect.Inflate(-3,-3);
            Region maskRegion = new Region(video1.Bounds);
            maskRegion.Exclude(rect);
            lMask1.Region = maskRegion;
            label_video2.Region = maskRegion;
        }
開發者ID:dalinhuang,項目名稱:iloujiok-ffp-csharp,代碼行數:20,代碼來源:FormTest.cs


注:本文中的System.Drawing.Region.Exclude方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。