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


C# Surface.ClearWithCheckboardPattern方法代码示例

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


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

示例1: DrawToGraphics

        private void DrawToGraphics(Graphics g)
        {
            PointF clientPos = new PointF(
                (this.position.X * this.dragAreaRect.Width) / ClientSize.Width,
                (this.position.Y * this.dragAreaRect.Height) / ClientSize.Height);

            PointF ptCenter = new PointF(ClientSize.Width / 2.0f, ClientSize.Height / 2.0f);
            PointF ptDot = new PointF((1 + clientPos.X) * ClientSize.Width / 2.0f, (1 + clientPos.Y) * ClientSize.Height / 2.0f);
            PointF ptArrow;

            if (-1 <= clientPos.X && clientPos.X <= 1 &&
                -1 <= clientPos.Y && clientPos.Y <= 1)
            {
                ptArrow = new PointF((1 + clientPos.X) * ClientSize.Width / 2, (1 + clientPos.Y) * ClientSize.Height / 2);
            }
            else
            {
                ptArrow = new PointF((1 + clientPos.X) * ClientSize.Width / 2, (1 + clientPos.Y) * ClientSize.Height / 2);

                if (Math.Abs(clientPos.X) > Math.Abs(clientPos.Y))
                {
                    if (clientPos.X > 0)
                    {
                        ptArrow.X = ClientSize.Width - 1;
                        ptArrow.Y = (1 + clientPos.Y / clientPos.X) * ClientSize.Height / 2;
                    }
                    else
                    {
                        ptArrow.X = 0;
                        ptArrow.Y = (1 - clientPos.Y / clientPos.X) * ClientSize.Height / 2;
                    }
                }
                else
                {
                    if (clientPos.Y > 0)
                    {
                        ptArrow.X = (1 + clientPos.X / clientPos.Y) * ClientSize.Width / 2;
                        ptArrow.Y = ClientSize.Height - 1;
                    }
                    else
                    {
                        ptArrow.X = (1 - clientPos.X / clientPos.Y) * ClientSize.Width / 2;
                        ptArrow.Y = 0;
                    }
                }
            }

            CompositingMode oldCM = g.CompositingMode;

            g.CompositingMode = CompositingMode.SourceCopy;
            g.Clear(this.BackColor);
            g.CompositingMode = CompositingMode.SourceOver;

            if (this.staticImageUnderlay != null)
            {
                Size dstSize;

                if (this.cachedUnderlay != null)
                {
                    dstSize = new Size(this.cachedUnderlay.Width, this.cachedUnderlay.Height);
                }
                else
                {
                    Image image = this.staticImageUnderlay.Reference;
                    Rectangle srcRect = new Rectangle(0, 0, image.Width, image.Height);

                    Size maxThumbSize = new Size(
                        Math.Max(1, Math.Min(ClientSize.Width - 4, srcRect.Width)),
                        Math.Max(1, Math.Min(ClientSize.Height - 4, srcRect.Height)));

                    dstSize = Utility.ComputeThumbnailSize(image.Size, Math.Min(maxThumbSize.Width, maxThumbSize.Height));

                    this.cachedUnderlay = new Bitmap(dstSize.Width, dstSize.Height, PixelFormat.Format24bppRgb);

                    Surface checkers = new Surface(dstSize);
                    checkers.ClearWithCheckboardPattern();
                    Bitmap checkersBmp = checkers.CreateAliasedBitmap();

                    Rectangle gcuRect = new Rectangle(0, 0, this.cachedUnderlay.Width, this.cachedUnderlay.Height);

                    using (Graphics gcu = Graphics.FromImage(this.cachedUnderlay))
                    {
                        gcu.CompositingMode = CompositingMode.SourceOver;
                        gcu.DrawImage(checkersBmp, gcuRect, new Rectangle(0, 0, checkersBmp.Width, checkersBmp.Height), GraphicsUnit.Pixel);

                        gcu.InterpolationMode = InterpolationMode.HighQualityBicubic;
                        RectangleF gcuRect2 = RectangleF.Inflate(gcuRect, 0.5f, 0.5f);
                        gcu.DrawImage(image, gcuRect2, srcRect, GraphicsUnit.Pixel);
                    }

                    checkersBmp.Dispose();
                    checkersBmp = null;

                    checkers.Dispose();
                    checkers = null;
                }

                Rectangle dstRect = new Rectangle((ClientSize.Width - dstSize.Width) / 2, (ClientSize.Height - dstSize.Height) / 2, dstSize.Width, dstSize.Height);
                g.DrawImage(this.cachedUnderlay, dstRect, new Rectangle(0, 0, this.cachedUnderlay.Width, this.cachedUnderlay.Height), GraphicsUnit.Pixel);
                g.DrawRectangle(Pens.Black, new Rectangle(dstRect.Left - 1, dstRect.Top - 1, dstRect.Width + 1, dstRect.Height + 1));
//.........这里部分代码省略.........
开发者ID:metadeta96,项目名称:openpdn,代码行数:101,代码来源:PanControl.cs


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