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


C# IInputElement.ReleaseMouseCapture方法代码示例

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


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

示例1: RegisterBorderEvents


//.........这里部分代码省略.........
                                cursorOffset.X = cursorLocation.X;
                                cursorOffset.Y = (Height - cursorLocation.Y);
                                break;
                        }

                        _cursorOffset = cursorOffset;

                        border.CaptureMouse();
                    }
                };
            #endregion

            #region MouseMove
            //border.PreviewMouseMove

            border.MouseMove += (sender, e) =>
                {
                    if (WindowState != WindowState.Maximized && border.IsMouseCaptured && ResizeMode == ResizeMode.CanResize)
                    {
                        var cursorLocation = e.GetPosition(this);

                        var nHorizontalChange = (cursorLocation.X - _cursorOffset.X);
                        var pHorizontalChange = (cursorLocation.X + _cursorOffset.X);
                        var nVerticalChange = (cursorLocation.Y - _cursorOffset.Y);
                        var pVerticalChange = (cursorLocation.Y + _cursorOffset.Y);

                        switch (borderEdge)
                        {
                            case WindowBorderEdge.Left:
                                if (Width - nHorizontalChange <= MinWidth) break;
                                Left += nHorizontalChange;
                                Width -= nHorizontalChange;
                                break;
                            case WindowBorderEdge.TopLeft:
                                if (!(Width - nHorizontalChange <= MinWidth))
                                {
                                    Left += nHorizontalChange;
                                    Width -= nHorizontalChange;
                                }
                                if (!(Height - nVerticalChange <= MinHeight))
                                {
                                    Top += nVerticalChange;
                                    Height -= nVerticalChange;
                                }
                                break;
                            case WindowBorderEdge.Top:
                                if (Height - nVerticalChange <= MinHeight) break;
                                Top += nVerticalChange;
                                Height -= nVerticalChange;
                                break;
                            case WindowBorderEdge.TopRight:
                                if (!(pHorizontalChange <= MinWidth))
                                {
                                    Width = pHorizontalChange;
                                }
                                if (!(Height - nVerticalChange <= MinHeight))
                                {
                                    Top += nVerticalChange;
                                    Height -= nVerticalChange;
                                }
                                break;
                            case WindowBorderEdge.Right:
                                if (pHorizontalChange <= MinWidth) break;
                                Width = pHorizontalChange;
                                break;
                            case WindowBorderEdge.BottomRight:
                                if (!(pHorizontalChange <= MinWidth))
                                {
                                    Width = pHorizontalChange;
                                }
                                if (!(pVerticalChange <= MinHeight))
                                {
                                    Height = pVerticalChange;
                                }
                                break;
                            case WindowBorderEdge.Bottom:
                                if (pVerticalChange <= MinHeight) break;
                                Height = pVerticalChange;
                                break;
                            case WindowBorderEdge.BottomLeft:
                                if (!(Width - nHorizontalChange <= MinWidth))
                                {
                                    Left += nHorizontalChange;
                                    Width -= nHorizontalChange;
                                }
                                if (!(pVerticalChange <= MinHeight))
                                {
                                    Height = pVerticalChange;
                                }

                                break;
                        }
                    }
                };
            #endregion

            #region MouseLeftButtonUp
            border.MouseLeftButtonUp += (sender, e) => border.ReleaseMouseCapture();
            #endregion
        }
开发者ID:Techide,项目名称:DMC,代码行数:101,代码来源:ThemedWindow.cs


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