// 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 { /// /// Implements the Manipulation menu /// public class ManipulationMenu { public enum EMode { eNothing, eMirrorHorizontal, eMirrorVertical, eRotateLeft, eRotateRight, eScrollUp, eScrollDown, eScrollLeft, eScrollRight, eEdge, eDropShadow, eReplace, eReplaceAll }; 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); CreateItem("Edge",EMode.eEdge); CreateItem("Drop Shadow",EMode.eDropShadow); CreateItem("Replace Colour",EMode.eReplace); CreateItem("Replace all non-zero alpha colours",EMode.eReplaceAll); } private void OnMenu(object sender, System.EventArgs e) { m_mode=(EMode)m_modeMap[sender]; } } }