Hello,
Maybe this is a newbie question but I am not able to achieve what I want.
I have created a custom Dialog inheriting from GenericDialog.
I have overridden the Handle method and I am doing what I want to achieve with it but ( there is always a but) I am not able to mark or tell the consumer code that the handle has finished.
Here is my code:
My custom Class:
public class GenericDialog
{
....
public override void Handle()
{
if (this.HandlerDelegate != null)
{
this.HandlerDelegate(this);
}
else
{
try
{
System.Threading.Thread.Sleep(100);
InvokePrint.Invoke();
System.Threading.Thread.Sleep(100);
Window currentWindow = WindowManager.FindWindowRecursively(IntPtr.Zero, "Save Print Output As", false, 1500);
if (currentWindow != null)
{
currentWindow.SetFocus();
currentWindow.SetActive();
ArtOfTest.WebAii.Win32.Button saveButton = new ArtOfTest.WebAii.Win32.Button(currentWindow.Handle, ButtonAutomationId);
(Window child in currentWindow.AllChildren)
{
if (child.ContainsControl(FileNameAutomationId))//FileNameText
{
child.SetFocus();
child.SetActive();
SetFileName.Invoke();
System.Threading.Thread.Sleep(500);
}
}
if (saveButton != null)
{
System.Threading.Thread.Sleep(500);
//ActionToPerform.Invoke();
saveButton.SetFocus();
saveButton.SetActive();
saveButton.Click();
InvokePrint.Invoke();
}
System.Threading.Thread.Sleep(5000);
InvokePrint.Invoke();
}
this.HandleCount = 0;
this.Window.Close();
// Make sure the dialog is knocked down.
this.Window.WaitForVisibility(false, 500);
}
catch (Exception ex)
{
// Do any custom handling and return error.
throw;
}
}
}
The Consumer Method which is in another class:
private void PrintTax()
{
try
{
PrintDialog printDialog = new PrintDialog(ActiveBrowser, PrintDialogText, false, PrintDialogText); // Click on the Print button
printDialog.InvokePrint = InvokePrint;
printDialog.SetFileName = EnviarPath;
Manager.DialogMonitor.AddDialog(printDialog);
Manager.DialogMonitor.Start();
//Click the link that launches the security dialog
ImprimirTasaButton();
printDialog.WaitUntilHandled(20000);
Manager.DialogMonitor.Stop();
}
catch (Exception ex)
{
//TODO: Log this exception
throw;
}
}
Note: This code is still a Work in progress but I am getting a timeout exception as it seems it has been never handled even though I have done all I wanted to do.