Esempio n. 1
0
        private void buttonImage_Click(object sender, RoutedEventArgs e)
        {
            ImageURLDialog imgDia = new ImageURLDialog();

            imgDia.Closed += new EventHandler(imgDia_Closed);
            imgDia.Show();
        }
Esempio n. 2
0
        private void buttonImage_Click(object sender, RoutedEventArgs e)
        {
            string url = null;

            ImageURLDialog imgDia = new ImageURLDialog();

            imgDia.ShowDialog();

            //get inserted url
            url = imgDia.URLString;

            //check if it is a valid url
            if (url != null && (url.StartsWith("http://") || url.StartsWith("https://")))
            {
                //Create bitmapimage refrenceing the online link to download it
                BitmapImage bitmap = new BitmapImage(new Uri(url, UriKind.RelativeOrAbsolute));
                //bitmap.DownloadCompleted += controller.GetDownloadCompleteEventHandler();
                bitmap.DownloadCompleted += new EventHandler(controller.ImageDownloadComplete);

                TextRange tr = new TextRange(richTextBox.Selection.Start, richTextBox.Selection.End);
                tr.Text = "";

                Run       run   = new Run("[IMAGE:" + url + "]");
                Hyperlink hlink = new Hyperlink(run, tr.Start);
                hlink.NavigateUri = new Uri(url);
            }
        }
Esempio n. 3
0
        private void imgDia_Closed(object sender, EventArgs args)
        {
            ImageURLDialog imgDia = (ImageURLDialog)sender;

            //get inserted url
            string url = imgDia.URLString;

            //check if it is a valid url
            if (url != null && (url.StartsWith("http://") || url.StartsWith("https://")))
            {
                string urlString = "[IMAGE:" + url + "]";
                richTextBox.Selection.Text += urlString;
            }
        }