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


C# MouseEventArgs.GetPosition方法代码示例

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


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

示例1: DrawPixel

            // The DrawPixel method updates the WriteableBitmap by using
            // unsafe code to write a pixel into the back buffer.
            static void DrawPixel(MouseEventArgs e)
            {
                int column = (int)e.GetPosition(i).X;
                int row = (int)e.GetPosition(i).Y;

                // Reserve the back buffer for updates.
                writeableBitmap.Lock();

                unsafe
                {
                    // Get a pointer to the back buffer.
                    int pBackBuffer = (int)writeableBitmap.BackBuffer;

                    // Find the address of the pixel to draw.
                    pBackBuffer += row * writeableBitmap.BackBufferStride;
                    pBackBuffer += column * 4;

                    // Compute the pixel's color.
                    int color_data = 255 << 16; // R
                    color_data |= 128 << 8;   // G
                    color_data |= 255 << 0;   // B

                    // Assign the color data to the pixel.
                    *((int*)pBackBuffer) = color_data;
                }

                // Specify the area of the bitmap that changed.
                writeableBitmap.AddDirtyRect(new Int32Rect(column, row, 1, 1));

                // Release the back buffer and make it available for display.
                writeableBitmap.Unlock();
            }
开发者ID:Pokat,项目名称:Life,代码行数:34,代码来源:Class1.cs

示例2: Control_MouseMove

        private void Control_MouseMove(object sender, MouseEventArgs e)
        {
            var draggableControl = sender as UserControl;

            if (isDragging && draggableControl != null)
            {
                Point currentPosition = e.GetPosition(this.Parent as UIElement);

                var transform = draggableControl.RenderTransform as TranslateTransform;
                if (transform == null)
                {
                    transform = new TranslateTransform();
                    draggableControl.RenderTransform = transform;
                }

                transform.X = currentPosition.X - clickPosition.X;
                transform.Y = currentPosition.Y - clickPosition.Y;
            }
        }
开发者ID:blahblahblahblah831,项目名称:brawltools2,代码行数:19,代码来源:GradientDialog2.cs

示例3: ErasePixel

            static void ErasePixel(MouseEventArgs e)
            {
                byte[] ColorData = { 0, 0, 0, 0 }; // B G R

                Int32Rect rect = new Int32Rect(
                        (int)(e.GetPosition(i).X),
                        (int)(e.GetPosition(i).Y),
                        1,
                        1);

                writeableBitmap.WritePixels(rect, ColorData, 4, 0);
            }
开发者ID:Pokat,项目名称:Life,代码行数:12,代码来源:Class1.cs

示例4: MainPage_MouseMove

        private void MainPage_MouseMove(object sender, MouseEventArgs e)
        {
            if (!_isDragging)
                return;

            if (!SearchPopup.IsOpen)
                SearchPopup.IsOpen = true;

            Point position = e.GetPosition(null);

            SearchPopup.HorizontalOffset = position.X;
            SearchPopup.VerticalOffset = position.Y;
        }
开发者ID:emospy,项目名称:MyTest,代码行数:13,代码来源:MainPage.xaml.cs


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