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); } } }
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); } } } }
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); } } }