public MainWindow() { InitializeComponent(); this.Closing += new System.ComponentModel.CancelEventHandler(Window_Closing); /* Set up ghostscript calls for progress update */ m_ghostscript = new ghostsharp(); m_ghostscript.gsUpdateMain += new ghostsharp.gsCallBackMain(gsProgress); m_ghostscript.gsIOUpdateMain += new ghostsharp.gsIOCallBackMain(gsIO); m_ghostscript.gsDLLProblemMain += new ghostsharp.gsDLLProblem(gsDLL); m_currpage = 0; m_gsoutput = new gsOutput(); m_gsoutput.Activate(); m_tempfiles = new List <TempFile>(); m_thumbnails = new List <DocPage>(); m_docPages = new Pages(); m_pageType = new List <Page_Content_t>(); m_page_sizes = new List <pagesizes_t>(); m_file_open = false; m_document_type = doc_t.UNKNOWN; m_doczoom = 1.0; m_init_done = false; m_busy_render = true; m_validZoom = true; m_firstime = true; m_list_thumb = new List <idata_t>(); m_images_rendered = new List <idata_t>(); m_busy_rendering = false; m_aa = true; m_aa_change = false; xaml_PageList.AddHandler(Grid.DragOverEvent, new System.Windows.DragEventHandler(Grid_DragOver), true); xaml_PageList.AddHandler(Grid.DropEvent, new System.Windows.DragEventHandler(Grid_Drop), true); /* For case of opening another file */ string[] arguments = Environment.GetCommandLineArgs(); if (arguments.Length > 1) { string filePath = arguments[1]; ProcessFile(filePath); } }
public MainWindow() { InitializeComponent(); this.Closing += new System.ComponentModel.CancelEventHandler(Window_Closing); /* Set up ghostscript calls for progress update */ m_ghostscript = new GSNET(); m_ghostscript.ProgressCallBack += new GSNET.Progress(gsProgress); m_ghostscript.StdIOCallBack += new GSNET.StdIO(gsIO); m_ghostscript.DLLProblemCallBack += new GSNET.DLLProblem(gsDLL); m_ghostscript.DisplayDeviceOpen(); m_currpage = 0; m_gsoutput = new gsOutput(); m_gsoutput.Activate(); m_tempfiles = new List <TempFile>(); m_thumbnails = new List <DocPage>(); m_docPages = new Pages(); m_pageType = new List <Page_Content_t>(); m_page_sizes = new List <pagesizes_t>(); m_document_type = doc_t.UNKNOWN; m_doczoom = 1.0; m_viewer_state = ViewerState_t.NO_FILE; m_validZoom = true; m_doc_type_has_page_access = true; m_list_thumb = new List <idata_t>(); m_images_rendered = new List <idata_t>(); m_aa = true; xaml_PageList.AddHandler(Grid.DragOverEvent, new System.Windows.DragEventHandler(Grid_DragOver), true); xaml_PageList.AddHandler(Grid.DropEvent, new System.Windows.DragEventHandler(Grid_Drop), true); /* For case of opening another file, or launching a print process */ string[] arguments = Environment.GetCommandLineArgs(); if (arguments.Length == 3) { string filePath = arguments[1]; string job = arguments[2]; if (String.Equals(job, "open")) { ProcessFile(filePath); } } else if (arguments.Length == 5) { string filePath = arguments[1]; string job = arguments[2]; try { m_currpage = Int32.Parse(arguments[3]); m_numpages = Int32.Parse(arguments[4]); } catch (FormatException) { Console.WriteLine("Failure to parse print page info"); Close(); } /* Keep main window hidden if we are doing a print process */ this.IsVisibleChanged += new System.Windows.DependencyPropertyChangedEventHandler(WindowVisible); m_viewer_state = ViewerState_t.PRINTING; Print(filePath); } }