zoukankan      html  css  js  c++  java
  • MatrixTransform 控件拖动边界检测

    原项目演示地址 http://www.youpvp.com/misc/adorners.html
    但那个项目没有加上边界检测,要加上边界检测,只需修改方法 adorned_MouseMove

    void adorned_MouseMove(object sender, MouseEventArgs e)
    {
        if (isDragging)
        {
            Point pt = e.GetPosition(null);//返回鼠标在整个 Silverlight 插件内容区域内的坐标位置。
            Point ee = e.GetPosition(this);//返回鼠标在当前控件内容区域内的坐标位置。
            Matrix mx = (current.RenderTransform as MatrixTransform).Matrix;
            double Height = (double)this.Parent.GetValue(ActualHeightProperty);//获取 Silverlight 插件的呈现区域的高度
            double Width = (double)this.Parent.GetValue(ActualWidthProperty);//获取 Silverlight 插件的呈现区域的宽度
            double MinX = Math.Max(ee.X, pt.X);
            double MinY = Math.Max(ee.Y, pt.Y);
            double MaxX = current.ActualWidth - ee.X + pt.X;//当前控件右边的位置
            double MaxY = current.ActualHeight - ee.Y + pt.Y;//当前控件下边的位置
    
            if (MaxX < Width)
            {
                mx.OffsetX += MinX - dragAnchor.X;
            }
            else
            {
                mx.OffsetX += -1;
            }
            if (MaxY < Height)
            {
                mx.OffsetY += MinY - dragAnchor.Y;
            }
            else
            {
                mx.OffsetY += -1;
            }
    
            //mx.OffsetX += pt.X - dragAnchor.X;
            //mx.OffsetY += pt.Y - dragAnchor.Y;
            current.RenderTransform = new MatrixTransform() { Matrix = mx };
            dragAnchor = pt;
        }
    }
    
  • 相关阅读:
    nginx rewrite 伪静态重写学习笔记
    正则表达式相关知识
    rpm的含义
    find命令的使用
    chmod的运用方式
    [GO]数组的比较和赋值
    [GO]二维数组的介绍
    [GO]变量内存和变量地址
    [GO]给导入包起别名
    阿里云负载均衡SLB 七层https协议 nginx 获取真实IP
  • 原文地址:https://www.cnblogs.com/geass/p/2026519.html
Copyright © 2011-2022 走看看