本文整理汇总了C#中System.Windows.Window.Activate方法的典型用法代码示例。如果您正苦于以下问题:C# Window.Activate方法的具体用法?C# Window.Activate怎么用?C# Window.Activate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Window
的用法示例。
在下文中一共展示了Window.Activate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowModal
/// <summary>
/// Shows the modal.
/// </summary>
/// <param name="owner">The owner.</param>
public void ShowModal(Window owner, IUserInputManager userInputManager = null)
{
_userInputManager = userInputManager;
WindowStyle = WindowStyle.None;
ResizeMode = ResizeMode.NoResize;
ShowInTaskbar = false;
WindowStartupLocation = WindowStartupLocation.Manual;
AllowsTransparency = true;
Width = owner.Width;
Height = owner.Height;
Top = owner.Top;
Left = owner.Left;
WindowState = owner.WindowState;
Owner = owner;
EventHandler closedHanlder = null;
closedHanlder = (sender, e) => {
owner.Activate();
Closed -= closedHanlder;
};
Closed += closedHanlder;
Show();
}
示例2: Initialize
public void Initialize(Window window, bool activate = true)
{
if (window.Content == null)
window.Content = RootFrame;
if (activate)
window.Activate();
}
示例3: TryActivateMainWindow
static void TryActivateMainWindow(Window mainWindow) {
try {
mainWindow.Show();
mainWindow.Activate();
} catch (InvalidOperationException e) {
MainLog.Logger.FormattedDebugException(e);
}
}
示例4: ExampleTest
public void ExampleTest()
{
var window = new Window() {Width = 100, Height = 100};
window.Show();
window.Activate();
window.Dispatcher.InvokeShutdown();
window.Close();
}
示例5: BringToFrontWindow
public static void BringToFrontWindow(Window w)
{
ExecuteUIHelper(w, () =>
{
if (w.WindowState == WindowState.Minimized) w.WindowState = WindowState.Normal;
w.Show();
w.Activate();
});
}
示例6: ActivateWindow
public static void ActivateWindow(Window window)
{
var interopHelper = new WindowInteropHelper(window);
var currentForegroundWindow = GetForegroundWindow();
var thisWindowThreadId = GetWindowThreadProcessId(interopHelper.Handle, IntPtr.Zero);
var currentForegroundWindowThreadId = GetWindowThreadProcessId(currentForegroundWindow, IntPtr.Zero);
AttachThreadInput(currentForegroundWindowThreadId, thisWindowThreadId, true);
SetWindowPos(interopHelper.Handle, new IntPtr(0), 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW);
AttachThreadInput(currentForegroundWindowThreadId, thisWindowThreadId, false);
window.Show();
window.Activate();
}
示例7: BringToForeground
public static void BringToForeground(Window mainWindow)
{
if (mainWindow.WindowState == WindowState.Minimized || mainWindow.Visibility == Visibility.Hidden)
{
mainWindow.Show();
mainWindow.WindowState = WindowState.Normal;
}
// According to some sources these steps gurantee that an app will be brought to foreground.
mainWindow.Activate();
mainWindow.Topmost = true;
mainWindow.Topmost = false;
mainWindow.Focus();
mainWindow.ShowInTaskbar = true;
}
示例8: ActivateForm
public override void ActivateForm(Window form, Window window, IntPtr hwnd) {
var fHandle = (PresentationSource.FromVisual(form) as HwndSource).Handle;
var wHandle = (PresentationSource.FromVisual(window) as HwndSource).Handle;
if (window == null || wHandle != fHandle) {
// bring to top
form.Topmost = true;
form.Topmost = false;
// set as active form in task bar
form.Activate();
// stop flashing...happens occassionally when switching quickly when activate manuver is fails
Shell32.FlashWindow(fHandle, 0);
}
}
示例9: ActivateWindow
private void ActivateWindow(Window window)
{
if (!window.IsVisible)
{
window.Show();
}
if (window.WindowState == WindowState.Minimized)
{
window.WindowState = WindowState.Normal;
}
window.Activate();
window.Topmost = true;
window.Topmost = false;
window.Focus();
}
示例10: ShowModal
/// <summary>
/// Shows the modal.
/// </summary>
/// <param name="owner">The owner.</param>
public void ShowModal(Window owner)
{
WindowStyle = WindowStyle.None;
ResizeMode = ResizeMode.NoResize;
ShowInTaskbar = false;
WindowStartupLocation = WindowStartupLocation.Manual;
AllowsTransparency = true;
Width = owner.Width;
Height = owner.Height;
Top = owner.Top;
Left = owner.Left;
WindowState = owner.WindowState;
Owner = owner;
ShowDialog();
owner.Activate();
}
示例11: ActivateWindow
private static void ActivateWindow(Window window)
{
window.Dispatcher.Invoke(
new SendOrPostCallback(
delegate(object ignored)
{
window.Activate();
}),
String.Empty);
}
示例12: WinCondition
public static void WinCondition()
{
Window win = new Window();
win.Title = "You win!";
win.Activate();
}
示例13: LoseCondition
internal static void LoseCondition()
{
Window lose = new Window();
lose.Title = "You lose!";
lose.Activate();
}
示例14: GetSetWndPosition
// ReSharper restore UnusedParameter.Local
/// <summary>
/// Locates the window passed as if it is a Progman, the Start Menu.
/// First, by screenPoint passed calculates active screen.
/// By it's bounds determines the location of TaskBar.
/// Finally, calculates the position of target window.
/// Shows window except if it is a Placement rectangle.
/// Focuses window if it is a ButtonStack.
/// </summary>
/// <param name="w">Window to locate</param>
/// <param name="screenPoint">Unmanaged struct containing absolute screen coordinates, in px.</param>
/// <param name="ignoreTaskbarPosition">Flag instructing method to ignore the location of task bar
/// locating w simply in the corner closest to the screenPoint. E.g. to show BtnStch by Alt+Z.</param>
private static void GetSetWndPosition(Window w, API.POINT screenPoint, bool ignoreTaskbarPosition)
{
var resPoint = new Point();
var screen = Screen.FromPoint(new System.Drawing.Point(screenPoint.X, screenPoint.Y));
//We show stack in the corner closest to the mouse
bool isHideTaskBarOptionOn = (screen.WorkingArea.Width == screen.Bounds.Width &&
screen.WorkingArea.Height == screen.Bounds.Height)
|| ignoreTaskbarPosition;
//taskbar is vertical @ left or horizontal
if ((isHideTaskBarOptionOn && screenPoint.X <= screen.WorkingArea.X + screen.WorkingArea.Width/2)
|| screen.WorkingArea.X > screen.Bounds.X
|| (screen.WorkingArea.Width == screen.Bounds.Width & !isHideTaskBarOptionOn))
resPoint.X = screen.WorkingArea.X;
else //vertical @ right
resPoint.X = (screen.WorkingArea.Width + screen.WorkingArea.X - w.Width*SystemScale)/SystemScale;
//taskbar is horizontal @ top or vertical
if ((isHideTaskBarOptionOn && screenPoint.Y <= screen.WorkingArea.Y + screen.WorkingArea.Height/2)
|| screen.WorkingArea.Y > screen.Bounds.Y
|| (screen.WorkingArea.Height == screen.Bounds.Height & !isHideTaskBarOptionOn))
resPoint.Y = screen.WorkingArea.Y;
else //horizontal @ bottom
resPoint.Y = (screen.WorkingArea.Height + screen.WorkingArea.Y - w.Height*SystemScale)/SystemScale;
w.Left = resPoint.X;
w.Top = resPoint.Y;
// ReSharper disable PossibleUnintendedReferenceComparison
if(w != PlacementWnd)
w.Activate();
// ReSharper restore PossibleUnintendedReferenceComparison
var b = w as BtnStck;
if (b != null)
b.Focus();//Focus() is __new on ButtonStack, must explicitly type
}
示例15: BringToFront
private void BringToFront(Window window)
{
if (window.WindowState == WindowState.Minimized)
window.WindowState = WindowState.Normal;
window.Activate();
window.Topmost = true;
window.Topmost = false;
window.Focus();
}