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


C# Size.IsValid方法代码示例

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


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

示例1: Config

        public void Config(Size pageSize)
        {
            Contract.Requires(pageSize.IsValid());
            Debug.Assert(m_flipper == null);

            PageWidth = pageSize.Width;
            PageHeight = pageSize.Height;
            PageDoubleWidth = pageSize.Width * 2;
            m_turningPageBack.Clip = new RectangleGeometry() { Rect = new Rect(new Point(), pageSize) };

            // TODO: HotSpot support need to be enabled with page content model
            m_flipper = new PageFlipper(pageSize, null, m_pageTop, m_curlShadow, m_shadow);

            m_flipper.IsAnimatingChanged += (sender, args) =>
            {
                if (!m_flipper.IsAnimating)
                {
                    m_working = false;
                    var stillWorking = startDance();
                    if (!stillWorking)
                    {
                        OnDoneFlipping();
                    }
                }
            };

            m_turningPageBack.RenderTransform = m_flipper.FlippingPageBackTransform;
            m_page2nd.Clip = m_flipper.NextPageClip;
            m_pageTop.Clip = m_flipper.PageHolderClip;

            m_contentBitmapLeft = new WriteableBitmap((int)pageSize.Width, (int)pageSize.Height);
            m_contentBitmapRight = new WriteableBitmap((int)pageSize.Width, (int)pageSize.Height);
            m_currentContentSnapshot = new WriteableBitmap((int)pageSize.Width * 2, (int)pageSize.Height);
            m_nextContentSnapshot = new WriteableBitmap((int)pageSize.Width * 2, (int)pageSize.Height);

#if FUNKY
      var stack = new StackPanel() { HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Bottom, Opacity = .67 };

      (new WriteableBitmap[] { m_currentContentSnapshot, m_nextContentSnapshot, m_contentBitmapLeft, m_contentBitmapRight }).ForEach(wp => {
        var image = new Image() { Source = wp, Stretch = Stretch.UniformToFill, Height = 150, Width = 200 };
        stack.Children.Add(image);
      });

      ((Grid)Content).Children.Add(stack);

#endif

            m_leftImage.Source = m_contentBitmapLeft;
            m_rightImage.Source = m_contentBitmapRight;
        }
开发者ID:hungdluit,项目名称:bot,代码行数:50,代码来源:FlipControl.xaml.cs

示例2: ScaleToFit

        /// <summary>
        ///     Returns the scale factor by which an object of size <paramref name="source"/>
        ///     should be scaled to fit within an object of size <param name="target"/>.
        /// </summary>
        /// <param name="target">The target size.</param>
        /// <param name="size2">The source size.</param>
        public static double ScaleToFit(Size target, Size source)
        {
            Contract.Requires(target.IsValid());
            Contract.Requires(source.IsValid());
            Contract.Requires(target.Width > 0);
            Contract.Requires(source.Width > 0);

            double targetHWR = target.Height / target.Width;
            double sourceHWR = source.Height / source.Width;

            if (targetHWR > sourceHWR)
            {
                return target.Width / source.Width;
            }
            else
            {
                return target.Height / source.Height;
            }
        }
开发者ID:heartszhang,项目名称:WeiZhi3,代码行数:25,代码来源:GeoHelper.cs

示例3: Subtract

 public static Vector Subtract(this Size size, Size other)
 {
     Contract.Requires(size.IsValid());
     Contract.Requires(other.IsValid());
     Contract.Ensures(Contract.Result<Vector>().IsValid());
     return new Vector(size.Width - other.Width, size.Height - other.Height);
 }
开发者ID:heartszhang,项目名称:WeiZhi3,代码行数:7,代码来源:GeoHelper.cs

