Пример #1
0
 private void OnImageToolboxClicked(object sender, EventArgs e)
 {
     Application.EnableVisualStyles();
     ThumbnailViewer.UseWebViewer = true;
     using (var dlg = new ImageToolboxDialog(new PalasoImage(), null))
     {
         dlg.ShowDialog();
     }
 }
Пример #2
0
        public void ShowToolboxWith_PreExisting_EnsureRawFormatUnchanged()
        {
            Application.EnableVisualStyles();
            PalasoImage i = PalasoImage.FromImage(TestImages.logo);

            using (var dlg = new ImageToolboxDialog(i, ""))
            {
                dlg.ShowDialog();
                Assert.AreEqual(ImageFormat.Jpeg.Guid, dlg.ImageInfo.Image.RawFormat.Guid);
            }
        }
Пример #3
0
 public void ShowToolbox()
 {
     Application.EnableVisualStyles();
     using (var dlg = new ImageToolboxDialog(new PalasoImage(), null))           // "arrow"))
     {
         if (DialogResult.OK == dlg.ShowDialog())
         {
             // File name ending in .tmp will confuse TagLib#...doesn't know what kind of metadata to write.
             string path = Path.ChangeExtension(Path.GetTempFileName(), ".png");
             dlg.ImageInfo.Save(path);
             Process.Start("explorer.exe", "/select, \"" + path + "\"");
         }
     }
 }
Пример #4
0
        public void ShowToolboxWith_PreExisting_Image_WithMetadata()
        {
            Application.EnableVisualStyles();
            PalasoImage i = PalasoImage.FromImage(LicenseLogos.by_nd);

            i.Metadata.License         = new CreativeCommonsLicense(true, true, CreativeCommonsLicense.DerivativeRules.DerivativesWithShareAndShareAlike);
            i.Metadata.CopyrightNotice = "Copyright 1992 Papua New Guinea Department of Education and Other Good Things";
            i.Metadata.CollectionName  = "International Illustrations: The Art Of Reading";
            i.Metadata.Creator         = "Various Talented Illustrators";
            //using (var f = TempFile.WithExtension(".png"))
            {
                //i.Save(f.Path);
                using (var dlg = new ImageToolboxDialog(i, "arrow"))
                {
                    dlg.ShowDialog();
                }
            }
        }
Пример #5
0
        private void OnChangeImage(DomEventArgs ge)
        {
            var imageElement = GetImageNode(ge);

            if (imageElement == null)
            {
                return;
            }
            string currentPath = imageElement.GetAttribute("src").Replace("%20", " ");

            if (!CheckIfLockedAndWarn(currentPath))
            {
                return;
            }
            var target = (GeckoHtmlElement)ge.Target.CastToGeckoElement();

            if (target.ClassName.Contains("licenseImage"))
            {
                return;
            }

            Cursor = Cursors.WaitCursor;

            var imageInfo         = new PalasoImage();
            var existingImagePath = Path.Combine(_model.CurrentBook.FolderPath, currentPath);

            //don't send the placeholder to the imagetoolbox... we get a better user experience if we admit we don't have an image yet.
            if (!currentPath.ToLower().Contains("placeholder") && File.Exists(existingImagePath))
            {
                try
                {
                    imageInfo = PalasoImage.FromFile(existingImagePath);
                }
                catch (Exception)
                {
                    //todo: log this
                }
            }
            ;
            Logger.WriteEvent("Showing ImageToolboxDialog Editor Dialog");
            using (var dlg = new ImageToolboxDialog(imageInfo, null))
            {
                if (DialogResult.OK == dlg.ShowDialog())
                {
                    // var path = MakePngOrJpgTempFileForImage(dlg.ImageInfo.Image);
                    try
                    {
                        _model.ChangePicture(imageElement, dlg.ImageInfo, new NullProgress());
                    }
                    catch (System.IO.IOException error)
                    {
                        Palaso.Reporting.ErrorReport.NotifyUserOfProblem(error, error.Message);
                    }
                    catch (ApplicationException error)
                    {
                        Palaso.Reporting.ErrorReport.NotifyUserOfProblem(error, error.Message);
                    }
                    catch (Exception error)
                    {
                        Palaso.Reporting.ErrorReport.NotifyUserOfProblem(error, "Bloom had a problem including that image");
                    }
                }
            }
            Logger.WriteMinorEvent("Emerged from ImageToolboxDialog Editor Dialog");
            Cursor = Cursors.Default;
        }
Пример #6
0
        private void OnChangeImage(GeckoDomEventArgs ge)
        {
            var imageElement = GetImageNode(ge);

            if (imageElement == null)
            {
                return;
            }
            string currentPath = imageElement.GetAttribute("src").Replace("%20", " ");

            //TODO: this would let them set it once without us bugging them, but after that if they
            //go to change it, we would bug them because we don't have a way of knowing that it was a placeholder before.
            if (!currentPath.ToLower().Contains("placeholder") &&           //always alow them to put in something over a placeholder
                !_model.CanChangeImages())
            {
                if (DialogResult.Cancel == MessageBox.Show(LocalizationManager.GetString("EditTab.ImageChangeWarning", "This book is locked down as shell. Are you sure you want to change the picture?"), LocalizationManager.GetString("EditTab.ChangeImage", "Change Image"), MessageBoxButtons.OKCancel))
                {
                    return;
                }
            }
            if (ge.Target.ClassName.Contains("licenseImage"))
            {
                return;
            }

            Cursor = Cursors.WaitCursor;

            var imageInfo         = new PalasoImage();
            var existingImagePath = Path.Combine(_model.CurrentBook.FolderPath, currentPath);

            //don't send the placeholder to the imagetoolbox... we get a better user experience if we admit we don't have an image yet.
            if (!currentPath.ToLower().Contains("placeholder") && File.Exists(existingImagePath))
            {
                try
                {
                    imageInfo = PalasoImage.FromFile(existingImagePath);
                }
                catch (Exception)
                {
                    //todo: log this
                }
            }
            ;
            Logger.WriteEvent("Showing ImageToolboxDialog Editor Dialog");
            using (var dlg = new ImageToolboxDialog(imageInfo, null))
            {
                if (DialogResult.OK == dlg.ShowDialog())
                {
                    // var path = MakePngOrJpgTempFileForImage(dlg.ImageInfo.Image);
                    try
                    {
                        _model.ChangePicture(imageElement, dlg.ImageInfo, new NullProgress());
                    }
                    catch (System.IO.IOException error)
                    {
                        Palaso.Reporting.ErrorReport.NotifyUserOfProblem(error, error.Message);
                    }
                    catch (ApplicationException error)
                    {
                        Palaso.Reporting.ErrorReport.NotifyUserOfProblem(error, error.Message);
                    }
                    catch (Exception error)
                    {
                        Palaso.Reporting.ErrorReport.NotifyUserOfProblem(error, "Bloom had a problem including that image");
                    }
                }
            }
            Logger.WriteMinorEvent("Emerged from ImageToolboxDialog Editor Dialog");
            Cursor = Cursors.Default;
        }