25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 
 
 

107 satır
3.1 KiB

  1. //
  2. // The Pimp The Pathetic Image Manipulation Program
  3. // Copyright (c) 2008 Sam Hocevar <sam@zoy.org>
  4. // All Rights Reserved
  5. //
  6. // $Id$
  7. //
  8. // This library is free software. It comes without any warranty, to
  9. // the extent permitted by applicable law. You can redistribute it
  10. // and/or modify it under the terms of the Do What The Fuck You Want
  11. // To Public License, Version 2, as published by Sam Hocevar. See
  12. // http://sam.zoy.org/wtfpl/COPYING for more details.
  13. //
  14. using System;
  15. using Gtk;
  16. using Pipi;
  17. using ThePimp;
  18. namespace ThePimp
  19. {
  20. public partial class MainWindow: Gtk.Window
  21. {
  22. public MainWindow (): base (Gtk.WindowType.Toplevel)
  23. {
  24. Build ();
  25. vpaned1.Add1(new ToolBox());
  26. }
  27. protected void OnDeleteEvent (object sender, DeleteEventArgs a)
  28. {
  29. Application.Quit ();
  30. a.RetVal = true;
  31. }
  32. protected virtual void OnOpenActionActivated (object sender, System.EventArgs e)
  33. {
  34. OpenFile dialog = new OpenFile();
  35. string s = dialog.GetChoice();
  36. dialog.Destroy();
  37. if(s == null)
  38. return;
  39. Pipi.Picture p = Pipi.Picture.Load(s);
  40. if(p == null)
  41. {
  42. new ErrorWindow("Could not open \"" + s + "\". Check the file format.");
  43. return;
  44. }
  45. while(notebook1.NPages > 0)
  46. notebook1.RemovePage(0);
  47. int n = notebook1.AppendPage(new PictureView(p),
  48. new Label(p.FileName));
  49. notebook1.Page = n;
  50. }
  51. protected virtual void OnNewActionActivated (object sender, System.EventArgs e)
  52. {
  53. NewFile dialog = new NewFile();
  54. string s = dialog.GetChoice();
  55. dialog.Destroy();
  56. if(s == null)
  57. return;
  58. Pipi.Picture p = Pipi.Picture.Load(s);
  59. if(p == null)
  60. {
  61. new ErrorWindow("Could not create image.");
  62. return;
  63. }
  64. while(notebook1.NPages > 0)
  65. notebook1.RemovePage(0);
  66. int n = notebook1.AppendPage(new PictureView(p),
  67. new Label(p.FileName));
  68. notebook1.Page = n;
  69. }
  70. protected virtual void OnQuitActionActivated (object sender, System.EventArgs e)
  71. {
  72. Application.Quit ();
  73. }
  74. protected virtual void OnSaveAsActionActivated (object sender, System.EventArgs e)
  75. {
  76. if(notebook1.NPages <= 0)
  77. return;
  78. SaveFile save = new SaveFile();
  79. PictureView view = notebook1.CurrentPageWidget as PictureView;
  80. save.Save(view.Picture);
  81. save.Destroy();
  82. }
  83. protected virtual void OnAboutActionActivated (object sender, System.EventArgs e)
  84. {
  85. new AboutWindow();
  86. }
  87. protected virtual void OnSaveActionActivated (object sender, System.EventArgs e)
  88. {
  89. }
  90. }
  91. }