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


C# Rect.Transform方法代码示例

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


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

示例1: WindowBoundsValidAnyScreen

		static bool WindowBoundsValidAnyScreen(PresentationSource source, Rect bounds)
		{
			foreach (var screen in System.Windows.Forms.Screen.AllScreens) {
				var wa = screen.WorkingArea;
				var i = new Rect(wa.X, wa.Y, wa.Width, wa.Height);
				i.Transform(source.CompositionTarget.TransformFromDevice);
				i.Intersect(bounds);
				if (i.Width > 10 && i.Height > 10) return true;
			}
			return false;
		}
开发者ID:x-strong,项目名称:ILSpy,代码行数:11,代码来源:MainWindow.xaml.cs

示例2: OnRequestBringIntoView

        /// <summary>
        /// Brings the SN into view. When navigate through the keyboard navigation the focus
        /// can get to a SN that is not currently  into view.
        /// </summary>
        /// <param name="sender">sender</param>
        /// <param name="e">arguments</param>
        /// <remarks> Since the AdornerLayer does not have scrolling abilities we need to scroll
        /// AnnotatedElement. In order to get out SN into view we must calculate the corresponding area of
        /// the AnnotatedElement.</remarks>
        private void OnRequestBringIntoView(Object sender, RequestBringIntoViewEventArgs e)
        {
            Debug.Assert(((IAnnotationComponent)this).AnnotatedElement != null, "undefined annotated element");
            FrameworkElement target = ((IAnnotationComponent)this).AnnotatedElement as FrameworkElement;

            DocumentPageHost host = target as DocumentPageHost;
            if (host != null)
            {
                target = host.PageVisual as FrameworkElement;
            }

            if (target == null)
            {
                //we have nothing to do here
                return;
            }

            //if target is IScrollInfo - check if we are within the viewport
            IScrollInfo scrollInfo = target as IScrollInfo;
            if (scrollInfo != null)
            {
                Rect bounds = StickyNoteBounds;
                Rect viewport = new Rect(0, 0, scrollInfo.ViewportWidth, scrollInfo.ViewportHeight);
                if (bounds.IntersectsWith(viewport))
                    return;
            }

            //get adorned element
            Transform adornerTransform = (Transform)TransformToVisual(target);
            Debug.Assert(adornerTransform != null, "transform to AnnotatedElement is null");

            //get SN sizes
            Rect rect = new Rect(0, 0, Width, Height);
            rect.Transform(adornerTransform.Value);

            // Schedule BringIntoView, rather than making direct call.
            // Otherwise in some cases this can cause nested RequestBringIntoView call to be issued.
            // In scenario when document is inside scroll viewer and annotation needs to be 
            // brought to view the call to BringIntoView won't work because of nested events.
            // For more details refer to Dev10 679033 comments.
            Dispatcher.BeginInvoke(DispatcherPriority.Normal, new DispatcherOperationCallback(DispatchBringIntoView), new object []{target, rect});
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:51,代码来源:StickyNoteAnnotations.cs


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