Ejemplo n.º 1
0
        private void CleanUp()
        {
            /* Collapse this stuff since it is going to be released */
            xaml_ThumbGrid.Visibility = System.Windows.Visibility.Collapsed;

            /* Clear out everything */
            if (m_docPages != null && m_docPages.Count > 0)
            {
                m_docPages.Clear();
            }
            if (m_pageType != null && m_pageType.Count > 0)
            {
                m_pageType.Clear();
            }
            if (m_thumbnails != null && m_thumbnails.Count > 0)
            {
                m_thumbnails.Clear();
            }
            if (m_toppage_pos != null && m_toppage_pos.Count > 0)
            {
                m_toppage_pos.Clear();
            }
            if (m_list_thumb != null && m_list_thumb.Count > 0)
            {
                m_list_thumb.Clear();
            }
            if (m_images_rendered != null && m_images_rendered.Count > 0)
            {
                m_images_rendered.Clear();
            }
            if (m_page_sizes != null && m_page_sizes.Count > 0)
            {
                m_page_sizes.Clear();
            }

            m_currfile = null;
            m_origfile = null;
            m_numpages = -1;
            m_doc_type_has_page_access = true;
            m_document_type            = doc_t.UNKNOWN;
            m_origfile = null;
            CleanUpTempFiles();
            xaml_TotalPages.Text = "/ 0";
            xaml_currPage.Text   = "0";
            CloseExtraWindows(false);

            m_ghostscript.gsPageRenderedMain -= new ghostsharp.gsCallBackPageRenderedMain(gsPageRendered);
            m_ghostscript.DisplayDeviceClose();
            m_ghostscript.DisplayDeviceOpen();
            m_viewer_state = ViewerState_t.NO_FILE;

            /* Set vertical scroll to top position */
            Decorator    border       = VisualTreeHelper.GetChild(xaml_PageList, 0) as Decorator;
            ScrollViewer scrollViewer = border.Child as ScrollViewer;

            scrollViewer.ScrollToVerticalOffset(0);
            return;
        }
Ejemplo n.º 2
0
        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_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);
            }
        }