public static void UpdateMetadataAttributesOnImage(GeckoElement img, PalasoImage imageInfo) { //see also Book.UpdateMetadataAttributesOnImage(), which does the same thing but on the document itself, not the browser dom img.SetAttribute("data-copyright", String.IsNullOrEmpty(imageInfo.Metadata.CopyrightNotice) ? "" : imageInfo.Metadata.CopyrightNotice); img.SetAttribute("data-creator", String.IsNullOrEmpty(imageInfo.Metadata.Creator) ? "" : imageInfo.Metadata.Creator); img.SetAttribute("data-license", imageInfo.Metadata.License == null ? "" : imageInfo.Metadata.License.ToString()); }
public ImageToolboxControl() { InitializeComponent(); _toolImages = new ImageList(); ImageInfo = new PalasoImage(); _copyExemplarMetadata.Font = _editMetadataLink.Font; }
private void SetCurrentImageToolTip(PalasoImage image) { _toolTip.SetToolTip(_currentImageBox, ""); //enchance: this only uses the "originalpath" version, which may be a lot larger than what we //currently have, if we cropped, for example. But I'm loath to save it to disk just to get an accurate size. if (image != null && !string.IsNullOrEmpty(image.OriginalFilePath) && File.Exists(image.OriginalFilePath)) { try { float size = new System.IO.FileInfo(image.OriginalFilePath).Length; if (size > 1000 * 1024) { _toolTip.SetToolTip(_currentImageBox, string.Format("{0} {1:N2}M", image.OriginalFilePath, size / (1024f * 1000f))); } else { _toolTip.SetToolTip(_currentImageBox, string.Format("{0} {1:N2}K", image.OriginalFilePath, size / 1024f)); } } catch (Exception error) { _toolTip.SetToolTip(_currentImageBox, error.Message); } } }
private static string GetImageFileName(string bookFolderPath, PalasoImage imageInfo, bool isJpeg) { string s; if(string.IsNullOrEmpty(imageInfo.FileName) || imageInfo.FileName.StartsWith("tmp")) { // Some images, like from a scanner or camera, won't have a name yet. Some will need a number // in order to differentiate from what is already there. We don't try and be smart somehow and // know when to just replace the existing one with the same name... some other process will have // to remove unused images. s = "image"; int i = 0; string suffix = ""; string extension = isJpeg ? ".jpg" : ".png"; while (File.Exists(Path.Combine(bookFolderPath, s + suffix + extension))) { ++i; suffix = i.ToString(); } return s + suffix + extension; } else { var extension = isJpeg ? ".jpg" : ".png"; return Path.GetFileNameWithoutExtension(imageInfo.FileName) + extension; } }
/// <summary> /// /// </summary> /// <param name="imageInfo">optional (can be null)</param> /// <param name="initialSearchString">optional</param> public ImageToolboxDialog(PalasoImage imageInfo, string initialSearchString) { InitializeComponent(); imageToolboxControl1.ImageInfo = imageInfo; imageToolboxControl1.InitialSearchString = initialSearchString; SearchLanguage = "en"; // unless the caller specifies otherwise explicitly }
/// <summary> /// for testing.... todo: maybe they should test ProcessAndCopyImage() directly, instead /// </summary> public void ChangePicture(string bookFolderPath, XmlDocument dom, string imageId, PalasoImage imageInfo) { var matches = dom.SafeSelectNodes("//img[@id='" + imageId + "']"); XmlElement img = matches[0] as XmlElement; var imageFileName = ProcessAndCopyImage(imageInfo, bookFolderPath); img.SetAttribute("src", imageFileName); }
public ImageToolboxControl() { InitializeComponent(); _toolImages = new ImageList(); ImageInfo = new PalasoImage(); _copyExemplarMetadata.Font = _editMetadataLink.Font; SearchLanguage = "en"; // unless/until the owner specifies otherwise explicitly }
public void SetImage(PalasoImage image) { _previousImage = image; if (ImageChanged != null) { ImageChanged.Invoke(this, null); } }
public void SetImage(PalasoImage image) { _previousImage = image; _scannerButton.Checked = _cameraButton.Checked = false; _currentImage = image; if (image == null) _pictureBox.Image = null; else _pictureBox.Image = image.Image; SetMode(Modes.SingleImage); }
private void OpenFileFromDrag(string path) { SetMode(Modes.SingleImage); _currentImage = PalasoImage.FromFile(path); _pictureBox.Image = _currentImage.Image; ImageToolboxSettings.Default.LastImageFolder = Path.GetDirectoryName(path); ImageToolboxSettings.Default.Save(); if (ImageChanged != null) { ImageChanged.Invoke(this, null); } }
public static PalasoImage FromFile(string path) { var i = new PalasoImage { Image = LoadImageWithoutLocking(path), FileName = Path.GetFileName(path), _originalFilePath = path, _pathForSavingMetadataChanges = path, Metadata = Metadata.FromFile(path) }; return(i); }
private void OnGetFromFileSystemClick(object sender, EventArgs e) { SetMode(Modes.SingleImage); #if MONO using (var dlg = new OpenFileDialog()) #else // The primary thing that OpenFileDialogWithViews buys us is the ability to default to large icons. // OpenFileDialogWithViews still doesn't let us read (and thus remember) the selected view. using (var dlg = new OpenFileDialogWithViews(OpenFileDialogWithViews.DialogViewTypes.Large_Icons)) #endif { #if __MonoCS__ // OpenFileDialogWithViews is Windows-only. Until we need more of its functionality elsewhere, // it's much simpler to implement the one method we need here for Mono/Linux. SelectLargeIconView(dlg); #endif if (string.IsNullOrEmpty(ImageToolboxSettings.Default.LastImageFolder)) { dlg.InitialDirectory = System.Environment.GetFolderPath(Environment.SpecialFolder.MyPictures); } else { dlg.InitialDirectory = ImageToolboxSettings.Default.LastImageFolder;; } //NB: dissallowed gif because of a .net crash: http://jira.palaso.org/issues/browse/BL-85 dlg.Filter = "picture files".Localize("ImageToolbox.PictureFiles", "Shown in the file-picking dialog to describe what kind of files the dialog is filtering for") + "(*.png;*.tif;*.tiff;*.jpg;*.jpeg;*.bmp)|*.png;*.tif;*.tiff;*.jpg;*.jpeg;*.bmp;"; if (DialogResult.OK == dlg.ShowDialog()) { ImageToolboxSettings.Default.LastImageFolder = Path.GetDirectoryName(dlg.FileName); ImageToolboxSettings.Default.Save(); try { _currentImage = PalasoImage.FromFile(dlg.FileName); } catch (Exception err) //for example, http://jira.palaso.org/issues/browse/BL-199 { Palaso.Reporting.ErrorReport.NotifyUserOfProblem(err, "Sorry, there was a problem loading that image.".Localize("ImageToolbox.ProblemLoadingImage")); return; } _pictureBox.Image = _currentImage.Image; if (ImageChanged != null) { ImageChanged.Invoke(this, null); } } } }
private void OnGetFromFileSystemClick(object sender, EventArgs e) { SetMode(Modes.SingleImage); #if MONO using (var dlg = new OpenFileDialog()) #else // The primary thing that OpenFileDialogWithViews buys us is the ability to default to large icons. // OpenFileDialogWithViews still doesn't let us read (and thus remember) the selected view. using (var dlg = new OpenFileDialogWithViews(OpenFileDialogWithViews.DialogViewTypes.Large_Icons)) #endif { #if __MonoCS__ // OpenFileDialogWithViews is Windows-only. Until we need more of its functionality elsewhere, // it's much simpler to implement the one method we need here for Mono/Linux. SelectLargeIconView(dlg); #endif if (string.IsNullOrEmpty(ImageToolboxSettings.Default.LastImageFolder)) { dlg.InitialDirectory = System.Environment.GetFolderPath(Environment.SpecialFolder.MyPictures); } else { dlg.InitialDirectory = ImageToolboxSettings.Default.LastImageFolder; ; } //NB: dissallowed gif because of a .net crash: http://jira.palaso.org/issues/browse/BL-85 dlg.Filter = "picture files".Localize("ImageToolbox.PictureFiles", "Shown in the file-picking dialog to describe what kind of files the dialog is filtering for")+"(*.png;*.tif;*.tiff;*.jpg;*.jpeg;*.bmp)|*.png;*.tif;*.tiff;*.jpg;*.jpeg;*.bmp;"; if (DialogResult.OK == dlg.ShowDialog()) { ImageToolboxSettings.Default.LastImageFolder = Path.GetDirectoryName(dlg.FileName); ImageToolboxSettings.Default.Save(); try { _currentImage = PalasoImage.FromFile(dlg.FileName); } catch (Exception err) //for example, http://jira.palaso.org/issues/browse/BL-199 { Palaso.Reporting.ErrorReport.NotifyUserOfProblem(err,"Sorry, there was a problem loading that image.".Localize("ImageToolbox.ProblemLoadingImage")); return; } _pictureBox.Image = _currentImage.Image; if (ImageChanged != null) ImageChanged.Invoke(this, null); } } }
public PalasoImage GetImage() { if (ChosenPath != null && File.Exists(ChosenPath)) { try { return(PalasoImage.FromFile(ChosenPath)); } catch (Exception error) { Palaso.Reporting.ErrorReport.ReportNonFatalExceptionWithMessage(error, "There was a problem choosing that image."); return(_previousImage); } } return(_previousImage); }
public void SetImage(PalasoImage image) { _previousImage = image; _scannerButton.Checked = _cameraButton.Checked = false; _currentImage = image; if (image == null) { _pictureBox.Image = null; } else { _pictureBox.Image = image.Image; } SetMode(Modes.SingleImage); }
/// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing) { _toolImages.Dispose(); if (_imageInfo!=null) { _imageInfo.Dispose(); _imageInfo = null; } if (components != null) { components.Dispose(); components = null; } } base.Dispose(disposing); }
/// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing) { _toolImages.Dispose(); if (_imageInfo != null) { _imageInfo.Dispose(); _imageInfo = null; } if (components != null) { components.Dispose(); components = null; } } base.Dispose(disposing); }
private void GetFromDevice(ImageAcquisitionService.DeviceKind deviceKind) { //_pictureBox.Image = SampleImages.sampleScan; try { var acquisitionService = new ImageAcquisitionService(deviceKind); var wiaImageFile = acquisitionService.Acquire(); if (wiaImageFile == null) { return; } var imageFile = ConvertToPngOrJpegIfNotAlready(wiaImageFile); _currentImage = PalasoImage.FromFile(imageFile); _pictureBox.Image = _currentImage.Image; if (ImageChanged != null) { ImageChanged.Invoke(this, null); } } catch (ImageDeviceNotFoundException error) { _messageLabel.Text = error.Message + Environment.NewLine + Environment.NewLine + "Note: this program works with devices that have a 'WIA' driver, not the old-style 'TWAIN' driver"; _messageLabel.Visible = true; } catch (WIA_Version2_MissingException error) { _messageLabel.Text = "Windows XP does not come with a crucial DLL that lets you use a WIA scanner with this program. Get a technical person to downloand and follow the directions at http://vbnet.mvps.org/files/updates/wiaautsdk.zip"; _messageLabel.Visible = true; } catch (Exception error) { Palaso.Reporting.ErrorReport.NotifyUserOfProblem(error, "Problem Getting Image".Localize("ImageToolbox.ProblemGettingImageFromDevice")); } }
private void GetFromDevice(ImageAcquisitionService.DeviceKind deviceKind) { //_pictureBox.Image = SampleImages.sampleScan; try { var acquisitionService = new ImageAcquisitionService(deviceKind); var wiaImageFile = acquisitionService.Acquire(); if (wiaImageFile == null) return; var imageFile = ConvertToPngOrJpegIfNotAlready(wiaImageFile); _currentImage = PalasoImage.FromFile(imageFile); _pictureBox.Image = _currentImage.Image; if (ImageChanged != null) ImageChanged.Invoke(this, null); } catch (ImageDeviceNotFoundException error) { _messageLabel.Text = error.Message + Environment.NewLine +Environment.NewLine+ "Note: this program works with devices that have a 'WIA' driver, not the old-style 'TWAIN' driver"; _messageLabel.Visible = true; } catch (WIA_Version2_MissingException error) { _messageLabel.Text = "Windows XP does not come with a crucial DLL that lets you use a WIA scanner with this program. Get a technical person to downloand and follow the directions at http://vbnet.mvps.org/files/updates/wiaautsdk.zip"; _messageLabel.Visible = true; } catch (Exception error) { Palaso.Reporting.ErrorReport.NotifyUserOfProblem(error, "Problem Getting Image".Localize("ImageToolbox.ProblemGettingImageFromDevice")); } }
private void OpenFileFromDrag(string path) { SetMode(Modes.SingleImage); _currentImage = PalasoImage.FromFile(path); _pictureBox.Image = _currentImage.Image; ImageToolboxSettings.Default.LastImageFolder = Path.GetDirectoryName(path); ImageToolboxSettings.Default.Save(); if (ImageChanged != null) ImageChanged.Invoke(this, null); }
public void SetImage(PalasoImage image) { _previousImage = image; if(ImageChanged!=null) ImageChanged.Invoke(this,null); }
private void SetCurrentImageToolTip(PalasoImage image) { _toolTip.SetToolTip(_currentImageBox, ""); //enchance: this only uses the "originalpath" version, which may be a lot larger than what we //currently have, if we cropped, for example. But I'm loath to save it to disk just to get an accurate size. if (image!=null && !string.IsNullOrEmpty(image.OriginalFilePath) && File.Exists(image.OriginalFilePath)) { try { float size = new System.IO.FileInfo(image.OriginalFilePath).Length; if (size > 1000*1024) _toolTip.SetToolTip(_currentImageBox, string.Format("{0} {1:N2}M", image.OriginalFilePath, size/(1024f*1000f))); else { _toolTip.SetToolTip(_currentImageBox, string.Format("{0} {1:N2}K", image.OriginalFilePath, size/1024f)); } } catch (Exception error) { _toolTip.SetToolTip(_currentImageBox, error.Message); } } }
/// <summary> /// /// </summary> /// <param name="imageInfo">optional (can be null)</param> /// <param name="initialSearchString">optional</param> public ImageToolboxDialog(PalasoImage imageInfo, string initialSearchString) { InitializeComponent(); imageToolboxControl1.ImageInfo = imageInfo; imageToolboxControl1.InitialSearchString = initialSearchString; }
public static PalasoImage FromFile(string path) { var i = new PalasoImage { Image = LoadImageWithoutLocking(path), FileName = Path.GetFileName(path), _originalFilePath = path, _pathForSavingMetadataChanges = path, Metadata = Metadata.FromFile(path) }; return i; }
public void ChangePicture(GeckoElement img, PalasoImage imageInfo, IProgress progress) { try { Logger.WriteMinorEvent("Starting ChangePicture {0}...", imageInfo.FileName); var editor = new PageEditingModel(); editor.ChangePicture(_bookSelection.CurrentSelection.FolderPath, img, imageInfo, progress); //we have to save so that when asked by the thumbnailer, the book will give the proper image SaveNow(); //but then, we need the non-cleaned version back there _view.UpdateSingleDisplayedPage(_pageSelection.CurrentSelection); _view.UpdateThumbnailAsync(_pageSelection.CurrentSelection); Logger.WriteMinorEvent("Finished ChangePicture {0} (except for async thumbnail) ...", imageInfo.FileName); Analytics.Track("Change Picture"); Logger.WriteEvent("ChangePicture {0}...", imageInfo.FileName); } catch (Exception e) { ErrorReport.NotifyUserOfProblem(e, "Could not change the picture"); } }
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 allow 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; }
private bool ShouldSaveAsJpeg(PalasoImage imageInfo) { /* * Note, each guid is VERY SIMILAR. The difference is only in the last 2 digits of the 1st group. Undefined B96B3CA9 MemoryBMP B96B3CAA BMP B96B3CAB EMF B96B3CAC WMF B96B3CAD JPEG B96B3CAE PNG B96B3CAF GIF B96B3CB0 TIFF B96B3CB1 EXIF B96B3CB2 Icon B96B3CB5 */ if(ImageFormat.Jpeg.Guid == imageInfo.Image.RawFormat.Guid) return true; if(ImageFormat.Jpeg.Equals(imageInfo.Image.PixelFormat))//review return true; if(string.IsNullOrEmpty(imageInfo.FileName)) return false; return new []{"jpg", "jpeg"}.Contains(Path.GetExtension(imageInfo.FileName).ToLower()); }
public void Image_CreatedWithImageOnly_GivesSameImage() { Bitmap bitmap = new Bitmap(10, 10); var pi = new PalasoImage(bitmap); Assert.AreEqual(bitmap, pi.Image); }
public void ChangePicture(string bookFolderPath, GeckoElement img, PalasoImage imageInfo, IProgress progress) { var imageFileName = ProcessAndCopyImage(imageInfo, bookFolderPath); img.SetAttribute("src", imageFileName); UpdateMetdataAttributesOnImgElement(img, imageInfo); }
public static PalasoImage FromFile(string path) { _pathForSavingMetadataChanges = path; var i = new PalasoImage() { Image = LoadImageWithoutLocking(path), FileName = Path.GetFileName(path) }; i.Metadata = Metadata.FromFile(path); return i; }
private void OnGetFromFileSystemClick(object sender, EventArgs e) { SetMode(Modes.SingleImage); //#if MONO // using (var dlg = new OpenFileDialog()) // { // if (string.IsNullOrEmpty(ImageToolboxSettings.Default.LastImageFolder)) // { // dlg.InitialDirectory = System.Environment.GetFolderPath(Environment.SpecialFolder.MyPictures); // } // else // { // dlg.InitialDirectory = ImageToolboxSettings.Default.LastImageFolder; // } // // dlg.Filter = "picture files|*.png;*.tif;*.tiff;*.jpg;*.jpeg;*.bmp;"; // dlg.Multiselect = false; // dlg.AutoUpgradeEnabled = true; // if (DialogResult.OK == dlg.ShowDialog()) // { // _currentImage = PalasoImage.FromFile(dlg.FileName); // _pictureBox.Image = _currentImage.Image; // ImageToolboxSettings.Default.LastImageFolder = Path.GetDirectoryName(dlg.FileName); // ImageToolboxSettings.Default.Save(); // if (ImageChanged != null) // ImageChanged.Invoke(this, null); // } // } //#else #if MONO using (var dlg = new OpenFileDialog()) #else //The primary thing this OpenFileDialogEx buys us is that with the standard one, there's //no way pre-set, what "view" the user gets. With the standard dialog, //we had complaints that a user had to change the view to show icons *each time* they used this. //Now, OpenFileDialogWithViews still doesn't let us read (and thus remember) the selected view. using (var dlg = new OpenFileDialogWithViews(OpenFileDialogWithViews.DialogViewTypes.Large_Icons)) #endif { if (string.IsNullOrEmpty(ImageToolboxSettings.Default.LastImageFolder)) { dlg.InitialDirectory = System.Environment.GetFolderPath(Environment.SpecialFolder.MyPictures); } else { dlg.InitialDirectory = ImageToolboxSettings.Default.LastImageFolder; ; } //NB: dissallowed gif because of a .net crash: http://jira.palaso.org/issues/browse/BL-85 dlg.Filter = "picture files".Localize("ImageToolbox.PictureFiles", "Shown in the file-picking dialog to describe what kind of files the dialog is filtering for")+"(*.png;*.tif;*.tiff;*.jpg;*.jpeg;*.bmp)|*.png;*.tif;*.tiff;*.jpg;*.jpeg;*.bmp;"; if (DialogResult.OK == dlg.ShowDialog()) { ImageToolboxSettings.Default.LastImageFolder = Path.GetDirectoryName(dlg.FileName); ImageToolboxSettings.Default.Save(); try { _currentImage = PalasoImage.FromFile(dlg.FileName); } catch (Exception err) //for example, http://jira.palaso.org/issues/browse/BL-199 { Palaso.Reporting.ErrorReport.NotifyUserOfProblem(err,"Sorry, there was a problem loading that image.".Localize("ImageToolbox.ProblemLoadingImage")); return; } _pictureBox.Image = _currentImage.Image; if (ImageChanged != null) ImageChanged.Invoke(this, null); } } }
/// <summary> /// Makes the image png if it's not a jpg, makes white transparent, compresses it, and saves in the book's folder. /// Replaces any file with the same name. /// </summary> /// <returns>The name of the file, now in the book's folder.</returns> private string ProcessAndCopyImage(PalasoImage imageInfo, string bookFolderPath) { var isJpeg = ShouldSaveAsJpeg(imageInfo); try { using (Bitmap image = new Bitmap(imageInfo.Image)) //nb: there are cases (undefined) where we get out of memory if we are not operating on a copy { //photographs don't work if you try to make the white transparent if (!isJpeg && image is Bitmap) { ((Bitmap) image).MakeTransparent(Color.White); //make white look realistic against background } string imageFileName = GetImageFileName(bookFolderPath, imageInfo, isJpeg); var dest = Path.Combine(bookFolderPath, imageFileName); if (File.Exists(dest)) { try { File.Delete(dest); } catch (System.IO.IOException error) { throw new ApplicationException("Bloom could not replace the image " + imageFileName + ", probably because Bloom itself has it locked."); } } image.Save(dest, isJpeg ? ImageFormat.Jpeg : ImageFormat.Png); if (!isJpeg) { using (var dlg = new ProgressDialogBackground()) { dlg.ShowAndDoWork((progress, args) => ImageUpdater.CompressImage(dest, progress)); } } imageInfo.Metadata.Write(dest); return imageFileName; } } catch (System.IO.IOException) { throw; //these are informative on their own } catch (Exception error) { if (!string.IsNullOrEmpty(imageInfo.FileName) && File.Exists(imageInfo.OriginalFilePath)) { var megs = new System.IO.FileInfo(imageInfo.OriginalFilePath).Length / (1024 * 1000); if (megs > 2) { var msg = string.Format("Bloom was not able to prepare that picture for including in the book. \r\nThis is a rather large image to be adding to a book --{0} Megs--.", megs); if(isJpeg) { msg += "\r\nNote, this file is a jpeg, which is normally used for photographs, not line-drawings (png, tiff, bmp). Bloom can handle smallish jpegs, large ones are difficult to handle, especialy if memory is limitted."; } throw new ApplicationException(msg, error); } } throw new ApplicationException("Bloom was not able to prepare that picture for including in the book. Is it too large, or an odd format?\r\n" + imageInfo.FileName, error); } }
public void UpdateMetdataAttributesOnImgElement(GeckoElement img, PalasoImage imageInfo) { UpdateMetadataAttributesOnImage(img, imageInfo); img.Click(); //wake up javascript to update overlays }
private void OnGetFromFileSystemClick(object sender, EventArgs e) { SetMode(Modes.SingleImage); //#if MONO // using (var dlg = new OpenFileDialog()) // { // if (string.IsNullOrEmpty(ImageToolboxSettings.Default.LastImageFolder)) // { // dlg.InitialDirectory = System.Environment.GetFolderPath(Environment.SpecialFolder.MyPictures); // } // else // { // dlg.InitialDirectory = ImageToolboxSettings.Default.LastImageFolder; // } // // dlg.Filter = "picture files|*.png;*.tif;*.tiff;*.jpg;*.jpeg;*.bmp;"; // dlg.Multiselect = false; // dlg.AutoUpgradeEnabled = true; // if (DialogResult.OK == dlg.ShowDialog()) // { // _currentImage = PalasoImage.FromFile(dlg.FileName); // _pictureBox.Image = _currentImage.Image; // ImageToolboxSettings.Default.LastImageFolder = Path.GetDirectoryName(dlg.FileName); // ImageToolboxSettings.Default.Save(); // if (ImageChanged != null) // ImageChanged.Invoke(this, null); // } // } //#else #if MONO using (var dlg = new OpenFileDialog()) #else //The primary thing this OpenFileDialogEx buys us is that with the standard one, there's //no way pre-set, what "view" the user gets. With the standard dialog, //we had complaints that a user had to change the view to show icons *each time* they used this. //Now, OpenFileDialogWithViews still doesn't let us read (and thus remember) the selected view. using (var dlg = new OpenFileDialogWithViews(OpenFileDialogWithViews.DialogViewTypes.Large_Icons)) #endif { if (string.IsNullOrEmpty(ImageToolboxSettings.Default.LastImageFolder)) { dlg.InitialDirectory = System.Environment.GetFolderPath(Environment.SpecialFolder.MyPictures); } else { dlg.InitialDirectory = ImageToolboxSettings.Default.LastImageFolder;; } //NB: dissallowed gif because of a .net crash: http://jira.palaso.org/issues/browse/BL-85 dlg.Filter = "picture files".Localize("ImageToolbox.PictureFiles", "Shown in the file-picking dialog to describe what kind of files the dialog is filtering for") + "(*.png;*.tif;*.tiff;*.jpg;*.jpeg;*.bmp)|*.png;*.tif;*.tiff;*.jpg;*.jpeg;*.bmp;"; if (DialogResult.OK == dlg.ShowDialog()) { ImageToolboxSettings.Default.LastImageFolder = Path.GetDirectoryName(dlg.FileName); ImageToolboxSettings.Default.Save(); try { _currentImage = PalasoImage.FromFile(dlg.FileName); } catch (Exception err) //for example, http://jira.palaso.org/issues/browse/BL-199 { Palaso.Reporting.ErrorReport.NotifyUserOfProblem(err, "Sorry, there was a problem loading that image.".Localize("ImageToolbox.ProblemLoadingImage")); return; } _pictureBox.Image = _currentImage.Image; if (ImageChanged != null) { ImageChanged.Invoke(this, null); } } } }
public void Locked_NewOne_False() { var pi = new PalasoImage(); Assert.IsFalse(pi.MetadataLocked); }