private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e) { try { //Can draw histrogram after uncertainty simulation function if (blnEnableHistUncern) { int x = e.x; int y = e.y; IPoint pPoint = m_mapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y); int intFID = FindFeatureFID(pPoint); int intColumnLength = arrSimuResults.GetUpperBound(1) + 1; double[] arrHist = new double[intColumnLength]; for (int i = 0; i < intColumnLength; i++) { arrHist[i] = arrSimuResults[intFID, i]; } NumericVector vecBLL = pEngine.CreateNumericVector(arrHist); pEngine.SetSymbol(strValue, vecBLL); string strCommand = "hist(" + strValue + ", freq=FALSE, main=paste('Histogram of FID ', " + intFID.ToString() + "));abline(v=" + Math.Round(arrOrivalue[intFID], 3).ToString() + ", col='red');"; string strTitle = "Histogram"; System.Text.StringBuilder CommandPlot = new System.Text.StringBuilder(); //Temporary path-needs to be changed //Have to assing pathes differently at R and ArcObject string pathr = @"D:\\temp\\"; string path = @"D:\temp\"; //Remove existing image file pathes if (multipageImage == null) { multipageImage = new List <string>(); } else { multipageImage.Clear(); } //Create new list to delete and save the image pathes //List<string> pmultipageImage = new List<string>(); //Delete existing image files multipageImage.AddRange(Directory.GetFiles(path, "rnet*.wmf")); for (int j = 0; j < multipageImage.Count; j++) { FileInfo pinfo = new FileInfo(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%02d.wmf', width=" + strwidth + ", height=" + strHeight + ");"); CommandPlot.Append("win.metafile('" + pathr + "rnet%01d.wmf');"); CommandPlot.Append(strCommand); CommandPlot.Append("graphics.off()"); pEngine.Evaluate(CommandPlot.ToString()); //Add Plot pathes at List multipageImage.Clear(); multipageImage.AddRange(Directory.GetFiles(path, "rnet*.wmf")); intCurrentIdx = 0; m_pSnippet.drawCurrentChart(multipageImage, intCurrentIdx, pfrmPlot); m_pSnippet.enableButtons(multipageImage, intCurrentIdx, pfrmPlot); } else { return; } } catch (Exception ex) { frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog(); return; } }