Exemplo n.º 1
0
 /// <summary>
 /// 用于AyWindow,快速创建单击拖动,双击最大化或者还原窗体
 /// 添加时间:2016-6-20 01:13:22
 /// 作者:AY
 /// <param name="element"></param>
 /// <param name="e">鼠标对象</param>
 /// <param name="ClickTwoAction">双击执行的代码</param>
 /// <returns></returns>
 public static void SetAyWindowMouseLeftButtonCommonClick(UIElement element, Action ClickTwoAction = null)
 {
     if (element == null)
     {
         return;
     }
     ay.Controls.AyWindowBase aywindow = Window.GetWindow(element) as ay.Controls.AyWindowBase;
     if (aywindow == null)
     {
         return;
     }
     element.MouseLeftButtonDown += (sender, e) =>
     {
         if (e.ClickCount == 2)
         {
             if (ClickTwoAction == null)
             {
                 if (aywindow.MaxWindowMethodOverride == null)
                 {
                     aywindow.DoRestoreOrMax();
                 }
                 else
                 {
                     aywindow.MaxWindowMethodOverride();
                 }
             }
             else
             {
                 ClickTwoAction();
             }
             e.Handled = true;
         }
         if (e.ClickCount == 1)
         {
             if (aywindow.WindowState == WindowState.Normal)
             {
                 aywindow.DragMove();
             }
         }
         e.Handled = true;
     };
 }
Exemplo n.º 2
0
 public static void SetAyWindowMouseLeftButtonMove(ay.Controls.AyWindowBase aywindow, UIElement element)
 {
     if (element == null)
     {
         return;
     }
     if (aywindow == null)
     {
         return;
     }
     element.MouseLeftButtonDown += (sender, e) =>
     {
         if (e.ClickCount == 1)
         {
             if (aywindow.WindowState == WindowState.Normal)
             {
                 aywindow.DragMove();
             }
         }
         e.Handled = true;
     };
 }