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


C# Rect.Deflate方法代码示例

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


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

示例1: Render

        public override void Render (ConsoleBuffer buffer)
        {
            if (buffer == null)
                throw new ArgumentNullException(nameof(buffer));

            Rect renderRectWithoutShadow = new Rect(RenderSize).Deflate(Thickness.Max(Shadow, 0));

            //base.Render(buffer);
            if (Background != null)
                buffer.FillBackgroundRectangle(renderRectWithoutShadow, Background.Value);
            buffer.FillForegroundRectangle(new Rect(RenderSize), EffectiveColor);

            if (!Shadow.IsEmpty) {
                // 3 2 2 1:     -1 -1 2 3:
                // ▄▄▄▄▄▄▄▄▄    oooo▄▄
                // █████████    oooo██
                // ███oooo██     █████
                // ███oooo██     █████
                // ▀▀▀▀▀▀▀▀▀     ▀▀▀▀▀
                Thickness shadowLineDelta = new Thickness(0, 1);
                Thickness shadowOffset = Thickness.Max(-Shadow - shadowLineDelta, 0);
                Rect shadowRect = new Rect(RenderSize).Deflate(shadowOffset);

                if (Shadow.Top != 0)
                    buffer.FillForegroundLine(shadowRect.TopLine, ShadowColor, Chars.LowerHalfBlock);
                if (Shadow.Bottom != 0)
                    buffer.FillForegroundLine(shadowRect.BottomLine, ShadowColor, Chars.UpperHalfBlock);
                buffer.FillForegroundRectangle(shadowRect.Deflate(shadowLineDelta), ShadowColor, Chars.FullBlock);
                if (ShadowColor == null && ShadowColorMap != null)
                    buffer.ApplyColorMap(shadowRect, ShadowColorMap,
                        (ref ConsoleChar c) => c.ForegroundColor = ShadowColorMap[(int)c.BackgroundColor]);
            }
            buffer.FillForegroundRectangle(renderRectWithoutShadow, EffectiveColor);
            buffer.DrawRectangle(renderRectWithoutShadow, EffectiveColor, Stroke);
        }
开发者ID:jhorv,项目名称:CsConsoleFormat,代码行数:35,代码来源:Border.cs

示例2: MainInterop

    // --------------------------------------------------------------------------
    // Section 9.5 Using F# libraries from C#
    // Note: You have to add reference using 'Add Reference' first.
    // The 'using' directive is above.
    static void MainInterop()
    {
        // Create an instance of the class
        var rc1 = new Rect(0.0f, 100.0f, 0.0f, 50.0f);

        // Invoke a functional member of the class
        var rc2 = rc1.Deflate(20.0f, 10.0f);

        // Prints '(10, 20) - (60, 30)'
        Console.WriteLine("({0}, {1}) - ({2}, {3})",
        rc2.Left, rc2.Top, rc2.Width, rc2.Height);
    }
开发者ID:clp-takekawa,项目名称:codes-from-books,代码行数:16,代码来源:Program.cs

示例3: Main

        static void Main(string[] args)
        {
            var rc = new Rect(50.0f, 60.0f, 300.0f, 200.0f);
            // Note that rc is immutable, you cannot change the values
            // once it is created. You can only create new copies with modified
            // values.
            var rc2 = rc.Deflate(20.0f, 10.0f);
            Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-us");
            var msg = String.Format("{0:f}; {1:f}; {2:f}; {3:f}", rc2.Left, rc2.Top, rc2.Width, rc2.Height);
            Console.WriteLine(msg);
            // Using a static function from module MyModule
            Console.WriteLine(MyModule.Add(1, 2));
            Console.ReadLine();

        }
开发者ID:jmchapman,项目名称:ITT8060.2013,代码行数:15,代码来源:live8b.cs

示例4: ArrangeOverride

        protected override Size ArrangeOverride(Size finalSize)
        {
            IElement child = this.Child;

            if (child != null)
            {
                var finalRect = new Rect(new Point(), finalSize);

                finalRect = finalRect.Deflate(this.BorderThickness);
                finalRect = finalRect.Deflate(this.Padding);
                child.Arrange(finalRect);
            }

            return finalSize;
        }
开发者ID:redbadger,项目名称:XPF,代码行数:15,代码来源:Border.cs

示例5: ArrangeToFill

        private static void ArrangeToFill(Size availableSize, Margins margins, ILayoutable layoutable)
        {
            var containerRect = new Rect(new Point(0,0), availableSize);
            var marginsCutout = margins.AsThickness();
            var withoutMargins = containerRect.Deflate(marginsCutout);

            var finalSize = GetConstrainedSize(layoutable, withoutMargins);

            var finalRect = withoutMargins.AlignChild(finalSize, Alignment.Middle, Alignment.Middle);

            layoutable.Arrange(finalRect);
        }
开发者ID:shahid-pk,项目名称:Perspex,代码行数:12,代码来源:DockPanel.cs


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