Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 
 

126 řádky
3.5 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. [Gtk.Binding(Gdk.Key.F11, "ToggleFullScreen")]
  21. public partial class MainWindow: Gtk.Window
  22. {
  23. public MainWindow (): base (Gtk.WindowType.Toplevel)
  24. {
  25. Build ();
  26. vpaned1.Add1(new ToolBox());
  27. }
  28. protected void OnDeleteEvent (object sender, DeleteEventArgs a)
  29. {
  30. Application.Quit ();
  31. a.RetVal = true;
  32. }
  33. protected virtual void OnOpenActionActivated (object sender, System.EventArgs e)
  34. {
  35. string s = OpenFile.GetChoice();
  36. if(s == null)
  37. return;
  38. Pipi.Picture p = Pipi.Picture.Load(s);
  39. if(p == null)
  40. {
  41. new ErrorWindow("Could not open \"" + s + "\". Check the file format.");
  42. return;
  43. }
  44. while(notebook1.NPages > 0)
  45. notebook1.RemovePage(0);
  46. int n = notebook1.AppendPage(new PictureView(p),
  47. new Label(p.FileName));
  48. notebook1.Page = n;
  49. }
  50. protected virtual void OnNewActionActivated (object sender, System.EventArgs e)
  51. {
  52. NewFile dialog = new NewFile();
  53. string s = dialog.GetChoice();
  54. dialog.Destroy();
  55. if(s == null)
  56. return;
  57. Pipi.Picture p = Pipi.Picture.Load(s);
  58. if(p == null)
  59. {
  60. new ErrorWindow("Could not create image.");
  61. return;
  62. }
  63. while(notebook1.NPages > 0)
  64. notebook1.RemovePage(0);
  65. int n = notebook1.AppendPage(new PictureView(p),
  66. new Label(p.FileName));
  67. notebook1.Page = n;
  68. }
  69. protected virtual void OnQuitActionActivated (object sender, System.EventArgs e)
  70. {
  71. Application.Quit ();
  72. }
  73. protected virtual void OnSaveAsActionActivated (object sender, System.EventArgs e)
  74. {
  75. if(notebook1.NPages <= 0)
  76. return;
  77. PictureView view = notebook1.CurrentPageWidget as PictureView;
  78. string s = OpenFile.GetChoice();
  79. if(s == null)
  80. return;
  81. view.Picture.Save(s);
  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. private bool _fullscreen = false;
  91. protected virtual void ToggleFullScreen()
  92. {
  93. _fullscreen = !_fullscreen;
  94. if(_fullscreen)
  95. Fullscreen();
  96. else
  97. Unfullscreen();
  98. }
  99. protected virtual void OnFullscreenActionActivated (object sender, System.EventArgs e)
  100. {
  101. ToggleFullScreen();
  102. }
  103. }
  104. }