本文整理汇总了C#中Window.ForceClose方法的典型用法代码示例。如果您正苦于以下问题:C# Window.ForceClose方法的具体用法?C# Window.ForceClose怎么用?C# Window.ForceClose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Window
的用法示例。
在下文中一共展示了Window.ForceClose方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleDialog
/// <inheritdoc />
public override bool HandleDialog(Window window)
{
if (CanHandleDialog(window))
{
window.ToFront();
window.SetActivate();
var inputBoxHwnd = new Hwnd(NativeMethods.GetChildWindowHwnd(window.Hwnd, "Edit"));
if (inputBoxHwnd.hwnd == IntPtr.Zero) return false;
if (_cancel)
{
window.ForceClose();
}
else
{
inputBoxHwnd.SetFocus();
inputBoxHwnd.SendString(_input);
var okButton = new WinButton(1, window.Hwnd);
okButton.Click();
}
return true;
}
return false;
}
示例2: HandleWindow
/// <summary>
/// If the window is a dialog and visible, it will be passed to
/// the registered dialog handlers. I none if these can handle
/// it, it will be closed if <see cref="CloseUnhandledDialogs"/>
/// is <c>true</c>.
/// </summary>
/// <param name="window">The window.</param>
public void HandleWindow(Window window)
{
if (!window.IsDialog()) return;
if (!IsWindowOfIexploreProcess(window)) return;
// This is needed otherwise the window Style will return a "wrong" result.
WaitUntilVisibleOrTimeOut(window);
// Lock the thread and see if a handler will handle
// this dialog window
lock (this)
{
foreach (var dialogHandler in _handlers)
{
try
{
if (dialogHandler.CanHandleDialog(window, MainWindowHwnd))
{
if (dialogHandler.HandleDialog(window)) return;
}
}
catch (Exception e)
{
LastException = e;
Logger.LogAction("Exception was thrown while DialogWatcher called HandleDialog: {0}",e.ToString());
}
}
// If no handler handled the dialog, see if the dialog
// should be closed automatically.
if (!CloseUnhandledDialogs || MainWindowHwnd != window.ToplevelWindow.Hwnd) return;
Logger.LogAction("Auto closing dialog with title: '{0}', text: {1}, style: ", window.Title, window.Message, window.StyleInHex);
window.ForceClose();
}
}
示例3: HandleDialog
public override bool HandleDialog(Window window)
{
var handle = GetMessageBoxHandle(window);
if (handle != IntPtr.Zero)
{
alertQueue.Enqueue(NativeMethods.GetWindowText(handle));
window.ForceClose();
return true;
}
return false;
}
示例4: HandleWindow
public void HandleWindow(Window window)
{
if (!window.IsDialog() || !this.HasDialogSameProcessNameAsBrowserWindow(window))
return;
DialogWatcher.WaitUntilVisibleOrTimeOut(window);
lock (this)
{
foreach (IDialogHandler item_0 in (IEnumerable<IDialogHandler>) this._handlers)
{
try
{
if (item_0.CanHandleDialog(window, this.MainWindow.Hwnd))
{
if (item_0.HandleDialog(window))
return;
}
}
catch (Exception exception_0)
{
this.LastException = exception_0;
Logger.LogAction((LogMessageCallback) (log => log("Exception was thrown while DialogWatcher called HandleDialog: {0}", new object[1]
{
(object) exception_0.ToString()
})));
}
}
if (!this.CloseUnhandledDialogs || !this.MainWindow.Equals((object) window.ToplevelWindow))
return;
Logger.LogAction((LogMessageCallback) (log => log("Auto closing dialog with title: '{0}', text: {1}, style: ", new object[3]
{
(object) window.Title,
(object) window.Message,
(object) window.StyleInHex
})));
window.ForceClose();
}
}