private void SelectionMade(object gsObject, SelectEventArgs results) { switch (results.State) { case SelectStatus_t.CANCEL: case SelectStatus_t.CLOSE: m_selection = null; return; case SelectStatus_t.SELECT: /* Get the information we need */ double zoom = results.ZoomFactor; Point start = results.TopLeft; Point size = results.Size; int page = results.PageNum; gsDevice_t Device = gsDevice_t.pdfwrite; start.X = start.X / zoom; start.Y = start.Y / zoom; size.X = size.X / zoom; size.Y = size.Y / zoom; /* Do the actual extraction */ String options; System.Windows.Forms.SaveFileDialog dlg = new System.Windows.Forms.SaveFileDialog(); dlg.FilterIndex = 1; /* Get us set up to do a fixed size */ options = "-dFirstPage=" + page + " -dLastPage=" + page + " -dDEVICEWIDTHPOINTS=" + size.X + " -dDEVICEHEIGHTPOINTS=" + size.Y + " -dFIXEDMEDIA"; /* Set up the translation */ String init_string = "<</Install {-" + start.X + " -" + start.Y + " translate (testing) == flush}>> setpagedevice"; switch (results.Type) { case Extract_Type_t.PDF: dlg.Filter = "PDF Files(*.pdf)|*.pdf"; break; case Extract_Type_t.EPS: dlg.Filter = "EPS Files(*.eps)|*.eps"; Device = gsDevice_t.eps2write; break; case Extract_Type_t.PS: dlg.Filter = "PostScript Files(*.ps)|*.ps"; Device = gsDevice_t.ps2write; break; case Extract_Type_t.SVG: dlg.Filter = "SVG Files(*.svg)|*.svg"; break; } if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (m_ghostscript.Convert(m_currfile, options, Enum.GetName(typeof(gsDevice_t), Device), dlg.FileName, 1, 300, false, null, page, page, null, init_string) == gsStatus.GS_BUSY) { ShowMessage(NotifyType_t.MESS_STATUS, "GS busy"); return; } } m_selection.Close(); break; case SelectStatus_t.ZOOMIN: /* Render new page at this resolution and hand it off */ SelectionZoom(results.PageNum - 1, results.ZoomFactor); break; case SelectStatus_t.ZOOMOUT: /* Render new page at this resolution and hand it off */ SelectionZoom(results.PageNum - 1, results.ZoomFactor); break; } }
public MainWindow() { InitializeComponent(); this.Closing += new System.ComponentModel.CancelEventHandler(Window_Closing); m_file_open = false; m_regstartup = true; m_showannot = true; /* Allocations and set up */ try { m_docPages = new Pages(); m_thumbnails = new List<DocPage>(); m_lineptrs = new List<LinesText>(); m_textptrs = new List<BlocksText>(); m_textset = new List<Boolean>(); m_ghostscript = new ghostsharp(); m_ghostscript.gsUpdateMain += new ghostsharp.gsCallBackMain(gsProgress); m_gsoutput = new gsOutput(); m_gsoutput.Activate(); m_outputintents = new OutputIntent(); m_outputintents.Activate(); m_ghostscript.gsIOUpdateMain += new ghostsharp.gsIOCallBackMain(gsIO); m_ghostscript.gsDLLProblemMain += new ghostsharp.gsDLLProblem(gsDLL); m_convertwin = null; m_extractwin = null; m_selection = null; xaml_ZoomSlider.AddHandler(MouseLeftButtonUpEvent, new MouseButtonEventHandler(ZoomReleased), 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); DimSelections(); status_t result = CleanUp(); string[] arguments = Environment.GetCommandLineArgs(); if (arguments.Length > 1) { string filePath = arguments[1]; ProcessFile(filePath); } else { if (m_regstartup) InitFromRegistry(); } } catch (OutOfMemoryException e) { Console.WriteLine("Memory allocation failed at initialization\n"); ShowMessage(NotifyType_t.MESS_ERROR, "Out of memory: " + e.Message); } }
private void Extract(Extract_Type_t type) { if (m_selection != null || !m_init_done) return; m_selection = new Selection(m_currpage + 1, m_doczoom, type); m_selection.UpdateMain += new Selection.CallBackMain(SelectionMade); m_selection.Show(); m_selection.xaml_Image.Source = m_docPages[m_currpage].BitMap; m_selection.xaml_Image.Height = m_docPages[m_currpage].Height; m_selection.xaml_Image.Width = m_docPages[m_currpage].Width; }