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


C# MouseButtonEventArgs.GetPosition方法代码示例

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


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

示例1: Control_MouseLeftButtonDown

 private void Control_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     isDragging = true;
     var draggableControl = sender as UserControl;
     clickPosition = e.GetPosition(this);
     draggableControl.CaptureMouse();
 }
开发者ID:blahblahblahblah831,项目名称:brawltools2,代码行数:7,代码来源:GradientDialog2.cs

示例2: AllowMouseLeftButtonDown

        /// <summary>
        /// Check if the control's MouseLeftButtonDown event should be handled.
        /// </summary>
        /// <param name="e">Event arguments.</param>
        /// <returns>
        /// A value indicating whether the event should be handled.
        /// </returns>
        public bool AllowMouseLeftButtonDown(MouseButtonEventArgs e)
        {
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }

            bool enabled = Control.IsEnabled;
            if (enabled)
            {
                // Get the current position and time
                DateTime now = DateTime.UtcNow;
                Point position = e.GetPosition(Control);

                // Compute the deltas from the last click
                double timeDelta = (now - LastClickTime).TotalMilliseconds;
                Point lastPosition = LastClickPosition;
                double dx = position.X - lastPosition.X;
                double dy = position.Y - lastPosition.Y;
                double distance = dx * dx + dy * dy;

                // Check if the values fall under the sequential click temporal
                // and spatial thresholds
                if (timeDelta < SequentialClickThresholdInMilliseconds &&
                    distance < SequentialClickThresholdInPixelsSquared)
                {
                    ClickCount++;
                }
                else
                {
                    ClickCount = 1;
                }

                // Set the new position and time
                LastClickTime = now;
                LastClickPosition = position;

                // Raise the event
                IsPressed = true;
            }
            else
            {
                ClickCount = 1;
            }

            return enabled;
        }
开发者ID:5nophilwu,项目名称:S1Nyan,代码行数:54,代码来源:InteractionHelper.cs

示例3: ClassesImg_MouseLeftButtonDown

        void ClassesImg_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            System.Windows.Point coo = e.GetPosition(this.ClassesImg);
            Pixel p;
            if (classes < 4)
            {
                p = img.GetPixel((uint)coo.X, (uint)coo.Y);
                m[classes] = p.R;
                if (Combo.SelectedIndex == 0)
                {
                    if (classes == 0)
                        Class1Mu.Text = m[classes].ToString();
                    else if (classes == 1)
                        Class2Mu.Text = m[classes].ToString();
                    else if (classes == 2)
                        Class3Mu.Text = m[classes].ToString();
                    else if (classes == 3)
                        Class4Mu.Text = m[classes].ToString();
                }
                else if (Combo.SelectedIndex == 1)
                {

                    if (classes == 0)
                    {
                        ClassARMeau.Text = p.R.ToString();
                        ClassAGMeau.Text = p.G.ToString();
                        ClassABMeau.Text = p.B.ToString();
                    }
                    else if (classes == 1)
                    {
                        ClassBRMeau.Text = p.R.ToString();
                        ClassBGMeau.Text = p.G.ToString();
                        ClassBBMeau.Text = p.B.ToString();
                    }
                    else if (classes == 2)
                    {
                        ClassCRMeau.Text = p.R.ToString();
                        ClassCGMeau.Text = p.G.ToString();
                        ClassCBMeau.Text = p.B.ToString();
                    }
                    else if (classes == 3)
                    {
                        ClassDRMeau.Text = p.R.ToString();
                        ClassDGMeau.Text = p.G.ToString();
                        ClassDBMeau.Text = p.B.ToString();
                    }
                }
                ++classes;
            }
        }
开发者ID:keroishak,项目名称:Pattern-Recognition,代码行数:50,代码来源:MainWindow.xaml.cs


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