示例4: PageFlipper

        public PageFlipper(Size pageSize, UIElement hotCorner, UIElement pageHolder, FrameworkElement curlShadow, FrameworkElement dropShadow)
        {
            Contract.Requires(pageSize.IsValid());
            m_pageSize = pageSize;

            m_hotCorner = hotCorner;

            m_curlShadow = curlShadow;
            m_dropShadow = dropShadow;

            // can be null
            m_pageHolder = pageHolder;

            #region helper values
            m_pageHalfHeight = m_pageSize.Height * .5;
            m_origin = new Point(m_pageSize.Width, m_pageSize.Height / 2.0);
            m_pageDiagonal = Math.Sqrt(m_pageSize.Width * m_pageSize.Width + m_pageSize.Height * m_pageSize.Height);
            m_pointLeft = new Point(-m_pageSize.Width, m_pageHalfHeight);
            m_pointRight = new Point(m_pageSize.Width, m_pageHalfHeight);
            #endregion

            #region clips and transforms

            m_pageTransformGroup = new TransformGroup();
            m_pageTransformGroup.Children.Add(new TranslateTransform() { Y = -m_pageSize.Height });
            m_pageTransformGroup.Children.Add(m_pageRotateTransform = new RotateTransform());
            m_pageTransformGroup.Children.Add(m_pageTranslateTransform = new TranslateTransform());

            m_pageHolderClip = new RectangleGeometry() { Rect = new Rect(0, 0, m_pageSize.Width, m_pageSize.Height * 2) };
            m_nextPageClip = new RectangleGeometry() { Rect = new Rect(0, 0, m_pageSize.Width * 2, m_pageSize.Height * 2) };

            if (m_curlShadow != null)
            {
                var group = new TransformGroup();
                group.Children.Add(m_curlShadowRotate = new RotateTransform());
                group.Children.Add(m_curlShadowTranslate = new TranslateTransform());
                m_curlShadow.RenderTransform = group;

                m_curlShadow.Height = m_pageDiagonal * 1.5;
                m_curlShadowRotate.CenterX = m_curlShadow.Width;
                m_curlShadowRotate.CenterY = m_pageDiagonal;

                m_curlShadowTranslate.Y = m_pageSize.Height - m_pageDiagonal;
            }

            if (m_dropShadow != null)
            {
                //m_dropShadowBlurEffect = new BlurEffect() { Radius = 20 };
                //m_dropShadow.Effect = m_dropShadowBlurEffect;
                m_dropShadow.RenderTransform = m_pageTransformGroup;
                m_dropShadow.Width = m_pageSize.Width;
                m_dropShadow.Height = m_pageSize.Height;
            }

            #endregion

            // MOST OF THE LOADED FUNCTION IS USED TO SET LOOK UP VALUES
            // BASED ON THE pageWidth AND pageHeight INITIALLY DEFINED.
            // POSITION THE PAGE AND SPINE VISUALS ACCORDINGLY
            m_mouse.X = m_pageSize.Width - 1;
            m_mouse.Y = m_pageHalfHeight - 1;
            m_follow = m_mouse;

            #region mouse handlers

            if (m_hotCorner != null && m_pageHolder != null)
            {
                m_hotCorner.MouseMove += (sender, e) =>
                {
                    m_animating = false;
                    m_listener.StartListening();
                    Point testBounds = (Point)e.GetPosition(m_pageHolder).Subtract(m_origin);
                    if (testBounds.X > m_pageSize.Width && testBounds.Y > m_pageHalfHeight)
                    {
                        m_mouse = m_pointRight;
                    }
                    else
                    {
                        m_mouse = testBounds;
                    }
                };

                m_hotCorner.MouseLeftButtonDown += (sender, e) =>
                {
                    m_hotCorner.CaptureMouse();
                };

                m_hotCorner.MouseLeftButtonUp += (sender, e) =>
                {
                    m_listener.StartListening();
                    m_hotCorner.ReleaseMouseCapture();
                    m_mouse = (m_mouse.X < 0) ? m_pointLeft : m_pointRight;
                };

                m_hotCorner.MouseLeave += (sender, e) =>
                {
                    m_listener.StartListening();
                    m_mouse = m_pointRight;
                };
            }
//.........这里部分代码省略.........
开发者ID:edealbag,项目名称:bot,代码行数:101,代码来源:PageFlipper.cs


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