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


C# Button.TranslatePoint方法代码示例

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


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

示例1: ShowKeyboardAtLocation

        private void ShowKeyboardAtLocation(Button btn, int offsetX, int offsetY)
        {
            Window window = Window.GetWindow(this);
            Point pt0 = this.TransformToAncestor(window).Transform(new Point(0, 0));
            Point pt1 = btn.TranslatePoint(new Point(), this);

            int left = (int)(pt0.X + pt1.X) + offsetX;
            int top = (int)(pt0.Y + pt1.Y) + offsetY;

            var hwnd = ((HwndSource)PresentationSource.FromVisual(this.ModalDialog.Child)).Handle;

            RECT rect;
            if (GetWindowRect(hwnd, out rect))
            {
                SetWindowPos(hwnd, -2, left, top, -1, -1, 0);
            }
        }
开发者ID:junzheng,项目名称:YF17A,代码行数:17,代码来源:PagePopup.xaml.cs

示例2: SplitScreen

        //private double newTop = 50;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="origin">which raise the event</param>
        /// <param name="dst">new postion for the original control</param>
        /// <param name="screen">backgroud image split</param>
        public SplitScreen(Button origin,Point dst, Grid screen): this()
        {
            //this.Background = screen.Background;

            //copy button
            buttonOldPoint = origin.TranslatePoint(new Point(0, 0), screen);

            //TO-DO add some logic
            buttonNewPoint.X = buttonOldPoint.X ;
            buttonNewPoint.Y = buttonOldPoint.Y ;

            splitLine = buttonOldPoint.Y + interval + origin.Height;

            button = new ProgressButton();

            button.Content = origin.Content;
            button.Width = origin.Width;
            button.Height = origin.Height;

            button.FirstImage = (origin as ProgressButton).FirstImage;
            button.SecondImage = (origin as ProgressButton).SecondImage;
            button.CoverImage = (origin as ProgressButton).CoverImage;
            button.RotatedImage = (origin as ProgressButton).RotatedImage;

            button.State = State.Normal;
            button.Click += new RoutedEventHandler(button_Click);

            Canvas.SetLeft(button, buttonOldPoint.X);
            Canvas.SetTop(button, buttonOldPoint.Y);

            this.canvas.Children.Add(button);

            //copy background
            var background = new RenderTargetBitmap((int)screen.ActualWidth, (int)screen.ActualHeight, 
                                                    96d, 96d, PixelFormats.Pbgra32);
            background.Render(screen);

            int height = (int)background.Height;
            int width = (int)background.Width;
            
            var top = new CroppedBitmap(background, new Int32Rect(0, 0, width, (int)splitLine));
            var bottom = new CroppedBitmap(background, new Int32Rect(0, (int)splitLine, width, (int)(height - splitLine)));

            bg_top.Source = top;
            bg_bottom.Source = bottom;

            bg_top.Width = width;
            bg_top.Height = splitLine;

            bg_bottom.Width = width;
            bg_bottom.Height = height - splitLine;

            //generata container
            this.Container.Width = width;
            this.Container.Height = 300;

            //animation
            double verticalMove = buttonOldPoint.Y - buttonNewPoint.Y;

            translate(bg_top, 0, -verticalMove);
            translate(button, buttonOldPoint.Y, buttonNewPoint.Y);
            translate(Container, splitLine, splitLine - verticalMove);
            translate(bg_bottom, splitLine, splitLine + (Container.Height - verticalMove));
        }
开发者ID:hdhRance,项目名称:umeng-muti-channel-build-tool,代码行数:72,代码来源:SplitScreen.xaml.cs


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