public static void download_image_to_doc(NOPSAImageHolder imageholder) { //Debug.WriteLine(Util.GetUserDataPath()); //ApplicationInteraction.PowerPointApplication.ActiveWindow.Selection.SlideRange.Shapes.AddPicture(Path.Combine(Util.GetUserDataPath() , "citywall.jpg") , //new Util.Downloader(imageholder.img_url); //ApplicationInteraction.imagesadded.Add(imageholder); //downloading image //office hangs when loading image, even when run in seperate thread or backgroundworker. when you insert image from url, office hangs (without using addin), so I suppose its problem at their end try { Shape addedpic = ApplicationInteraction.PowerPointApplication.ActiveWindow.Selection.SlideRange.Shapes.AddPicture( imageholder.img_url, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoCTrue, 0, 0); shape_uuids.Add(addedpic.GetHashCode()); imagesadded.Add(imageholder); ApplicationInteraction.add_credits_slide(); } catch (Exception ex) { //System.Windows.Forms.MessageBox.Show("Dear paba, here comes a error :) "); //System.Windows.Forms.MessageBox.Show("-" + ex.Message); //System.Windows.Forms.MessageBox.Show("-" + ex.StackTrace); TextWriter tw = new StreamWriter(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\ribbon.txt"); tw.WriteLine("Message:"); tw.WriteLine(ex.Message); tw.WriteLine("StackTrace:"); tw.WriteLine(ex.StackTrace); tw.WriteLine("Source:"); tw.WriteLine(ex.Source); tw.WriteLine("helplink"); tw.WriteLine(ex.HelpLink); tw.Close(); } }
void processxml(string xml) { String license_url; String license_name; String license_image; try { license_url = xml.Substring(xml.IndexOf("<license_url>") + 13, xml.IndexOf("</license_url>") - xml.IndexOf("<license_url>") - 13); Debug.WriteLine(license_url); license_name = xml.Substring(xml.IndexOf("<license_name>") + 14, xml.IndexOf("</license_name>") - xml.IndexOf("<license_name>") - 14); Debug.WriteLine(license_name); license_image = xml.Substring(xml.IndexOf("<license_image>") + 15, xml.IndexOf("</license_image>") - xml.IndexOf("<license_image>") - 15); } catch (Exception ex) { MessageBox.Show("Lincese generation error." + ex.Message); return; } //Debug.WriteLine(license_url); //Debug.WriteLine(license_name); //Debug.WriteLine(license_image); ApplicationInteraction.addlicense(license_url, license_name, license_image); }
private void downloadimg_img_Click(object sender, EventArgs e) //downloads the image { //Debug.WriteLine("download the image"); ApplicationInteraction.download_image_to_doc(this.imageholder); }