Пример #1
0
        private void LoadWebImage()
        {
            Dialogs.LoadWebImage dialog = new Dialogs.LoadWebImage();
            if (dialog.Run() == ResponseType.Ok && dialog.Url != null)
            {
                WebFetch webFetch = new WebFetch(dialog.Url);
                string   fileName = null;
                try {
                    if (dialog.Save == true)
                    {
                        string name = dialog.Url.Substring(dialog.Url.LastIndexOf('/') + 1);
                        fileName = System.IO.Path.Combine(Paths.WebImagesDirectory, name);
                    }
                    else
                    {
                        fileName = System.IO.Path.GetTempFileName();
                    }
                    webFetch.Save(fileName);
                } catch (Exception e) {
                    MessageErrorDialog("Save Web Image", e.Message);
                }

                try {
                    LoadImage(fileName, dialog.Save);
                } catch (Exception e) {
                    MessageErrorDialog("Load Web Image", e.Message);
                    // Delete Saved File
                    if (dialog.Save == true)
                    {
                        File.Delete(fileName);
                    }
                }

                // Delete Temp File
                if (dialog.Save == false)
                {
                    File.Delete(fileName);
                }
            }
            dialog.Destroy();
        }
Пример #2
0
        private void LoadWebImage()
        {
            Dialogs.LoadWebImage dialog = new Dialogs.LoadWebImage();
            if (dialog.Run() == ResponseType.Ok && dialog.Url != null) {
                WebFetch webFetch = new WebFetch(dialog.Url);
                string fileName = null;
                try {
                    if (dialog.Save == true) {
                        string name = dialog.Url.Substring(dialog.Url.LastIndexOf('/') + 1);
                        fileName = System.IO.Path.Combine(Paths.WebImagesDirectory, name);
                    } else {
                        fileName = System.IO.Path.GetTempFileName();
                    }
                    webFetch.Save(fileName);
                } catch (Exception e) {
                    MessageErrorDialog("Save Web Image", e.Message);
                }

                try {
                    LoadImage(fileName, dialog.Save);
                } catch (Exception e) {
                    MessageErrorDialog("Load Web Image", e.Message);
                    // Delete Saved File
                    if (dialog.Save == true) File.Delete(fileName);
                }

                // Delete Temp File
                if (dialog.Save == false) File.Delete(fileName);
            }
            dialog.Destroy();
        }