// // The Pimp The Pathetic Image Manipulation Program // Copyright (c) 2008 Sam Hocevar // All Rights Reserved // // $Id$ // // This library is free software. It comes without any warranty, to // the extent permitted by applicable law. You can redistribute it // and/or modify it under the terms of the Do What The Fuck You Want // To Public License, Version 2, as published by Sam Hocevar. See // http://sam.zoy.org/wtfpl/COPYING for more details. // using System; using Gtk; using Pipi; using ThePimp; namespace ThePimp { public partial class MainWindow: Gtk.Window { public MainWindow (): base (Gtk.WindowType.Toplevel) { Build (); vpaned1.Add1(new ToolBox()); } protected void OnDeleteEvent (object sender, DeleteEventArgs a) { Application.Quit (); a.RetVal = true; } protected virtual void OnOpenActionActivated (object sender, System.EventArgs e) { OpenFile dialog = new OpenFile(); string s = dialog.GetChoice(); dialog.Destroy(); if(s == null) return; Pipi.Picture p = Pipi.Picture.Load(s); if(p == null) { new ErrorWindow("Could not open \"" + s + "\". Check the file format."); return; } while(notebook1.NPages > 0) notebook1.RemovePage(0); int n = notebook1.AppendPage(new PictureView(p), new Label(p.FileName)); notebook1.Page = n; } protected virtual void OnNewActionActivated (object sender, System.EventArgs e) { NewFile dialog = new NewFile(); string s = dialog.GetChoice(); dialog.Destroy(); if(s == null) return; Pipi.Picture p = Pipi.Picture.Load(s); if(p == null) { new ErrorWindow("Could not create image."); return; } while(notebook1.NPages > 0) notebook1.RemovePage(0); int n = notebook1.AppendPage(new PictureView(p), new Label(p.FileName)); notebook1.Page = n; } protected virtual void OnQuitActionActivated (object sender, System.EventArgs e) { Application.Quit (); } protected virtual void OnSaveAsActionActivated (object sender, System.EventArgs e) { if(notebook1.NPages <= 0) return; SaveFile save = new SaveFile(); PictureView view = notebook1.CurrentPageWidget as PictureView; save.Save(view.Picture); save.Destroy(); } protected virtual void OnAboutActionActivated (object sender, System.EventArgs e) { new AboutWindow(); } protected virtual void OnSaveActionActivated (object sender, System.EventArgs e) { } } }