|
|
@ -26,9 +26,12 @@ |
|
|
|
// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
|
|
|
|
using System; |
|
|
|
using System; |
|
|
|
|
|
|
|
using System.Drawing; |
|
|
|
|
|
|
|
using System.Drawing.Imaging; |
|
|
|
using System.IO; |
|
|
|
using System.IO; |
|
|
|
using System.Windows.Forms; |
|
|
|
using System.Windows.Forms; |
|
|
|
using ICSharpCode.Core; |
|
|
|
using ICSharpCode.Core; |
|
|
|
|
|
|
|
using ICSharpCode.SharpDevelop; |
|
|
|
using ICSharpCode.SharpDevelop.Gui; |
|
|
|
using ICSharpCode.SharpDevelop.Gui; |
|
|
|
|
|
|
|
|
|
|
|
namespace ImageViewer |
|
|
|
namespace ImageViewer |
|
|
@ -36,36 +39,54 @@ namespace ImageViewer |
|
|
|
public class ImageViewContent : AbstractViewContent |
|
|
|
public class ImageViewContent : AbstractViewContent |
|
|
|
{ |
|
|
|
{ |
|
|
|
PictureBox box = new PictureBox(); |
|
|
|
PictureBox box = new PictureBox(); |
|
|
|
|
|
|
|
ImageFormat format; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ImageViewContent(OpenedFile file) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
this.TabPageText = "Image Viewer"; |
|
|
|
|
|
|
|
this.Files.Add(file); |
|
|
|
|
|
|
|
file.ForceInitializeView(this); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public override Control Control { |
|
|
|
public override Control Control { |
|
|
|
get { |
|
|
|
get { |
|
|
|
return box; |
|
|
|
return box; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
public override string TabPageText { |
|
|
|
|
|
|
|
|
|
|
|
public override bool IsReadOnly { |
|
|
|
get { |
|
|
|
get { |
|
|
|
return "Image Viewer"; |
|
|
|
if (File.Exists(PrimaryFile.FileName)) { |
|
|
|
|
|
|
|
return (File.GetAttributes(PrimaryFile.FileName) |
|
|
|
|
|
|
|
& FileAttributes.ReadOnly) != 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
public override void Load(string fileName) { |
|
|
|
|
|
|
|
this.IsDirty = false; |
|
|
|
/// <summary>
|
|
|
|
this.FileName = fileName; |
|
|
|
/// The load method takes a copy of the image and saves the
|
|
|
|
this.TitleName = Path.GetFileName(fileName); |
|
|
|
/// image format so the image can be saved later without throwing
|
|
|
|
|
|
|
|
/// a GDI+ exception. This is because the stream is disposed during
|
|
|
|
|
|
|
|
/// the lifetime of the image:
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
/// http://support.microsoft.com/?id=814675
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
public override void Load(OpenedFile file, Stream stream) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Image image = Image.FromStream(stream); |
|
|
|
|
|
|
|
format = image.RawFormat; |
|
|
|
|
|
|
|
|
|
|
|
box.SizeMode = PictureBoxSizeMode.Zoom; |
|
|
|
box.SizeMode = PictureBoxSizeMode.Zoom; |
|
|
|
box.Load(fileName); |
|
|
|
box.Image = new Bitmap(image.Width, image.Height); |
|
|
|
} |
|
|
|
using (Graphics graphics = Graphics.FromImage(box.Image)) { |
|
|
|
|
|
|
|
graphics.DrawImage(image, 0, 0); |
|
|
|
public override void Save(string fileName) { |
|
|
|
} |
|
|
|
this.IsDirty = false; |
|
|
|
|
|
|
|
this.FileName = fileName; |
|
|
|
|
|
|
|
this.TitleName = Path.GetFileName(fileName); |
|
|
|
|
|
|
|
box.Image.Save(fileName); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public override bool IsReadOnly { |
|
|
|
public override void Save(OpenedFile file, Stream stream) |
|
|
|
get { |
|
|
|
{ |
|
|
|
return (File.GetAttributes(this.FileName) |
|
|
|
box.Image.Save(stream, format); |
|
|
|
& FileAttributes.ReadOnly) != 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|