public System.Collections.ArrayList GetDialogWindows( ) { Tracing.StartMethodTrace(); System.Collections.ArrayList dialogs = new System.Collections.ArrayList(); System.Collections.ArrayList dialogs1 = UI.Window_GetTopLevelWindows(); System.Collections.ArrayList dialogs2 = UI.Window_GetChildWindows(this.m_painter); foreach (int hwnd in dialogs1) { if (this.IsPainterDialog(hwnd)) { string wclass = WindowsAutomation.UI.Window_GetWindowClass(hwnd); string title = WindowsAutomation.UI.Window_GetWindowText(hwnd); if ((wclass == "_ASI_THREED_") && (title == "")) { continue; } dialogs.Add(hwnd); Trace.WriteLine("Found Painter Dialog"); Tracing.DumpWindow(hwnd); } } foreach (int hwnd in dialogs2) { if (this.IsPainterDialog(hwnd)) { dialogs.Add(hwnd); } } Tracing.EndMethodTrace(); return(dialogs); }
public int FindXaraDialog(string title) { Tracing.StartMethodTrace(); System.Collections.ArrayList dialogs = this.GetDialogWindows( ); int dialog = 0; foreach (int hwnd in dialogs) { string this_dialogs_title = WindowsAutomation.UI.Window_GetWindowText(hwnd); if (this_dialogs_title == title) { int this_dialogs_root = WindowsAutomation.UI.Window_GetRootOwner(hwnd); if (this_dialogs_root == this.XaraAppHWND) { dialog = hwnd; break; } } } Tracing.EndMethodTrace(); return(dialog); }
public int WaitForFileAccess(string filename) { Tracing.StartMethodTrace(); int time_waited = 0; int callback_interval = 500; int max_wait = 1000 * 60 * 2; // At most wait two minutes before giving up Tracing.WriteLine("max time to wait: {0}", max_wait); bool er_status = WindowsAutomation.IO.WaitForExclusiveRead(filename, max_wait, out time_waited, null, callback_interval); Tracing.WriteLine("time elapsed: {0}", time_waited); Tracing.WriteLine("err status: {0}", er_status); if (er_status == false) { Tracing.WriteLine("Throwing timeout exception"); string msg = string.Format("Time-out in WaitForFileAccess on filename {0} ", filename); throw new Errors.TimeOutError(msg); } Tracing.EndMethodTrace(); return(time_waited); }
public void FileSave(string output_file, bool save_alpha, string color_space, FormatDescription fmt) { Tracing.StartMethodTrace(); this.VerifyAlive(); this.VerifyNoDialogs(); this.VerifyDocumentCount(1); WindowsAutomation.IO.VerifyFileDoesNotExist(output_file); WindowsAutomation.UI.Menu_Select(this.m_painter, "file", "save as..."); // We know the command succeeded if the SaveAs dialog is up int the_dialog = this.WaitForDialogToAppear(WindowTextEnum.SaveAsWindowText); this.Sleep(500); int the_combobox = UI.GetChildEx(the_dialog, 0, WindowClassEnum.ComboBoxWindowClass, null, WindowTextEnum.RIFFFilesWindowText, 0); WindowsAutomation.UI.ComboBox_SelectItem(the_combobox, fmt.FilenameExtension); this.Sleep(500); int eb = UI.GetChild(the_dialog, WindowClassEnum.EditFieldWindowClass, null); UI.SetTextRaw(eb, output_file); this.Sleep(500); if (save_alpha == true) { int save_alpha_control = UI.GetChild(the_dialog, WindowClassEnum.ButtonWindowClass, WindowTextEnum.SaveAlphaWindowText); System.Windows.Forms.SendKeys.SendWait("+"); // Use this key to always set the value regardless of its initial state this.Sleep(500); } int SAVE_button = UI.GetChild(the_dialog, WindowClassEnum.ButtonWindowClass, WindowTextEnum.SaveButtonWindowText); UI.LeftClick(SAVE_button); this.WaitForDialogToDisappear(the_dialog); // This section handles the Layer warning dialog and the tif export options dialog // The layer warning dialog only appears (when layers need to be collapsed) // The export options dialog appears every time this.Sleep(500); this.HandleLayerWarningDialog( ); this.Sleep(500); this.HandleExportOptions(color_space); this.Sleep(500); this.WaitForFileAccess(output_file); this.VerifyAlive(); this.VerifyNoDialogs(); this.VerifyDocumentCount(1); Tracing.EndMethodTrace(); }
public int WaitForDialogToAppear(string t, int timeout) { Tracing.StartMethodTrace(); WaitForDialogToAppearObj wait_client = new WaitForDialogToAppearObj(this, t); int interval = 250; // .5 second int elapsed; bool success; Tracing.WriteLine("max time to wait: {0}", timeout); success = WindowsAutomation.Timing.WaitObject.WaitForCondition(wait_client, timeout, interval, out elapsed); Tracing.WriteLine("time elapsed: {0}", elapsed); Tracing.WriteLine("success: {0}", success); if (!success) { Tracing.WriteLine("Throwing timeout exception"); string msg = string.Format("Time-out in WaitForDialogToAppear for Dialog {0}", t); throw new Errors.TimeOutError(msg); } Tracing.EndMethodTrace(); return(wait_client.FoundDialog); }
public void FileSave(string output_file, bool save_alpha, string color_space, FormatDescription fmt, string inputfile) { Tracing.StartMethodTrace(); this.VerifyAlive(); this.VerifyNoDialogs(); this.VerifyDocumentCount(1); WindowsAutomation.IO.VerifyFileDoesNotExist(output_file); WindowsAutomation.UI.Menu_Select(this.XaraAppHWND, "file", "export..."); // We know the command succeeded if the SaveAs dialog is up int the_dialog = this.WaitForDialogToAppear("Export file", 5 * 1000); this.Sleep(500); System.Collections.Generic.List <int> comboboxes = UI.Window_FindChildWindowsEx(the_dialog, 0, "ComboBox", null, null, 0); int the_combobox = (int)comboboxes[2]; string ext = fmt.FilenameExtension; ext = ".tif"; WindowsAutomation.UI.ComboBox_SelectItem(the_combobox, ext); this.Sleep(500); int eb = UI.Window_GetChild(the_dialog, WindowClassEnum.EditFieldWindowClass, null); UI.SetTextRaw(eb, output_file); this.Sleep(500); int SAVE_button = UI.Window_GetChild(the_dialog, WindowClassEnum.ButtonWindowClass, "Export"); UI.Mouse_LeftClick(SAVE_button); this.WaitForDialogToDisappear(the_dialog); // This section handles the Layer warning dialog and the tif export options dialog // The layer warning dialog only appears (when layers need to be collapsed) // The export options dialog appears every time this.Sleep(500); //this.HandleLayerWarningDialog( ); //this.Sleep(500); this.HandleExportOptions(color_space); this.Sleep(500); this.WaitForFileAccess(output_file); this.VerifyAlive(); this.VerifyNoDialogs(); this.VerifyDocumentCount(1); Tracing.EndMethodTrace(); }
public void FileOpen(string input_file) { Tracing.StartMethodTrace(); this.VerifyAlive(); this.VerifyNoDialogs(); this.VerifyDocumentCount(0); WindowsAutomation.UI.Menu_Select(this.XaraAppHWND, "file", "open..."); int select_image_dialog = this.WaitForDialogToAppear("Open Document", 5 * 1000); this.Sleep(500); int eb = UI.Window_GetChild(select_image_dialog, WindowClassEnum.EditFieldWindowClass, ""); UI.SetTextRaw(eb, input_file); this.Sleep(500); int OPEN_button = UI.Window_GetChild(select_image_dialog, WindowClassEnum.ButtonWindowClass, WindowTextEnum.OpenButtonWindowText); UI.Mouse_LeftClick(OPEN_button); this.WaitForDialogToDisappear(select_image_dialog); System.Threading.Thread.Sleep(500); try { int warning_dialog = this.WaitForDialogToAppear("Warning from Xara X", 500); int OK_button = UI.Window_GetChild(warning_dialog, WindowClassEnum.ButtonWindowClass, "OK"); UI.Mouse_LeftClick(OK_button); } catch { } this.WaitForFileAccess(input_file); this.VerifyAlive(); this.VerifyNoDialogs(); // Wait until the document HWND becomes available (sometimes // it takes a while even if the I/O is done if (false == this.WaitForDocumentCount(1)) { string msg = string.Format("Time-out waiting in File/Open {0}", input_file); throw new Errors.TimeOutError(msg); } this.Sleep(500); Tracing.EndMethodTrace(); }
public void Init(XaraApp app) { Tracing.StartMethodTrace(); this.m_xarahwnd = app; Tracing.EndMethodTrace(); }
public void Init(PainterApp pa) { Tracing.StartMethodTrace(); this.m_painter = pa; Tracing.EndMethodTrace(); }
public bool MyWaitCallback(int status, int time) { Tracing.StartMethodTrace(); bool retval = true; Tracing.EndMethodTrace(); return(retval); }
public void PrepareJobs(string inpath, string outpath, ConversionOptions co) { Tracing.StartMethodTrace(); Log("Searching for RIFs in {0}", inpath); this.m_jobs = GenerateJobs(inpath, "*.rif", outpath, co); Log("{0} RIF files to convert", this.m_jobs.Length); Tracing.EndMethodTrace(); }
public void DoJob(ConversionJob job) { Tracing.StartMethodTrace(); this.report_job_status(0, job); Log(""); Log("Converting file #{0} ", job.SequenceNumber + 1); Log("Input file: {0} ", job.InputFile); Log("Output file: {0} ", job.OutputFile); bool skip_this_file = false; bool output_already_existed = System.IO.File.Exists(job.OutputFile); if (output_already_existed) { Log("Output file already exists; Skipping."); skip_this_file = true; } else { // Ensure that that is a path ready for the output file string path_for_file = System.IO.Path.GetDirectoryName(job.OutputFile); if (!System.IO.Directory.Exists(path_for_file)) { Log("Creating folder {0}", path_for_file); System.IO.Directory.CreateDirectory(path_for_file); } } if (skip_this_file == false) { if (!((job.Options.Format.ID == FormatsEnum.PSDFormat.ID) || (job.Options.Format.ID == FormatsEnum.TIFFormat.ID))) { Log(">>>Unknown Format {0}", job.Options.Format.ID); throw new Errors.InvalidFormatError("Unknown format"); } Log("File/Open"); this.m_painter.FileOpen(job.InputFile); Log("File/Save"); this.m_painter.FileSave(job.OutputFile, job.Options.SaveAlpha, job.Options.Colorspace, job.Options.Format); Log("File/Close"); this.m_painter.FileClose( ); } Log("Finished file #{0} ", job.SequenceNumber + 1); Tracing.EndMethodTrace(); }
public void PrepareJobs(string inpath, string outpath, ConversionOptions co) { Tracing.StartMethodTrace(); string extension = ".xar"; string pattern = "*" + extension; Tracing.WriteLine("Searching for {0} files in {1}", extension, inpath); this.Jobs = GenerateJobs(inpath, pattern, outpath, co); Tracing.WriteLine("{0} {1} files found", this.Jobs.Length, extension); Tracing.EndMethodTrace(); }
public void VerifyNoDialogs() { Tracing.StartMethodTrace(); System.Collections.ArrayList dialogs = this.GetDialogWindows( ); if (dialogs.Count > 0) { Tracing.DumpWindows(dialogs); throw new Errors.UnexpectedDialog(err_dialogs_found); } Tracing.EndMethodTrace(); }
public void FileOpen(string input_file) { Tracing.StartMethodTrace(); this.VerifyAlive(); this.VerifyNoDialogs(); this.VerifyDocumentCount(0); //this.SendMenuCommand( MenuCommandEnum.cmd_file_open ); WindowsAutomation.UI.Menu_Select(this.m_painter, "file", "open..."); int select_image_dialog = this.WaitForDialogToAppear(WindowTextEnum.SelectImageWindowText); this.Sleep(500); int eb = UI.GetChild(select_image_dialog, WindowClassEnum.EditFieldWindowClass, ""); UI.SetTextRaw(eb, input_file); this.Sleep(500); int OPEN_button = UI.GetChild(select_image_dialog, WindowClassEnum.ButtonWindowClass, WindowTextEnum.OpenButtonWindowText); UI.LeftClick(OPEN_button); this.WaitForDialogToDisappear(select_image_dialog); System.Threading.Thread.Sleep(500); this.WaitForFileAccess(input_file); this.VerifyAlive(); this.VerifyNoDialogs(); // Wait until the document HWND becomes available (sometimes // it takes a while even if the I/O is done if (false == this.WaitForDocumentCount(1)) { string msg = string.Format("Time-out waiting in File/Open {0}", input_file); throw new Errors.TimeOutError(msg); } this.Sleep(500); Tracing.EndMethodTrace(); }
public int GetPainterDialog(string title) { Trace.WriteLine(string.Format("GetPainterDialog \"{0}\"", title)); int dialog = this.FindPainterDialog(title); if (dialog == 0) { throw new Errors.UnexpectedDialog(PainterApp.err_unexpected_dialog); } Tracing.EndMethodTrace(); return(dialog); }
public void RunJobs( ) { Tracing.StartMethodTrace(); if (this.m_jobs == null) { throw new Errors.PainterError("Init() was not called"); } foreach (ConversionJob job in this.m_jobs) { this.DoJob(job); } Tracing.EndMethodTrace(); }
public void FileClose( ) { Tracing.StartMethodTrace(); this.VerifyAlive(); this.VerifyNoDialogs(); this.VerifyDocumentCount(1); //this.SendMenuCommand( MenuCommandEnum.cmd_file_close ); WindowsAutomation.UI.Menu_Select(this.m_painter, "file", "close"); if (false == this.WaitForDocumentCount(0)) { string msg = string.Format("Time-out in file Close"); throw new Errors.TimeOutError(msg); } Tracing.EndMethodTrace(); }
public ConverterEngine(PainterApp pa) { Tracing.StartMethodTrace(); this.Init(pa); Tracing.EndMethodTrace(); }
public AutomationError(string str) : base(str) { Tracing.StartMethodTrace(); this.Init(str); Tracing.EndMethodTrace(); }
public PainterError(string str) : base(str) { Tracing.StartMethodTrace(); this.Init(str); Tracing.EndMethodTrace(); }
public ConverterEngine(XaraApp app) { Tracing.StartMethodTrace(); this.Init(app); Tracing.EndMethodTrace(); }