本文整理汇总了C#中System.Windows.Window.DragMove方法的典型用法代码示例。如果您正苦于以下问题:C# Window.DragMove方法的具体用法?C# Window.DragMove怎么用?C# Window.DragMove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Window
的用法示例。
在下文中一共展示了Window.DragMove方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetupShell
private void SetupShell(Window window)
{
//Source: http://code-inside.de/blog/2012/11/11/howto-rahmenlose-wpf-apps-mit-schattenwurf/
window.WindowStyle = WindowStyle.None;
window.ResizeMode = ResizeMode.NoResize;
window.ShowInTaskbar = false;
window.Topmost = true;
window.SourceInitialized += (o, e) => {
if (!Helper.IsWindows7)
return;
var helper = new WindowInteropHelper(window);
var val = 2;
DwmSetWindowAttribute(helper.Handle, 2, ref val, 4);
var m = new Margins { bottomHeight = -1, leftWidth = -1, rightWidth = -1, topHeight = -1 };
DwmExtendFrameIntoClientArea(helper.Handle, ref m);
var hwnd = new WindowInteropHelper(window).Handle;
};
window.MouseLeftButtonDown += (o, e) => window.DragMove();
//Track changes on TopMost-settings
_Settings.PropertyChanged += (o, e) => {
if (e.PropertyName == "AlwaysOnTop")
window.Topmost = _Settings.AlwaysOnTop;
};
}
示例2: MoreColorsClicked
private void MoreColorsClicked(object sender, RoutedEventArgs e)
{
popup.IsOpen = false;
var advancedColorPickerDialog = new AdvancedColorPickerDialog();
_advancedPickerWindow = new Window
{
AllowsTransparency = true,
Content = advancedColorPickerDialog,
WindowStyle = WindowStyle.None,
ShowInTaskbar = false,
Background = new SolidColorBrush(Colors.Transparent),
Padding = new Thickness(0),
Margin = new Thickness(0),
WindowState = WindowState.Normal,
WindowStartupLocation = WindowStartupLocation.CenterOwner,
SizeToContent = SizeToContent.WidthAndHeight
};
_advancedPickerWindow.DragMove();
_advancedPickerWindow.KeyDown += AdvancedPickerPopUpKeyDown;
advancedColorPickerDialog.DialogResultEvent += AdvancedColorPickerDialogDialogResultEvent;
advancedColorPickerDialog.Drag += AdvancedColorPickerDialogDrag;
ShowModal(_advancedPickerWindow);
}
示例3: MoveWindow
private void MoveWindow(Window win, Point pt)
{
//Use a BeginInvoke to delay the execution slightly, else we can have problems grabbing the newly opened window.
this.Dispatcher.BeginInvoke(new Action(() =>
{
win.Topmost = true;
//We position the window at the mouse position
win.Left = pt.X - win.Width + 200;
win.Top = pt.Y - 20;
Debug.WriteLine(DateTime.Now.ToShortTimeString() + " dragging window");
if (Mouse.LeftButton == MouseButtonState.Pressed)
{
win.DragMove();//capture the movement to the mouse, so it can be dragged around
}
win.Topmost = false;
}));
}
示例4: DockedTabHotArea
/// <summary>
/// Initializes a new instance of the <see cref="DockedTabHotArea" /> class.
/// </summary>
/// <param name="parent">The parent.</param>
public DockedTabHotArea(DockContainer parent)
: base(parent)
{
SpecialMouseCursor = Cursors.Hand;
MouseClick += (sender, args) =>
{
switch (Position)
{
case DockPosition.Main:
Parent.MainDockSelectedIndex = NewIndex;
break;
case DockPosition.Left:
Parent.LeftDockSelectedIndex = NewIndex;
break;
case DockPosition.Top:
Parent.TopDockSelectedIndex = NewIndex;
break;
case DockPosition.Right:
Parent.RightDockSelectedIndex = NewIndex;
break;
case DockPosition.Bottom:
Parent.BottomDockSelectedIndex = NewIndex;
break;
}
};
MouseDown += (sender, args) =>
{
if (args.LeftButton != MouseButtonState.Pressed) return;
var downPosition = args.GetPosition(Parent);
Mouse.Capture(Parent);
Parent.MouseDownAndMoveOverride = e =>
{
if (e.LeftButton != MouseButtonState.Pressed) return;
var currentPosition = e.GetPosition(Parent);
if (currentPosition.X < downPosition.X - 20d || currentPosition.X > downPosition.X + 20d ||
currentPosition.Y < downPosition.Y - 20d || currentPosition.Y > downPosition.Y + 20d)
{
// The mouse moved far enough in the down position for us to consider this a drag operation
// Note: We may want to handle this differently in the future
if (_currentDragWindow == null)
{
var dockedElements = Parent.SecondaryDockWell.Where(d => d.Position == Position && d.IsDocked).ToList();
if (NewIndex >= dockedElements.Count) return;
var dockedElement = dockedElements[NewIndex];
if (dockedElement == null) return;
_currentDragWindow = new DockWellFloatWindow(Parent, dockedElement, Parent.DockWellRenderer, Parent.DockWellRenderer.DockWellHeaderHeight, Parent.DockWellRenderer.DockWellFooterHeight);
switch (Position)
{
case DockPosition.Left:
_currentDragWindow.Height = Parent.ActualHeight;
_currentDragWindow.Width = Parent.LeftDockWidth;
var totalDocked = Parent.SecondaryDockWell.Count(d => d.Position == Position && d.IsDocked);
if (totalDocked > 0 && Parent.LeftDockSelectedIndex >= totalDocked) Parent.LeftDockSelectedIndex = totalDocked - 1;
break;
case DockPosition.Top:
_currentDragWindow.Height = Parent.TopDockHeight;
_currentDragWindow.Width = Parent.ActualWidth - Parent.LeftDockWidth - Parent.RightDockWidth;
var totalDocked2 = Parent.SecondaryDockWell.Count(d => d.Position == Position && d.IsDocked);
if (totalDocked2 > 0 && Parent.TopDockSelectedIndex >= totalDocked2) Parent.TopDockSelectedIndex = totalDocked2 - 1;
break;
case DockPosition.Right:
_currentDragWindow.Height = Parent.ActualHeight;
_currentDragWindow.Width = Parent.RightDockWidth;
var totalDocked3 = Parent.SecondaryDockWell.Count(d => d.Position == Position && d.IsDocked);
if (totalDocked3 > 0 && Parent.RightDockSelectedIndex >= totalDocked3) Parent.RightDockSelectedIndex = totalDocked3 - 1;
break;
case DockPosition.Bottom:
_currentDragWindow.Height = Parent.BottomDockHeight;
_currentDragWindow.Width = Parent.ActualWidth - Parent.LeftDockWidth - Parent.RightDockWidth;
var totalDocked4 = Parent.SecondaryDockWell.Count(d => d.Position == Position && d.IsDocked);
if (totalDocked4 > 0 && Parent.BottomDockSelectedIndex >= totalDocked4) Parent.BottomDockSelectedIndex = totalDocked4 - 1;
break;
}
Mouse.Capture(null);
_currentDragWindow.DragMove();
}
}
};
};
}
示例5: EnableGlassEffect
public static bool EnableGlassEffect(Window window)
{
window.MouseLeftButtonDown += (s, e) =>
{
window.DragMove();
};
return EnableGlassEffect(window, true);
}