summaryrefslogtreecommitdiff
path: root/CopyMenu.cs
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2005-07-30 01:55:41 +0000
committerIan C <ianc@noddybox.co.uk>2005-07-30 01:55:41 +0000
commit93ac9c657ce285c5daa5a3ea6ed8c91b50e0281c (patch)
tree40524242c2f73c6b922e2152f63b233f02545852 /CopyMenu.cs
parentbe2ad76237e13937a37a4a9c419300bba563712c (diff)
Development checkin
Diffstat (limited to 'CopyMenu.cs')
-rw-r--r--CopyMenu.cs165
1 files changed, 165 insertions, 0 deletions
diff --git a/CopyMenu.cs b/CopyMenu.cs
new file mode 100644
index 0000000..a123fe3
--- /dev/null
+++ b/CopyMenu.cs
@@ -0,0 +1,165 @@
+// 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 Copy/Paste menu
+ /// </summary>
+ public class CopyMenu
+ {
+ public enum EMode
+ {
+ eNothing,
+ eMark,
+ ePaste,
+ ePasteTransparent
+ };
+
+ public enum EGravity
+ {
+ eTopLeft,
+ eTopRight,
+ eBottomLeft,
+ eBottomRight,
+ eCentre
+ };
+
+ public CopyMenu()
+ {
+ m_mode=EMode.eNothing;
+ m_grav=EGravity.eTopLeft;
+
+ CreateMenus();
+ }
+
+ public bool AllowPaste
+ {
+ set
+ {
+ m_paste.Enabled=value;
+ m_pasteTrans.Enabled=value;
+ }
+ }
+
+ public EMode Mode
+ {
+ get {return m_mode;}
+ set {m_mode=value;}
+ }
+
+ public EGravity Gravity
+ {
+ get {return m_grav;}
+ }
+
+ public void Show(Control c, int x, int y)
+ {
+ m_menu.Show(c, new Point(x,y));
+ }
+
+
+ // ------------------------------------------------
+ // PRIVATE
+ //
+ private EMode m_mode;
+ private EGravity m_grav;
+
+ private Hashtable m_modeMap;
+ private Hashtable m_gravMap;
+
+ private ContextMenu m_menu;
+ private MenuItem m_mark;
+ private MenuItem m_paste;
+ private MenuItem m_pasteTrans;
+ private MenuItem m_gravSub;
+ private MenuItem m_topLeft;
+ private MenuItem m_topRight;
+ private MenuItem m_bottomLeft;
+ private MenuItem m_bottomRight;
+ private MenuItem m_centre;
+
+ private void CreateMenus()
+ {
+ m_menu=new ContextMenu();
+
+ m_mark=new MenuItem("Mark and Copy", new EventHandler(OnMenu));
+ m_paste=new MenuItem("Paste", new EventHandler(OnMenu));
+ m_pasteTrans=new MenuItem("Paste Transparent", new EventHandler(OnMenu));
+
+ m_gravSub=new MenuItem("Paste Gravity");
+
+ m_topLeft=new MenuItem("Top Left",new EventHandler(OnGravity));
+ m_topRight=new MenuItem("Top Right",new EventHandler(OnGravity));
+ m_bottomLeft=new MenuItem("Bottom Left",new EventHandler(OnGravity));
+ m_bottomRight=new MenuItem("Bottom Right",new EventHandler(OnGravity));
+ m_centre=new MenuItem("Centre",new EventHandler(OnGravity));
+
+ m_gravSub.MenuItems.Add(m_topLeft);
+ m_gravSub.MenuItems.Add(m_topRight);
+ m_gravSub.MenuItems.Add(m_bottomLeft);
+ m_gravSub.MenuItems.Add(m_bottomRight);
+ m_gravSub.MenuItems.Add(m_centre);
+
+ m_topLeft.Checked=true;
+
+ m_menu.MenuItems.Add(m_mark);
+ m_menu.MenuItems.Add(m_gravSub);
+ m_menu.MenuItems.Add(m_paste);
+ m_menu.MenuItems.Add(m_pasteTrans);
+
+ m_modeMap=new Hashtable();
+ m_gravMap=new Hashtable();
+
+ m_modeMap[m_mark]=EMode.eMark;
+ m_modeMap[m_paste]=EMode.ePaste;
+ m_modeMap[m_pasteTrans]=EMode.ePasteTransparent;
+
+ m_gravMap[m_topLeft]=EGravity.eTopLeft;
+ m_gravMap[m_topRight]=EGravity.eTopRight;
+ m_gravMap[m_bottomLeft]=EGravity.eBottomLeft;
+ m_gravMap[m_bottomRight]=EGravity.eBottomRight;
+ m_gravMap[m_centre]=EGravity.eCentre;
+ }
+
+ private void OnMenu(object sender, System.EventArgs e)
+ {
+ m_mode=(EMode)m_modeMap[sender];
+ }
+
+ private void OnGravity(object sender, System.EventArgs e)
+ {
+ MenuItem i=(MenuItem)sender;
+
+ m_grav=(EGravity)m_gravMap[sender];
+
+ foreach (MenuItem m in m_gravSub.MenuItems)
+ {
+ m.Checked=false;
+ }
+
+ i.Checked=true;
+ }
+ }
+}