public string InputFileFromURL()
        {
            TabPage tb = tabControl1.SelectedTab;

            if (tb as EditorTabPage == null)
            {
                return(string.Empty);
            }
            EditorTabPage etb = tb as EditorTabPage;
            FileInfo      fi  = new FileInfo(etb.GetFileFullPathAndName());

            var dialog = new InsertImageDialog();

            dialog.FileName = fi.Name.Substring(0, fi.Name.Length - fi.Extension.Length) + "_pic1";
            if (dialog.ShowDialog() != DialogResult.OK)
            {
                return(String.Empty);
            }
            if (fi.Directory.Exists == false)
            {
                Directory.CreateDirectory(fi.DirectoryName);
            }
            Download(dialog.URL, fi.DirectoryName, dialog.FileName);
            var resBuilder = new StringBuilder();

            resBuilder.AppendFormat($"<img src=\"{dialog.FileName}\" alt=\"{dialog.ALT}\"/>");
            return(resBuilder.ToString());
        }
Example #2
0
 private void InsertImage_Executed(object sender, ExecutedRoutedEventArgs e)
 {
     if (DocumentIsReady)
     {
         InsertImageDialog dialog = new InsertImageDialog
         {
             Owner = Window.GetWindow(this)
         };
         if (dialog.ShowDialog() == true)
         {
             InsertHtml(dialog.Model.ToHtml());
         }
     }
 }