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


C# Region.GetBounds方法代码示例

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


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

示例1: DrawShapeOnGraphics

        public override void DrawShapeOnGraphics(GraphicsPath shapeAsGraphicsPath, Graphics g)
        {
            styleToDecorate.DrawShapeOnGraphics(shapeAsGraphicsPath, g);

              Region shapeAsRegion = new Region(shapeAsGraphicsPath);
              RectangleF rr = shapeAsRegion.GetBounds(g);
              CreateGradient(rr);
              g.FillRegion(styleToDecorate.fillBrush_, shapeAsRegion);
        }
开发者ID:pchmielowski,项目名称:Paint,代码行数:9,代码来源:Style.cs

示例2: AddObject

        public void AddObject(Region path, string layer, ToolTipInfo toolTipInfo, System.Drawing.Graphics g)
        {
            lock (m_QuadTree)
            {
                RectangleF rf = path.GetBounds(g);
                Envelope env = new Envelope(rf.Left, rf.Right, rf.Bottom, rf.Top);

                m_QuadTree.Insert(env, new QuickInfoObject(path, layer, toolTipInfo, env));
            }
        }
开发者ID:oliverheilig,项目名称:SharpMap.Ptv,代码行数:10,代码来源:InteractiveMap.cs

示例3: CheckEmpty

		// a region with an "empty ctor" graphic path is "empty" (i.e. not infinite)
		private void CheckEmpty (string prefix, Region region)
		{
			Assert.IsTrue (region.IsEmpty (graphic), prefix + "IsEmpty");
			Assert.IsFalse (region.IsInfinite (graphic), prefix + "graphic");

			RectangleF rect = region.GetBounds (graphic);
			Assert.AreEqual (0f, rect.X, prefix + "GetBounds.X");
			Assert.AreEqual (0f, rect.Y, prefix + "GetBounds.Y");
			Assert.AreEqual (0f, rect.Width, prefix + "GetBounds.Width");
			Assert.AreEqual (0f, rect.Height, prefix + "GetBounds.Height");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:12,代码来源:RegionNonRectTest.cs

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

示例5: SetSaveReset

		public void SetSaveReset ()
		{
			Bitmap bmp = new Bitmap (200, 200);
			Graphics g = Graphics.FromImage (bmp);
			GraphicsState state_default, state_modified;

			state_default = g.Save (); // Default

			g.CompositingMode = CompositingMode.SourceCopy;
			g.CompositingQuality = CompositingQuality.GammaCorrected;
			g.InterpolationMode = InterpolationMode.HighQualityBilinear;
			g.PageScale = 2;
			g.PageUnit = GraphicsUnit.Inch;
			g.PixelOffsetMode = PixelOffsetMode.Half;
			g.Clip = new Region (new Rectangle (0, 0, 100, 100));
			g.RenderingOrigin = new Point (10, 20);
			g.SmoothingMode = SmoothingMode.AntiAlias;
			g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;


			state_modified = g.Save (); // Modified

			g.CompositingMode = CompositingMode.SourceOver;
			g.CompositingQuality = CompositingQuality.Default;
			g.InterpolationMode = InterpolationMode.Bilinear;
			g.PageScale = 5;
			g.PageUnit = GraphicsUnit.Display;
			g.PixelOffsetMode = PixelOffsetMode.Default;
			g.Clip = new Region (new Rectangle (1, 2, 20, 25));
			g.RenderingOrigin = new Point (5, 6);
			g.SmoothingMode = SmoothingMode.None;
			g.TextRenderingHint = TextRenderingHint.SystemDefault;

			g.Restore (state_modified);

			Assert.AreEqual (CompositingMode.SourceCopy, g.CompositingMode, "SetSaveReset1");
			Assert.AreEqual (CompositingQuality.GammaCorrected, g.CompositingQuality, "SetSaveReset2");
			Assert.AreEqual (InterpolationMode.HighQualityBilinear, g.InterpolationMode, "SetSaveReset3");
			Assert.AreEqual (2, g.PageScale, "SetSaveReset4");
			Assert.AreEqual (GraphicsUnit.Inch, g.PageUnit, "SetSaveReset5");
			Assert.AreEqual (PixelOffsetMode.Half, g.PixelOffsetMode, "SetSaveReset6");
			Assert.AreEqual (new Point (10, 20), g.RenderingOrigin, "SetSaveReset7");
			Assert.AreEqual (SmoothingMode.AntiAlias, g.SmoothingMode, "SetSaveReset8");
			Assert.AreEqual (TextRenderingHint.ClearTypeGridFit, g.TextRenderingHint, "SetSaveReset9");
			Assert.AreEqual (0, (int) g.ClipBounds.X, "SetSaveReset10");
			Assert.AreEqual (0, (int) g.ClipBounds.Y, "SetSaveReset10");

			g.Restore (state_default);

			Assert.AreEqual (CompositingMode.SourceOver, g.CompositingMode, "SetSaveReset11");
			Assert.AreEqual (CompositingQuality.Default, g.CompositingQuality, "SetSaveReset12");
			Assert.AreEqual (InterpolationMode.Bilinear, g.InterpolationMode, "SetSaveReset13");
			Assert.AreEqual (1, g.PageScale, "SetSaveReset14");
			Assert.AreEqual (GraphicsUnit.Display, g.PageUnit, "SetSaveReset15");
			Assert.AreEqual (PixelOffsetMode.Default, g.PixelOffsetMode, "SetSaveReset16");
			Assert.AreEqual (new Point (0, 0), g.RenderingOrigin, "SetSaveReset17");
			Assert.AreEqual (SmoothingMode.None, g.SmoothingMode, "SetSaveReset18");
			Assert.AreEqual (TextRenderingHint.SystemDefault, g.TextRenderingHint, "SetSaveReset19");

			Region r = new Region ();
			Assert.AreEqual (r.GetBounds (g), g.ClipBounds, "SetSaveReset20");

			g.Dispose ();
		}
开发者ID:Profit0004,项目名称:mono,代码行数:64,代码来源:TestGraphics.cs

示例6: GetTransformCellRect

 private RectangleF GetTransformCellRect(int index)
 {
     RectangleF rect = GetCellRect(index);
     Region region = new Region(rect);
     region.Translate(AutoScrollPosition.X, AutoScrollPosition.Y);
     rect = region.GetBounds(CreateGraphics());
     return rect;
 }
开发者ID:khonsoe,项目名称:keymagic,代码行数:8,代码来源:GlypeTable.cs

示例7: PaintForm

        private void PaintForm(Graphics g, Region clip)
        {
            if (!clip.GetBounds(g).Equals(UpdateRegion.GetBounds(g)))
                UpdateRegion.Union(clip);

            DrawBackground(g);

            Opacity = Layout.Settings.Opacity;

            if (Layout.Settings.AntiAliasing)
                g.TextRenderingHint = TextRenderingHint.AntiAlias;
            else
                g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
            g.CompositingQuality = CompositingQuality.GammaCorrected;
            g.InterpolationMode = InterpolationMode.Bilinear;
            g.SmoothingMode = SmoothingMode.AntiAlias;

            ComponentRenderer.CalculateOverallSize(Layout.Mode);

            var scaleFactor = Layout.Mode == LayoutMode.Vertical
                ? Height / Math.Max(ComponentRenderer.OverallSize, 1f)
                : Width / Math.Max(ComponentRenderer.OverallSize, 1f);

            g.ResetTransform();
            g.ScaleTransform(scaleFactor, scaleFactor);
            float transformedWidth = Width;
            float transformedHeight = Height;

            if (Layout.Mode == LayoutMode.Vertical)
                transformedWidth /= scaleFactor;
            else
                transformedHeight /= scaleFactor;

            BackColor = Color.Black;

            ComponentRenderer.Render(g, CurrentState, transformedWidth, transformedHeight, Layout.Mode, UpdateRegion);

            var currentSize = ComponentRenderer.OverallSize;

            if (OldSize >= 0)
            {
                if (OldSize != currentSize)
                {
                    MinimumSize = new Size(0, 0);
                    if (Layout.Mode == LayoutMode.Vertical)
                        Height = (int)((currentSize / (double)OldSize) * Height + 0.5);
                    else
                        Width = (int)((currentSize / (double)OldSize) * Width + 0.5);
                }
                FixSize();
                if (Layout.Mode == LayoutMode.Vertical)
                    MinimumSize = new Size(100, (int)((ComponentRenderer.OverallSize / 3) + 0.5f));
                else
                    MinimumSize = new Size((int)((ComponentRenderer.OverallSize / 3) + 0.5f), 25);
            }
            else
            {
                if (Layout.Mode == LayoutMode.Vertical)
                    Size = new Size(Layout.VerticalWidth, Layout.VerticalHeight);
                else
                    Size = new Size(Layout.HorizontalWidth, Layout.HorizontalHeight);
                OldSize++;
            }

            if (OldSize >= 0)
                OldSize = currentSize;
        }
开发者ID:TheKotti,项目名称:LiveSplit,代码行数:67,代码来源:TimerForm.cs

示例8: PaintForm

        private void PaintForm(Graphics g, Region clip)
        {
            if (CurrentState.LayoutSettings.BackgroundColor != Color.Transparent
                || CurrentState.LayoutSettings.BackgroundGradient != GradientType.Plain
                && CurrentState.LayoutSettings.BackgroundColor2 != Color.Transparent)
            {
                var gradientBrush = new LinearGradientBrush(
                            new PointF(0, 0),
                            CurrentState.LayoutSettings.BackgroundGradient == GradientType.Horizontal
                            ? new PointF(this.Size.Width, 0)
                            : new PointF(0, this.Size.Height),
                            CurrentState.LayoutSettings.BackgroundColor,
                            CurrentState.LayoutSettings.BackgroundGradient == GradientType.Plain
                            ? CurrentState.LayoutSettings.BackgroundColor
                            : CurrentState.LayoutSettings.BackgroundColor2);
                g.FillRectangle(gradientBrush, 0, 0, this.Size.Width, this.Size.Height);
            }

            this.Opacity = Layout.Settings.Opacity;

            if (Layout.Settings.AntiAliasing)
                g.TextRenderingHint = TextRenderingHint.AntiAlias;
            else
                g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
            g.CompositingQuality = CompositingQuality.GammaCorrected;
            g.InterpolationMode = InterpolationMode.Bilinear;
            g.SmoothingMode = SmoothingMode.AntiAlias;

            var scaleFactor = Layout.Mode == LayoutMode.Vertical
                ? (float)this.Height / Math.Max(ComponentRenderer.OverallHeight, 1f)
                : (float)this.Width / Math.Max(ComponentRenderer.OverallWidth, 1f);

            g.ResetTransform();
            g.ScaleTransform(scaleFactor, scaleFactor);
            float transformedWidth = this.Width;
            float transformedHeight = this.Height;

            if (Layout.Mode == LayoutMode.Vertical)
                transformedWidth /= scaleFactor;
            else
                transformedHeight /= scaleFactor;

            this.BackColor = Color.Black;

            if (!clip.GetBounds(g).Equals(UpdateRegion.GetBounds(g)))
                UpdateRegion.Union(clip);

            /*if (!CurrentState.DrawLock.TryEnterReadLock(500))
                return;*/

            ComponentRenderer.Render(g, CurrentState, transformedWidth, transformedHeight, Layout.Mode, UpdateRegion);
                
            //CurrentState.DrawLock.ExitReadLock();

            var currentSize = Layout.Mode == LayoutMode.Vertical ? ComponentRenderer.OverallHeight : ComponentRenderer.OverallWidth;

            if (OldSize >= 0)
            {
                if (OldSize != currentSize)
                {
                    this.MinimumSize = new Size(0, 0);
                    if (Layout.Mode == LayoutMode.Vertical)
                        this.Height = (int)((currentSize / (double)OldSize) * this.Height + 0.5);
                    else
                        this.Width = (int)((currentSize / (double)OldSize) * this.Width + 0.5);
                }
                FixSize();
                if (Layout.Mode == LayoutMode.Vertical)
                    this.MinimumSize = new Size(100, (int)((ComponentRenderer.OverallHeight / 2) * (100 / Math.Max(100, ComponentRenderer.MinimumWidth)) + 0.5f));
                else
                    this.MinimumSize = new Size((int)((ComponentRenderer.OverallWidth / 2) * (25 / Math.Max(25, ComponentRenderer.MinimumHeight)) + 0.5f), 25);
            }
            else
            {
                if (Layout.Mode == LayoutMode.Vertical)
                    this.Size = new Size(Layout.VerticalWidth, Layout.VerticalHeight);
                else
                    this.Size = new Size(Layout.HorizontalWidth, Layout.HorizontalHeight);
                OldSize++;
            }

            if (OldSize == 0)
                RefreshesRemaining = 10;

            if (OldSize >= 0)
                OldSize = currentSize;
        }
开发者ID:xarrez,项目名称:LiveSplit,代码行数:87,代码来源:TimerForm.cs

示例9: PushClip

		/// <summary>
		/// Overridden.  PiccoloDirect3D only supports rectangular clip regions.  So, if a
		/// non-rectangular region is pushed, the bounds of that region will be used instead.
		/// </summary>
		/// <param name="aClip">The clip to push.</param>
		public override void PushClip(Region aClip) {
			PushClip(aClip.GetBounds(graphics));
		}
开发者ID:malacandrian,项目名称:Piccolo.NET,代码行数:8,代码来源:P3PaintContext.cs

示例10: foreach

        /*public void ResetPoly()
        {
            SvgElementCollection col= tlVectorControl1.SVGDocument.SelectCollection;
            if(col.Count<1){
                return;
            }
            SvgElementCollection.ISvgElementEnumerator enumerator1 = tlVectorControl1.DrawArea.ElementList.GetEnumerator();
            foreach(SvgElement ele in col){
                if (ele.GetType().ToString() == "ItopVector.Core.Figure.Polygon")
                {
                    glebeProperty p=new glebeProperty();
                    p.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    p.EleID = ((IGraph)ele).ID;
                    p = Services.BaseService.GetObject("SelectglebePropertyByEleID", p);
                    if(p!=null){
                        PointF[] tfArray1 = TLMath.getPolygonPoints(ele);
                        GraphicsPath selectAreaPath = new GraphicsPath();
                        selectAreaPath.AddLines(tfArray1);
                        selectAreaPath.CloseFigure();
                        Region region1 = new Region(selectAreaPath);
                        while (enumerator1.MoveNext())
                        {
                            IGraph graph1 = (IGraph)enumerator1.Current;
                            GraphicsPath path1 = (GraphicsPath)graph1.GPath.Clone();
                            path1.Transform(graph1.GraphTransform.Matrix);
                            Region region2 = new Region(path1);
                            region2.Intersect(region1);
                            if (!region2.GetBounds(Graphics.FromHwnd(IntPtr.Zero)).IsEmpty)
                            {
                                glebeProperty p1 = new glebeProperty();
                                p1.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                p1.EleID = graph1.ID;
                                p1 = Services.BaseService.GetObject("SelectglebePropertyByEleID", p1);
                                if(p1!=null){
                                    p1.ParentEleID = p.UID;
                                    Services.BaseService.Update("UpdateglebePropertyAreaAll", p1);
                                }
                            }
                        }
                    }
                }
            }
            MessageBox.Show("更新完成。","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
        }*/
        private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            try
            {
                if (e.ClickedItem.Text == "属性")
                {
                    XmlElement xml1 = (XmlElement)tlVectorControl1.SVGDocument.CurrentElement;
                    //PointF[] pf = TLMath.getPolygonPoints(xml1);
                    DeviceHelper.xml1 = xml1;
                    //((Polygon)xml1).Transform.Matrix.TransformPoints(pf);
                    // 规划
                    if (getlayer(SvgDocument.currentLayer, "电网规划层", tlVectorControl1.SVGDocument.getLayerList()))
                    {

                        if (xml1 == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg")
                        {
                            MessageBox.Show("请先选择规划区域。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.RectangleElement")
                        {
                            //frmImgManager frm = new frmImgManager();
                            //frm.Show();
                        }
                        if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Polygon")
                        {
                            XmlNodeList n1 = tlVectorControl1.SVGDocument.GetElementsByTagName("use");
                            PointF[] tfArray1 = TLMath.getPolygonPoints(xml1);
                            string str220 = "";
                            string str110 = "";
                            string str66 = "";

                            string str_id = "";
                            GraphicsPath selectAreaPath = new GraphicsPath();
                            selectAreaPath.AddLines(tfArray1);
                            selectAreaPath.CloseFigure();
                            //Matrix x=new Matrix(
                            //Region region1 = new Region(selectAreaPath);
                            for (int i = 0; i < n1.Count; i++)
                            {
                                float OffX = 0f;
                                float OffY = 0f;
                                bool ck = false;
                                Use use = (Use)n1[i];
                                if (use.GetAttribute("xlink:href").Contains("byq") || use.GetAttribute("xlink:href").Contains("pds"))
                                {
                                    if (selectAreaPath.IsVisible(use.CenterPoint))
                                    {
                                        if (use.GetAttribute("Deviceid") != "")
                                        {
                                            str_id = str_id + "'" + use.GetAttribute("Deviceid") + "',";
                                        }
                                    }
                                }
                                if (use.GetAttribute("xlink:href").Contains("Substation"))
                                {
//.........这里部分代码省略.........
开发者ID:EdgarEDT,项目名称:myitoppsp,代码行数:101,代码来源:frmMain_Spatial.cs

示例11: InfinityIntersectTransform

		public void InfinityIntersectTransform ()
		{
			using (Region r = new Region ()) {
				Assert.IsTrue (r.IsInfinite (graphic), "before");
				r.Intersect (new Rectangle (-10, -10, 20, 20));
				using (Matrix m = new Matrix (2, 0, 0, 0.5f, 10, 10)) {
					r.Transform (m);
				}
				RectangleF bounds = r.GetBounds (graphic);
				Assert.AreEqual (-10, bounds.X, "X");
				Assert.AreEqual (5, bounds.Y, "Y");
				Assert.AreEqual (40, bounds.Width, "Width");
				Assert.AreEqual (10, bounds.Height, "Height");
			}
		}
开发者ID:Profit0004,项目名称:mono,代码行数:15,代码来源:TestRegion.cs

示例12: InfinityIntersectTranslate

		public void InfinityIntersectTranslate ()
		{
			using (Region r = new Region ()) {
				Assert.IsTrue (r.IsInfinite (graphic), "before");
				r.Intersect (new Rectangle (-10, -10, 20, 20));
				r.Translate (10, 10);
				RectangleF bounds = r.GetBounds (graphic);
				Assert.AreEqual (0, bounds.X, "X");
				Assert.AreEqual (0, bounds.Y, "Y");
				Assert.AreEqual (20, bounds.Width, "Width");
				Assert.AreEqual (20, bounds.Height, "Height");
			}
		}
开发者ID:Profit0004,项目名称:mono,代码行数:13,代码来源:TestRegion.cs

示例13: InfinityExclude

		public void InfinityExclude ()
		{
			using (Region r = new Region ()) {
				Assert.IsTrue (r.IsInfinite (graphic), "before");
				r.Exclude (new Rectangle (5, 5, 10, 10));
				Assert.IsFalse (r.IsInfinite (graphic), "after");
				RectangleF bounds = r.GetBounds (graphic);
				Assert.AreEqual (-4194304, bounds.X, "X");
				Assert.AreEqual (-4194304, bounds.Y, "Y");
				Assert.AreEqual (8388608, bounds.Width, "Width");
				Assert.AreEqual (8388608, bounds.Height, "Height");
			}
		}
开发者ID:Profit0004,项目名称:mono,代码行数:13,代码来源:TestRegion.cs

示例14: Animator06

        // 原理:将图像分为正方形块,然后计算所有分块按照奇偶从左到右显示或从右到左显示所需的区域,并用材质画刷填充
        private void Animator06()
        {
            const float blockSize = 70; // 正方块的边长
            const int showWidth = 1; // 每次显示的像素列数
            try
            {
                OnDrawStarted(this, EventArgs.Empty);
                ClearBackground();

                // 建立空区域,如使用Region的无参构造函数则建立一个无限大小的区域,而非空区域
                Region region = new Region(new GraphicsPath());
                // 建立位图材质画刷
                TextureBrush textureBrush = new TextureBrush(bmp);
                // 分块的行坐标+列坐标为偶数则从左到右逐列显示本块,否则从右到左逐列显示本块
                for (int i = 0; i <= Math.Ceiling(blockSize / showWidth); i++)
                {
                    for (int x = 0; x < Math.Ceiling(bmp.Width / blockSize); x++)
                    {
                        for (int y = 0; y < Math.Ceiling(bmp.Height / blockSize); y++)
                        {
                            RectangleF rect;
                            // 判断块的行列坐标和为奇数或偶数
                            if ((x + y) % 2 == 0)
                            {
                                rect = new RectangleF(x * blockSize + i * showWidth, y * blockSize, showWidth, blockSize);
                            }
                            else
                            {
                                rect = new RectangleF((x + 1) * blockSize - i * showWidth, y * blockSize, showWidth, blockSize);
                            }
                            region.Union(rect); // 将要显示的区域合并到region中
                        }
                    }
                    dc.FillRegion(textureBrush, region); // 使用材质画刷填充区域

                    ShowBmp(region.GetBounds(dc));
                    Thread.Sleep(10 * delay);
                }
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
            finally
            {
                OnDrawCompleted(this, EventArgs.Empty);
            }
        }
开发者ID:burstas,项目名称:rmps,代码行数:49,代码来源:Animator.cs

示例15: Animator03

        // 原理:由大到小生成图像中心区域,然后用总区域减去该中心区域,并用材质画刷填充
        private void Animator03()
        {
            const float stepCount = 4; // 每次收缩的步长像素
            try
            {
                OnDrawStarted(this, EventArgs.Empty);
                ClearBackground();

                // 建立空区域,如使用Region的无参构造函数则建立一个无限大小的区域,而非空区域
                Region region = new Region(new GraphicsPath());
                // 建立位图材质画刷
                TextureBrush textureBrush = new TextureBrush(bmp);
                for (float x = 0; x <= bmp.Width / 2f; x += stepCount)
                {
                    // 添加整个位图区域
                    region.Union(new Rectangle(0, 0, bmp.Width, bmp.Height));
                    // 从中心开始,由大到小填充背景色或填充缩小尺寸的原图
                    // 计算高度变化量,如果宽度大,则高度变化量小于宽度,否则大于宽度
                    float y = x * bmp.Height / bmp.Width;
                    RectangleF rect = new RectangleF(x, y, bmp.Width - 2f * x, bmp.Height - 2f * y);
                    // 计算整个位图区域与背景色区域的差集
                    region.Exclude(rect);
                    dc.FillRegion(textureBrush, region); // 使用材质画刷填充区域

                    ShowBmp(region.GetBounds(dc));
                    Thread.Sleep(10 * delay);
                }
                // 由于stepCount可能无法被宽度整除,则最终生成的背景色区域并不为空,故在循环结束后绘制整个位图
                dc.DrawImage(bmp, 0, 0);

                ShowBmp();
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
            finally
            {
                OnDrawCompleted(this, EventArgs.Empty);
            }
        }
开发者ID:burstas,项目名称:rmps,代码行数:42,代码来源:Animator.cs


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