Esempio n. 1
0
 public void drawCurrentChart(System.Collections.Generic.List <string> multipageImage, int currIndex, frmPlot mPlot)
 {
     try
     {
         if (multipageImage.Count > 0)
         {
             using (System.IO.StreamReader str = new System.IO.StreamReader(multipageImage[currIndex]))
             {
                 //mPlot.picPlot.Image = new System.Drawing.Bitmap(str.BaseStream);
                 mPlot.picPlot.Image = new System.Drawing.Imaging.Metafile(str.BaseStream);
                 str.Close();
             }
             mPlot.picPlot.Invalidate();
         }
     }
     catch (Exception ex)
     {
         frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog();
         return;
     }
 }
Esempio n. 2
0
        public void enableButtons(System.Collections.Generic.List <string> multipageImage, int intCurrentIdx, frmPlot pfrmPlot)
        {
            try
            {
                if (intCurrentIdx > 0)
                {
                    pfrmPlot.btnPreviousPlot.Enabled = true;
                }
                else
                {
                    pfrmPlot.btnPreviousPlot.Enabled = false;
                }

                if (intCurrentIdx >= multipageImage.Count - 1)
                {
                    pfrmPlot.btnNextPlot.Enabled = false;
                }
                else
                {
                    pfrmPlot.btnNextPlot.Enabled = true;
                }
            }
            catch (Exception ex)
            {
                frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog();
                return;
            }
        }
Esempio n. 3
0
        public void drawPlottoForm(string strTitle, string strCommand)
        {
            try
            {
                MainForm mForm   = Application.OpenForms["MainForm"] as MainForm;
                REngine  pEngine = mForm.pEngine;
                //Create Plots in R
                StringBuilder CommandPlot = new StringBuilder();

                //Plots are saved in temporary folders.
                string path = Path.GetTempPath();
                //Have to assing pathes differently at R and ArcObject
                string pathr = path.Replace(@"\", @"/");
                //Remove existing image file pathes
                if (mForm.multipageImage == null)
                {
                    mForm.multipageImage = new List <string>();
                }
                else
                {
                    mForm.multipageImage.Clear();
                }

                //Delete existing image files
                mForm.multipageImage.AddRange(Directory.GetFiles(path, "rnet*.wmf"));

                for (int j = 0; j < mForm.multipageImage.Count; j++)
                {
                    FileInfo pinfo = new FileInfo(mForm.multipageImage[j]);
                    if (pinfo.Exists)
                    {
                        pinfo.Delete();
                    }
                    pinfo.Refresh();
                }

                //Load Form and assign the settings
                frmPlot pfrmPlot = new frmPlot();
                pfrmPlot.Text = strTitle;
                pfrmPlot.Show();
                string strwidth  = pfrmPlot.picPlot.Size.Width.ToString();
                string strHeight = pfrmPlot.picPlot.Size.Height.ToString();

                //Create Plots in R
                CommandPlot.Append("win.metafile('" + pathr + "rnet%01d.wmf');");
                CommandPlot.Append(strCommand);
                CommandPlot.Append("graphics.off()");
                pEngine.Evaluate(CommandPlot.ToString());

                //Add Plot pathes at List
                mForm.multipageImage.Clear();
                mForm.multipageImage.AddRange(Directory.GetFiles(path, "rnet*.wmf"));

                //Draw plots at the Form
                mForm.intCurrentIdx = 0;
                drawCurrentChart(mForm.multipageImage, mForm.intCurrentIdx, pfrmPlot);
                enableButtons(mForm.multipageImage, mForm.intCurrentIdx, pfrmPlot);
            }
            catch (Exception ex)
            {
                frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog();
                return;
            }
        }