Exemplo n.º 1
0
        void AsyncBmpGenerator_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            // invoke shouldn't be necessary... actually

            //TESharedComponents.MyBackgroundWorker.BeginInvoke(() =>
            //{
            AsyncBmpData data = e.Result as AsyncBmpData;

            // if filename has changed while the bmp was generated-> don't display
            if (data.File == View.PdfPath)
            {
                // if returned bitmap null or error -> set unavailable
                if (e.Error == null && data.bmp != null)
                {
                    Bmp            = data.bmp;
                    IsImageVisible = true;
                    IsUnavailable  = false;
                }
                else
                {
                    Bmp            = null;
                    IsImageVisible = false;
                    IsUnavailable  = true;
                }
            }
            // restart compilation if job pending
            NextBmpJob = NextBmpJob;

            // });
        }
Exemplo n.º 2
0
 /// <summary>
 /// Updates the control state. Should be called whenever the PdfPath property changes
 /// </summary>
 public void Refresh()
 {
     if (View.PdfPath == "")
     {
         IsUnavailable  = true;
         IsImageVisible = false;
         NextBmpJob     = null; // if manually set to unavailable-> clear pending bmp jobs
         myPdfBmpDoc.UnloadPdf();
     }
     else
     {
         RedrawBMP(true);
     }
 }
Exemplo n.º 3
0
        void AsyncBmpGenerator_DoWork(object sender, DoWorkEventArgs e)
        {
            AsyncBmpData data = e.Argument as AsyncBmpData;

            if (data.File != null) //&& data.Reload)
            {
                myPdfBmpDoc.LoadPdf(data.File);
            }
            // this is not optimal since the pdf might be changing when called.... pass PdfWrapper instead to remedy....
            //data.bmp = myPdfBmpDoc.GetBitmapSource(data.Resolution, data.RenderTransparent);

            data.bmp = myPdfBmpDoc.GetBitmap(data.Resolution, data.RenderTransparent);
            e.Result = data;
        }
Exemplo n.º 4
0
        /// <summary>
        /// This method draws the currently loaded Pdf into a bitmap, and displays this bitmap in the image control.
        /// It is called, e.g., when the size of the TikzDisplay control changes
        /// Warning: It reloads the Pdf only if ReloadFile is set.
        /// </summary>
        /// <param name="ReloadFile">Reload the pdf file from disk.</param>
        public void RedrawBMP(bool ReloadFile)
        {
            if (myPdfBmpDoc != null)
            {
                AsyncBmpData data = new AsyncBmpData();
                data.Resolution        = View.Resolution;
                data.RenderTransparent = View.RenderTransparent;
                data.File   = View.PdfPath;
                data.Reload = ReloadFile;

                NextBmpJob = data; // this automatically starts the background worker if no other job is in progress

                return;
            }
        }