示例#1
0
        private void LayoutRoot_Loaded(object sender, RoutedEventArgs e)
        {
            if (MyMainPage.floatChatReal == null)
            {
                MyMainPage.initializeFloatChat();
            }

            System.Windows.Media.GeneralTransform gt = lstTraditionalHost.TransformToVisual(Application.Current.RootVisual);
            Point offset = gt.Transform(new Point(lstTraditionalHost.Width + 30, 0));

            MyMainPage.floatChatReal.Position = offset;

            MyMainPage.refreshFloatChat(lstTraditionalHost.ActualHeight / 1.5, lstTraditionalHost.ActualHeight);
        }
示例#2
0
        /// <summary>
        /// Scrolls and item into view.
        /// </summary>
        /// <param name="item">The item to scroll into view.</param>
        public void ScrollIntoView(object item)
        {
            if (this.scrollViewer != null && this.containersByItem.ContainsKey(item))
            {
                MatchingTermItemContainer container = this.containersByItem[item];
                if (System.Windows.Media.VisualTreeHelper.GetParent(container) != null)
                {
                    System.Windows.Media.GeneralTransform transform = container.TransformToVisual(this.scrollViewer);
                    double verticalOffset = transform.Transform(new Point(0, 0)).Y;

                    if (verticalOffset + container.ActualHeight > this.scrollViewer.ViewportHeight)
                    {
                        this.scrollViewer.ScrollToVerticalOffset(this.scrollViewer.VerticalOffset + (verticalOffset - this.scrollViewer.ViewportHeight) + container.ActualHeight);
                    }
                    else if (verticalOffset < 0)
                    {
                        this.scrollViewer.ScrollToVerticalOffset(this.scrollViewer.VerticalOffset + verticalOffset);
                    }
                }
            }
        }
示例#3
0
        private IntPtr GetWin32InfoFromUIElement(System.Windows.UIElement uiElement, out System.Drawing.Rectangle rect)
        {
            // Convert UIElement to Rectangle
            System.Windows.Media.Matrix       matrix;
            System.Windows.PresentationSource presentationSource = System.Windows.PresentationSource.FromVisual(uiElement);
            if (presentationSource == null)
            {
                throw new InvalidOperationException("The specified UiElement is not connected to a rendering Visual Tree.");
            }
            try
            {
                System.Windows.Media.GeneralTransform generalTransform = uiElement.TransformToAncestor(presentationSource.RootVisual);
                System.Windows.Media.Transform        transform        = generalTransform as System.Windows.Media.Transform;
                if (transform == null)
                {
                    throw new ApplicationException("//TODO: Handle GeneralTransform Case - introduced by Transforms Breaking Change");
                }
                matrix = transform.Value;
            }
            catch (InvalidOperationException)
            {
                throw new InvalidOperationException("The specified UiElement is not connected to a rendering Visual Tree.");
            }
            System.Windows.Rect rect1 = new System.Windows.Rect(new System.Windows.Point(), uiElement.RenderSize);
            rect1.Transform(matrix);
            System.Windows.Point point1 = rect1.TopLeft;
            point1 = presentationSource.CompositionTarget.TransformToDevice.Transform(point1);
            Point  point2 = new Point((int)point1.X, (int)point1.Y);
            IntPtr hwnd   = ((System.Windows.Interop.HwndSource)presentationSource).Handle; // PresentaionSource.RootVisual ?

            User32.ClientToScreen(hwnd, ref point2);
            rect = new System.Drawing.Rectangle(point2, new System.Drawing.Size(
                                                    Convert.ToInt32(Microsoft.Test.Display.Monitor.ConvertLogicalToScreen(Microsoft.Test.Display.Dimension.Width, uiElement.RenderSize.Width)),
                                                    Convert.ToInt32(Microsoft.Test.Display.Monitor.ConvertLogicalToScreen(Microsoft.Test.Display.Dimension.Height, uiElement.RenderSize.Height))));

            return(hwnd);
        }
示例#4
0
 System.Windows.Media.GeneralTransform MS.Internal.Annotations.Component.IAnnotationComponent.GetDesiredTransform(System.Windows.Media.GeneralTransform transform)
 {
     return(default(System.Windows.Media.GeneralTransform));
 }
 public virtual new System.Windows.Media.GeneralTransform GetDesiredTransform(System.Windows.Media.GeneralTransform transform)
 {
     return(default(System.Windows.Media.GeneralTransform));
 }