當前位置: 首頁>>代碼示例>>C#>>正文


C# UIElement.CaptureMouse方法代碼示例

本文整理匯總了C#中System.Windows.UIElement.CaptureMouse方法的典型用法代碼示例。如果您正苦於以下問題:C# UIElement.CaptureMouse方法的具體用法?C# UIElement.CaptureMouse怎麽用?C# UIElement.CaptureMouse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。


在下文中一共展示了UIElement.CaptureMouse方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: MouseDownHandler

private void MouseDownHandler(object sender, MouseButtonEventArgs e)
{
    if (!Enabled) return;
    e.Handled = true;

    if (Keyboard.IsKeyDown(Key.F1) == true)
    {
        Reset();
        return;
    }

    UIElement el = (UIElement)sender;
    _point = e.MouseDevice.GetPosition(el);
    // Initialize the center of rotation to the lookatpoint
    if (!_centered)
    {
        ProjectionCamera camera = (ProjectionCamera)_slaves[0].Camera;
        _center = camera.LookDirection;
        _centered = true;
    }

    _scaling = (e.MiddleButton == MouseButtonState.Pressed);

    if (Keyboard.IsKeyDown(Key.Space) == false)
        _rotating = true;
    else
        _rotating = false;

    el.CaptureMouse();
}

private void MouseUpHandler(object sender, MouseButtonEventArgs e)
{
    if (!_enabled) return;
    e.Handled = true;

    // Stuff the current initial + delta into initial so when we next move we
    // start at the right place.
    if (_rotating == true)
    {
        _rotation = _rotationDelta * _rotation;
    }
    else
    {
        _translate += _translateDelta;
        _translateDelta.X = 0;
        _translateDelta.Y = 0;
    }

    //_scale = _scaleDelta*_scale;
    UIElement el = (UIElement)sender;
    el.ReleaseMouseCapture();
}
開發者ID:.NET開發者,項目名稱:System.Windows,代碼行數:53,代碼來源:UIElement.CaptureMouse


注:本文中的System.Windows.UIElement.CaptureMouse方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。