summaryrefslogtreecommitdiff
path: root/ManipulationMenu.cs
diff options
context:
space:
mode:
Diffstat (limited to 'ManipulationMenu.cs')
-rw-r--r--ManipulationMenu.cs104
1 files changed, 104 insertions, 0 deletions
diff --git a/ManipulationMenu.cs b/ManipulationMenu.cs
new file mode 100644
index 0000000..f71cbd3
--- /dev/null
+++ b/ManipulationMenu.cs
@@ -0,0 +1,104 @@
+// BitmapSpriteEd - Bitmap Sprite Editor
+// Copyright (C) 2005 Ian Cowburn
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+// $Id$
+//
+using System;
+using System.Collections;
+using System.Drawing;
+using System.Windows.Forms;
+
+namespace BitmapSpriteEd
+{
+ /// <summary>
+ /// Implements the Manipulation menu
+ /// </summary>
+ public class ManipulationMenu
+ {
+ public enum EMode
+ {
+ eNothing,
+ eMirrorHorizontal,
+ eMirrorVertical,
+ eRotateLeft,
+ eRotateRight,
+ eScrollUp,
+ eScrollDown,
+ eScrollLeft,
+ eScrollRight
+ };
+
+ public ManipulationMenu()
+ {
+ m_mode=EMode.eNothing;
+
+ CreateMenus();
+ }
+
+ public EMode Mode
+ {
+ get {return m_mode;}
+ }
+
+ public void Show(Control c, int x, int y)
+ {
+ m_mode=EMode.eNothing;
+ m_menu.Show(c, new Point(x,y));
+
+ // Kludge warning!
+ //
+ Application.DoEvents();
+ }
+
+
+ // ------------------------------------------------
+ // PRIVATE
+ //
+ private EMode m_mode;
+
+ private Hashtable m_modeMap;
+
+ private ContextMenu m_menu;
+
+ private void CreateItem(string text, EMode mode)
+ {
+ MenuItem i=new MenuItem(text,new EventHandler(OnMenu));
+ m_modeMap[i]=mode;
+ m_menu.MenuItems.Add(i);
+ }
+
+ private void CreateMenus()
+ {
+ m_menu=new ContextMenu();
+ m_modeMap=new Hashtable();
+
+ CreateItem("Mirror Horizontal",EMode.eMirrorHorizontal);
+ CreateItem("Mirror Vertical",EMode.eMirrorVertical);
+ CreateItem("Rotate Left",EMode.eRotateLeft);
+ CreateItem("Rotate Right",EMode.eRotateRight);
+ CreateItem("Scroll Up",EMode.eScrollUp);
+ CreateItem("Scroll Down",EMode.eScrollDown);
+ CreateItem("Scroll Left",EMode.eScrollLeft);
+ CreateItem("Scroll Right",EMode.eScrollRight);
+ }
+
+ private void OnMenu(object sender, System.EventArgs e)
+ {
+ m_mode=(EMode)m_modeMap[sender];
+ }
+ }
+}