monogame port
This commit is contained in:
		@@ -1,286 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: ArchiveManager.cs                            //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.IO;
 | 
			
		||||
using Microsoft.Xna.Framework.Content;
 | 
			
		||||
using TomShane.Neoforce.External.Zip;
 | 
			
		||||
using System.Globalization;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
  #region //// Classes ///////////
 | 
			
		||||
  
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////  
 | 
			
		||||
  /// <include file='Documents/ArchiveManager.xml' path='ArchiveManager/Class[@name="ArchiveManager"]/*' />          
 | 
			
		||||
  public class ArchiveManager : ContentManager
 | 
			
		||||
  {
 | 
			
		||||
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    private string archivePath = null;
 | 
			
		||||
    private ZipFile archive = null;
 | 
			
		||||
    private bool useArchive = false;   
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Properties ////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    /// <include file='Documents/ArchiveManager.xml' path='ArchiveManager/Member[@name="ArchivePath"]/*' />          
 | 
			
		||||
    public virtual string ArchivePath
 | 
			
		||||
    {
 | 
			
		||||
      get { return archivePath; }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public bool UseArchive
 | 
			
		||||
    {
 | 
			
		||||
      get { return useArchive; }
 | 
			
		||||
      set { useArchive = value; }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Constructors //////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    /// <include file='Documents/ArchiveManager.xml' path='ArchiveManager/Member[@name="ArchiveManager"]/*' />              
 | 
			
		||||
    public ArchiveManager(IServiceProvider serviceProvider) : this(serviceProvider, null) { }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    /// <include file='Documents/ArchiveManager.xml' path='ArchiveManager/Member[@name="ArchiveManager1"]/*' />                  
 | 
			
		||||
    public ArchiveManager(IServiceProvider serviceProvider, string archive): base(serviceProvider)
 | 
			
		||||
    {
 | 
			
		||||
      if (archive != null)
 | 
			
		||||
      {
 | 
			
		||||
        this.archive = ZipFile.Read(archive);
 | 
			
		||||
        archivePath = archive;
 | 
			
		||||
        useArchive = true;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Methods ///////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////        
 | 
			
		||||
    /// <include file='Documents/ArchiveManager.xml' path='ArchiveManager/Member[@name="OpenStream"]/*' />
 | 
			
		||||
    protected override Stream OpenStream(string assetName)
 | 
			
		||||
    {
 | 
			
		||||
      if (useArchive && archive != null)
 | 
			
		||||
      {
 | 
			
		||||
        assetName = assetName.Replace("\\", "/");
 | 
			
		||||
        if (assetName.StartsWith("/")) assetName = assetName.Remove(0, 1);
 | 
			
		||||
 | 
			
		||||
        string fullAssetName = (assetName + ".xnb").ToLower();
 | 
			
		||||
 | 
			
		||||
        foreach (ZipEntry entry in archive)
 | 
			
		||||
        {
 | 
			
		||||
          ZipDirEntry ze = new ZipDirEntry(entry);
 | 
			
		||||
          
 | 
			
		||||
          string entryName = entry.FileName.ToLower();
 | 
			
		||||
 | 
			
		||||
          if (entryName == fullAssetName)
 | 
			
		||||
          {
 | 
			
		||||
            return entry.GetStream();
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
        throw new Exception("Cannot find asset \"" + assetName + "\" in the archive.");
 | 
			
		||||
      }
 | 
			
		||||
      else
 | 
			
		||||
      {
 | 
			
		||||
        return base.OpenStream(assetName);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
    /// <include file='Documents/ArchiveManager.xml' path='ArchiveManager/Member[@name="GetAssetNames"]/*' />
 | 
			
		||||
    public string[] GetAssetNames()
 | 
			
		||||
    {
 | 
			
		||||
      if (useArchive && archive != null)
 | 
			
		||||
      {
 | 
			
		||||
        List<string> filenames = new List<string>();
 | 
			
		||||
 | 
			
		||||
        foreach (ZipEntry entry in archive)
 | 
			
		||||
        {
 | 
			
		||||
          string name = entry.FileName;
 | 
			
		||||
          if (name.EndsWith(".xnb"))
 | 
			
		||||
          {
 | 
			
		||||
            name = name.Remove(name.Length - 4, 4);
 | 
			
		||||
            filenames.Add(name);
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
        return filenames.ToArray();
 | 
			
		||||
      }
 | 
			
		||||
      else
 | 
			
		||||
      {
 | 
			
		||||
        return null;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
    /// <include file='Documents/ArchiveManager.xml' path='ArchiveManager/Member[@name="GetAssetNames1"]/*' />        
 | 
			
		||||
    public string[] GetAssetNames(string path)
 | 
			
		||||
    {
 | 
			
		||||
      if (useArchive && archive != null)
 | 
			
		||||
      {
 | 
			
		||||
        if (path != null && path != "" && path != "\\" && path != "/")
 | 
			
		||||
        {
 | 
			
		||||
          List<string> filenames = new List<string>();
 | 
			
		||||
 | 
			
		||||
          foreach (ZipEntry entry in archive)
 | 
			
		||||
          {            
 | 
			
		||||
            string name = entry.FileName;
 | 
			
		||||
            if (name.EndsWith(".xnb"))
 | 
			
		||||
            {
 | 
			
		||||
              name = name.Remove(name.Length - 4, 4);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            string[] parts = name.Split('/');
 | 
			
		||||
            string dir = "";
 | 
			
		||||
            for (int i = 0; i < parts.Length - 1; i++)
 | 
			
		||||
            {
 | 
			
		||||
              dir += parts[i] + '/';
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            path = path.Replace("\\", "/");
 | 
			
		||||
            if (path.StartsWith("/")) path = path.Remove(0, 1);
 | 
			
		||||
            if (!path.EndsWith("/")) path += '/';
 | 
			
		||||
 | 
			
		||||
            if (dir.ToLower() == path.ToLower() && !name.EndsWith("/"))
 | 
			
		||||
            {
 | 
			
		||||
              filenames.Add(name);
 | 
			
		||||
            }
 | 
			
		||||
          }
 | 
			
		||||
          return filenames.ToArray();
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
          return GetAssetNames();
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
      else
 | 
			
		||||
      {
 | 
			
		||||
        return null;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
    /// <include file='Documents/ArchiveManager.xml' path='ArchiveManager/Member[@name="GetFileStream"]/*' />
 | 
			
		||||
    public Stream GetFileStream(string filename)
 | 
			
		||||
    {
 | 
			
		||||
      if (useArchive && archive != null)
 | 
			
		||||
      {
 | 
			
		||||
        filename = filename.Replace("\\", "/").ToLower();
 | 
			
		||||
        if (filename.StartsWith("/")) filename = filename.Remove(0, 1);
 | 
			
		||||
 | 
			
		||||
        foreach (ZipEntry entry in archive)
 | 
			
		||||
        {
 | 
			
		||||
          string entryName = entry.FileName.ToLower();
 | 
			
		||||
 | 
			
		||||
          if (entryName.Equals(filename))
 | 
			
		||||
            return entry.GetStream();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        throw new Exception("Cannot find file \"" + filename + "\" in the archive.");
 | 
			
		||||
      }
 | 
			
		||||
      else
 | 
			
		||||
      {
 | 
			
		||||
        return null;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public string[] GetDirectories(string path)
 | 
			
		||||
    {
 | 
			
		||||
      if (useArchive && archive != null)
 | 
			
		||||
      {
 | 
			
		||||
        if (path != null && path != "" && path != "\\" && path != "/")
 | 
			
		||||
        {
 | 
			
		||||
          List<string> dirs = new List<string>();
 | 
			
		||||
 | 
			
		||||
          path = path.Replace("\\", "/");
 | 
			
		||||
          if (path.StartsWith("/")) path = path.Remove(0, 1);
 | 
			
		||||
          if (!path.EndsWith("/")) path += '/';
 | 
			
		||||
 | 
			
		||||
          foreach (ZipEntry entry in archive)
 | 
			
		||||
          {
 | 
			
		||||
            string name = entry.FileName;                     
 | 
			
		||||
            if (name.ToLower().StartsWith(path.ToLower()))
 | 
			
		||||
            {
 | 
			
		||||
              int i = name.IndexOf("/", path.Length);
 | 
			
		||||
              string item = name.Substring(path.Length, i - path.Length) + "\\";
 | 
			
		||||
              if (!dirs.Contains(item))
 | 
			
		||||
              {
 | 
			
		||||
                dirs.Add(item);
 | 
			
		||||
              }  
 | 
			
		||||
            }            
 | 
			
		||||
          }
 | 
			
		||||
          return dirs.ToArray();
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
          return GetAssetNames();
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
      else if (Directory.Exists(path))
 | 
			
		||||
      {
 | 
			
		||||
        string[] dirs = Directory.GetDirectories(path);
 | 
			
		||||
        
 | 
			
		||||
        for (int i = 0; i < dirs.Length; i++)
 | 
			
		||||
        {
 | 
			
		||||
          string[] parts = dirs[i].Split('\\');
 | 
			
		||||
          dirs[i] = parts[parts.Length - 1] + '\\';
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        return dirs;
 | 
			
		||||
      }
 | 
			
		||||
      else return null;
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
  #endregion  
 | 
			
		||||
  
 | 
			
		||||
}
 | 
			
		||||
@@ -1,306 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: Bevel.cs                                     //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
using Microsoft.Xna.Framework;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
using Microsoft.Xna.Framework.Graphics;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{ 
 | 
			
		||||
 | 
			
		||||
  #region //// Enums /////////////
 | 
			
		||||
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////                 
 | 
			
		||||
  public enum BevelStyle
 | 
			
		||||
  {
 | 
			
		||||
    None,
 | 
			
		||||
    Flat,
 | 
			
		||||
    Etched,
 | 
			
		||||
    Bumped,
 | 
			
		||||
    Lowered,
 | 
			
		||||
    Raised
 | 
			
		||||
  }
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////  
 | 
			
		||||
  public enum BevelBorder
 | 
			
		||||
  {
 | 
			
		||||
    None,
 | 
			
		||||
    Left,
 | 
			
		||||
    Top,
 | 
			
		||||
    Right,
 | 
			
		||||
    Bottom,
 | 
			
		||||
    All
 | 
			
		||||
  }
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////  
 | 
			
		||||
 | 
			
		||||
  #endregion
 | 
			
		||||
 | 
			
		||||
  public class Bevel: Control
 | 
			
		||||
  {
 | 
			
		||||
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                 
 | 
			
		||||
    private BevelBorder border = BevelBorder.All;
 | 
			
		||||
    private BevelStyle style = BevelStyle.Etched;   
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Properties ////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public BevelBorder Border
 | 
			
		||||
    {
 | 
			
		||||
      get { return border; }
 | 
			
		||||
      set 
 | 
			
		||||
      { 
 | 
			
		||||
        if (border != value)
 | 
			
		||||
        {
 | 
			
		||||
          border = value;
 | 
			
		||||
          if (!Suspended) OnBorderChanged(new EventArgs());
 | 
			
		||||
        }  
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////        
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public BevelStyle Style
 | 
			
		||||
    {
 | 
			
		||||
      get { return style; }
 | 
			
		||||
      set
 | 
			
		||||
      { 
 | 
			
		||||
        if (style != value)
 | 
			
		||||
        {
 | 
			
		||||
          style = value;
 | 
			
		||||
          if (!Suspended) OnStyleChanged(new EventArgs());
 | 
			
		||||
        }          
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Events ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                 
 | 
			
		||||
    public event EventHandler BorderChanged;
 | 
			
		||||
    public event EventHandler StyleChanged;
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Construstors //////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////       
 | 
			
		||||
    public Bevel(Manager manager): base(manager)
 | 
			
		||||
    {            
 | 
			
		||||
      CanFocus = false;
 | 
			
		||||
      Passive = true;      
 | 
			
		||||
      Width = 64;
 | 
			
		||||
      Height = 64;
 | 
			
		||||
    }    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
    
 | 
			
		||||
    #region //// Methods ///////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public override void Init()
 | 
			
		||||
    {      
 | 
			
		||||
      base.Init();
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                                                        
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                                                        
 | 
			
		||||
    protected internal override void InitSkin()
 | 
			
		||||
    {
 | 
			
		||||
      base.InitSkin();      
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                                                        
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
 | 
			
		||||
    {   
 | 
			
		||||
      if (Border != BevelBorder.None && Style != BevelStyle.None)
 | 
			
		||||
      {           
 | 
			
		||||
        if (Border != BevelBorder.All)
 | 
			
		||||
        {
 | 
			
		||||
          DrawPart(renderer, rect, Border, Style, false);  
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
          DrawPart(renderer, rect, BevelBorder.Left, Style, true);
 | 
			
		||||
          DrawPart(renderer, rect, BevelBorder.Top, Style, true);
 | 
			
		||||
          DrawPart(renderer, rect, BevelBorder.Right, Style, true);
 | 
			
		||||
          DrawPart(renderer, rect, BevelBorder.Bottom, Style, true);
 | 
			
		||||
        }  
 | 
			
		||||
      }  
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    private void DrawPart(Renderer renderer, Rectangle rect, BevelBorder pos, BevelStyle style, bool all)
 | 
			
		||||
    {                  
 | 
			
		||||
      SkinLayer layer = Skin.Layers["Control"];   
 | 
			
		||||
      Color c1 = Utilities.ParseColor(layer.Attributes["LightColor"].Value);
 | 
			
		||||
      Color c2 = Utilities.ParseColor(layer.Attributes["DarkColor"].Value);
 | 
			
		||||
      Color c3 = Utilities.ParseColor(layer.Attributes["FlatColor"].Value); 
 | 
			
		||||
      
 | 
			
		||||
      if (Color != UndefinedColor) c3 = Color;
 | 
			
		||||
      
 | 
			
		||||
      Texture2D img = Skin.Layers["Control"].Image.Resource;
 | 
			
		||||
 | 
			
		||||
      int x1 = 0; int y1 = 0; int w1 = 0; int h1 = 0;
 | 
			
		||||
      int x2 = 0; int y2 = 0; int w2 = 0; int h2 = 0;
 | 
			
		||||
            
 | 
			
		||||
      if (style == BevelStyle.Bumped || style == BevelStyle.Etched)     
 | 
			
		||||
      {        
 | 
			
		||||
        if (all && (pos == BevelBorder.Top || pos == BevelBorder.Bottom))
 | 
			
		||||
        {
 | 
			
		||||
          rect = new Rectangle(rect.Left + 1, rect.Top, rect.Width - 2, rect.Height);
 | 
			
		||||
        }
 | 
			
		||||
        else if (all && (pos == BevelBorder.Left))
 | 
			
		||||
        {
 | 
			
		||||
          rect = new Rectangle(rect.Left, rect.Top, rect.Width, rect.Height - 1);
 | 
			
		||||
        }
 | 
			
		||||
        switch (pos)
 | 
			
		||||
        {
 | 
			
		||||
          case BevelBorder.Left:
 | 
			
		||||
          {
 | 
			
		||||
            x1 = rect.Left; y1 = rect.Top; w1 = 1; h1 = rect.Height;
 | 
			
		||||
            x2 = x1 + 1; y2 = y1; w2 = w1; h2 = h1;
 | 
			
		||||
            break;
 | 
			
		||||
          }
 | 
			
		||||
          case BevelBorder.Top:
 | 
			
		||||
          {
 | 
			
		||||
            x1 = rect.Left; y1 = rect.Top; w1 = rect.Width; h1 = 1;
 | 
			
		||||
            x2 = x1; y2 = y1 + 1; w2 = w1; h2 = h1;
 | 
			
		||||
            break;
 | 
			
		||||
          }
 | 
			
		||||
          case BevelBorder.Right:
 | 
			
		||||
          {
 | 
			
		||||
            x1 = rect.Left + rect.Width - 2; y1 = rect.Top; w1 = 1; h1 = rect.Height;
 | 
			
		||||
            x2 = x1 + 1; y2 = y1; w2 = w1; h2 = h1;
 | 
			
		||||
            break;
 | 
			
		||||
          }
 | 
			
		||||
          case BevelBorder.Bottom:
 | 
			
		||||
          {
 | 
			
		||||
            x1 = rect.Left; y1 = rect.Top + rect.Height - 2; w1 = rect.Width; h1 = 1;
 | 
			
		||||
            x2 = x1; y2 = y1 + 1; w2 = w1; h2 = h1;
 | 
			
		||||
            break;
 | 
			
		||||
          }
 | 
			
		||||
        }                                             
 | 
			
		||||
      }
 | 
			
		||||
      else
 | 
			
		||||
      {
 | 
			
		||||
        switch (pos)
 | 
			
		||||
        {
 | 
			
		||||
          case BevelBorder.Left:
 | 
			
		||||
          {
 | 
			
		||||
            x1 = rect.Left; y1 = rect.Top; w1 = 1; h1 = rect.Height;            
 | 
			
		||||
            break;
 | 
			
		||||
          }
 | 
			
		||||
          case BevelBorder.Top:
 | 
			
		||||
          {
 | 
			
		||||
            x1 = rect.Left; y1 = rect.Top; w1 = rect.Width; h1 = 1;            
 | 
			
		||||
            break;
 | 
			
		||||
          }
 | 
			
		||||
          case BevelBorder.Right:
 | 
			
		||||
          {
 | 
			
		||||
            x1 = rect.Left + rect.Width - 1; y1 = rect.Top; w1 = 1; h1 = rect.Height;            
 | 
			
		||||
            break;
 | 
			
		||||
          }
 | 
			
		||||
          case BevelBorder.Bottom:
 | 
			
		||||
          {
 | 
			
		||||
            x1 = rect.Left; y1 = rect.Top + rect.Height - 1; w1 = rect.Width; h1 = 1;            
 | 
			
		||||
            break;
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      } 
 | 
			
		||||
                            
 | 
			
		||||
      switch (Style)
 | 
			
		||||
      {
 | 
			
		||||
        case BevelStyle.Bumped:
 | 
			
		||||
        {
 | 
			
		||||
          renderer.Draw(img, new Rectangle(x1, y1, w1, h1), c1);
 | 
			
		||||
          renderer.Draw(img, new Rectangle(x2, y2, w2, h2), c2);          
 | 
			
		||||
          break;
 | 
			
		||||
        }
 | 
			
		||||
        case BevelStyle.Etched:
 | 
			
		||||
        {
 | 
			
		||||
          renderer.Draw(img, new Rectangle(x1, y1, w1, h1), c2);
 | 
			
		||||
          renderer.Draw(img, new Rectangle(x2, y2, w2, h2), c1);          
 | 
			
		||||
          break;
 | 
			
		||||
        }
 | 
			
		||||
        case BevelStyle.Raised:
 | 
			
		||||
        {
 | 
			
		||||
          Color c = c1;
 | 
			
		||||
          if (pos == BevelBorder.Left || pos == BevelBorder.Top) c = c1;
 | 
			
		||||
          else c = c2;          
 | 
			
		||||
          
 | 
			
		||||
          renderer.Draw(img, new Rectangle(x1, y1, w1, h1), c);     
 | 
			
		||||
          break;
 | 
			
		||||
        }
 | 
			
		||||
        case BevelStyle.Lowered:
 | 
			
		||||
        {
 | 
			
		||||
          Color c = c1;
 | 
			
		||||
          if (pos == BevelBorder.Left || pos == BevelBorder.Top) c = c2;
 | 
			
		||||
          else c = c1; 
 | 
			
		||||
          
 | 
			
		||||
          renderer.Draw(img, new Rectangle(x1, y1, w1, h1), c);     
 | 
			
		||||
          break;
 | 
			
		||||
        }
 | 
			
		||||
        default:
 | 
			
		||||
        {
 | 
			
		||||
          renderer.Draw(img, new Rectangle(x1, y1, w1, h1), c3);     
 | 
			
		||||
          break;
 | 
			
		||||
        }
 | 
			
		||||
      }  
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////          
 | 
			
		||||
    protected virtual void OnBorderChanged(EventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      if (BorderChanged != null) BorderChanged.Invoke(this, e);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////          
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////          
 | 
			
		||||
    protected virtual void OnStyleChanged(EventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      if (StyleChanged != null) StyleChanged.Invoke(this, e);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////          
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    #endregion  
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,294 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: Button.cs                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
using Microsoft.Xna.Framework;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
using Microsoft.Xna.Framework.Graphics;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{ 
 | 
			
		||||
  
 | 
			
		||||
  #region //// Enums /////////////
 | 
			
		||||
  
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////              
 | 
			
		||||
  ///  <include file='Documents/Button.xml' path='Button/Class[@name="SizeMode"]/*' />
 | 
			
		||||
  public enum SizeMode
 | 
			
		||||
  {
 | 
			
		||||
    Normal, 
 | 
			
		||||
    Auto,
 | 
			
		||||
    Centered,
 | 
			
		||||
    Stretched,
 | 
			
		||||
      /// <summary>
 | 
			
		||||
      /// Only Supported by ImageBox
 | 
			
		||||
      /// </summary>
 | 
			
		||||
    Tiled
 | 
			
		||||
  }  
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////              
 | 
			
		||||
  ///  <include file='Documents/Button.xml' path='Button/Class[@name="SizeMode"]/*' />
 | 
			
		||||
  public enum ButtonMode
 | 
			
		||||
  {
 | 
			
		||||
    Normal,
 | 
			
		||||
    PushButton
 | 
			
		||||
  }
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  #endregion
 | 
			
		||||
 | 
			
		||||
  #region //// Classes ///////////
 | 
			
		||||
  
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////              
 | 
			
		||||
  ///  <include file='Documents/Button.xml' path='Button/Class[@name="Glyph"]/*' />          
 | 
			
		||||
  public class Glyph
 | 
			
		||||
  {
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////  
 | 
			
		||||
    public Texture2D Image = null;
 | 
			
		||||
    public SizeMode SizeMode = SizeMode.Stretched;
 | 
			
		||||
    public Color Color = Color.White;
 | 
			
		||||
    public Point Offset = Point.Zero;  
 | 
			
		||||
    public Rectangle SourceRect = Rectangle.Empty;
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////  
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////  
 | 
			
		||||
    public Glyph(Texture2D image)
 | 
			
		||||
    {
 | 
			
		||||
      Image = image;
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////  
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////  
 | 
			
		||||
    public Glyph(Texture2D image, Rectangle sourceRect): this(image)
 | 
			
		||||
    {      
 | 
			
		||||
      SourceRect = sourceRect;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////  
 | 
			
		||||
    
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////  
 | 
			
		||||
  ///  <include file='Documents/Button.xml' path='Button/Class[@name="Button"]/*' />          
 | 
			
		||||
  public class Button: ButtonBase
 | 
			
		||||
  {
 | 
			
		||||
 | 
			
		||||
    #region //// Consts ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    private const string skButton = "Button";
 | 
			
		||||
    private const string lrButton = "Control";
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////              
 | 
			
		||||
    private Glyph glyph = null;
 | 
			
		||||
    private ModalResult modalResult = ModalResult.None;
 | 
			
		||||
    private ButtonMode mode = ButtonMode.Normal;
 | 
			
		||||
    private bool pushed = false;    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Properties ////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////        
 | 
			
		||||
    public Glyph Glyph
 | 
			
		||||
    {
 | 
			
		||||
      get { return glyph; }
 | 
			
		||||
      set 
 | 
			
		||||
      { 
 | 
			
		||||
        glyph = value;
 | 
			
		||||
        if (!Suspended) OnGlyphChanged(new EventArgs());        
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public ModalResult ModalResult
 | 
			
		||||
    {
 | 
			
		||||
      get { return modalResult; }
 | 
			
		||||
      set { modalResult = value; }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public ButtonMode Mode
 | 
			
		||||
    {
 | 
			
		||||
      get { return mode; }
 | 
			
		||||
      set { mode = value; }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public bool Pushed
 | 
			
		||||
    {
 | 
			
		||||
      get { return pushed; }
 | 
			
		||||
      set 
 | 
			
		||||
      { 
 | 
			
		||||
        pushed = value; 
 | 
			
		||||
        Invalidate();
 | 
			
		||||
      }      
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Events ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                 
 | 
			
		||||
    public event EventHandler GlyphChanged;
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Construstors //////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////       
 | 
			
		||||
    public Button(Manager manager): base(manager)
 | 
			
		||||
    {            
 | 
			
		||||
      SetDefaultSize(72, 24);      
 | 
			
		||||
    }    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Destructors ///////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected override void Dispose(bool disposing)
 | 
			
		||||
    {
 | 
			
		||||
      if (disposing)
 | 
			
		||||
      {
 | 
			
		||||
      }
 | 
			
		||||
      base.Dispose(disposing);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
    
 | 
			
		||||
    #region //// Methods ///////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public override void Init()
 | 
			
		||||
    {      
 | 
			
		||||
      base.Init();        
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected internal override void InitSkin()
 | 
			
		||||
    {
 | 
			
		||||
      base.InitSkin();
 | 
			
		||||
      Skin = new SkinControl(Manager.Skin.Controls[skButton]);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
 | 
			
		||||
    {                    
 | 
			
		||||
 | 
			
		||||
      if (mode == ButtonMode.PushButton && pushed)
 | 
			
		||||
      {
 | 
			
		||||
        SkinLayer l = Skin.Layers[lrButton];
 | 
			
		||||
        renderer.DrawLayer(l, rect, l.States.Pressed.Color, l.States.Pressed.Index);
 | 
			
		||||
        if (l.States.Pressed.Overlay)
 | 
			
		||||
        {
 | 
			
		||||
          renderer.DrawLayer(l, rect, l.Overlays.Pressed.Color, l.Overlays.Pressed.Index);          
 | 
			
		||||
        }                
 | 
			
		||||
      }
 | 
			
		||||
      else
 | 
			
		||||
      {
 | 
			
		||||
        base.DrawControl(renderer, rect, gameTime);
 | 
			
		||||
      }
 | 
			
		||||
    
 | 
			
		||||
      SkinLayer layer = Skin.Layers[lrButton];                                  
 | 
			
		||||
      SpriteFont font = (layer.Text != null && layer.Text.Font != null) ? layer.Text.Font.Resource : null;
 | 
			
		||||
      Color col = Color.White;              
 | 
			
		||||
      int ox = 0; int oy = 0;
 | 
			
		||||
    
 | 
			
		||||
      if (ControlState == ControlState.Pressed)
 | 
			
		||||
      {       
 | 
			
		||||
        if (layer.Text != null) col = layer.Text.Colors.Pressed;
 | 
			
		||||
        ox = 1; oy = 1;
 | 
			
		||||
      }                               
 | 
			
		||||
      if (glyph != null)
 | 
			
		||||
      {
 | 
			
		||||
        Margins cont = layer.ContentMargins;
 | 
			
		||||
        Rectangle r = new Rectangle(rect.Left + cont.Left, 
 | 
			
		||||
                                    rect.Top + cont.Top, 
 | 
			
		||||
                                    rect.Width - cont.Horizontal, 
 | 
			
		||||
                                    rect.Height - cont.Vertical);
 | 
			
		||||
        renderer.DrawGlyph(glyph, r);
 | 
			
		||||
      }
 | 
			
		||||
      else 
 | 
			
		||||
      {
 | 
			
		||||
        renderer.DrawString(this, layer, Text, rect, true, ox, oy);
 | 
			
		||||
      }       
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    private void OnGlyphChanged(EventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      if (GlyphChanged != null) GlyphChanged.Invoke(this, e);
 | 
			
		||||
    }
 | 
			
		||||
    //////////////////////////////////////////////////////////////////////////// 
 | 
			
		||||
 | 
			
		||||
    //////////////////////////////////////////////////////////////////////////// 
 | 
			
		||||
    protected override void OnClick(EventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      MouseEventArgs ex = (e is MouseEventArgs) ? (MouseEventArgs)e : new MouseEventArgs();      
 | 
			
		||||
      
 | 
			
		||||
      if (ex.Button == MouseButton.Left || ex.Button == MouseButton.None)
 | 
			
		||||
      {
 | 
			
		||||
        pushed = !pushed;
 | 
			
		||||
      }  
 | 
			
		||||
      
 | 
			
		||||
      base.OnClick(e);           
 | 
			
		||||
      
 | 
			
		||||
      if ((ex.Button == MouseButton.Left || ex.Button == MouseButton.None) && Root != null)
 | 
			
		||||
      {
 | 
			
		||||
        if (Root is Window)
 | 
			
		||||
        {
 | 
			
		||||
          Window wnd = (Window)Root;
 | 
			
		||||
          if (ModalResult != ModalResult.None)
 | 
			
		||||
          {            
 | 
			
		||||
            wnd.Close(ModalResult);
 | 
			
		||||
          }
 | 
			
		||||
        }        
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
  
 | 
			
		||||
    #endregion  
 | 
			
		||||
     
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  #endregion
 | 
			
		||||
  
 | 
			
		||||
}
 | 
			
		||||
@@ -1,117 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: ButtonBase.cs                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
  #region //// Classes ///////////
 | 
			
		||||
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
  ///  <include file='Documents/ButtonBase.xml' path='ButtonBase/Class[@name="ButtonBase"]/*' />          
 | 
			
		||||
  public abstract class ButtonBase: Control
 | 
			
		||||
  {
 | 
			
		||||
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                  
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Properties ////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
    public override ControlState ControlState
 | 
			
		||||
    {
 | 
			
		||||
      get
 | 
			
		||||
      {
 | 
			
		||||
        if (DesignMode) return ControlState.Enabled;
 | 
			
		||||
        else if (Suspended) return ControlState.Disabled;
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
          if (!Enabled) return ControlState.Disabled;
 | 
			
		||||
 | 
			
		||||
          if ((Pressed[(int)MouseButton.Left] && Inside) || (Focused && (Pressed[(int)GamePadActions.Press] || Pressed[(int)MouseButton.None]))) return ControlState.Pressed;
 | 
			
		||||
          else if (Hovered && Inside) return ControlState.Hovered;
 | 
			
		||||
          else if ((Focused && !Inside) || (Hovered && !Inside) || (Focused && !Hovered && Inside)) return ControlState.Focused;
 | 
			
		||||
          else return ControlState.Enabled;
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Events ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Construstors //////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////       
 | 
			
		||||
    protected ButtonBase(Manager manager)
 | 
			
		||||
      : base(manager)
 | 
			
		||||
    {
 | 
			
		||||
      SetDefaultSize(72, 24);
 | 
			
		||||
      DoubleClicks = false;
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Methods ///////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public override void Init()
 | 
			
		||||
    {
 | 
			
		||||
      base.Init();
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                                 
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected override void OnClick(EventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      MouseEventArgs ex = (e is MouseEventArgs) ? (MouseEventArgs)e : new MouseEventArgs();      
 | 
			
		||||
      if (ex.Button == MouseButton.Left || ex.Button == MouseButton.None)
 | 
			
		||||
      {
 | 
			
		||||
        base.OnClick(e);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
  #endregion
 | 
			
		||||
  
 | 
			
		||||
}
 | 
			
		||||
@@ -1,158 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: CheckBox.cs                                  //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
using Microsoft.Xna.Framework;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{ 
 | 
			
		||||
 | 
			
		||||
  public class CheckBox: ButtonBase
 | 
			
		||||
  {
 | 
			
		||||
 | 
			
		||||
    #region //// Consts ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    private const string skCheckBox = "CheckBox";
 | 
			
		||||
    private const string lrCheckBox = "Control";
 | 
			
		||||
    private const string lrChecked  = "Checked";   
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////               
 | 
			
		||||
    private bool state = false;
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Properties ////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public virtual bool Checked 
 | 
			
		||||
    { 
 | 
			
		||||
      get 
 | 
			
		||||
      { 
 | 
			
		||||
        return state; 
 | 
			
		||||
      } 
 | 
			
		||||
      set 
 | 
			
		||||
      { 
 | 
			
		||||
        state = value; 
 | 
			
		||||
        Invalidate();
 | 
			
		||||
        if (!Suspended) OnCheckedChanged(new EventArgs());
 | 
			
		||||
      } 
 | 
			
		||||
    }   
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
    
 | 
			
		||||
    #region //// Events ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                     
 | 
			
		||||
    public event EventHandler CheckedChanged;
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Construstors //////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////       
 | 
			
		||||
    public CheckBox(Manager manager): base(manager)
 | 
			
		||||
    {
 | 
			
		||||
      CheckLayer(Skin, lrChecked);      
 | 
			
		||||
 | 
			
		||||
      Width = 64;
 | 
			
		||||
      Height = 16;           
 | 
			
		||||
    }    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
    
 | 
			
		||||
    #region //// Methods ///////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public override void Init()
 | 
			
		||||
    {      
 | 
			
		||||
      base.Init();  
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected internal override void InitSkin()
 | 
			
		||||
    {
 | 
			
		||||
      base.InitSkin();
 | 
			
		||||
      Skin = new SkinControl(Manager.Skin.Controls[skCheckBox]);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
 | 
			
		||||
    {      
 | 
			
		||||
      SkinLayer layer = Skin.Layers[lrChecked];
 | 
			
		||||
      SkinText font = Skin.Layers[lrChecked].Text;      
 | 
			
		||||
      
 | 
			
		||||
      if (!state)
 | 
			
		||||
      {
 | 
			
		||||
        layer = Skin.Layers[lrCheckBox];
 | 
			
		||||
        font = Skin.Layers[lrCheckBox].Text;      
 | 
			
		||||
      }
 | 
			
		||||
            
 | 
			
		||||
      rect.Width = layer.Width;
 | 
			
		||||
      rect.Height = layer.Height;      
 | 
			
		||||
      Rectangle rc = new Rectangle(rect.Left + rect.Width + 4, rect.Y,  Width - (layer.Width + 4), rect.Height);
 | 
			
		||||
      
 | 
			
		||||
      renderer.DrawLayer(this, layer, rect);            
 | 
			
		||||
      renderer.DrawString(this, layer, Text, rc, false, 0, 0);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    protected override void OnClick(EventArgs e)    
 | 
			
		||||
    {
 | 
			
		||||
      MouseEventArgs ex = (e is MouseEventArgs) ? (MouseEventArgs)e : new MouseEventArgs();      
 | 
			
		||||
      
 | 
			
		||||
      if (ex.Button == MouseButton.Left || ex.Button == MouseButton.None)      
 | 
			
		||||
      {        
 | 
			
		||||
        Checked = !Checked;
 | 
			
		||||
      }  
 | 
			
		||||
      base.OnClick(e);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    protected virtual void OnCheckedChanged(EventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      if (CheckedChanged != null) CheckedChanged.Invoke(this, e);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    #endregion  
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,65 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: ClipBox.cs                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
using Microsoft.Xna.Framework;
 | 
			
		||||
using Microsoft.Xna.Framework.Graphics;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{
 | 
			
		||||
  
 | 
			
		||||
  public class ClipBox: Control
 | 
			
		||||
  {    
 | 
			
		||||
  
 | 
			
		||||
    #region //// Constructors //////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public ClipBox(Manager manager): base(manager)
 | 
			
		||||
    {            
 | 
			
		||||
      Color =  Color.Transparent;
 | 
			
		||||
      BackColor = Color.Transparent;
 | 
			
		||||
      CanFocus = false;
 | 
			
		||||
      Passive = true;      
 | 
			
		||||
    } 
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
		#region //// Methods ///////////
 | 
			
		||||
			
 | 
			
		||||
		////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
		protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
 | 
			
		||||
    {            
 | 
			
		||||
      base.DrawControl(renderer, rect, gameTime);
 | 
			
		||||
    }
 | 
			
		||||
		////////////////////////////////////////////////////////////////////////////   		
 | 
			
		||||
    
 | 
			
		||||
		#endregion  
 | 
			
		||||
		
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
}
 | 
			
		||||
@@ -1,181 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: Control.cs                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
using Microsoft.Xna.Framework;
 | 
			
		||||
using Microsoft.Xna.Framework.Graphics;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{     
 | 
			
		||||
      
 | 
			
		||||
  public class ClipControl: Control
 | 
			
		||||
  {
 | 
			
		||||
   
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
    private ClipBox clientArea;  
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion   
 | 
			
		||||
 | 
			
		||||
    #region //// Properties ////////
 | 
			
		||||
   
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
    public virtual ClipBox ClientArea
 | 
			
		||||
    {
 | 
			
		||||
      get { return clientArea; }
 | 
			
		||||
      set { clientArea = value; }
 | 
			
		||||
    }   
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////          
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public override Margins ClientMargins
 | 
			
		||||
    {
 | 
			
		||||
      get
 | 
			
		||||
      {
 | 
			
		||||
        return base.ClientMargins;
 | 
			
		||||
      }
 | 
			
		||||
      set
 | 
			
		||||
      {
 | 
			
		||||
        base.ClientMargins = value;
 | 
			
		||||
        if (clientArea != null)
 | 
			
		||||
        {
 | 
			
		||||
          clientArea.Left = ClientLeft;
 | 
			
		||||
          clientArea.Top = ClientTop;
 | 
			
		||||
          clientArea.Width = ClientWidth;
 | 
			
		||||
          clientArea.Height = ClientHeight;        
 | 
			
		||||
        }  
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        
 | 
			
		||||
    #endregion
 | 
			
		||||
    
 | 
			
		||||
 	  #region //// Constructors //////
 | 
			
		||||
	 		
 | 
			
		||||
	  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
		public ClipControl(Manager manager): base(manager)
 | 
			
		||||
    {                              
 | 
			
		||||
      clientArea = new ClipBox(manager);      
 | 
			
		||||
      
 | 
			
		||||
      clientArea.Init();
 | 
			
		||||
      clientArea.MinimumWidth = 0;
 | 
			
		||||
      clientArea.MinimumHeight = 0;
 | 
			
		||||
      clientArea.Left = ClientLeft;
 | 
			
		||||
      clientArea.Top = ClientTop;
 | 
			
		||||
      clientArea.Width = ClientWidth;
 | 
			
		||||
      clientArea.Height = ClientHeight;
 | 
			
		||||
                
 | 
			
		||||
      base.Add(clientArea);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////       
 | 
			
		||||
       
 | 
			
		||||
  	#endregion   
 | 
			
		||||
 | 
			
		||||
    #region //// Methods ///////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public override void Init()
 | 
			
		||||
    {      
 | 
			
		||||
      base.Init();
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////        
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected internal override void InitSkin()
 | 
			
		||||
    {
 | 
			
		||||
      base.InitSkin();           
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public virtual void Add(Control control, bool client)
 | 
			
		||||
    {
 | 
			
		||||
      if (client)
 | 
			
		||||
      {
 | 
			
		||||
        clientArea.Add(control);        
 | 
			
		||||
      }
 | 
			
		||||
      else
 | 
			
		||||
      {
 | 
			
		||||
        base.Add(control);
 | 
			
		||||
      }                  
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////           
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public override void Add(Control control)
 | 
			
		||||
    {
 | 
			
		||||
      Add(control, true);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////       
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////       
 | 
			
		||||
    public override void Remove(Control control)
 | 
			
		||||
    {
 | 
			
		||||
      base.Remove(control);
 | 
			
		||||
      clientArea.Remove(control);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected internal override void Update(GameTime gameTime)
 | 
			
		||||
    {      
 | 
			
		||||
      base.Update(gameTime);               
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
 | 
			
		||||
    {      
 | 
			
		||||
      base.DrawControl(renderer, rect, gameTime);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////  
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////  
 | 
			
		||||
    protected override void OnResize(ResizeEventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      base.OnResize(e);
 | 
			
		||||
      
 | 
			
		||||
      if (clientArea != null)
 | 
			
		||||
      {      
 | 
			
		||||
        clientArea.Left = ClientLeft;
 | 
			
		||||
        clientArea.Top = ClientTop;
 | 
			
		||||
        clientArea.Width = ClientWidth;
 | 
			
		||||
        clientArea.Height = ClientHeight;
 | 
			
		||||
      }  
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////             
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////  
 | 
			
		||||
    protected virtual void AdjustMargins()
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
                         
 | 
			
		||||
    #endregion
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,418 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: ComboBox.cs                                  //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
using Microsoft.Xna.Framework;
 | 
			
		||||
using Microsoft.Xna.Framework.Input;
 | 
			
		||||
using System;
 | 
			
		||||
using Microsoft.Xna.Framework.Graphics;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
  public class ComboBox: TextBox
 | 
			
		||||
  {
 | 
			
		||||
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                     
 | 
			
		||||
    private Button btnDown = null;    
 | 
			
		||||
    private List<object> items = new List<object>();
 | 
			
		||||
    private ListBox lstCombo = null;    
 | 
			
		||||
    private int maxItems = 5;
 | 
			
		||||
    private bool drawSelection = true;  
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Properties ////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public override bool ReadOnly
 | 
			
		||||
    {
 | 
			
		||||
      get { return base.ReadOnly; }
 | 
			
		||||
      set
 | 
			
		||||
      {
 | 
			
		||||
        base.ReadOnly = value;
 | 
			
		||||
        CaretVisible = !value;
 | 
			
		||||
        if (value)
 | 
			
		||||
        {
 | 
			
		||||
          #if (!XBOX && !XBOX_FAKE)
 | 
			
		||||
            Cursor = Manager.Skin.Cursors["Default"].Resource;
 | 
			
		||||
          #endif 
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
          #if (!XBOX && !XBOX_FAKE)
 | 
			
		||||
            Cursor = Manager.Skin.Cursors["Text"].Resource;
 | 
			
		||||
          #endif         
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public bool DrawSelection
 | 
			
		||||
    {
 | 
			
		||||
      get { return drawSelection; }
 | 
			
		||||
      set { drawSelection = value; }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public override string Text
 | 
			
		||||
    {
 | 
			
		||||
        get
 | 
			
		||||
        {
 | 
			
		||||
            return base.Text;
 | 
			
		||||
        }
 | 
			
		||||
        set
 | 
			
		||||
        {
 | 
			
		||||
            base.Text = value;
 | 
			
		||||
            //if (!items.Contains(value))  --- bug
 | 
			
		||||
            if (!items.ConvertAll(item => item.ToString()).Contains(value))
 | 
			
		||||
            {
 | 
			
		||||
                ItemIndex = -1;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public virtual List<object> Items
 | 
			
		||||
    {
 | 
			
		||||
      get { return items; }      
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public int MaxItems
 | 
			
		||||
    {
 | 
			
		||||
      get { return maxItems; }
 | 
			
		||||
      set 
 | 
			
		||||
      { 
 | 
			
		||||
        if (maxItems != value)
 | 
			
		||||
        {
 | 
			
		||||
          maxItems = value; 
 | 
			
		||||
          if (!Suspended) OnMaxItemsChanged(new EventArgs());
 | 
			
		||||
        }  
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public int ItemIndex
 | 
			
		||||
    {
 | 
			
		||||
      get { return lstCombo.ItemIndex; }
 | 
			
		||||
      set 
 | 
			
		||||
      { 
 | 
			
		||||
        if (lstCombo != null)
 | 
			
		||||
        {
 | 
			
		||||
          if (value >= 0 && value < items.Count)
 | 
			
		||||
          {
 | 
			
		||||
            lstCombo.ItemIndex = value; 
 | 
			
		||||
            Text = lstCombo.Items[value].ToString();
 | 
			
		||||
          }
 | 
			
		||||
          else
 | 
			
		||||
          {
 | 
			
		||||
            lstCombo.ItemIndex = -1;          
 | 
			
		||||
          }
 | 
			
		||||
        }  
 | 
			
		||||
        if (!Suspended) OnItemIndexChanged(new EventArgs());
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Events ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                 
 | 
			
		||||
    public event EventHandler MaxItemsChanged;    
 | 
			
		||||
    public event EventHandler ItemIndexChanged;    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Construstors //////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////       
 | 
			
		||||
    public ComboBox(Manager manager): base(manager)
 | 
			
		||||
    {
 | 
			
		||||
      Height = 20;
 | 
			
		||||
      Width = 64;
 | 
			
		||||
      ReadOnly = true;      
 | 
			
		||||
            
 | 
			
		||||
      btnDown = new Button(Manager);
 | 
			
		||||
      btnDown.Init();
 | 
			
		||||
      btnDown.Skin = new SkinControl(Manager.Skin.Controls["ComboBox.Button"]);
 | 
			
		||||
      btnDown.CanFocus = false;      
 | 
			
		||||
      btnDown.Click += new EventHandler(btnDown_Click);      
 | 
			
		||||
      Add(btnDown, false);            
 | 
			
		||||
 | 
			
		||||
      lstCombo = new ListBox(Manager);
 | 
			
		||||
      lstCombo.Init();
 | 
			
		||||
      lstCombo.HotTrack = true;      
 | 
			
		||||
      lstCombo.Detached = true;
 | 
			
		||||
      lstCombo.Visible = false;      
 | 
			
		||||
      lstCombo.Click += new EventHandler(lstCombo_Click);
 | 
			
		||||
      lstCombo.FocusLost += new EventHandler(lstCombo_FocusLost);
 | 
			
		||||
      lstCombo.Items = items;      
 | 
			
		||||
      manager.Input.MouseDown += new MouseEventHandler(Input_MouseDown);      
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion            
 | 
			
		||||
       
 | 
			
		||||
    #region //// Destructors ///////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected override void Dispose(bool disposing)
 | 
			
		||||
    {
 | 
			
		||||
      if (disposing)
 | 
			
		||||
      {
 | 
			
		||||
        // We added the listbox to another parent than this control, so we dispose it manually
 | 
			
		||||
        if (lstCombo != null)
 | 
			
		||||
        {
 | 
			
		||||
          lstCombo.Dispose();
 | 
			
		||||
          lstCombo = null;
 | 
			
		||||
        }
 | 
			
		||||
        Manager.Input.MouseDown -= Input_MouseDown;
 | 
			
		||||
      }
 | 
			
		||||
      base.Dispose(disposing);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion   
 | 
			
		||||
 | 
			
		||||
    #region //// Methods ///////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public override void Init()
 | 
			
		||||
    {
 | 
			
		||||
      base.Init();      
 | 
			
		||||
 | 
			
		||||
      lstCombo.Skin = new SkinControl(Manager.Skin.Controls["ComboBox.ListBox"]);      
 | 
			
		||||
 | 
			
		||||
      btnDown.Glyph = new Glyph(Manager.Skin.Images["Shared.ArrowDown"].Resource);
 | 
			
		||||
      btnDown.Glyph.Color = Manager.Skin.Controls["ComboBox.Button"].Layers["Control"].Text.Colors.Enabled;
 | 
			
		||||
      btnDown.Glyph.SizeMode = SizeMode.Centered;            
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                          
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                          
 | 
			
		||||
    protected internal override void InitSkin()
 | 
			
		||||
    {
 | 
			
		||||
      base.InitSkin();
 | 
			
		||||
      Skin = new SkinControl(Manager.Skin.Controls["ComboBox"]);
 | 
			
		||||
      AdjustMargins();
 | 
			
		||||
      ReadOnly = ReadOnly; // To init the right cursor
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                          
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
 | 
			
		||||
    {
 | 
			
		||||
      base.DrawControl(renderer, rect, gameTime);      
 | 
			
		||||
      
 | 
			
		||||
      if (ReadOnly && (Focused || lstCombo.Focused) && drawSelection)
 | 
			
		||||
      {
 | 
			
		||||
        SkinLayer lr = Skin.Layers[0];
 | 
			
		||||
        Rectangle rc = new Rectangle(rect.Left + lr.ContentMargins.Left, 
 | 
			
		||||
                                     rect.Top + lr.ContentMargins.Top, 
 | 
			
		||||
                                     Width - lr.ContentMargins.Horizontal - btnDown.Width,
 | 
			
		||||
                                     Height - lr.ContentMargins.Vertical);
 | 
			
		||||
        renderer.Draw(Manager.Skin.Images["ListBox.Selection"].Resource, rc , Color.FromNonPremultiplied(255, 255, 255, 128));
 | 
			
		||||
      }  
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    protected override void OnResize(ResizeEventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      base.OnResize(e);
 | 
			
		||||
      
 | 
			
		||||
      if (btnDown != null)
 | 
			
		||||
      {
 | 
			
		||||
        btnDown.Width = 16;
 | 
			
		||||
        btnDown.Height = Height - Skin.Layers[0].ContentMargins.Vertical;
 | 
			
		||||
        btnDown.Top = Skin.Layers[0].ContentMargins.Top;
 | 
			
		||||
        btnDown.Left = Width - btnDown.Width - 2;                                
 | 
			
		||||
      }  
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    void btnDown_Click(object sender, EventArgs e)
 | 
			
		||||
    {          
 | 
			
		||||
      if (items != null && items.Count > 0)
 | 
			
		||||
      {        
 | 
			
		||||
        if (this.Root != null && this.Root is Container)
 | 
			
		||||
        {          
 | 
			
		||||
          (this.Root as Container).Add(lstCombo, false);
 | 
			
		||||
          lstCombo.Alpha = Root.Alpha;
 | 
			
		||||
          lstCombo.Left = AbsoluteLeft - Root.Left;
 | 
			
		||||
          lstCombo.Top = AbsoluteTop - Root.Top + Height + 1;
 | 
			
		||||
        }  
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
          Manager.Add(lstCombo);          
 | 
			
		||||
          lstCombo.Alpha = Alpha;
 | 
			
		||||
          lstCombo.Left = AbsoluteLeft;
 | 
			
		||||
          lstCombo.Top = AbsoluteTop + Height + 1;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        lstCombo.AutoHeight(maxItems);
 | 
			
		||||
        if (lstCombo.AbsoluteTop + lstCombo.Height > Manager.TargetHeight)
 | 
			
		||||
        {          
 | 
			
		||||
          lstCombo.Top = lstCombo.Top - Height - lstCombo.Height - 2;          
 | 
			
		||||
        }    
 | 
			
		||||
        
 | 
			
		||||
        lstCombo.Visible = !lstCombo.Visible;
 | 
			
		||||
        lstCombo.Focused = true;
 | 
			
		||||
        lstCombo.Width = Width;
 | 
			
		||||
        lstCombo.AutoHeight(maxItems);           
 | 
			
		||||
      }        
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    void Input_MouseDown(object sender, MouseEventArgs e)
 | 
			
		||||
    {    
 | 
			
		||||
      if (ReadOnly && 
 | 
			
		||||
          (e.Position.X >= AbsoluteLeft &&
 | 
			
		||||
           e.Position.X <= AbsoluteLeft + Width &&
 | 
			
		||||
           e.Position.Y >= AbsoluteTop &&
 | 
			
		||||
           e.Position.Y <= AbsoluteTop + Height)) return;
 | 
			
		||||
           
 | 
			
		||||
      if (lstCombo.Visible &&      
 | 
			
		||||
         (e.Position.X < lstCombo.AbsoluteLeft ||
 | 
			
		||||
          e.Position.X > lstCombo.AbsoluteLeft + lstCombo.Width ||
 | 
			
		||||
          e.Position.Y < lstCombo.AbsoluteTop ||
 | 
			
		||||
          e.Position.Y > lstCombo.AbsoluteTop + lstCombo.Height) &&         
 | 
			
		||||
         (e.Position.X < btnDown.AbsoluteLeft ||
 | 
			
		||||
          e.Position.X > btnDown.AbsoluteLeft + btnDown.Width ||
 | 
			
		||||
          e.Position.Y < btnDown.AbsoluteTop ||
 | 
			
		||||
          e.Position.Y > btnDown.AbsoluteTop + btnDown.Height))
 | 
			
		||||
      {
 | 
			
		||||
        //lstCombo.Visible = false;      
 | 
			
		||||
        btnDown_Click(sender, e);
 | 
			
		||||
      }      
 | 
			
		||||
    }   
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    void lstCombo_Click(object sender, EventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      MouseEventArgs ex = (e is MouseEventArgs) ? (MouseEventArgs)e : new MouseEventArgs();      
 | 
			
		||||
      
 | 
			
		||||
      if (ex.Button == MouseButton.Left || ex.Button == MouseButton.None)
 | 
			
		||||
      {
 | 
			
		||||
        lstCombo.Visible = false;        
 | 
			
		||||
        if (lstCombo.ItemIndex >= 0)
 | 
			
		||||
        {        
 | 
			
		||||
          Text = lstCombo.Items[lstCombo.ItemIndex].ToString();
 | 
			
		||||
          Focused = true;
 | 
			
		||||
          ItemIndex = lstCombo.ItemIndex;
 | 
			
		||||
        }  
 | 
			
		||||
      }  
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    protected override void OnKeyDown(KeyEventArgs e)
 | 
			
		||||
    {      
 | 
			
		||||
      if (e.Key == Keys.Down)
 | 
			
		||||
      {
 | 
			
		||||
        e.Handled = true;
 | 
			
		||||
        btnDown_Click(this, new MouseEventArgs());        
 | 
			
		||||
      }
 | 
			
		||||
      base.OnKeyDown(e);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected override void OnGamePadDown(GamePadEventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      if (!e.Handled)
 | 
			
		||||
      {        
 | 
			
		||||
        if (e.Button == GamePadActions.Click || e.Button == GamePadActions.Press || e.Button == GamePadActions.Down)
 | 
			
		||||
        {
 | 
			
		||||
          e.Handled = true;
 | 
			
		||||
          btnDown_Click(this, new MouseEventArgs());
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
      base.OnGamePadDown(e);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    protected override void OnMouseDown(MouseEventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      base.OnMouseDown(e);
 | 
			
		||||
      
 | 
			
		||||
      if (ReadOnly && e.Button == MouseButton.Left)
 | 
			
		||||
      {
 | 
			
		||||
        btnDown_Click(this, new MouseEventArgs());
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    protected virtual void OnMaxItemsChanged(EventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      if (MaxItemsChanged != null) MaxItemsChanged.Invoke(this, e);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    protected virtual void OnItemIndexChanged(EventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      if (ItemIndexChanged != null) ItemIndexChanged.Invoke(this, e);      
 | 
			
		||||
    }    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    void lstCombo_FocusLost(object sender, EventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      //lstCombo.Visible = false;
 | 
			
		||||
      Invalidate();
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    protected override void AdjustMargins()
 | 
			
		||||
    {
 | 
			
		||||
      base.AdjustMargins();
 | 
			
		||||
      ClientMargins = new Margins(ClientMargins.Left, ClientMargins.Top, ClientMargins.Right + 16, ClientMargins.Bottom);      
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,105 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: Component.cs                                 //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
using System;
 | 
			
		||||
using Microsoft.Xna.Framework;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
  public class Component: Disposable
 | 
			
		||||
  {
 | 
			
		||||
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    private Manager manager = null;
 | 
			
		||||
    private bool initialized = false;      
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Properties ////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public virtual Manager Manager { get { return manager; } set { manager = value; } }
 | 
			
		||||
    public virtual bool Initialized { get { return initialized; } }    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Constructors //////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public Component(Manager manager)
 | 
			
		||||
    {      
 | 
			
		||||
      if (manager != null)
 | 
			
		||||
      {
 | 
			
		||||
       this.manager = manager;                 
 | 
			
		||||
      }
 | 
			
		||||
      else
 | 
			
		||||
      {
 | 
			
		||||
        throw new Exception("Component cannot be created. Manager instance is needed.");
 | 
			
		||||
      }                 
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Destructors ///////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected override void Dispose(bool disposing)
 | 
			
		||||
    {      
 | 
			
		||||
      if (disposing)
 | 
			
		||||
      {      
 | 
			
		||||
      }
 | 
			
		||||
      base.Dispose(disposing);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Methods ///////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////         
 | 
			
		||||
    public virtual void Init()
 | 
			
		||||
    {
 | 
			
		||||
      initialized = true;
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////          
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
    protected internal virtual void Update(GameTime gameTime)
 | 
			
		||||
    {       
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,593 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: Console.cs                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
using System;
 | 
			
		||||
using Microsoft.Xna.Framework;
 | 
			
		||||
using Microsoft.Xna.Framework.Graphics;
 | 
			
		||||
using System.Collections;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
    public struct ConsoleMessage
 | 
			
		||||
    {
 | 
			
		||||
        public string Text;
 | 
			
		||||
        public byte Channel;
 | 
			
		||||
        public DateTime Time;
 | 
			
		||||
        public string Sender;
 | 
			
		||||
 | 
			
		||||
        public ConsoleMessage(string sender, string text, byte channel)
 | 
			
		||||
        {
 | 
			
		||||
            this.Text = text;
 | 
			
		||||
            this.Channel = channel;
 | 
			
		||||
            this.Time = DateTime.Now;
 | 
			
		||||
            this.Sender = sender;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public class ChannelList : EventedList<ConsoleChannel>
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        #region //// Indexers //////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        public ConsoleChannel this[string name]
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                for (int i = 0; i < this.Count; i++)
 | 
			
		||||
                {
 | 
			
		||||
                    ConsoleChannel s = (ConsoleChannel)this[i];
 | 
			
		||||
                    if (s.Name.ToLower() == name.ToLower())
 | 
			
		||||
                    {
 | 
			
		||||
                        return s;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                return default(ConsoleChannel);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                for (int i = 0; i < this.Count; i++)
 | 
			
		||||
                {
 | 
			
		||||
                    ConsoleChannel s = (ConsoleChannel)this[i];
 | 
			
		||||
                    if (s.Name.ToLower() == name.ToLower())
 | 
			
		||||
                    {
 | 
			
		||||
                        this[i] = value;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        public ConsoleChannel this[byte index]
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                for (int i = 0; i < this.Count; i++)
 | 
			
		||||
                {
 | 
			
		||||
                    ConsoleChannel s = (ConsoleChannel)this[i];
 | 
			
		||||
                    if (s.Index == index)
 | 
			
		||||
                    {
 | 
			
		||||
                        return s;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                return default(ConsoleChannel);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                for (int i = 0; i < this.Count; i++)
 | 
			
		||||
                {
 | 
			
		||||
                    ConsoleChannel s = (ConsoleChannel)this[i];
 | 
			
		||||
                    if (s.Index == index)
 | 
			
		||||
                    {
 | 
			
		||||
                        this[i] = value;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public class ConsoleChannel
 | 
			
		||||
    {
 | 
			
		||||
        private string name;
 | 
			
		||||
        private byte index;
 | 
			
		||||
        private Color color;
 | 
			
		||||
 | 
			
		||||
        public ConsoleChannel(byte index, string name, Color color)
 | 
			
		||||
        {
 | 
			
		||||
            this.name = name;
 | 
			
		||||
            this.index = index;
 | 
			
		||||
            this.color = color;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public virtual byte Index
 | 
			
		||||
        {
 | 
			
		||||
            get { return index; }
 | 
			
		||||
            set { index = value; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public virtual Color Color
 | 
			
		||||
        {
 | 
			
		||||
            get { return color; }
 | 
			
		||||
            set { color = value; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public virtual string Name
 | 
			
		||||
        {
 | 
			
		||||
            get { return name; }
 | 
			
		||||
            set { name = value; }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    [Flags]
 | 
			
		||||
    public enum ConsoleMessageFormats
 | 
			
		||||
    {
 | 
			
		||||
        None = 0x00,
 | 
			
		||||
        ChannelName = 0x01,
 | 
			
		||||
        TimeStamp = 0x02,
 | 
			
		||||
        Sender = 0x03,
 | 
			
		||||
        All = Sender | ChannelName | TimeStamp
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public class Console : Container
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////                 
 | 
			
		||||
        private TextBox txtMain = null;
 | 
			
		||||
        private ComboBox cmbMain;
 | 
			
		||||
        private EventedList<ConsoleMessage> buffer = new EventedList<ConsoleMessage>();
 | 
			
		||||
        private ChannelList channels = new ChannelList();
 | 
			
		||||
        private List<byte> filter = new List<byte>();
 | 
			
		||||
        private ConsoleMessageFormats messageFormat = ConsoleMessageFormats.None;
 | 
			
		||||
        private bool channelsVisible = true;
 | 
			
		||||
        private bool textBoxVisible = true;
 | 
			
		||||
        private string sender;
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region //// Properties ////////
 | 
			
		||||
 | 
			
		||||
        public string Sender
 | 
			
		||||
        {
 | 
			
		||||
            get { return sender; }
 | 
			
		||||
            set { sender = value; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        public virtual EventedList<ConsoleMessage> MessageBuffer
 | 
			
		||||
        {
 | 
			
		||||
            get { return buffer; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                buffer.ItemAdded -= new EventHandler(buffer_ItemAdded);
 | 
			
		||||
                buffer = value;
 | 
			
		||||
                buffer.ItemAdded += new EventHandler(buffer_ItemAdded);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        public virtual ChannelList Channels
 | 
			
		||||
        {
 | 
			
		||||
            get { return channels; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                channels.ItemAdded -= new EventHandler(channels_ItemAdded);
 | 
			
		||||
                channels = value;
 | 
			
		||||
                channels.ItemAdded += new EventHandler(channels_ItemAdded);
 | 
			
		||||
                channels_ItemAdded(null, null);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        public virtual List<byte> ChannelFilter
 | 
			
		||||
        {
 | 
			
		||||
            get { return filter; }
 | 
			
		||||
            set { filter = value; }
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        public virtual byte SelectedChannel
 | 
			
		||||
        {
 | 
			
		||||
            set { cmbMain.Text = channels[value].Name; }
 | 
			
		||||
            get { return channels[cmbMain.Text].Index; }
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        public virtual ConsoleMessageFormats MessageFormat
 | 
			
		||||
        {
 | 
			
		||||
            get { return messageFormat; }
 | 
			
		||||
            set { messageFormat = value; }
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////       
 | 
			
		||||
        public virtual bool ChannelsVisible
 | 
			
		||||
        {
 | 
			
		||||
            get { return channelsVisible; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                cmbMain.Visible = channelsVisible = value;
 | 
			
		||||
                if (value && !textBoxVisible) TextBoxVisible = false;
 | 
			
		||||
                PositionControls();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////       
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////       
 | 
			
		||||
        public virtual bool TextBoxVisible
 | 
			
		||||
        {
 | 
			
		||||
            get { return textBoxVisible; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                txtMain.Visible = textBoxVisible = value;
 | 
			
		||||
                txtMain.Focused = true;
 | 
			
		||||
                if (!value && channelsVisible) ChannelsVisible = false;
 | 
			
		||||
                PositionControls();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////       
 | 
			
		||||
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region //// Events ////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        public event ConsoleMessageEventHandler MessageSent;
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region //// Construstors //////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////       
 | 
			
		||||
        public Console(Manager manager)
 | 
			
		||||
            : base(manager)
 | 
			
		||||
        {
 | 
			
		||||
            Width = 320;
 | 
			
		||||
            Height = 160;
 | 
			
		||||
            MinimumHeight = 64;
 | 
			
		||||
            MinimumWidth = 64;
 | 
			
		||||
            CanFocus = false;
 | 
			
		||||
            Resizable = false;
 | 
			
		||||
            Movable = false;
 | 
			
		||||
 | 
			
		||||
            cmbMain = new ComboBox(manager);
 | 
			
		||||
            cmbMain.Init();
 | 
			
		||||
            cmbMain.Top = Height - cmbMain.Height;
 | 
			
		||||
            cmbMain.Left = 0;
 | 
			
		||||
            cmbMain.Width = 128;
 | 
			
		||||
            cmbMain.Anchor = Anchors.Left | Anchors.Bottom;
 | 
			
		||||
            cmbMain.Detached = false;
 | 
			
		||||
            cmbMain.DrawSelection = false;
 | 
			
		||||
            cmbMain.Visible = channelsVisible;
 | 
			
		||||
            Add(cmbMain, false);
 | 
			
		||||
 | 
			
		||||
            txtMain = new TextBox(manager);
 | 
			
		||||
            txtMain.Init();
 | 
			
		||||
            txtMain.Top = Height - txtMain.Height;
 | 
			
		||||
            txtMain.Left = cmbMain.Width + 1;
 | 
			
		||||
            txtMain.Anchor = Anchors.Left | Anchors.Bottom | Anchors.Right;
 | 
			
		||||
            txtMain.Detached = false;
 | 
			
		||||
            txtMain.Visible = textBoxVisible;
 | 
			
		||||
            txtMain.KeyDown += new KeyEventHandler(txtMain_KeyDown);
 | 
			
		||||
            txtMain.GamePadDown += new GamePadEventHandler(txtMain_GamePadDown);
 | 
			
		||||
            txtMain.FocusGained += new EventHandler(txtMain_FocusGained);
 | 
			
		||||
            Add(txtMain, false);
 | 
			
		||||
 | 
			
		||||
            VerticalScrollBar.Top = 2;
 | 
			
		||||
            VerticalScrollBar.Left = Width - 18;
 | 
			
		||||
            VerticalScrollBar.Range = 1;
 | 
			
		||||
            VerticalScrollBar.PageSize = 1;
 | 
			
		||||
            VerticalScrollBar.ValueChanged += new EventHandler(VerticalScrollBar_ValueChanged);
 | 
			
		||||
            VerticalScrollBar.Visible = true;
 | 
			
		||||
 | 
			
		||||
            ClientArea.Draw += new DrawEventHandler(ClientArea_Draw);
 | 
			
		||||
 | 
			
		||||
            buffer.ItemAdded += new EventHandler(buffer_ItemAdded);
 | 
			
		||||
            channels.ItemAdded += new EventHandler(channels_ItemAdded);
 | 
			
		||||
            channels.ItemRemoved += new EventHandler(channels_ItemRemoved);
 | 
			
		||||
 | 
			
		||||
            PositionControls();
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////       
 | 
			
		||||
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region //// Methods ///////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        private void PositionControls()
 | 
			
		||||
        {
 | 
			
		||||
            if (txtMain != null)
 | 
			
		||||
            {
 | 
			
		||||
                txtMain.Left = channelsVisible ? cmbMain.Width + 1 : 0;
 | 
			
		||||
                txtMain.Width = channelsVisible ? Width - cmbMain.Width - 1 : Width;
 | 
			
		||||
 | 
			
		||||
                if (textBoxVisible)
 | 
			
		||||
                {
 | 
			
		||||
                    ClientMargins = new Margins(Skin.ClientMargins.Left, Skin.ClientMargins.Top + 4, VerticalScrollBar.Width + 6, txtMain.Height + 4);
 | 
			
		||||
                    VerticalScrollBar.Height = Height - txtMain.Height - 5;
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    ClientMargins = new Margins(Skin.ClientMargins.Left, Skin.ClientMargins.Top + 4, VerticalScrollBar.Width + 6, 2);
 | 
			
		||||
                    VerticalScrollBar.Height = Height - 4;
 | 
			
		||||
                }
 | 
			
		||||
                Invalidate();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        public override void Init()
 | 
			
		||||
        {
 | 
			
		||||
            base.Init();
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////                          
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////                          
 | 
			
		||||
        protected internal override void InitSkin()
 | 
			
		||||
        {
 | 
			
		||||
            base.InitSkin();
 | 
			
		||||
            Skin = new SkinControl(Manager.Skin.Controls["Console"]);
 | 
			
		||||
 | 
			
		||||
            PositionControls();
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////                          
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        protected internal override void Update(GameTime gameTime)
 | 
			
		||||
        {
 | 
			
		||||
            base.Update(gameTime);
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        void ClientArea_Draw(object sender, DrawEventArgs e)
 | 
			
		||||
        {
 | 
			
		||||
            SpriteFont font = Skin.Layers[0].Text.Font.Resource;
 | 
			
		||||
            Rectangle r = new Rectangle(e.Rectangle.Left, e.Rectangle.Top, e.Rectangle.Width, e.Rectangle.Height);
 | 
			
		||||
            int pos = 0;
 | 
			
		||||
 | 
			
		||||
            if (buffer.Count > 0)
 | 
			
		||||
            {
 | 
			
		||||
                EventedList<ConsoleMessage> b = GetFilteredBuffer(filter);
 | 
			
		||||
                int c = b.Count;
 | 
			
		||||
                int s = (VerticalScrollBar.Value + VerticalScrollBar.PageSize);
 | 
			
		||||
                int f = s - VerticalScrollBar.PageSize;
 | 
			
		||||
 | 
			
		||||
                if (b.Count > 0)
 | 
			
		||||
                {
 | 
			
		||||
                    for (int i = s - 1; i >= f; i--)
 | 
			
		||||
                    {
 | 
			
		||||
                        {
 | 
			
		||||
                            int x = 4;
 | 
			
		||||
                            int y = r.Bottom - (pos + 1) * ((int)font.LineSpacing + 0);
 | 
			
		||||
 | 
			
		||||
                            string msg = ((ConsoleMessage)b[i]).Text;
 | 
			
		||||
                            string pre = "";
 | 
			
		||||
                            ConsoleChannel ch = (channels[((ConsoleMessage)b[i]).Channel] as ConsoleChannel);
 | 
			
		||||
 | 
			
		||||
                            if ((messageFormat & ConsoleMessageFormats.ChannelName) == ConsoleMessageFormats.ChannelName)
 | 
			
		||||
                            {
 | 
			
		||||
                                pre += string.Format("[{0}]", channels[((ConsoleMessage)b[i]).Channel].Name);
 | 
			
		||||
                            }
 | 
			
		||||
                            if ((messageFormat & ConsoleMessageFormats.Sender) == ConsoleMessageFormats.Sender)
 | 
			
		||||
                            {
 | 
			
		||||
                                pre += string.Format("[{0}]", ((ConsoleMessage)b[i]).Sender);
 | 
			
		||||
                            }
 | 
			
		||||
                            if ((messageFormat & ConsoleMessageFormats.TimeStamp) == ConsoleMessageFormats.TimeStamp)
 | 
			
		||||
                            {
 | 
			
		||||
                                pre = string.Format("[{0}]", ((ConsoleMessage)b[i]).Time.ToLongTimeString()) + pre;
 | 
			
		||||
                            }
 | 
			
		||||
 | 
			
		||||
                            if (pre != "") msg = pre + ": " + msg;
 | 
			
		||||
 | 
			
		||||
                            e.Renderer.DrawString(font,
 | 
			
		||||
                                                msg,
 | 
			
		||||
                                                x, y,
 | 
			
		||||
                                                ch.Color);
 | 
			
		||||
                            pos += 1;
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
 | 
			
		||||
        {
 | 
			
		||||
            int h = txtMain.Visible ? (txtMain.Height + 1) : 0;
 | 
			
		||||
            Rectangle r = new Rectangle(rect.Left, rect.Top, rect.Width, rect.Height - h);
 | 
			
		||||
            base.DrawControl(renderer, r, gameTime);
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////              
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
        void txtMain_FocusGained(object sender, EventArgs e)
 | 
			
		||||
        {
 | 
			
		||||
            ConsoleChannel ch = channels[cmbMain.Text];
 | 
			
		||||
            if (ch != null) txtMain.TextColor = ch.Color;
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
        void txtMain_KeyDown(object sender, KeyEventArgs e)
 | 
			
		||||
        {
 | 
			
		||||
            SendMessage(e);
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////        
 | 
			
		||||
        void txtMain_GamePadDown(object sender, GamePadEventArgs e)
 | 
			
		||||
        {
 | 
			
		||||
            SendMessage(e);
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////        
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////        
 | 
			
		||||
        private void SendMessage(EventArgs x)
 | 
			
		||||
        {
 | 
			
		||||
            KeyEventArgs k = new KeyEventArgs();
 | 
			
		||||
            GamePadEventArgs g = new GamePadEventArgs(PlayerIndex.One);
 | 
			
		||||
 | 
			
		||||
            if (x is KeyEventArgs) k = x as KeyEventArgs;
 | 
			
		||||
            else if (x is GamePadEventArgs) g = x as GamePadEventArgs;
 | 
			
		||||
 | 
			
		||||
            ConsoleChannel ch = channels[cmbMain.Text];
 | 
			
		||||
            if (ch != null)
 | 
			
		||||
            {
 | 
			
		||||
                txtMain.TextColor = ch.Color;
 | 
			
		||||
 | 
			
		||||
                string message = txtMain.Text;
 | 
			
		||||
                if ((k.Key == Microsoft.Xna.Framework.Input.Keys.Enter || g.Button == GamePadActions.Press) && message != null && message != "")
 | 
			
		||||
                {
 | 
			
		||||
                    x.Handled = true;
 | 
			
		||||
 | 
			
		||||
                    ConsoleMessageEventArgs me = new ConsoleMessageEventArgs(new ConsoleMessage(sender, message, ch.Index));
 | 
			
		||||
                    OnMessageSent(me);
 | 
			
		||||
 | 
			
		||||
                    buffer.Add(new ConsoleMessage(sender, me.Message.Text, me.Message.Channel));
 | 
			
		||||
 | 
			
		||||
                    txtMain.Text = "";
 | 
			
		||||
                    ClientArea.Invalidate();
 | 
			
		||||
 | 
			
		||||
                    CalcScrolling();
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////        
 | 
			
		||||
        protected virtual void OnMessageSent(ConsoleMessageEventArgs e)
 | 
			
		||||
        {
 | 
			
		||||
            if (MessageSent != null) MessageSent.Invoke(this, e);
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        void channels_ItemAdded(object sender, EventArgs e)
 | 
			
		||||
        {
 | 
			
		||||
            cmbMain.Items.Clear();
 | 
			
		||||
            for (int i = 0; i < channels.Count; i++)
 | 
			
		||||
            {
 | 
			
		||||
                cmbMain.Items.Add((channels[i] as ConsoleChannel).Name);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        void channels_ItemRemoved(object sender, EventArgs e)
 | 
			
		||||
        {
 | 
			
		||||
            cmbMain.Items.Clear();
 | 
			
		||||
            for (int i = 0; i < channels.Count; i++)
 | 
			
		||||
            {
 | 
			
		||||
                cmbMain.Items.Add((channels[i] as ConsoleChannel).Name);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        void buffer_ItemAdded(object sender, EventArgs e)
 | 
			
		||||
        {
 | 
			
		||||
            CalcScrolling();
 | 
			
		||||
            ClientArea.Invalidate();
 | 
			
		||||
        }
 | 
			
		||||
        //////////////////////////////////////////////////////////////////////////// 
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
        private void CalcScrolling()
 | 
			
		||||
        {
 | 
			
		||||
            if (VerticalScrollBar != null)
 | 
			
		||||
            {
 | 
			
		||||
                int line = Skin.Layers[0].Text.Font.Resource.LineSpacing;
 | 
			
		||||
                int c = GetFilteredBuffer(filter).Count;
 | 
			
		||||
                int p = (int)Math.Ceiling(ClientArea.ClientHeight / (float)line);
 | 
			
		||||
 | 
			
		||||
                VerticalScrollBar.Range = c == 0 ? 1 : c;
 | 
			
		||||
                VerticalScrollBar.PageSize = c == 0 ? 1 : p;
 | 
			
		||||
                VerticalScrollBar.Value = VerticalScrollBar.Range;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        //////////////////////////////////////////////////////////////////////////// 
 | 
			
		||||
 | 
			
		||||
        //////////////////////////////////////////////////////////////////////////// 
 | 
			
		||||
        void VerticalScrollBar_ValueChanged(object sender, EventArgs e)
 | 
			
		||||
        {
 | 
			
		||||
            ClientArea.Invalidate();
 | 
			
		||||
        }
 | 
			
		||||
        //////////////////////////////////////////////////////////////////////////// 
 | 
			
		||||
 | 
			
		||||
        //////////////////////////////////////////////////////////////////////////// 
 | 
			
		||||
        protected override void OnResize(ResizeEventArgs e)
 | 
			
		||||
        {
 | 
			
		||||
            CalcScrolling();
 | 
			
		||||
            base.OnResize(e);
 | 
			
		||||
        }
 | 
			
		||||
        //////////////////////////////////////////////////////////////////////////// 
 | 
			
		||||
 | 
			
		||||
        //////////////////////////////////////////////////////////////////////////// 
 | 
			
		||||
        private EventedList<ConsoleMessage> GetFilteredBuffer(List<byte> filter)
 | 
			
		||||
        {
 | 
			
		||||
            EventedList<ConsoleMessage> ret = new EventedList<ConsoleMessage>();
 | 
			
		||||
 | 
			
		||||
            if (filter.Count > 0)
 | 
			
		||||
            {
 | 
			
		||||
                for (int i = 0; i < buffer.Count; i++)
 | 
			
		||||
                {
 | 
			
		||||
                    if (filter.Contains(((ConsoleMessage)buffer[i]).Channel))
 | 
			
		||||
                    {
 | 
			
		||||
                        ret.Add(buffer[i]);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                return ret;
 | 
			
		||||
            }
 | 
			
		||||
            else return buffer;
 | 
			
		||||
        }
 | 
			
		||||
        //////////////////////////////////////////////////////////////////////////// 
 | 
			
		||||
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,554 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: Container.cs                                 //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
using Microsoft.Xna.Framework;
 | 
			
		||||
using Microsoft.Xna.Framework.Graphics;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
  public struct ScrollBarValue
 | 
			
		||||
  {
 | 
			
		||||
    public int Vertical;
 | 
			
		||||
    public int Horizontal;
 | 
			
		||||
  }
 | 
			
		||||
     
 | 
			
		||||
  public class Container: ClipControl
 | 
			
		||||
  {   
 | 
			
		||||
   
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////        
 | 
			
		||||
    private ScrollBar sbVert;
 | 
			
		||||
    private ScrollBar sbHorz;
 | 
			
		||||
    private MainMenu mainMenu;
 | 
			
		||||
    private ToolBarPanel toolBarPanel;   
 | 
			
		||||
    private StatusBar statusBar;
 | 
			
		||||
    private bool autoScroll = false;
 | 
			
		||||
    private Control defaultControl = null;   
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Scroll by PageSize (true) or StepSize (false)
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    private bool scrollAlot = true;
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion   
 | 
			
		||||
 | 
			
		||||
    #region //// Properties ////////
 | 
			
		||||
   
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public virtual ScrollBarValue ScrollBarValue
 | 
			
		||||
    {
 | 
			
		||||
      get
 | 
			
		||||
      {
 | 
			
		||||
        ScrollBarValue scb = new ScrollBarValue();
 | 
			
		||||
        scb.Vertical = (sbVert != null ? sbVert.Value : 0);
 | 
			
		||||
        scb.Horizontal = (sbHorz != null ? sbHorz.Value : 0);
 | 
			
		||||
        return scb;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public override bool Visible
 | 
			
		||||
    {
 | 
			
		||||
      get
 | 
			
		||||
      {
 | 
			
		||||
        return base.Visible;        
 | 
			
		||||
      }
 | 
			
		||||
      set
 | 
			
		||||
      {   
 | 
			
		||||
        if (value)
 | 
			
		||||
        {
 | 
			
		||||
          if (DefaultControl != null)
 | 
			
		||||
          {
 | 
			
		||||
            DefaultControl.Focused = true;  
 | 
			
		||||
          }        
 | 
			
		||||
        }
 | 
			
		||||
        base.Visible = value;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public virtual Control DefaultControl
 | 
			
		||||
    {
 | 
			
		||||
      get { return defaultControl; }
 | 
			
		||||
      set { defaultControl = value; }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public virtual bool AutoScroll
 | 
			
		||||
    {
 | 
			
		||||
      get { return autoScroll; }
 | 
			
		||||
      set { autoScroll = value; }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
    public virtual MainMenu MainMenu
 | 
			
		||||
    {
 | 
			
		||||
      get { return mainMenu; }
 | 
			
		||||
      set
 | 
			
		||||
      {
 | 
			
		||||
        if (mainMenu != null)
 | 
			
		||||
        {
 | 
			
		||||
          mainMenu.Resize -= Bars_Resize;
 | 
			
		||||
          Remove(mainMenu);
 | 
			
		||||
        }
 | 
			
		||||
        mainMenu = value;
 | 
			
		||||
        
 | 
			
		||||
        if (mainMenu != null)
 | 
			
		||||
        {
 | 
			
		||||
          Add(mainMenu, false);
 | 
			
		||||
          mainMenu.Resize += Bars_Resize;          
 | 
			
		||||
        }
 | 
			
		||||
        AdjustMargins();
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public virtual ToolBarPanel ToolBarPanel
 | 
			
		||||
    {
 | 
			
		||||
      get 
 | 
			
		||||
      { 
 | 
			
		||||
        return toolBarPanel; 
 | 
			
		||||
      }
 | 
			
		||||
      set
 | 
			
		||||
      {
 | 
			
		||||
        if (toolBarPanel != null)
 | 
			
		||||
        {
 | 
			
		||||
          toolBarPanel.Resize -= Bars_Resize;
 | 
			
		||||
          Remove(toolBarPanel);
 | 
			
		||||
        }
 | 
			
		||||
        toolBarPanel = value;
 | 
			
		||||
        
 | 
			
		||||
        if (toolBarPanel != null)
 | 
			
		||||
        {
 | 
			
		||||
          Add(toolBarPanel, false);
 | 
			
		||||
          toolBarPanel.Resize += Bars_Resize;          
 | 
			
		||||
        }
 | 
			
		||||
        AdjustMargins();
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public virtual StatusBar StatusBar
 | 
			
		||||
    {
 | 
			
		||||
      get
 | 
			
		||||
      {
 | 
			
		||||
        return statusBar;
 | 
			
		||||
      }
 | 
			
		||||
      set
 | 
			
		||||
      {
 | 
			
		||||
        if (statusBar != null)
 | 
			
		||||
        {
 | 
			
		||||
          statusBar.Resize -= Bars_Resize;
 | 
			
		||||
          Remove(statusBar);        
 | 
			
		||||
        }  
 | 
			
		||||
        statusBar = value;
 | 
			
		||||
        
 | 
			
		||||
        if (statusBar != null)
 | 
			
		||||
        {
 | 
			
		||||
          Add(statusBar, false);
 | 
			
		||||
          statusBar.Resize += Bars_Resize;
 | 
			
		||||
        }
 | 
			
		||||
        AdjustMargins();
 | 
			
		||||
      }
 | 
			
		||||
    }    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Scroll by PageSize (true) or StepSize (false)
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public virtual bool ScrollAlot
 | 
			
		||||
    {
 | 
			
		||||
        get { return this.scrollAlot; }
 | 
			
		||||
        set { this.scrollAlot = value; }
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Gets the container's vertical scroll bar.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    protected virtual ScrollBar VerticalScrollBar
 | 
			
		||||
    {
 | 
			
		||||
        get { return this.sbVert; }
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Gets the container's horizontal scroll bar.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    protected virtual ScrollBar HorizontalScrollBar
 | 
			
		||||
    {
 | 
			
		||||
        get { return this.sbHorz; }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
    
 | 
			
		||||
 	  #region //// Constructors //////
 | 
			
		||||
	 		
 | 
			
		||||
	  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
		public Container(Manager manager): base(manager)
 | 
			
		||||
    {                                           
 | 
			
		||||
      sbVert = new ScrollBar(manager, Orientation.Vertical);
 | 
			
		||||
      sbVert.Init();      
 | 
			
		||||
      sbVert.Detached = false;
 | 
			
		||||
      sbVert.Anchor = Anchors.Top | Anchors.Right | Anchors.Bottom;
 | 
			
		||||
      sbVert.ValueChanged += new EventHandler(ScrollBarValueChanged);                 
 | 
			
		||||
      sbVert.Range = 0;
 | 
			
		||||
      sbVert.PageSize = 0;
 | 
			
		||||
      sbVert.Value = 0;
 | 
			
		||||
      sbVert.Visible = false;
 | 
			
		||||
 | 
			
		||||
      sbHorz = new ScrollBar(manager, Orientation.Horizontal);
 | 
			
		||||
      sbHorz.Init();
 | 
			
		||||
      sbHorz.Detached = false;
 | 
			
		||||
      sbHorz.Anchor = Anchors.Right | Anchors.Left | Anchors.Bottom;
 | 
			
		||||
      sbHorz.ValueChanged += new EventHandler(ScrollBarValueChanged);
 | 
			
		||||
      sbHorz.Range = 0;
 | 
			
		||||
      sbHorz.PageSize = 0;
 | 
			
		||||
      sbHorz.Value = 0;
 | 
			
		||||
      sbHorz.Visible = false;
 | 
			
		||||
            
 | 
			
		||||
      Add(sbVert, false);
 | 
			
		||||
      Add(sbHorz, false);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////         
 | 
			
		||||
       
 | 
			
		||||
  	#endregion   
 | 
			
		||||
 | 
			
		||||
    #region //// Methods ///////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public override void Init()
 | 
			
		||||
    {      
 | 
			
		||||
      base.Init();
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////        
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected internal override void InitSkin()
 | 
			
		||||
    {
 | 
			
		||||
      base.InitSkin();      
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    private void Bars_Resize(object sender, ResizeEventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      AdjustMargins();      
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////  
 | 
			
		||||
    protected override void AdjustMargins()
 | 
			
		||||
    {
 | 
			
		||||
      Margins m = Skin.ClientMargins;
 | 
			
		||||
      
 | 
			
		||||
      if (this.GetType() != typeof(Container))
 | 
			
		||||
      {
 | 
			
		||||
        m = ClientMargins;
 | 
			
		||||
      } 
 | 
			
		||||
            
 | 
			
		||||
      if (mainMenu != null && mainMenu.Visible)
 | 
			
		||||
      {
 | 
			
		||||
        if (!mainMenu.Initialized) mainMenu.Init();
 | 
			
		||||
        mainMenu.Left = m.Left;
 | 
			
		||||
        mainMenu.Top = m.Top;
 | 
			
		||||
        mainMenu.Width = Width - m.Horizontal;
 | 
			
		||||
        mainMenu.Anchor = Anchors.Left | Anchors.Top | Anchors.Right;                
 | 
			
		||||
     
 | 
			
		||||
        m.Top += mainMenu.Height;        
 | 
			
		||||
      }
 | 
			
		||||
      if (toolBarPanel != null && toolBarPanel.Visible)
 | 
			
		||||
      {
 | 
			
		||||
        if (!toolBarPanel.Initialized) toolBarPanel.Init();
 | 
			
		||||
        toolBarPanel.Left = m.Left;
 | 
			
		||||
        toolBarPanel.Top = m.Top;
 | 
			
		||||
        toolBarPanel.Width = Width - m.Horizontal;
 | 
			
		||||
        toolBarPanel.Anchor = Anchors.Left | Anchors.Top | Anchors.Right;        
 | 
			
		||||
        
 | 
			
		||||
        m.Top += toolBarPanel.Height;
 | 
			
		||||
      }
 | 
			
		||||
      if (statusBar != null && statusBar.Visible)
 | 
			
		||||
      {                
 | 
			
		||||
        if (!statusBar.Initialized) statusBar.Init();        
 | 
			
		||||
        statusBar.Left = m.Left;
 | 
			
		||||
        statusBar.Top = Height - m.Bottom - statusBar.Height;
 | 
			
		||||
        statusBar.Width = Width - m.Horizontal;
 | 
			
		||||
        statusBar.Anchor = Anchors.Left | Anchors.Bottom | Anchors.Right;        
 | 
			
		||||
 | 
			
		||||
        m.Bottom += statusBar.Height;
 | 
			
		||||
      }
 | 
			
		||||
      if (sbVert != null && sbVert.Visible)
 | 
			
		||||
      {
 | 
			
		||||
        m.Right += (sbVert.Width + 2);
 | 
			
		||||
      }
 | 
			
		||||
      if (sbHorz != null && sbHorz.Visible)
 | 
			
		||||
      {
 | 
			
		||||
        m.Bottom += (sbHorz.Height + 2);
 | 
			
		||||
      }            
 | 
			
		||||
      
 | 
			
		||||
      ClientMargins = m;            
 | 
			
		||||
      
 | 
			
		||||
      PositionScrollBars();
 | 
			
		||||
      
 | 
			
		||||
      base.AdjustMargins();
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////  
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public override void Add(Control control, bool client)
 | 
			
		||||
    {
 | 
			
		||||
      base.Add(control, client);
 | 
			
		||||
      CalcScrolling();
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////           
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected internal override void Update(GameTime gameTime)
 | 
			
		||||
    {      
 | 
			
		||||
      base.Update(gameTime);                     
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
 | 
			
		||||
    {      
 | 
			
		||||
      base.DrawControl(renderer, rect, gameTime);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////  
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////  
 | 
			
		||||
    protected internal override void OnSkinChanged(EventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      base.OnSkinChanged(e);
 | 
			
		||||
      if (sbVert != null && sbHorz != null)
 | 
			
		||||
      {
 | 
			
		||||
        sbVert.Visible = false;
 | 
			
		||||
        sbHorz.Visible = false;
 | 
			
		||||
        CalcScrolling();
 | 
			
		||||
      }  
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////  
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    private void PositionScrollBars()
 | 
			
		||||
    {
 | 
			
		||||
      if (sbVert != null)
 | 
			
		||||
      {
 | 
			
		||||
        sbVert.Left = ClientLeft + ClientWidth + 1;
 | 
			
		||||
        sbVert.Top = ClientTop + 1;
 | 
			
		||||
        int m = (sbHorz != null && sbHorz.Visible) ? 0 : 2;
 | 
			
		||||
        sbVert.Height = ClientArea.Height - m;  
 | 
			
		||||
        sbVert.Range = ClientArea.VirtualHeight;
 | 
			
		||||
        sbVert.PageSize = ClientArea.ClientHeight;
 | 
			
		||||
      }
 | 
			
		||||
      
 | 
			
		||||
      if (sbHorz != null)
 | 
			
		||||
      {
 | 
			
		||||
        sbHorz.Left = ClientLeft + 1;
 | 
			
		||||
        sbHorz.Top = ClientTop + ClientHeight + 1;
 | 
			
		||||
        int m = (sbVert != null && sbVert.Visible) ? 0 : 2;              
 | 
			
		||||
        sbHorz.Width = ClientArea.Width - m;
 | 
			
		||||
        sbHorz.Range = ClientArea.VirtualWidth;
 | 
			
		||||
        sbHorz.PageSize = ClientArea.ClientWidth;
 | 
			
		||||
      }  
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    private void CalcScrolling()
 | 
			
		||||
    {                      
 | 
			
		||||
      if (sbVert != null && autoScroll)
 | 
			
		||||
      {                
 | 
			
		||||
        bool vis = sbVert.Visible;        
 | 
			
		||||
        sbVert.Visible = ClientArea.VirtualHeight > ClientArea.ClientHeight;                
 | 
			
		||||
        if (ClientArea.VirtualHeight <= ClientArea.ClientHeight) sbVert.Value = 0;
 | 
			
		||||
        
 | 
			
		||||
        if (vis != sbVert.Visible)
 | 
			
		||||
        {
 | 
			
		||||
          if (!sbVert.Visible)
 | 
			
		||||
          {
 | 
			
		||||
            foreach (Control c in ClientArea.Controls)
 | 
			
		||||
            {
 | 
			
		||||
              c.TopModifier = 0;
 | 
			
		||||
              c.Invalidate();
 | 
			
		||||
            }
 | 
			
		||||
          }
 | 
			
		||||
          AdjustMargins(); 
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        PositionScrollBars();                                           
 | 
			
		||||
        foreach (Control c in ClientArea.Controls)
 | 
			
		||||
        {
 | 
			
		||||
          c.TopModifier = -sbVert.Value;
 | 
			
		||||
          c.Invalidate();
 | 
			
		||||
        }    
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if (sbHorz != null && autoScroll)
 | 
			
		||||
      {
 | 
			
		||||
        bool vis = sbHorz.Visible;
 | 
			
		||||
        sbHorz.Visible = ClientArea.VirtualWidth > ClientArea.ClientWidth;     
 | 
			
		||||
        if (ClientArea.VirtualWidth <= ClientArea.ClientWidth) sbHorz.Value = 0;
 | 
			
		||||
        
 | 
			
		||||
        if (vis != sbHorz.Visible)
 | 
			
		||||
        {
 | 
			
		||||
          if (!sbHorz.Visible)
 | 
			
		||||
          {   
 | 
			
		||||
            foreach (Control c in ClientArea.Controls)
 | 
			
		||||
            {
 | 
			
		||||
              c.LeftModifier = 0;
 | 
			
		||||
              sbVert.Refresh();
 | 
			
		||||
              c.Invalidate();
 | 
			
		||||
            }
 | 
			
		||||
          }
 | 
			
		||||
          AdjustMargins();
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        PositionScrollBars();
 | 
			
		||||
        foreach (Control c in ClientArea.Controls)
 | 
			
		||||
        {
 | 
			
		||||
          c.LeftModifier = -sbHorz.Value;
 | 
			
		||||
          sbHorz.Refresh();
 | 
			
		||||
          c.Invalidate();
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
    public virtual void ScrollTo(int x, int y)
 | 
			
		||||
    {
 | 
			
		||||
      sbVert.Value = y;
 | 
			
		||||
      sbHorz.Value = x;
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public virtual void ScrollTo(Control control)
 | 
			
		||||
    {
 | 
			
		||||
      if (control != null && ClientArea != null && ClientArea.Contains(control, true))
 | 
			
		||||
      {
 | 
			
		||||
        if (control.AbsoluteTop + control.Height > ClientArea.AbsoluteTop + ClientArea.Height)
 | 
			
		||||
        {
 | 
			
		||||
          sbVert.Value = sbVert.Value + control.AbsoluteTop - ClientArea.AbsoluteTop - sbVert.PageSize + control.Height;
 | 
			
		||||
        }
 | 
			
		||||
        else if (control.AbsoluteTop < ClientArea.AbsoluteTop)
 | 
			
		||||
        {
 | 
			
		||||
          sbVert.Value = sbVert.Value + control.AbsoluteTop - ClientArea.AbsoluteTop;
 | 
			
		||||
        }
 | 
			
		||||
        if (control.AbsoluteLeft + control.Width > ClientArea.AbsoluteLeft + ClientArea.Width)
 | 
			
		||||
        {
 | 
			
		||||
          sbHorz.Value = sbHorz.Value + control.AbsoluteLeft - ClientArea.AbsoluteLeft - sbHorz.PageSize + control.Width;
 | 
			
		||||
        }
 | 
			
		||||
        else if (control.AbsoluteLeft < ClientArea.AbsoluteLeft)
 | 
			
		||||
        {
 | 
			
		||||
          sbHorz.Value = sbHorz.Value + control.AbsoluteLeft - ClientArea.AbsoluteLeft;
 | 
			
		||||
        }
 | 
			
		||||
      }  
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                  
 | 
			
		||||
    void ScrollBarValueChanged(object sender, EventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      CalcScrolling();     
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////           
 | 
			
		||||
    protected override void OnResize(ResizeEventArgs e)
 | 
			
		||||
    {             
 | 
			
		||||
      base.OnResize(e);
 | 
			
		||||
      CalcScrolling();
 | 
			
		||||
      
 | 
			
		||||
      // Crappy fix to certain scrolling issue
 | 
			
		||||
      //if (sbVert != null) sbVert.Value -= 1; 
 | 
			
		||||
      //if (sbHorz != null) sbHorz.Value -= 1;      
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
    public override void Invalidate()
 | 
			
		||||
    {        
 | 
			
		||||
      base.Invalidate();
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
    protected override void OnClick(EventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      MouseEventArgs ex = e as MouseEventArgs;      
 | 
			
		||||
      ex.Position = new Point(ex.Position.X + sbHorz.Value, ex.Position.Y + sbVert.Value);
 | 
			
		||||
      
 | 
			
		||||
      base.OnClick(e);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////       
 | 
			
		||||
   
 | 
			
		||||
    protected override void OnMouseScroll(MouseEventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
        if (!ClientArea.Enabled)
 | 
			
		||||
            return;
 | 
			
		||||
 
 | 
			
		||||
        // If current control doesn't scroll, scroll the parent control
 | 
			
		||||
        if (sbVert.Range - sbVert.PageSize < 1)
 | 
			
		||||
        {
 | 
			
		||||
            Control c = this;
 | 
			
		||||
 
 | 
			
		||||
            while (c != null)
 | 
			
		||||
            {
 | 
			
		||||
                var p = c.Parent as Container;
 | 
			
		||||
 
 | 
			
		||||
                if (p != null && p.Enabled)
 | 
			
		||||
                {
 | 
			
		||||
                    p.OnMouseScroll(e);
 | 
			
		||||
 
 | 
			
		||||
                    break;
 | 
			
		||||
                }
 | 
			
		||||
 
 | 
			
		||||
                c = c.Parent;
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
        if (e.ScrollDirection == MouseScrollDirection.Down)
 | 
			
		||||
            sbVert.ScrollDown(ScrollAlot);
 | 
			
		||||
        else
 | 
			
		||||
            sbVert.ScrollUp(ScrollAlot);
 | 
			
		||||
 
 | 
			
		||||
        base.OnMouseScroll(e);
 | 
			
		||||
    }
 | 
			
		||||
    #endregion
 | 
			
		||||
 }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,155 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: ContentReaders.cs                            //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
//////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
using System;
 | 
			
		||||
using System.IO;
 | 
			
		||||
using System.Xml;
 | 
			
		||||
using Microsoft.Xna.Framework.Content;
 | 
			
		||||
 | 
			
		||||
#if (!XBOX && !XBOX_FAKE)
 | 
			
		||||
using Microsoft.Xna.Framework.Graphics;
 | 
			
		||||
using Microsoft.Xna.Framework;
 | 
			
		||||
#endif
 | 
			
		||||
//////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public class LayoutXmlDocument : XmlDocument { }
 | 
			
		||||
    public class SkinXmlDocument : XmlDocument { }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public class SkinReader : ContentTypeReader<SkinXmlDocument>
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        #region //// Methods ///////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        protected override SkinXmlDocument Read(ContentReader input, SkinXmlDocument existingInstance)
 | 
			
		||||
        {
 | 
			
		||||
            if (existingInstance == null)
 | 
			
		||||
            {
 | 
			
		||||
                SkinXmlDocument doc = new SkinXmlDocument();
 | 
			
		||||
                doc.LoadXml(input.ReadString());
 | 
			
		||||
                return doc;
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                existingInstance.LoadXml(input.ReadString());
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return existingInstance;
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public class LayoutReader : ContentTypeReader<LayoutXmlDocument>
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        #region //// Methods ///////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        protected override LayoutXmlDocument Read(ContentReader input, LayoutXmlDocument existingInstance)
 | 
			
		||||
        {
 | 
			
		||||
            if (existingInstance == null)
 | 
			
		||||
            {
 | 
			
		||||
                LayoutXmlDocument doc = new LayoutXmlDocument();
 | 
			
		||||
                doc.LoadXml(input.ReadString());
 | 
			
		||||
                return doc;
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                existingInstance.LoadXml(input.ReadString());
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return existingInstance;
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
#if (!XBOX && !XBOX_FAKE)
 | 
			
		||||
 | 
			
		||||
    public class CursorReader : ContentTypeReader<Cursor>
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        #region //// Methods ///////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        protected override Cursor Read(ContentReader input, Cursor existingInstance)
 | 
			
		||||
        {
 | 
			
		||||
            if (existingInstance == null)
 | 
			
		||||
            {
 | 
			
		||||
                int count = input.ReadInt32();
 | 
			
		||||
                byte[] data = input.ReadBytes(count);
 | 
			
		||||
 | 
			
		||||
                string path = Path.GetTempFileName();
 | 
			
		||||
                File.WriteAllBytes(path, data);
 | 
			
		||||
                string tPath = Path.GetTempFileName();
 | 
			
		||||
                using(System.Drawing.Icon i = System.Drawing.Icon.ExtractAssociatedIcon(path))
 | 
			
		||||
                {
 | 
			
		||||
                    using (System.Drawing.Bitmap b = i.ToBitmap())
 | 
			
		||||
                    {
 | 
			
		||||
 | 
			
		||||
                        b.Save(tPath, System.Drawing.Imaging.ImageFormat.Png);
 | 
			
		||||
                        b.Dispose();
 | 
			
		||||
                    }
 | 
			
		||||
                    
 | 
			
		||||
                    i.Dispose();
 | 
			
		||||
                }
 | 
			
		||||
                //TODO: Replace with xml based solution for getting hotspot and size instead
 | 
			
		||||
                IntPtr handle = NativeMethods.LoadCursor(path);
 | 
			
		||||
                System.Windows.Forms.Cursor c = new System.Windows.Forms.Cursor(handle);
 | 
			
		||||
                Vector2 hs = new Vector2(c.HotSpot.X, c.HotSpot.Y);
 | 
			
		||||
                int w = c.Size.Width;
 | 
			
		||||
                int h = c.Size.Height;
 | 
			
		||||
                c.Dispose();
 | 
			
		||||
                File.Delete(path);
 | 
			
		||||
 | 
			
		||||
                return new Cursor(tPath, hs, w, h);
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return existingInstance;
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -1,575 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: ContextMenu.cs                               //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using Microsoft.Xna.Framework;
 | 
			
		||||
using Microsoft.Xna.Framework.Graphics;
 | 
			
		||||
using Microsoft.Xna.Framework.Input;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{ 
 | 
			
		||||
  
 | 
			
		||||
  public class ContextMenu: MenuBase
 | 
			
		||||
  {
 | 
			
		||||
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                 
 | 
			
		||||
    private long timer = 0;
 | 
			
		||||
    private Control sender = null; 
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Properties ////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
    protected internal Control Sender { get { return sender; } set { sender = value; } }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Construstors //////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////       
 | 
			
		||||
    public ContextMenu(Manager manager): base(manager)
 | 
			
		||||
    {      
 | 
			
		||||
      Visible = false;
 | 
			
		||||
      Detached = true;      
 | 
			
		||||
      StayOnBack = true;
 | 
			
		||||
      
 | 
			
		||||
      Manager.Input.MouseDown += new MouseEventHandler(Input_MouseDown);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Destructors ///////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected override void Dispose(bool disposing)
 | 
			
		||||
    {
 | 
			
		||||
      if (disposing)
 | 
			
		||||
      {
 | 
			
		||||
        Manager.Input.MouseDown -= Input_MouseDown;
 | 
			
		||||
      }
 | 
			
		||||
      base.Dispose(disposing);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion   
 | 
			
		||||
    
 | 
			
		||||
    #region //// Methods ///////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public override void Init()
 | 
			
		||||
    {      
 | 
			
		||||
      base.Init();      
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                          
 | 
			
		||||
    protected internal override void InitSkin()
 | 
			
		||||
    {
 | 
			
		||||
      base.InitSkin();
 | 
			
		||||
      Skin = new SkinControl(Manager.Skin.Controls["ContextMenu"]);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                          
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
 | 
			
		||||
    {                              
 | 
			
		||||
      base.DrawControl(renderer, rect, gameTime);
 | 
			
		||||
      
 | 
			
		||||
      SkinLayer l1 = Skin.Layers["Control"];
 | 
			
		||||
      SkinLayer l2 = Skin.Layers["Selection"];      
 | 
			
		||||
      
 | 
			
		||||
      int vsize = LineHeight();
 | 
			
		||||
      Color col = Color.White;
 | 
			
		||||
     
 | 
			
		||||
      for (int i = 0; i < Items.Count; i++)
 | 
			
		||||
      {
 | 
			
		||||
        int mod = i > 0 ? 2 : 0;
 | 
			
		||||
        int left = rect.Left + l1.ContentMargins.Left + vsize;
 | 
			
		||||
        int h = vsize - mod - (i < (Items.Count - 1) ? 1 : 0);
 | 
			
		||||
        int top = rect.Top + l1.ContentMargins.Top + (i * vsize) + mod;                
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        if (Items[i].Separated && i > 0)
 | 
			
		||||
        {
 | 
			
		||||
          Rectangle r = new Rectangle(left, rect.Top + l1.ContentMargins.Top + (i * vsize), LineWidth() - vsize + 4, 1);
 | 
			
		||||
          renderer.Draw(Manager.Skin.Controls["Control"].Layers[0].Image.Resource, r, l1.Text.Colors.Enabled);
 | 
			
		||||
        }
 | 
			
		||||
        if (ItemIndex != i)
 | 
			
		||||
        {                    
 | 
			
		||||
          if (Items[i].Enabled)
 | 
			
		||||
          {
 | 
			
		||||
            Rectangle r = new Rectangle(left, top, LineWidth() - vsize, h);        
 | 
			
		||||
            renderer.DrawString(this, l1, Items[i].Text, r, false);        
 | 
			
		||||
            col = l1.Text.Colors.Enabled;
 | 
			
		||||
          }
 | 
			
		||||
          else
 | 
			
		||||
          {
 | 
			
		||||
            Rectangle r = new Rectangle(left + l1.Text.OffsetX,
 | 
			
		||||
                                        top + l1.Text.OffsetY, 
 | 
			
		||||
                                        LineWidth() - vsize, h);
 | 
			
		||||
            renderer.DrawString(l1.Text.Font.Resource, Items[i].Text, r, l1.Text.Colors.Disabled, l1.Text.Alignment);
 | 
			
		||||
            col = l1.Text.Colors.Disabled;
 | 
			
		||||
          }  
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {    
 | 
			
		||||
          if (Items[i].Enabled)
 | 
			
		||||
          {                  
 | 
			
		||||
            Rectangle rs = new Rectangle(rect.Left + l1.ContentMargins.Left, 
 | 
			
		||||
                                         top, 
 | 
			
		||||
                                         Width - (l1.ContentMargins.Horizontal - Skin.OriginMargins.Horizontal), 
 | 
			
		||||
                                         h);
 | 
			
		||||
            renderer.DrawLayer(this, l2, rs);
 | 
			
		||||
 | 
			
		||||
            Rectangle r = new Rectangle(left,
 | 
			
		||||
                                        top, LineWidth() - vsize, h);
 | 
			
		||||
 | 
			
		||||
            renderer.DrawString(this, l2, Items[i].Text, r, false);
 | 
			
		||||
            col = l2.Text.Colors.Enabled;
 | 
			
		||||
          }  
 | 
			
		||||
          else
 | 
			
		||||
          {
 | 
			
		||||
            Rectangle rs = new Rectangle(rect.Left + l1.ContentMargins.Left,
 | 
			
		||||
                                         top,
 | 
			
		||||
                                         Width - (l1.ContentMargins.Horizontal - Skin.OriginMargins.Horizontal),
 | 
			
		||||
                                         vsize);
 | 
			
		||||
            renderer.DrawLayer(l2, rs, l2.States.Disabled.Color, l2.States.Disabled.Index);
 | 
			
		||||
            
 | 
			
		||||
            Rectangle r = new Rectangle(left + l1.Text.OffsetX,
 | 
			
		||||
                                        top + l1.Text.OffsetY,
 | 
			
		||||
                                        LineWidth() - vsize, h);
 | 
			
		||||
            renderer.DrawString(l2.Text.Font.Resource, Items[i].Text, r, l2.Text.Colors.Disabled, l2.Text.Alignment);
 | 
			
		||||
            col = l2.Text.Colors.Disabled;
 | 
			
		||||
          }
 | 
			
		||||
                    
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (Items[i].Image != null)
 | 
			
		||||
        {                     
 | 
			
		||||
          Rectangle r = new Rectangle(rect.Left + l1.ContentMargins.Left + 3, 
 | 
			
		||||
                                      rect.Top + top + 3, 
 | 
			
		||||
                                      LineHeight() - 6, 
 | 
			
		||||
                                      LineHeight() - 6);
 | 
			
		||||
          renderer.Draw(Items[i].Image, r, Color.White);
 | 
			
		||||
        }     
 | 
			
		||||
        
 | 
			
		||||
        if (Items[i].Items != null && Items[i].Items.Count > 0)
 | 
			
		||||
        {          
 | 
			
		||||
          renderer.Draw(Manager.Skin.Images["Shared.ArrowRight"].Resource, rect.Left + LineWidth() - 4, rect.Top + l1.ContentMargins.Top + (i * vsize) + 8, col);
 | 
			
		||||
        }     
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    private int LineHeight()
 | 
			
		||||
    {
 | 
			
		||||
      int h = 0;
 | 
			
		||||
      if (Items.Count > 0)
 | 
			
		||||
      {
 | 
			
		||||
        SkinLayer l = Skin.Layers["Control"];
 | 
			
		||||
        h = (int)l.Text.Font.Resource.LineSpacing + 9; 
 | 
			
		||||
      }
 | 
			
		||||
      return h;
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    private int LineWidth()
 | 
			
		||||
    {
 | 
			
		||||
      int w = 0;
 | 
			
		||||
      SkinFont font = Skin.Layers["Control"].Text.Font;
 | 
			
		||||
      if (Items.Count > 0)
 | 
			
		||||
      {
 | 
			
		||||
        for (int i = 0; i < Items.Count; i++)
 | 
			
		||||
        {
 | 
			
		||||
          int wx = (int)font.Resource.MeasureString(Items[i].Text).X + 16;
 | 
			
		||||
          if (wx > w) w = wx;
 | 
			
		||||
        }        
 | 
			
		||||
      }      
 | 
			
		||||
      
 | 
			
		||||
      w += 4 + LineHeight();
 | 
			
		||||
      
 | 
			
		||||
      return w;
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    private void AutoSize()
 | 
			
		||||
    {      
 | 
			
		||||
      SkinText font = Skin.Layers["Control"].Text;
 | 
			
		||||
      if (Items != null && Items.Count > 0)
 | 
			
		||||
      {        
 | 
			
		||||
        Height = (LineHeight() * Items.Count) + (Skin.Layers["Control"].ContentMargins.Vertical - Skin.OriginMargins.Vertical);        
 | 
			
		||||
        Width = LineWidth() + (Skin.Layers["Control"].ContentMargins.Horizontal - Skin.OriginMargins.Horizontal) + font.OffsetX; 
 | 
			
		||||
      }
 | 
			
		||||
      else
 | 
			
		||||
      {
 | 
			
		||||
        Height = 16;
 | 
			
		||||
        Width = 16;
 | 
			
		||||
      }    
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    private void TrackItem(int x, int y)
 | 
			
		||||
    {            
 | 
			
		||||
      if (Items != null && Items.Count > 0)
 | 
			
		||||
      {
 | 
			
		||||
        SkinText font = Skin.Layers["Control"].Text;
 | 
			
		||||
        int h = LineHeight();
 | 
			
		||||
        y -= Skin.Layers["Control"].ContentMargins.Top;
 | 
			
		||||
        int i = (int)((float)y / h);
 | 
			
		||||
        if (i < Items.Count)
 | 
			
		||||
        {
 | 
			
		||||
          if (i != ItemIndex && Items[i].Enabled)
 | 
			
		||||
          {
 | 
			
		||||
            if (ChildMenu != null)
 | 
			
		||||
            {
 | 
			
		||||
              this.HideMenu(false);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (i >= 0 && i != ItemIndex)
 | 
			
		||||
            {
 | 
			
		||||
              Items[i].SelectedInvoke(new EventArgs());              
 | 
			
		||||
            } 
 | 
			
		||||
            
 | 
			
		||||
            Focused = true;
 | 
			
		||||
            ItemIndex = i;  
 | 
			
		||||
            timer = (long)TimeSpan.FromTicks(DateTime.Now.Ticks).TotalMilliseconds;            
 | 
			
		||||
          }
 | 
			
		||||
          else if (!Items[i].Enabled && ChildMenu == null)
 | 
			
		||||
          {
 | 
			
		||||
            ItemIndex = -1;
 | 
			
		||||
          }                              
 | 
			
		||||
        }  
 | 
			
		||||
        Invalidate();      
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected override void OnMouseMove(MouseEventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      base.OnMouseMove(e);
 | 
			
		||||
      TrackItem(e.Position.X, e.Position.Y);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected internal override void Update(GameTime gameTime)
 | 
			
		||||
    {      
 | 
			
		||||
      base.Update(gameTime);
 | 
			
		||||
      
 | 
			
		||||
      AutoSize();
 | 
			
		||||
            
 | 
			
		||||
      long time = (long)TimeSpan.FromTicks(DateTime.Now.Ticks).TotalMilliseconds;            
 | 
			
		||||
     
 | 
			
		||||
      if (timer != 0 && time - timer >= Manager.MenuDelay && ItemIndex >= 0 && Items[ItemIndex].Items.Count > 0 && ChildMenu == null)
 | 
			
		||||
      {
 | 
			
		||||
        OnClick(new MouseEventArgs(new MouseState(), MouseButton.Left, Point.Zero));                  
 | 
			
		||||
      }  
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected override void OnMouseOut(MouseEventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      base.OnMouseOut(e);
 | 
			
		||||
            
 | 
			
		||||
      if (!CheckArea(e.State.X, e.State.Y) && ChildMenu == null)
 | 
			
		||||
      {
 | 
			
		||||
        ItemIndex = -1;
 | 
			
		||||
      }  
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected override void OnClick(EventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      if (sender != null && !(sender is MenuBase)) sender.Focused = true;   
 | 
			
		||||
      base.OnClick(e);
 | 
			
		||||
      timer = 0;
 | 
			
		||||
 | 
			
		||||
      MouseEventArgs ex = (e is MouseEventArgs) ? (MouseEventArgs)e : new MouseEventArgs();
 | 
			
		||||
 | 
			
		||||
      if (ex.Button == MouseButton.Left || ex.Button == MouseButton.None)
 | 
			
		||||
      {      
 | 
			
		||||
        if (ItemIndex >= 0 && Items[ItemIndex].Enabled)
 | 
			
		||||
        {
 | 
			
		||||
          if (ItemIndex >= 0 && Items[ItemIndex].Items != null && Items[ItemIndex].Items.Count > 0)
 | 
			
		||||
          {
 | 
			
		||||
            if (ChildMenu == null)
 | 
			
		||||
            {
 | 
			
		||||
              ChildMenu = new ContextMenu(Manager);         
 | 
			
		||||
              (ChildMenu as ContextMenu).RootMenu = this.RootMenu;
 | 
			
		||||
              (ChildMenu as ContextMenu).ParentMenu = this;
 | 
			
		||||
              (ChildMenu as ContextMenu).sender = sender;
 | 
			
		||||
              ChildMenu.Items.AddRange(Items[ItemIndex].Items);
 | 
			
		||||
              (ChildMenu as ContextMenu).AutoSize();                    
 | 
			
		||||
            }  
 | 
			
		||||
            int y = AbsoluteTop + Skin.Layers["Control"].ContentMargins.Top + (ItemIndex * LineHeight());
 | 
			
		||||
            (ChildMenu as ContextMenu).Show(sender, AbsoluteLeft + Width - 1, y);
 | 
			
		||||
            if (ex.Button == MouseButton.None) (ChildMenu as ContextMenu).ItemIndex = 0;
 | 
			
		||||
          }
 | 
			
		||||
          else
 | 
			
		||||
          {                                
 | 
			
		||||
            if (ItemIndex >= 0)
 | 
			
		||||
            {
 | 
			
		||||
              Items[ItemIndex].ClickInvoke(ex);
 | 
			
		||||
            }          
 | 
			
		||||
            if (RootMenu is ContextMenu) (RootMenu as ContextMenu).HideMenu(true);
 | 
			
		||||
            else if (RootMenu is MainMenu)
 | 
			
		||||
            {           
 | 
			
		||||
              (RootMenu as MainMenu).HideMenu();            
 | 
			
		||||
            }            
 | 
			
		||||
          }      
 | 
			
		||||
        }  
 | 
			
		||||
      }  
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected override void OnKeyPress(KeyEventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      base.OnKeyPress(e);
 | 
			
		||||
      
 | 
			
		||||
      timer = 0;
 | 
			
		||||
      
 | 
			
		||||
      if (e.Key == Keys.Down || (e.Key == Keys.Tab && !e.Shift))
 | 
			
		||||
      {
 | 
			
		||||
        e.Handled = true;
 | 
			
		||||
        ItemIndex += 1;
 | 
			
		||||
      }  
 | 
			
		||||
      
 | 
			
		||||
      if (e.Key == Keys.Up || (e.Key == Keys.Tab && e.Shift))
 | 
			
		||||
      {
 | 
			
		||||
        e.Handled = true;
 | 
			
		||||
        ItemIndex -=1;        
 | 
			
		||||
      }  
 | 
			
		||||
      
 | 
			
		||||
      if (ItemIndex > Items.Count - 1) ItemIndex = 0;            
 | 
			
		||||
      if (ItemIndex < 0) ItemIndex = Items.Count - 1;
 | 
			
		||||
      
 | 
			
		||||
      if (e.Key == Keys.Right && Items[ItemIndex].Items.Count > 0)
 | 
			
		||||
      {
 | 
			
		||||
        e.Handled = true;
 | 
			
		||||
        OnClick(new MouseEventArgs(new MouseState(), MouseButton.None, Point.Zero));
 | 
			
		||||
      }  
 | 
			
		||||
      if (e.Key == Keys.Left)
 | 
			
		||||
      {
 | 
			
		||||
        e.Handled = true;
 | 
			
		||||
        if (ParentMenu != null && ParentMenu is ContextMenu)
 | 
			
		||||
        {
 | 
			
		||||
          (ParentMenu as ContextMenu).Focused = true;
 | 
			
		||||
          (ParentMenu as ContextMenu).HideMenu(false);        
 | 
			
		||||
        }        
 | 
			
		||||
      }       
 | 
			
		||||
      if (e.Key == Keys.Escape)
 | 
			
		||||
      {
 | 
			
		||||
        e.Handled = true;
 | 
			
		||||
        if (ParentMenu != null) ParentMenu.Focused = true;        
 | 
			
		||||
        HideMenu(true);
 | 
			
		||||
      }  
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected override void OnGamePadPress(GamePadEventArgs e)
 | 
			
		||||
    {      
 | 
			
		||||
      timer = 0;      
 | 
			
		||||
 | 
			
		||||
      if (e.Button == GamePadButton.None) return;
 | 
			
		||||
      
 | 
			
		||||
      if (e.Button == GamePadActions.Down || e.Button == GamePadActions.NextControl)
 | 
			
		||||
      {
 | 
			
		||||
        e.Handled = true;
 | 
			
		||||
        ItemIndex += 1;
 | 
			
		||||
      }  
 | 
			
		||||
      else if (e.Button == GamePadActions.Up || e.Button == GamePadActions.PrevControl)
 | 
			
		||||
      {
 | 
			
		||||
        e.Handled = true;
 | 
			
		||||
        ItemIndex -= 1;
 | 
			
		||||
      }  
 | 
			
		||||
 | 
			
		||||
      if (ItemIndex > Items.Count - 1) ItemIndex = 0;
 | 
			
		||||
      if (ItemIndex < 0) ItemIndex = Items.Count - 1;
 | 
			
		||||
 | 
			
		||||
      if (e.Button == GamePadActions.Right && Items[ItemIndex].Items.Count > 0)
 | 
			
		||||
      {
 | 
			
		||||
        e.Handled = true;
 | 
			
		||||
        OnClick(new MouseEventArgs(new MouseState(), MouseButton.None, Point.Zero));
 | 
			
		||||
      }  
 | 
			
		||||
      if (e.Button == GamePadActions.Left)
 | 
			
		||||
      {
 | 
			
		||||
        e.Handled = true;
 | 
			
		||||
        if (ParentMenu != null && ParentMenu is ContextMenu)
 | 
			
		||||
        {
 | 
			
		||||
          (ParentMenu as ContextMenu).Focused = true;
 | 
			
		||||
          (ParentMenu as ContextMenu).HideMenu(false);
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
      
 | 
			
		||||
      base.OnGamePadPress(e);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public virtual void HideMenu(bool hideCurrent)
 | 
			
		||||
    {                
 | 
			
		||||
      if (hideCurrent)
 | 
			
		||||
      {
 | 
			
		||||
        Visible = false;
 | 
			
		||||
        ItemIndex = -1;                
 | 
			
		||||
      }  
 | 
			
		||||
      if (ChildMenu != null)
 | 
			
		||||
      {
 | 
			
		||||
        (ChildMenu as ContextMenu).HideMenu(true);
 | 
			
		||||
        ChildMenu.Dispose();
 | 
			
		||||
        ChildMenu = null;
 | 
			
		||||
      }                 
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public override void Show()
 | 
			
		||||
    {     
 | 
			
		||||
      Show(null, Left, Top);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public virtual void Show(Control sender, int x, int y)
 | 
			
		||||
    {
 | 
			
		||||
      AutoSize();
 | 
			
		||||
      base.Show();  
 | 
			
		||||
      if (!Initialized) Init();          
 | 
			
		||||
      if (sender != null && sender.Root != null && sender.Root is Container)
 | 
			
		||||
      {
 | 
			
		||||
        (sender.Root as Container).Add(this, false);
 | 
			
		||||
      }  
 | 
			
		||||
      else
 | 
			
		||||
      {
 | 
			
		||||
        Manager.Add(this);
 | 
			
		||||
      }
 | 
			
		||||
        
 | 
			
		||||
      this.sender = sender;
 | 
			
		||||
 | 
			
		||||
      if (sender != null && sender.Root != null && sender.Root is Container)
 | 
			
		||||
      {
 | 
			
		||||
        Left = x - Root.AbsoluteLeft;
 | 
			
		||||
        Top = y - Root.AbsoluteTop;                      
 | 
			
		||||
      }
 | 
			
		||||
      else
 | 
			
		||||
      {
 | 
			
		||||
        Left = x;
 | 
			
		||||
        Top = y;      
 | 
			
		||||
      }
 | 
			
		||||
      
 | 
			
		||||
      if (AbsoluteLeft + Width > Manager.TargetWidth)
 | 
			
		||||
      {
 | 
			
		||||
        Left = Left - Width;
 | 
			
		||||
        if (ParentMenu != null && ParentMenu is ContextMenu)
 | 
			
		||||
        {
 | 
			
		||||
          Left = Left - ParentMenu.Width + 2;
 | 
			
		||||
        }
 | 
			
		||||
        else if (ParentMenu != null)
 | 
			
		||||
        {
 | 
			
		||||
          Left = Manager.TargetWidth - (Parent != null ? Parent.AbsoluteLeft : 0) - Width - 2;
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
      if (AbsoluteTop + Height > Manager.TargetHeight)
 | 
			
		||||
      {
 | 
			
		||||
        Top = Top - Height;
 | 
			
		||||
        if (ParentMenu != null && ParentMenu is ContextMenu)
 | 
			
		||||
        {
 | 
			
		||||
          Top = Top + LineHeight();
 | 
			
		||||
        }
 | 
			
		||||
        else if (ParentMenu != null)
 | 
			
		||||
        {
 | 
			
		||||
          Top = ParentMenu.Top - Height - 1;
 | 
			
		||||
        }  
 | 
			
		||||
      }           
 | 
			
		||||
      
 | 
			
		||||
      Focused = true;
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
    private void  Input_MouseDown(object sender, MouseEventArgs e)
 | 
			
		||||
    {   
 | 
			
		||||
      if ((RootMenu is ContextMenu) && !(RootMenu as ContextMenu).CheckArea(e.Position.X, e.Position.Y) && Visible)
 | 
			
		||||
      {
 | 
			
		||||
        HideMenu(true);
 | 
			
		||||
      }
 | 
			
		||||
      else if ((RootMenu is MainMenu) && RootMenu.ChildMenu != null && !(RootMenu.ChildMenu as ContextMenu).CheckArea(e.Position.X, e.Position.Y) && Visible)
 | 
			
		||||
      {
 | 
			
		||||
        (RootMenu as MainMenu).HideMenu();
 | 
			
		||||
      }
 | 
			
		||||
    }        
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    private bool CheckArea(int x, int y)
 | 
			
		||||
    {
 | 
			
		||||
      if (Visible)
 | 
			
		||||
      {
 | 
			
		||||
        if (x <= AbsoluteLeft ||
 | 
			
		||||
            x >= AbsoluteLeft + Width ||
 | 
			
		||||
            y <= AbsoluteTop ||
 | 
			
		||||
            y >= AbsoluteTop + Height)
 | 
			
		||||
        {        
 | 
			
		||||
          bool ret = false;          
 | 
			
		||||
          if (ChildMenu != null)
 | 
			
		||||
          {
 | 
			
		||||
            ret = (ChildMenu as ContextMenu).CheckArea(x, y);
 | 
			
		||||
          }  
 | 
			
		||||
          return ret;
 | 
			
		||||
        }  
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
          return true;
 | 
			
		||||
        }        
 | 
			
		||||
      }
 | 
			
		||||
      else
 | 
			
		||||
      {
 | 
			
		||||
        return false;
 | 
			
		||||
      }      
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion  
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										3045
									
								
								Neoforce/Control.cs
									
									
									
									
									
								
							
							
						
						
									
										3045
									
								
								Neoforce/Control.cs
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -1,56 +0,0 @@
 | 
			
		||||
using Microsoft.Xna.Framework;
 | 
			
		||||
using Microsoft.Xna.Framework.Graphics;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Provides a basic Software cursor
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class Cursor
 | 
			
		||||
    {
 | 
			
		||||
        private Texture2D cursorTexture;
 | 
			
		||||
 | 
			
		||||
        public Texture2D CursorTexture
 | 
			
		||||
        {
 | 
			
		||||
            get { return cursorTexture;}
 | 
			
		||||
            set { cursorTexture = value; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        internal string cursorPath;
 | 
			
		||||
 | 
			
		||||
        private Vector2 hotspot;
 | 
			
		||||
        private int width;
 | 
			
		||||
        private int height;
 | 
			
		||||
 | 
			
		||||
        public int Height
 | 
			
		||||
        {
 | 
			
		||||
            get { return height; }
 | 
			
		||||
            set { height = value; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public int Width
 | 
			
		||||
        {
 | 
			
		||||
            get { return width; }
 | 
			
		||||
            set { width = value; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public Vector2 HotSpot
 | 
			
		||||
        {
 | 
			
		||||
            get { return hotspot; }
 | 
			
		||||
            set { hotspot = value; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public Cursor(string path, Vector2 hotspot, int width, int height)
 | 
			
		||||
        {
 | 
			
		||||
            this.cursorPath = path;
 | 
			
		||||
            this.hotspot = hotspot;
 | 
			
		||||
            this.width = width;
 | 
			
		||||
            this.height = height;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,53 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: Delegates.cs                                 //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
  #region //// Delegates /////////
 | 
			
		||||
  
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////  
 | 
			
		||||
  public delegate void DeviceEventHandler(DeviceEventArgs e);
 | 
			
		||||
  public delegate void SkinEventHandler(EventArgs e);  
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////  
 | 
			
		||||
  
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////  
 | 
			
		||||
  public delegate void EventHandler(object sender, EventArgs e);
 | 
			
		||||
  public delegate void MouseEventHandler(object sender, MouseEventArgs e);
 | 
			
		||||
  public delegate void KeyEventHandler(object sender, KeyEventArgs e);
 | 
			
		||||
  public delegate void GamePadEventHandler(object sender, GamePadEventArgs e);
 | 
			
		||||
  public delegate void DrawEventHandler(object sender, DrawEventArgs e);
 | 
			
		||||
  public delegate void MoveEventHandler(object sender, MoveEventArgs e);
 | 
			
		||||
  public delegate void ResizeEventHandler(object sender, ResizeEventArgs e);
 | 
			
		||||
  public delegate void WindowClosingEventHandler(object sender, WindowClosingEventArgs e);
 | 
			
		||||
  public delegate void WindowClosedEventHandler(object sender, WindowClosedEventArgs e);
 | 
			
		||||
  public delegate void ConsoleMessageEventHandler(object sender, ConsoleMessageEventArgs e);
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
  #endregion
 | 
			
		||||
  
 | 
			
		||||
}
 | 
			
		||||
@@ -1,148 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Central                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: Dialog.cs                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{ 
 | 
			
		||||
 | 
			
		||||
  public class Dialog: Window
 | 
			
		||||
  {
 | 
			
		||||
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                 
 | 
			
		||||
    private Panel pnlTop = null;
 | 
			
		||||
    private Label lblCapt = null;
 | 
			
		||||
    private Label lblDesc = null;    
 | 
			
		||||
    private Panel pnlBottom = null;
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Properties ////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
    public Panel TopPanel { get { return pnlTop; } }    
 | 
			
		||||
    public Panel BottomPanel { get { return pnlBottom; } }
 | 
			
		||||
    public Label Caption { get { return lblCapt; } }
 | 
			
		||||
    public Label Description { get { return lblDesc; } }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////       
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Events ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                         
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Construstors //////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////       
 | 
			
		||||
    public Dialog(Manager manager): base(manager)
 | 
			
		||||
    {                                      
 | 
			
		||||
      pnlTop = new Panel(manager);
 | 
			
		||||
      pnlTop.Anchor = Anchors.Left | Anchors.Top | Anchors.Right;     
 | 
			
		||||
      pnlTop.Init();      
 | 
			
		||||
      pnlTop.Parent = this;      
 | 
			
		||||
      pnlTop.Width = ClientWidth;
 | 
			
		||||
      pnlTop.Height = 64;      
 | 
			
		||||
      pnlTop.BevelBorder = BevelBorder.Bottom;      
 | 
			
		||||
   
 | 
			
		||||
      lblCapt = new Label(manager);    
 | 
			
		||||
      lblCapt.Init();
 | 
			
		||||
      lblCapt.Parent = pnlTop;     
 | 
			
		||||
      lblCapt.Width = lblCapt.Parent.ClientWidth - 16;      
 | 
			
		||||
      lblCapt.Text = "Caption";
 | 
			
		||||
      lblCapt.Left = 8;
 | 
			
		||||
      lblCapt.Top = 8;            
 | 
			
		||||
      lblCapt.Alignment = Alignment.TopLeft;      
 | 
			
		||||
      lblCapt.Anchor = Anchors.Left | Anchors.Top | Anchors.Right;                  
 | 
			
		||||
 | 
			
		||||
      lblDesc = new Label(manager);
 | 
			
		||||
      lblDesc.Init();      
 | 
			
		||||
      lblDesc.Parent = pnlTop;
 | 
			
		||||
      lblDesc.Width = lblDesc.Parent.ClientWidth - 16;      
 | 
			
		||||
      lblDesc.Left = 8;            
 | 
			
		||||
      lblDesc.Text = "Description text.";      
 | 
			
		||||
      lblDesc.Alignment = Alignment.TopLeft;      
 | 
			
		||||
      lblDesc.Anchor = Anchors.Left | Anchors.Top | Anchors.Right;                
 | 
			
		||||
 | 
			
		||||
      pnlBottom = new Panel(manager);
 | 
			
		||||
      pnlBottom.Init();
 | 
			
		||||
      pnlBottom.Parent = this;     
 | 
			
		||||
      pnlBottom.Width = ClientWidth;
 | 
			
		||||
      pnlBottom.Height = 24 + 16;
 | 
			
		||||
      pnlBottom.Top = ClientHeight - pnlBottom.Height;
 | 
			
		||||
      pnlBottom.BevelBorder = BevelBorder.Top;
 | 
			
		||||
      pnlBottom.Anchor = Anchors.Left | Anchors.Bottom | Anchors.Right;
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Methods ///////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public override void Init()
 | 
			
		||||
    {
 | 
			
		||||
      base.Init();
 | 
			
		||||
      
 | 
			
		||||
      SkinLayer lc = new SkinLayer(lblCapt.Skin.Layers[0]);
 | 
			
		||||
      lc.Text.Font.Resource = Manager.Skin.Fonts[Manager.Skin.Controls["Dialog"].Layers["TopPanel"].Attributes["CaptFont"].Value].Resource;
 | 
			
		||||
      lc.Text.Colors.Enabled = Utilities.ParseColor(Manager.Skin.Controls["Dialog"].Layers["TopPanel"].Attributes["CaptFontColor"].Value);
 | 
			
		||||
 | 
			
		||||
      SkinLayer ld = new SkinLayer(lblDesc.Skin.Layers[0]);
 | 
			
		||||
      ld.Text.Font.Resource = Manager.Skin.Fonts[Manager.Skin.Controls["Dialog"].Layers["TopPanel"].Attributes["DescFont"].Value].Resource;
 | 
			
		||||
      ld.Text.Colors.Enabled = Utilities.ParseColor(Manager.Skin.Controls["Dialog"].Layers["TopPanel"].Attributes["DescFontColor"].Value);
 | 
			
		||||
      
 | 
			
		||||
      pnlTop.Color = Utilities.ParseColor(Manager.Skin.Controls["Dialog"].Layers["TopPanel"].Attributes["Color"].Value);
 | 
			
		||||
      pnlTop.BevelMargin = int.Parse(Manager.Skin.Controls["Dialog"].Layers["TopPanel"].Attributes["BevelMargin"].Value);
 | 
			
		||||
      pnlTop.BevelStyle = Utilities.ParseBevelStyle(Manager.Skin.Controls["Dialog"].Layers["TopPanel"].Attributes["BevelStyle"].Value);
 | 
			
		||||
 | 
			
		||||
      lblCapt.Skin = new SkinControl(lblCapt.Skin);            
 | 
			
		||||
      lblCapt.Skin.Layers[0] = lc;      
 | 
			
		||||
      lblCapt.Height = Manager.Skin.Fonts[Manager.Skin.Controls["Dialog"].Layers["TopPanel"].Attributes["CaptFont"].Value].Height;            
 | 
			
		||||
      
 | 
			
		||||
      lblDesc.Skin = new SkinControl(lblDesc.Skin);
 | 
			
		||||
      lblDesc.Skin.Layers[0] = ld;
 | 
			
		||||
      lblDesc.Height = Manager.Skin.Fonts[Manager.Skin.Controls["Dialog"].Layers["TopPanel"].Attributes["DescFont"].Value].Height;
 | 
			
		||||
      lblDesc.Top = lblCapt.Top + lblCapt.Height + 4;  
 | 
			
		||||
      lblDesc.Height = lblDesc.Parent.ClientHeight - lblDesc.Top - 8;      
 | 
			
		||||
    
 | 
			
		||||
      pnlBottom.Color = Utilities.ParseColor(Manager.Skin.Controls["Dialog"].Layers["BottomPanel"].Attributes["Color"].Value);
 | 
			
		||||
      pnlBottom.BevelMargin = int.Parse(Manager.Skin.Controls["Dialog"].Layers["BottomPanel"].Attributes["BevelMargin"].Value);
 | 
			
		||||
      pnlBottom.BevelStyle = Utilities.ParseBevelStyle(Manager.Skin.Controls["Dialog"].Layers["BottomPanel"].Attributes["BevelStyle"].Value);      
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,93 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: Disposable.cs                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
using System;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
  public abstract class Disposable: Unknown, IDisposable
 | 
			
		||||
  {
 | 
			
		||||
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    private static int count = 0;
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Properties ////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public static int Count { get { return count; } }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Constructors //////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected Disposable()
 | 
			
		||||
    {
 | 
			
		||||
      count += 1;
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
    
 | 
			
		||||
    #region //// Destructors ///////
 | 
			
		||||
 | 
			
		||||
    //////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    ~Disposable()
 | 
			
		||||
    {      
 | 
			
		||||
      Dispose(false);
 | 
			
		||||
    }
 | 
			
		||||
    //////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    //////////////////////////////////////////////////////////////////////////	  	  
 | 
			
		||||
    public void Dispose()
 | 
			
		||||
    {
 | 
			
		||||
      Dispose(true);
 | 
			
		||||
      GC.SuppressFinalize(this);
 | 
			
		||||
    }
 | 
			
		||||
    //////////////////////////////////////////////////////////////////////////	  	  	  
 | 
			
		||||
 | 
			
		||||
    //////////////////////////////////////////////////////////////////////////	  	  	  
 | 
			
		||||
    protected virtual void Dispose(bool disposing)
 | 
			
		||||
    {
 | 
			
		||||
      if (disposing)
 | 
			
		||||
      {
 | 
			
		||||
        count -= 1;                
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    //////////////////////////////////////////////////////////////////////////	  	  	  	  	 
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
}
 | 
			
		||||
@@ -1,427 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: EventArgs.cs                                 //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
using Microsoft.Xna.Framework;
 | 
			
		||||
using Microsoft.Xna.Framework.Input;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
  #region //// Classes ///////////
 | 
			
		||||
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
  public class EventArgs: System.EventArgs
 | 
			
		||||
  {
 | 
			
		||||
  
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public bool Handled = false; 
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
    
 | 
			
		||||
    #region //// Consructors ///////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public EventArgs()
 | 
			
		||||
    {              
 | 
			
		||||
    } 
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion    
 | 
			
		||||
  }
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
  public class KeyEventArgs: EventArgs
 | 
			
		||||
  {
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public Keys Key = Keys.None;
 | 
			
		||||
    public bool Control = false;
 | 
			
		||||
    public bool Shift = false;
 | 
			
		||||
    public bool Alt = false;   
 | 
			
		||||
    public bool Caps = false;  
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
		#region //// Constructors //////
 | 
			
		||||
			
 | 
			
		||||
		////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
		public KeyEventArgs()
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public KeyEventArgs(Keys key)
 | 
			
		||||
    {
 | 
			
		||||
      Key = key;
 | 
			
		||||
      Control = false;
 | 
			
		||||
      Shift = false;
 | 
			
		||||
      Alt = false;
 | 
			
		||||
      Caps = false;      
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public KeyEventArgs(Keys key, bool control, bool shift, bool alt, bool caps)
 | 
			
		||||
    {
 | 
			
		||||
      Key = key;
 | 
			
		||||
      Control = control;
 | 
			
		||||
      Shift = shift;
 | 
			
		||||
      Alt = alt;
 | 
			
		||||
      Caps = caps;  
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
			
 | 
			
		||||
		#endregion  
 | 
			
		||||
	}
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
  public class MouseEventArgs: EventArgs
 | 
			
		||||
  {
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public MouseState State = new MouseState();
 | 
			
		||||
    public MouseButton Button = MouseButton.None;
 | 
			
		||||
    public Point Position = new Point(0, 0);
 | 
			
		||||
    public Point Difference = new Point(0, 0);
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Mouse scroll direction
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public MouseScrollDirection ScrollDirection = MouseScrollDirection.None;
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Constructors //////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public MouseEventArgs()
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public MouseEventArgs(MouseState state, MouseButton button, Point position)
 | 
			
		||||
    {
 | 
			
		||||
      State = state;
 | 
			
		||||
      Button = button;
 | 
			
		||||
      Position = position;
 | 
			
		||||
    } 
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Creates a new initialized instace of the MouseEventArgs class.
 | 
			
		||||
    /// <param name="state">Mouse state at the time of the event.</param>
 | 
			
		||||
    /// <param name="button">Mouse button state at the time of the event.</param>
 | 
			
		||||
    /// <param name="position">Mosue cursor position at the time of the event.</param>
 | 
			
		||||
    /// <param name="scrollDirection">Mouse scroll direction at the time of the event.</param>
 | 
			
		||||
    public MouseEventArgs(MouseState state, MouseButton button, Point position, MouseScrollDirection scrollDirection)
 | 
			
		||||
        : this(state, button, position)
 | 
			
		||||
    {
 | 
			
		||||
        ScrollDirection = scrollDirection;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public MouseEventArgs(MouseEventArgs e)
 | 
			
		||||
        : this(e.State, e.Button, e.Position)
 | 
			
		||||
    {
 | 
			
		||||
      Difference = e.Difference;
 | 
			
		||||
      ScrollDirection = e.ScrollDirection;
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
  }
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
  public class GamePadEventArgs : EventArgs
 | 
			
		||||
  {
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public PlayerIndex PlayerIndex = PlayerIndex.One;
 | 
			
		||||
    public GamePadState State = new GamePadState();
 | 
			
		||||
    public GamePadButton Button = GamePadButton.None;   
 | 
			
		||||
    public GamePadVectors Vectors;    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Constructors //////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
   /*
 | 
			
		||||
    public GamePadEventArgs()
 | 
			
		||||
    {                      
 | 
			
		||||
    }*/
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public GamePadEventArgs(PlayerIndex playerIndex)
 | 
			
		||||
    {
 | 
			
		||||
      PlayerIndex = playerIndex;    
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public GamePadEventArgs(PlayerIndex playerIndex, GamePadButton button)
 | 
			
		||||
    {
 | 
			
		||||
      PlayerIndex = playerIndex;
 | 
			
		||||
      Button = button;
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
  }
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
  public class DrawEventArgs: EventArgs
 | 
			
		||||
  {
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public Renderer Renderer = null;
 | 
			
		||||
    public Rectangle Rectangle = Rectangle.Empty;
 | 
			
		||||
    public GameTime GameTime = null; 
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Constructors //////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public DrawEventArgs()
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public DrawEventArgs(Renderer renderer, Rectangle rectangle, GameTime gameTime)
 | 
			
		||||
    {
 | 
			
		||||
      Renderer = renderer;
 | 
			
		||||
      Rectangle = rectangle;
 | 
			
		||||
      GameTime = gameTime;
 | 
			
		||||
    } 
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
  }
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
  public class ResizeEventArgs: EventArgs
 | 
			
		||||
  {
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public int Width = 0;
 | 
			
		||||
    public int Height = 0;
 | 
			
		||||
    public int OldWidth = 0;
 | 
			
		||||
    public int OldHeight = 0; 
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Constructors //////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public ResizeEventArgs()
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public ResizeEventArgs(int width, int height, int oldWidth, int oldHeight)
 | 
			
		||||
    {
 | 
			
		||||
      Width = width;
 | 
			
		||||
      Height = height;
 | 
			
		||||
      OldWidth = oldWidth;
 | 
			
		||||
      OldHeight = oldHeight;
 | 
			
		||||
    }  
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion    
 | 
			
		||||
  }
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
  public class MoveEventArgs: EventArgs
 | 
			
		||||
  {
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public int Left = 0;
 | 
			
		||||
    public int Top = 0;
 | 
			
		||||
    public int OldLeft = 0;
 | 
			
		||||
    public int OldTop = 0; 
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Constructors //////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public MoveEventArgs()
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public MoveEventArgs(int left, int top, int oldLeft, int oldTop)
 | 
			
		||||
    {
 | 
			
		||||
      Left = left;
 | 
			
		||||
      Top = top;
 | 
			
		||||
      OldLeft = oldLeft;
 | 
			
		||||
      OldTop = oldTop;
 | 
			
		||||
    } 
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
  }
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////  
 | 
			
		||||
  
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
  public class DeviceEventArgs: EventArgs
 | 
			
		||||
  {
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public PreparingDeviceSettingsEventArgs DeviceSettings = null;
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Constructors //////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public DeviceEventArgs()
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public DeviceEventArgs(PreparingDeviceSettingsEventArgs deviceSettings)
 | 
			
		||||
    {
 | 
			
		||||
      DeviceSettings = deviceSettings;
 | 
			
		||||
    } 
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
  }
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
  public class WindowClosingEventArgs: EventArgs
 | 
			
		||||
  {
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public bool Cancel = false;
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
    
 | 
			
		||||
    #region //// Consructors ///////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public WindowClosingEventArgs()
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
  }
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////	
 | 
			
		||||
  
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
  public class WindowClosedEventArgs: EventArgs
 | 
			
		||||
  {
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public bool Dispose = false;
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Consructors ///////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public WindowClosedEventArgs()
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
  }
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////						
 | 
			
		||||
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
  public class ConsoleMessageEventArgs : EventArgs
 | 
			
		||||
  {
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public ConsoleMessage Message;
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Consructors ///////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public ConsoleMessageEventArgs()
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public ConsoleMessageEventArgs(ConsoleMessage message)
 | 
			
		||||
    {
 | 
			
		||||
      Message = message;
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
  }
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////						
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  #endregion
 | 
			
		||||
  
 | 
			
		||||
}
 | 
			
		||||
@@ -1,146 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: EventedList.cs                               //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
using System;
 | 
			
		||||
using Microsoft.Xna.Framework;
 | 
			
		||||
using Microsoft.Xna.Framework.Graphics;
 | 
			
		||||
using System.Collections;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{ 
 | 
			
		||||
   
 | 
			
		||||
  public class EventedList<T>: List<T>
 | 
			
		||||
  {
 | 
			
		||||
 | 
			
		||||
    #region //// Events ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public event EventHandler ItemAdded;
 | 
			
		||||
    public event EventHandler ItemRemoved; 
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
         
 | 
			
		||||
  	#region //// Constructors //////
 | 
			
		||||
			
 | 
			
		||||
		////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
		public EventedList(): base() {}
 | 
			
		||||
		public EventedList(int capacity): base(capacity) {}
 | 
			
		||||
		public EventedList(IEnumerable<T> collection): base(collection) {}
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////               
 | 
			
		||||
 | 
			
		||||
    #endregion  
 | 
			
		||||
        
 | 
			
		||||
    #region //// Methods ///////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public new void Add(T item)
 | 
			
		||||
    {
 | 
			
		||||
      int c = this.Count;
 | 
			
		||||
      base.Add(item);
 | 
			
		||||
      if (ItemAdded != null && c != this.Count) ItemAdded.Invoke(this, new EventArgs());      
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public new void Remove(T obj)
 | 
			
		||||
    {
 | 
			
		||||
      int c = this.Count;
 | 
			
		||||
      base.Remove(obj);
 | 
			
		||||
      if (ItemRemoved != null && c != this.Count) ItemRemoved.Invoke(this, new EventArgs());
 | 
			
		||||
    } 
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
    public new void Clear()
 | 
			
		||||
    {
 | 
			
		||||
      int c = this.Count;
 | 
			
		||||
      base.Clear();
 | 
			
		||||
      if (ItemRemoved != null && c != this.Count) ItemRemoved.Invoke(this, new EventArgs());            
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public new void AddRange(IEnumerable<T> collection)
 | 
			
		||||
    {
 | 
			
		||||
      int c = this.Count;
 | 
			
		||||
      base.AddRange(collection);
 | 
			
		||||
      if (ItemAdded != null && c != this.Count) ItemAdded.Invoke(this, new EventArgs());      
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
    public new void Insert(int index, T item)
 | 
			
		||||
    {
 | 
			
		||||
      int c = this.Count;
 | 
			
		||||
      base.Insert(index, item);
 | 
			
		||||
      if (ItemAdded != null && c != this.Count) ItemAdded.Invoke(this, new EventArgs());            
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
    public new void InsertRange(int index, IEnumerable<T> collection)
 | 
			
		||||
    {
 | 
			
		||||
      int c = this.Count;
 | 
			
		||||
      base.InsertRange(index, collection);
 | 
			
		||||
      if (ItemAdded != null && c != this.Count) ItemAdded.Invoke(this, new EventArgs());
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public new int RemoveAll(Predicate<T> match)
 | 
			
		||||
    {
 | 
			
		||||
      int c = this.Count;
 | 
			
		||||
      int ret = base.RemoveAll(match);
 | 
			
		||||
      if (ItemRemoved != null && c != this.Count) ItemRemoved.Invoke(this, new EventArgs());                        
 | 
			
		||||
      return ret;
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public new void RemoveAt(int index)
 | 
			
		||||
    {
 | 
			
		||||
      int c = this.Count;
 | 
			
		||||
      base.RemoveAt(index);
 | 
			
		||||
      if (ItemRemoved != null && c != this.Count) ItemRemoved.Invoke(this, new EventArgs());            
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public new void RemoveRange(int index, int count)
 | 
			
		||||
    {
 | 
			
		||||
      int c = this.Count;
 | 
			
		||||
      base.RemoveRange(index, count);      
 | 
			
		||||
      if (ItemRemoved != null && c != this.Count) ItemRemoved.Invoke(this, new EventArgs());
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////        
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,130 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Central                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: ExitDialog.cs                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{ 
 | 
			
		||||
 | 
			
		||||
  public class ExitDialog: Dialog
 | 
			
		||||
  {
 | 
			
		||||
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                 
 | 
			
		||||
    public Button btnYes;
 | 
			
		||||
    public Button btnNo;
 | 
			
		||||
    private Label lblMessage;
 | 
			
		||||
    private ImageBox imgIcon;
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Properties ////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////       
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Events ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                         
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Construstors //////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////       
 | 
			
		||||
    public ExitDialog(Manager manager): base(manager)
 | 
			
		||||
    {
 | 
			
		||||
      string msg = "Do you really want to exit " + Manager.Game.Window.Title + "?";
 | 
			
		||||
      ClientWidth = (int)Manager.Skin.Controls["Label"].Layers[0].Text.Font.Resource.MeasureString(msg).X + 48 + 16 + 16 + 16;                         
 | 
			
		||||
      ClientHeight = 120;
 | 
			
		||||
      TopPanel.Visible = false;
 | 
			
		||||
      IconVisible = true;      
 | 
			
		||||
      Resizable = false;
 | 
			
		||||
      Text = Manager.Game.Window.Title;
 | 
			
		||||
      Center();   
 | 
			
		||||
            
 | 
			
		||||
      imgIcon = new ImageBox(Manager);
 | 
			
		||||
      imgIcon.Init();
 | 
			
		||||
      imgIcon.Image = Manager.Skin.Images["Icon.Question"].Resource;
 | 
			
		||||
      imgIcon.Left = 16;
 | 
			
		||||
      imgIcon.Top = 16;
 | 
			
		||||
      imgIcon.Width = 48;
 | 
			
		||||
      imgIcon.Height = 48;
 | 
			
		||||
      imgIcon.SizeMode = SizeMode.Stretched;
 | 
			
		||||
      
 | 
			
		||||
      lblMessage = new Label(Manager);      
 | 
			
		||||
      lblMessage.Init();            
 | 
			
		||||
      
 | 
			
		||||
      lblMessage.Left = 80;
 | 
			
		||||
      lblMessage.Top = 16;
 | 
			
		||||
      lblMessage.Width = ClientWidth - lblMessage.Left;
 | 
			
		||||
      lblMessage.Height = 48;
 | 
			
		||||
      lblMessage.Alignment = Alignment.TopLeft;
 | 
			
		||||
      lblMessage.Text = msg;
 | 
			
		||||
      
 | 
			
		||||
      btnYes = new Button(Manager);
 | 
			
		||||
      btnYes.Init();      
 | 
			
		||||
      btnYes.Left = (BottomPanel.ClientWidth / 2) - btnYes.Width - 4;
 | 
			
		||||
      btnYes.Top = 8;
 | 
			
		||||
      btnYes.Text = "Yes";      
 | 
			
		||||
      btnYes.ModalResult = ModalResult.Yes;
 | 
			
		||||
 | 
			
		||||
      btnNo = new Button(Manager);
 | 
			
		||||
      btnNo.Init();
 | 
			
		||||
      btnNo.Left = (BottomPanel.ClientWidth / 2) + 4;
 | 
			
		||||
      btnNo.Top = 8;
 | 
			
		||||
      btnNo.Text = "No";
 | 
			
		||||
      btnNo.ModalResult = ModalResult.No;            
 | 
			
		||||
 | 
			
		||||
      Add(imgIcon);                                      
 | 
			
		||||
      Add(lblMessage);
 | 
			
		||||
      BottomPanel.Add(btnYes);
 | 
			
		||||
      BottomPanel.Add(btnNo);
 | 
			
		||||
 | 
			
		||||
      DefaultControl = btnNo;
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Methods ///////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public override void Init()
 | 
			
		||||
    {
 | 
			
		||||
      base.Init();                
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										84
									
								
								Neoforce/External/Zip/Crc32.cs
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										84
									
								
								Neoforce/External/Zip/Crc32.cs
									
									
									
									
										vendored
									
									
								
							@@ -1,84 +0,0 @@
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.External.Zip
 | 
			
		||||
{
 | 
			
		||||
   internal class CRC32
 | 
			
		||||
   {      
 | 
			
		||||
      private UInt32[] crc32Table;
 | 
			
		||||
      private const int BUFFER_SIZE = 8192;
 | 
			
		||||
     
 | 
			
		||||
     private Int32 _TotalBytesRead= 0; 
 | 
			
		||||
     public Int32 TotalBytesRead {
 | 
			
		||||
       get {
 | 
			
		||||
	 return _TotalBytesRead;
 | 
			
		||||
       }
 | 
			
		||||
     }
 | 
			
		||||
 | 
			
		||||
      public UInt32 GetCrc32(System.IO.Stream input)
 | 
			
		||||
      {
 | 
			
		||||
	return GetCrc32AndCopy(input, null) ;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      public UInt32 GetCrc32AndCopy(System.IO.Stream input, System.IO.Stream output)
 | 
			
		||||
      {
 | 
			
		||||
         unchecked
 | 
			
		||||
         {
 | 
			
		||||
            UInt32 crc32Result;
 | 
			
		||||
            crc32Result = 0xFFFFFFFF;
 | 
			
		||||
            byte[] buffer = new byte[BUFFER_SIZE];
 | 
			
		||||
            int readSize = BUFFER_SIZE;
 | 
			
		||||
 | 
			
		||||
	    _TotalBytesRead= 0;
 | 
			
		||||
            int count = input.Read(buffer, 0, readSize);
 | 
			
		||||
	    if (output != null) output.Write(buffer,0,count); 
 | 
			
		||||
	    _TotalBytesRead += count;
 | 
			
		||||
            while (count > 0)
 | 
			
		||||
            {
 | 
			
		||||
               for (int i = 0; i < count; i++)
 | 
			
		||||
               {
 | 
			
		||||
                  crc32Result = ((crc32Result) >> 8) ^ crc32Table[(buffer[i]) ^ ((crc32Result) & 0x000000FF)];
 | 
			
		||||
               }
 | 
			
		||||
               count = input.Read(buffer, 0, readSize);
 | 
			
		||||
	       if (output != null) output.Write(buffer,0,count); 
 | 
			
		||||
	       _TotalBytesRead += count;
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
            return ~crc32Result;
 | 
			
		||||
         }
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
      public CRC32()
 | 
			
		||||
      {
 | 
			
		||||
         unchecked
 | 
			
		||||
         {
 | 
			
		||||
            // This is the official polynomial used by CRC32 in PKZip.
 | 
			
		||||
            // Often the polynomial is shown reversed as 0x04C11DB7.
 | 
			
		||||
            UInt32 dwPolynomial = 0xEDB88320;
 | 
			
		||||
            UInt32 i, j;
 | 
			
		||||
 | 
			
		||||
            crc32Table = new UInt32[256];
 | 
			
		||||
 | 
			
		||||
            UInt32 dwCrc;
 | 
			
		||||
            for(i = 0; i < 256; i++)
 | 
			
		||||
            {
 | 
			
		||||
               dwCrc = i;
 | 
			
		||||
               for(j = 8; j > 0; j--)
 | 
			
		||||
               {
 | 
			
		||||
                  if ((dwCrc & 1)==1)
 | 
			
		||||
                  {
 | 
			
		||||
                     dwCrc = (dwCrc >> 1) ^ dwPolynomial;
 | 
			
		||||
                  }
 | 
			
		||||
                  else
 | 
			
		||||
                  {
 | 
			
		||||
                     dwCrc >>= 1;
 | 
			
		||||
                  }
 | 
			
		||||
               }
 | 
			
		||||
               crc32Table[i] = dwCrc;
 | 
			
		||||
            }
 | 
			
		||||
         }
 | 
			
		||||
      }
 | 
			
		||||
   }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										112
									
								
								Neoforce/External/Zip/Shared.cs
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										112
									
								
								Neoforce/External/Zip/Shared.cs
									
									
									
									
										vendored
									
									
								
							@@ -1,112 +0,0 @@
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.External.Zip
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	internal class Shared
 | 
			
		||||
    {
 | 
			
		||||
        protected internal static string StringFromBuffer(byte[] buf, int start, int maxlength)
 | 
			
		||||
        {
 | 
			
		||||
            int i;
 | 
			
		||||
            char[] c = new char[maxlength];
 | 
			
		||||
            for (i = 0; (i < maxlength) && (i < buf.Length) && (buf[i] != 0); i++)
 | 
			
		||||
            {
 | 
			
		||||
                c[i] = (char)buf[i]; // System.BitConverter.ToChar(buf, start+i*2);
 | 
			
		||||
            }
 | 
			
		||||
            string s = new System.String(c, 0, i);
 | 
			
		||||
            return s;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        protected internal static int ReadSignature(System.IO.Stream s)
 | 
			
		||||
        {
 | 
			
		||||
            int n = 0;
 | 
			
		||||
            byte[] sig = new byte[4];
 | 
			
		||||
            n = s.Read(sig, 0, sig.Length);
 | 
			
		||||
            if (n != sig.Length) throw new Exception("Could not read signature - no data!");
 | 
			
		||||
            int signature = (((sig[3] * 256 + sig[2]) * 256) + sig[1]) * 256 + sig[0];
 | 
			
		||||
            return signature;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        protected internal static long FindSignature(System.IO.Stream s, int SignatureToFind)
 | 
			
		||||
        {
 | 
			
		||||
            long startingPosition = s.Position;
 | 
			
		||||
 | 
			
		||||
            int BATCH_SIZE = 1024;
 | 
			
		||||
            byte[] targetBytes = new byte[4];
 | 
			
		||||
            targetBytes[0] = (byte) (SignatureToFind >> 24);
 | 
			
		||||
            targetBytes[1] = (byte) ((SignatureToFind & 0x00FF0000) >> 16);
 | 
			
		||||
            targetBytes[2] = (byte) ((SignatureToFind & 0x0000FF00) >> 8);
 | 
			
		||||
            targetBytes[3] = (byte) (SignatureToFind & 0x000000FF);
 | 
			
		||||
            byte[] batch = new byte[BATCH_SIZE];
 | 
			
		||||
            int n = 0;
 | 
			
		||||
            bool success = false;
 | 
			
		||||
            do
 | 
			
		||||
            {
 | 
			
		||||
                n = s.Read(batch, 0, batch.Length);
 | 
			
		||||
                if (n != 0)
 | 
			
		||||
                {
 | 
			
		||||
                    for (int i = 0; i < n; i++)
 | 
			
		||||
                    {
 | 
			
		||||
                        if (batch[i] == targetBytes[3])
 | 
			
		||||
                        {
 | 
			
		||||
                            s.Seek(i - n, System.IO.SeekOrigin.Current);
 | 
			
		||||
                            int sig = ReadSignature(s);
 | 
			
		||||
                            success = (sig == SignatureToFind);
 | 
			
		||||
                            if (!success) s.Seek(-3, System.IO.SeekOrigin.Current);
 | 
			
		||||
                            break; // out of for loop
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                else break;
 | 
			
		||||
                if (success) break;
 | 
			
		||||
            } while (true);
 | 
			
		||||
            if (!success)
 | 
			
		||||
            {
 | 
			
		||||
                s.Seek(startingPosition, System.IO.SeekOrigin.Begin);
 | 
			
		||||
                return -1;  // or throw?
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // subtract 4 for the signature.
 | 
			
		||||
            long bytesRead = (s.Position - startingPosition) - 4 ;
 | 
			
		||||
            // number of bytes read, should be the same as compressed size of file            
 | 
			
		||||
            return bytesRead;   
 | 
			
		||||
        }
 | 
			
		||||
        protected internal static DateTime PackedToDateTime(Int32 packedDateTime)
 | 
			
		||||
        {
 | 
			
		||||
            Int16 packedTime = (Int16)(packedDateTime & 0x0000ffff);
 | 
			
		||||
            Int16 packedDate = (Int16)((packedDateTime & 0xffff0000) >> 16);
 | 
			
		||||
 | 
			
		||||
            int year = 1980 + ((packedDate & 0xFE00) >> 9);
 | 
			
		||||
            int month = (packedDate & 0x01E0) >> 5;
 | 
			
		||||
            int day = packedDate & 0x001F;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            int hour = (packedTime & 0xF800) >> 11;
 | 
			
		||||
            int minute = (packedTime & 0x07E0) >> 5;
 | 
			
		||||
            int second = packedTime & 0x001F;
 | 
			
		||||
 | 
			
		||||
            DateTime d = System.DateTime.Now;
 | 
			
		||||
            try { d = new System.DateTime(year, month, day, hour, minute, second, 0); }
 | 
			
		||||
            catch
 | 
			
		||||
            {
 | 
			
		||||
                Console.Write("\nInvalid date/time?:\nyear: {0} ", year);
 | 
			
		||||
                Console.Write("month: {0} ", month);
 | 
			
		||||
                Console.WriteLine("day: {0} ", day);
 | 
			
		||||
                Console.WriteLine("HH:MM:SS= {0}:{1}:{2}", hour, minute, second);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return d;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        protected internal static Int32 DateTimeToPacked(DateTime time)
 | 
			
		||||
        {
 | 
			
		||||
            UInt16 packedDate = (UInt16)((time.Day & 0x0000001F) | ((time.Month << 5) & 0x000001E0) | (((time.Year - 1980) << 9) & 0x0000FE00));
 | 
			
		||||
            UInt16 packedTime = (UInt16)((time.Second & 0x0000001F) | ((time.Minute << 5) & 0x000007E0) | ((time.Hour << 11) & 0x0000F800));
 | 
			
		||||
            return (Int32)(((UInt32)(packedDate << 16)) | packedTime);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										149
									
								
								Neoforce/External/Zip/ZipDirEntry.cs
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										149
									
								
								Neoforce/External/Zip/ZipDirEntry.cs
									
									
									
									
										vendored
									
									
								
							@@ -1,149 +0,0 @@
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.External.Zip
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    internal class ZipDirEntry
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        internal const int ZipDirEntrySignature = 0x02014b50;
 | 
			
		||||
 | 
			
		||||
        private bool _Debug = false;
 | 
			
		||||
 | 
			
		||||
        private ZipDirEntry() { }
 | 
			
		||||
 | 
			
		||||
        private DateTime _LastModified;
 | 
			
		||||
        public DateTime LastModified
 | 
			
		||||
        {
 | 
			
		||||
            get { return _LastModified; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private string _FileName;
 | 
			
		||||
        public string FileName
 | 
			
		||||
        {
 | 
			
		||||
            get { return _FileName; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private string _Comment;
 | 
			
		||||
        public string Comment
 | 
			
		||||
        {
 | 
			
		||||
            get { return _Comment; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private Int16 _VersionMadeBy;
 | 
			
		||||
        public Int16 VersionMadeBy
 | 
			
		||||
        {
 | 
			
		||||
            get { return _VersionMadeBy; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private Int16 _VersionNeeded;
 | 
			
		||||
        public Int16 VersionNeeded
 | 
			
		||||
        {
 | 
			
		||||
            get { return _VersionNeeded; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private Int16 _CompressionMethod;
 | 
			
		||||
        public Int16 CompressionMethod
 | 
			
		||||
        {
 | 
			
		||||
            get { return _CompressionMethod; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private Int32 _CompressedSize;
 | 
			
		||||
        public Int32 CompressedSize
 | 
			
		||||
        {
 | 
			
		||||
            get { return _CompressedSize; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private Int32 _UncompressedSize;
 | 
			
		||||
        public Int32 UncompressedSize
 | 
			
		||||
        {
 | 
			
		||||
            get { return _UncompressedSize; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public Double CompressionRatio
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                return 100 * (1.0 - (1.0 * CompressedSize) / (1.0 * UncompressedSize));
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private Int16 _BitField;
 | 
			
		||||
        private Int32 _LastModDateTime;
 | 
			
		||||
 | 
			
		||||
        private Int32 _Crc32;
 | 
			
		||||
        private byte[] _Extra;
 | 
			
		||||
 | 
			
		||||
        internal ZipDirEntry(ZipEntry ze) { }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        internal static ZipDirEntry Read(System.IO.Stream s)
 | 
			
		||||
        {
 | 
			
		||||
            return Read(s, false);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        internal static ZipDirEntry Read(System.IO.Stream s, bool TurnOnDebug)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
            int signature = TomShane.Neoforce.External.Zip.Shared.ReadSignature(s);
 | 
			
		||||
            // return null if this is not a local file header signature
 | 
			
		||||
            if (SignatureIsNotValid(signature))
 | 
			
		||||
            {
 | 
			
		||||
                s.Seek(-4, System.IO.SeekOrigin.Current);
 | 
			
		||||
                if (TurnOnDebug) System.Console.WriteLine("  ZipDirEntry::Read(): Bad signature ({0:X8}) at position {1}", signature, s.Position);
 | 
			
		||||
                return null;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            byte[] block = new byte[42];
 | 
			
		||||
            int n = s.Read(block, 0, block.Length);
 | 
			
		||||
            if (n != block.Length) return null;
 | 
			
		||||
 | 
			
		||||
            int i = 0;
 | 
			
		||||
            ZipDirEntry zde = new ZipDirEntry();
 | 
			
		||||
 | 
			
		||||
            zde._Debug = TurnOnDebug;
 | 
			
		||||
            zde._VersionMadeBy = (short)(block[i++] + block[i++] * 256);
 | 
			
		||||
            zde._VersionNeeded = (short)(block[i++] + block[i++] * 256);
 | 
			
		||||
            zde._BitField = (short)(block[i++] + block[i++] * 256);
 | 
			
		||||
            zde._CompressionMethod = (short)(block[i++] + block[i++] * 256);
 | 
			
		||||
            zde._LastModDateTime = block[i++] + block[i++] * 256 + block[i++] * 256 * 256 + block[i++] * 256 * 256 * 256;
 | 
			
		||||
            zde._Crc32 = block[i++] + block[i++] * 256 + block[i++] * 256 * 256 + block[i++] * 256 * 256 * 256;
 | 
			
		||||
            zde._CompressedSize = block[i++] + block[i++] * 256 + block[i++] * 256 * 256 + block[i++] * 256 * 256 * 256;
 | 
			
		||||
            zde._UncompressedSize = block[i++] + block[i++] * 256 + block[i++] * 256 * 256 + block[i++] * 256 * 256 * 256;
 | 
			
		||||
 | 
			
		||||
            zde._LastModified = TomShane.Neoforce.External.Zip.Shared.PackedToDateTime(zde._LastModDateTime);
 | 
			
		||||
 | 
			
		||||
            Int16 filenameLength = (short)(block[i++] + block[i++] * 256);
 | 
			
		||||
            Int16 extraFieldLength = (short)(block[i++] + block[i++] * 256);
 | 
			
		||||
            Int16 commentLength = (short)(block[i++] + block[i++] * 256);
 | 
			
		||||
            Int16 diskNumber = (short)(block[i++] + block[i++] * 256);
 | 
			
		||||
            Int16 internalFileAttrs = (short)(block[i++] + block[i++] * 256);
 | 
			
		||||
            Int32 externalFileAttrs = block[i++] + block[i++] * 256 + block[i++] * 256 * 256 + block[i++] * 256 * 256 * 256;
 | 
			
		||||
            Int32 Offset = block[i++] + block[i++] * 256 + block[i++] * 256 * 256 + block[i++] * 256 * 256 * 256;
 | 
			
		||||
 | 
			
		||||
            block = new byte[filenameLength];
 | 
			
		||||
            n = s.Read(block, 0, block.Length);
 | 
			
		||||
            zde._FileName = TomShane.Neoforce.External.Zip.Shared.StringFromBuffer(block, 0, block.Length);
 | 
			
		||||
 | 
			
		||||
            zde._Extra = new byte[extraFieldLength];
 | 
			
		||||
            n = s.Read(zde._Extra, 0, zde._Extra.Length);
 | 
			
		||||
 | 
			
		||||
            block = new byte[commentLength];
 | 
			
		||||
            n = s.Read(block, 0, block.Length);
 | 
			
		||||
            zde._Comment = TomShane.Neoforce.External.Zip.Shared.StringFromBuffer(block, 0, block.Length);
 | 
			
		||||
 | 
			
		||||
            return zde;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private static bool SignatureIsNotValid(int signature)
 | 
			
		||||
        {
 | 
			
		||||
            return (signature != ZipDirEntrySignature);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										699
									
								
								Neoforce/External/Zip/ZipEntry.cs
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										699
									
								
								Neoforce/External/Zip/ZipEntry.cs
									
									
									
									
										vendored
									
									
								
							@@ -1,699 +0,0 @@
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.External.Zip
 | 
			
		||||
{
 | 
			
		||||
	internal class ZipEntry
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        private const int ZipEntrySignature = 0x04034b50;
 | 
			
		||||
        private const int ZipEntryDataDescriptorSignature= 0x08074b50;
 | 
			
		||||
 
 | 
			
		||||
        private bool _Debug = false;
 | 
			
		||||
 | 
			
		||||
        private DateTime _LastModified;
 | 
			
		||||
        public DateTime LastModified
 | 
			
		||||
        {
 | 
			
		||||
            get { return _LastModified; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
      // when this is set, we trim the volume (eg C:\) off any fully-qualified pathname, 
 | 
			
		||||
      // before writing the ZipEntry into the ZipFile. 
 | 
			
		||||
      private bool _TrimVolumeFromFullyQualifiedPaths= true;  // by default, trim them.
 | 
			
		||||
        public bool TrimVolumeFromFullyQualifiedPaths
 | 
			
		||||
        {
 | 
			
		||||
            get { return _TrimVolumeFromFullyQualifiedPaths; }
 | 
			
		||||
            set { _TrimVolumeFromFullyQualifiedPaths= value; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private string _FileName;
 | 
			
		||||
        public string FileName
 | 
			
		||||
        {
 | 
			
		||||
            get { return _FileName; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private Int16 _VersionNeeded;
 | 
			
		||||
        public Int16 VersionNeeded
 | 
			
		||||
        {
 | 
			
		||||
            get { return _VersionNeeded; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private Int16 _BitField;
 | 
			
		||||
        public Int16 BitField
 | 
			
		||||
        {
 | 
			
		||||
            get { return _BitField; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private Int16 _CompressionMethod;
 | 
			
		||||
        public Int16 CompressionMethod
 | 
			
		||||
        {
 | 
			
		||||
            get { return _CompressionMethod; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private Int32 _CompressedSize;
 | 
			
		||||
        public Int32 CompressedSize
 | 
			
		||||
        {
 | 
			
		||||
            get { return _CompressedSize; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private Int32 _UncompressedSize;
 | 
			
		||||
        public Int32 UncompressedSize
 | 
			
		||||
        {
 | 
			
		||||
            get { return _UncompressedSize; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public Double CompressionRatio
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                return 100 * (1.0 - (1.0 * CompressedSize) / (1.0 * UncompressedSize));
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private Int32 _LastModDateTime;
 | 
			
		||||
        private Int32 _Crc32;
 | 
			
		||||
        private byte[] _Extra;
 | 
			
		||||
 | 
			
		||||
        private byte[] __filedata;
 | 
			
		||||
        private byte[] _FileData
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                if (__filedata == null)
 | 
			
		||||
                {
 | 
			
		||||
                }
 | 
			
		||||
                return __filedata;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private System.IO.MemoryStream _UnderlyingMemoryStream;
 | 
			
		||||
        private System.IO.Compression.DeflateStream _CompressedStream;
 | 
			
		||||
        private System.IO.Compression.DeflateStream CompressedStream
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                if (_CompressedStream == null)
 | 
			
		||||
                {
 | 
			
		||||
                    _UnderlyingMemoryStream = new System.IO.MemoryStream();
 | 
			
		||||
                    bool LeaveUnderlyingStreamOpen = true;
 | 
			
		||||
                    _CompressedStream = new System.IO.Compression.DeflateStream(_UnderlyingMemoryStream,
 | 
			
		||||
                                                    System.IO.Compression.CompressionMode.Compress,
 | 
			
		||||
                                                    LeaveUnderlyingStreamOpen);
 | 
			
		||||
                }
 | 
			
		||||
                return _CompressedStream;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private byte[] _header;
 | 
			
		||||
        internal byte[] Header
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                return _header;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private int _RelativeOffsetOfHeader;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private static bool ReadHeader(System.IO.Stream s, ZipEntry ze)
 | 
			
		||||
        {
 | 
			
		||||
            int signature = TomShane.Neoforce.External.Zip.Shared.ReadSignature(s);
 | 
			
		||||
 | 
			
		||||
            // return null if this is not a local file header signature
 | 
			
		||||
            if (SignatureIsNotValid(signature))
 | 
			
		||||
            {
 | 
			
		||||
                s.Seek(-4, System.IO.SeekOrigin.Current);
 | 
			
		||||
                if (ze._Debug) System.Console.WriteLine("  ZipEntry::Read(): Bad signature ({0:X8}) at position {1}", signature, s.Position);
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            byte[] block = new byte[26];
 | 
			
		||||
            int n = s.Read(block, 0, block.Length);
 | 
			
		||||
            if (n != block.Length) return false;
 | 
			
		||||
 | 
			
		||||
            int i = 0;
 | 
			
		||||
            ze._VersionNeeded = (short)(block[i++] + block[i++] * 256);
 | 
			
		||||
            ze._BitField = (short)(block[i++] + block[i++] * 256);
 | 
			
		||||
            ze._CompressionMethod = (short)(block[i++] + block[i++] * 256);
 | 
			
		||||
            ze._LastModDateTime = block[i++] + block[i++] * 256 + block[i++] * 256 * 256 + block[i++] * 256 * 256 * 256;
 | 
			
		||||
 | 
			
		||||
            // the PKZIP spec says that if bit 3 is set (0x0008), then the CRC, Compressed size, and uncompressed size
 | 
			
		||||
            // come directly after the file data.  The only way to find it is to scan the zip archive for the signature of 
 | 
			
		||||
            // the Data Descriptor, and presume that that signature does not appear in the (compressed) data of the compressed file.  
 | 
			
		||||
 | 
			
		||||
            if ((ze._BitField & 0x0008) != 0x0008)
 | 
			
		||||
            {
 | 
			
		||||
                ze._Crc32 = block[i++] + block[i++] * 256 + block[i++] * 256 * 256 + block[i++] * 256 * 256 * 256;
 | 
			
		||||
                ze._CompressedSize = block[i++] + block[i++] * 256 + block[i++] * 256 * 256 + block[i++] * 256 * 256 * 256;
 | 
			
		||||
                ze._UncompressedSize = block[i++] + block[i++] * 256 + block[i++] * 256 * 256 + block[i++] * 256 * 256 * 256;
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                // the CRC, compressed size, and uncompressed size are stored later in the stream.
 | 
			
		||||
                // here, we advance the pointer.
 | 
			
		||||
                i += 12;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            Int16 filenameLength = (short)(block[i++] + block[i++] * 256);
 | 
			
		||||
            Int16 extraFieldLength = (short)(block[i++] + block[i++] * 256);
 | 
			
		||||
 | 
			
		||||
            block = new byte[filenameLength];
 | 
			
		||||
            n = s.Read(block, 0, block.Length);
 | 
			
		||||
            ze._FileName = TomShane.Neoforce.External.Zip.Shared.StringFromBuffer(block, 0, block.Length);
 | 
			
		||||
 | 
			
		||||
            ze._Extra = new byte[extraFieldLength];
 | 
			
		||||
            n = s.Read(ze._Extra, 0, ze._Extra.Length);
 | 
			
		||||
 | 
			
		||||
            // transform the time data into something usable
 | 
			
		||||
            ze._LastModified = TomShane.Neoforce.External.Zip.Shared.PackedToDateTime(ze._LastModDateTime);
 | 
			
		||||
 | 
			
		||||
            // actually get the compressed size and CRC if necessary
 | 
			
		||||
            if ((ze._BitField & 0x0008) == 0x0008)
 | 
			
		||||
            {
 | 
			
		||||
                long posn = s.Position;
 | 
			
		||||
                long SizeOfDataRead = TomShane.Neoforce.External.Zip.Shared.FindSignature(s, ZipEntryDataDescriptorSignature);
 | 
			
		||||
                if (SizeOfDataRead == -1) return false; 
 | 
			
		||||
 | 
			
		||||
                // read 3x 4-byte fields (CRC, Compressed Size, Uncompressed Size)
 | 
			
		||||
                block = new byte[12];
 | 
			
		||||
                n = s.Read(block, 0, block.Length);
 | 
			
		||||
                if (n != 12) return false;
 | 
			
		||||
                i = 0;
 | 
			
		||||
                ze._Crc32 = block[i++] + block[i++] * 256 + block[i++] * 256 * 256 + block[i++] * 256 * 256 * 256;
 | 
			
		||||
                ze._CompressedSize = block[i++] + block[i++] * 256 + block[i++] * 256 * 256 + block[i++] * 256 * 256 * 256;
 | 
			
		||||
                ze._UncompressedSize = block[i++] + block[i++] * 256 + block[i++] * 256 * 256 + block[i++] * 256 * 256 * 256;
 | 
			
		||||
 | 
			
		||||
                if (SizeOfDataRead != ze._CompressedSize)
 | 
			
		||||
                    throw new Exception("Data format error (bit 3 is set)"); 
 | 
			
		||||
                
 | 
			
		||||
                // seek back to previous position, to read file data
 | 
			
		||||
                s.Seek(posn, System.IO.SeekOrigin.Begin);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private static bool SignatureIsNotValid(int signature)
 | 
			
		||||
        {
 | 
			
		||||
            return (signature != ZipEntrySignature);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public static ZipEntry Read(System.IO.Stream s)
 | 
			
		||||
        {
 | 
			
		||||
            return Read(s, false);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        internal static ZipEntry Read(System.IO.Stream s, bool TurnOnDebug)
 | 
			
		||||
        {
 | 
			
		||||
            ZipEntry entry = new ZipEntry();
 | 
			
		||||
            entry._Debug = TurnOnDebug;
 | 
			
		||||
            if (!ReadHeader(s, entry)) return null;
 | 
			
		||||
 | 
			
		||||
            entry.__filedata = new byte[entry.CompressedSize];
 | 
			
		||||
            int n = s.Read(entry._FileData, 0, entry._FileData.Length);
 | 
			
		||||
            if (n != entry._FileData.Length)
 | 
			
		||||
            {
 | 
			
		||||
                throw new Exception("badly formatted zip file.");
 | 
			
		||||
            }
 | 
			
		||||
            // finally, seek past the (already read) Data descriptor if necessary
 | 
			
		||||
            if ((entry._BitField & 0x0008) == 0x0008)
 | 
			
		||||
            {
 | 
			
		||||
                s.Seek(16, System.IO.SeekOrigin.Current);
 | 
			
		||||
            }
 | 
			
		||||
            return entry;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        internal static ZipEntry Create(String filename)
 | 
			
		||||
        {
 | 
			
		||||
            ZipEntry entry = new ZipEntry();
 | 
			
		||||
            entry._FileName = filename;
 | 
			
		||||
 | 
			
		||||
            entry._LastModified = System.IO.File.GetLastWriteTime(filename);
 | 
			
		||||
	    // adjust the time if the .NET BCL thinks it is in DST.  
 | 
			
		||||
	    // see the note elsewhere in this file for more info. 
 | 
			
		||||
            if (entry._LastModified.IsDaylightSavingTime())
 | 
			
		||||
            {
 | 
			
		||||
                System.DateTime AdjustedTime = entry._LastModified - new System.TimeSpan(1, 0, 0);
 | 
			
		||||
                entry._LastModDateTime = TomShane.Neoforce.External.Zip.Shared.DateTimeToPacked(AdjustedTime);
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
                entry._LastModDateTime = TomShane.Neoforce.External.Zip.Shared.DateTimeToPacked(entry._LastModified);
 | 
			
		||||
 | 
			
		||||
            // we don't actually slurp in the file until the caller invokes Write on this entry.
 | 
			
		||||
 | 
			
		||||
            return entry;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public void Extract()
 | 
			
		||||
        {
 | 
			
		||||
            Extract(".");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void Extract(System.IO.Stream s)
 | 
			
		||||
        {
 | 
			
		||||
            Extract(null, s);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void Extract(string basedir)
 | 
			
		||||
        {
 | 
			
		||||
            Extract(basedir, null);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		internal System.IO.Stream GetStream()
 | 
			
		||||
		{
 | 
			
		||||
			System.IO.MemoryStream memstream = new System.IO.MemoryStream(_FileData);
 | 
			
		||||
 | 
			
		||||
			if (CompressedSize == UncompressedSize)
 | 
			
		||||
				return memstream;
 | 
			
		||||
 | 
			
		||||
			return new System.IO.Compression.DeflateStream(
 | 
			
		||||
				memstream, System.IO.Compression.CompressionMode.Decompress);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
        // pass in either basedir or s, but not both. 
 | 
			
		||||
        // In other words, you can extract to a stream or to a directory, but not both!
 | 
			
		||||
        private void Extract(string basedir, System.IO.Stream s)
 | 
			
		||||
        {
 | 
			
		||||
            string TargetFile = null;
 | 
			
		||||
            if (basedir != null)
 | 
			
		||||
            {
 | 
			
		||||
                TargetFile = System.IO.Path.Combine(basedir, FileName);
 | 
			
		||||
 | 
			
		||||
                // check if a directory
 | 
			
		||||
                if (FileName.EndsWith("/"))
 | 
			
		||||
                {
 | 
			
		||||
                    if (!System.IO.Directory.Exists(TargetFile))
 | 
			
		||||
                        System.IO.Directory.CreateDirectory(TargetFile);
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            else if (s != null)
 | 
			
		||||
            {
 | 
			
		||||
                if (FileName.EndsWith("/"))
 | 
			
		||||
                    // extract a directory to streamwriter?  nothing to do!
 | 
			
		||||
                    return;
 | 
			
		||||
            }
 | 
			
		||||
            else throw new Exception("Invalid input.");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            using (System.IO.MemoryStream memstream = new System.IO.MemoryStream(_FileData))
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
                System.IO.Stream input = null;
 | 
			
		||||
                try
 | 
			
		||||
                {
 | 
			
		||||
 | 
			
		||||
                    if (CompressedSize == UncompressedSize)
 | 
			
		||||
                    {
 | 
			
		||||
                        // the System.IO.Compression.DeflateStream class does not handle uncompressed data.
 | 
			
		||||
                        // so if an entry is not compressed, then we just translate the bytes directly.
 | 
			
		||||
                        input = memstream;
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        input = new System.IO.Compression.DeflateStream(memstream, System.IO.Compression.CompressionMode.Decompress);
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                    if (TargetFile != null)
 | 
			
		||||
                    {
 | 
			
		||||
                        // ensure the target path exists
 | 
			
		||||
                        if (!System.IO.Directory.Exists(System.IO.Path.GetDirectoryName(TargetFile)))
 | 
			
		||||
                        {
 | 
			
		||||
                            System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(TargetFile));
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                    System.IO.Stream output = null;
 | 
			
		||||
                    try
 | 
			
		||||
                    {
 | 
			
		||||
                        if (TargetFile != null)
 | 
			
		||||
                            output = new System.IO.FileStream(TargetFile, System.IO.FileMode.CreateNew);
 | 
			
		||||
                        else
 | 
			
		||||
                            output = s;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                        byte[] bytes = new byte[4096];
 | 
			
		||||
                        int n;
 | 
			
		||||
 | 
			
		||||
                        if (_Debug)
 | 
			
		||||
                        {
 | 
			
		||||
                            Console.WriteLine("{0}: _FileData.Length= {1}", TargetFile, _FileData.Length);
 | 
			
		||||
                            Console.WriteLine("{0}: memstream.Position: {1}", TargetFile, memstream.Position);
 | 
			
		||||
                            n = _FileData.Length;
 | 
			
		||||
                            if (n > 1000)
 | 
			
		||||
                            {
 | 
			
		||||
                                n = 500;
 | 
			
		||||
                                Console.WriteLine("{0}: truncating dump from {1} to {2} bytes...", TargetFile, _FileData.Length, n);
 | 
			
		||||
                            }
 | 
			
		||||
                            for (int j = 0; j < n; j += 2)
 | 
			
		||||
                            {
 | 
			
		||||
                                if ((j > 0) && (j % 40 == 0))
 | 
			
		||||
                                    System.Console.WriteLine();
 | 
			
		||||
                                System.Console.Write(" {0:X2}", _FileData[j]);
 | 
			
		||||
                                if (j + 1 < n)
 | 
			
		||||
                                    System.Console.Write("{0:X2}", _FileData[j + 1]);
 | 
			
		||||
                            }
 | 
			
		||||
                            System.Console.WriteLine("\n");
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        n = 1; // anything non-zero
 | 
			
		||||
                        while (n != 0)
 | 
			
		||||
                        {
 | 
			
		||||
                            if (_Debug) Console.WriteLine("{0}: about to read...", TargetFile);
 | 
			
		||||
                            n = input.Read(bytes, 0, bytes.Length);
 | 
			
		||||
                            if (_Debug) Console.WriteLine("{0}: got {1} bytes", TargetFile, n);
 | 
			
		||||
                            if (n > 0)
 | 
			
		||||
                            {
 | 
			
		||||
                                if (_Debug) Console.WriteLine("{0}: about to write...", TargetFile);
 | 
			
		||||
                                output.Write(bytes, 0, n);
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    finally
 | 
			
		||||
                    {
 | 
			
		||||
                        // we only close the output stream if we opened it. 
 | 
			
		||||
                        if ((output != null) && (TargetFile != null))
 | 
			
		||||
                        {
 | 
			
		||||
                            output.Close();
 | 
			
		||||
                            output.Dispose();
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    if (TargetFile != null)
 | 
			
		||||
                    {
 | 
			
		||||
                      // We may have to adjust the last modified time to compensate
 | 
			
		||||
                      // for differences in how the .NET Base Class Library deals
 | 
			
		||||
                      // with daylight saving time (DST) versus how the Windows
 | 
			
		||||
                      // filesystem deals with daylight saving time. See 
 | 
			
		||||
		      // http://blogs.msdn.com/oldnewthing/archive/2003/10/24/55413.aspx for some context. 
 | 
			
		||||
 | 
			
		||||
		      // in a nutshell: Daylight savings time rules change regularly.  In
 | 
			
		||||
		      // 2007, for example, the inception week of DST changed.  In 1977,
 | 
			
		||||
		      // DST was in place all year round. in 1945, likewise.  And so on.
 | 
			
		||||
		      // Win32 does not attempt to guess which time zone rules were in
 | 
			
		||||
		      // effect at the time in question.  It will render a time as
 | 
			
		||||
		      // "standard time" and allow the app to change to DST as necessary.
 | 
			
		||||
		      //  .NET makes a different choice.
 | 
			
		||||
 | 
			
		||||
		      // -------------------------------------------------------
 | 
			
		||||
		      // Compare the output of FileInfo.LastWriteTime.ToString("f") with
 | 
			
		||||
		      // what you see in the property sheet for a file that was last
 | 
			
		||||
		      // written to on the other side of the DST transition. For example,
 | 
			
		||||
		      // suppose the file was last modified on October 17, during DST but
 | 
			
		||||
		      // DST is not currently in effect. Explorer's file properties
 | 
			
		||||
		      // reports Thursday, October 17, 2003, 8:45:38 AM, but .NETs
 | 
			
		||||
		      // FileInfo reports Thursday, October 17, 2003, 9:45 AM.
 | 
			
		||||
		      
 | 
			
		||||
		      // Win32 says, "Thursday, October 17, 2002 8:45:38 AM PST". Note:
 | 
			
		||||
		      // Pacific STANDARD Time. Even though October 17 of that year
 | 
			
		||||
		      // occurred during Pacific Daylight Time, Win32 displays the time as
 | 
			
		||||
		      // standard time because that's what time it is NOW.
 | 
			
		||||
 | 
			
		||||
		      // .NET BCL assumes that the current DST rules were in place at the
 | 
			
		||||
		      // time in question.  So, .NET says, "Well, if the rules in effect
 | 
			
		||||
		      // now were also in effect on October 17, 2003, then that would be
 | 
			
		||||
		      // daylight time" so it displays "Thursday, October 17, 2003, 9:45
 | 
			
		||||
		      // AM PDT" - daylight time.
 | 
			
		||||
 | 
			
		||||
		      // So .NET gives a value which is more intuitively correct, but is
 | 
			
		||||
		      // also potentially incorrect, and which is not invertible. Win32
 | 
			
		||||
		      // gives a value which is intuitively incorrect, but is strictly
 | 
			
		||||
		      // correct.
 | 
			
		||||
		      // -------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
		      // With this adjustment, I add one hour to the tweaked .NET time, if
 | 
			
		||||
		      // necessary.  That is to say, if the time in question had occurred
 | 
			
		||||
		      // in what the .NET BCL assumed to be DST (an assumption that may be
 | 
			
		||||
		      // wrong given the constantly changing DST rules).
 | 
			
		||||
 | 
			
		||||
#if !XBOX
 | 
			
		||||
                        if (LastModified.IsDaylightSavingTime())
 | 
			
		||||
                        {
 | 
			
		||||
                            DateTime AdjustedLastModified = LastModified + new System.TimeSpan(1, 0, 0);
 | 
			
		||||
                            System.IO.File.SetLastWriteTime(TargetFile, AdjustedLastModified);
 | 
			
		||||
                        }
 | 
			
		||||
                        else
 | 
			
		||||
                            System.IO.File.SetLastWriteTime(TargetFile, LastModified);
 | 
			
		||||
#endif
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                }
 | 
			
		||||
                finally
 | 
			
		||||
                {
 | 
			
		||||
		  // we only close the output stream if we opened it. 
 | 
			
		||||
                    // we cannot use using() here because in some cases we do not want to Dispose the stream!
 | 
			
		||||
                    if ((input != null) && (input != memstream))
 | 
			
		||||
                    {
 | 
			
		||||
                        input.Close();
 | 
			
		||||
                        input.Dispose();
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        internal void WriteCentralDirectoryEntry(System.IO.Stream s)
 | 
			
		||||
        {
 | 
			
		||||
            byte[] bytes = new byte[4096];
 | 
			
		||||
            int i = 0;
 | 
			
		||||
            // signature
 | 
			
		||||
            bytes[i++] = (byte)(ZipDirEntry.ZipDirEntrySignature & 0x000000FF);
 | 
			
		||||
            bytes[i++] = (byte)((ZipDirEntry.ZipDirEntrySignature & 0x0000FF00) >> 8);
 | 
			
		||||
            bytes[i++] = (byte)((ZipDirEntry.ZipDirEntrySignature & 0x00FF0000) >> 16);
 | 
			
		||||
            bytes[i++] = (byte)((ZipDirEntry.ZipDirEntrySignature & 0xFF000000) >> 24);
 | 
			
		||||
 | 
			
		||||
            // Version Made By
 | 
			
		||||
            bytes[i++] = Header[4];
 | 
			
		||||
            bytes[i++] = Header[5];
 | 
			
		||||
 | 
			
		||||
            // Version Needed, Bitfield, compression method, lastmod,
 | 
			
		||||
            // crc, sizes, filename length and extra field length -
 | 
			
		||||
            // are all the same as the local file header. So just copy them
 | 
			
		||||
            int j = 0;
 | 
			
		||||
            for (j = 0; j < 26; j++)
 | 
			
		||||
                bytes[i + j] = Header[4 + j];
 | 
			
		||||
 | 
			
		||||
            i += j;  // positioned at next available byte
 | 
			
		||||
 | 
			
		||||
            // File Comment Length
 | 
			
		||||
            bytes[i++] = 0;
 | 
			
		||||
            bytes[i++] = 0;
 | 
			
		||||
 | 
			
		||||
            // Disk number start
 | 
			
		||||
            bytes[i++] = 0;
 | 
			
		||||
            bytes[i++] = 0;
 | 
			
		||||
 | 
			
		||||
            // internal file attrs            
 | 
			
		||||
            bytes[i++] = 1;
 | 
			
		||||
            bytes[i++] = 0;
 | 
			
		||||
 | 
			
		||||
            // external file attrs            
 | 
			
		||||
            bytes[i++] = 0x20;
 | 
			
		||||
            bytes[i++] = 0;
 | 
			
		||||
            bytes[i++] = 0xb6;
 | 
			
		||||
            bytes[i++] = 0x81;
 | 
			
		||||
 | 
			
		||||
            // relative offset of local header (I think this can be zero)
 | 
			
		||||
            bytes[i++] = (byte)(_RelativeOffsetOfHeader & 0x000000FF);
 | 
			
		||||
            bytes[i++] = (byte)((_RelativeOffsetOfHeader & 0x0000FF00) >> 8);
 | 
			
		||||
            bytes[i++] = (byte)((_RelativeOffsetOfHeader & 0x00FF0000) >> 16);
 | 
			
		||||
            bytes[i++] = (byte)((_RelativeOffsetOfHeader & 0xFF000000) >> 24);
 | 
			
		||||
 | 
			
		||||
            if (_Debug) System.Console.WriteLine("\ninserting filename into CDS: (length= {0})", Header.Length - 30);
 | 
			
		||||
            // actual filename (starts at offset 34 in header) 
 | 
			
		||||
            for (j = 0; j < Header.Length - 30; j++)
 | 
			
		||||
            {
 | 
			
		||||
                bytes[i + j] = Header[30 + j];
 | 
			
		||||
                if (_Debug) System.Console.Write(" {0:X2}", bytes[i + j]);
 | 
			
		||||
            }
 | 
			
		||||
            if (_Debug) System.Console.WriteLine();
 | 
			
		||||
            i += j;
 | 
			
		||||
 | 
			
		||||
            s.Write(bytes, 0, i);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private void WriteHeader(System.IO.Stream s, byte[] bytes)
 | 
			
		||||
        {
 | 
			
		||||
            // write the header info
 | 
			
		||||
 | 
			
		||||
            int i = 0;
 | 
			
		||||
            // signature
 | 
			
		||||
            bytes[i++] = (byte)(ZipEntrySignature & 0x000000FF);
 | 
			
		||||
            bytes[i++] = (byte)((ZipEntrySignature & 0x0000FF00) >> 8);
 | 
			
		||||
            bytes[i++] = (byte)((ZipEntrySignature & 0x00FF0000) >> 16);
 | 
			
		||||
            bytes[i++] = (byte)((ZipEntrySignature & 0xFF000000) >> 24);
 | 
			
		||||
 | 
			
		||||
            // version needed
 | 
			
		||||
            Int16 FixedVersionNeeded = 0x14; // from examining existing zip files
 | 
			
		||||
            bytes[i++] = (byte)(FixedVersionNeeded & 0x00FF);
 | 
			
		||||
            bytes[i++] = (byte)((FixedVersionNeeded & 0xFF00) >> 8);
 | 
			
		||||
 | 
			
		||||
            // bitfield
 | 
			
		||||
            Int16 BitField = 0x00; // from examining existing zip files
 | 
			
		||||
            bytes[i++] = (byte)(BitField & 0x00FF);
 | 
			
		||||
            bytes[i++] = (byte)((BitField & 0xFF00) >> 8);
 | 
			
		||||
 | 
			
		||||
            // compression method
 | 
			
		||||
            Int16 CompressionMethod = 0x08; // 0x08 = Deflate
 | 
			
		||||
            bytes[i++] = (byte)(CompressionMethod & 0x00FF);
 | 
			
		||||
            bytes[i++] = (byte)((CompressionMethod & 0xFF00) >> 8);
 | 
			
		||||
 | 
			
		||||
            // LastMod
 | 
			
		||||
            bytes[i++] = (byte)(_LastModDateTime & 0x000000FF);
 | 
			
		||||
            bytes[i++] = (byte)((_LastModDateTime & 0x0000FF00) >> 8);
 | 
			
		||||
            bytes[i++] = (byte)((_LastModDateTime & 0x00FF0000) >> 16);
 | 
			
		||||
            bytes[i++] = (byte)((_LastModDateTime & 0xFF000000) >> 24);
 | 
			
		||||
 | 
			
		||||
            // CRC32 (Int32)
 | 
			
		||||
            CRC32 crc32 = new CRC32();
 | 
			
		||||
            UInt32 crc = 0;
 | 
			
		||||
            using (System.IO.Stream input = System.IO.File.OpenRead(FileName))
 | 
			
		||||
            {
 | 
			
		||||
                crc = crc32.GetCrc32AndCopy(input, CompressedStream);
 | 
			
		||||
            }
 | 
			
		||||
            CompressedStream.Close();  // to get the footer bytes written to the underlying stream
 | 
			
		||||
 | 
			
		||||
            bytes[i++] = (byte)(crc & 0x000000FF);
 | 
			
		||||
            bytes[i++] = (byte)((crc & 0x0000FF00) >> 8);
 | 
			
		||||
            bytes[i++] = (byte)((crc & 0x00FF0000) >> 16);
 | 
			
		||||
            bytes[i++] = (byte)((crc & 0xFF000000) >> 24);
 | 
			
		||||
 | 
			
		||||
            // CompressedSize (Int32)
 | 
			
		||||
            Int32 isz = (Int32)_UnderlyingMemoryStream.Length;
 | 
			
		||||
            UInt32 sz = (UInt32)isz;
 | 
			
		||||
            bytes[i++] = (byte)(sz & 0x000000FF);
 | 
			
		||||
            bytes[i++] = (byte)((sz & 0x0000FF00) >> 8);
 | 
			
		||||
            bytes[i++] = (byte)((sz & 0x00FF0000) >> 16);
 | 
			
		||||
            bytes[i++] = (byte)((sz & 0xFF000000) >> 24);
 | 
			
		||||
 | 
			
		||||
            // UncompressedSize (Int32)
 | 
			
		||||
            if (_Debug) System.Console.WriteLine("Uncompressed Size: {0}", crc32.TotalBytesRead);
 | 
			
		||||
            bytes[i++] = (byte)(crc32.TotalBytesRead & 0x000000FF);
 | 
			
		||||
            bytes[i++] = (byte)((crc32.TotalBytesRead & 0x0000FF00) >> 8);
 | 
			
		||||
            bytes[i++] = (byte)((crc32.TotalBytesRead & 0x00FF0000) >> 16);
 | 
			
		||||
            bytes[i++] = (byte)((crc32.TotalBytesRead & 0xFF000000) >> 24);
 | 
			
		||||
 | 
			
		||||
            // filename length (Int16)
 | 
			
		||||
            Int16 length = (Int16)FileName.Length;
 | 
			
		||||
	    // see note below about TrimVolumeFromFullyQualifiedPaths.
 | 
			
		||||
	    if ( (TrimVolumeFromFullyQualifiedPaths) && (FileName[1]==':') && (FileName[2]=='\\')) length-=3;
 | 
			
		||||
            bytes[i++] = (byte)(length & 0x00FF);
 | 
			
		||||
            bytes[i++] = (byte)((length & 0xFF00) >> 8);
 | 
			
		||||
 | 
			
		||||
            // extra field length (short)
 | 
			
		||||
            Int16 ExtraFieldLength = 0x00;
 | 
			
		||||
            bytes[i++] = (byte)(ExtraFieldLength & 0x00FF);
 | 
			
		||||
            bytes[i++] = (byte)((ExtraFieldLength & 0xFF00) >> 8);
 | 
			
		||||
 | 
			
		||||
	    // Tue, 27 Mar 2007  16:35
 | 
			
		||||
 | 
			
		||||
	    // Creating a zip that contains entries with "fully qualified" pathnames
 | 
			
		||||
	    // can result in a zip archive that is unreadable by Windows Explorer.
 | 
			
		||||
	    // Such archives are valid according to other tools but not to explorer.
 | 
			
		||||
	    // To avoid this, we can trim off the leading volume name and slash (eg
 | 
			
		||||
	    // c:\) when creating (writing) a zip file.  We do this by default and we
 | 
			
		||||
	    // leave the old behavior available with the
 | 
			
		||||
	    // TrimVolumeFromFullyQualifiedPaths flag - set it to false to get the old
 | 
			
		||||
	    // behavior.  It only affects zip creation.
 | 
			
		||||
 | 
			
		||||
            // actual filename
 | 
			
		||||
            char[] c =  ( (TrimVolumeFromFullyQualifiedPaths) && (FileName[1]==':') && (FileName[2]=='\\')) ? 
 | 
			
		||||
	      FileName.Substring(3).ToCharArray() :  // trim off volume letter, colon, and slash
 | 
			
		||||
	      FileName.ToCharArray();
 | 
			
		||||
            int j = 0;
 | 
			
		||||
 | 
			
		||||
            if (_Debug)
 | 
			
		||||
            {
 | 
			
		||||
                System.Console.WriteLine("local header: writing filename, {0} chars", c.Length);
 | 
			
		||||
                System.Console.WriteLine("starting offset={0}", i);
 | 
			
		||||
            }
 | 
			
		||||
            for (j = 0; (j < c.Length) && (i + j < bytes.Length); j++)
 | 
			
		||||
            {
 | 
			
		||||
                bytes[i + j] = System.BitConverter.GetBytes(c[j])[0];
 | 
			
		||||
                if (_Debug) System.Console.Write(" {0:X2}", bytes[i + j]);
 | 
			
		||||
            }
 | 
			
		||||
            if (_Debug) System.Console.WriteLine();
 | 
			
		||||
 | 
			
		||||
            i += j;
 | 
			
		||||
 | 
			
		||||
            // extra field (we always write nothing in this implementation)
 | 
			
		||||
            // ;;
 | 
			
		||||
 | 
			
		||||
            // remember the file offset of this header
 | 
			
		||||
            _RelativeOffsetOfHeader = (int)s.Length;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            if (_Debug)
 | 
			
		||||
            {
 | 
			
		||||
                System.Console.WriteLine("\nAll header data:");
 | 
			
		||||
                for (j = 0; j < i; j++)
 | 
			
		||||
                    System.Console.Write(" {0:X2}", bytes[j]);
 | 
			
		||||
                System.Console.WriteLine();
 | 
			
		||||
            }
 | 
			
		||||
            // finally, write the header to the stream
 | 
			
		||||
            s.Write(bytes, 0, i);
 | 
			
		||||
 | 
			
		||||
            // preserve this header data for use with the central directory structure.
 | 
			
		||||
            _header = new byte[i];
 | 
			
		||||
            if (_Debug) System.Console.WriteLine("preserving header of {0} bytes", _header.Length);
 | 
			
		||||
            for (j = 0; j < i; j++)
 | 
			
		||||
                _header[j] = bytes[j];
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        internal void Write(System.IO.Stream s)
 | 
			
		||||
        {
 | 
			
		||||
            byte[] bytes = new byte[4096];
 | 
			
		||||
            int n;
 | 
			
		||||
 | 
			
		||||
            // write the header:
 | 
			
		||||
            WriteHeader(s, bytes);
 | 
			
		||||
 | 
			
		||||
            // write the actual file data: 
 | 
			
		||||
            _UnderlyingMemoryStream.Position = 0;
 | 
			
		||||
 | 
			
		||||
            if (_Debug)
 | 
			
		||||
            {
 | 
			
		||||
                Console.WriteLine("{0}: writing compressed data to zipfile...", FileName);
 | 
			
		||||
                Console.WriteLine("{0}: total data length: {1}", FileName, _UnderlyingMemoryStream.Length);
 | 
			
		||||
            }
 | 
			
		||||
            while ((n = _UnderlyingMemoryStream.Read(bytes, 0, bytes.Length)) != 0)
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
                if (_Debug)
 | 
			
		||||
                {
 | 
			
		||||
                    Console.WriteLine("{0}: transferring {1} bytes...", FileName, n);
 | 
			
		||||
 | 
			
		||||
                    for (int j = 0; j < n; j += 2)
 | 
			
		||||
                    {
 | 
			
		||||
                        if ((j > 0) && (j % 40 == 0))
 | 
			
		||||
                            System.Console.WriteLine();
 | 
			
		||||
                        System.Console.Write(" {0:X2}", bytes[j]);
 | 
			
		||||
                        if (j + 1 < n)
 | 
			
		||||
                            System.Console.Write("{0:X2}", bytes[j + 1]);
 | 
			
		||||
                    }
 | 
			
		||||
                    System.Console.WriteLine("\n");
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                s.Write(bytes, 0, n);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            //_CompressedStream.Close();
 | 
			
		||||
            //_CompressedStream= null;
 | 
			
		||||
            _UnderlyingMemoryStream.Close();
 | 
			
		||||
            _UnderlyingMemoryStream = null;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										505
									
								
								Neoforce/External/Zip/ZipFile.cs
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										505
									
								
								Neoforce/External/Zip/ZipFile.cs
									
									
									
									
										vendored
									
									
								
							@@ -1,505 +0,0 @@
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.External.Zip
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
    internal class ZipFile : System.Collections.Generic.IEnumerable<ZipEntry>,
 | 
			
		||||
      IDisposable
 | 
			
		||||
    {
 | 
			
		||||
        private string _name;
 | 
			
		||||
        public string Name
 | 
			
		||||
        {
 | 
			
		||||
            get { return _name; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
      // when this is set, we trim the volume (eg C:) off any fully-qualified pathname, 
 | 
			
		||||
      // before writing the ZipEntry into the ZipFile. 
 | 
			
		||||
      // We default this to true.  This allows Windows Explorer to read the zip archives properly. 
 | 
			
		||||
      private bool _TrimVolumeFromFullyQualifiedPaths= true;
 | 
			
		||||
      public bool TrimVolumeFromFullyQualifiedPaths
 | 
			
		||||
      {
 | 
			
		||||
            get { return _TrimVolumeFromFullyQualifiedPaths; }
 | 
			
		||||
            set { _TrimVolumeFromFullyQualifiedPaths= value; }
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
        private System.IO.Stream ReadStream
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                if (_readstream == null)
 | 
			
		||||
                {
 | 
			
		||||
                    _readstream = System.IO.File.OpenRead(_name);
 | 
			
		||||
                }
 | 
			
		||||
                return _readstream;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private System.IO.FileStream WriteStream
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                if (_writestream == null)
 | 
			
		||||
                {
 | 
			
		||||
                    _writestream = new System.IO.FileStream(_name, System.IO.FileMode.CreateNew);
 | 
			
		||||
                }
 | 
			
		||||
                return _writestream;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private ZipFile() { }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        #region For Writing Zip Files
 | 
			
		||||
 | 
			
		||||
        public ZipFile(string NewZipFileName)
 | 
			
		||||
        {
 | 
			
		||||
            // create a new zipfile
 | 
			
		||||
            _name = NewZipFileName;
 | 
			
		||||
            if (System.IO.File.Exists(_name))
 | 
			
		||||
                throw new System.Exception(String.Format("That file ({0}) already exists.", NewZipFileName));
 | 
			
		||||
            _entries = new System.Collections.Generic.List<ZipEntry>();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public void AddItem(string FileOrDirectoryName)
 | 
			
		||||
        {
 | 
			
		||||
            AddItem(FileOrDirectoryName, false);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void AddItem(string FileOrDirectoryName, bool WantVerbose)
 | 
			
		||||
        {
 | 
			
		||||
            if (System.IO.File.Exists(FileOrDirectoryName))
 | 
			
		||||
                AddFile(FileOrDirectoryName, WantVerbose);
 | 
			
		||||
            else if (System.IO.Directory.Exists(FileOrDirectoryName))
 | 
			
		||||
                AddDirectory(FileOrDirectoryName, WantVerbose);
 | 
			
		||||
 | 
			
		||||
            else
 | 
			
		||||
                throw new Exception(String.Format("That file or directory ({0}) does not exist!", FileOrDirectoryName));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void AddFile(string FileName)
 | 
			
		||||
        {
 | 
			
		||||
            AddFile(FileName, false);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void AddFile(string FileName, bool WantVerbose)
 | 
			
		||||
        {
 | 
			
		||||
            ZipEntry ze = ZipEntry.Create(FileName);
 | 
			
		||||
            ze.TrimVolumeFromFullyQualifiedPaths= TrimVolumeFromFullyQualifiedPaths;
 | 
			
		||||
            if (WantVerbose) Console.WriteLine("adding {0}...", FileName);
 | 
			
		||||
			ze.Write(WriteStream);
 | 
			
		||||
            _entries.Add(ze);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void AddDirectory(string DirectoryName)
 | 
			
		||||
        {
 | 
			
		||||
            AddDirectory(DirectoryName, false);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void AddDirectory(string DirectoryName, bool WantVerbose)
 | 
			
		||||
        {
 | 
			
		||||
            String[] filenames = System.IO.Directory.GetFiles(DirectoryName);
 | 
			
		||||
            foreach (String filename in filenames)
 | 
			
		||||
            {
 | 
			
		||||
                if (WantVerbose) Console.WriteLine("adding {0}...", filename);
 | 
			
		||||
                AddFile(filename);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public void Save()
 | 
			
		||||
        {
 | 
			
		||||
            WriteCentralDirectoryStructure();
 | 
			
		||||
            WriteStream.Close();
 | 
			
		||||
            _writestream = null;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private void WriteCentralDirectoryStructure()
 | 
			
		||||
        {
 | 
			
		||||
            // the central directory structure
 | 
			
		||||
            long Start = WriteStream.Length;
 | 
			
		||||
            foreach (ZipEntry e in _entries)
 | 
			
		||||
            {
 | 
			
		||||
                e.WriteCentralDirectoryEntry(WriteStream);
 | 
			
		||||
            }
 | 
			
		||||
            long Finish = WriteStream.Length;
 | 
			
		||||
 | 
			
		||||
            // now, the footer
 | 
			
		||||
            WriteCentralDirectoryFooter(Start, Finish);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private void WriteCentralDirectoryFooter(long StartOfCentralDirectory, long EndOfCentralDirectory)
 | 
			
		||||
        {
 | 
			
		||||
            byte[] bytes = new byte[1024];
 | 
			
		||||
            int i = 0;
 | 
			
		||||
            // signature
 | 
			
		||||
            UInt32 EndOfCentralDirectorySignature = 0x06054b50;
 | 
			
		||||
            bytes[i++] = (byte)(EndOfCentralDirectorySignature & 0x000000FF);
 | 
			
		||||
            bytes[i++] = (byte)((EndOfCentralDirectorySignature & 0x0000FF00) >> 8);
 | 
			
		||||
            bytes[i++] = (byte)((EndOfCentralDirectorySignature & 0x00FF0000) >> 16);
 | 
			
		||||
            bytes[i++] = (byte)((EndOfCentralDirectorySignature & 0xFF000000) >> 24);
 | 
			
		||||
 | 
			
		||||
            // number of this disk
 | 
			
		||||
            bytes[i++] = 0;
 | 
			
		||||
            bytes[i++] = 0;
 | 
			
		||||
 | 
			
		||||
            // number of the disk with the start of the central directory
 | 
			
		||||
            bytes[i++] = 0;
 | 
			
		||||
            bytes[i++] = 0;
 | 
			
		||||
 | 
			
		||||
            // total number of entries in the central dir on this disk
 | 
			
		||||
            bytes[i++] = (byte)(_entries.Count & 0x00FF);
 | 
			
		||||
            bytes[i++] = (byte)((_entries.Count & 0xFF00) >> 8);
 | 
			
		||||
 | 
			
		||||
            // total number of entries in the central directory
 | 
			
		||||
            bytes[i++] = (byte)(_entries.Count & 0x00FF);
 | 
			
		||||
            bytes[i++] = (byte)((_entries.Count & 0xFF00) >> 8);
 | 
			
		||||
 | 
			
		||||
            // size of the central directory
 | 
			
		||||
            Int32 SizeOfCentralDirectory = (Int32)(EndOfCentralDirectory - StartOfCentralDirectory);
 | 
			
		||||
            bytes[i++] = (byte)(SizeOfCentralDirectory & 0x000000FF);
 | 
			
		||||
            bytes[i++] = (byte)((SizeOfCentralDirectory & 0x0000FF00) >> 8);
 | 
			
		||||
            bytes[i++] = (byte)((SizeOfCentralDirectory & 0x00FF0000) >> 16);
 | 
			
		||||
            bytes[i++] = (byte)((SizeOfCentralDirectory & 0xFF000000) >> 24);
 | 
			
		||||
 | 
			
		||||
            // offset of the start of the central directory 
 | 
			
		||||
            Int32 StartOffset = (Int32)StartOfCentralDirectory;  // cast down from Long
 | 
			
		||||
            bytes[i++] = (byte)(StartOffset & 0x000000FF);
 | 
			
		||||
            bytes[i++] = (byte)((StartOffset & 0x0000FF00) >> 8);
 | 
			
		||||
            bytes[i++] = (byte)((StartOffset & 0x00FF0000) >> 16);
 | 
			
		||||
            bytes[i++] = (byte)((StartOffset & 0xFF000000) >> 24);
 | 
			
		||||
 | 
			
		||||
            // zip comment length
 | 
			
		||||
            bytes[i++] = 0;
 | 
			
		||||
            bytes[i++] = 0;
 | 
			
		||||
 | 
			
		||||
            WriteStream.Write(bytes, 0, i);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region For Reading Zip Files
 | 
			
		||||
 | 
			
		||||
        internal static ZipFile Read(string zipfilename)
 | 
			
		||||
        {
 | 
			
		||||
            return Read(zipfilename, false);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        internal static ZipFile Read(string zipfilename, bool TurnOnDebug)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
            ZipFile zf = new ZipFile();
 | 
			
		||||
            zf._Debug = TurnOnDebug;
 | 
			
		||||
            zf._name = zipfilename;
 | 
			
		||||
            zf._entries = new System.Collections.Generic.List<ZipEntry>();
 | 
			
		||||
            ZipEntry e;
 | 
			
		||||
            while ((e = ZipEntry.Read(zf.ReadStream, zf._Debug)) != null)
 | 
			
		||||
            {
 | 
			
		||||
                if (zf._Debug) System.Console.WriteLine("  ZipFile::Read(): ZipEntry: {0}", e.FileName);
 | 
			
		||||
                zf._entries.Add(e);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // read the zipfile's central directory structure here.
 | 
			
		||||
            zf._direntries = new System.Collections.Generic.List<ZipDirEntry>();
 | 
			
		||||
 | 
			
		||||
            ZipDirEntry de;
 | 
			
		||||
            while ((de = ZipDirEntry.Read(zf.ReadStream, zf._Debug)) != null)
 | 
			
		||||
            {
 | 
			
		||||
                if (zf._Debug) System.Console.WriteLine("  ZipFile::Read(): ZipDirEntry: {0}", de.FileName);
 | 
			
		||||
                zf._direntries.Add(de);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return zf;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public System.Collections.Generic.IEnumerator<ZipEntry> GetEnumerator()
 | 
			
		||||
        {
 | 
			
		||||
            foreach (ZipEntry e in _entries)
 | 
			
		||||
                yield return e;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
 | 
			
		||||
        {
 | 
			
		||||
            return GetEnumerator();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public void ExtractAll(string path)
 | 
			
		||||
        {
 | 
			
		||||
            ExtractAll(path, false);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public void ExtractAll(string path, bool WantVerbose)
 | 
			
		||||
        {
 | 
			
		||||
            bool header = WantVerbose;
 | 
			
		||||
            foreach (ZipEntry e in _entries)
 | 
			
		||||
            {
 | 
			
		||||
                if (header)
 | 
			
		||||
                {
 | 
			
		||||
                    System.Console.WriteLine("\n{1,-22} {2,-6} {3,4}   {4,-8}  {0}",
 | 
			
		||||
                                 "Name", "Modified", "Size", "Ratio", "Packed");
 | 
			
		||||
                    System.Console.WriteLine(new System.String('-', 72));
 | 
			
		||||
                    header = false;
 | 
			
		||||
                }
 | 
			
		||||
                if (WantVerbose)
 | 
			
		||||
                    System.Console.WriteLine("{1,-22} {2,-6} {3,4:F0}%   {4,-8} {0}",
 | 
			
		||||
                                 e.FileName,
 | 
			
		||||
                                 e.LastModified.ToString("yyyy-MM-dd HH:mm:ss"),
 | 
			
		||||
                                 e.UncompressedSize,
 | 
			
		||||
                                 e.CompressionRatio,
 | 
			
		||||
                                 e.CompressedSize);
 | 
			
		||||
                e.Extract(path);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public void Extract(string filename)
 | 
			
		||||
        {
 | 
			
		||||
            this[filename].Extract();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public void Extract(string filename, System.IO.Stream s)
 | 
			
		||||
        {
 | 
			
		||||
            this[filename].Extract(s);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public ZipEntry this[String filename]
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                foreach (ZipEntry e in _entries)
 | 
			
		||||
                {
 | 
			
		||||
                    if (e.FileName == filename) return e;
 | 
			
		||||
                }
 | 
			
		||||
                return null;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        // the destructor
 | 
			
		||||
        ~ZipFile()
 | 
			
		||||
        {
 | 
			
		||||
            // call Dispose with false.  Since we're in the
 | 
			
		||||
            // destructor call, the managed resources will be
 | 
			
		||||
            // disposed of anyways.
 | 
			
		||||
            Dispose(false);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void Dispose()
 | 
			
		||||
        {
 | 
			
		||||
            // dispose of the managed and unmanaged resources
 | 
			
		||||
            Dispose(true);
 | 
			
		||||
 | 
			
		||||
            // tell the GC that the Finalize process no longer needs
 | 
			
		||||
            // to be run for this object.
 | 
			
		||||
            GC.SuppressFinalize(this);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        protected virtual void Dispose(bool disposeManagedResources)
 | 
			
		||||
        {
 | 
			
		||||
            if (!this._disposed)
 | 
			
		||||
            {
 | 
			
		||||
                if (disposeManagedResources)
 | 
			
		||||
                {
 | 
			
		||||
                    // dispose managed resources
 | 
			
		||||
                    if (_readstream != null)
 | 
			
		||||
                    {
 | 
			
		||||
                        _readstream.Dispose();
 | 
			
		||||
                        _readstream = null;
 | 
			
		||||
                    }
 | 
			
		||||
                    if (_writestream != null)
 | 
			
		||||
                    {
 | 
			
		||||
                        _writestream.Dispose();
 | 
			
		||||
                        _writestream = null;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                this._disposed = true;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private System.IO.Stream _readstream;
 | 
			
		||||
        private System.IO.FileStream _writestream;
 | 
			
		||||
        private bool _Debug = false;
 | 
			
		||||
        private bool _disposed = false;
 | 
			
		||||
        private System.Collections.Generic.List<ZipEntry> _entries = null;
 | 
			
		||||
        private System.Collections.Generic.List<ZipDirEntry> _direntries = null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#region More Info
 | 
			
		||||
// Example usage: 
 | 
			
		||||
// 1. Extracting all files from a Zip file: 
 | 
			
		||||
//
 | 
			
		||||
//     try 
 | 
			
		||||
//     {
 | 
			
		||||
//       using(ZipFile zip= ZipFile.Read(ZipFile))
 | 
			
		||||
//       {
 | 
			
		||||
//         zip.ExtractAll(TargetDirectory, true);
 | 
			
		||||
//       }
 | 
			
		||||
//     }
 | 
			
		||||
//     catch (System.Exception ex1)
 | 
			
		||||
//     {
 | 
			
		||||
//       System.Console.Error.WriteLine("exception: " + ex1);
 | 
			
		||||
//     }
 | 
			
		||||
//
 | 
			
		||||
// 2. Extracting files from a zip individually:
 | 
			
		||||
//
 | 
			
		||||
//     try 
 | 
			
		||||
//     {
 | 
			
		||||
//       using(ZipFile zip= ZipFile.Read(ZipFile)) 
 | 
			
		||||
//       {
 | 
			
		||||
//         foreach (ZipEntry e in zip) 
 | 
			
		||||
//         {
 | 
			
		||||
//           e.Extract(TargetDirectory);
 | 
			
		||||
//         }
 | 
			
		||||
//       }
 | 
			
		||||
//     }
 | 
			
		||||
//     catch (System.Exception ex1)
 | 
			
		||||
//     {
 | 
			
		||||
//       System.Console.Error.WriteLine("exception: " + ex1);
 | 
			
		||||
//     }
 | 
			
		||||
//
 | 
			
		||||
// 3. Creating a zip archive: 
 | 
			
		||||
//
 | 
			
		||||
//     try 
 | 
			
		||||
//     {
 | 
			
		||||
//       using(ZipFile zip= new ZipFile(NewZipFile)) 
 | 
			
		||||
//       {
 | 
			
		||||
//
 | 
			
		||||
//         String[] filenames= System.IO.Directory.GetFiles(Directory); 
 | 
			
		||||
//         foreach (String filename in filenames) 
 | 
			
		||||
//         {
 | 
			
		||||
//           zip.Add(filename);
 | 
			
		||||
//         }
 | 
			
		||||
//
 | 
			
		||||
//         zip.Save(); 
 | 
			
		||||
//       }
 | 
			
		||||
//
 | 
			
		||||
//     }
 | 
			
		||||
//     catch (System.Exception ex1)
 | 
			
		||||
//     {
 | 
			
		||||
//       System.Console.Error.WriteLine("exception: " + ex1);
 | 
			
		||||
//     }
 | 
			
		||||
//
 | 
			
		||||
//
 | 
			
		||||
// ==================================================================
 | 
			
		||||
//
 | 
			
		||||
//
 | 
			
		||||
//
 | 
			
		||||
// Information on the ZIP format:
 | 
			
		||||
//
 | 
			
		||||
// From
 | 
			
		||||
// http://www.pkware.com/business_and_developers/developer/popups/appnote.txt
 | 
			
		||||
//
 | 
			
		||||
//  Overall .ZIP file format:
 | 
			
		||||
//
 | 
			
		||||
//     [local file header 1]
 | 
			
		||||
//     [file data 1]
 | 
			
		||||
//     [data descriptor 1]  ** sometimes
 | 
			
		||||
//     . 
 | 
			
		||||
//     .
 | 
			
		||||
//     .
 | 
			
		||||
//     [local file header n]
 | 
			
		||||
//     [file data n]
 | 
			
		||||
//     [data descriptor n]   ** sometimes
 | 
			
		||||
//     [archive decryption header] 
 | 
			
		||||
//     [archive extra data record] 
 | 
			
		||||
//     [central directory]
 | 
			
		||||
//     [zip64 end of central directory record]
 | 
			
		||||
//     [zip64 end of central directory locator] 
 | 
			
		||||
//     [end of central directory record]
 | 
			
		||||
//
 | 
			
		||||
// Local File Header format:
 | 
			
		||||
//         local file header signature     4 bytes  (0x04034b50)
 | 
			
		||||
//         version needed to extract       2 bytes
 | 
			
		||||
//         general purpose bit flag        2 bytes
 | 
			
		||||
//         compression method              2 bytes
 | 
			
		||||
//         last mod file time              2 bytes
 | 
			
		||||
//         last mod file date              2 bytes
 | 
			
		||||
//         crc-32                          4 bytes
 | 
			
		||||
//         compressed size                 4 bytes
 | 
			
		||||
//         uncompressed size               4 bytes
 | 
			
		||||
//         file name length                2 bytes
 | 
			
		||||
//         extra field length              2 bytes
 | 
			
		||||
//         file name                       varies
 | 
			
		||||
//         extra field                     varies
 | 
			
		||||
//
 | 
			
		||||
//
 | 
			
		||||
// Data descriptor:  (used only when bit 3 of the general purpose bitfield is set)
 | 
			
		||||
//         local file header signature     4 bytes  (0x08074b50)
 | 
			
		||||
//         crc-32                          4 bytes
 | 
			
		||||
//         compressed size                 4 bytes
 | 
			
		||||
//         uncompressed size               4 bytes
 | 
			
		||||
//
 | 
			
		||||
//
 | 
			
		||||
//   Central directory structure:
 | 
			
		||||
//
 | 
			
		||||
//       [file header 1]
 | 
			
		||||
//       .
 | 
			
		||||
//       .
 | 
			
		||||
//       . 
 | 
			
		||||
//       [file header n]
 | 
			
		||||
//       [digital signature] 
 | 
			
		||||
//
 | 
			
		||||
//
 | 
			
		||||
//       File header:  (This is ZipDirEntry in the code above)
 | 
			
		||||
//         central file header signature   4 bytes  (0x02014b50)
 | 
			
		||||
//         version made by                 2 bytes
 | 
			
		||||
//         version needed to extract       2 bytes
 | 
			
		||||
//         general purpose bit flag        2 bytes
 | 
			
		||||
//         compression method              2 bytes
 | 
			
		||||
//         last mod file time              2 bytes
 | 
			
		||||
//         last mod file date              2 bytes
 | 
			
		||||
//         crc-32                          4 bytes
 | 
			
		||||
//         compressed size                 4 bytes
 | 
			
		||||
//         uncompressed size               4 bytes
 | 
			
		||||
//         file name length                2 bytes
 | 
			
		||||
//         extra field length              2 bytes
 | 
			
		||||
//         file comment length             2 bytes
 | 
			
		||||
//         disk number start               2 bytes
 | 
			
		||||
//         internal file attributes        2 bytes
 | 
			
		||||
//         external file attributes        4 bytes
 | 
			
		||||
//         relative offset of local header 4 bytes
 | 
			
		||||
//         file name (variable size)
 | 
			
		||||
//         extra field (variable size)
 | 
			
		||||
//         file comment (variable size)
 | 
			
		||||
//
 | 
			
		||||
// End of central directory record:
 | 
			
		||||
//
 | 
			
		||||
//         end of central dir signature    4 bytes  (0x06054b50)
 | 
			
		||||
//         number of this disk             2 bytes
 | 
			
		||||
//         number of the disk with the
 | 
			
		||||
//         start of the central directory  2 bytes
 | 
			
		||||
//         total number of entries in the
 | 
			
		||||
//         central directory on this disk  2 bytes
 | 
			
		||||
//         total number of entries in
 | 
			
		||||
//         the central directory           2 bytes
 | 
			
		||||
//         size of the central directory   4 bytes
 | 
			
		||||
//         offset of start of central
 | 
			
		||||
//         directory with respect to
 | 
			
		||||
//         the starting disk number        4 bytes
 | 
			
		||||
//         .ZIP file comment length        2 bytes
 | 
			
		||||
//         .ZIP file comment       (variable size)
 | 
			
		||||
//
 | 
			
		||||
// date and time are packed values, as MSDOS did them
 | 
			
		||||
// time: bits 0-4 : second
 | 
			
		||||
//            5-10: minute
 | 
			
		||||
//            11-15: hour
 | 
			
		||||
// date  bits 0-4 : day
 | 
			
		||||
//            5-8: month
 | 
			
		||||
//            9-15 year (since 1980)
 | 
			
		||||
//
 | 
			
		||||
// see http://www.vsft.com/hal/dostime.htm
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
@@ -1,139 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: GroupBox.cs                                  //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
using Microsoft.Xna.Framework;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
using Microsoft.Xna.Framework.Graphics;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
    public enum GroupBoxType
 | 
			
		||||
    {
 | 
			
		||||
        Normal,
 | 
			
		||||
        Flat
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public class GroupBox : Container
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////       
 | 
			
		||||
        private GroupBoxType type = GroupBoxType.Normal;
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region //// Properties ////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        public virtual GroupBoxType Type
 | 
			
		||||
        {
 | 
			
		||||
            get { return type; }
 | 
			
		||||
            set { type = value; Invalidate(); }
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region //// Construstors //////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////       
 | 
			
		||||
        public GroupBox(Manager manager)
 | 
			
		||||
            : base(manager)
 | 
			
		||||
        {
 | 
			
		||||
            CheckLayer(Skin, "Control");
 | 
			
		||||
            CheckLayer(Skin, "Flat");
 | 
			
		||||
 | 
			
		||||
            CanFocus = false;
 | 
			
		||||
            Passive = true;
 | 
			
		||||
            Width = 64;
 | 
			
		||||
            Height = 64;
 | 
			
		||||
            BackColor = Color.Transparent;
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region //// Methods ///////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
        public override void Init()
 | 
			
		||||
        {
 | 
			
		||||
            base.Init();
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private void AdjustClientMargins()
 | 
			
		||||
        {
 | 
			
		||||
            SkinLayer layer = this.type == GroupBoxType.Normal ? this.Skin.Layers["Control"] : this.Skin.Layers["Flat"];
 | 
			
		||||
            SpriteFont font = (layer.Text != null && layer.Text.Font != null) ? layer.Text.Font.Resource : null;
 | 
			
		||||
            Vector2 size = font.MeasureString(this.Text);
 | 
			
		||||
            var cm = this.ClientMargins;
 | 
			
		||||
            cm.Top = string.IsNullOrWhiteSpace(this.Text) ? this.ClientTop : (int)size.Y;
 | 
			
		||||
            this.ClientMargins = new Margins(cm.Left, cm.Top, cm.Right, cm.Bottom);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        protected override void OnTextChanged(EventArgs e)
 | 
			
		||||
        {
 | 
			
		||||
            base.OnTextChanged(e);
 | 
			
		||||
            AdjustClientMargins();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        protected internal override void OnSkinChanged(EventArgs e)
 | 
			
		||||
        {
 | 
			
		||||
            base.OnSkinChanged(e);
 | 
			
		||||
            AdjustClientMargins();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
        protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
 | 
			
		||||
        {
 | 
			
		||||
            SkinLayer layer = type == GroupBoxType.Normal ? Skin.Layers["Control"] : Skin.Layers["Flat"];
 | 
			
		||||
            SpriteFont font = (layer.Text != null && layer.Text.Font != null) ? layer.Text.Font.Resource : null;
 | 
			
		||||
            Color col = (layer.Text != null) ? layer.Text.Colors.Enabled : Color.White;
 | 
			
		||||
            Point offset = new Point(layer.Text.OffsetX, layer.Text.OffsetY);
 | 
			
		||||
            Vector2 size = font.MeasureString(Text);
 | 
			
		||||
            size.Y = font.LineSpacing;
 | 
			
		||||
            Rectangle r = new Rectangle(rect.Left, rect.Top + (int)(size.Y / 2), rect.Width, rect.Height - (int)(size.Y / 2));
 | 
			
		||||
 | 
			
		||||
            renderer.DrawLayer(this, layer, r);
 | 
			
		||||
 | 
			
		||||
            if (font != null && Text != null && Text != "")
 | 
			
		||||
            {
 | 
			
		||||
                Rectangle bg = new Rectangle(r.Left + offset.X, (r.Top - (int)(size.Y / 2)) + offset.Y, (int)size.X + layer.ContentMargins.Horizontal, (int)size.Y);
 | 
			
		||||
                renderer.DrawLayer(Manager.Skin.Controls["Control"].Layers[0], bg, new Color(64, 64, 64), 0);
 | 
			
		||||
                renderer.DrawString(this, layer, Text, new Rectangle(r.Left, r.Top - (int)(size.Y / 2), (int)(size.X), (int)size.Y), true, 0, 0, false);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,94 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: GroupPanel.cs                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
using Microsoft.Xna.Framework;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
using Microsoft.Xna.Framework.Graphics;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
  public class GroupPanel: Container
 | 
			
		||||
  {
 | 
			
		||||
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////           
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Properties ////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Construstors //////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////       
 | 
			
		||||
    public GroupPanel(Manager manager): base(manager)
 | 
			
		||||
    {     
 | 
			
		||||
      CanFocus = false;
 | 
			
		||||
      Passive = true;
 | 
			
		||||
      Width = 64;
 | 
			
		||||
      Height = 64;
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Methods ///////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
    public override void Init()
 | 
			
		||||
    {
 | 
			
		||||
      base.Init();      
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
    protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
 | 
			
		||||
    {                  
 | 
			
		||||
      SkinLayer layer = Skin.Layers["Control"];      
 | 
			
		||||
      SpriteFont font = (layer.Text != null && layer.Text.Font != null) ? layer.Text.Font.Resource : null;
 | 
			
		||||
      Color col = (layer.Text != null) ? layer.Text.Colors.Enabled : Color.White;
 | 
			
		||||
      Point offset = new Point(layer.Text.OffsetX, layer.Text.OffsetY);        
 | 
			
		||||
               
 | 
			
		||||
      renderer.DrawLayer(this, layer, rect);
 | 
			
		||||
     
 | 
			
		||||
      if (font != null && Text != null && Text != "")
 | 
			
		||||
      {                      
 | 
			
		||||
        renderer.DrawString(this, layer, Text, new Rectangle(rect.Left, rect.Top + layer.ContentMargins.Top, rect.Width, Skin.ClientMargins.Top - layer.ContentMargins.Horizontal), false, offset.X, offset.Y, false);
 | 
			
		||||
      } 
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,197 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: ImageBox.cs                                  //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
using Microsoft.Xna.Framework;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
using Microsoft.Xna.Framework.Graphics;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{ 
 | 
			
		||||
 | 
			
		||||
  public class ImageBox: Control
 | 
			
		||||
  {
 | 
			
		||||
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                 
 | 
			
		||||
    private Texture2D image = null;
 | 
			
		||||
    private SizeMode sizeMode = SizeMode.Normal;
 | 
			
		||||
    private Rectangle sourceRect = Rectangle.Empty;   
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Properties ////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
    public Texture2D Image
 | 
			
		||||
    {
 | 
			
		||||
      get { return image; }
 | 
			
		||||
      set 
 | 
			
		||||
      {         
 | 
			
		||||
        image = value;
 | 
			
		||||
        sourceRect = new Rectangle(0, 0, image.Width, image.Height);
 | 
			
		||||
        Invalidate();
 | 
			
		||||
        if (!Suspended) OnImageChanged(new EventArgs());
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public Rectangle SourceRect
 | 
			
		||||
    {
 | 
			
		||||
      get { return sourceRect; }
 | 
			
		||||
      set 
 | 
			
		||||
      {                 
 | 
			
		||||
        if (value != null && image != null)
 | 
			
		||||
        {
 | 
			
		||||
          int l = value.Left;
 | 
			
		||||
          int t = value.Top;
 | 
			
		||||
          int w = value.Width;        
 | 
			
		||||
          int h = value.Height;
 | 
			
		||||
          
 | 
			
		||||
          if (l < 0) l = 0;
 | 
			
		||||
          if (t < 0) t = 0;
 | 
			
		||||
          if (w > image.Width) w = image.Width;
 | 
			
		||||
          if (h > image.Height) h = image.Height;
 | 
			
		||||
          if (l + w > image.Width) w = (image.Width - l); 
 | 
			
		||||
          if (t + h > image.Height) h = (image.Height - t);
 | 
			
		||||
 | 
			
		||||
          sourceRect = new Rectangle(l, t, w, h); 
 | 
			
		||||
        }
 | 
			
		||||
        else if (image != null)
 | 
			
		||||
        {
 | 
			
		||||
          sourceRect = new Rectangle(0, 0, image.Width, image.Height);
 | 
			
		||||
        }  
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
          sourceRect = Rectangle.Empty;
 | 
			
		||||
        }                
 | 
			
		||||
        Invalidate();
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public SizeMode SizeMode
 | 
			
		||||
    {
 | 
			
		||||
      get { return sizeMode; }
 | 
			
		||||
      set
 | 
			
		||||
      {
 | 
			
		||||
        if (value == SizeMode.Auto && image != null)
 | 
			
		||||
        {
 | 
			
		||||
          Width = image.Width;
 | 
			
		||||
          Height = image.Height;
 | 
			
		||||
        }
 | 
			
		||||
        sizeMode = value;
 | 
			
		||||
        Invalidate();
 | 
			
		||||
        if (!Suspended) OnSizeModeChanged(new EventArgs());
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Events ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                     
 | 
			
		||||
    public event EventHandler ImageChanged;
 | 
			
		||||
    public event EventHandler SizeModeChanged;
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Construstors //////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////       
 | 
			
		||||
    public ImageBox(Manager manager): base(manager)
 | 
			
		||||
    {                 
 | 
			
		||||
    }    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
    
 | 
			
		||||
    #region //// Methods ///////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public override void Init()
 | 
			
		||||
    {      
 | 
			
		||||
      base.Init();  
 | 
			
		||||
      CanFocus = false;   
 | 
			
		||||
      Color = Color.White;        
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                          
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
 | 
			
		||||
    {      
 | 
			
		||||
      if (image != null)
 | 
			
		||||
      {
 | 
			
		||||
        if (sizeMode == SizeMode.Normal)
 | 
			
		||||
        {
 | 
			
		||||
          renderer.Draw(image, rect.X, rect.Y, sourceRect, Color);
 | 
			
		||||
        }
 | 
			
		||||
        else if (sizeMode == SizeMode.Auto)
 | 
			
		||||
        {          
 | 
			
		||||
          renderer.Draw(image, rect.X, rect.Y, sourceRect, Color);
 | 
			
		||||
        }
 | 
			
		||||
        else if (sizeMode == SizeMode.Stretched)
 | 
			
		||||
        {    
 | 
			
		||||
          renderer.Draw(image, rect, sourceRect, Color);
 | 
			
		||||
        }
 | 
			
		||||
        else if (sizeMode == SizeMode.Centered)
 | 
			
		||||
        {
 | 
			
		||||
          int x = (rect.Width / 2) - (image.Width / 2);
 | 
			
		||||
          int y = (rect.Height / 2) - (image.Height / 2);
 | 
			
		||||
          
 | 
			
		||||
          renderer.Draw(image, x, y, sourceRect, Color);
 | 
			
		||||
        }
 | 
			
		||||
        else if (sizeMode == SizeMode.Tiled)
 | 
			
		||||
        {
 | 
			
		||||
            renderer.DrawTileTexture(image, rect, Color);
 | 
			
		||||
        }
 | 
			
		||||
      }           
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    protected virtual void OnImageChanged(EventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      if (ImageChanged != null) ImageChanged.Invoke(this, e);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////  
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    protected virtual void OnSizeModeChanged(EventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      if (SizeModeChanged != null) SizeModeChanged.Invoke(this, e);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////  
 | 
			
		||||
 | 
			
		||||
    #endregion  
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,732 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: InputSystem.cs                               //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using Microsoft.Xna.Framework;
 | 
			
		||||
using Microsoft.Xna.Framework.Input;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
  #region //// Enums /////////////
 | 
			
		||||
  
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
  [Flags]
 | 
			
		||||
  public enum InputMethods
 | 
			
		||||
  {    
 | 
			
		||||
    None = 0x00,    
 | 
			
		||||
    Keyboard = 0x01,
 | 
			
		||||
    Mouse = 0x02,
 | 
			
		||||
    GamePad = 0x04,
 | 
			
		||||
    All = Keyboard | Mouse | 0x04
 | 
			
		||||
  }
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
  
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
  public enum MouseButton
 | 
			
		||||
  {
 | 
			
		||||
    None = 0,
 | 
			
		||||
    Left,
 | 
			
		||||
    Right,
 | 
			
		||||
    Middle,
 | 
			
		||||
    XButton1,
 | 
			
		||||
    XButton2    
 | 
			
		||||
  }
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
  public enum MouseScrollDirection
 | 
			
		||||
  {
 | 
			
		||||
    None = 0,
 | 
			
		||||
    Down = 1,
 | 
			
		||||
    Up = 2
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
  public enum GamePadButton
 | 
			
		||||
  {
 | 
			
		||||
    None = 0,
 | 
			
		||||
    Start = 6,
 | 
			
		||||
    Back,
 | 
			
		||||
    Up,
 | 
			
		||||
    Down,
 | 
			
		||||
    Left,
 | 
			
		||||
    Right,
 | 
			
		||||
    A,
 | 
			
		||||
    B,
 | 
			
		||||
    X,
 | 
			
		||||
    Y,
 | 
			
		||||
    BigButton,
 | 
			
		||||
    LeftShoulder,
 | 
			
		||||
    RightShoulder,
 | 
			
		||||
    LeftTrigger,
 | 
			
		||||
    RightTrigger,
 | 
			
		||||
    LeftStick,
 | 
			
		||||
    RightStick,
 | 
			
		||||
    LeftStickLeft,
 | 
			
		||||
    LeftStickRight,
 | 
			
		||||
    LeftStickUp,
 | 
			
		||||
    LeftStickDown,
 | 
			
		||||
    RightStickLeft,
 | 
			
		||||
    RightStickRight,
 | 
			
		||||
    RightStickUp,
 | 
			
		||||
    RightStickDown    
 | 
			
		||||
  }
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
  public enum ActivePlayer
 | 
			
		||||
  {
 | 
			
		||||
    None = -1,
 | 
			
		||||
    One = 0,
 | 
			
		||||
    Two = 1,
 | 
			
		||||
    Three = 2,
 | 
			
		||||
    Four = 3
 | 
			
		||||
  }
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
  #endregion       
 | 
			
		||||
 | 
			
		||||
  #region //// Structs ///////////
 | 
			
		||||
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
  public struct GamePadVectors
 | 
			
		||||
  {
 | 
			
		||||
    public Vector2 LeftStick;
 | 
			
		||||
    public Vector2 RightStick;
 | 
			
		||||
    public float LeftTrigger;
 | 
			
		||||
    public float RightTrigger;
 | 
			
		||||
  } 
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
  public struct InputOffset
 | 
			
		||||
  {
 | 
			
		||||
    public int X;
 | 
			
		||||
    public int Y;
 | 
			
		||||
    public float RatioX;
 | 
			
		||||
    public float RatioY;        
 | 
			
		||||
    
 | 
			
		||||
    public InputOffset(int x, int y, float rx, float ry)
 | 
			
		||||
    {
 | 
			
		||||
      X = x;
 | 
			
		||||
      Y = y;
 | 
			
		||||
      RatioX = rx;
 | 
			
		||||
      RatioY = ry;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
  #endregion
 | 
			
		||||
 | 
			
		||||
  #region //// Classes ///////////
 | 
			
		||||
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
  public class InputSystem: Disposable
 | 
			
		||||
  {
 | 
			
		||||
  
 | 
			
		||||
    #region //// Classes ///////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    private class InputKey
 | 
			
		||||
    {
 | 
			
		||||
      public Keys Key = Keys.None;
 | 
			
		||||
      public bool Pressed = false;
 | 
			
		||||
      public double Countdown = RepeatDelay;
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    private class InputMouseButton
 | 
			
		||||
    {
 | 
			
		||||
      public MouseButton Button = MouseButton.None;
 | 
			
		||||
      public bool Pressed = false;
 | 
			
		||||
      public double Countdown = RepeatDelay;
 | 
			
		||||
      
 | 
			
		||||
      public InputMouseButton()
 | 
			
		||||
      {
 | 
			
		||||
      }
 | 
			
		||||
      
 | 
			
		||||
      public InputMouseButton(MouseButton button)
 | 
			
		||||
      {
 | 
			
		||||
        Button = button;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
    private class InputMouse
 | 
			
		||||
    {
 | 
			
		||||
      public MouseState State = new MouseState();
 | 
			
		||||
      public Point Position = new Point(0, 0);    
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    private class InputGamePadButton
 | 
			
		||||
    {
 | 
			
		||||
      public GamePadButton Button = GamePadButton.None;
 | 
			
		||||
      public bool Pressed = false;
 | 
			
		||||
      public double Countdown = RepeatDelay;
 | 
			
		||||
      
 | 
			
		||||
      public InputGamePadButton()
 | 
			
		||||
      {        
 | 
			
		||||
      }
 | 
			
		||||
      
 | 
			
		||||
      public InputGamePadButton(GamePadButton button)
 | 
			
		||||
      {
 | 
			
		||||
        Button = button;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Consts ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    private const int RepeatDelay = 500;
 | 
			
		||||
    private const int RepeatRate = 50;
 | 
			
		||||
    private float ClickThreshold = 0.5f;
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
    
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
    private List<InputKey> keys = new List<InputKey>();
 | 
			
		||||
    private List<InputMouseButton> mouseButtons = new List<InputMouseButton>();
 | 
			
		||||
    private List<InputGamePadButton> gamePadButtons = new List<InputGamePadButton>();        
 | 
			
		||||
    private MouseState mouseState = new MouseState();
 | 
			
		||||
    private GamePadState gamePadState = new GamePadState();    
 | 
			
		||||
    private Manager manager = null;
 | 
			
		||||
    private InputOffset inputOffset = new InputOffset(0, 0, 1.0f, 1.0f);
 | 
			
		||||
    private InputMethods inputMethods = InputMethods.All;
 | 
			
		||||
    private ActivePlayer activePlayer = ActivePlayer.None;       
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion   
 | 
			
		||||
        
 | 
			
		||||
    #region //// Properties ////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets or gets input offset and ratio when rescaling controls in render target.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public virtual InputOffset InputOffset
 | 
			
		||||
    {
 | 
			
		||||
      get { return inputOffset; }
 | 
			
		||||
      set { inputOffset = value; }
 | 
			
		||||
    }  
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets or gets input methods allowed for navigation.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public virtual InputMethods InputMethods
 | 
			
		||||
    {
 | 
			
		||||
      get { return inputMethods; }
 | 
			
		||||
      set { inputMethods = value; }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public virtual ActivePlayer ActivePlayer
 | 
			
		||||
    {
 | 
			
		||||
      get { return activePlayer; }
 | 
			
		||||
      set { activePlayer = value; }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Events ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////		        
 | 
			
		||||
    public event KeyEventHandler KeyDown;
 | 
			
		||||
    public event KeyEventHandler KeyPress;
 | 
			
		||||
    public event KeyEventHandler KeyUp;    
 | 
			
		||||
        
 | 
			
		||||
    public event MouseEventHandler MouseDown;
 | 
			
		||||
    public event MouseEventHandler MousePress;
 | 
			
		||||
    public event MouseEventHandler MouseUp;        
 | 
			
		||||
    public event MouseEventHandler MouseMove; 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Occurs when the mouse is scrolled.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public event MouseEventHandler MouseScroll;
 | 
			
		||||
    
 | 
			
		||||
    public event GamePadEventHandler GamePadUp;
 | 
			
		||||
    public event GamePadEventHandler GamePadDown;
 | 
			
		||||
    public event GamePadEventHandler GamePadPress;
 | 
			
		||||
    public event GamePadEventHandler GamePadMove;    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Constructors //////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public InputSystem(Manager manager, InputOffset offset)
 | 
			
		||||
    {
 | 
			
		||||
      this.inputOffset = offset;
 | 
			
		||||
      this.manager = manager;
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public InputSystem(Manager manager): this(manager, new InputOffset(0, 0, 1.0f, 1.0f))
 | 
			
		||||
    {          
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Methods ///////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public virtual void Initialize()
 | 
			
		||||
    {
 | 
			
		||||
      keys.Clear();
 | 
			
		||||
      mouseButtons.Clear();
 | 
			
		||||
      gamePadButtons.Clear();      
 | 
			
		||||
      
 | 
			
		||||
      #if (!XBOX && !XBOX_FAKE)      
 | 
			
		||||
        foreach (string str in Enum.GetNames(typeof(Keys)))
 | 
			
		||||
        {
 | 
			
		||||
          InputKey key = new InputKey();
 | 
			
		||||
          key.Key = (Keys)Enum.Parse(typeof(Keys), str);
 | 
			
		||||
          keys.Add(key);
 | 
			
		||||
        }
 | 
			
		||||
              
 | 
			
		||||
        foreach (string str in Enum.GetNames(typeof(MouseButton)))
 | 
			
		||||
        {
 | 
			
		||||
          InputMouseButton btn = new InputMouseButton();
 | 
			
		||||
          btn.Button = (MouseButton)Enum.Parse(typeof(MouseButton), str);
 | 
			
		||||
          mouseButtons.Add(btn);
 | 
			
		||||
        }     
 | 
			
		||||
              
 | 
			
		||||
        foreach (string str in Enum.GetNames(typeof(GamePadButton)))
 | 
			
		||||
        {
 | 
			
		||||
          InputGamePadButton btn = new InputGamePadButton();
 | 
			
		||||
          btn.Button = (GamePadButton)Enum.Parse(typeof(GamePadButton), str);
 | 
			
		||||
          gamePadButtons.Add(btn);
 | 
			
		||||
        }     
 | 
			
		||||
      #else             
 | 
			
		||||
        gamePadButtons.Add(new InputGamePadButton(GamePadButton.None));
 | 
			
		||||
        gamePadButtons.Add(new InputGamePadButton(GamePadButton.Start));
 | 
			
		||||
        gamePadButtons.Add(new InputGamePadButton(GamePadButton.Back));
 | 
			
		||||
        gamePadButtons.Add(new InputGamePadButton(GamePadButton.Up));        
 | 
			
		||||
        gamePadButtons.Add(new InputGamePadButton(GamePadButton.Down));
 | 
			
		||||
        gamePadButtons.Add(new InputGamePadButton(GamePadButton.Left));
 | 
			
		||||
        gamePadButtons.Add(new InputGamePadButton(GamePadButton.Right));       
 | 
			
		||||
        gamePadButtons.Add(new InputGamePadButton(GamePadButton.A));
 | 
			
		||||
        gamePadButtons.Add(new InputGamePadButton(GamePadButton.B));
 | 
			
		||||
        gamePadButtons.Add(new InputGamePadButton(GamePadButton.X));
 | 
			
		||||
        gamePadButtons.Add(new InputGamePadButton(GamePadButton.Y));         
 | 
			
		||||
        gamePadButtons.Add(new InputGamePadButton(GamePadButton.BigButton)); 
 | 
			
		||||
        gamePadButtons.Add(new InputGamePadButton(GamePadButton.LeftShoulder)); 
 | 
			
		||||
        gamePadButtons.Add(new InputGamePadButton(GamePadButton.RightShoulder)); 
 | 
			
		||||
        gamePadButtons.Add(new InputGamePadButton(GamePadButton.LeftTrigger)); 
 | 
			
		||||
        gamePadButtons.Add(new InputGamePadButton(GamePadButton.RightTrigger));         
 | 
			
		||||
        gamePadButtons.Add(new InputGamePadButton(GamePadButton.LeftStick)); 
 | 
			
		||||
        gamePadButtons.Add(new InputGamePadButton(GamePadButton.RightStick));         
 | 
			
		||||
        gamePadButtons.Add(new InputGamePadButton(GamePadButton.LeftStickLeft));         
 | 
			
		||||
        gamePadButtons.Add(new InputGamePadButton(GamePadButton.LeftStickRight));                 
 | 
			
		||||
        gamePadButtons.Add(new InputGamePadButton(GamePadButton.LeftStickUp));
 | 
			
		||||
        gamePadButtons.Add(new InputGamePadButton(GamePadButton.LeftStickDown));                         
 | 
			
		||||
        gamePadButtons.Add(new InputGamePadButton(GamePadButton.RightStickLeft));                 
 | 
			
		||||
        gamePadButtons.Add(new InputGamePadButton(GamePadButton.RightStickRight));                 
 | 
			
		||||
        gamePadButtons.Add(new InputGamePadButton(GamePadButton.RightStickUp));                 
 | 
			
		||||
        gamePadButtons.Add(new InputGamePadButton(GamePadButton.RightStickDown));                 
 | 
			
		||||
      #endif        
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public virtual void SendMouseState(MouseState state, GameTime gameTime)
 | 
			
		||||
    {
 | 
			
		||||
      UpdateMouse(state, gameTime);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public virtual void SendKeyboardState(KeyboardState state, GameTime gameTime)
 | 
			
		||||
    {
 | 
			
		||||
      UpdateKeys(state, gameTime);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public virtual void SendGamePadState(PlayerIndex playerIndex, GamePadState state, GameTime gameTime)
 | 
			
		||||
    {
 | 
			
		||||
      UpdateGamePad(playerIndex, state, gameTime);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public virtual void Update(GameTime gameTime)
 | 
			
		||||
    {
 | 
			
		||||
      #if (!XBOX && !XBOX_FAKE)
 | 
			
		||||
        MouseState ms = Mouse.GetState();
 | 
			
		||||
        KeyboardState ks = Keyboard.GetState();      
 | 
			
		||||
      #endif  
 | 
			
		||||
            
 | 
			
		||||
          
 | 
			
		||||
      
 | 
			
		||||
      {
 | 
			
		||||
        #if (!XBOX && !XBOX_FAKE)
 | 
			
		||||
          if ((inputMethods & InputMethods.Mouse) == InputMethods.Mouse) UpdateMouse(ms, gameTime);
 | 
			
		||||
          if ((inputMethods & InputMethods.Keyboard) == InputMethods.Keyboard) UpdateKeys(ks, gameTime);                    
 | 
			
		||||
        #endif  
 | 
			
		||||
      }  
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    private ButtonState GetVectorState(GamePadButton button, GamePadState state)
 | 
			
		||||
    {
 | 
			
		||||
      ButtonState ret = ButtonState.Released;
 | 
			
		||||
      bool down = false;
 | 
			
		||||
      float t = ClickThreshold;
 | 
			
		||||
      
 | 
			
		||||
      switch (button)
 | 
			
		||||
      {
 | 
			
		||||
        case GamePadButton.LeftStickLeft: down = state.ThumbSticks.Left.X < -t; break;
 | 
			
		||||
        case GamePadButton.LeftStickRight: down = state.ThumbSticks.Left.X > t; break;
 | 
			
		||||
        case GamePadButton.LeftStickUp: down = state.ThumbSticks.Left.Y > t; break;
 | 
			
		||||
        case GamePadButton.LeftStickDown: down = state.ThumbSticks.Left.Y < -t; break;
 | 
			
		||||
 | 
			
		||||
        case GamePadButton.RightStickLeft: down = state.ThumbSticks.Right.X < -t; break;
 | 
			
		||||
        case GamePadButton.RightStickRight: down = state.ThumbSticks.Right.X > t; break;
 | 
			
		||||
        case GamePadButton.RightStickUp: down = state.ThumbSticks.Right.Y > t; break;
 | 
			
		||||
        case GamePadButton.RightStickDown: down = state.ThumbSticks.Right.Y < -t; break;      
 | 
			
		||||
        
 | 
			
		||||
        case GamePadButton.LeftTrigger: down = state.Triggers.Left > t; break;
 | 
			
		||||
        case GamePadButton.RightTrigger: down = state.Triggers.Right > t; break;
 | 
			
		||||
      }
 | 
			
		||||
      
 | 
			
		||||
      ret = down ? ButtonState.Pressed : ButtonState.Released;
 | 
			
		||||
            
 | 
			
		||||
      return ret;
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    private void UpdateGamePad(PlayerIndex playerIndex, GamePadState state, GameTime gameTime)
 | 
			
		||||
    {          
 | 
			
		||||
      GamePadEventArgs e = new GamePadEventArgs(playerIndex);      
 | 
			
		||||
      
 | 
			
		||||
      if (state.ThumbSticks.Left != gamePadState.ThumbSticks.Left ||
 | 
			
		||||
          state.ThumbSticks.Right != gamePadState.ThumbSticks.Right ||
 | 
			
		||||
          state.Triggers.Left != gamePadState.Triggers.Left ||
 | 
			
		||||
          state.Triggers.Right != gamePadState.Triggers.Right)
 | 
			
		||||
      {
 | 
			
		||||
        BuildGamePadEvent(state, GamePadButton.None, ref e);
 | 
			
		||||
        if (GamePadMove != null) GamePadMove.Invoke(this, e);        
 | 
			
		||||
      }           
 | 
			
		||||
 | 
			
		||||
      foreach (InputGamePadButton btn in gamePadButtons)
 | 
			
		||||
      {
 | 
			
		||||
        ButtonState bs = ButtonState.Released;
 | 
			
		||||
 | 
			
		||||
        if (btn.Button == GamePadButton.None) continue;
 | 
			
		||||
        else if (btn.Button == GamePadButton.A) bs = state.Buttons.A;
 | 
			
		||||
        else if (btn.Button == GamePadButton.B) bs = state.Buttons.B;
 | 
			
		||||
        else if (btn.Button == GamePadButton.Back) bs = state.Buttons.Back;
 | 
			
		||||
        else if (btn.Button == GamePadButton.Down) bs = state.DPad.Down;
 | 
			
		||||
        else if (btn.Button == GamePadButton.Left) bs = state.DPad.Left;
 | 
			
		||||
        else if (btn.Button == GamePadButton.Right) bs = state.DPad.Right;
 | 
			
		||||
        else if (btn.Button == GamePadButton.Start) bs = state.Buttons.Start;
 | 
			
		||||
        else if (btn.Button == GamePadButton.Up) bs = state.DPad.Up;
 | 
			
		||||
        else if (btn.Button == GamePadButton.X) bs = state.Buttons.X;
 | 
			
		||||
        else if (btn.Button == GamePadButton.Y) bs = state.Buttons.Y;
 | 
			
		||||
        else if (btn.Button == GamePadButton.BigButton) bs = state.Buttons.BigButton;
 | 
			
		||||
        else if (btn.Button == GamePadButton.LeftShoulder) bs = state.Buttons.LeftShoulder;
 | 
			
		||||
        else if (btn.Button == GamePadButton.RightShoulder) bs = state.Buttons.RightShoulder;
 | 
			
		||||
        else if (btn.Button == GamePadButton.LeftStick) bs = state.Buttons.LeftStick;
 | 
			
		||||
        else if (btn.Button == GamePadButton.RightStick) bs = state.Buttons.RightStick;                        
 | 
			
		||||
        else bs = GetVectorState(btn.Button, state);
 | 
			
		||||
        
 | 
			
		||||
        bool pressed = (bs == ButtonState.Pressed);
 | 
			
		||||
        if (pressed)
 | 
			
		||||
        {
 | 
			
		||||
          double ms = gameTime.ElapsedGameTime.TotalMilliseconds;          
 | 
			
		||||
          if (pressed) btn.Countdown -= ms;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if ((pressed) && (!btn.Pressed))
 | 
			
		||||
        {
 | 
			
		||||
          btn.Pressed = true;
 | 
			
		||||
          BuildGamePadEvent(state, btn.Button, ref e);
 | 
			
		||||
 | 
			
		||||
          if (GamePadDown != null) GamePadDown.Invoke(this, e);
 | 
			
		||||
          if (GamePadPress != null) GamePadPress.Invoke(this, e);
 | 
			
		||||
        }
 | 
			
		||||
        else if ((!pressed) && (btn.Pressed))
 | 
			
		||||
        {
 | 
			
		||||
          btn.Pressed = false;
 | 
			
		||||
          btn.Countdown = RepeatDelay;
 | 
			
		||||
          BuildGamePadEvent(state, btn.Button, ref e);
 | 
			
		||||
 | 
			
		||||
          if (GamePadUp != null) GamePadUp.Invoke(this, e);
 | 
			
		||||
        }
 | 
			
		||||
        else if (btn.Pressed && btn.Countdown < 0)
 | 
			
		||||
        {
 | 
			
		||||
          e.Button = btn.Button;
 | 
			
		||||
          btn.Countdown = RepeatRate;          
 | 
			
		||||
          BuildGamePadEvent(state, btn.Button, ref e);
 | 
			
		||||
 | 
			
		||||
          if (GamePadPress != null) GamePadPress.Invoke(this, e);          
 | 
			
		||||
        }
 | 
			
		||||
      }    
 | 
			
		||||
      gamePadState = state;
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    private void BuildGamePadEvent(GamePadState state, GamePadButton button, ref GamePadEventArgs e)
 | 
			
		||||
    {      
 | 
			
		||||
      e.State = state;
 | 
			
		||||
      e.Button = button;   
 | 
			
		||||
      e.Vectors.LeftStick = new Vector2(state.ThumbSticks.Left.X, state.ThumbSticks.Left.Y);
 | 
			
		||||
      e.Vectors.RightStick = new Vector2(state.ThumbSticks.Right.X, state.ThumbSticks.Right.Y);
 | 
			
		||||
      e.Vectors.LeftTrigger = state.Triggers.Left;
 | 
			
		||||
      e.Vectors.RightTrigger = state.Triggers.Right;
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    private void UpdateKeys(KeyboardState state, GameTime gameTime)
 | 
			
		||||
    {            
 | 
			
		||||
      #if (!XBOX && !XBOX_FAKE)
 | 
			
		||||
      
 | 
			
		||||
      KeyEventArgs e = new KeyEventArgs();
 | 
			
		||||
      
 | 
			
		||||
      e.Caps = (((ushort)NativeMethods.GetKeyState(0x14)) & 0xffff) != 0;      
 | 
			
		||||
      
 | 
			
		||||
      foreach (Keys key in state.GetPressedKeys())
 | 
			
		||||
      {
 | 
			
		||||
        if (key == Keys.LeftAlt || key == Keys.RightAlt) e.Alt = true;
 | 
			
		||||
        else if (key == Keys.LeftShift || key == Keys.RightShift) e.Shift = true;
 | 
			
		||||
        else if (key == Keys.LeftControl || key == Keys.RightControl) e.Control = true;        
 | 
			
		||||
      }        
 | 
			
		||||
 | 
			
		||||
      foreach (InputKey key in keys)
 | 
			
		||||
      {
 | 
			
		||||
        if (key.Key == Keys.LeftAlt || key.Key == Keys.RightAlt ||
 | 
			
		||||
            key.Key == Keys.LeftShift || key.Key == Keys.RightShift ||
 | 
			
		||||
            key.Key == Keys.LeftControl || key.Key == Keys.RightControl)
 | 
			
		||||
        {
 | 
			
		||||
          continue;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        bool pressed = state.IsKeyDown(key.Key);
 | 
			
		||||
 | 
			
		||||
        double ms = gameTime.ElapsedGameTime.TotalMilliseconds;        
 | 
			
		||||
        if (pressed) key.Countdown -= ms;        
 | 
			
		||||
 | 
			
		||||
        if ((pressed) && (!key.Pressed))
 | 
			
		||||
        {
 | 
			
		||||
          key.Pressed = true;
 | 
			
		||||
          e.Key = key.Key;     
 | 
			
		||||
                                       
 | 
			
		||||
          if (KeyDown != null) KeyDown.Invoke(this, e);
 | 
			
		||||
          if (KeyPress != null) KeyPress.Invoke(this, e);
 | 
			
		||||
        }
 | 
			
		||||
        else if ((!pressed) && (key.Pressed))
 | 
			
		||||
        {
 | 
			
		||||
          key.Pressed = false;
 | 
			
		||||
          key.Countdown = RepeatDelay;
 | 
			
		||||
          e.Key = key.Key;
 | 
			
		||||
          
 | 
			
		||||
          if (KeyUp != null) KeyUp.Invoke(this, e);
 | 
			
		||||
        }
 | 
			
		||||
        else if (key.Pressed && key.Countdown < 0)
 | 
			
		||||
        {
 | 
			
		||||
          key.Countdown = RepeatRate;   
 | 
			
		||||
          e.Key = key.Key;          
 | 
			
		||||
          
 | 
			
		||||
          if (KeyPress != null) KeyPress.Invoke(this, e);                 
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
      #endif
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    private Point RecalcPosition(Point pos)
 | 
			
		||||
    {
 | 
			
		||||
      return new Point((int)((pos.X - InputOffset.X) / InputOffset.RatioX), (int)((pos.Y - InputOffset.Y) / InputOffset.RatioY));
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
    private void AdjustPosition(ref MouseEventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      Rectangle screen = manager.Game.Window.ClientBounds;
 | 
			
		||||
 | 
			
		||||
      if (e.Position.X < 0) e.Position.X = 0;
 | 
			
		||||
      if (e.Position.Y < 0) e.Position.Y = 0;
 | 
			
		||||
      if (e.Position.X >= screen.Width) e.Position.X = screen.Width - 1;
 | 
			
		||||
      if (e.Position.Y >= screen.Height) e.Position.Y = screen.Height - 1;            
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    private void BuildMouseEvent(MouseState state, MouseButton button, ref MouseEventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      e.State = state;      
 | 
			
		||||
      e.Button = button;
 | 
			
		||||
 | 
			
		||||
      e.Position = new Point(state.X, state.Y);                        
 | 
			
		||||
      AdjustPosition(ref e);
 | 
			
		||||
 | 
			
		||||
      e.Position = RecalcPosition(e.Position);      
 | 
			
		||||
      e.State = new MouseState(e.Position.X, e.Position.Y, e.State.ScrollWheelValue, e.State.LeftButton, e.State.MiddleButton, e.State.RightButton, e.State.XButton1, e.State.XButton2);      
 | 
			
		||||
      
 | 
			
		||||
      Point pos = RecalcPosition(new Point(mouseState.X, mouseState.Y));                              
 | 
			
		||||
      e.Difference = new Point(e.Position.X - pos.X, e.Position.Y - pos.Y);                              
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
 | 
			
		||||
    private void BuildMouseEvent(MouseState state, MouseButton button, MouseScrollDirection direction, ref MouseEventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
        BuildMouseEvent(state, button, ref e);
 | 
			
		||||
 | 
			
		||||
        e.ScrollDirection = direction;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    private void UpdateMouse(MouseState state, GameTime gameTime)
 | 
			
		||||
    {            
 | 
			
		||||
      #if (!XBOX && !XBOX_FAKE)   
 | 
			
		||||
      
 | 
			
		||||
      if ((state.X != mouseState.X) || (state.Y != mouseState.Y))
 | 
			
		||||
      {
 | 
			
		||||
        MouseEventArgs e = new MouseEventArgs();          
 | 
			
		||||
        
 | 
			
		||||
        MouseButton btn = MouseButton.None;       
 | 
			
		||||
        if (state.LeftButton == ButtonState.Pressed) btn = MouseButton.Left;
 | 
			
		||||
        else if (state.RightButton == ButtonState.Pressed) btn = MouseButton.Right;
 | 
			
		||||
        else if (state.MiddleButton == ButtonState.Pressed) btn = MouseButton.Middle;
 | 
			
		||||
        else if (state.XButton1 == ButtonState.Pressed) btn = MouseButton.XButton1;
 | 
			
		||||
        else if (state.XButton2 == ButtonState.Pressed) btn = MouseButton.XButton2;
 | 
			
		||||
        
 | 
			
		||||
        BuildMouseEvent(state, btn, ref e);
 | 
			
		||||
        if (MouseMove != null) 
 | 
			
		||||
        {
 | 
			
		||||
          MouseMove.Invoke(this, e);
 | 
			
		||||
        }  
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      // Mouse wheel position changed
 | 
			
		||||
      if (state.ScrollWheelValue != mouseState.ScrollWheelValue)
 | 
			
		||||
      {
 | 
			
		||||
          MouseEventArgs e = new MouseEventArgs();
 | 
			
		||||
          MouseScrollDirection direction = state.ScrollWheelValue < mouseState.ScrollWheelValue ? MouseScrollDirection.Down : MouseScrollDirection.Up;
 | 
			
		||||
 | 
			
		||||
          BuildMouseEvent(state, MouseButton.None, direction, ref e);
 | 
			
		||||
 | 
			
		||||
          if (MouseScroll != null)
 | 
			
		||||
          {
 | 
			
		||||
              MouseScroll.Invoke(this, e);
 | 
			
		||||
          }
 | 
			
		||||
      }
 | 
			
		||||
      
 | 
			
		||||
      UpdateButtons(state, gameTime);    
 | 
			
		||||
      
 | 
			
		||||
      mouseState = state;
 | 
			
		||||
      
 | 
			
		||||
      #endif
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////        
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    private void UpdateButtons(MouseState state, GameTime gameTime)
 | 
			
		||||
    {          
 | 
			
		||||
      #if (!XBOX && !XBOX_FAKE)      
 | 
			
		||||
 | 
			
		||||
      MouseEventArgs e = new MouseEventArgs();
 | 
			
		||||
 | 
			
		||||
      foreach (InputMouseButton btn in mouseButtons)
 | 
			
		||||
      {      
 | 
			
		||||
        ButtonState bs = ButtonState.Released;
 | 
			
		||||
        
 | 
			
		||||
        if (btn.Button == MouseButton.Left) bs = state.LeftButton;
 | 
			
		||||
        else if (btn.Button == MouseButton.Right) bs = state.RightButton;
 | 
			
		||||
        else if (btn.Button == MouseButton.Middle) bs = state.MiddleButton;
 | 
			
		||||
        else if (btn.Button == MouseButton.XButton1) bs = state.XButton1;
 | 
			
		||||
        else if (btn.Button == MouseButton.XButton2) bs = state.XButton2;
 | 
			
		||||
        else continue;
 | 
			
		||||
      
 | 
			
		||||
        bool pressed = (bs == ButtonState.Pressed);                
 | 
			
		||||
        if (pressed)
 | 
			
		||||
        {
 | 
			
		||||
          double ms = gameTime.ElapsedGameTime.TotalMilliseconds;          
 | 
			
		||||
          if (pressed) btn.Countdown -= ms;
 | 
			
		||||
        } 
 | 
			
		||||
 | 
			
		||||
        if ((pressed) && (!btn.Pressed))
 | 
			
		||||
        {
 | 
			
		||||
          btn.Pressed = true;                    
 | 
			
		||||
          BuildMouseEvent(state, btn.Button, ref e);
 | 
			
		||||
          
 | 
			
		||||
          if (MouseDown != null) MouseDown.Invoke(this, e);
 | 
			
		||||
          if (MousePress != null) MousePress.Invoke(this, e);          
 | 
			
		||||
        }
 | 
			
		||||
        else if ((!pressed) && (btn.Pressed))
 | 
			
		||||
        {
 | 
			
		||||
          btn.Pressed = false;
 | 
			
		||||
          btn.Countdown = RepeatDelay;
 | 
			
		||||
          BuildMouseEvent(state, btn.Button, ref e);
 | 
			
		||||
 | 
			
		||||
          if (MouseUp != null) MouseUp.Invoke(this, e);
 | 
			
		||||
        }
 | 
			
		||||
        else if (btn.Pressed && btn.Countdown < 0)
 | 
			
		||||
        {
 | 
			
		||||
          e.Button = btn.Button;
 | 
			
		||||
          btn.Countdown = RepeatRate;
 | 
			
		||||
          BuildMouseEvent(state, btn.Button, ref e);
 | 
			
		||||
          
 | 
			
		||||
          if (MousePress != null) MousePress.Invoke(this, e);          
 | 
			
		||||
        }
 | 
			
		||||
      }      
 | 
			
		||||
      
 | 
			
		||||
      #endif
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
  } 
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
  #endregion
 | 
			
		||||
  
 | 
			
		||||
}
 | 
			
		||||
@@ -1,461 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: KeyboardLayout.cs                            //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
/*****
 | 
			
		||||
 * Made Changes to the German Input, based on Kergos, input.
 | 
			
		||||
 *****/
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
        
 | 
			
		||||
//////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
using Microsoft.Xna.Framework.Input;
 | 
			
		||||
using System.Globalization;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Text;
 | 
			
		||||
//////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{     
 | 
			
		||||
		
 | 
			
		||||
	public class KeyboardLayout
 | 
			
		||||
	{    
 | 
			
		||||
        
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
                
 | 
			
		||||
    //////////////////////////////////////////////////////////////////////////            
 | 
			
		||||
    private string name = "English";  
 | 
			
		||||
    public List<int> LayoutList = new List<int>();
 | 
			
		||||
    //////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
   
 | 
			
		||||
    #endregion                
 | 
			
		||||
    
 | 
			
		||||
    #region //// Properties ////////
 | 
			
		||||
	  
 | 
			
		||||
	  //////////////////////////////////////////////////////////////////////////	  
 | 
			
		||||
    public virtual string Name
 | 
			
		||||
    {
 | 
			
		||||
      get { return name; }
 | 
			
		||||
      set { name = value; }
 | 
			
		||||
    }    
 | 
			
		||||
	  //////////////////////////////////////////////////////////////////////////
 | 
			
		||||
	  
 | 
			
		||||
	  #endregion        
 | 
			
		||||
	  
 | 
			
		||||
    #region //// Constructors //////
 | 
			
		||||
        
 | 
			
		||||
	  //////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public KeyboardLayout()
 | 
			
		||||
    {          
 | 
			
		||||
      LayoutList.Add(1033);
 | 
			
		||||
    }
 | 
			
		||||
    //////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    #endregion      	  
 | 
			
		||||
        
 | 
			
		||||
    #region //// Methods ///////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
    public virtual string GetKey(KeyEventArgs args)
 | 
			
		||||
    {
 | 
			
		||||
      string ret = "";
 | 
			
		||||
      
 | 
			
		||||
      if (args.Caps && !args.Shift) ret = KeyToString(args).ToUpper();
 | 
			
		||||
      else if (!args.Caps && args.Shift) ret = KeyToString(args).ToUpper();
 | 
			
		||||
      else if (args.Caps && args.Shift) ret = KeyToString(args).ToLower();
 | 
			
		||||
      else if (!args.Caps && !args.Shift) ret = KeyToString(args).ToLower();
 | 
			
		||||
      
 | 
			
		||||
      
 | 
			
		||||
      return ret;
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
    protected virtual string KeyToString(KeyEventArgs args)
 | 
			
		||||
    {
 | 
			
		||||
      switch (args.Key)
 | 
			
		||||
      {
 | 
			
		||||
        case Keys.A:
 | 
			
		||||
          return "a";        
 | 
			
		||||
        case Keys.B:
 | 
			
		||||
          return "b";
 | 
			
		||||
        case Keys.C:
 | 
			
		||||
          return "c";
 | 
			
		||||
        case Keys.D:
 | 
			
		||||
          return "d";
 | 
			
		||||
        case Keys.E:
 | 
			
		||||
          return "e";
 | 
			
		||||
        case Keys.F:
 | 
			
		||||
          return "f";
 | 
			
		||||
        case Keys.G:
 | 
			
		||||
          return "g";
 | 
			
		||||
        case Keys.H:
 | 
			
		||||
          return "h";
 | 
			
		||||
        case Keys.I:
 | 
			
		||||
          return "i";
 | 
			
		||||
        case Keys.J:
 | 
			
		||||
          return "j";
 | 
			
		||||
        case Keys.K:
 | 
			
		||||
          return "k";
 | 
			
		||||
        case Keys.L:
 | 
			
		||||
          return "l";
 | 
			
		||||
        case Keys.M:
 | 
			
		||||
          return "m";
 | 
			
		||||
        case Keys.N:
 | 
			
		||||
          return "n";
 | 
			
		||||
        case Keys.O:
 | 
			
		||||
          return "o";
 | 
			
		||||
        case Keys.P:
 | 
			
		||||
          return "p";
 | 
			
		||||
        case Keys.Q:
 | 
			
		||||
          return "q";
 | 
			
		||||
        case Keys.R:
 | 
			
		||||
          return "r";
 | 
			
		||||
        case Keys.S:
 | 
			
		||||
          return "s";
 | 
			
		||||
        case Keys.T:
 | 
			
		||||
          return "t";
 | 
			
		||||
        case Keys.U:
 | 
			
		||||
          return "u";
 | 
			
		||||
        case Keys.V:
 | 
			
		||||
          return "v";
 | 
			
		||||
        case Keys.W:
 | 
			
		||||
          return "w";
 | 
			
		||||
        case Keys.X:
 | 
			
		||||
          return "x";
 | 
			
		||||
        case Keys.Y:
 | 
			
		||||
          return "y";
 | 
			
		||||
        case Keys.Z:
 | 
			
		||||
          return "z";
 | 
			
		||||
 | 
			
		||||
        case Keys.D0:
 | 
			
		||||
          return (args.Shift) ? ")" : "0";
 | 
			
		||||
        case Keys.D1:
 | 
			
		||||
          return (args.Shift) ? "!" : "1";
 | 
			
		||||
        case Keys.D2:
 | 
			
		||||
          return (args.Shift) ? "@" : "2";
 | 
			
		||||
        case Keys.D3:
 | 
			
		||||
          return (args.Shift) ? "#" : "3";
 | 
			
		||||
        case Keys.D4:
 | 
			
		||||
          return (args.Shift) ? "$" : "4";
 | 
			
		||||
        case Keys.D5:
 | 
			
		||||
          return (args.Shift) ? "%" : "5";
 | 
			
		||||
        case Keys.D6:
 | 
			
		||||
          return (args.Shift) ? "^" : "6";
 | 
			
		||||
        case Keys.D7:
 | 
			
		||||
          return (args.Shift) ? "&" : "7";
 | 
			
		||||
        case Keys.D8:
 | 
			
		||||
          return (args.Shift) ? "*" : "8";          
 | 
			
		||||
        case Keys.D9:
 | 
			
		||||
          return (args.Shift) ? "(" : "9";
 | 
			
		||||
 | 
			
		||||
        case Keys.OemPlus:
 | 
			
		||||
          return (args.Shift) ? "+" : "=";
 | 
			
		||||
        case Keys.OemMinus:
 | 
			
		||||
          return (args.Shift) ? "_" : "-";
 | 
			
		||||
        case Keys.OemOpenBrackets:
 | 
			
		||||
          return (args.Shift) ? "{" : "[";
 | 
			
		||||
        case Keys.OemCloseBrackets:
 | 
			
		||||
          return (args.Shift) ? "}" : "]";
 | 
			
		||||
        case Keys.OemQuestion:
 | 
			
		||||
          return (args.Shift) ? "?" : "/";
 | 
			
		||||
        case Keys.OemPeriod:
 | 
			
		||||
          return (args.Shift) ? ">" : ".";
 | 
			
		||||
        case Keys.OemComma:
 | 
			
		||||
          return (args.Shift) ? "<" : ",";
 | 
			
		||||
        case Keys.OemPipe:
 | 
			
		||||
          return (args.Shift) ? "|" : "\\";
 | 
			
		||||
        case Keys.Space:
 | 
			
		||||
          return " ";
 | 
			
		||||
        case Keys.OemSemicolon:
 | 
			
		||||
          return (args.Shift) ? ":" : ";";
 | 
			
		||||
        case Keys.OemQuotes:
 | 
			
		||||
          return (args.Shift) ? "\"" : "'";
 | 
			
		||||
        case Keys.OemTilde:
 | 
			
		||||
          return (args.Shift) ? "~" : "`";
 | 
			
		||||
 | 
			
		||||
        case Keys.NumPad0:
 | 
			
		||||
          return (args.Shift) ? "" : "0";
 | 
			
		||||
        case Keys.NumPad1:
 | 
			
		||||
          return (args.Shift) ? "" : "1";
 | 
			
		||||
        case Keys.NumPad2:
 | 
			
		||||
          return (args.Shift) ? "" : "2";
 | 
			
		||||
        case Keys.NumPad3:
 | 
			
		||||
          return (args.Shift) ? "" : "3";
 | 
			
		||||
        case Keys.NumPad4:
 | 
			
		||||
          return (args.Shift) ? "" : "4";
 | 
			
		||||
        case Keys.NumPad5:
 | 
			
		||||
          return (args.Shift) ? "" : "5";
 | 
			
		||||
        case Keys.NumPad6:
 | 
			
		||||
          return (args.Shift) ? "" : "6";
 | 
			
		||||
        case Keys.NumPad7:
 | 
			
		||||
          return (args.Shift) ? "" : "7";
 | 
			
		||||
        case Keys.NumPad8:
 | 
			
		||||
          return (args.Shift) ? "" : "8";
 | 
			
		||||
        case Keys.NumPad9:
 | 
			
		||||
          return (args.Shift) ? "" : "9";
 | 
			
		||||
        case Keys.Decimal:
 | 
			
		||||
          return (args.Shift) ? "" : ".";
 | 
			
		||||
 | 
			
		||||
        case Keys.Divide:
 | 
			
		||||
          return (args.Shift) ? "/" : "/";
 | 
			
		||||
        case Keys.Multiply:
 | 
			
		||||
          return (args.Shift) ? "*" : "*";
 | 
			
		||||
        case Keys.Subtract:
 | 
			
		||||
          return (args.Shift) ? "-" : "-";
 | 
			
		||||
        case Keys.Add:
 | 
			
		||||
          return (args.Shift) ? "+" : "+";
 | 
			
		||||
          
 | 
			
		||||
        default:
 | 
			
		||||
          return "";
 | 
			
		||||
      }           
 | 
			
		||||
    }    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
	  
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public class CzechKeyboardLayout: KeyboardLayout
 | 
			
		||||
  {
 | 
			
		||||
 | 
			
		||||
    #region //// Constructors //////
 | 
			
		||||
 | 
			
		||||
    //////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public CzechKeyboardLayout()
 | 
			
		||||
    {
 | 
			
		||||
        Name = "Czech";
 | 
			
		||||
        LayoutList.Clear();
 | 
			
		||||
        LayoutList.Add(1029);
 | 
			
		||||
    }
 | 
			
		||||
    //////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Methods ///////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
    protected override string KeyToString(KeyEventArgs args)
 | 
			
		||||
    {                            
 | 
			
		||||
      switch (args.Key)
 | 
			
		||||
      {        
 | 
			
		||||
        case Keys.D0:
 | 
			
		||||
          return (args.Shift) ? "0" : "<22>";
 | 
			
		||||
        case Keys.D1:
 | 
			
		||||
          return (args.Shift) ? "1" : "+";
 | 
			
		||||
        case Keys.D2:
 | 
			
		||||
          return (args.Shift) ? "2" : "<22>";
 | 
			
		||||
        case Keys.D3:
 | 
			
		||||
          return (args.Shift) ? "3" : "<22>";
 | 
			
		||||
        case Keys.D4:
 | 
			
		||||
          return (args.Shift) ? "4" : "<22>";
 | 
			
		||||
        case Keys.D5:
 | 
			
		||||
          return (args.Shift) ? "5" : "<22>";
 | 
			
		||||
        case Keys.D6:
 | 
			
		||||
          return (args.Shift) ? "6" : "<22>";
 | 
			
		||||
        case Keys.D7:
 | 
			
		||||
          return (args.Shift) ? "7" : "<22>";
 | 
			
		||||
        case Keys.D8:
 | 
			
		||||
          return (args.Shift) ? "8" : "<22>";
 | 
			
		||||
        case Keys.D9:
 | 
			
		||||
          return (args.Shift) ? "9" : "<22>";
 | 
			
		||||
 | 
			
		||||
        case Keys.OemPlus:
 | 
			
		||||
          return (args.Shift) ? "<22>" : "<22>";
 | 
			
		||||
        case Keys.OemMinus:
 | 
			
		||||
          return (args.Shift) ? "%" : "=";
 | 
			
		||||
        case Keys.OemOpenBrackets:
 | 
			
		||||
          return (args.Shift) ? "/" : "<22>";
 | 
			
		||||
        case Keys.OemCloseBrackets:
 | 
			
		||||
          return (args.Shift) ? "(" : ")";
 | 
			
		||||
        case Keys.OemQuestion:
 | 
			
		||||
          return (args.Shift) ? "_" : "-";
 | 
			
		||||
        case Keys.OemPeriod:
 | 
			
		||||
          return (args.Shift) ? ":" : ".";
 | 
			
		||||
        case Keys.OemComma:
 | 
			
		||||
          return (args.Shift) ? "?" : ",";
 | 
			
		||||
        case Keys.OemPipe:
 | 
			
		||||
          return (args.Shift) ? "'" : "<22>";
 | 
			
		||||
        case Keys.Space:
 | 
			
		||||
          return " ";
 | 
			
		||||
        case Keys.OemSemicolon:
 | 
			
		||||
          return (args.Shift) ? "\"" : "<22>";
 | 
			
		||||
        case Keys.OemQuotes:
 | 
			
		||||
          return (args.Shift) ? "!" : "<22>";
 | 
			
		||||
        case Keys.OemTilde:
 | 
			
		||||
          return (args.Shift) ? "<22>" : ";";
 | 
			
		||||
        
 | 
			
		||||
        case Keys.Decimal:
 | 
			
		||||
          return (args.Shift) ? "" : ",";
 | 
			
		||||
 | 
			
		||||
        default:
 | 
			
		||||
          return base.KeyToString(args);
 | 
			
		||||
      }            
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public class GermanKeyboardLayout : KeyboardLayout
 | 
			
		||||
  {
 | 
			
		||||
 | 
			
		||||
    #region //// Constructors //////
 | 
			
		||||
 | 
			
		||||
    //////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public GermanKeyboardLayout()
 | 
			
		||||
    {
 | 
			
		||||
      Name = "German";
 | 
			
		||||
      LayoutList.Clear();
 | 
			
		||||
      LayoutList.Add(1031);
 | 
			
		||||
    }
 | 
			
		||||
    //////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Methods ///////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
    protected override string KeyToString(KeyEventArgs args)
 | 
			
		||||
    {
 | 
			
		||||
      switch (args.Key)
 | 
			
		||||
      {
 | 
			
		||||
        case Keys.D0:
 | 
			
		||||
          return (args.Shift) ? "=" : "0";
 | 
			
		||||
        case Keys.D1:
 | 
			
		||||
          return (args.Shift) ? "!" : "1";
 | 
			
		||||
        case Keys.D2:
 | 
			
		||||
          return (args.Shift) ? "\"": "2";
 | 
			
		||||
        case Keys.D3:
 | 
			
		||||
          return (args.Shift) ? "<22>" : "3";
 | 
			
		||||
        case Keys.D4:
 | 
			
		||||
          return (args.Shift) ? "$" : "4";
 | 
			
		||||
        case Keys.D5:
 | 
			
		||||
          return (args.Shift) ? "%" : "5";
 | 
			
		||||
        case Keys.D6:
 | 
			
		||||
          return (args.Shift) ? "&" : "6";
 | 
			
		||||
        case Keys.D7:
 | 
			
		||||
          return (args.Shift) ? "/" : "7";
 | 
			
		||||
        case Keys.D8:
 | 
			
		||||
          return (args.Shift) ? "(" : "8";
 | 
			
		||||
        case Keys.D9:
 | 
			
		||||
          return (args.Shift) ? ")" : "9";
 | 
			
		||||
        case Keys.OemBackslash:
 | 
			
		||||
          return (args.Shift) ? ">" : "<";
 | 
			
		||||
        case Keys.OemPlus:
 | 
			
		||||
          return (args.Shift) ? "*" : "+";
 | 
			
		||||
        case Keys.OemMinus:
 | 
			
		||||
          return (args.Shift) ? "_" : "-";
 | 
			
		||||
        case Keys.OemOpenBrackets:
 | 
			
		||||
          return (args.Shift) ? "?" : "<22>";
 | 
			
		||||
        case Keys.OemCloseBrackets:
 | 
			
		||||
          return (args.Shift) ? "`" : "<22>";
 | 
			
		||||
        case Keys.OemQuestion:
 | 
			
		||||
          return (args.Shift) ? "'" : "#";
 | 
			
		||||
        case Keys.OemPeriod:
 | 
			
		||||
          return (args.Shift) ? ":" : ".";
 | 
			
		||||
        case Keys.OemComma:
 | 
			
		||||
          return (args.Shift) ? ";" : ",";
 | 
			
		||||
        case Keys.OemPipe:
 | 
			
		||||
          return (args.Shift) ? "<22>" : "^";
 | 
			
		||||
        case Keys.Space:
 | 
			
		||||
          return " ";
 | 
			
		||||
        case Keys.OemSemicolon:
 | 
			
		||||
          return (args.Shift) ? "<22>" : "<22>";
 | 
			
		||||
        case Keys.OemQuotes:
 | 
			
		||||
          return (args.Shift) ? "<22>" : "<22>";
 | 
			
		||||
        case Keys.OemTilde:
 | 
			
		||||
          return (args.Shift) ? "<22>" : "<22>";
 | 
			
		||||
          
 | 
			
		||||
        case Keys.Decimal:
 | 
			
		||||
          return (args.Shift) ? "" : ".";
 | 
			
		||||
 | 
			
		||||
        default:
 | 
			
		||||
          return base.KeyToString(args);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////  
 | 
			
		||||
 
 | 
			
		||||
   
 | 
			
		||||
  #endregion
 | 
			
		||||
  
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public class PolishKeyboardLayout: KeyboardLayout
 | 
			
		||||
  {
 | 
			
		||||
 | 
			
		||||
    #region //// Constructors //////
 | 
			
		||||
    //////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public PolishKeyboardLayout()
 | 
			
		||||
    {
 | 
			
		||||
      Name = "Polish"; 
 | 
			
		||||
      LayoutList.Clear();
 | 
			
		||||
      LayoutList.Add(1045);
 | 
			
		||||
    }
 | 
			
		||||
    //////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Methods ///////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected override string KeyToString(KeyEventArgs args)
 | 
			
		||||
    {     
 | 
			
		||||
      if (args.Alt)
 | 
			
		||||
      {
 | 
			
		||||
        switch (args.Key)
 | 
			
		||||
        {
 | 
			
		||||
          case Keys.A:
 | 
			
		||||
            return (args.Shift) ? "<22>" : "<22>";
 | 
			
		||||
          case Keys.C:
 | 
			
		||||
            return (args.Shift) ? "<22>" : "<22>";
 | 
			
		||||
          case Keys.E:
 | 
			
		||||
            return (args.Shift) ? "<22>" : "<22>";
 | 
			
		||||
          case Keys.L:
 | 
			
		||||
            return (args.Shift) ? "<22>" : "<22>";
 | 
			
		||||
          case Keys.N:
 | 
			
		||||
            return (args.Shift) ? "<22>" : "<22>";
 | 
			
		||||
          case Keys.O:
 | 
			
		||||
            return (args.Shift) ? "<22>" : "<22>";
 | 
			
		||||
          case Keys.S:
 | 
			
		||||
            return (args.Shift) ? "<22>" : "<22>";
 | 
			
		||||
          case Keys.X:
 | 
			
		||||
            return (args.Shift) ? "<22>" : "<22>";
 | 
			
		||||
          case Keys.Z:
 | 
			
		||||
            return (args.Shift) ? "<22>" : "<22>";
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
      return base.KeyToString(args);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    #endregion
 | 
			
		||||
  
 | 
			
		||||
  }
 | 
			
		||||
		
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -1,104 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: Label.cs                                     //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
using Microsoft.Xna.Framework;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
  public class Label: Control
 | 
			
		||||
  {
 | 
			
		||||
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////           
 | 
			
		||||
    private Alignment alignment = Alignment.MiddleLeft;    
 | 
			
		||||
    private bool ellipsis = true;    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Properties ////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
    public virtual Alignment Alignment 
 | 
			
		||||
    { 
 | 
			
		||||
      get { return alignment; } 
 | 
			
		||||
      set { alignment = value; } 
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
    public virtual bool Ellipsis 
 | 
			
		||||
    {
 | 
			
		||||
      get { return ellipsis; }
 | 
			
		||||
      set { ellipsis = value; }       
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Construstors //////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////       
 | 
			
		||||
    public Label(Manager manager): base(manager)
 | 
			
		||||
    {      
 | 
			
		||||
      CanFocus = false;    
 | 
			
		||||
      Passive = true;    
 | 
			
		||||
      Width = 64;
 | 
			
		||||
      Height = 16;    
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
    
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Methods ///////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
    public override void Init()
 | 
			
		||||
    {
 | 
			
		||||
      base.Init();            
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////           
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
    protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
 | 
			
		||||
    {      
 | 
			
		||||
      //base.DrawControl(renderer, rect, gameTime);
 | 
			
		||||
   
 | 
			
		||||
      SkinLayer s = new SkinLayer(Skin.Layers[0]);
 | 
			
		||||
      s.Text.Alignment = alignment;
 | 
			
		||||
      renderer.DrawString(this, s, Text, rect, true, 0, 0, ellipsis);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,182 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: Layout.cs                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
using System;
 | 
			
		||||
using Microsoft.Xna.Framework;
 | 
			
		||||
using System.Xml;
 | 
			
		||||
using System.Reflection;
 | 
			
		||||
using System.IO;
 | 
			
		||||
using Microsoft.Xna.Framework.Graphics;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{ 
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  public static class Layout
 | 
			
		||||
  {
 | 
			
		||||
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                     
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Properties ////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Construstors //////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////       
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
    
 | 
			
		||||
    #region //// Methods ///////////    
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
    public static Container Load(Manager manager, string asset)
 | 
			
		||||
    {
 | 
			
		||||
      Container win = null;
 | 
			
		||||
      LayoutXmlDocument doc = new LayoutXmlDocument();
 | 
			
		||||
      ArchiveManager content = new ArchiveManager(manager.Game.Services);            
 | 
			
		||||
      
 | 
			
		||||
      try
 | 
			
		||||
      {      
 | 
			
		||||
        content.RootDirectory = manager.LayoutDirectory;
 | 
			
		||||
        
 | 
			
		||||
        #if (!XBOX && !XBOX_FAKE)
 | 
			
		||||
        
 | 
			
		||||
        string file = content.RootDirectory + asset;
 | 
			
		||||
        
 | 
			
		||||
        if (File.Exists(file))
 | 
			
		||||
        {
 | 
			
		||||
          doc.Load(file);
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        
 | 
			
		||||
        #endif
 | 
			
		||||
        {
 | 
			
		||||
          doc = content.Load<LayoutXmlDocument>(asset);
 | 
			
		||||
        }  
 | 
			
		||||
          
 | 
			
		||||
        
 | 
			
		||||
        if (doc != null && doc["Layout"]["Controls"] != null && doc["Layout"]["Controls"].HasChildNodes)
 | 
			
		||||
        {       
 | 
			
		||||
          XmlNode node = doc["Layout"]["Controls"].GetElementsByTagName("Control").Item(0);         
 | 
			
		||||
          string cls = node.Attributes["Class"].Value;
 | 
			
		||||
          Type type = Type.GetType(cls);
 | 
			
		||||
          
 | 
			
		||||
          if (type == null)
 | 
			
		||||
          {
 | 
			
		||||
            cls = "TomShane.Neoforce.Controls." + cls;
 | 
			
		||||
            type = Type.GetType(cls);
 | 
			
		||||
          }
 | 
			
		||||
                    
 | 
			
		||||
          win = (Container)LoadControl(manager, node, type, null);                    
 | 
			
		||||
        }  
 | 
			
		||||
        
 | 
			
		||||
      }
 | 
			
		||||
      finally
 | 
			
		||||
      {
 | 
			
		||||
        content.Dispose();
 | 
			
		||||
      }                  
 | 
			
		||||
      
 | 
			
		||||
      return win;
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    private static Control LoadControl(Manager manager, XmlNode node, Type type, Control parent)
 | 
			
		||||
    {
 | 
			
		||||
      Control c = null;   
 | 
			
		||||
      
 | 
			
		||||
      Object[] args = new Object[] {manager};      
 | 
			
		||||
      
 | 
			
		||||
      c = (Control)type.InvokeMember(null, BindingFlags.CreateInstance, null, null, args);    
 | 
			
		||||
      if (parent != null) c.Parent = parent;
 | 
			
		||||
      c.Name = node.Attributes["Name"].Value;            
 | 
			
		||||
      
 | 
			
		||||
      if (node != null && node["Properties"] != null && node["Properties"].HasChildNodes)
 | 
			
		||||
      {
 | 
			
		||||
        LoadProperties(node["Properties"].GetElementsByTagName("Property"), c);
 | 
			
		||||
      }  
 | 
			
		||||
 | 
			
		||||
      if (node != null && node["Controls"] != null && node["Controls"].HasChildNodes)
 | 
			
		||||
      {
 | 
			
		||||
        foreach (XmlElement e in node["Controls"].GetElementsByTagName("Control"))
 | 
			
		||||
        {
 | 
			
		||||
          string cls = e.Attributes["Class"].Value;
 | 
			
		||||
          Type t = Type.GetType(cls);
 | 
			
		||||
          
 | 
			
		||||
          if (t == null)
 | 
			
		||||
          {
 | 
			
		||||
            cls = "TomShane.Neoforce.Controls." + cls;
 | 
			
		||||
            t = Type.GetType(cls);
 | 
			
		||||
          }
 | 
			
		||||
          LoadControl(manager, e, t, c);
 | 
			
		||||
        }
 | 
			
		||||
      }                    
 | 
			
		||||
      
 | 
			
		||||
      return c;
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    private static void LoadProperties(XmlNodeList node, Control c)        
 | 
			
		||||
    {
 | 
			
		||||
      foreach (XmlElement e in node)
 | 
			
		||||
      {
 | 
			
		||||
        string name = e.Attributes["Name"].Value;
 | 
			
		||||
        string val = e.Attributes["Value"].Value;
 | 
			
		||||
        
 | 
			
		||||
        PropertyInfo i = c.GetType().GetProperty(name);
 | 
			
		||||
        
 | 
			
		||||
        if (i != null)
 | 
			
		||||
        {                                       
 | 
			
		||||
          {  
 | 
			
		||||
            try
 | 
			
		||||
            {                          
 | 
			
		||||
              i.SetValue(c, Convert.ChangeType(val, i.PropertyType, null), null);
 | 
			
		||||
            }
 | 
			
		||||
            catch
 | 
			
		||||
            {              
 | 
			
		||||
            }  
 | 
			
		||||
          }  
 | 
			
		||||
        }                              
 | 
			
		||||
      }  
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion  
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,485 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: ListBox.cs                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using Microsoft.Xna.Framework;
 | 
			
		||||
using Microsoft.Xna.Framework.Input;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
    #region //// Classes ///////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    ///  <include file='Documents/ListBox.xml' path='ListBox/Class[@name="ListBox"]/*' />          
 | 
			
		||||
    public class ListBox : Control
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////                     
 | 
			
		||||
        private List<object> items = new List<object>();
 | 
			
		||||
        private ScrollBar sbVert = null;
 | 
			
		||||
        private ClipBox pane = null;
 | 
			
		||||
        private int itemIndex = -1;
 | 
			
		||||
        private bool hotTrack = false;
 | 
			
		||||
        private int itemsCount = 0;
 | 
			
		||||
        private bool hideSelection = true;
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region //// Properties ////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        public virtual List<object> Items
 | 
			
		||||
        {
 | 
			
		||||
            get { return items; }
 | 
			
		||||
            internal set { items = value; }
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        public virtual bool HotTrack
 | 
			
		||||
        {
 | 
			
		||||
            get { return hotTrack; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                if (hotTrack != value)
 | 
			
		||||
                {
 | 
			
		||||
                    hotTrack = value;
 | 
			
		||||
                    if (!Suspended) OnHotTrackChanged(new EventArgs());
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        public virtual int ItemIndex
 | 
			
		||||
        {
 | 
			
		||||
            get { return itemIndex; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                //if (itemIndex != value)
 | 
			
		||||
                {
 | 
			
		||||
                    if (value >= 0 && value < items.Count)
 | 
			
		||||
                    {
 | 
			
		||||
                        itemIndex = value;
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        itemIndex = -1;
 | 
			
		||||
                    }
 | 
			
		||||
                    ScrollTo(itemIndex);
 | 
			
		||||
 | 
			
		||||
                    if (!Suspended) OnItemIndexChanged(new EventArgs());
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        public virtual bool HideSelection
 | 
			
		||||
        {
 | 
			
		||||
            get { return hideSelection; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                if (hideSelection != value)
 | 
			
		||||
                {
 | 
			
		||||
                    hideSelection = value;
 | 
			
		||||
                    Invalidate();
 | 
			
		||||
                    if (!Suspended) OnHideSelectionChanged(new EventArgs());
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region //// Events ////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////                 
 | 
			
		||||
        public event EventHandler HotTrackChanged;
 | 
			
		||||
        public event EventHandler ItemIndexChanged;
 | 
			
		||||
        public event EventHandler HideSelectionChanged;
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region //// Construstors //////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////       
 | 
			
		||||
        public ListBox(Manager manager)
 | 
			
		||||
            : base(manager)
 | 
			
		||||
        {
 | 
			
		||||
            Width = 64;
 | 
			
		||||
            Height = 64;
 | 
			
		||||
            MinimumHeight = 16;
 | 
			
		||||
 | 
			
		||||
            sbVert = new ScrollBar(Manager, Orientation.Vertical);
 | 
			
		||||
            sbVert.Init();
 | 
			
		||||
            sbVert.Parent = this;
 | 
			
		||||
            sbVert.Left = Left + Width - sbVert.Width - Skin.Layers["Control"].ContentMargins.Right;
 | 
			
		||||
            sbVert.Top = Top + Skin.Layers["Control"].ContentMargins.Top;
 | 
			
		||||
            sbVert.Height = Height - Skin.Layers["Control"].ContentMargins.Vertical;
 | 
			
		||||
            sbVert.Anchor = Anchors.Top | Anchors.Right | Anchors.Bottom;
 | 
			
		||||
            sbVert.PageSize = 25;
 | 
			
		||||
            sbVert.Range = 1;
 | 
			
		||||
            sbVert.PageSize = 1;
 | 
			
		||||
            sbVert.StepSize = 10;
 | 
			
		||||
 | 
			
		||||
            pane = new ClipBox(manager);
 | 
			
		||||
            pane.Init();
 | 
			
		||||
            pane.Parent = this;
 | 
			
		||||
            pane.Top = Skin.Layers["Control"].ContentMargins.Top;
 | 
			
		||||
            pane.Left = Skin.Layers["Control"].ContentMargins.Left;
 | 
			
		||||
            pane.Width = Width - sbVert.Width - Skin.Layers["Control"].ContentMargins.Horizontal - 1;
 | 
			
		||||
            pane.Height = Height - Skin.Layers["Control"].ContentMargins.Vertical;
 | 
			
		||||
            pane.Anchor = Anchors.All;
 | 
			
		||||
            pane.Passive = true;
 | 
			
		||||
            pane.CanFocus = false;
 | 
			
		||||
            pane.Draw += new DrawEventHandler(DrawPane);
 | 
			
		||||
 | 
			
		||||
            CanFocus = true;
 | 
			
		||||
            Passive = false;
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region //// Methods ///////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        public override void Init()
 | 
			
		||||
        {
 | 
			
		||||
            base.Init();
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        public virtual void AutoHeight(int maxItems)
 | 
			
		||||
        {
 | 
			
		||||
            if (items != null && items.Count < maxItems) maxItems = items.Count;
 | 
			
		||||
            if (maxItems < 3)
 | 
			
		||||
            {
 | 
			
		||||
                //maxItems = 3;
 | 
			
		||||
                sbVert.Visible = false;
 | 
			
		||||
                pane.Width = Width - Skin.Layers["Control"].ContentMargins.Horizontal - 1;
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                pane.Width = Width - sbVert.Width - Skin.Layers["Control"].ContentMargins.Horizontal - 1;
 | 
			
		||||
                sbVert.Visible = true;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            SkinText font = Skin.Layers["Control"].Text;
 | 
			
		||||
            if (items != null && items.Count > 0)
 | 
			
		||||
            {
 | 
			
		||||
                int h = (int)font.Font.Resource.MeasureString(items[0].ToString()).Y;
 | 
			
		||||
                Height = (h * maxItems) + (Skin.Layers["Control"].ContentMargins.Vertical);// - Skin.OriginMargins.Vertical);
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                Height = 32;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        public override int MinimumHeight
 | 
			
		||||
        {
 | 
			
		||||
            get { return base.MinimumHeight; }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                base.MinimumHeight = value;
 | 
			
		||||
                if (this.sbVert != null) this.sbVert.MinimumHeight = value;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
 | 
			
		||||
        {
 | 
			
		||||
            sbVert.Invalidate();
 | 
			
		||||
            pane.Invalidate();
 | 
			
		||||
            //DrawPane(this, new DrawEventArgs(renderer, rect, gameTime));
 | 
			
		||||
 | 
			
		||||
            base.DrawControl(renderer, rect, gameTime);
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        private void DrawPane(object sender, DrawEventArgs e)
 | 
			
		||||
        {
 | 
			
		||||
            if (items != null && items.Count > 0)
 | 
			
		||||
            {
 | 
			
		||||
                SkinText font = Skin.Layers["Control"].Text;
 | 
			
		||||
                SkinLayer sel = Skin.Layers["ListBox.Selection"];
 | 
			
		||||
                int h = (int)font.Font.Resource.MeasureString(items[0].ToString()).Y;
 | 
			
		||||
                int v = (sbVert.Value / 10);
 | 
			
		||||
                int p = (sbVert.PageSize / 10);
 | 
			
		||||
                int d = (int)(((sbVert.Value % 10) / 10f) * h);
 | 
			
		||||
                int c = items.Count;
 | 
			
		||||
                int s = itemIndex;
 | 
			
		||||
 | 
			
		||||
                for (int i = v; i <= v + p + 1; i++)
 | 
			
		||||
                {
 | 
			
		||||
                    if (i < c)
 | 
			
		||||
                    {
 | 
			
		||||
                        e.Renderer.DrawString(this, Skin.Layers["Control"], items[i].ToString(), new Rectangle(e.Rectangle.Left, e.Rectangle.Top - d + ((i - v) * h), e.Rectangle.Width, h), false);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                if (s >= 0 && s < c && (Focused || !hideSelection))
 | 
			
		||||
                {
 | 
			
		||||
                    int pos = -d + ((s - v) * h);
 | 
			
		||||
                    if (pos > -h && pos < (p + 1) * h)
 | 
			
		||||
                    {
 | 
			
		||||
                        e.Renderer.DrawLayer(this, sel, new Rectangle(e.Rectangle.Left, e.Rectangle.Top + pos, e.Rectangle.Width, h));
 | 
			
		||||
                        e.Renderer.DrawString(this, sel, items[s].ToString(), new Rectangle(e.Rectangle.Left, e.Rectangle.Top + pos, e.Rectangle.Width, h), false);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        protected override void OnMouseDown(MouseEventArgs e)
 | 
			
		||||
        {
 | 
			
		||||
            base.OnMouseDown(e);
 | 
			
		||||
 | 
			
		||||
            if (e.Button == MouseButton.Left || e.Button == MouseButton.Right)
 | 
			
		||||
            {
 | 
			
		||||
                TrackItem(e.Position.X, e.Position.Y);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        private void TrackItem(int x, int y)
 | 
			
		||||
        {
 | 
			
		||||
            if (items != null && items.Count > 0 && (pane.ControlRect.Contains(new Point(x, y))))
 | 
			
		||||
            {
 | 
			
		||||
                SkinText font = Skin.Layers["Control"].Text;
 | 
			
		||||
                int h = (int)font.Font.Resource.MeasureString(items[0].ToString()).Y;
 | 
			
		||||
                int d = (int)(((sbVert.Value % 10) / 10f) * h);
 | 
			
		||||
                int i = (int)Math.Floor((sbVert.Value / 10f) + ((float)y / h));
 | 
			
		||||
                if (i >= 0 && i < Items.Count && i >= (int)Math.Floor((float)sbVert.Value / 10f) && i < (int)Math.Ceiling((float)(sbVert.Value + sbVert.PageSize) / 10f)) ItemIndex = i;
 | 
			
		||||
                Focused = true;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        protected override void OnMouseMove(MouseEventArgs e)
 | 
			
		||||
        {
 | 
			
		||||
            base.OnMouseMove(e);
 | 
			
		||||
 | 
			
		||||
            if (hotTrack)
 | 
			
		||||
            {
 | 
			
		||||
                TrackItem(e.Position.X, e.Position.Y);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        protected override void OnKeyPress(KeyEventArgs e)
 | 
			
		||||
        {
 | 
			
		||||
            if (e.Key == Keys.Down)
 | 
			
		||||
            {
 | 
			
		||||
                e.Handled = true;
 | 
			
		||||
                itemIndex += sbVert.StepSize / 10;
 | 
			
		||||
            }
 | 
			
		||||
            else if (e.Key == Keys.Up)
 | 
			
		||||
            {
 | 
			
		||||
                e.Handled = true;
 | 
			
		||||
                itemIndex -= sbVert.StepSize / 10;
 | 
			
		||||
            }
 | 
			
		||||
            else if (e.Key == Keys.PageDown)
 | 
			
		||||
            {
 | 
			
		||||
                e.Handled = true;
 | 
			
		||||
                itemIndex += sbVert.PageSize / 10;
 | 
			
		||||
            }
 | 
			
		||||
            else if (e.Key == Keys.PageUp)
 | 
			
		||||
            {
 | 
			
		||||
                e.Handled = true;
 | 
			
		||||
                itemIndex -= sbVert.PageSize / 10;
 | 
			
		||||
            }
 | 
			
		||||
            else if (e.Key == Keys.Home)
 | 
			
		||||
            {
 | 
			
		||||
                e.Handled = true;
 | 
			
		||||
                itemIndex = 0;
 | 
			
		||||
            }
 | 
			
		||||
            else if (e.Key == Keys.End)
 | 
			
		||||
            {
 | 
			
		||||
                e.Handled = true;
 | 
			
		||||
                itemIndex = items.Count - 1;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (itemIndex < 0) itemIndex = 0;
 | 
			
		||||
            else if (itemIndex >= Items.Count) itemIndex = Items.Count - 1;
 | 
			
		||||
 | 
			
		||||
            ItemIndex = itemIndex;
 | 
			
		||||
 | 
			
		||||
            base.OnKeyPress(e);
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Handles mouse scroll events for the list box.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="e"></param>
 | 
			
		||||
        protected override void OnMouseScroll(MouseEventArgs e)
 | 
			
		||||
        {
 | 
			
		||||
            Focused = true;
 | 
			
		||||
 
 | 
			
		||||
            if (e.ScrollDirection == MouseScrollDirection.Down)
 | 
			
		||||
            {
 | 
			
		||||
                e.Handled = true;
 | 
			
		||||
                itemIndex += sbVert.StepSize / 10;
 | 
			
		||||
            }
 | 
			
		||||
            else if (e.ScrollDirection == MouseScrollDirection.Up)
 | 
			
		||||
            {
 | 
			
		||||
                e.Handled = true;
 | 
			
		||||
                itemIndex -= sbVert.StepSize / 10;
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
            // Wrap index in collection range.
 | 
			
		||||
            if (itemIndex < 0) itemIndex = 0;
 | 
			
		||||
            else if (itemIndex >= Items.Count) itemIndex = Items.Count - 1;
 | 
			
		||||
 
 | 
			
		||||
            ItemIndex = itemIndex;
 | 
			
		||||
 
 | 
			
		||||
            base.OnMouseScroll(e);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        protected override void OnGamePadPress(GamePadEventArgs e)
 | 
			
		||||
        {
 | 
			
		||||
            if (e.Button == GamePadActions.Down)
 | 
			
		||||
            {
 | 
			
		||||
                e.Handled = true;
 | 
			
		||||
                itemIndex += sbVert.StepSize / 10;
 | 
			
		||||
            }
 | 
			
		||||
            else if (e.Button == GamePadActions.Up)
 | 
			
		||||
            {
 | 
			
		||||
                e.Handled = true;
 | 
			
		||||
                itemIndex -= sbVert.StepSize / 10;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (itemIndex < 0) itemIndex = 0;
 | 
			
		||||
            else if (itemIndex >= Items.Count) itemIndex = Items.Count - 1;
 | 
			
		||||
 | 
			
		||||
            ItemIndex = itemIndex;
 | 
			
		||||
            base.OnGamePadPress(e);
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        private void ItemsChanged()
 | 
			
		||||
        {
 | 
			
		||||
            if (items != null && items.Count > 0)
 | 
			
		||||
            {
 | 
			
		||||
                SkinText font = Skin.Layers["Control"].Text;
 | 
			
		||||
                int h = (int)font.Font.Resource.MeasureString(items[0].ToString()).Y;
 | 
			
		||||
 | 
			
		||||
                int sizev = Height - Skin.Layers["Control"].ContentMargins.Vertical;
 | 
			
		||||
                sbVert.Range = items.Count * 10;
 | 
			
		||||
                sbVert.PageSize = (int)Math.Floor((float)sizev * 10 / h);
 | 
			
		||||
                Invalidate();
 | 
			
		||||
            }
 | 
			
		||||
            else if (items == null || items.Count <= 0)
 | 
			
		||||
            {
 | 
			
		||||
                sbVert.Range = 1;
 | 
			
		||||
                sbVert.PageSize = 1;
 | 
			
		||||
                Invalidate();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        protected override void OnResize(ResizeEventArgs e)
 | 
			
		||||
        {
 | 
			
		||||
            base.OnResize(e);
 | 
			
		||||
            ItemsChanged();
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        public virtual void ScrollTo(int index)
 | 
			
		||||
        {
 | 
			
		||||
            ItemsChanged();
 | 
			
		||||
            if ((index * 10) < sbVert.Value)
 | 
			
		||||
            {
 | 
			
		||||
                sbVert.Value = index * 10;
 | 
			
		||||
            }
 | 
			
		||||
            else if (index >= (int)Math.Floor(((float)sbVert.Value + sbVert.PageSize) / 10f))
 | 
			
		||||
            {
 | 
			
		||||
                sbVert.Value = ((index + 1) * 10) - sbVert.PageSize;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        protected internal override void Update(GameTime gameTime)
 | 
			
		||||
        {
 | 
			
		||||
            base.Update(gameTime);
 | 
			
		||||
 | 
			
		||||
            if (Visible && items != null && items.Count != itemsCount)
 | 
			
		||||
            {
 | 
			
		||||
                itemsCount = items.Count;
 | 
			
		||||
                ItemsChanged();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
        protected virtual void OnItemIndexChanged(EventArgs e)
 | 
			
		||||
        {
 | 
			
		||||
            if (ItemIndexChanged != null) ItemIndexChanged.Invoke(this, e);
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
        protected virtual void OnHotTrackChanged(EventArgs e)
 | 
			
		||||
        {
 | 
			
		||||
            if (HotTrackChanged != null) HotTrackChanged.Invoke(this, e);
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////  
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
        protected virtual void OnHideSelectionChanged(EventArgs e)
 | 
			
		||||
        {
 | 
			
		||||
            if (HideSelectionChanged != null) HideSelectionChanged.Invoke(this, e);
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////       
 | 
			
		||||
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,362 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: MainMenu.cs                                  //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using Microsoft.Xna.Framework;
 | 
			
		||||
using Microsoft.Xna.Framework.Graphics;
 | 
			
		||||
using Microsoft.Xna.Framework.Input;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{ 
 | 
			
		||||
 | 
			
		||||
  public class MainMenu: MenuBase
 | 
			
		||||
  {
 | 
			
		||||
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                 
 | 
			
		||||
    private Rectangle[] rs;
 | 
			
		||||
    private int lastIndex = -1;    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Properties ////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Constructors //////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////       
 | 
			
		||||
    public MainMenu(Manager manager): base(manager)
 | 
			
		||||
    {      
 | 
			
		||||
      Left = 0;
 | 
			
		||||
      Top = 0;
 | 
			
		||||
      Height = 24;
 | 
			
		||||
      Detached = false;
 | 
			
		||||
      DoubleClicks = false;    
 | 
			
		||||
      StayOnBack = true;  
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Destructors ///////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected override void Dispose(bool disposing)
 | 
			
		||||
    {
 | 
			
		||||
      if (disposing)
 | 
			
		||||
      {        
 | 
			
		||||
      }
 | 
			
		||||
      base.Dispose(disposing);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion   
 | 
			
		||||
    
 | 
			
		||||
    #region //// Methods ///////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public override void Init()
 | 
			
		||||
    {      
 | 
			
		||||
      base.Init();      
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                          
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected internal override void InitSkin()
 | 
			
		||||
    {
 | 
			
		||||
      base.InitSkin();
 | 
			
		||||
      Skin = new SkinControl(Manager.Skin.Controls["MainMenu"]);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
 | 
			
		||||
    {                                          
 | 
			
		||||
      SkinLayer l1 = Skin.Layers["Control"];
 | 
			
		||||
      SkinLayer l2 = Skin.Layers["Selection"];
 | 
			
		||||
      rs = new Rectangle[Items.Count];       
 | 
			
		||||
 | 
			
		||||
      renderer.DrawLayer(this, l1, rect, ControlState.Enabled);
 | 
			
		||||
      
 | 
			
		||||
      int prev = l1.ContentMargins.Left;
 | 
			
		||||
      for (int i = 0; i < Items.Count; i++)
 | 
			
		||||
      {     
 | 
			
		||||
        MenuItem mi = Items[i];
 | 
			
		||||
 | 
			
		||||
        int tw = (int)l1.Text.Font.Resource.MeasureString(mi.Text).X + l1.ContentMargins.Horizontal;
 | 
			
		||||
        rs[i] = new Rectangle(rect.Left + prev, rect.Top + l1.ContentMargins.Top, tw, Height - l1.ContentMargins.Vertical);
 | 
			
		||||
        prev += tw;      
 | 
			
		||||
        
 | 
			
		||||
        if (ItemIndex != i)
 | 
			
		||||
        {          
 | 
			
		||||
          if (mi.Enabled && Enabled)
 | 
			
		||||
          {             
 | 
			
		||||
            renderer.DrawString(this, l1, mi.Text, rs[i], ControlState.Enabled, false);
 | 
			
		||||
          }
 | 
			
		||||
          else
 | 
			
		||||
          {
 | 
			
		||||
            renderer.DrawString(this, l1, mi.Text, rs[i], ControlState.Disabled, false);
 | 
			
		||||
          }  
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
          if (Items[i].Enabled && Enabled)
 | 
			
		||||
          {      
 | 
			
		||||
            renderer.DrawLayer(this, l2, rs[i], ControlState.Enabled);
 | 
			
		||||
            renderer.DrawString(this, l2, mi.Text, rs[i], ControlState.Enabled, false);           
 | 
			
		||||
          }  
 | 
			
		||||
          else
 | 
			
		||||
          {
 | 
			
		||||
            renderer.DrawLayer(this, l2, rs[i], ControlState.Disabled);
 | 
			
		||||
            renderer.DrawString(this, l2, mi.Text, rs[i], ControlState.Disabled, false);  
 | 
			
		||||
          }
 | 
			
		||||
        }  
 | 
			
		||||
      }      
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////  
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    private void TrackItem(int x, int y)
 | 
			
		||||
    {          
 | 
			
		||||
      if (Items != null && Items.Count > 0 && rs != null)
 | 
			
		||||
      {
 | 
			
		||||
        Invalidate();
 | 
			
		||||
        for (int i = 0; i < rs.Length; i++)
 | 
			
		||||
        {
 | 
			
		||||
          if (rs[i].Contains(x, y))
 | 
			
		||||
          {
 | 
			
		||||
            if (i >= 0 && i != ItemIndex)
 | 
			
		||||
            {
 | 
			
		||||
              Items[i].SelectedInvoke(new EventArgs());              
 | 
			
		||||
            } 
 | 
			
		||||
            ItemIndex = i;        
 | 
			
		||||
            return;
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
        if (ChildMenu == null) ItemIndex = -1;        
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    private bool CheckArea(int x, int y)
 | 
			
		||||
    {
 | 
			
		||||
      return true;       
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected override void OnMouseMove(MouseEventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      base.OnMouseMove(e);
 | 
			
		||||
      int i = lastIndex;      
 | 
			
		||||
                  
 | 
			
		||||
      TrackItem(e.State.X - Root.AbsoluteLeft, e.State.Y - Root.AbsoluteTop);
 | 
			
		||||
 | 
			
		||||
      if (ItemIndex >= 0 && (i == -1 || i != ItemIndex) && Items[ItemIndex].Items != null && Items[ItemIndex].Items.Count > 0 && ChildMenu != null)
 | 
			
		||||
      {                               
 | 
			
		||||
        HideSubMenu();
 | 
			
		||||
        lastIndex = ItemIndex; 
 | 
			
		||||
        OnClick(e);          
 | 
			
		||||
      }
 | 
			
		||||
      else if (ChildMenu != null && i != ItemIndex)
 | 
			
		||||
      {                 
 | 
			
		||||
         HideSubMenu();
 | 
			
		||||
         Focused = true;             
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
    protected override void OnMouseDown(MouseEventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      base.OnMouseDown(e);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
    protected override void OnMouseOut(MouseEventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      base.OnMouseOut(e);
 | 
			
		||||
      
 | 
			
		||||
      OnMouseMove(e);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
  
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
    private void HideSubMenu()
 | 
			
		||||
    {
 | 
			
		||||
      if (ChildMenu != null)
 | 
			
		||||
      {
 | 
			
		||||
        (ChildMenu as ContextMenu).HideMenu(true);
 | 
			
		||||
        ChildMenu.Dispose();
 | 
			
		||||
        ChildMenu = null;
 | 
			
		||||
      }      
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
    public virtual void HideMenu()
 | 
			
		||||
    {
 | 
			
		||||
      if (ChildMenu != null)
 | 
			
		||||
      {
 | 
			
		||||
        (ChildMenu as ContextMenu).HideMenu(true);
 | 
			
		||||
        ChildMenu.Dispose();
 | 
			
		||||
        ChildMenu = null;
 | 
			
		||||
      }
 | 
			
		||||
      if (Manager.FocusedControl is MenuBase) Focused = true;
 | 
			
		||||
      Invalidate();
 | 
			
		||||
      ItemIndex = -1;
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected override void OnClick(EventArgs e)
 | 
			
		||||
    {      
 | 
			
		||||
      base.OnClick(e);
 | 
			
		||||
 | 
			
		||||
      MouseEventArgs ex = (e is MouseEventArgs) ? (MouseEventArgs)e : new MouseEventArgs();
 | 
			
		||||
      
 | 
			
		||||
      if (ex.Button == MouseButton.Left || ex.Button == MouseButton.None)
 | 
			
		||||
      {
 | 
			
		||||
        if (ItemIndex >= 0 && Items[ItemIndex].Enabled)
 | 
			
		||||
        {
 | 
			
		||||
          if (ItemIndex >= 0 && Items[ItemIndex].Items != null && Items[ItemIndex].Items.Count > 0)
 | 
			
		||||
          {
 | 
			
		||||
            if (ChildMenu != null)
 | 
			
		||||
            {
 | 
			
		||||
              ChildMenu.Dispose();
 | 
			
		||||
              ChildMenu = null;
 | 
			
		||||
            }
 | 
			
		||||
            ChildMenu = new ContextMenu(Manager);
 | 
			
		||||
            (ChildMenu as ContextMenu).RootMenu = this;
 | 
			
		||||
            (ChildMenu as ContextMenu).ParentMenu = this;
 | 
			
		||||
            (ChildMenu as ContextMenu).Sender = this.Root;
 | 
			
		||||
            ChildMenu.Items.AddRange(Items[ItemIndex].Items);                
 | 
			
		||||
 | 
			
		||||
            int y = Root.AbsoluteTop + rs[ItemIndex].Bottom + 1;
 | 
			
		||||
            (ChildMenu as ContextMenu).Show(this.Root, Root.AbsoluteLeft + rs[ItemIndex].Left, y);
 | 
			
		||||
            if (ex.Button == MouseButton.None) (ChildMenu as ContextMenu).ItemIndex = 0;            
 | 
			
		||||
          }        
 | 
			
		||||
          else
 | 
			
		||||
          {
 | 
			
		||||
            if (ItemIndex >= 0)
 | 
			
		||||
            {
 | 
			
		||||
              Items[ItemIndex].ClickInvoke(ex);
 | 
			
		||||
            }
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      }  
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected override void OnKeyPress(KeyEventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      base.OnKeyPress(e);      
 | 
			
		||||
 | 
			
		||||
      if (e.Key == Keys.Right)
 | 
			
		||||
      {
 | 
			
		||||
        ItemIndex += 1;
 | 
			
		||||
        e.Handled = true;
 | 
			
		||||
      }
 | 
			
		||||
      if (e.Key == Keys.Left)
 | 
			
		||||
      {
 | 
			
		||||
        ItemIndex -= 1;
 | 
			
		||||
        e.Handled = true;
 | 
			
		||||
      } 
 | 
			
		||||
 | 
			
		||||
      if (ItemIndex > Items.Count - 1) ItemIndex = 0;
 | 
			
		||||
      if (ItemIndex < 0) ItemIndex = Items.Count - 1;
 | 
			
		||||
 | 
			
		||||
      if (e.Key == Keys.Down && Items.Count > 0 && Items[ItemIndex].Items.Count > 0)
 | 
			
		||||
      {
 | 
			
		||||
        e.Handled = true;
 | 
			
		||||
        OnClick(new MouseEventArgs(new MouseState(), MouseButton.None, Point.Zero));        
 | 
			
		||||
      }  
 | 
			
		||||
      if (e.Key == Keys.Escape)
 | 
			
		||||
      {
 | 
			
		||||
        e.Handled = true;
 | 
			
		||||
        ItemIndex = -1;
 | 
			
		||||
      }      
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected override void OnGamePadPress(GamePadEventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      base.OnGamePadPress(e);
 | 
			
		||||
 | 
			
		||||
      if (e.Button == GamePadActions.Right)
 | 
			
		||||
      {
 | 
			
		||||
        ItemIndex += 1;
 | 
			
		||||
        e.Handled = true;
 | 
			
		||||
      }
 | 
			
		||||
      if (e.Button == GamePadActions.Left)
 | 
			
		||||
      {
 | 
			
		||||
        ItemIndex -= 1;
 | 
			
		||||
        e.Handled = true;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if (ItemIndex > Items.Count - 1) ItemIndex = 0;
 | 
			
		||||
      if (ItemIndex < 0) ItemIndex = Items.Count - 1;
 | 
			
		||||
 | 
			
		||||
      if (e.Button == GamePadActions.Down && Items[ItemIndex].Items.Count > 0)
 | 
			
		||||
      {
 | 
			
		||||
        e.Handled = true;
 | 
			
		||||
        OnClick(new MouseEventArgs(new MouseState(), MouseButton.None, Point.Zero));
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected override void OnFocusGained(EventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      base.OnFocusGained(e);  
 | 
			
		||||
      if (ItemIndex < 0 && Items.Count > 0) ItemIndex = 0;    
 | 
			
		||||
    }    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
    protected override void OnFocusLost(EventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      base.OnFocusLost(e);
 | 
			
		||||
      if (ChildMenu == null || !ChildMenu.Visible) ItemIndex = -1;
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
      
 | 
			
		||||
    #endregion  
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										1849
									
								
								Neoforce/Manager.cs
									
									
									
									
									
								
							
							
						
						
									
										1849
									
								
								Neoforce/Manager.cs
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -1,141 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: MenuBase.cs                                  //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using Microsoft.Xna.Framework;
 | 
			
		||||
using Microsoft.Xna.Framework.Graphics;
 | 
			
		||||
using Microsoft.Xna.Framework.Input;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{ 
 | 
			
		||||
 | 
			
		||||
  public class MenuItem: Unknown
 | 
			
		||||
  {    
 | 
			
		||||
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public string Text = "MenuItem";
 | 
			
		||||
    public List<MenuItem> Items = new List<MenuItem>();
 | 
			
		||||
    public bool Separated = false;     
 | 
			
		||||
    public Texture2D Image = null;
 | 
			
		||||
    public bool Enabled = true;
 | 
			
		||||
    public object Tag { get; set; }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Constructors //////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public MenuItem()
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public MenuItem(string text): this()
 | 
			
		||||
    {
 | 
			
		||||
      Text = text;
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public MenuItem(string text, bool separated): this(text)
 | 
			
		||||
    {      
 | 
			
		||||
      Separated = separated;
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Methods ///////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public event EventHandler Click;
 | 
			
		||||
    public event EventHandler Selected;
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    internal void ClickInvoke(EventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      if (Click != null) Click.Invoke(this, e);
 | 
			
		||||
    } 
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    internal void SelectedInvoke(EventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      if (Selected != null) Selected.Invoke(this, e);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
    
 | 
			
		||||
  } 
 | 
			
		||||
 | 
			
		||||
  public abstract class MenuBase: Control
 | 
			
		||||
  {
 | 
			
		||||
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                 
 | 
			
		||||
    private int itemIndex = -1;
 | 
			
		||||
    private List<MenuItem> items = new List<MenuItem>();
 | 
			
		||||
    private MenuBase childMenu = null;   
 | 
			
		||||
    private MenuBase rootMenu = null;
 | 
			
		||||
    private MenuBase parentMenu = null;    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Properties ////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected internal int ItemIndex { get { return itemIndex; } set { itemIndex = value; } }
 | 
			
		||||
    protected internal MenuBase ChildMenu { get { return childMenu; } set { childMenu = value; } }
 | 
			
		||||
    protected internal MenuBase RootMenu { get { return rootMenu; } set { rootMenu = value; } }
 | 
			
		||||
    protected internal MenuBase ParentMenu { get { return parentMenu; } set { parentMenu = value; } }    
 | 
			
		||||
    public List<MenuItem> Items { get { return items; } }    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Construstors //////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////       
 | 
			
		||||
    public MenuBase(Manager manager): base(manager)
 | 
			
		||||
    {            
 | 
			
		||||
      rootMenu = this;            
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
        
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,194 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: ModalContainer.cs                            //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
using Microsoft.Xna.Framework;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{
 | 
			
		||||
   
 | 
			
		||||
  public class ModalContainer: Container
 | 
			
		||||
  {
 | 
			
		||||
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    private ModalResult modalResult = ModalResult.None;
 | 
			
		||||
    private ModalContainer lastModal = null; 
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Properties ////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public override bool Visible
 | 
			
		||||
    {
 | 
			
		||||
      get
 | 
			
		||||
      {
 | 
			
		||||
        return base.Visible;
 | 
			
		||||
      }
 | 
			
		||||
      set
 | 
			
		||||
      {
 | 
			
		||||
        if (value) Focused = true;
 | 
			
		||||
        base.Visible = value;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public virtual bool IsModal
 | 
			
		||||
    {
 | 
			
		||||
      get { return Manager.ModalWindow == this; }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public virtual ModalResult ModalResult
 | 
			
		||||
    {
 | 
			
		||||
      get
 | 
			
		||||
      {
 | 
			
		||||
        return modalResult;
 | 
			
		||||
      }
 | 
			
		||||
      set
 | 
			
		||||
      {
 | 
			
		||||
        modalResult = value;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Events ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public event WindowClosingEventHandler Closing;
 | 
			
		||||
    public event WindowClosedEventHandler Closed;
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
  
 | 
			
		||||
    #region //// Consructors ///////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public ModalContainer(Manager manager): base(manager)
 | 
			
		||||
    {      
 | 
			
		||||
      Manager.Input.GamePadDown += new GamePadEventHandler(Input_GamePadDown);
 | 
			
		||||
      GamePadActions = new WindowGamePadActions();
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion 
 | 
			
		||||
 | 
			
		||||
    #region //// Methods ///////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public virtual void ShowModal()
 | 
			
		||||
    {
 | 
			
		||||
      lastModal = Manager.ModalWindow;
 | 
			
		||||
      Manager.ModalWindow = this;
 | 
			
		||||
      Manager.Input.KeyDown += new KeyEventHandler(Input_KeyDown);
 | 
			
		||||
      Manager.Input.GamePadDown += new GamePadEventHandler(Input_GamePadDown);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////  
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public virtual void Close()
 | 
			
		||||
    {
 | 
			
		||||
      WindowClosingEventArgs ex = new WindowClosingEventArgs();
 | 
			
		||||
      OnClosing(ex);
 | 
			
		||||
      if (!ex.Cancel)
 | 
			
		||||
      {
 | 
			
		||||
        Manager.Input.KeyDown -= Input_KeyDown;
 | 
			
		||||
        Manager.Input.GamePadDown -= Input_GamePadDown;
 | 
			
		||||
        Manager.ModalWindow = lastModal;
 | 
			
		||||
        if (lastModal != null) lastModal.Focused = true;
 | 
			
		||||
        Hide();
 | 
			
		||||
        WindowClosedEventArgs ev = new WindowClosedEventArgs();
 | 
			
		||||
        OnClosed(ev);        
 | 
			
		||||
 | 
			
		||||
        if (ev.Dispose)
 | 
			
		||||
        {
 | 
			
		||||
          this.Dispose();          
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
    public virtual void Close(ModalResult modalResult)
 | 
			
		||||
    {
 | 
			
		||||
      ModalResult = modalResult;
 | 
			
		||||
      Close();
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
    protected virtual void OnClosing(WindowClosingEventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      if (Closing != null) Closing.Invoke(this, e);
 | 
			
		||||
    }
 | 
			
		||||
    //////////////////////////////////////////////////////////////////////////// 
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
    protected virtual void OnClosed(WindowClosedEventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      if (Closed != null) Closed.Invoke(this, e);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////      
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    void Input_KeyDown(object sender, KeyEventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      if (Visible && (Manager.FocusedControl != null && Manager.FocusedControl.Root == this) && 
 | 
			
		||||
          e.Key == Microsoft.Xna.Framework.Input.Keys.Escape)
 | 
			
		||||
      {        
 | 
			
		||||
        //Close(ModalResult.Cancel);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    void Input_GamePadDown(object sender, GamePadEventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      if (Visible && (Manager.FocusedControl != null && Manager.FocusedControl.Root == this))
 | 
			
		||||
      {
 | 
			
		||||
        if (e.Button == (GamePadActions as WindowGamePadActions).Accept)
 | 
			
		||||
        {          
 | 
			
		||||
          Close(ModalResult.Ok);
 | 
			
		||||
        }
 | 
			
		||||
        else if (e.Button == (GamePadActions as WindowGamePadActions).Cancel)
 | 
			
		||||
        {          
 | 
			
		||||
          Close(ModalResult.Cancel);
 | 
			
		||||
        }
 | 
			
		||||
      }  
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion  
 | 
			
		||||
  
 | 
			
		||||
  }        
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,69 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: NativeMethods.cs                             //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
using System;
 | 
			
		||||
using System.Runtime.InteropServices;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{
 | 
			
		||||
    [Obsolete("Native methods should be avoided at all times")]
 | 
			
		||||
    internal static class NativeMethods
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        #region //// Methods ///////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        [Obsolete]
 | 
			
		||||
        [DllImport("User32.dll", CharSet = CharSet.Unicode)]
 | 
			
		||||
        internal static extern IntPtr LoadImage(IntPtr instance, string fileName, uint type, int width, int height, uint load);
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        [Obsolete]
 | 
			
		||||
        [DllImport("User32.dll")]
 | 
			
		||||
        [return: MarshalAs(UnmanagedType.Bool)]
 | 
			
		||||
        internal static extern bool DestroyCursor(IntPtr cursor);
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        [Obsolete]
 | 
			
		||||
        internal static IntPtr LoadCursor(string fileName)
 | 
			
		||||
        {
 | 
			
		||||
            return LoadImage(IntPtr.Zero, fileName, 2, 0, 0, 0x0010);
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        [Obsolete]
 | 
			
		||||
        [DllImport("user32.dll")]
 | 
			
		||||
        internal static extern short GetKeyState(int key);
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,280 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: Panel.cs                                     //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
using Microsoft.Xna.Framework;
 | 
			
		||||
using Microsoft.Xna.Framework.Graphics;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{ 
 | 
			
		||||
 | 
			
		||||
  public class Panel: Container
 | 
			
		||||
  {
 | 
			
		||||
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                 
 | 
			
		||||
    private Bevel bevel = null;
 | 
			
		||||
    private BevelStyle bevelStyle = BevelStyle.None;
 | 
			
		||||
    private BevelBorder bevelBorder = BevelBorder.None;
 | 
			
		||||
    private int bevelMargin = 0;
 | 
			
		||||
    private Color bevelColor = Color.Transparent;   
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Properties ////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public BevelStyle BevelStyle
 | 
			
		||||
    {
 | 
			
		||||
      get { return bevelStyle; }
 | 
			
		||||
      set 
 | 
			
		||||
      { 
 | 
			
		||||
        if (bevelStyle != value)
 | 
			
		||||
        {
 | 
			
		||||
          bevelStyle = bevel.Style = value; 
 | 
			
		||||
          AdjustMargins();
 | 
			
		||||
          if (!Suspended) OnBevelStyleChanged(new EventArgs());
 | 
			
		||||
        }  
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public BevelBorder BevelBorder
 | 
			
		||||
    {
 | 
			
		||||
      get { return bevelBorder; }
 | 
			
		||||
      set 
 | 
			
		||||
      { 
 | 
			
		||||
        if (bevelBorder != value)
 | 
			
		||||
        {
 | 
			
		||||
          bevelBorder = bevel.Border = value; 
 | 
			
		||||
          bevel.Visible = bevelBorder != BevelBorder.None; 
 | 
			
		||||
          AdjustMargins();
 | 
			
		||||
          if (!Suspended) OnBevelBorderChanged(new EventArgs());
 | 
			
		||||
        }  
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public int BevelMargin
 | 
			
		||||
    {
 | 
			
		||||
      get { return bevelMargin; }
 | 
			
		||||
      set 
 | 
			
		||||
      { 
 | 
			
		||||
        if (bevelMargin != value)
 | 
			
		||||
        {
 | 
			
		||||
          bevelMargin = value; 
 | 
			
		||||
          AdjustMargins();
 | 
			
		||||
          if (!Suspended) OnBevelMarginChanged(new EventArgs());
 | 
			
		||||
        }  
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public virtual Color BevelColor
 | 
			
		||||
    {
 | 
			
		||||
      get { return bevelColor; }
 | 
			
		||||
      set 
 | 
			
		||||
      {
 | 
			
		||||
        bevel.Color = bevelColor = value; 
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
       
 | 
			
		||||
    #endregion
 | 
			
		||||
    
 | 
			
		||||
    #region //// Events ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                 
 | 
			
		||||
    public event EventHandler BevelBorderChanged;
 | 
			
		||||
    public event EventHandler BevelStyleChanged;
 | 
			
		||||
    public event EventHandler BevelMarginChanged;
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion    
 | 
			
		||||
 | 
			
		||||
    #region //// Construstors //////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////       
 | 
			
		||||
    public Panel(Manager manager): base(manager)
 | 
			
		||||
    {
 | 
			
		||||
      Passive = false;
 | 
			
		||||
      CanFocus = false;
 | 
			
		||||
      Width = 64;
 | 
			
		||||
      Height = 64;
 | 
			
		||||
      
 | 
			
		||||
      bevel = new Bevel(Manager);                     
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
    
 | 
			
		||||
    #region //// Methods ///////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public override void Init()
 | 
			
		||||
    {      
 | 
			
		||||
      base.Init();            
 | 
			
		||||
      
 | 
			
		||||
      bevel.Init();
 | 
			
		||||
      bevel.Style = bevelStyle;
 | 
			
		||||
      bevel.Border = bevelBorder;
 | 
			
		||||
      bevel.Left = 0;
 | 
			
		||||
      bevel.Top = 0;
 | 
			
		||||
      bevel.Width = Width;
 | 
			
		||||
      bevel.Height = Height;
 | 
			
		||||
      bevel.Color = bevelColor;
 | 
			
		||||
      bevel.Visible = (bevelBorder != BevelBorder.None);
 | 
			
		||||
      bevel.Anchor = Anchors.Left | Anchors.Top | Anchors.Right | Anchors.Bottom;
 | 
			
		||||
      Add(bevel, false);      
 | 
			
		||||
      AdjustMargins();  
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                          
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected internal override void InitSkin()
 | 
			
		||||
    {
 | 
			
		||||
      base.InitSkin();
 | 
			
		||||
      Skin = new SkinControl(Manager.Skin.Controls["Panel"]);  
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected override void AdjustMargins()
 | 
			
		||||
    {
 | 
			
		||||
      int l = 0;
 | 
			
		||||
      int t = 0;
 | 
			
		||||
      int r = 0;
 | 
			
		||||
      int b = 0;
 | 
			
		||||
      int s = bevelMargin;
 | 
			
		||||
 | 
			
		||||
      if (bevelBorder != BevelBorder.None)
 | 
			
		||||
      {
 | 
			
		||||
        if (bevelStyle != BevelStyle.Flat)
 | 
			
		||||
        {
 | 
			
		||||
          s += 2;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
          s += 1;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (bevelBorder == BevelBorder.Left || bevelBorder == BevelBorder.All)
 | 
			
		||||
        {
 | 
			
		||||
          l = s;
 | 
			
		||||
        }
 | 
			
		||||
        if (bevelBorder == BevelBorder.Top || bevelBorder == BevelBorder.All)
 | 
			
		||||
        {
 | 
			
		||||
          t = s;
 | 
			
		||||
        }
 | 
			
		||||
        if (bevelBorder == BevelBorder.Right || bevelBorder == BevelBorder.All)
 | 
			
		||||
        {
 | 
			
		||||
          r = s;
 | 
			
		||||
        }
 | 
			
		||||
        if (bevelBorder == BevelBorder.Bottom || bevelBorder == BevelBorder.All)
 | 
			
		||||
        {
 | 
			
		||||
          b = s;
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
      ClientMargins = new Margins(Skin.ClientMargins.Left + l, Skin.ClientMargins.Top + t, Skin.ClientMargins.Right + r, Skin.ClientMargins.Bottom + b);      
 | 
			
		||||
      
 | 
			
		||||
      base.AdjustMargins();                        
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
 | 
			
		||||
    {              
 | 
			
		||||
      int x = rect.Left;
 | 
			
		||||
      int y = rect.Top;
 | 
			
		||||
      int w = rect.Width;
 | 
			
		||||
      int h = rect.Height;
 | 
			
		||||
      int s = bevelMargin;
 | 
			
		||||
 | 
			
		||||
      if (bevelBorder != BevelBorder.None)
 | 
			
		||||
      {      
 | 
			
		||||
        if (bevelStyle != BevelStyle.Flat)
 | 
			
		||||
        {
 | 
			
		||||
          s += 2;
 | 
			
		||||
        }
 | 
			
		||||
        else 
 | 
			
		||||
        {
 | 
			
		||||
          s += 1;
 | 
			
		||||
        }      
 | 
			
		||||
      
 | 
			
		||||
        if (bevelBorder == BevelBorder.Left || bevelBorder == BevelBorder.All)
 | 
			
		||||
        {
 | 
			
		||||
          x += s; 
 | 
			
		||||
          w -= s; 
 | 
			
		||||
        }
 | 
			
		||||
        if (bevelBorder == BevelBorder.Top || bevelBorder == BevelBorder.All)
 | 
			
		||||
        {
 | 
			
		||||
          y += s;
 | 
			
		||||
          h -= s;
 | 
			
		||||
        } 
 | 
			
		||||
        if (bevelBorder == BevelBorder.Right || bevelBorder == BevelBorder.All)
 | 
			
		||||
        {
 | 
			
		||||
          w -= s;
 | 
			
		||||
        } 
 | 
			
		||||
        if (bevelBorder == BevelBorder.Bottom || bevelBorder == BevelBorder.All)
 | 
			
		||||
        {
 | 
			
		||||
          h -= s;
 | 
			
		||||
        }              
 | 
			
		||||
      }                  
 | 
			
		||||
      
 | 
			
		||||
      base.DrawControl(renderer, new Rectangle(x, y, w, h), gameTime);      
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////          
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    protected virtual void OnBevelBorderChanged(EventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      if (BevelBorderChanged != null) BevelBorderChanged.Invoke(this, e);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    protected virtual void OnBevelStyleChanged(EventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      if (BevelStyleChanged != null) BevelStyleChanged.Invoke(this, e);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    protected virtual void OnBevelMarginChanged(EventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      if (BevelMarginChanged != null) BevelMarginChanged.Invoke(this, e);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
 | 
			
		||||
    #endregion  
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,264 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: ProgressBar.cs                               //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
using Microsoft.Xna.Framework;
 | 
			
		||||
using System;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
  #region //// Enums /////////////
 | 
			
		||||
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
  public enum ProgressBarMode
 | 
			
		||||
  {
 | 
			
		||||
    Default,
 | 
			
		||||
    Infinite
 | 
			
		||||
  }
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
  #endregion
 | 
			
		||||
 | 
			
		||||
  public class ProgressBar : Control
 | 
			
		||||
  {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                 
 | 
			
		||||
    private int range = 100;
 | 
			
		||||
    private int value = 0;
 | 
			
		||||
    private double time = 0;
 | 
			
		||||
    private int sign = 1;
 | 
			
		||||
    private ProgressBarMode mode = ProgressBarMode.Default;
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Properties ////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public int Value
 | 
			
		||||
    {
 | 
			
		||||
      get { return this.value; }
 | 
			
		||||
      set
 | 
			
		||||
      {
 | 
			
		||||
        if (mode == ProgressBarMode.Default)
 | 
			
		||||
        {
 | 
			
		||||
          if (this.value != value)
 | 
			
		||||
          {
 | 
			
		||||
            this.value = value;
 | 
			
		||||
            if (this.value > range) this.value = range;
 | 
			
		||||
            if (this.value < 0) this.value = 0;
 | 
			
		||||
            Invalidate();
 | 
			
		||||
 | 
			
		||||
            if (!Suspended) OnValueChanged(new EventArgs());
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public ProgressBarMode Mode
 | 
			
		||||
    {
 | 
			
		||||
      get { return mode; }
 | 
			
		||||
      set
 | 
			
		||||
      {
 | 
			
		||||
        if (mode != value)
 | 
			
		||||
        {
 | 
			
		||||
          mode = value;
 | 
			
		||||
          if (mode == ProgressBarMode.Infinite)
 | 
			
		||||
          {
 | 
			
		||||
            range = 100;
 | 
			
		||||
            this.value = 0;
 | 
			
		||||
            time = 0;
 | 
			
		||||
            sign = 1;
 | 
			
		||||
          }
 | 
			
		||||
          else
 | 
			
		||||
          {
 | 
			
		||||
            this.value = 0;
 | 
			
		||||
            range = 100;
 | 
			
		||||
          }
 | 
			
		||||
          Invalidate();
 | 
			
		||||
 | 
			
		||||
          if (!Suspended) OnModeChanged(new EventArgs());
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public int Range
 | 
			
		||||
    {
 | 
			
		||||
      get { return range; }
 | 
			
		||||
      set
 | 
			
		||||
      {
 | 
			
		||||
        if (range != value)
 | 
			
		||||
        {
 | 
			
		||||
          if (mode == ProgressBarMode.Default)
 | 
			
		||||
          {
 | 
			
		||||
            range = value;
 | 
			
		||||
            if (range < 0) range = 0;
 | 
			
		||||
            if (range < this.value) this.value = range;
 | 
			
		||||
            Invalidate();
 | 
			
		||||
 | 
			
		||||
            if (!Suspended) OnRangeChanged(new EventArgs());
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Events ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                 
 | 
			
		||||
    public event EventHandler ValueChanged;
 | 
			
		||||
    public event EventHandler RangeChanged;
 | 
			
		||||
    public event EventHandler ModeChanged;
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Construstors //////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////       
 | 
			
		||||
    public ProgressBar(Manager manager)
 | 
			
		||||
      : base(manager)
 | 
			
		||||
    {
 | 
			
		||||
      Width = 128;
 | 
			
		||||
      Height = 16;
 | 
			
		||||
      MinimumHeight = 8;
 | 
			
		||||
      MinimumWidth = 32;
 | 
			
		||||
      Passive = true;
 | 
			
		||||
      CanFocus = false;
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Methods ///////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public override void Init()
 | 
			
		||||
    {
 | 
			
		||||
      base.Init();
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                          
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
 | 
			
		||||
    {
 | 
			
		||||
      CheckLayer(Skin, "Control");
 | 
			
		||||
      CheckLayer(Skin, "Scale");
 | 
			
		||||
 | 
			
		||||
      base.DrawControl(renderer, rect, gameTime);
 | 
			
		||||
 | 
			
		||||
      if (Value > 0 || mode == ProgressBarMode.Infinite)
 | 
			
		||||
      {
 | 
			
		||||
        SkinLayer p = Skin.Layers["Control"];
 | 
			
		||||
        SkinLayer l = Skin.Layers["Scale"];
 | 
			
		||||
        Rectangle r = new Rectangle(rect.Left + p.ContentMargins.Left,
 | 
			
		||||
                                    rect.Top + p.ContentMargins.Top,
 | 
			
		||||
                                    rect.Width - p.ContentMargins.Vertical,
 | 
			
		||||
                                    rect.Height - p.ContentMargins.Horizontal);
 | 
			
		||||
 | 
			
		||||
        float perc = ((float)value / range) * 100;
 | 
			
		||||
        int w = (int)((perc / 100) * r.Width);
 | 
			
		||||
        Rectangle rx;
 | 
			
		||||
        if (mode == ProgressBarMode.Default)
 | 
			
		||||
        {
 | 
			
		||||
          if (w < l.SizingMargins.Vertical) w = l.SizingMargins.Vertical;
 | 
			
		||||
          rx = new Rectangle(r.Left, r.Top, w, r.Height);
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
          int s = r.Left + w;
 | 
			
		||||
          if (s > r.Left + p.ContentMargins.Left + r.Width - (r.Width / 4)) s = r.Left + p.ContentMargins.Left + r.Width - (r.Width / 4);
 | 
			
		||||
          rx = new Rectangle(s, r.Top, (r.Width / 4), r.Height);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        renderer.DrawLayer(this, l, rx);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    protected internal override void Update(GameTime gameTime)
 | 
			
		||||
    {
 | 
			
		||||
      base.Update(gameTime);
 | 
			
		||||
 | 
			
		||||
      if (mode == ProgressBarMode.Infinite && Enabled && Visible)
 | 
			
		||||
      {
 | 
			
		||||
        time += gameTime.ElapsedGameTime.TotalMilliseconds;
 | 
			
		||||
        if (time >= 33f)
 | 
			
		||||
        {
 | 
			
		||||
          value += sign * (int)Math.Ceiling(time / 20f);
 | 
			
		||||
          if (value >= Range - (Range / 4))
 | 
			
		||||
          {
 | 
			
		||||
            value = Range - (Range / 4);
 | 
			
		||||
            sign = -1;
 | 
			
		||||
          }
 | 
			
		||||
          else if (value <= 0)
 | 
			
		||||
          {
 | 
			
		||||
            value = 0;
 | 
			
		||||
            sign = 1;
 | 
			
		||||
          }  
 | 
			
		||||
          time = 0;          
 | 
			
		||||
          Invalidate();
 | 
			
		||||
        }                        
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    protected virtual void OnValueChanged(EventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      if (ValueChanged != null) ValueChanged.Invoke(this, e);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    protected virtual void OnRangeChanged(EventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      if (RangeChanged != null) RangeChanged.Invoke(this, e);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    protected virtual void OnModeChanged(EventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      if (ModeChanged != null) ModeChanged.Invoke(this, e);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,36 +0,0 @@
 | 
			
		||||
using System.Reflection;
 | 
			
		||||
using System.Runtime.CompilerServices;
 | 
			
		||||
using System.Runtime.InteropServices;
 | 
			
		||||
 | 
			
		||||
// General Information about an assembly is controlled through the following 
 | 
			
		||||
// set of attributes. Change these attribute values to modify the information
 | 
			
		||||
// associated with an assembly.
 | 
			
		||||
[assembly: AssemblyTitle("MonoGame.Controls")]
 | 
			
		||||
[assembly: AssemblyDescription("")]
 | 
			
		||||
[assembly: AssemblyConfiguration("")]
 | 
			
		||||
[assembly: AssemblyCompany("")]
 | 
			
		||||
[assembly: AssemblyProduct("MonoGame.Controls")]
 | 
			
		||||
[assembly: AssemblyCopyright("Copyright ©  2014")]
 | 
			
		||||
[assembly: AssemblyTrademark("")]
 | 
			
		||||
[assembly: AssemblyCulture("")]
 | 
			
		||||
 | 
			
		||||
// Setting ComVisible to false makes the types in this assembly not visible 
 | 
			
		||||
// to COM components.  If you need to access a type in this assembly from 
 | 
			
		||||
// COM, set the ComVisible attribute to true on that type.
 | 
			
		||||
[assembly: ComVisible(false)]
 | 
			
		||||
 | 
			
		||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
 | 
			
		||||
[assembly: Guid("581cd203-a917-4a56-87f8-79ef3cbe4f5e")]
 | 
			
		||||
 | 
			
		||||
// Version information for an assembly consists of the following four values:
 | 
			
		||||
//
 | 
			
		||||
//      Major Version
 | 
			
		||||
//      Minor Version 
 | 
			
		||||
//      Build Number
 | 
			
		||||
//      Revision
 | 
			
		||||
//
 | 
			
		||||
// You can specify all the values or you can default the Build and Revision Numbers 
 | 
			
		||||
// by using the '*' as shown below:
 | 
			
		||||
// [assembly: AssemblyVersion("1.0.*")]
 | 
			
		||||
[assembly: AssemblyVersion("1.0.0.0")]
 | 
			
		||||
[assembly: AssemblyFileVersion("1.0.0.0")]
 | 
			
		||||
@@ -1,159 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: RadioButton.cs                               //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
using Microsoft.Xna.Framework;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
  #region //// Enums /////////////
 | 
			
		||||
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////               
 | 
			
		||||
  public enum RadioButtonMode
 | 
			
		||||
  {
 | 
			
		||||
    Auto,
 | 
			
		||||
    Manual
 | 
			
		||||
  }
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
 #endregion
 | 
			
		||||
 | 
			
		||||
  public class RadioButton: CheckBox
 | 
			
		||||
  {
 | 
			
		||||
 | 
			
		||||
    #region //// Consts ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    private const string skRadioButton = "RadioButton";
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////               
 | 
			
		||||
    private RadioButtonMode mode = RadioButtonMode.Auto;  
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Properties ////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public RadioButtonMode Mode
 | 
			
		||||
    {
 | 
			
		||||
      get { return mode; }
 | 
			
		||||
      set { mode = value; }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////       
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Events ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                         
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Construstors //////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////       
 | 
			
		||||
    public RadioButton(Manager manager): base(manager)
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Methods ///////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public override void Init()
 | 
			
		||||
    {
 | 
			
		||||
      base.Init();
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected internal override void InitSkin()
 | 
			
		||||
    {
 | 
			
		||||
      base.InitSkin();
 | 
			
		||||
      Skin = new SkinControl(Manager.Skin.Controls[skRadioButton]);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
 | 
			
		||||
    {
 | 
			
		||||
      base.DrawControl(renderer, rect, gameTime);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    protected override void OnClick(EventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      MouseEventArgs ex = (e is MouseEventArgs) ? (MouseEventArgs)e : new MouseEventArgs();      
 | 
			
		||||
      
 | 
			
		||||
      if (ex.Button == MouseButton.Left || ex.Button == MouseButton.None)      
 | 
			
		||||
      {      
 | 
			
		||||
        if (mode == RadioButtonMode.Auto)
 | 
			
		||||
        {
 | 
			
		||||
          if (Parent != null)
 | 
			
		||||
          {
 | 
			
		||||
            ControlsList lst = Parent.Controls as ControlsList;
 | 
			
		||||
            for (int i = 0; i < lst.Count; i++)
 | 
			
		||||
            {
 | 
			
		||||
              if (lst[i] is RadioButton)
 | 
			
		||||
              {
 | 
			
		||||
                (lst[i] as RadioButton).Checked = false;
 | 
			
		||||
              }
 | 
			
		||||
            }  
 | 
			
		||||
          }
 | 
			
		||||
          else if (Parent == null && Manager != null)
 | 
			
		||||
          {
 | 
			
		||||
            ControlsList lst = Manager.Controls as ControlsList;
 | 
			
		||||
            
 | 
			
		||||
            for (int i = 0; i < lst.Count; i++)
 | 
			
		||||
            {              
 | 
			
		||||
              if (lst[i] is RadioButton)
 | 
			
		||||
              {
 | 
			
		||||
                (lst[i] as RadioButton).Checked = false;
 | 
			
		||||
              }
 | 
			
		||||
            }  
 | 
			
		||||
          }  
 | 
			
		||||
        }  
 | 
			
		||||
      }              
 | 
			
		||||
      base.OnClick(e);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////          
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,767 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: Renderer.cs                                  //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
using System;
 | 
			
		||||
using Microsoft.Xna.Framework;
 | 
			
		||||
using Microsoft.Xna.Framework.Graphics;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{
 | 
			
		||||
    public enum BlendingMode
 | 
			
		||||
    {
 | 
			
		||||
        Default,
 | 
			
		||||
        None,
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    #region //// Classes ///////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public class DeviceStates
 | 
			
		||||
    {
 | 
			
		||||
        public readonly BlendState BlendState;
 | 
			
		||||
        public readonly RasterizerState RasterizerState;
 | 
			
		||||
        public readonly DepthStencilState DepthStencilState;
 | 
			
		||||
        public readonly SamplerState SamplerState;
 | 
			
		||||
 | 
			
		||||
        public DeviceStates()
 | 
			
		||||
        {
 | 
			
		||||
            BlendState = new BlendState();
 | 
			
		||||
            BlendState.AlphaBlendFunction = BlendState.AlphaBlend.AlphaBlendFunction;
 | 
			
		||||
            BlendState.AlphaDestinationBlend = BlendState.AlphaBlend.AlphaDestinationBlend;
 | 
			
		||||
            BlendState.AlphaSourceBlend = BlendState.AlphaBlend.AlphaSourceBlend;
 | 
			
		||||
            BlendState.BlendFactor = BlendState.AlphaBlend.BlendFactor;
 | 
			
		||||
            BlendState.ColorBlendFunction = BlendState.AlphaBlend.ColorBlendFunction;
 | 
			
		||||
            BlendState.ColorDestinationBlend = BlendState.AlphaBlend.ColorDestinationBlend;
 | 
			
		||||
            BlendState.ColorSourceBlend = BlendState.AlphaBlend.ColorSourceBlend;
 | 
			
		||||
            BlendState.ColorWriteChannels = BlendState.AlphaBlend.ColorWriteChannels;
 | 
			
		||||
            BlendState.ColorWriteChannels1 = BlendState.AlphaBlend.ColorWriteChannels1;
 | 
			
		||||
            BlendState.ColorWriteChannels2 = BlendState.AlphaBlend.ColorWriteChannels2;
 | 
			
		||||
            BlendState.ColorWriteChannels3 = BlendState.AlphaBlend.ColorWriteChannels3;
 | 
			
		||||
            BlendState.MultiSampleMask = BlendState.AlphaBlend.MultiSampleMask;
 | 
			
		||||
 | 
			
		||||
            RasterizerState = new RasterizerState();
 | 
			
		||||
            RasterizerState.CullMode = RasterizerState.CullNone.CullMode;
 | 
			
		||||
            RasterizerState.DepthBias = RasterizerState.CullNone.DepthBias;
 | 
			
		||||
            RasterizerState.FillMode = RasterizerState.CullNone.FillMode;
 | 
			
		||||
            RasterizerState.MultiSampleAntiAlias = RasterizerState.CullNone.MultiSampleAntiAlias;
 | 
			
		||||
            RasterizerState.ScissorTestEnable = RasterizerState.CullNone.ScissorTestEnable;
 | 
			
		||||
            RasterizerState.SlopeScaleDepthBias = RasterizerState.CullNone.SlopeScaleDepthBias;
 | 
			
		||||
 | 
			
		||||
            RasterizerState.ScissorTestEnable = true;
 | 
			
		||||
 | 
			
		||||
            SamplerState = new SamplerState();
 | 
			
		||||
            SamplerState.AddressU = SamplerState.AnisotropicClamp.AddressU;
 | 
			
		||||
            SamplerState.AddressV = SamplerState.AnisotropicClamp.AddressV;
 | 
			
		||||
            SamplerState.AddressW = SamplerState.AnisotropicClamp.AddressW;
 | 
			
		||||
            SamplerState.Filter = SamplerState.AnisotropicClamp.Filter;
 | 
			
		||||
            SamplerState.MaxAnisotropy = SamplerState.AnisotropicClamp.MaxAnisotropy;
 | 
			
		||||
            SamplerState.MaxMipLevel = SamplerState.AnisotropicClamp.MaxMipLevel;
 | 
			
		||||
            SamplerState.MipMapLevelOfDetailBias = SamplerState.AnisotropicClamp.MipMapLevelOfDetailBias;
 | 
			
		||||
 | 
			
		||||
            DepthStencilState = new DepthStencilState();
 | 
			
		||||
            DepthStencilState = DepthStencilState.None;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    public class Renderer : Component
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        private SpriteBatch sb = null;
 | 
			
		||||
        private DeviceStates states = new DeviceStates();
 | 
			
		||||
        private BlendingMode bmode = BlendingMode.Default;
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region //// Properties ////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        public virtual SpriteBatch SpriteBatch
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                return sb;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region //// Constructors //////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        public Renderer(Manager manager)
 | 
			
		||||
            : base(manager)
 | 
			
		||||
        {
 | 
			
		||||
            sb = new SpriteBatch(Manager.GraphicsDevice);
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region //// Destructors ///////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        protected override void Dispose(bool disposing)
 | 
			
		||||
        {
 | 
			
		||||
            if (disposing)
 | 
			
		||||
            {
 | 
			
		||||
                if (sb != null)
 | 
			
		||||
                {
 | 
			
		||||
                    sb.Dispose();
 | 
			
		||||
                    sb = null;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            base.Dispose(disposing);
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region //// Methods ///////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        public override void Init()
 | 
			
		||||
        {
 | 
			
		||||
            base.Init();
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        public virtual void Begin(BlendingMode mode)
 | 
			
		||||
        {
 | 
			
		||||
            bmode = mode;
 | 
			
		||||
            if (mode != BlendingMode.None)
 | 
			
		||||
            {
 | 
			
		||||
                sb.Begin(SpriteSortMode.Immediate, states.BlendState, states.SamplerState, states.DepthStencilState, states.RasterizerState);
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                sb.Begin(SpriteSortMode.Immediate, BlendState.Opaque, states.SamplerState, states.DepthStencilState, states.RasterizerState);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        public virtual void End()
 | 
			
		||||
        {
 | 
			
		||||
            sb.End();
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        public virtual void Draw(Texture2D texture, Rectangle destination, Color color)
 | 
			
		||||
        {
 | 
			
		||||
            if (destination.Width > 0 && destination.Height > 0)
 | 
			
		||||
            {
 | 
			
		||||
                sb.Draw(texture, destination, null, color, 0.0f, Vector2.Zero, SpriteEffects.None, Manager.GlobalDepth);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        public virtual void DrawTileTexture(Texture2D texture, Rectangle destination, Color color)
 | 
			
		||||
        {
 | 
			
		||||
            if (destination.Width > 0 && destination.Height > 0)
 | 
			
		||||
            {
 | 
			
		||||
                End();
 | 
			
		||||
 | 
			
		||||
                sb.Begin(SpriteSortMode.Texture, BlendState.AlphaBlend, SamplerState.LinearWrap, DepthStencilState.Default, RasterizerState.CullNone);
 | 
			
		||||
 | 
			
		||||
                sb.Draw(texture, new Vector2(destination.X,destination.Y), destination, color, 0, Vector2.Zero, 1, SpriteEffects.None, 0);
 | 
			
		||||
 | 
			
		||||
                End();
 | 
			
		||||
                Begin(bmode);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        public virtual void Draw(Texture2D texture, Rectangle destination, Rectangle source, Color color)
 | 
			
		||||
        {
 | 
			
		||||
            if (source.Width > 0 && source.Height > 0 && destination.Width > 0 && destination.Height > 0)
 | 
			
		||||
            {
 | 
			
		||||
                sb.Draw(texture, destination, source, color, 0.0f, Vector2.Zero, SpriteEffects.None, Manager.GlobalDepth);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        public virtual void Draw(Texture2D texture, int left, int top, Color color)
 | 
			
		||||
        {
 | 
			
		||||
            sb.Draw(texture, new Vector2(left, top), null, color, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, Manager.GlobalDepth);
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        public virtual void Draw(Texture2D texture, int left, int top, Rectangle source, Color color)
 | 
			
		||||
        {
 | 
			
		||||
            if (source.Width > 0 && source.Height > 0)
 | 
			
		||||
            {
 | 
			
		||||
                sb.Draw(texture, new Vector2(left, top), source, color, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, Manager.GlobalDepth);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        public virtual void DrawString(SpriteFont font, string text, int left, int top, Color color)
 | 
			
		||||
        {
 | 
			
		||||
            sb.DrawString(font, text, new Vector2(left, top), color, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, Manager.GlobalDepth);
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        public virtual void DrawString(SpriteFont font, string text, Rectangle rect, Color color, Alignment alignment)
 | 
			
		||||
        {
 | 
			
		||||
            DrawString(font, text, rect, color, alignment, 0, 0, true);
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        public virtual void DrawString(SpriteFont font, string text, Rectangle rect, Color color, Alignment alignment, bool ellipsis)
 | 
			
		||||
        {
 | 
			
		||||
            DrawString(font, text, rect, color, alignment, 0, 0, ellipsis);
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        public virtual void DrawString(Control control, SkinLayer layer, string text, Rectangle rect)
 | 
			
		||||
        {
 | 
			
		||||
            DrawString(control, layer, text, rect, true, 0, 0, true);
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        public virtual void DrawString(Control control, SkinLayer layer, string text, Rectangle rect, ControlState state)
 | 
			
		||||
        {
 | 
			
		||||
            DrawString(control, layer, text, rect, state, true, 0, 0, true);
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        public virtual void DrawString(Control control, SkinLayer layer, string text, Rectangle rect, bool margins)
 | 
			
		||||
        {
 | 
			
		||||
            DrawString(control, layer, text, rect, margins, 0, 0, true);
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        public virtual void DrawString(Control control, SkinLayer layer, string text, Rectangle rect, ControlState state, bool margins)
 | 
			
		||||
        {
 | 
			
		||||
            DrawString(control, layer, text, rect, state, margins, 0, 0, true);
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        public virtual void DrawString(Control control, SkinLayer layer, string text, Rectangle rect, bool margins, int ox, int oy)
 | 
			
		||||
        {
 | 
			
		||||
            DrawString(control, layer, text, rect, margins, ox, oy, true);
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        public virtual void DrawString(Control control, SkinLayer layer, string text, Rectangle rect, ControlState state, bool margins, int ox, int oy)
 | 
			
		||||
        {
 | 
			
		||||
            DrawString(control, layer, text, rect, state, margins, ox, oy, true);
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        public virtual void DrawString(Control control, SkinLayer layer, string text, Rectangle rect, bool margins, int ox, int oy, bool ellipsis)
 | 
			
		||||
        {
 | 
			
		||||
            DrawString(control, layer, text, rect, control.ControlState, margins, ox, oy, ellipsis);
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        public virtual void DrawString(Control control, SkinLayer layer, string text, Rectangle rect, ControlState state, bool margins, int ox, int oy, bool ellipsis)
 | 
			
		||||
        {
 | 
			
		||||
            Color col = Color.White;
 | 
			
		||||
 | 
			
		||||
            if (layer.Text != null)
 | 
			
		||||
            {
 | 
			
		||||
                if (margins)
 | 
			
		||||
                {
 | 
			
		||||
                    Margins m = layer.ContentMargins;
 | 
			
		||||
                    rect = new Rectangle(rect.Left + m.Left, rect.Top + m.Top, rect.Width - m.Horizontal, rect.Height - m.Vertical);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if (state == ControlState.Hovered && (layer.States.Hovered.Index != -1))
 | 
			
		||||
                {
 | 
			
		||||
                    col = layer.Text.Colors.Hovered;
 | 
			
		||||
                }
 | 
			
		||||
                else if (state == ControlState.Pressed)
 | 
			
		||||
                {
 | 
			
		||||
                    col = layer.Text.Colors.Pressed;
 | 
			
		||||
                }
 | 
			
		||||
                else if (state == ControlState.Focused || (control.Focused && state == ControlState.Hovered && layer.States.Hovered.Index == -1))
 | 
			
		||||
                {
 | 
			
		||||
                    col = layer.Text.Colors.Focused;
 | 
			
		||||
                }
 | 
			
		||||
                else if (state == ControlState.Disabled)
 | 
			
		||||
                {
 | 
			
		||||
                    col = layer.Text.Colors.Disabled;
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    col = layer.Text.Colors.Enabled;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if (text != null && text != "")
 | 
			
		||||
                {
 | 
			
		||||
                    SkinText font = layer.Text;
 | 
			
		||||
                    if (control.TextColor != Control.UndefinedColor && control.ControlState != ControlState.Disabled) col = control.TextColor;
 | 
			
		||||
                    DrawString(font.Font.Resource, text, rect, col, font.Alignment, font.OffsetX + ox, font.OffsetY + oy, ellipsis);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        public virtual void DrawString(SpriteFont font, string text, Rectangle rect, Color color, Alignment alignment, int offsetX, int offsetY, bool ellipsis)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
            if (ellipsis)
 | 
			
		||||
            {
 | 
			
		||||
                const string elli = "...";
 | 
			
		||||
                int size = (int)Math.Ceiling(font.MeasureString(text).X);
 | 
			
		||||
                if (size > rect.Width)
 | 
			
		||||
                {
 | 
			
		||||
                    int es = (int)Math.Ceiling(font.MeasureString(elli).X);
 | 
			
		||||
                    for (int i = text.Length - 1; i > 0; i--)
 | 
			
		||||
                    {
 | 
			
		||||
                        int c = 1;
 | 
			
		||||
                        if (char.IsWhiteSpace(text[i - 1]))
 | 
			
		||||
                        {
 | 
			
		||||
                            c = 2;
 | 
			
		||||
                            i--;
 | 
			
		||||
                        }
 | 
			
		||||
                        text = text.Remove(i, c);
 | 
			
		||||
                        size = (int)Math.Ceiling(font.MeasureString(text).X);
 | 
			
		||||
                        if (size + es <= rect.Width)
 | 
			
		||||
                        {
 | 
			
		||||
                            break;
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    text += elli;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (rect.Width > 0 && rect.Height > 0)
 | 
			
		||||
            {
 | 
			
		||||
                Vector2 pos = new Vector2(rect.Left, rect.Top);
 | 
			
		||||
                Vector2 size = font.MeasureString(text);
 | 
			
		||||
 | 
			
		||||
                int x = 0; int y = 0;
 | 
			
		||||
 | 
			
		||||
                switch (alignment)
 | 
			
		||||
                {
 | 
			
		||||
                    case Alignment.TopLeft:
 | 
			
		||||
                        break;
 | 
			
		||||
                    case Alignment.TopCenter:
 | 
			
		||||
                        x = GetTextCenter(rect.Width, size.X);
 | 
			
		||||
                        break;
 | 
			
		||||
                    case Alignment.TopRight:
 | 
			
		||||
                        x = rect.Width - (int)size.X;
 | 
			
		||||
                        break;
 | 
			
		||||
                    case Alignment.MiddleLeft:
 | 
			
		||||
                        y = GetTextCenter(rect.Height, size.Y);
 | 
			
		||||
                        break;
 | 
			
		||||
                    case Alignment.MiddleRight:
 | 
			
		||||
                        x = rect.Width - (int)size.X;
 | 
			
		||||
                        y = GetTextCenter(rect.Height, size.Y);
 | 
			
		||||
                        break;
 | 
			
		||||
                    case Alignment.BottomLeft:
 | 
			
		||||
                        y = rect.Height - (int)size.Y;
 | 
			
		||||
                        break;
 | 
			
		||||
                    case Alignment.BottomCenter:
 | 
			
		||||
                        x = GetTextCenter(rect.Width, size.X);
 | 
			
		||||
                        y = rect.Height - (int)size.Y;
 | 
			
		||||
                        break;
 | 
			
		||||
                    case Alignment.BottomRight:
 | 
			
		||||
                        x = rect.Width - (int)size.X;
 | 
			
		||||
                        y = rect.Height - (int)size.Y;
 | 
			
		||||
                        break;
 | 
			
		||||
 | 
			
		||||
                    default:
 | 
			
		||||
                        x = GetTextCenter(rect.Width, size.X);
 | 
			
		||||
                        y = GetTextCenter(rect.Height, size.Y);
 | 
			
		||||
                        break;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                pos.X = (int)(pos.X + x);
 | 
			
		||||
                pos.Y = (int)(pos.Y + y);
 | 
			
		||||
 | 
			
		||||
                DrawString(font, text, (int)pos.X + offsetX, (int)pos.Y + offsetY, color);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        private static int GetTextCenter(float size1, float size2)
 | 
			
		||||
        {
 | 
			
		||||
            return (int)Math.Ceiling((size1 / 2) - (size2 / 2));
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////              
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        public virtual void DrawLayer(SkinLayer layer, Rectangle rect, Color color, int index)
 | 
			
		||||
        {
 | 
			
		||||
            Size imageSize = new Size(layer.Image.Resource.Width, layer.Image.Resource.Height);
 | 
			
		||||
            Size partSize = new Size(layer.Width, layer.Height);
 | 
			
		||||
 | 
			
		||||
            Draw(layer.Image.Resource, GetDestinationArea(rect, layer.SizingMargins, Alignment.TopLeft), GetSourceArea(imageSize, partSize, layer.SizingMargins, Alignment.TopLeft, index), color);
 | 
			
		||||
            Draw(layer.Image.Resource, GetDestinationArea(rect, layer.SizingMargins, Alignment.TopCenter), GetSourceArea(imageSize, partSize, layer.SizingMargins, Alignment.TopCenter, index), color);
 | 
			
		||||
            Draw(layer.Image.Resource, GetDestinationArea(rect, layer.SizingMargins, Alignment.TopRight), GetSourceArea(imageSize, partSize, layer.SizingMargins, Alignment.TopRight, index), color);
 | 
			
		||||
            Draw(layer.Image.Resource, GetDestinationArea(rect, layer.SizingMargins, Alignment.MiddleLeft), GetSourceArea(imageSize, partSize, layer.SizingMargins, Alignment.MiddleLeft, index), color);
 | 
			
		||||
            Draw(layer.Image.Resource, GetDestinationArea(rect, layer.SizingMargins, Alignment.MiddleCenter), GetSourceArea(imageSize, partSize, layer.SizingMargins, Alignment.MiddleCenter, index), color);
 | 
			
		||||
            Draw(layer.Image.Resource, GetDestinationArea(rect, layer.SizingMargins, Alignment.MiddleRight), GetSourceArea(imageSize, partSize, layer.SizingMargins, Alignment.MiddleRight, index), color);
 | 
			
		||||
            Draw(layer.Image.Resource, GetDestinationArea(rect, layer.SizingMargins, Alignment.BottomLeft), GetSourceArea(imageSize, partSize, layer.SizingMargins, Alignment.BottomLeft, index), color);
 | 
			
		||||
            Draw(layer.Image.Resource, GetDestinationArea(rect, layer.SizingMargins, Alignment.BottomCenter), GetSourceArea(imageSize, partSize, layer.SizingMargins, Alignment.BottomCenter, index), color);
 | 
			
		||||
            Draw(layer.Image.Resource, GetDestinationArea(rect, layer.SizingMargins, Alignment.BottomRight), GetSourceArea(imageSize, partSize, layer.SizingMargins, Alignment.BottomRight, index), color);
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        private static Rectangle GetSourceArea(Size imageSize, Size partSize, Margins margins, Alignment alignment, int index)
 | 
			
		||||
        {
 | 
			
		||||
            Rectangle rect = new Rectangle();
 | 
			
		||||
            int xc = (int)((float)imageSize.Width / partSize.Width);
 | 
			
		||||
            int yc = (int)((float)imageSize.Height / partSize.Height);
 | 
			
		||||
 | 
			
		||||
            int xm = (index) % xc;
 | 
			
		||||
            int ym = (index) / xc;
 | 
			
		||||
 | 
			
		||||
            int adj = 1;
 | 
			
		||||
            margins.Left += margins.Left > 0 ? adj : 0;
 | 
			
		||||
            margins.Top += margins.Top > 0 ? adj : 0;
 | 
			
		||||
            margins.Right += margins.Right > 0 ? adj : 0;
 | 
			
		||||
            margins.Bottom += margins.Bottom > 0 ? adj : 0;
 | 
			
		||||
 | 
			
		||||
            margins = new Margins(margins.Left, margins.Top, margins.Right, margins.Bottom);
 | 
			
		||||
            switch (alignment)
 | 
			
		||||
            {
 | 
			
		||||
                case Alignment.TopLeft:
 | 
			
		||||
                    {
 | 
			
		||||
                        rect = new Rectangle((0 + (xm * partSize.Width)),
 | 
			
		||||
                                             (0 + (ym * partSize.Height)),
 | 
			
		||||
                                             margins.Left,
 | 
			
		||||
                                             margins.Top);
 | 
			
		||||
                        break;
 | 
			
		||||
                    }
 | 
			
		||||
                case Alignment.TopCenter:
 | 
			
		||||
                    {
 | 
			
		||||
                        rect = new Rectangle((0 + (xm * partSize.Width)) + margins.Left,
 | 
			
		||||
                                             (0 + (ym * partSize.Height)),
 | 
			
		||||
                                             partSize.Width - margins.Left - margins.Right,
 | 
			
		||||
                                             margins.Top);
 | 
			
		||||
                        break;
 | 
			
		||||
                    }
 | 
			
		||||
                case Alignment.TopRight:
 | 
			
		||||
                    {
 | 
			
		||||
                        rect = new Rectangle((partSize.Width + (xm * partSize.Width)) - margins.Right,
 | 
			
		||||
                                             (0 + (ym * partSize.Height)),
 | 
			
		||||
                                             margins.Right,
 | 
			
		||||
                                             margins.Top);
 | 
			
		||||
                        break;
 | 
			
		||||
                    }
 | 
			
		||||
                case Alignment.MiddleLeft:
 | 
			
		||||
                    {
 | 
			
		||||
                        rect = new Rectangle((0 + (xm * partSize.Width)),
 | 
			
		||||
                                             (0 + (ym * partSize.Height)) + margins.Top,
 | 
			
		||||
                                             margins.Left,
 | 
			
		||||
                                             partSize.Height - margins.Top - margins.Bottom);
 | 
			
		||||
                        break;
 | 
			
		||||
                    }
 | 
			
		||||
                case Alignment.MiddleCenter:
 | 
			
		||||
                    {
 | 
			
		||||
                        rect = new Rectangle((0 + (xm * partSize.Width)) + margins.Left,
 | 
			
		||||
                                             (0 + (ym * partSize.Height)) + margins.Top,
 | 
			
		||||
                                             partSize.Width - margins.Left - margins.Right,
 | 
			
		||||
                                             partSize.Height - margins.Top - margins.Bottom);
 | 
			
		||||
                        break;
 | 
			
		||||
                    }
 | 
			
		||||
                case Alignment.MiddleRight:
 | 
			
		||||
                    {
 | 
			
		||||
                        rect = new Rectangle((partSize.Width + (xm * partSize.Width)) - margins.Right,
 | 
			
		||||
                                             (0 + (ym * partSize.Height)) + margins.Top,
 | 
			
		||||
                                             margins.Right,
 | 
			
		||||
                                             partSize.Height - margins.Top - margins.Bottom);
 | 
			
		||||
                        break;
 | 
			
		||||
                    }
 | 
			
		||||
                case Alignment.BottomLeft:
 | 
			
		||||
                    {
 | 
			
		||||
                        rect = new Rectangle((0 + (xm * partSize.Width)),
 | 
			
		||||
                                             (partSize.Height + (ym * partSize.Height)) - margins.Bottom,
 | 
			
		||||
                                             margins.Left,
 | 
			
		||||
                                             margins.Bottom);
 | 
			
		||||
                        break;
 | 
			
		||||
                    }
 | 
			
		||||
                case Alignment.BottomCenter:
 | 
			
		||||
                    {
 | 
			
		||||
                        rect = new Rectangle((0 + (xm * partSize.Width)) + margins.Left,
 | 
			
		||||
                                             (partSize.Height + (ym * partSize.Height)) - margins.Bottom,
 | 
			
		||||
                                             partSize.Width - margins.Left - margins.Right,
 | 
			
		||||
                                             margins.Bottom);
 | 
			
		||||
                        break;
 | 
			
		||||
                    }
 | 
			
		||||
                case Alignment.BottomRight:
 | 
			
		||||
                    {
 | 
			
		||||
                        rect = new Rectangle((partSize.Width + (xm * partSize.Width)) - margins.Right,
 | 
			
		||||
                                             (partSize.Height + (ym * partSize.Height)) - margins.Bottom,
 | 
			
		||||
                                             margins.Right,
 | 
			
		||||
                                             margins.Bottom);
 | 
			
		||||
                        break;
 | 
			
		||||
                    }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return rect;
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        public static Rectangle GetDestinationArea(Rectangle area, Margins margins, Alignment alignment)
 | 
			
		||||
        {
 | 
			
		||||
            Rectangle rect = new Rectangle();
 | 
			
		||||
 | 
			
		||||
            int adj = 1;
 | 
			
		||||
            margins.Left += margins.Left > 0 ? adj : 0;
 | 
			
		||||
            margins.Top += margins.Top > 0 ? adj : 0;
 | 
			
		||||
            margins.Right += margins.Right > 0 ? adj : 0;
 | 
			
		||||
            margins.Bottom += margins.Bottom > 0 ? adj : 0;
 | 
			
		||||
 | 
			
		||||
            margins = new Margins(margins.Left, margins.Top, margins.Right, margins.Bottom);
 | 
			
		||||
 | 
			
		||||
            switch (alignment)
 | 
			
		||||
            {
 | 
			
		||||
                case Alignment.TopLeft:
 | 
			
		||||
                    {
 | 
			
		||||
                        rect = new Rectangle(area.Left + 0,
 | 
			
		||||
                                             area.Top + 0,
 | 
			
		||||
                                             margins.Left,
 | 
			
		||||
                                             margins.Top);
 | 
			
		||||
                        break;
 | 
			
		||||
 | 
			
		||||
                    }
 | 
			
		||||
                case Alignment.TopCenter:
 | 
			
		||||
                    {
 | 
			
		||||
                        rect = new Rectangle(area.Left + margins.Left,
 | 
			
		||||
                                             area.Top + 0,
 | 
			
		||||
                                             area.Width - margins.Left - margins.Right,
 | 
			
		||||
                                             margins.Top);
 | 
			
		||||
                        break;
 | 
			
		||||
 | 
			
		||||
                    }
 | 
			
		||||
                case Alignment.TopRight:
 | 
			
		||||
                    {
 | 
			
		||||
                        rect = new Rectangle(area.Left + area.Width - margins.Right,
 | 
			
		||||
                                             area.Top + 0,
 | 
			
		||||
                                             margins.Right,
 | 
			
		||||
                                             margins.Top);
 | 
			
		||||
                        break;
 | 
			
		||||
 | 
			
		||||
                    }
 | 
			
		||||
                case Alignment.MiddleLeft:
 | 
			
		||||
                    {
 | 
			
		||||
                        rect = new Rectangle(area.Left + 0,
 | 
			
		||||
                                             area.Top + margins.Top,
 | 
			
		||||
                                             margins.Left,
 | 
			
		||||
                                             area.Height - margins.Top - margins.Bottom);
 | 
			
		||||
                        break;
 | 
			
		||||
                    }
 | 
			
		||||
                case Alignment.MiddleCenter:
 | 
			
		||||
                    {
 | 
			
		||||
                        rect = new Rectangle(area.Left + margins.Left,
 | 
			
		||||
                                             area.Top + margins.Top,
 | 
			
		||||
                                             area.Width - margins.Left - margins.Right,
 | 
			
		||||
                                             area.Height - margins.Top - margins.Bottom);
 | 
			
		||||
                        break;
 | 
			
		||||
                    }
 | 
			
		||||
                case Alignment.MiddleRight:
 | 
			
		||||
                    {
 | 
			
		||||
                        rect = new Rectangle(area.Left + area.Width - margins.Right,
 | 
			
		||||
                                             area.Top + margins.Top,
 | 
			
		||||
                                             margins.Right,
 | 
			
		||||
                                             area.Height - margins.Top - margins.Bottom);
 | 
			
		||||
                        break;
 | 
			
		||||
                    }
 | 
			
		||||
                case Alignment.BottomLeft:
 | 
			
		||||
                    {
 | 
			
		||||
                        rect = new Rectangle(area.Left + 0,
 | 
			
		||||
                                             area.Top + area.Height - margins.Bottom,
 | 
			
		||||
                                             margins.Left,
 | 
			
		||||
                                             margins.Bottom);
 | 
			
		||||
                        break;
 | 
			
		||||
                    }
 | 
			
		||||
                case Alignment.BottomCenter:
 | 
			
		||||
                    {
 | 
			
		||||
                        rect = new Rectangle(area.Left + margins.Left,
 | 
			
		||||
                                             area.Top + area.Height - margins.Bottom,
 | 
			
		||||
                                             area.Width - margins.Left - margins.Right,
 | 
			
		||||
                                             margins.Bottom);
 | 
			
		||||
                        break;
 | 
			
		||||
                    }
 | 
			
		||||
                case Alignment.BottomRight:
 | 
			
		||||
                    {
 | 
			
		||||
                        rect = new Rectangle(area.Left + area.Width - margins.Right,
 | 
			
		||||
                                             area.Top + area.Height - margins.Bottom,
 | 
			
		||||
                                             margins.Right,
 | 
			
		||||
                                             margins.Bottom);
 | 
			
		||||
                        break;
 | 
			
		||||
                    }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return rect;
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        public void DrawGlyph(Glyph glyph, Rectangle rect)
 | 
			
		||||
        {
 | 
			
		||||
            Size imageSize = new Size(glyph.Image.Width, glyph.Image.Height);
 | 
			
		||||
 | 
			
		||||
            if (!glyph.SourceRect.IsEmpty)
 | 
			
		||||
            {
 | 
			
		||||
                imageSize = new Size(glyph.SourceRect.Width, glyph.SourceRect.Height);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (glyph.SizeMode == SizeMode.Centered)
 | 
			
		||||
            {
 | 
			
		||||
                rect = new Rectangle((rect.X + (rect.Width - imageSize.Width) / 2) + glyph.Offset.X,
 | 
			
		||||
                                     (rect.Y + (rect.Height - imageSize.Height) / 2) + glyph.Offset.Y,
 | 
			
		||||
                                     imageSize.Width,
 | 
			
		||||
                                     imageSize.Height);
 | 
			
		||||
            }
 | 
			
		||||
            else if (glyph.SizeMode == SizeMode.Normal)
 | 
			
		||||
            {
 | 
			
		||||
                rect = new Rectangle(rect.X + glyph.Offset.X, rect.Y + glyph.Offset.Y, imageSize.Width, imageSize.Height);
 | 
			
		||||
            }
 | 
			
		||||
            else if (glyph.SizeMode == SizeMode.Auto)
 | 
			
		||||
            {
 | 
			
		||||
                rect = new Rectangle(rect.X + glyph.Offset.X, rect.Y + glyph.Offset.Y, imageSize.Width, imageSize.Height);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (glyph.SourceRect.IsEmpty)
 | 
			
		||||
            {
 | 
			
		||||
                Draw(glyph.Image, rect, glyph.Color);
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                Draw(glyph.Image, rect, glyph.SourceRect, glyph.Color);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        public virtual void DrawLayer(Control control, SkinLayer layer, Rectangle rect)
 | 
			
		||||
        {
 | 
			
		||||
            DrawLayer(control, layer, rect, control.ControlState);
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
        public virtual void DrawLayer(Control control, SkinLayer layer, Rectangle rect, ControlState state)
 | 
			
		||||
        {
 | 
			
		||||
            Color c = Color.White;
 | 
			
		||||
            Color oc = Color.White;
 | 
			
		||||
            int i = 0;
 | 
			
		||||
            int oi = -1;
 | 
			
		||||
            SkinLayer l = layer;
 | 
			
		||||
 | 
			
		||||
            if (state == ControlState.Hovered && (layer.States.Hovered.Index != -1))
 | 
			
		||||
            {
 | 
			
		||||
                c = l.States.Hovered.Color;
 | 
			
		||||
                i = l.States.Hovered.Index;
 | 
			
		||||
 | 
			
		||||
                if (l.States.Hovered.Overlay)
 | 
			
		||||
                {
 | 
			
		||||
                    oc = l.Overlays.Hovered.Color;
 | 
			
		||||
                    oi = l.Overlays.Hovered.Index;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            else if (state == ControlState.Focused || (control.Focused && state == ControlState.Hovered && layer.States.Hovered.Index == -1))
 | 
			
		||||
            {
 | 
			
		||||
                c = l.States.Focused.Color;
 | 
			
		||||
                i = l.States.Focused.Index;
 | 
			
		||||
 | 
			
		||||
                if (l.States.Focused.Overlay)
 | 
			
		||||
                {
 | 
			
		||||
                    oc = l.Overlays.Focused.Color;
 | 
			
		||||
                    oi = l.Overlays.Focused.Index;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            else if (state == ControlState.Pressed)
 | 
			
		||||
            {
 | 
			
		||||
                c = l.States.Pressed.Color;
 | 
			
		||||
                i = l.States.Pressed.Index;
 | 
			
		||||
 | 
			
		||||
                if (l.States.Pressed.Overlay)
 | 
			
		||||
                {
 | 
			
		||||
                    oc = l.Overlays.Pressed.Color;
 | 
			
		||||
                    oi = l.Overlays.Pressed.Index;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            else if (state == ControlState.Disabled)
 | 
			
		||||
            {
 | 
			
		||||
                c = l.States.Disabled.Color;
 | 
			
		||||
                i = l.States.Disabled.Index;
 | 
			
		||||
 | 
			
		||||
                if (l.States.Disabled.Overlay)
 | 
			
		||||
                {
 | 
			
		||||
                    oc = l.Overlays.Disabled.Color;
 | 
			
		||||
                    oi = l.Overlays.Disabled.Index;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                c = l.States.Enabled.Color;
 | 
			
		||||
                i = l.States.Enabled.Index;
 | 
			
		||||
 | 
			
		||||
                if (l.States.Enabled.Overlay)
 | 
			
		||||
                {
 | 
			
		||||
                    oc = l.Overlays.Enabled.Color;
 | 
			
		||||
                    oi = l.Overlays.Enabled.Index;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (control.Color != Control.UndefinedColor) c = control.Color * (control.Color.A / 255f);
 | 
			
		||||
            DrawLayer(l, rect, c, i);
 | 
			
		||||
 | 
			
		||||
            if (oi != -1)
 | 
			
		||||
            {
 | 
			
		||||
                DrawLayer(l, rect, oc, oi);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,493 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: ScrollBar.cs                                 //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
using System;
 | 
			
		||||
using Microsoft.Xna.Framework;
 | 
			
		||||
using Microsoft.Xna.Framework.Graphics;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
  public class ScrollBar: Control
 | 
			
		||||
  {
 | 
			
		||||
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////          
 | 
			
		||||
    private int range = 100;
 | 
			
		||||
    private int value = 0;
 | 
			
		||||
    private int pageSize = 50;
 | 
			
		||||
    private int stepSize = 1;   
 | 
			
		||||
    private Orientation orientation = Orientation.Vertical;   
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////          
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////          
 | 
			
		||||
    private Button btnMinus = null;
 | 
			
		||||
    private Button btnPlus = null;
 | 
			
		||||
    private Button btnSlider = null;
 | 
			
		||||
 | 
			
		||||
    private string strButton = "ScrollBar.ButtonVert";
 | 
			
		||||
    private string strRail = "ScrollBar.RailVert";
 | 
			
		||||
    private string strSlider = "ScrollBar.SliderVert";
 | 
			
		||||
    private string strGlyph = "ScrollBar.GlyphVert";
 | 
			
		||||
    private string strMinus = "ScrollBar.ArrowUp";
 | 
			
		||||
    private string strPlus = "ScrollBar.ArrowDown";    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Properties ////////
 | 
			
		||||
  
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
    public virtual int Value
 | 
			
		||||
    {
 | 
			
		||||
      get { return this.value; }
 | 
			
		||||
      set 
 | 
			
		||||
      { 
 | 
			
		||||
        if (this.value != value)
 | 
			
		||||
        {
 | 
			
		||||
          this.value = value;  
 | 
			
		||||
          if (this.value < 0) this.value = 0;
 | 
			
		||||
          if (this.value > range - pageSize) this.value = range - pageSize;
 | 
			
		||||
          Invalidate();
 | 
			
		||||
          if (!Suspended) OnValueChanged(new EventArgs());
 | 
			
		||||
        }  
 | 
			
		||||
      }      
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
    public virtual int Range
 | 
			
		||||
    {
 | 
			
		||||
      get { return range; }
 | 
			
		||||
      set 
 | 
			
		||||
      { 
 | 
			
		||||
        if (range != value)
 | 
			
		||||
        {
 | 
			
		||||
          range = value;
 | 
			
		||||
          if (pageSize > range) pageSize = range;
 | 
			
		||||
          RecalcParams();
 | 
			
		||||
          if (!Suspended) OnRangeChanged(new EventArgs());
 | 
			
		||||
        }  
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
    public virtual int PageSize
 | 
			
		||||
    {
 | 
			
		||||
      get { return pageSize; }
 | 
			
		||||
      set 
 | 
			
		||||
      { 
 | 
			
		||||
        if (pageSize !=  value)
 | 
			
		||||
        {
 | 
			
		||||
          pageSize = value;        
 | 
			
		||||
          if (pageSize > range) pageSize = range;
 | 
			
		||||
          RecalcParams();
 | 
			
		||||
          if (!Suspended) OnPageSizeChanged(new EventArgs());                   
 | 
			
		||||
        }  
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
    public virtual int StepSize
 | 
			
		||||
    {
 | 
			
		||||
      get { return stepSize; }
 | 
			
		||||
      set
 | 
			
		||||
      { 
 | 
			
		||||
        if (stepSize != value)
 | 
			
		||||
        {
 | 
			
		||||
          stepSize = value;
 | 
			
		||||
          if (!Suspended) OnStepSizeChanged(new EventArgs());                   
 | 
			
		||||
        }  
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Events ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////            
 | 
			
		||||
    public event EventHandler ValueChanged;
 | 
			
		||||
    public event EventHandler RangeChanged;
 | 
			
		||||
    public event EventHandler StepSizeChanged;
 | 
			
		||||
    public event EventHandler PageSizeChanged;
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Construstors //////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////       
 | 
			
		||||
    public ScrollBar(Manager manager, Orientation orientation): base(manager)
 | 
			
		||||
    {
 | 
			
		||||
      this.orientation = orientation;
 | 
			
		||||
      CanFocus = false;     
 | 
			
		||||
           
 | 
			
		||||
 | 
			
		||||
      if (orientation == Orientation.Horizontal)
 | 
			
		||||
      {
 | 
			
		||||
        strButton = "ScrollBar.ButtonHorz";
 | 
			
		||||
        strRail = "ScrollBar.RailHorz";
 | 
			
		||||
        strSlider = "ScrollBar.SliderHorz";
 | 
			
		||||
        strGlyph = "ScrollBar.GlyphHorz";
 | 
			
		||||
        strMinus = "ScrollBar.ArrowLeft";
 | 
			
		||||
        strPlus = "ScrollBar.ArrowRight";
 | 
			
		||||
 | 
			
		||||
        MinimumHeight = 16;
 | 
			
		||||
        MinimumWidth = 46;
 | 
			
		||||
        Width = 64;
 | 
			
		||||
        Height = 16;        
 | 
			
		||||
      }
 | 
			
		||||
      else
 | 
			
		||||
      {
 | 
			
		||||
        strButton = "ScrollBar.ButtonVert";
 | 
			
		||||
        strRail = "ScrollBar.RailVert";
 | 
			
		||||
        strSlider = "ScrollBar.SliderVert";
 | 
			
		||||
        strGlyph = "ScrollBar.GlyphVert";
 | 
			
		||||
        strMinus = "ScrollBar.ArrowUp";
 | 
			
		||||
        strPlus = "ScrollBar.ArrowDown";
 | 
			
		||||
 | 
			
		||||
        MinimumHeight = 46;
 | 
			
		||||
        MinimumWidth = 16;
 | 
			
		||||
        Width = 16;
 | 
			
		||||
        Height = 64;        
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      btnMinus = new Button(Manager);
 | 
			
		||||
      btnMinus.Init();
 | 
			
		||||
      btnMinus.Text = "";
 | 
			
		||||
      btnMinus.MousePress += new MouseEventHandler(ArrowPress);
 | 
			
		||||
      btnMinus.CanFocus = false;
 | 
			
		||||
 | 
			
		||||
      btnSlider = new Button(Manager);
 | 
			
		||||
      btnSlider.Init();
 | 
			
		||||
      btnSlider.Text = "";
 | 
			
		||||
      btnSlider.CanFocus = false;
 | 
			
		||||
      btnSlider.MinimumHeight = 16;
 | 
			
		||||
      btnSlider.MinimumWidth = 16;      
 | 
			
		||||
 | 
			
		||||
      btnPlus = new Button(Manager);
 | 
			
		||||
      btnPlus.Init();
 | 
			
		||||
      btnPlus.Text = "";
 | 
			
		||||
      btnPlus.MousePress += new MouseEventHandler(ArrowPress);
 | 
			
		||||
      btnPlus.CanFocus = false;
 | 
			
		||||
 | 
			
		||||
      btnSlider.Move += new MoveEventHandler(btnSlider_Move);
 | 
			
		||||
 | 
			
		||||
      Add(btnMinus);
 | 
			
		||||
      Add(btnSlider);
 | 
			
		||||
      Add(btnPlus);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Methods ///////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    public void ScrollUp()
 | 
			
		||||
    {
 | 
			
		||||
        Value -= stepSize;
 | 
			
		||||
        if (Value < 0) Value = 0;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
    public void ScrollDown()
 | 
			
		||||
    {
 | 
			
		||||
        Value += stepSize;
 | 
			
		||||
        if (Value > range - pageSize) Value = range - pageSize - 1;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
    public void ScrollUp(bool alot)
 | 
			
		||||
    {
 | 
			
		||||
        if (alot)
 | 
			
		||||
        {
 | 
			
		||||
            Value -= pageSize;
 | 
			
		||||
            if (Value < 0) Value = 0;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
            ScrollUp();
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
    public void ScrollDown(bool alot)
 | 
			
		||||
    {
 | 
			
		||||
        if (alot)
 | 
			
		||||
        {
 | 
			
		||||
            Value += pageSize;
 | 
			
		||||
            if (Value > range - pageSize) Value = range - pageSize - 1;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
            ScrollDown();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
    public override void Init()
 | 
			
		||||
    {
 | 
			
		||||
      base.Init();    
 | 
			
		||||
   
 | 
			
		||||
      SkinControl sc = new SkinControl(btnPlus.Skin);
 | 
			
		||||
      sc.Layers["Control"] = new SkinLayer(Skin.Layers[strButton]);
 | 
			
		||||
      sc.Layers[strButton].Name = "Control";
 | 
			
		||||
      btnPlus.Skin = btnMinus.Skin = sc;   
 | 
			
		||||
 | 
			
		||||
      SkinControl ss = new SkinControl(btnSlider.Skin);
 | 
			
		||||
      ss.Layers["Control"] = new SkinLayer(Skin.Layers[strSlider]);
 | 
			
		||||
      ss.Layers[strSlider].Name = "Control";      
 | 
			
		||||
      btnSlider.Skin = ss;      
 | 
			
		||||
   
 | 
			
		||||
      btnMinus.Glyph = new Glyph(Skin.Layers[strMinus].Image.Resource);
 | 
			
		||||
      btnMinus.Glyph.SizeMode = SizeMode.Centered;
 | 
			
		||||
      btnMinus.Glyph.Color = Manager.Skin.Controls["Button"].Layers["Control"].Text.Colors.Enabled;
 | 
			
		||||
   
 | 
			
		||||
      btnPlus.Glyph = new Glyph(Skin.Layers[strPlus].Image.Resource);
 | 
			
		||||
      btnPlus.Glyph.SizeMode = SizeMode.Centered;
 | 
			
		||||
      btnPlus.Glyph.Color = Manager.Skin.Controls["Button"].Layers["Control"].Text.Colors.Enabled;
 | 
			
		||||
   
 | 
			
		||||
      btnSlider.Glyph = new Glyph(Skin.Layers[strGlyph].Image.Resource);
 | 
			
		||||
      btnSlider.Glyph.SizeMode = SizeMode.Centered;      
 | 
			
		||||
   
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////        
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
    protected internal override void InitSkin()
 | 
			
		||||
    {
 | 
			
		||||
      base.InitSkin();
 | 
			
		||||
      Skin = new SkinControl(Manager.Skin.Controls["ScrollBar"]);
 | 
			
		||||
    }      
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////       
 | 
			
		||||
           
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
    protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
 | 
			
		||||
    {      
 | 
			
		||||
      RecalcParams();                        
 | 
			
		||||
     
 | 
			
		||||
      SkinLayer bg = Skin.Layers[strRail];      
 | 
			
		||||
      renderer.DrawLayer(bg, rect, Color.White, bg.States.Enabled.Index);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    void ArrowPress(object sender, MouseEventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      if (e.Button == MouseButton.Left)
 | 
			
		||||
      {
 | 
			
		||||
        if (sender == btnMinus)
 | 
			
		||||
        {
 | 
			
		||||
            ScrollUp();
 | 
			
		||||
        }
 | 
			
		||||
        else if (sender == btnPlus)
 | 
			
		||||
        {
 | 
			
		||||
            ScrollDown();
 | 
			
		||||
        }       
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    protected override void OnResize(ResizeEventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      base.OnResize(e);     
 | 
			
		||||
      RecalcParams();
 | 
			
		||||
      if (Value + PageSize > Range) Value = Range - PageSize;              
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    private void RecalcParams()
 | 
			
		||||
    {      
 | 
			
		||||
      if (btnMinus != null && btnPlus != null && btnSlider != null)
 | 
			
		||||
      {    
 | 
			
		||||
        if (orientation == Orientation.Horizontal)
 | 
			
		||||
        {
 | 
			
		||||
          btnMinus.Width = Height;
 | 
			
		||||
          btnMinus.Height = Height;        
 | 
			
		||||
 | 
			
		||||
          btnPlus.Width = Height;
 | 
			
		||||
          btnPlus.Height = Height;
 | 
			
		||||
          btnPlus.Left = Width - Height;        
 | 
			
		||||
          btnPlus.Top = 0;        
 | 
			
		||||
                  
 | 
			
		||||
          btnSlider.Movable = true;        
 | 
			
		||||
          int size = btnMinus.Width + Skin.Layers[strSlider].OffsetX;
 | 
			
		||||
 | 
			
		||||
          btnSlider.MinimumWidth = Height;
 | 
			
		||||
          int w = (Width - 2 * size);
 | 
			
		||||
          btnSlider.Width = (int)Math.Ceiling((pageSize * w) / (float)range);
 | 
			
		||||
          btnSlider.Height = Height;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
          float px = (float)(Range - PageSize) / (float)(w - btnSlider.Width);
 | 
			
		||||
          int pos = (int)(Math.Ceiling(Value / (float)px));
 | 
			
		||||
          btnSlider.SetPosition(size + pos, 0);
 | 
			
		||||
          if (btnSlider.Left < size) btnSlider.SetPosition(size, 0);
 | 
			
		||||
          if (btnSlider.Left + btnSlider.Width + size > Width) btnSlider.SetPosition(Width - size - btnSlider.Width, 0);                    
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {        
 | 
			
		||||
          btnMinus.Width = Width;
 | 
			
		||||
          btnMinus.Height = Width;                
 | 
			
		||||
 | 
			
		||||
          btnPlus.Width = Width;
 | 
			
		||||
          btnPlus.Height = Width;
 | 
			
		||||
          btnPlus.Top = Height - Width;
 | 
			
		||||
 | 
			
		||||
          btnSlider.Movable = true;
 | 
			
		||||
          int size = btnMinus.Height + Skin.Layers[strSlider].OffsetY;
 | 
			
		||||
 | 
			
		||||
          btnSlider.MinimumHeight = Width;
 | 
			
		||||
          int h = (Height - 2 * size);
 | 
			
		||||
          btnSlider.Height = (int)Math.Ceiling((pageSize * h) / (float)range);
 | 
			
		||||
          btnSlider.Width = Width;               
 | 
			
		||||
 | 
			
		||||
          float px = (float)(Range - PageSize) / (float)(h - btnSlider.Height);
 | 
			
		||||
          int pos = (int)(Math.Ceiling(Value / (float)px));          
 | 
			
		||||
          btnSlider.SetPosition(0, size + pos);          
 | 
			
		||||
          if (btnSlider.Top < size) btnSlider.SetPosition(0, size);
 | 
			
		||||
          if (btnSlider.Top + btnSlider.Height + size > Height) btnSlider.SetPosition(0, Height - size - btnSlider.Height);
 | 
			
		||||
        }                
 | 
			
		||||
      }      
 | 
			
		||||
    }       
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    void btnSlider_Move(object sender, MoveEventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      if (orientation == Orientation.Horizontal)
 | 
			
		||||
      {
 | 
			
		||||
        int size = btnMinus.Width + Skin.Layers[strSlider].OffsetX;
 | 
			
		||||
        btnSlider.SetPosition(e.Left, 0);
 | 
			
		||||
        if (btnSlider.Left < size) btnSlider.SetPosition(size, 0);
 | 
			
		||||
        if (btnSlider.Left + btnSlider.Width + size > Width) btnSlider.SetPosition(Width - size - btnSlider.Width, 0);
 | 
			
		||||
      }
 | 
			
		||||
      else
 | 
			
		||||
      {                                    
 | 
			
		||||
        int size = btnMinus.Height + Skin.Layers[strSlider].OffsetY;         
 | 
			
		||||
        btnSlider.SetPosition(0, e.Top);
 | 
			
		||||
        if (btnSlider.Top < size) btnSlider.SetPosition(0, size);         
 | 
			
		||||
        if (btnSlider.Top + btnSlider.Height + size > Height) btnSlider.SetPosition(0, Height - size - btnSlider.Height);                
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if (orientation == Orientation.Horizontal)
 | 
			
		||||
      {
 | 
			
		||||
        int size = btnMinus.Width + Skin.Layers[strSlider].OffsetX;
 | 
			
		||||
        int w = (Width - 2 * size) - btnSlider.Width;
 | 
			
		||||
        float px = (float)(Range - PageSize) / (float)w;
 | 
			
		||||
        Value = (int)(Math.Ceiling((btnSlider.Left - size) * px));                                        
 | 
			
		||||
      }
 | 
			
		||||
      else
 | 
			
		||||
      {
 | 
			
		||||
        int size = btnMinus.Height + Skin.Layers[strSlider].OffsetY;
 | 
			
		||||
        int h = (Height - 2 * size) - btnSlider.Height;        
 | 
			
		||||
        float px = (float)(Range - PageSize) / (float)h;
 | 
			
		||||
        Value = (int)(Math.Ceiling((btnSlider.Top - size) * px));
 | 
			
		||||
      } 
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////        
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////        
 | 
			
		||||
    protected override void OnMouseUp(MouseEventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      btnSlider.Passive = false;  
 | 
			
		||||
      base.OnMouseUp(e);       
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////        
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////        
 | 
			
		||||
    protected override void OnMouseDown(MouseEventArgs e)
 | 
			
		||||
    {      
 | 
			
		||||
      base.OnMouseDown(e);            
 | 
			
		||||
      
 | 
			
		||||
      btnSlider.Passive = true;            
 | 
			
		||||
      
 | 
			
		||||
      if (e.Button == MouseButton.Left)
 | 
			
		||||
      {
 | 
			
		||||
        if (orientation == Orientation.Horizontal)
 | 
			
		||||
        {
 | 
			
		||||
          int pos = e.Position.X;
 | 
			
		||||
          
 | 
			
		||||
          if (pos < btnSlider.Left)
 | 
			
		||||
          {
 | 
			
		||||
              ScrollUp(true);      
 | 
			
		||||
          }
 | 
			
		||||
          else if (pos >= btnSlider.Left + btnSlider.Width)
 | 
			
		||||
          {
 | 
			
		||||
              ScrollDown(true);
 | 
			
		||||
          } 
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
          int pos = e.Position.Y;
 | 
			
		||||
 | 
			
		||||
          if (pos < btnSlider.Top)
 | 
			
		||||
          {
 | 
			
		||||
              ScrollUp(true);
 | 
			
		||||
          }
 | 
			
		||||
          else if (pos >= btnSlider.Top + btnSlider.Height)
 | 
			
		||||
          {
 | 
			
		||||
              ScrollDown(true);
 | 
			
		||||
          }       
 | 
			
		||||
        }                               
 | 
			
		||||
      }  
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////        
 | 
			
		||||
    protected virtual void OnValueChanged(EventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      if (ValueChanged != null) ValueChanged.Invoke(this, e);            
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////        
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////        
 | 
			
		||||
    protected virtual void OnRangeChanged(EventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      if (RangeChanged != null) RangeChanged.Invoke(this, e);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////        
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////        
 | 
			
		||||
    protected virtual void OnPageSizeChanged(EventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      if (PageSizeChanged != null) PageSizeChanged.Invoke(this, e);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////        
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////        
 | 
			
		||||
    protected virtual void OnStepSizeChanged(EventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      if (StepSizeChanged != null) StepSizeChanged.Invoke(this, e);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////        
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,89 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: SideBar.cs                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
using Microsoft.Xna.Framework;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{ 
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  public class SideBar: Panel
 | 
			
		||||
  {
 | 
			
		||||
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                 
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Properties ////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Construstors //////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////       
 | 
			
		||||
    public SideBar(Manager manager): base(manager)
 | 
			
		||||
    {      
 | 
			
		||||
     // CanFocus = true;
 | 
			
		||||
    }    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
    
 | 
			
		||||
    #region //// Methods ///////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public override void Init()
 | 
			
		||||
    {      
 | 
			
		||||
      base.Init();  
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                          
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                          
 | 
			
		||||
    protected internal override void InitSkin()
 | 
			
		||||
    {
 | 
			
		||||
      base.InitSkin();
 | 
			
		||||
      Skin = new SkinControl(Manager.Skin.Controls["SideBar"]);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                          
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
 | 
			
		||||
    {          
 | 
			
		||||
      base.DrawControl(renderer, rect, gameTime);       
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
 | 
			
		||||
    #endregion  
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,77 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: SideBarPanel.cs                              //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
using Microsoft.Xna.Framework;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
using Microsoft.Xna.Framework.Graphics;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
  public class SideBarPanel: Container
 | 
			
		||||
  {
 | 
			
		||||
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////           
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Properties ////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Construstors //////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////       
 | 
			
		||||
    public SideBarPanel(Manager manager): base(manager)
 | 
			
		||||
    {     
 | 
			
		||||
      CanFocus = false;
 | 
			
		||||
      Passive = true;
 | 
			
		||||
      Width = 64;
 | 
			
		||||
      Height = 64;
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Methods ///////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
    public override void Init()
 | 
			
		||||
    {
 | 
			
		||||
      base.Init();      
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										1259
									
								
								Neoforce/Skin.cs
									
									
									
									
									
								
							
							
						
						
									
										1259
									
								
								Neoforce/Skin.cs
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -1,391 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: SpinBox.cs                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
using Microsoft.Xna.Framework;
 | 
			
		||||
using Microsoft.Xna.Framework.Input;
 | 
			
		||||
using Microsoft.Xna.Framework.Graphics;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
  #region //// Enums /////////////
 | 
			
		||||
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
  public enum SpinBoxMode
 | 
			
		||||
  {
 | 
			
		||||
    Range,
 | 
			
		||||
    List
 | 
			
		||||
  }
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
  #endregion
 | 
			
		||||
  
 | 
			
		||||
  public class SpinBox: TextBox
 | 
			
		||||
  {
 | 
			
		||||
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                 
 | 
			
		||||
    private Button btnUp = null;
 | 
			
		||||
    private Button btnDown = null;
 | 
			
		||||
    private SpinBoxMode mode = SpinBoxMode.List;
 | 
			
		||||
    private List<object> items = new List<object>();
 | 
			
		||||
    private float value = 0;
 | 
			
		||||
    private float minimum = 0;
 | 
			
		||||
    private float maximum = 100;
 | 
			
		||||
    private float step = 0.25f;
 | 
			
		||||
    private int rounding = 2;
 | 
			
		||||
    private int itemIndex = -1;    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Properties ////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public new virtual SpinBoxMode Mode
 | 
			
		||||
    {
 | 
			
		||||
      get { return mode; }
 | 
			
		||||
      set { mode = value; }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public override bool ReadOnly
 | 
			
		||||
    {
 | 
			
		||||
      get { return base.ReadOnly; }
 | 
			
		||||
      set
 | 
			
		||||
      {
 | 
			
		||||
        base.ReadOnly = value;
 | 
			
		||||
        CaretVisible = !value;
 | 
			
		||||
        if (value)
 | 
			
		||||
        {
 | 
			
		||||
          #if (!XBOX && !XBOX_FAKE)
 | 
			
		||||
            Cursor = Manager.Skin.Cursors["Default"].Resource;
 | 
			
		||||
          #endif
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
          #if (!XBOX && !XBOX_FAKE)
 | 
			
		||||
            Cursor = Manager.Skin.Cursors["Text"].Resource;
 | 
			
		||||
          #endif
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public virtual List<object> Items
 | 
			
		||||
    {
 | 
			
		||||
      get { return items; }      
 | 
			
		||||
    } 
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
    public float Value
 | 
			
		||||
    {
 | 
			
		||||
      get { return this.value; }
 | 
			
		||||
      set 
 | 
			
		||||
      { 
 | 
			
		||||
        if (this.value != value)
 | 
			
		||||
        {
 | 
			
		||||
          this.value = value; 
 | 
			
		||||
          Invalidate();
 | 
			
		||||
        }          
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public float Minimum
 | 
			
		||||
    {
 | 
			
		||||
      get { return minimum; }
 | 
			
		||||
      set 
 | 
			
		||||
      { 
 | 
			
		||||
        if (minimum != value)
 | 
			
		||||
        {
 | 
			
		||||
          minimum = value; 
 | 
			
		||||
        }  
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public float Maximum
 | 
			
		||||
    {
 | 
			
		||||
      get { return maximum; }
 | 
			
		||||
      set 
 | 
			
		||||
      { 
 | 
			
		||||
        if (maximum != value)
 | 
			
		||||
        {
 | 
			
		||||
          maximum = value; 
 | 
			
		||||
        }  
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public float Step
 | 
			
		||||
    {
 | 
			
		||||
      get { return step; }
 | 
			
		||||
      set 
 | 
			
		||||
      { 
 | 
			
		||||
        if (step != value)
 | 
			
		||||
        {
 | 
			
		||||
          step = value; 
 | 
			
		||||
        }          
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public int ItemIndex
 | 
			
		||||
    {
 | 
			
		||||
      get { return itemIndex; }
 | 
			
		||||
      set 
 | 
			
		||||
      { 
 | 
			
		||||
        if (mode == SpinBoxMode.List)
 | 
			
		||||
        {
 | 
			
		||||
          itemIndex = value;
 | 
			
		||||
          Text = items[itemIndex].ToString();         
 | 
			
		||||
        }  
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public int Rounding
 | 
			
		||||
    {
 | 
			
		||||
      get { return rounding; }
 | 
			
		||||
      set 
 | 
			
		||||
      { 
 | 
			
		||||
        if (rounding != value)
 | 
			
		||||
        {        
 | 
			
		||||
          rounding = value; 
 | 
			
		||||
          Invalidate();
 | 
			
		||||
        }  
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Construstors //////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////       
 | 
			
		||||
    public SpinBox(Manager manager, SpinBoxMode mode): base(manager)
 | 
			
		||||
    {         
 | 
			
		||||
      this.mode = mode;
 | 
			
		||||
      ReadOnly = true;      
 | 
			
		||||
      
 | 
			
		||||
      Height = 20;
 | 
			
		||||
      Width = 64;           
 | 
			
		||||
                     
 | 
			
		||||
      btnUp = new Button(Manager);
 | 
			
		||||
      btnUp.Init();    
 | 
			
		||||
      btnUp.CanFocus = false;
 | 
			
		||||
      btnUp.MousePress += new MouseEventHandler(btn_MousePress);
 | 
			
		||||
      Add(btnUp, false);
 | 
			
		||||
 | 
			
		||||
      btnDown = new Button(Manager);
 | 
			
		||||
      btnDown.Init();            
 | 
			
		||||
      btnDown.CanFocus = false;
 | 
			
		||||
      btnDown.MousePress += new MouseEventHandler(btn_MousePress);
 | 
			
		||||
      Add(btnDown, false);                  
 | 
			
		||||
      
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Methods ///////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public override void Init()
 | 
			
		||||
    {
 | 
			
		||||
      base.Init();      
 | 
			
		||||
 | 
			
		||||
      SkinControl sc = new SkinControl(btnUp.Skin);
 | 
			
		||||
      sc.Layers["Control"] = new SkinLayer(Skin.Layers["Button"]);
 | 
			
		||||
      sc.Layers["Button"].Name = "Control";
 | 
			
		||||
      btnUp.Skin = btnDown.Skin = sc;
 | 
			
		||||
 | 
			
		||||
      btnUp.Glyph = new Glyph(Manager.Skin.Images["Shared.ArrowUp"].Resource);
 | 
			
		||||
      btnUp.Glyph.SizeMode = SizeMode.Centered;
 | 
			
		||||
      btnUp.Glyph.Color = Manager.Skin.Controls["Button"].Layers["Control"].Text.Colors.Enabled;
 | 
			
		||||
 | 
			
		||||
      btnDown.Glyph = new Glyph(Manager.Skin.Images["Shared.ArrowDown"].Resource);
 | 
			
		||||
      btnDown.Glyph.SizeMode = SizeMode.Centered;
 | 
			
		||||
      btnDown.Glyph.Color = Manager.Skin.Controls["Button"].Layers["Control"].Text.Colors.Enabled;
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                          
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                          
 | 
			
		||||
    protected internal override void InitSkin()
 | 
			
		||||
    {
 | 
			
		||||
      base.InitSkin();
 | 
			
		||||
      Skin = new SkinControl(Manager.Skin.Controls["SpinBox"]);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                          
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
 | 
			
		||||
    {
 | 
			
		||||
      base.DrawControl(renderer, rect, gameTime);
 | 
			
		||||
 | 
			
		||||
      if (ReadOnly && Focused)
 | 
			
		||||
      {
 | 
			
		||||
        SkinLayer lr = Skin.Layers[0];
 | 
			
		||||
        Rectangle rc = new Rectangle(rect.Left + lr.ContentMargins.Left,
 | 
			
		||||
                                     rect.Top + lr.ContentMargins.Top,
 | 
			
		||||
                                     Width - lr.ContentMargins.Horizontal - btnDown.Width - btnUp.Width,
 | 
			
		||||
                                     Height - lr.ContentMargins.Vertical);
 | 
			
		||||
        renderer.Draw(Manager.Skin.Images["ListBox.Selection"].Resource, rc, Color.FromNonPremultiplied(255, 255, 255, 128));
 | 
			
		||||
      }    
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    protected override void OnResize(ResizeEventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      base.OnResize(e);
 | 
			
		||||
      
 | 
			
		||||
      if (btnUp != null)
 | 
			
		||||
      {
 | 
			
		||||
        btnUp.Width = 16;
 | 
			
		||||
        btnUp.Height = Height - Skin.Layers["Control"].ContentMargins.Vertical;
 | 
			
		||||
        btnUp.Top = Skin.Layers["Control"].ContentMargins.Top;
 | 
			
		||||
        btnUp.Left = Width - 16 - 2 - 16 - 1;
 | 
			
		||||
      }  
 | 
			
		||||
      if (btnDown != null)
 | 
			
		||||
      {
 | 
			
		||||
        btnDown.Width = 16;
 | 
			
		||||
        btnDown.Height = Height - Skin.Layers["Control"].ContentMargins.Vertical;
 | 
			
		||||
        btnDown.Top = Skin.Layers["Control"].ContentMargins.Top; ;
 | 
			
		||||
        btnDown.Left = Width - 16 - 2;            
 | 
			
		||||
      }  
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    private void ShiftIndex(bool direction)
 | 
			
		||||
    {
 | 
			
		||||
      if (mode == SpinBoxMode.List)
 | 
			
		||||
      {
 | 
			
		||||
        if (items.Count > 0)
 | 
			
		||||
        {
 | 
			
		||||
          if (direction)
 | 
			
		||||
          {
 | 
			
		||||
            itemIndex += 1;
 | 
			
		||||
          }
 | 
			
		||||
          else
 | 
			
		||||
          {
 | 
			
		||||
            itemIndex -= 1;
 | 
			
		||||
          }
 | 
			
		||||
 | 
			
		||||
          if (itemIndex < 0) itemIndex = 0;
 | 
			
		||||
          if (itemIndex > items.Count - 1) itemIndex = itemIndex = items.Count - 1;
 | 
			
		||||
 | 
			
		||||
          Text = items[itemIndex].ToString();
 | 
			
		||||
        }  
 | 
			
		||||
      }
 | 
			
		||||
      else
 | 
			
		||||
      {
 | 
			
		||||
        if (direction)
 | 
			
		||||
        {
 | 
			
		||||
          value += step;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
          value -= step;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (value < minimum) value = minimum;
 | 
			
		||||
        if (value > maximum) value = maximum;
 | 
			
		||||
 | 
			
		||||
        Text = value.ToString("n" + rounding.ToString());
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    private void btn_MousePress(object sender, MouseEventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      Focused = true;
 | 
			
		||||
      if (sender == btnUp) ShiftIndex(true);
 | 
			
		||||
      else if (sender == btnDown) ShiftIndex(false);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected override void OnKeyPress(KeyEventArgs e)
 | 
			
		||||
    {            
 | 
			
		||||
      if (e.Key == Keys.Up)
 | 
			
		||||
      {
 | 
			
		||||
        e.Handled = true;
 | 
			
		||||
        ShiftIndex(true);
 | 
			
		||||
      }        
 | 
			
		||||
      else if (e.Key == Keys.Down)
 | 
			
		||||
      {
 | 
			
		||||
        e.Handled = true;
 | 
			
		||||
        ShiftIndex(false);
 | 
			
		||||
      }
 | 
			
		||||
      
 | 
			
		||||
      base.OnKeyPress(e);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected override void OnGamePadPress(GamePadEventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      if (e.Button == GamePadActions.Up)
 | 
			
		||||
      {
 | 
			
		||||
        e.Handled = true;
 | 
			
		||||
        ShiftIndex(true);
 | 
			
		||||
      }
 | 
			
		||||
      else if (e.Button == GamePadActions.Down)
 | 
			
		||||
      {
 | 
			
		||||
        e.Handled = true;
 | 
			
		||||
        ShiftIndex(false);
 | 
			
		||||
      }
 | 
			
		||||
      
 | 
			
		||||
      base.OnGamePadPress(e);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected override void OnGamePadDown(GamePadEventArgs e)
 | 
			
		||||
    {      
 | 
			
		||||
      base.OnGamePadDown(e);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    #endregion  
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,160 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: StackPanel.cs                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
using Microsoft.Xna.Framework;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using Microsoft.Xna.Framework.Graphics;
 | 
			
		||||
using System;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{
 | 
			
		||||
  
 | 
			
		||||
  public class StackPanel: Container
 | 
			
		||||
  {
 | 
			
		||||
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
      private Orientation orientation;
 | 
			
		||||
      public Orientation Orientation
 | 
			
		||||
      {
 | 
			
		||||
          get { return this.orientation; }
 | 
			
		||||
          set
 | 
			
		||||
          {
 | 
			
		||||
              this.orientation = value;
 | 
			
		||||
              this.CalcLayout();
 | 
			
		||||
          }
 | 
			
		||||
      }
 | 
			
		||||
      private bool autoRefresh;
 | 
			
		||||
 | 
			
		||||
      /// <summary>
 | 
			
		||||
      /// Should the stack panel refresh itself, when a control is added
 | 
			
		||||
      /// </summary>
 | 
			
		||||
      public bool AutoRefresh
 | 
			
		||||
      {
 | 
			
		||||
          get { return autoRefresh; }
 | 
			
		||||
          set { autoRefresh = value; }
 | 
			
		||||
      }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
      private TimeSpan refreshTimer;
 | 
			
		||||
      private const int refreshTime = 300; //ms
 | 
			
		||||
    #endregion
 | 
			
		||||
   
 | 
			
		||||
    #region //// Constructors //////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public StackPanel(Manager manager, Orientation orientation): base(manager)
 | 
			
		||||
    {
 | 
			
		||||
      this.orientation = orientation;
 | 
			
		||||
      this.Color = Color.Transparent;
 | 
			
		||||
      this.autoRefresh = true;
 | 
			
		||||
      refreshTimer = new TimeSpan(0, 0, 0, 0, refreshTime);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion                    
 | 
			
		||||
        
 | 
			
		||||
    #region //// Methods ///////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    private void CalcLayout()
 | 
			
		||||
    {
 | 
			
		||||
      int top = Top;
 | 
			
		||||
      int left = Left;            
 | 
			
		||||
 | 
			
		||||
      foreach (Control c in ClientArea.Controls)
 | 
			
		||||
      {
 | 
			
		||||
        Margins m = c.Margins;
 | 
			
		||||
  
 | 
			
		||||
        if (orientation == Orientation.Vertical)
 | 
			
		||||
        {
 | 
			
		||||
          top += m.Top;
 | 
			
		||||
          c.Top = top;
 | 
			
		||||
          top += c.Height;
 | 
			
		||||
          top += m.Bottom;
 | 
			
		||||
          c.Left = left;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (orientation == Orientation.Horizontal)
 | 
			
		||||
        {
 | 
			
		||||
          left += m.Left;
 | 
			
		||||
          c.Left = left;
 | 
			
		||||
          left += c.Width;
 | 
			
		||||
          left += m.Right;
 | 
			
		||||
          c.Top = top;
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
 | 
			
		||||
    {      
 | 
			
		||||
      base.DrawControl(renderer, rect, gameTime);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected override void OnResize(ResizeEventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      CalcLayout();
 | 
			
		||||
      base.OnResize(e);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    protected internal override void Update(GameTime gameTime)
 | 
			
		||||
    {
 | 
			
		||||
        base.Update(gameTime);
 | 
			
		||||
 | 
			
		||||
        if (autoRefresh)
 | 
			
		||||
        {
 | 
			
		||||
            refreshTimer = refreshTimer.Subtract(TimeSpan.FromMilliseconds(gameTime.ElapsedGameTime.TotalMilliseconds));
 | 
			
		||||
            if (refreshTimer.TotalMilliseconds <= 0.00)
 | 
			
		||||
            {
 | 
			
		||||
                Refresh();
 | 
			
		||||
                refreshTimer = new TimeSpan(0, 0, 0, 0, refreshTime);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public override void Add(Control control)
 | 
			
		||||
    {
 | 
			
		||||
        base.Add(control);
 | 
			
		||||
        if (autoRefresh) Refresh();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public override void Add(Control control, bool client)
 | 
			
		||||
    {
 | 
			
		||||
        base.Add(control, client);
 | 
			
		||||
        if (autoRefresh) Refresh();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    #endregion
 | 
			
		||||
  
 | 
			
		||||
  }       
 | 
			
		||||
  
 | 
			
		||||
}
 | 
			
		||||
@@ -1,93 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: StatusBar.cs                                 //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
using Microsoft.Xna.Framework;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  public class StatusBar: Control
 | 
			
		||||
  {
 | 
			
		||||
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                 
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Properties ////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Construstors //////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////       
 | 
			
		||||
    public StatusBar(Manager manager): base(manager)
 | 
			
		||||
    {
 | 
			
		||||
      Left = 0;
 | 
			
		||||
      Top = 0;
 | 
			
		||||
      Width = 64;
 | 
			
		||||
      Height = 24;
 | 
			
		||||
      CanFocus = false;
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Methods ///////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public override void Init()
 | 
			
		||||
    {
 | 
			
		||||
      base.Init();
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                          
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                          
 | 
			
		||||
    protected internal override void InitSkin()
 | 
			
		||||
    {
 | 
			
		||||
      base.InitSkin();
 | 
			
		||||
      Skin = new SkinControl(Manager.Skin.Controls["StatusBar"]);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                          
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
 | 
			
		||||
    {
 | 
			
		||||
      base.DrawControl(renderer, rect, gameTime);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,390 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: TabControl.cs                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using Microsoft.Xna.Framework;
 | 
			
		||||
using Microsoft.Xna.Framework.Graphics;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
  public class TabControlGamePadActions: GamePadActions
 | 
			
		||||
  {
 | 
			
		||||
    public GamePadButton NextTab = GamePadButton.RightTrigger;
 | 
			
		||||
    public GamePadButton PrevTab = GamePadButton.LeftTrigger;
 | 
			
		||||
  }
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
  
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
  public class TabPage: Control
 | 
			
		||||
  {
 | 
			
		||||
  
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                 
 | 
			
		||||
    private Rectangle headerRect = Rectangle.Empty;
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Properties ////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                     
 | 
			
		||||
    protected internal Rectangle HeaderRect
 | 
			
		||||
    {
 | 
			
		||||
      get { return headerRect; }
 | 
			
		||||
    }    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
   
 | 
			
		||||
    #region //// Constructors //////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public TabPage(Manager manager): base(manager)
 | 
			
		||||
    {
 | 
			
		||||
      Color = Color.Transparent;
 | 
			
		||||
      Passive = true;
 | 
			
		||||
      CanFocus = false;      
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion      
 | 
			
		||||
 | 
			
		||||
		#region //// Methods ///////////
 | 
			
		||||
			
 | 
			
		||||
		////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
		protected internal void CalcRect(Rectangle prev, SpriteFont font, Margins margins, Point offset, bool first)
 | 
			
		||||
    {
 | 
			
		||||
      int size = (int)Math.Ceiling(font.MeasureString(Text).X) + margins.Horizontal;
 | 
			
		||||
      
 | 
			
		||||
      if (first) offset.X = 0;
 | 
			
		||||
      
 | 
			
		||||
      headerRect = new Rectangle(prev.Right + offset.X, prev.Top, size, prev.Height);
 | 
			
		||||
    }
 | 
			
		||||
   	////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
			
 | 
			
		||||
		#endregion  
 | 
			
		||||
		
 | 
			
		||||
  }
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
  
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
  public class TabControl: Container
 | 
			
		||||
  {
 | 
			
		||||
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                 
 | 
			
		||||
    private List<TabPage> tabPages = new List<TabPage>();           
 | 
			
		||||
    private int selectedIndex = 0;
 | 
			
		||||
    private int hoveredIndex = -1;    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Properties ////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public TabPage[] TabPages
 | 
			
		||||
    {
 | 
			
		||||
      get { return tabPages.ToArray(); }      
 | 
			
		||||
    }    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public virtual int SelectedIndex
 | 
			
		||||
    {
 | 
			
		||||
      get { return selectedIndex; }
 | 
			
		||||
      set
 | 
			
		||||
      {
 | 
			
		||||
        if (selectedIndex >= 0 && selectedIndex < tabPages.Count && value >= 0 && value < tabPages.Count)
 | 
			
		||||
        {
 | 
			
		||||
          TabPages[selectedIndex].Visible = false;
 | 
			
		||||
        }
 | 
			
		||||
        if (value >= 0 && value < tabPages.Count)
 | 
			
		||||
        {
 | 
			
		||||
          TabPages[value].Visible = true;          
 | 
			
		||||
          ControlsList c = TabPages[value].Controls as ControlsList;          
 | 
			
		||||
          if (c.Count > 0) c[0].Focused = true;
 | 
			
		||||
          selectedIndex = value;
 | 
			
		||||
          if (!Suspended) OnPageChanged(new EventArgs());
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public virtual TabPage SelectedPage
 | 
			
		||||
    {
 | 
			
		||||
      get { return tabPages[SelectedIndex]; }
 | 
			
		||||
      set
 | 
			
		||||
      {
 | 
			
		||||
        for (int i = 0; i < tabPages.Count; i++)
 | 
			
		||||
        {
 | 
			
		||||
          if (tabPages[i] == value)
 | 
			
		||||
          {
 | 
			
		||||
            SelectedIndex = i;
 | 
			
		||||
            break;
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Events ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public event EventHandler PageChanged;
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Construstors //////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////       
 | 
			
		||||
    public TabControl(Manager manager): base(manager)
 | 
			
		||||
    {
 | 
			
		||||
      GamePadActions = new TabControlGamePadActions();
 | 
			
		||||
      Manager.Input.GamePadDown += new GamePadEventHandler(Input_GamePadDown);
 | 
			
		||||
      this.CanFocus = false;
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
    
 | 
			
		||||
    #region //// Methods ///////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public override void Init()
 | 
			
		||||
    {      
 | 
			
		||||
      base.Init();  
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected internal override void InitSkin()
 | 
			
		||||
    {
 | 
			
		||||
      base.InitSkin();
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
 | 
			
		||||
    {          
 | 
			
		||||
      SkinLayer l1 = Skin.Layers["Control"];
 | 
			
		||||
      SkinLayer l2 = Skin.Layers["Header"];
 | 
			
		||||
      Color col = this.Color != UndefinedColor ? this.Color : Color.White;
 | 
			
		||||
      
 | 
			
		||||
      Rectangle r1 = new Rectangle(rect.Left, rect.Top + l1.OffsetY, rect.Width, rect.Height - l1.OffsetY);
 | 
			
		||||
      if (tabPages.Count <= 0)
 | 
			
		||||
      {
 | 
			
		||||
        r1 = rect;
 | 
			
		||||
      }
 | 
			
		||||
            
 | 
			
		||||
      base.DrawControl(renderer, r1, gameTime);               
 | 
			
		||||
    
 | 
			
		||||
      if (tabPages.Count > 0)
 | 
			
		||||
      {
 | 
			
		||||
 | 
			
		||||
        Rectangle prev = new Rectangle(rect.Left, rect.Top + l2.OffsetY, 0, l2.Height);
 | 
			
		||||
        for (int i = 0; i < tabPages.Count; i++)
 | 
			
		||||
        {                   
 | 
			
		||||
          SpriteFont font = l2.Text.Font.Resource;
 | 
			
		||||
          Margins margins = l2.ContentMargins;
 | 
			
		||||
          Point offset = new Point(l2.OffsetX, l2.OffsetY);          
 | 
			
		||||
          if (i > 0) prev = tabPages[i - 1].HeaderRect;
 | 
			
		||||
                    
 | 
			
		||||
          tabPages[i].CalcRect(prev, font, margins, offset, i==0);
 | 
			
		||||
        }
 | 
			
		||||
      
 | 
			
		||||
        for (int i = tabPages.Count - 1; i >= 0; i--)
 | 
			
		||||
        {
 | 
			
		||||
          int li = tabPages[i].Enabled ? l2.States.Enabled.Index : l2.States.Disabled.Index;
 | 
			
		||||
          Color lc = tabPages[i].Enabled ? l2.Text.Colors.Enabled : l2.Text.Colors.Disabled;
 | 
			
		||||
          if (i == hoveredIndex)
 | 
			
		||||
          {
 | 
			
		||||
            li = l2.States.Hovered.Index;
 | 
			
		||||
            lc = l2.Text.Colors.Hovered;
 | 
			
		||||
          }
 | 
			
		||||
          
 | 
			
		||||
          
 | 
			
		||||
          Margins m = l2.ContentMargins;
 | 
			
		||||
          Rectangle rx = tabPages[i].HeaderRect;          
 | 
			
		||||
          Rectangle sx = new Rectangle(rx.Left + m.Left, rx.Top + m.Top, rx.Width - m.Horizontal, rx.Height - m.Vertical);
 | 
			
		||||
          if (i != selectedIndex)
 | 
			
		||||
          {
 | 
			
		||||
            renderer.DrawLayer(l2, rx, col, li);   
 | 
			
		||||
            renderer.DrawString(l2.Text.Font.Resource, tabPages[i].Text, sx, lc, l2.Text.Alignment);
 | 
			
		||||
          }  
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        Margins mi = l2.ContentMargins;
 | 
			
		||||
        Rectangle ri = tabPages[selectedIndex].HeaderRect;
 | 
			
		||||
        Rectangle si = new Rectangle(ri.Left + mi.Left, ri.Top + mi.Top, ri.Width - mi.Horizontal, ri.Height - mi.Vertical);
 | 
			
		||||
        renderer.DrawLayer(l2, ri, col, l2.States.Focused.Index);        
 | 
			
		||||
        renderer.DrawString(l2.Text.Font.Resource, tabPages[selectedIndex].Text, si, l2.Text.Colors.Focused, l2.Text.Alignment, l2.Text.OffsetX, l2.Text.OffsetY, false);
 | 
			
		||||
      }      
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    public virtual TabPage AddPage(string text)
 | 
			
		||||
    {
 | 
			
		||||
      TabPage p = AddPage();
 | 
			
		||||
      p.Text = text;
 | 
			
		||||
      
 | 
			
		||||
      return p;
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    public virtual TabPage AddPage()
 | 
			
		||||
    {
 | 
			
		||||
      TabPage page = new TabPage(Manager);
 | 
			
		||||
      page.Init();      
 | 
			
		||||
      page.Left = 0;
 | 
			
		||||
      page.Top = 0;
 | 
			
		||||
      page.Width = ClientWidth;
 | 
			
		||||
      page.Height = ClientHeight;
 | 
			
		||||
      page.Anchor = Anchors.All;
 | 
			
		||||
      page.Text = "Tab " + (tabPages.Count + 1).ToString();
 | 
			
		||||
      page.Visible = false;      
 | 
			
		||||
      Add(page, true);
 | 
			
		||||
      tabPages.Add(page);
 | 
			
		||||
      tabPages[0].Visible = true;
 | 
			
		||||
      
 | 
			
		||||
      return page;
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    public virtual void RemovePage(TabPage page, bool dispose)
 | 
			
		||||
    {      
 | 
			
		||||
      tabPages.Remove(page);
 | 
			
		||||
      if (dispose)
 | 
			
		||||
      {
 | 
			
		||||
        page.Dispose();
 | 
			
		||||
        page = null;
 | 
			
		||||
      }
 | 
			
		||||
      SelectedIndex = 0;
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////         
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////         
 | 
			
		||||
    public virtual void RemovePage(TabPage page)
 | 
			
		||||
    {
 | 
			
		||||
      RemovePage(page, true);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////         
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    protected override void OnMouseDown(MouseEventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      base.OnMouseDown(e);
 | 
			
		||||
      
 | 
			
		||||
      if (tabPages.Count > 1)
 | 
			
		||||
      {
 | 
			
		||||
        Point p = new Point(e.State.X - Root.AbsoluteLeft, e.State.Y - Root.AbsoluteTop);
 | 
			
		||||
        for (int i = 0; i < tabPages.Count; i++)
 | 
			
		||||
        {
 | 
			
		||||
          Rectangle r = tabPages[i].HeaderRect;
 | 
			
		||||
          if (p.X >= r.Left && p.X <= r.Right && p.Y >= r.Top && p.Y <= r.Bottom)
 | 
			
		||||
          {
 | 
			
		||||
            SelectedIndex = i;          
 | 
			
		||||
            break;
 | 
			
		||||
          }
 | 
			
		||||
        }        
 | 
			
		||||
      }      
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    protected override void OnMouseMove(MouseEventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      base.OnMouseMove(e); 
 | 
			
		||||
      if (tabPages.Count > 1)
 | 
			
		||||
      {
 | 
			
		||||
        int index = hoveredIndex;
 | 
			
		||||
        Point p = new Point(e.State.X - Root.AbsoluteLeft, e.State.Y - Root.AbsoluteTop);
 | 
			
		||||
        for (int i = 0; i < tabPages.Count; i++)
 | 
			
		||||
        {
 | 
			
		||||
          Rectangle r = tabPages[i].HeaderRect;
 | 
			
		||||
          if (p.X >= r.Left && p.X <= r.Right && p.Y >= r.Top && p.Y <= r.Bottom && tabPages[i].Enabled)
 | 
			
		||||
          {
 | 
			
		||||
            index = i;
 | 
			
		||||
            break;
 | 
			
		||||
          }
 | 
			
		||||
          else
 | 
			
		||||
          {
 | 
			
		||||
            index = -1;
 | 
			
		||||
          }         
 | 
			
		||||
        }
 | 
			
		||||
        if (index != hoveredIndex)
 | 
			
		||||
        {
 | 
			
		||||
          hoveredIndex = index;
 | 
			
		||||
          Invalidate();
 | 
			
		||||
        }
 | 
			
		||||
      }      
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    void Input_GamePadDown(object sender, GamePadEventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      if (this.Contains(Manager.FocusedControl, true))
 | 
			
		||||
      {
 | 
			
		||||
        if (e.Button == (GamePadActions as TabControlGamePadActions).NextTab)
 | 
			
		||||
        {
 | 
			
		||||
          e.Handled = true;
 | 
			
		||||
          SelectedIndex += 1;
 | 
			
		||||
        }
 | 
			
		||||
        else if (e.Button == (GamePadActions as TabControlGamePadActions).PrevTab)
 | 
			
		||||
        {
 | 
			
		||||
          e.Handled = true;
 | 
			
		||||
          SelectedIndex -= 1;
 | 
			
		||||
        }
 | 
			
		||||
      }  
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected virtual void OnPageChanged(EventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      if (PageChanged != null) PageChanged.Invoke(this, e);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    #endregion  
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										1427
									
								
								Neoforce/TextBox.cs
									
									
									
									
									
								
							
							
						
						
									
										1427
									
								
								Neoforce/TextBox.cs
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -1,119 +0,0 @@
 | 
			
		||||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
 | 
			
		||||
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
 | 
			
		||||
  <PropertyGroup>
 | 
			
		||||
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
 | 
			
		||||
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
 | 
			
		||||
    <ProjectGuid>{AC5F1CD8-AA8E-4DB5-814F-86C214175841}</ProjectGuid>
 | 
			
		||||
    <OutputType>Library</OutputType>
 | 
			
		||||
    <AppDesignerFolder>Properties</AppDesignerFolder>
 | 
			
		||||
    <RootNamespace>TomShane.Neoforce.Controls</RootNamespace>
 | 
			
		||||
    <AssemblyName>TomShane.Neoforce.Controls</AssemblyName>
 | 
			
		||||
    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
 | 
			
		||||
    <FileAlignment>512</FileAlignment>
 | 
			
		||||
    <TargetFrameworkProfile />
 | 
			
		||||
  </PropertyGroup>
 | 
			
		||||
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
 | 
			
		||||
    <DebugSymbols>true</DebugSymbols>
 | 
			
		||||
    <DebugType>full</DebugType>
 | 
			
		||||
    <Optimize>false</Optimize>
 | 
			
		||||
    <OutputPath>bin\Debug\</OutputPath>
 | 
			
		||||
    <DefineConstants>DEBUG;TRACE</DefineConstants>
 | 
			
		||||
    <ErrorReport>prompt</ErrorReport>
 | 
			
		||||
    <WarningLevel>4</WarningLevel>
 | 
			
		||||
  </PropertyGroup>
 | 
			
		||||
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
 | 
			
		||||
    <DebugType>pdbonly</DebugType>
 | 
			
		||||
    <Optimize>true</Optimize>
 | 
			
		||||
    <OutputPath>bin\Release\</OutputPath>
 | 
			
		||||
    <DefineConstants>TRACE</DefineConstants>
 | 
			
		||||
    <ErrorReport>prompt</ErrorReport>
 | 
			
		||||
    <WarningLevel>4</WarningLevel>
 | 
			
		||||
  </PropertyGroup>
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
    <Reference Include="MonoGame.Framework, Version=3.1.2.0, Culture=neutral, processorArchitecture=MSIL">
 | 
			
		||||
      <SpecificVersion>False</SpecificVersion>
 | 
			
		||||
      <HintPath>C:\Program Files (x86)\MonoGame\v3.0\Assemblies\Windows\MonoGame.Framework.dll</HintPath>
 | 
			
		||||
    </Reference>
 | 
			
		||||
    <Reference Include="MonoGame.Framework.Net, Version=3.4.0.456, Culture=neutral, processorArchitecture=MSIL">
 | 
			
		||||
      <SpecificVersion>False</SpecificVersion>
 | 
			
		||||
      <HintPath>C:\Program Files (x86)\MonoGame\v3.0\Assemblies\Windows\MonoGame.Framework.Net.dll</HintPath>
 | 
			
		||||
    </Reference>
 | 
			
		||||
    <Reference Include="System" />
 | 
			
		||||
    <Reference Include="System.Drawing" />
 | 
			
		||||
    <Reference Include="System.Windows.Forms" />
 | 
			
		||||
    <Reference Include="System.XML" />
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
    <Compile Include="ArchiveManager.cs" />
 | 
			
		||||
    <Compile Include="Bevel.cs" />
 | 
			
		||||
    <Compile Include="Button.cs" />
 | 
			
		||||
    <Compile Include="ButtonBase.cs" />
 | 
			
		||||
    <Compile Include="CheckBox.cs" />
 | 
			
		||||
    <Compile Include="ClipBox.cs" />
 | 
			
		||||
    <Compile Include="ClipControl.cs" />
 | 
			
		||||
    <Compile Include="ComboBox.cs" />
 | 
			
		||||
    <Compile Include="Component.cs" />
 | 
			
		||||
    <Compile Include="Console.cs" />
 | 
			
		||||
    <Compile Include="Container.cs" />
 | 
			
		||||
    <Compile Include="ContentReaders.cs" />
 | 
			
		||||
    <Compile Include="ContextMenu.cs" />
 | 
			
		||||
    <Compile Include="Control.cs" />
 | 
			
		||||
    <Compile Include="Cursor.cs" />
 | 
			
		||||
    <Compile Include="Delegates.cs" />
 | 
			
		||||
    <Compile Include="Dialog.cs" />
 | 
			
		||||
    <Compile Include="Disposable.cs" />
 | 
			
		||||
    <Compile Include="EventArgs.cs" />
 | 
			
		||||
    <Compile Include="EventedList.cs" />
 | 
			
		||||
    <Compile Include="ExitDialog.cs" />
 | 
			
		||||
    <Compile Include="External\Zip\Crc32.cs" />
 | 
			
		||||
    <Compile Include="External\Zip\Shared.cs" />
 | 
			
		||||
    <Compile Include="External\Zip\ZipDirEntry.cs" />
 | 
			
		||||
    <Compile Include="External\Zip\ZipEntry.cs" />
 | 
			
		||||
    <Compile Include="External\Zip\ZipFile.cs" />
 | 
			
		||||
    <Compile Include="GroupBox.cs" />
 | 
			
		||||
    <Compile Include="GroupPanel.cs" />
 | 
			
		||||
    <Compile Include="ImageBox.cs" />
 | 
			
		||||
    <Compile Include="InputSystem.cs" />
 | 
			
		||||
    <Compile Include="KeyboardLayout.cs" />
 | 
			
		||||
    <Compile Include="Label.cs" />
 | 
			
		||||
    <Compile Include="Layout.cs" />
 | 
			
		||||
    <Compile Include="ListBox.cs" />
 | 
			
		||||
    <Compile Include="MainMenu.cs" />
 | 
			
		||||
    <Compile Include="Manager.cs" />
 | 
			
		||||
    <Compile Include="MenuBase.cs" />
 | 
			
		||||
    <Compile Include="ModalContainer.cs" />
 | 
			
		||||
    <Compile Include="NativeMethods.cs" />
 | 
			
		||||
    <Compile Include="Panel.cs" />
 | 
			
		||||
    <Compile Include="ProgressBar.cs" />
 | 
			
		||||
    <Compile Include="Properties\AssemblyInfo.cs" />
 | 
			
		||||
    <Compile Include="RadioButton.cs" />
 | 
			
		||||
    <Compile Include="Renderer.cs" />
 | 
			
		||||
    <Compile Include="ScrollBar.cs" />
 | 
			
		||||
    <Compile Include="Sidebar.cs" />
 | 
			
		||||
    <Compile Include="SidebarPanel.cs" />
 | 
			
		||||
    <Compile Include="Skin.cs" />
 | 
			
		||||
    <Compile Include="SpinBox.cs" />
 | 
			
		||||
    <Compile Include="StackPanel.cs" />
 | 
			
		||||
    <Compile Include="StatusBar.cs" />
 | 
			
		||||
    <Compile Include="TabControl.cs" />
 | 
			
		||||
    <Compile Include="TextBox.cs" />
 | 
			
		||||
    <Compile Include="ToolBar.cs" />
 | 
			
		||||
    <Compile Include="ToolBarButton.cs" />
 | 
			
		||||
    <Compile Include="ToolBarPanel.cs" />
 | 
			
		||||
    <Compile Include="ToolTip.cs" />
 | 
			
		||||
    <Compile Include="TrackBar.cs" />
 | 
			
		||||
    <Compile Include="Types.cs" />
 | 
			
		||||
    <Compile Include="Unknown.cs" />
 | 
			
		||||
    <Compile Include="Utilities.cs" />
 | 
			
		||||
    <Compile Include="Window.cs" />
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
 | 
			
		||||
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
 | 
			
		||||
       Other similar extension points exist, see Microsoft.Common.targets.
 | 
			
		||||
  <Target Name="BeforeBuild">
 | 
			
		||||
  </Target>
 | 
			
		||||
  <Target Name="AfterBuild">
 | 
			
		||||
  </Target>
 | 
			
		||||
  -->
 | 
			
		||||
</Project>
 | 
			
		||||
@@ -1,113 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: ToolBar.cs                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
using Microsoft.Xna.Framework;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  public class ToolBar: Control
 | 
			
		||||
  {
 | 
			
		||||
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                 
 | 
			
		||||
    private int row = 0;
 | 
			
		||||
    private bool fullRow = false;
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Properties ////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public virtual int Row
 | 
			
		||||
    {
 | 
			
		||||
      get { return row; }
 | 
			
		||||
      set 
 | 
			
		||||
      { 
 | 
			
		||||
        row = value; 
 | 
			
		||||
        if (row < 0) row = 0;
 | 
			
		||||
        if (row > 7) row = 7;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public virtual bool FullRow
 | 
			
		||||
    {
 | 
			
		||||
      get { return fullRow; }
 | 
			
		||||
      set { fullRow = value; }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Construstors //////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////       
 | 
			
		||||
    public ToolBar(Manager manager): base(manager)
 | 
			
		||||
    {    
 | 
			
		||||
      Left = 0;
 | 
			
		||||
      Top = 0;
 | 
			
		||||
      Width = 64;
 | 
			
		||||
      Height = 24;
 | 
			
		||||
      CanFocus = false;
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Methods ///////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public override void Init()
 | 
			
		||||
    {
 | 
			
		||||
      base.Init();
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                          
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                          
 | 
			
		||||
    protected internal override void InitSkin()
 | 
			
		||||
    {
 | 
			
		||||
      base.InitSkin();
 | 
			
		||||
      Skin = new SkinControl(Manager.Skin.Controls["ToolBar"]);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                          
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
 | 
			
		||||
    {
 | 
			
		||||
      base.DrawControl(renderer, rect, gameTime);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,90 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: ToolBarButton.cs                             //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
using Microsoft.Xna.Framework;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  public class ToolBarButton: Button
 | 
			
		||||
  {
 | 
			
		||||
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                 
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Properties ////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Construstors //////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////       
 | 
			
		||||
    public ToolBarButton(Manager manager): base(manager)
 | 
			
		||||
    {
 | 
			
		||||
      CanFocus = false;
 | 
			
		||||
      Text = "";      
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Methods ///////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public override void Init()
 | 
			
		||||
    {
 | 
			
		||||
      base.Init();
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                          
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                          
 | 
			
		||||
    protected internal override void InitSkin()
 | 
			
		||||
    {
 | 
			
		||||
      base.InitSkin();
 | 
			
		||||
      Skin = new SkinControl(Manager.Skin.Controls["ToolBarButton"]);      
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                          
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
 | 
			
		||||
    {
 | 
			
		||||
      base.DrawControl(renderer, rect, gameTime);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,135 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: ToolBarPanel.cs                              //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
using Microsoft.Xna.Framework;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  public class ToolBarPanel: Control
 | 
			
		||||
  {
 | 
			
		||||
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                 
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Properties ////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Construstors //////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////       
 | 
			
		||||
    public ToolBarPanel(Manager manager): base(manager)
 | 
			
		||||
    {
 | 
			
		||||
      Width = 64;
 | 
			
		||||
      Height = 25;
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Methods ///////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public override void Init()
 | 
			
		||||
    {
 | 
			
		||||
      base.Init();
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                          
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                          
 | 
			
		||||
    protected internal override void InitSkin()
 | 
			
		||||
    {
 | 
			
		||||
      base.InitSkin();
 | 
			
		||||
      Skin = new SkinControl(Manager.Skin.Controls["ToolBarPanel"]);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                          
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
 | 
			
		||||
    {
 | 
			
		||||
      base.DrawControl(renderer, rect, gameTime);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    protected override void OnResize(ResizeEventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      base.OnResize(e);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected internal override void Update(GameTime gameTime)
 | 
			
		||||
    {
 | 
			
		||||
      base.Update(gameTime);      
 | 
			
		||||
      AlignBars();      
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    private void AlignBars()
 | 
			
		||||
    {
 | 
			
		||||
      int[] rx = new int[8];
 | 
			
		||||
      int h = 0; 
 | 
			
		||||
      int rm = -1;     
 | 
			
		||||
      
 | 
			
		||||
      foreach (Control c in Controls)
 | 
			
		||||
      {
 | 
			
		||||
        if (c is ToolBar)
 | 
			
		||||
        {
 | 
			
		||||
          ToolBar t = c as ToolBar;
 | 
			
		||||
          if (t.FullRow) t.Width = Width;
 | 
			
		||||
          t.Left = rx[t.Row];
 | 
			
		||||
          t.Top = (t.Row * t.Height) + (t.Row > 0 ? 1 : 0);
 | 
			
		||||
          rx[t.Row] += t.Width + 1;                    
 | 
			
		||||
          
 | 
			
		||||
          if (t.Row > rm)
 | 
			
		||||
          {
 | 
			
		||||
            rm = t.Row;
 | 
			
		||||
            h = t.Top + t.Height + 1;
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
      
 | 
			
		||||
      Height = h;
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,110 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: ToolTip.cs                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
using Microsoft.Xna.Framework;
 | 
			
		||||
using Microsoft.Xna.Framework.Input;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{  
 | 
			
		||||
  public class ToolTip: Control
 | 
			
		||||
  {
 | 
			
		||||
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                     
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Properties ////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public override bool Visible
 | 
			
		||||
    {
 | 
			
		||||
      set
 | 
			
		||||
      {
 | 
			
		||||
        if (value && Text != null && Text != "" && Skin != null && Skin.Layers[0] != null)
 | 
			
		||||
        {
 | 
			
		||||
          Vector2 size = Skin.Layers[0].Text.Font.Resource.MeasureString(Text);
 | 
			
		||||
          Width = (int)size.X + Skin.Layers[0].ContentMargins.Horizontal;
 | 
			
		||||
          Height = (int)size.Y + Skin.Layers[0].ContentMargins.Vertical;
 | 
			
		||||
          Left = Mouse.GetState().X;
 | 
			
		||||
          Top = Mouse.GetState().Y + 24;
 | 
			
		||||
          base.Visible = value;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
          base.Visible = false;
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Construstors //////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////       
 | 
			
		||||
    public ToolTip(Manager manager): base(manager)
 | 
			
		||||
    {  
 | 
			
		||||
      Text = "";          
 | 
			
		||||
    }    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
    
 | 
			
		||||
    #region //// Methods ///////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public override void Init()
 | 
			
		||||
    {      
 | 
			
		||||
      base.Init();
 | 
			
		||||
      CanFocus = false;
 | 
			
		||||
      Passive = true;          
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                          
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                          
 | 
			
		||||
    protected internal override void InitSkin()
 | 
			
		||||
    {
 | 
			
		||||
      base.InitSkin();
 | 
			
		||||
      Skin = Manager.Skin.Controls["ToolTip"];
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                          
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
 | 
			
		||||
    {                      
 | 
			
		||||
      renderer.DrawLayer(this, Skin.Layers[0], rect);
 | 
			
		||||
      renderer.DrawString(this, Skin.Layers[0], Text, rect, true);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
 | 
			
		||||
    #endregion  
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,341 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: TrackBar.cs                                  //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
using Microsoft.Xna.Framework;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
using Microsoft.Xna.Framework.Graphics;
 | 
			
		||||
using System;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
  public class TrackBar: Control
 | 
			
		||||
  {
 | 
			
		||||
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////           
 | 
			
		||||
    private int range = 100;
 | 
			
		||||
    private int value = 0; 
 | 
			
		||||
    private int stepSize = 1;
 | 
			
		||||
    private int pageSize = 5;
 | 
			
		||||
    private bool scale = true;    
 | 
			
		||||
    private Button btnSlider;    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Properties ////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
    public virtual int Value
 | 
			
		||||
    {
 | 
			
		||||
      get { return this.value; }
 | 
			
		||||
      set
 | 
			
		||||
      {
 | 
			
		||||
        if (this.value != value)
 | 
			
		||||
        {
 | 
			
		||||
          this.value = value;
 | 
			
		||||
          if (this.value < 0) this.value = 0;
 | 
			
		||||
          if (this.value > range) this.value = range;
 | 
			
		||||
          Invalidate();
 | 
			
		||||
          if (!Suspended) OnValueChanged(new EventArgs());
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
    public virtual int Range
 | 
			
		||||
    {
 | 
			
		||||
      get { return range; }
 | 
			
		||||
      set
 | 
			
		||||
      {
 | 
			
		||||
        if (range != value)
 | 
			
		||||
        {                    
 | 
			
		||||
          range = value;
 | 
			
		||||
          range = value;
 | 
			
		||||
          if (pageSize > range) pageSize = range;                
 | 
			
		||||
          RecalcParams();          
 | 
			
		||||
          if (!Suspended) OnRangeChanged(new EventArgs());
 | 
			
		||||
        }        
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
    public virtual int PageSize
 | 
			
		||||
    {
 | 
			
		||||
      get { return pageSize; }
 | 
			
		||||
      set
 | 
			
		||||
      {
 | 
			
		||||
        if (pageSize != value)
 | 
			
		||||
        {
 | 
			
		||||
          pageSize = value;
 | 
			
		||||
          if (pageSize > range) pageSize = range;
 | 
			
		||||
          RecalcParams();
 | 
			
		||||
          if (!Suspended) OnPageSizeChanged(new EventArgs());
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
    public virtual int StepSize
 | 
			
		||||
    {
 | 
			
		||||
      get { return stepSize; }
 | 
			
		||||
      set
 | 
			
		||||
      {
 | 
			
		||||
        if (stepSize != value)
 | 
			
		||||
        {
 | 
			
		||||
          stepSize = value;
 | 
			
		||||
          if (stepSize > range) stepSize = range;
 | 
			
		||||
          if (!Suspended) OnStepSizeChanged(new EventArgs());
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    //////////////////////////////////////////////////////////////////////////// 
 | 
			
		||||
    
 | 
			
		||||
    //////////////////////////////////////////////////////////////////////////// 
 | 
			
		||||
    public virtual bool Scale
 | 
			
		||||
    {
 | 
			
		||||
      get { return scale; }
 | 
			
		||||
      set { scale = value; }
 | 
			
		||||
    }
 | 
			
		||||
    //////////////////////////////////////////////////////////////////////////// 
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Events ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////            
 | 
			
		||||
    public event EventHandler ValueChanged;
 | 
			
		||||
    public event EventHandler RangeChanged;
 | 
			
		||||
    public event EventHandler StepSizeChanged;
 | 
			
		||||
    public event EventHandler PageSizeChanged;
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Construstors //////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////       
 | 
			
		||||
    public TrackBar(Manager manager): base(manager)
 | 
			
		||||
    {     
 | 
			
		||||
      Width = 64;
 | 
			
		||||
      Height = 20;      
 | 
			
		||||
      CanFocus = false;
 | 
			
		||||
 | 
			
		||||
      btnSlider = new Button(Manager);
 | 
			
		||||
      btnSlider.Init();
 | 
			
		||||
      btnSlider.Text = "";
 | 
			
		||||
      btnSlider.CanFocus = true;
 | 
			
		||||
      btnSlider.Parent = this;
 | 
			
		||||
      btnSlider.Anchor = Anchors.Left | Anchors.Top | Anchors.Bottom;
 | 
			
		||||
      btnSlider.Detached = true;
 | 
			
		||||
      btnSlider.Movable = true;
 | 
			
		||||
      btnSlider.Move += new MoveEventHandler(btnSlider_Move);
 | 
			
		||||
      btnSlider.KeyPress += new KeyEventHandler(btnSlider_KeyPress);
 | 
			
		||||
      btnSlider.GamePadPress += new GamePadEventHandler(btnSlider_GamePadPress);
 | 
			
		||||
    }    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Methods ///////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
    public override void Init()
 | 
			
		||||
    {
 | 
			
		||||
      base.Init();
 | 
			
		||||
      btnSlider.Skin = new SkinControl(Manager.Skin.Controls["TrackBar.Button"]);      
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected internal override void InitSkin()
 | 
			
		||||
    {
 | 
			
		||||
      base.InitSkin();
 | 
			
		||||
      Skin = new SkinControl(Manager.Skin.Controls["TrackBar"]);      
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
    protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
 | 
			
		||||
    {
 | 
			
		||||
      RecalcParams();
 | 
			
		||||
      
 | 
			
		||||
      SkinLayer p = Skin.Layers["Control"];
 | 
			
		||||
      SkinLayer l = Skin.Layers["Scale"];            
 | 
			
		||||
      
 | 
			
		||||
      float ratio = 0.66f;
 | 
			
		||||
      int h = (int)(ratio * rect.Height);
 | 
			
		||||
      int t = rect.Top + (Height - h) / 2;      
 | 
			
		||||
            
 | 
			
		||||
      float px = ((float)value / (float)range);
 | 
			
		||||
      int w = (int)Math.Ceiling(px * (rect.Width - p.ContentMargins.Horizontal - btnSlider.Width)) + 2;
 | 
			
		||||
            
 | 
			
		||||
      if (w < l.SizingMargins.Vertical) w = l.SizingMargins.Vertical;
 | 
			
		||||
      if (w > rect.Width - p.ContentMargins.Horizontal) w = rect.Width - p.ContentMargins.Horizontal;
 | 
			
		||||
      
 | 
			
		||||
      Rectangle r1 = new Rectangle(rect.Left + p.ContentMargins.Left, t + p.ContentMargins.Top, w, h - p.ContentMargins.Vertical);
 | 
			
		||||
            
 | 
			
		||||
      base.DrawControl(renderer, new Rectangle(rect.Left, t, rect.Width, h), gameTime);      
 | 
			
		||||
      if (scale) renderer.DrawLayer(this, l, r1);      
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    void btnSlider_Move(object sender, MoveEventArgs e)
 | 
			
		||||
    {      
 | 
			
		||||
      SkinLayer p = Skin.Layers["Control"];
 | 
			
		||||
      int size = btnSlider.Width;
 | 
			
		||||
      int w = Width - p.ContentMargins.Horizontal - size;
 | 
			
		||||
      int pos = e.Left;
 | 
			
		||||
 | 
			
		||||
      if (pos < p.ContentMargins.Left) pos = p.ContentMargins.Left;
 | 
			
		||||
      if (pos > w + p.ContentMargins.Left) pos = w + p.ContentMargins.Left;
 | 
			
		||||
      
 | 
			
		||||
      btnSlider.SetPosition(pos, 0);      
 | 
			
		||||
            
 | 
			
		||||
      float px = (float)range / (float)w;
 | 
			
		||||
      Value = (int)(Math.Ceiling((pos - p.ContentMargins.Left) * px));
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    private void RecalcParams()
 | 
			
		||||
    {
 | 
			
		||||
      if (btnSlider != null)
 | 
			
		||||
      {
 | 
			
		||||
        if (btnSlider.Width > 12)
 | 
			
		||||
        {        
 | 
			
		||||
          btnSlider.Glyph = new Glyph(Manager.Skin.Images["Shared.Glyph"].Resource);
 | 
			
		||||
          btnSlider.Glyph.SizeMode = SizeMode.Centered;      
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
          btnSlider.Glyph = null;
 | 
			
		||||
        }
 | 
			
		||||
      
 | 
			
		||||
        SkinLayer p = Skin.Layers["Control"];
 | 
			
		||||
        btnSlider.Width = (int)(Height * 0.8);
 | 
			
		||||
        btnSlider.Height = Height;
 | 
			
		||||
        int size = btnSlider.Width;
 | 
			
		||||
        int w = Width - p.ContentMargins.Horizontal - size;
 | 
			
		||||
 | 
			
		||||
        float px = (float)range / (float)w;
 | 
			
		||||
        int pos = p.ContentMargins.Left + (int)(Math.Ceiling(Value / (float)px));                                
 | 
			
		||||
        
 | 
			
		||||
        if (pos < p.ContentMargins.Left) pos = p.ContentMargins.Left;
 | 
			
		||||
        if (pos > w + p.ContentMargins.Left) pos = w + p.ContentMargins.Left;
 | 
			
		||||
        
 | 
			
		||||
        btnSlider.SetPosition(pos, 0);                
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////        
 | 
			
		||||
    protected override void OnMousePress(MouseEventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      base.OnMouseDown(e);  
 | 
			
		||||
      
 | 
			
		||||
      if (e.Button == MouseButton.Left)
 | 
			
		||||
      {        
 | 
			
		||||
        int pos = e.Position.X;
 | 
			
		||||
          
 | 
			
		||||
        if (pos < btnSlider.Left)
 | 
			
		||||
        {
 | 
			
		||||
          Value -= pageSize;         
 | 
			
		||||
        }
 | 
			
		||||
        else if (pos >= btnSlider.Left + btnSlider.Width)
 | 
			
		||||
        {
 | 
			
		||||
          Value += pageSize;          
 | 
			
		||||
        } 
 | 
			
		||||
      }         
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////           
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    void btnSlider_GamePadPress(object sender, GamePadEventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      if (e.Button == GamePadActions.Left || e.Button == GamePadActions.Down) Value -= stepSize;
 | 
			
		||||
      if (e.Button == GamePadActions.Right || e.Button == GamePadActions.Up) Value += stepSize;
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    void btnSlider_KeyPress(object sender, KeyEventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      if (e.Key == Microsoft.Xna.Framework.Input.Keys.Left || e.Key == Microsoft.Xna.Framework.Input.Keys.Down) Value -= stepSize;
 | 
			
		||||
      else if (e.Key == Microsoft.Xna.Framework.Input.Keys.Right || e.Key == Microsoft.Xna.Framework.Input.Keys.Up) Value += stepSize;
 | 
			
		||||
      else if (e.Key == Microsoft.Xna.Framework.Input.Keys.PageDown) Value -= pageSize;
 | 
			
		||||
      else if (e.Key == Microsoft.Xna.Framework.Input.Keys.PageUp) Value += pageSize;
 | 
			
		||||
      else if (e.Key == Microsoft.Xna.Framework.Input.Keys.Home) Value = 0;
 | 
			
		||||
      else if (e.Key == Microsoft.Xna.Framework.Input.Keys.End) Value = Range;
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
    protected override void OnResize(ResizeEventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      base.OnResize(e);
 | 
			
		||||
      RecalcParams();      
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////          
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////        
 | 
			
		||||
    protected virtual void OnValueChanged(EventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      if (ValueChanged != null) ValueChanged.Invoke(this, e);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////        
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////        
 | 
			
		||||
    protected virtual void OnRangeChanged(EventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      if (RangeChanged != null) RangeChanged.Invoke(this, e);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////         
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////        
 | 
			
		||||
    protected virtual void OnPageSizeChanged(EventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      if (PageSizeChanged != null) PageSizeChanged.Invoke(this, e);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////        
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////        
 | 
			
		||||
    protected virtual void OnStepSizeChanged(EventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      if (StepSizeChanged != null) StepSizeChanged.Invoke(this, e);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////        
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,178 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: Types.cs                                     //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
using System;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
  #region //// Enums /////////////
 | 
			
		||||
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////  
 | 
			
		||||
  public enum Message
 | 
			
		||||
  {
 | 
			
		||||
    Click,    
 | 
			
		||||
    MouseDown,
 | 
			
		||||
    MouseUp,
 | 
			
		||||
    MousePress,
 | 
			
		||||
    MouseMove,
 | 
			
		||||
    MouseOver,
 | 
			
		||||
    MouseOut,
 | 
			
		||||
    MouseScroll,
 | 
			
		||||
    KeyDown,
 | 
			
		||||
    KeyUp,
 | 
			
		||||
    KeyPress,
 | 
			
		||||
    GamePadDown,
 | 
			
		||||
    GamePadUp,
 | 
			
		||||
    GamePadPress    
 | 
			
		||||
  }
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////        
 | 
			
		||||
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
  public enum ControlState
 | 
			
		||||
  {    
 | 
			
		||||
    Enabled,
 | 
			
		||||
    Hovered,
 | 
			
		||||
    Pressed,
 | 
			
		||||
    Focused,
 | 
			
		||||
    Disabled
 | 
			
		||||
  }
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////  
 | 
			
		||||
  
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
  public enum Alignment
 | 
			
		||||
  {
 | 
			
		||||
    None,
 | 
			
		||||
    TopLeft,
 | 
			
		||||
    TopCenter,
 | 
			
		||||
    TopRight,
 | 
			
		||||
    MiddleLeft,
 | 
			
		||||
    MiddleCenter,
 | 
			
		||||
    MiddleRight,
 | 
			
		||||
    BottomLeft,
 | 
			
		||||
    BottomCenter,
 | 
			
		||||
    BottomRight
 | 
			
		||||
  }
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
  
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////  
 | 
			
		||||
  public enum ModalResult
 | 
			
		||||
  {
 | 
			
		||||
    None,
 | 
			
		||||
    Ok,
 | 
			
		||||
    Cancel,
 | 
			
		||||
    Yes,
 | 
			
		||||
    No,
 | 
			
		||||
    Abort,
 | 
			
		||||
    Retry,
 | 
			
		||||
    Ignore
 | 
			
		||||
  }
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
  public enum Orientation
 | 
			
		||||
  {
 | 
			
		||||
    Horizontal,
 | 
			
		||||
    Vertical
 | 
			
		||||
  }
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////  
 | 
			
		||||
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
  public enum ScrollBars
 | 
			
		||||
  {
 | 
			
		||||
    None,
 | 
			
		||||
    Vertical,
 | 
			
		||||
    Horizontal,
 | 
			
		||||
    Both
 | 
			
		||||
  }
 | 
			
		||||
  //////////////////////////////////////////////////////////////////////////// 
 | 
			
		||||
  
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////  
 | 
			
		||||
  [Flags]
 | 
			
		||||
  public enum Anchors
 | 
			
		||||
  {    
 | 
			
		||||
    None = 0x00,
 | 
			
		||||
    Left = 0x01,
 | 
			
		||||
    Top = 0x02,
 | 
			
		||||
    Right = 0x04,
 | 
			
		||||
    Bottom = 0x08,
 | 
			
		||||
    Horizontal = Left | Right,
 | 
			
		||||
    Vertical = Top | Bottom,
 | 
			
		||||
    All = Left | Top | Right | Bottom
 | 
			
		||||
  }
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////  
 | 
			
		||||
  
 | 
			
		||||
  #endregion
 | 
			
		||||
 | 
			
		||||
  #region //// Structs ///////////
 | 
			
		||||
  
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
  public struct Margins
 | 
			
		||||
  {
 | 
			
		||||
    public int Left;
 | 
			
		||||
    public int Top;
 | 
			
		||||
    public int Right;
 | 
			
		||||
    public int Bottom;   
 | 
			
		||||
    
 | 
			
		||||
    public int Vertical { get { return (Top + Bottom); } }
 | 
			
		||||
    public int Horizontal { get { return (Left + Right); } }
 | 
			
		||||
    
 | 
			
		||||
    public Margins(int left, int top, int right, int bottom)
 | 
			
		||||
    {
 | 
			
		||||
      Left = left;
 | 
			
		||||
      Top = top;
 | 
			
		||||
      Right = right;
 | 
			
		||||
      Bottom = bottom;
 | 
			
		||||
    }         
 | 
			
		||||
  }
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
  public struct Size
 | 
			
		||||
  {
 | 
			
		||||
    public int Width;
 | 
			
		||||
    public int Height;
 | 
			
		||||
    
 | 
			
		||||
    public Size(int width, int height)
 | 
			
		||||
    {
 | 
			
		||||
      Width = width;
 | 
			
		||||
      Height = height;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public static Size Zero
 | 
			
		||||
    {
 | 
			
		||||
      get 
 | 
			
		||||
      {
 | 
			
		||||
        return new Size(0, 0);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  //////////////////////////////////////////////////////////////////////////// 
 | 
			
		||||
  
 | 
			
		||||
  #endregion    
 | 
			
		||||
  
 | 
			
		||||
}
 | 
			
		||||
  
 | 
			
		||||
@@ -1,61 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: Unknown.cs                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
        
 | 
			
		||||
//////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
//////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{     
 | 
			
		||||
		
 | 
			
		||||
	public abstract class Unknown
 | 
			
		||||
	{    
 | 
			
		||||
        
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
                
 | 
			
		||||
    //////////////////////////////////////////////////////////////////////////            
 | 
			
		||||
    //////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
   
 | 
			
		||||
    #endregion                
 | 
			
		||||
    
 | 
			
		||||
    #region //// Properties ////////
 | 
			
		||||
	  
 | 
			
		||||
	  //////////////////////////////////////////////////////////////////////////	  
 | 
			
		||||
	  //////////////////////////////////////////////////////////////////////////
 | 
			
		||||
	  
 | 
			
		||||
	  #endregion        
 | 
			
		||||
	  
 | 
			
		||||
    #region //// Constructors //////
 | 
			
		||||
        
 | 
			
		||||
	  //////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected Unknown()
 | 
			
		||||
    {    
 | 
			
		||||
    }
 | 
			
		||||
    //////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    #endregion      	  
 | 
			
		||||
	  
 | 
			
		||||
  }			    
 | 
			
		||||
		
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -1,85 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: Utilities.cs                                 //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
using System;
 | 
			
		||||
using Microsoft.Xna.Framework.Graphics;
 | 
			
		||||
using Microsoft.Xna.Framework.Input;
 | 
			
		||||
using Microsoft.Xna.Framework;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{
 | 
			
		||||
  static class Utilities
 | 
			
		||||
  {
 | 
			
		||||
  
 | 
			
		||||
    #region //// Methods ///////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public static string DeriveControlName(Control control)
 | 
			
		||||
    {
 | 
			
		||||
      if (control != null)
 | 
			
		||||
      {
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
          string str = control.ToString();
 | 
			
		||||
          int i = str.LastIndexOf(".");
 | 
			
		||||
          return str.Remove(0, i + 1);
 | 
			
		||||
        }
 | 
			
		||||
        catch
 | 
			
		||||
        {
 | 
			
		||||
          return control.ToString();
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
      return control.ToString();
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public static Color ParseColor(string str)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
      string[] val = str.Split(';');
 | 
			
		||||
      byte r = 255, g = 255, b = 255, a = 255;
 | 
			
		||||
 | 
			
		||||
      if (val.Length >= 1) r = byte.Parse(val[0]);
 | 
			
		||||
      if (val.Length >= 2) g = byte.Parse(val[1]);
 | 
			
		||||
      if (val.Length >= 3) b = byte.Parse(val[2]);
 | 
			
		||||
      if (val.Length >= 4) a = byte.Parse(val[3]);
 | 
			
		||||
 | 
			
		||||
      return Color.FromNonPremultiplied(r, g, b, a);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public static BevelStyle ParseBevelStyle(string str)
 | 
			
		||||
    {
 | 
			
		||||
      return (BevelStyle)Enum.Parse(typeof(BevelStyle), str, true);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
 | 
			
		||||
    #endregion    
 | 
			
		||||
    
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,491 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Neoforce Controls                                         //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         File: Window.cs                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//      Version: 0.7                                          //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//         Date: 11/09/2010                                   //
 | 
			
		||||
//                                                            //
 | 
			
		||||
//       Author: Tom Shane                                    //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
//                                                            //
 | 
			
		||||
//  Copyright (c) by Tom Shane                                //
 | 
			
		||||
//                                                            //
 | 
			
		||||
////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#region //// Using /////////////
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
using Microsoft.Xna.Framework;
 | 
			
		||||
using Microsoft.Xna.Framework.Graphics;
 | 
			
		||||
using Microsoft.Xna.Framework.Input;
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#endregion
 | 
			
		||||
 | 
			
		||||
namespace TomShane.Neoforce.Controls
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
  #region //// Classes ///////////
 | 
			
		||||
  
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
  public class WindowGamePadActions: GamePadActions
 | 
			
		||||
  {
 | 
			
		||||
    public GamePadButton Accept = GamePadButton.Start;
 | 
			
		||||
    public GamePadButton Cancel = GamePadButton.Back;
 | 
			
		||||
  }
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
  
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
  ///  <include file='Documents/Window.xml' path='Window/Class[@name="Window"]/*' />          
 | 
			
		||||
  public class Window: ModalContainer
 | 
			
		||||
  {
 | 
			
		||||
 | 
			
		||||
    #region //// Consts ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    private const string skWindow       = "Window";
 | 
			
		||||
    private const string lrWindow       = "Control";
 | 
			
		||||
    private const string lrCaption      = "Caption";        
 | 
			
		||||
    private const string lrFrameTop     = "FrameTop";    
 | 
			
		||||
    private const string lrFrameLeft    = "FrameLeft";
 | 
			
		||||
    private const string lrFrameRight   = "FrameRight";
 | 
			
		||||
    private const string lrFrameBottom  = "FrameBottom";
 | 
			
		||||
    private const string lrIcon         = "Icon";  
 | 
			
		||||
      
 | 
			
		||||
    private const string skButton       = "Window.CloseButton";
 | 
			
		||||
    private const string lrButton       = "Control";
 | 
			
		||||
    
 | 
			
		||||
    private const string skShadow       = "Window.Shadow";
 | 
			
		||||
    private const string lrShadow       = "Control";        
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Fields ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
    private Button btnClose;
 | 
			
		||||
    private bool closeButtonVisible = true;
 | 
			
		||||
    private bool iconVisible = true;
 | 
			
		||||
    private Texture2D icon = null;
 | 
			
		||||
    private bool shadow = true;
 | 
			
		||||
    private bool captionVisible = true;    
 | 
			
		||||
    private bool borderVisible = true;
 | 
			
		||||
    private byte oldAlpha = 255;
 | 
			
		||||
    private byte dragAlpha = 200;  
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Events ////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Properties ////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public virtual Texture2D Icon
 | 
			
		||||
    {
 | 
			
		||||
      get { return icon; }
 | 
			
		||||
      set { icon = value; }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public virtual bool Shadow 
 | 
			
		||||
    { 
 | 
			
		||||
      get { return shadow; } 
 | 
			
		||||
      set { shadow = value; } 
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////      
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public virtual bool CloseButtonVisible
 | 
			
		||||
    {
 | 
			
		||||
      get
 | 
			
		||||
      {
 | 
			
		||||
        return closeButtonVisible;
 | 
			
		||||
      }
 | 
			
		||||
      set
 | 
			
		||||
      {
 | 
			
		||||
        closeButtonVisible = value;
 | 
			
		||||
        if (btnClose != null) btnClose.Visible = value;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public virtual bool IconVisible
 | 
			
		||||
    {
 | 
			
		||||
      get
 | 
			
		||||
      {
 | 
			
		||||
        return iconVisible;
 | 
			
		||||
      }
 | 
			
		||||
      set
 | 
			
		||||
      {
 | 
			
		||||
        iconVisible = value;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
    public virtual bool CaptionVisible
 | 
			
		||||
    {
 | 
			
		||||
      get { return captionVisible; }
 | 
			
		||||
      set 
 | 
			
		||||
      { 
 | 
			
		||||
        captionVisible = value; 
 | 
			
		||||
        AdjustMargins();        
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////   
 | 
			
		||||
    public virtual bool BorderVisible
 | 
			
		||||
    {
 | 
			
		||||
      get { return borderVisible; }
 | 
			
		||||
      set
 | 
			
		||||
      {
 | 
			
		||||
        borderVisible = value;
 | 
			
		||||
        AdjustMargins();
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    //////////////////////////////////////////////////////////////////////////// 
 | 
			
		||||
    
 | 
			
		||||
    //////////////////////////////////////////////////////////////////////////// 
 | 
			
		||||
    public virtual byte DragAlpha
 | 
			
		||||
    {
 | 
			
		||||
      get { return dragAlpha; }
 | 
			
		||||
      set { dragAlpha = value; }
 | 
			
		||||
    }
 | 
			
		||||
    //////////////////////////////////////////////////////////////////////////// 
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region //// Constructors //////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public Window(Manager manager): base(manager)
 | 
			
		||||
    {
 | 
			
		||||
      CheckLayer(Skin, lrWindow);
 | 
			
		||||
      CheckLayer(Skin, lrCaption);      
 | 
			
		||||
      CheckLayer(Skin, lrFrameTop);      
 | 
			
		||||
      CheckLayer(Skin, lrFrameLeft);
 | 
			
		||||
      CheckLayer(Skin, lrFrameRight);
 | 
			
		||||
      CheckLayer(Skin, lrFrameBottom);
 | 
			
		||||
      CheckLayer(Manager.Skin.Controls[skButton], lrButton);
 | 
			
		||||
      CheckLayer(Manager.Skin.Controls[skShadow], lrShadow);
 | 
			
		||||
      
 | 
			
		||||
      SetDefaultSize(640, 480);
 | 
			
		||||
      SetMinimumSize(100, 75);
 | 
			
		||||
 | 
			
		||||
      btnClose = new Button(manager);
 | 
			
		||||
      btnClose.Skin = new SkinControl(Manager.Skin.Controls[skButton]);
 | 
			
		||||
      btnClose.Init();
 | 
			
		||||
      btnClose.Detached = true;
 | 
			
		||||
      btnClose.CanFocus = false;      
 | 
			
		||||
      btnClose.Text = null;
 | 
			
		||||
      btnClose.Click += new EventHandler(btnClose_Click);
 | 
			
		||||
      btnClose.SkinChanged += new EventHandler(btnClose_SkinChanged);
 | 
			
		||||
 | 
			
		||||
      AdjustMargins();      
 | 
			
		||||
      
 | 
			
		||||
      AutoScroll = true;
 | 
			
		||||
      Movable = true;
 | 
			
		||||
      Resizable = true;
 | 
			
		||||
      Center();
 | 
			
		||||
     
 | 
			
		||||
      Add(btnClose, false);   
 | 
			
		||||
      
 | 
			
		||||
      oldAlpha = Alpha;               
 | 
			
		||||
    }   
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////             
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////             
 | 
			
		||||
    protected override void Dispose(bool disposing)
 | 
			
		||||
    {
 | 
			
		||||
      if (disposing)
 | 
			
		||||
      {       
 | 
			
		||||
      }
 | 
			
		||||
      base.Dispose(disposing);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////             
 | 
			
		||||
 | 
			
		||||
    #region //// Methods ///////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    public override void Init()
 | 
			
		||||
    {
 | 
			
		||||
      base.Init();
 | 
			
		||||
 | 
			
		||||
      SkinLayer l = btnClose.Skin.Layers[lrButton];            
 | 
			
		||||
      btnClose.Width = l.Width - btnClose.Skin.OriginMargins.Horizontal;
 | 
			
		||||
      btnClose.Height = l.Height - btnClose.Skin.OriginMargins.Vertical;
 | 
			
		||||
      btnClose.Left = OriginWidth - Skin.OriginMargins.Right - btnClose.Width + l.OffsetX;                  
 | 
			
		||||
      btnClose.Top = Skin.OriginMargins.Top + l.OffsetY;
 | 
			
		||||
      btnClose.Anchor = Anchors.Top | Anchors.Right;
 | 
			
		||||
 | 
			
		||||
      //SkinControl sc = new SkinControl(ClientArea.Skin);
 | 
			
		||||
      //sc.Layers[0] = Skin.Layers[lrWindow];
 | 
			
		||||
      //ClientArea.Color = Color.Transparent;
 | 
			
		||||
      //ClientArea.BackColor = Color.Transparent;
 | 
			
		||||
      //ClientArea.Skin = sc;                     
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected internal override void InitSkin()
 | 
			
		||||
    {
 | 
			
		||||
      base.InitSkin();
 | 
			
		||||
      Skin = new SkinControl(Manager.Skin.Controls[skWindow]);
 | 
			
		||||
      AdjustMargins();
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    void btnClose_SkinChanged(object sender, EventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      btnClose.Skin = new SkinControl(Manager.Skin.Controls[skButton]);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    internal override void Render(Renderer renderer, GameTime gameTime)
 | 
			
		||||
    {      
 | 
			
		||||
      if (Visible && Shadow)
 | 
			
		||||
      {        
 | 
			
		||||
        SkinControl c = Manager.Skin.Controls[skShadow];
 | 
			
		||||
        SkinLayer l = c.Layers[lrShadow];
 | 
			
		||||
 | 
			
		||||
        Color cl = Color.FromNonPremultiplied(l.States.Enabled.Color.R, l.States.Enabled.Color.G, l.States.Enabled.Color.B, Alpha);
 | 
			
		||||
 | 
			
		||||
        renderer.Begin(BlendingMode.Default);
 | 
			
		||||
        renderer.DrawLayer(l, new Rectangle(Left - c.OriginMargins.Left, Top - c.OriginMargins.Top, Width + c.OriginMargins.Horizontal, Height + c.OriginMargins.Vertical), cl, 0);
 | 
			
		||||
        renderer.End();
 | 
			
		||||
      }
 | 
			
		||||
      base.Render(renderer, gameTime);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
   
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    private Rectangle GetIconRect()
 | 
			
		||||
    {     
 | 
			
		||||
      SkinLayer l1 = Skin.Layers[lrCaption];
 | 
			
		||||
      SkinLayer l5 = Skin.Layers[lrIcon];             
 | 
			
		||||
      
 | 
			
		||||
      int s = l1.Height - l1.ContentMargins.Vertical;
 | 
			
		||||
      return new Rectangle(DrawingRect.Left + l1.ContentMargins.Left + l5.OffsetX,
 | 
			
		||||
                           DrawingRect.Top + l1.ContentMargins.Top + l5.OffsetY,
 | 
			
		||||
                           s, s);
 | 
			
		||||
                                       
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
 | 
			
		||||
    {
 | 
			
		||||
      SkinLayer l1 = captionVisible ? Skin.Layers[lrCaption] : Skin.Layers[lrFrameTop];      
 | 
			
		||||
      SkinLayer l2 = Skin.Layers[lrFrameLeft];
 | 
			
		||||
      SkinLayer l3 = Skin.Layers[lrFrameRight];
 | 
			
		||||
      SkinLayer l4 = Skin.Layers[lrFrameBottom];      
 | 
			
		||||
      SkinLayer l5 = Skin.Layers[lrIcon];      
 | 
			
		||||
      LayerStates s1, s2, s3, s4;
 | 
			
		||||
      SpriteFont f1 = l1.Text.Font.Resource;
 | 
			
		||||
      Color c1 = l1.Text.Colors.Enabled;                                                              
 | 
			
		||||
                              
 | 
			
		||||
      if ((Focused || (Manager.FocusedControl != null && Manager.FocusedControl.Root == this.Root)) && ControlState != ControlState.Disabled)
 | 
			
		||||
      {
 | 
			
		||||
        s1 = l1.States.Focused;
 | 
			
		||||
        s2 = l2.States.Focused;
 | 
			
		||||
        s3 = l3.States.Focused;
 | 
			
		||||
        s4 = l4.States.Focused;        
 | 
			
		||||
        c1 = l1.Text.Colors.Focused;        
 | 
			
		||||
      }
 | 
			
		||||
      else if (ControlState == ControlState.Disabled)
 | 
			
		||||
      {
 | 
			
		||||
        s1 = l1.States.Disabled;
 | 
			
		||||
        s2 = l2.States.Disabled;
 | 
			
		||||
        s3 = l3.States.Disabled;
 | 
			
		||||
        s4 = l4.States.Disabled;
 | 
			
		||||
        c1 = l1.Text.Colors.Disabled;
 | 
			
		||||
      }
 | 
			
		||||
      else
 | 
			
		||||
      {
 | 
			
		||||
        s1 = l1.States.Enabled;
 | 
			
		||||
        s2 = l2.States.Enabled;
 | 
			
		||||
        s3 = l3.States.Enabled;
 | 
			
		||||
        s4 = l4.States.Enabled;
 | 
			
		||||
        c1 = l1.Text.Colors.Enabled;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      renderer.DrawLayer(Skin.Layers[lrWindow], rect, Skin.Layers[lrWindow].States.Enabled.Color, Skin.Layers[lrWindow].States.Enabled.Index);
 | 
			
		||||
      
 | 
			
		||||
      if (borderVisible)
 | 
			
		||||
      {
 | 
			
		||||
        renderer.DrawLayer(l1, new Rectangle(rect.Left, rect.Top, rect.Width, l1.Height), s1.Color, s1.Index);
 | 
			
		||||
        renderer.DrawLayer(l2, new Rectangle(rect.Left, rect.Top + l1.Height, l2.Width, rect.Height - l1.Height - l4.Height), s2.Color, s2.Index);      
 | 
			
		||||
        renderer.DrawLayer(l3, new Rectangle(rect.Right - l3.Width, rect.Top + l1.Height, l3.Width, rect.Height - l1.Height - l4.Height), s3.Color, s3.Index);
 | 
			
		||||
        renderer.DrawLayer(l4, new Rectangle(rect.Left, rect.Bottom - l4.Height, rect.Width, l4.Height),  s4.Color, s4.Index);
 | 
			
		||||
     
 | 
			
		||||
        if (iconVisible && (icon != null || l5 != null) && captionVisible)
 | 
			
		||||
        {       
 | 
			
		||||
          Texture2D i = (icon != null) ? icon : l5.Image.Resource;        
 | 
			
		||||
          renderer.Draw(i, GetIconRect(), Color.White);        
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        int icosize = 0;
 | 
			
		||||
        if (l5 != null && iconVisible && captionVisible)
 | 
			
		||||
        {
 | 
			
		||||
          icosize = l1.Height - l1.ContentMargins.Vertical + 4 + l5.OffsetX;
 | 
			
		||||
        }
 | 
			
		||||
        int closesize = 0;
 | 
			
		||||
        if (btnClose.Visible)
 | 
			
		||||
        {
 | 
			
		||||
          closesize = btnClose.Width - (btnClose.Skin.Layers[lrButton].OffsetX);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        Rectangle r = new Rectangle(rect.Left + l1.ContentMargins.Left + icosize,
 | 
			
		||||
                                    rect.Top + l1.ContentMargins.Top,
 | 
			
		||||
                                    rect.Width - l1.ContentMargins.Horizontal - closesize - icosize,
 | 
			
		||||
                                    l1.Height - l1.ContentMargins.Top - l1.ContentMargins.Bottom);
 | 
			
		||||
        int ox = l1.Text.OffsetX;
 | 
			
		||||
        int oy = l1.Text.OffsetY;
 | 
			
		||||
        renderer.DrawString(f1, Text, r, c1, l1.Text.Alignment, ox, oy, true);
 | 
			
		||||
      }  
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////                               
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    void btnClose_Click(object sender, EventArgs e)
 | 
			
		||||
    {      
 | 
			
		||||
      Close(ModalResult = ModalResult.Cancel);
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////           
 | 
			
		||||
    public virtual void Center()
 | 
			
		||||
    {
 | 
			
		||||
      Left = (Manager.ScreenWidth / 2) - (Width / 2);
 | 
			
		||||
      Top = (Manager.ScreenHeight - Height) / 2;
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////           
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////           
 | 
			
		||||
    protected override void OnResize(ResizeEventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      SetMovableArea();
 | 
			
		||||
      base.OnResize(e);
 | 
			
		||||
    }
 | 
			
		||||
    //////////////////////////////////////////////////////////////////////////// 
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected override void OnMoveBegin(EventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      base.OnMoveBegin(e);
 | 
			
		||||
     
 | 
			
		||||
      try
 | 
			
		||||
      {     
 | 
			
		||||
        oldAlpha = Alpha;   
 | 
			
		||||
        Alpha = dragAlpha;
 | 
			
		||||
      }
 | 
			
		||||
      catch
 | 
			
		||||
      {
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    protected override void OnMoveEnd(EventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      base.OnMoveEnd(e);
 | 
			
		||||
      try
 | 
			
		||||
      {
 | 
			
		||||
        Alpha = oldAlpha;
 | 
			
		||||
      }
 | 
			
		||||
      catch
 | 
			
		||||
      {
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////  
 | 
			
		||||
    protected override void OnDoubleClick(EventArgs e)
 | 
			
		||||
    {
 | 
			
		||||
      base.OnDoubleClick(e);
 | 
			
		||||
                  
 | 
			
		||||
      MouseEventArgs ex = (e is MouseEventArgs) ? (MouseEventArgs) e : new MouseEventArgs();
 | 
			
		||||
      
 | 
			
		||||
      if (IconVisible && ex.Button == MouseButton.Left)
 | 
			
		||||
      {
 | 
			
		||||
        Rectangle r = GetIconRect();
 | 
			
		||||
        r.Offset(AbsoluteLeft, AbsoluteTop);
 | 
			
		||||
        if (r.Contains(ex.Position))
 | 
			
		||||
        {
 | 
			
		||||
          Close();
 | 
			
		||||
        }
 | 
			
		||||
      }  
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////     
 | 
			
		||||
    
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////    
 | 
			
		||||
    protected override void AdjustMargins()
 | 
			
		||||
    {                  
 | 
			
		||||
       
 | 
			
		||||
      if (captionVisible && borderVisible)
 | 
			
		||||
      {
 | 
			
		||||
        ClientMargins = new Margins(Skin.ClientMargins.Left, Skin.Layers[lrCaption].Height, Skin.ClientMargins.Right, Skin.ClientMargins.Bottom);                
 | 
			
		||||
      }
 | 
			
		||||
      else if (!captionVisible && borderVisible)     
 | 
			
		||||
      {
 | 
			
		||||
        ClientMargins = new Margins(Skin.ClientMargins.Left, Skin.ClientMargins.Top, Skin.ClientMargins.Right, Skin.ClientMargins.Bottom);        
 | 
			
		||||
      }
 | 
			
		||||
      else if (!borderVisible)
 | 
			
		||||
      {
 | 
			
		||||
        ClientMargins = new Margins(0, 0, 0, 0);        
 | 
			
		||||
      }
 | 
			
		||||
      
 | 
			
		||||
      if (btnClose != null)
 | 
			
		||||
      {
 | 
			
		||||
        btnClose.Visible = closeButtonVisible && captionVisible && borderVisible;
 | 
			
		||||
      }              
 | 
			
		||||
                
 | 
			
		||||
      SetMovableArea();
 | 
			
		||||
      
 | 
			
		||||
      base.AdjustMargins();
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    private void SetMovableArea()
 | 
			
		||||
    {
 | 
			
		||||
      if (captionVisible && borderVisible)
 | 
			
		||||
      {
 | 
			
		||||
        MovableArea = new Rectangle(Skin.OriginMargins.Left, Skin.OriginMargins.Top, Width, Skin.Layers[lrCaption].Height - Skin.OriginMargins.Top);
 | 
			
		||||
      }
 | 
			
		||||
      else if (!captionVisible)
 | 
			
		||||
      {
 | 
			
		||||
        MovableArea = new Rectangle(0, 0, Width, Height);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
  #endregion
 | 
			
		||||
  
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										13
									
								
								SpacePew.sln
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								SpacePew.sln
									
									
									
									
									
								
							@@ -1,7 +1,7 @@
 | 
			
		||||
 | 
			
		||||
Microsoft Visual Studio Solution File, Format Version 12.00
 | 
			
		||||
# Visual Studio 14
 | 
			
		||||
VisualStudioVersion = 14.0.24720.0
 | 
			
		||||
VisualStudioVersion = 14.0.25420.1
 | 
			
		||||
MinimumVisualStudioVersion = 10.0.40219.1
 | 
			
		||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpacePew", "SpacePew\SpacePew.csproj", "{8B1B6A0B-2F48-4FB4-936A-2086505B2914}"
 | 
			
		||||
EndProject
 | 
			
		||||
@@ -9,8 +9,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpacePew.Common", "SpacePew
 | 
			
		||||
EndProject
 | 
			
		||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lidgren.Network", "Lidgren.Network\Lidgren.Network.csproj", "{49BA1C69-6104-41AC-A5D8-B54FA9F696E8}"
 | 
			
		||||
EndProject
 | 
			
		||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TomShane.Neoforce.Controls", "Neoforce\TomShane.Neoforce.Controls.csproj", "{AC5F1CD8-AA8E-4DB5-814F-86C214175841}"
 | 
			
		||||
EndProject
 | 
			
		||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "References", "References", "{AC34EB05-CB95-4A1E-8C75-FE74BA4A1DD9}"
 | 
			
		||||
EndProject
 | 
			
		||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpacePew.MasterServer", "SpacePew.MasterServer\SpacePew.MasterServer.csproj", "{9BFE240A-AEE0-4FD6-80B8-5846DCFAE95C}"
 | 
			
		||||
@@ -46,14 +44,6 @@ Global
 | 
			
		||||
		{49BA1C69-6104-41AC-A5D8-B54FA9F696E8}.Release|Any CPU.Build.0 = Release|Any CPU
 | 
			
		||||
		{49BA1C69-6104-41AC-A5D8-B54FA9F696E8}.Release|x86.ActiveCfg = Release|Any CPU
 | 
			
		||||
		{49BA1C69-6104-41AC-A5D8-B54FA9F696E8}.Release|x86.Build.0 = Release|Any CPU
 | 
			
		||||
		{AC5F1CD8-AA8E-4DB5-814F-86C214175841}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 | 
			
		||||
		{AC5F1CD8-AA8E-4DB5-814F-86C214175841}.Debug|Any CPU.Build.0 = Debug|Any CPU
 | 
			
		||||
		{AC5F1CD8-AA8E-4DB5-814F-86C214175841}.Debug|x86.ActiveCfg = Debug|Any CPU
 | 
			
		||||
		{AC5F1CD8-AA8E-4DB5-814F-86C214175841}.Debug|x86.Build.0 = Debug|Any CPU
 | 
			
		||||
		{AC5F1CD8-AA8E-4DB5-814F-86C214175841}.Release|Any CPU.ActiveCfg = Release|Any CPU
 | 
			
		||||
		{AC5F1CD8-AA8E-4DB5-814F-86C214175841}.Release|Any CPU.Build.0 = Release|Any CPU
 | 
			
		||||
		{AC5F1CD8-AA8E-4DB5-814F-86C214175841}.Release|x86.ActiveCfg = Release|Any CPU
 | 
			
		||||
		{AC5F1CD8-AA8E-4DB5-814F-86C214175841}.Release|x86.Build.0 = Release|Any CPU
 | 
			
		||||
		{9BFE240A-AEE0-4FD6-80B8-5846DCFAE95C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 | 
			
		||||
		{9BFE240A-AEE0-4FD6-80B8-5846DCFAE95C}.Debug|Any CPU.Build.0 = Debug|Any CPU
 | 
			
		||||
		{9BFE240A-AEE0-4FD6-80B8-5846DCFAE95C}.Debug|x86.ActiveCfg = Debug|Any CPU
 | 
			
		||||
@@ -68,6 +58,5 @@ Global
 | 
			
		||||
	EndGlobalSection
 | 
			
		||||
	GlobalSection(NestedProjects) = preSolution
 | 
			
		||||
		{49BA1C69-6104-41AC-A5D8-B54FA9F696E8} = {AC34EB05-CB95-4A1E-8C75-FE74BA4A1DD9}
 | 
			
		||||
		{AC5F1CD8-AA8E-4DB5-814F-86C214175841} = {AC34EB05-CB95-4A1E-8C75-FE74BA4A1DD9}
 | 
			
		||||
	EndGlobalSection
 | 
			
		||||
EndGlobal
 | 
			
		||||
 
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -11,7 +11,7 @@ with.
 | 
			
		||||
    <!--
 | 
			
		||||
    Modify this string to change the font that will be imported.
 | 
			
		||||
    -->
 | 
			
		||||
    <FontName>Kootenay</FontName>
 | 
			
		||||
    <FontName>Tahoma</FontName>
 | 
			
		||||
 | 
			
		||||
    <!--
 | 
			
		||||
    Size is a float value, measured in points. Modify this value to change
 | 
			
		||||
 
 | 
			
		||||
@@ -11,7 +11,7 @@ with.
 | 
			
		||||
    <!--
 | 
			
		||||
    Modify this string to change the font that will be imported.
 | 
			
		||||
    -->
 | 
			
		||||
    <FontName>Kootenay</FontName>
 | 
			
		||||
    <FontName>Tahoma</FontName>
 | 
			
		||||
 | 
			
		||||
    <!--
 | 
			
		||||
    Size is a float value, measured in points. Modify this value to change
 | 
			
		||||
 
 | 
			
		||||
@@ -11,7 +11,7 @@ with.
 | 
			
		||||
    <!--
 | 
			
		||||
    Modify this string to change the font that will be imported.
 | 
			
		||||
    -->
 | 
			
		||||
    <FontName>Kootenay</FontName>
 | 
			
		||||
    <FontName>Tahoma</FontName>
 | 
			
		||||
 | 
			
		||||
    <!--
 | 
			
		||||
    Size is a float value, measured in points. Modify this value to change
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										12
									
								
								SpacePew/Content/GeonBit.UI/themes/editor/ThemeData.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								SpacePew/Content/GeonBit.UI/themes/editor/ThemeData.xml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,12 @@
 | 
			
		||||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<XnaContent xmlns:ns="Microsoft.Xna.Framework">
 | 
			
		||||
  <Asset Type="GeonBit.UI.DataTypes.ThemeSettings">
 | 
			
		||||
    <ThemeName>Clean</ThemeName>
 | 
			
		||||
    <AuthorName>Ronen Ness</AuthorName>
 | 
			
		||||
    <Description>A simple, editor-like UI theme.</Description>
 | 
			
		||||
    <Credits>Made by Ronen Ness</Credits>
 | 
			
		||||
    <Version>1.0.0</Version>
 | 
			
		||||
    <RepoUrl></RepoUrl>
 | 
			
		||||
	<License>MIT</License>
 | 
			
		||||
  </Asset>
 | 
			
		||||
</XnaContent>
 | 
			
		||||
@@ -0,0 +1,38 @@
 | 
			
		||||
#if OPENGL
 | 
			
		||||
	#define SV_POSITION POSITION
 | 
			
		||||
	#define VS_SHADERMODEL vs_3_0
 | 
			
		||||
	#define PS_SHADERMODEL ps_3_0
 | 
			
		||||
#else
 | 
			
		||||
	#define VS_SHADERMODEL vs_4_0_level_9_1
 | 
			
		||||
	#define PS_SHADERMODEL ps_4_0_level_9_1
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
Texture2D SpriteTexture;
 | 
			
		||||
 | 
			
		||||
sampler2D SpriteTextureSampler = sampler_state
 | 
			
		||||
{
 | 
			
		||||
	Texture = <SpriteTexture>;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct VertexShaderOutput
 | 
			
		||||
{
 | 
			
		||||
	float4 Position : SV_POSITION;
 | 
			
		||||
	float4 Color : COLOR0;
 | 
			
		||||
	float2 TextureCoordinates : TEXCOORD0;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
float4 MainPS(VertexShaderOutput input) : COLOR
 | 
			
		||||
{
 | 
			
		||||
	float4 color = tex2D(SpriteTextureSampler,input.TextureCoordinates) * input.Color;
 | 
			
		||||
	float value = (color.r + color.g + color.b) / 3;
 | 
			
		||||
	color.r = color.g = color.b = value;
 | 
			
		||||
	return color;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
technique SpriteDrawing
 | 
			
		||||
{
 | 
			
		||||
	pass P0
 | 
			
		||||
	{
 | 
			
		||||
		PixelShader = compile PS_SHADERMODEL MainPS();
 | 
			
		||||
	}
 | 
			
		||||
};
 | 
			
		||||
@@ -0,0 +1,39 @@
 | 
			
		||||
#if OPENGL
 | 
			
		||||
	#define SV_POSITION POSITION
 | 
			
		||||
	#define VS_SHADERMODEL vs_3_0
 | 
			
		||||
	#define PS_SHADERMODEL ps_3_0
 | 
			
		||||
#else
 | 
			
		||||
	#define VS_SHADERMODEL vs_4_0_level_9_1
 | 
			
		||||
	#define PS_SHADERMODEL ps_4_0_level_9_1
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
Texture2D SpriteTexture;
 | 
			
		||||
 | 
			
		||||
sampler2D SpriteTextureSampler = sampler_state
 | 
			
		||||
{
 | 
			
		||||
	Texture = <SpriteTexture>;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct VertexShaderOutput
 | 
			
		||||
{
 | 
			
		||||
	float4 Position : SV_POSITION;
 | 
			
		||||
	float4 Color : COLOR0;
 | 
			
		||||
	float2 TextureCoordinates : TEXCOORD0;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
float4 MainPS(VertexShaderOutput input) : COLOR
 | 
			
		||||
{
 | 
			
		||||
	float4 color = tex2D(SpriteTextureSampler,input.TextureCoordinates) * input.Color;
 | 
			
		||||
    color.r = 1 * color.a * input.Color.r;
 | 
			
		||||
    color.g = 1 * color.a * input.Color.g;
 | 
			
		||||
    color.b = 1 * color.a * input.Color.b;
 | 
			
		||||
	return color;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
technique SpriteDrawing
 | 
			
		||||
{
 | 
			
		||||
	pass P0
 | 
			
		||||
	{
 | 
			
		||||
		PixelShader = compile PS_SHADERMODEL MainPS();
 | 
			
		||||
	}
 | 
			
		||||
};
 | 
			
		||||
@@ -0,0 +1,60 @@
 | 
			
		||||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<!--
 | 
			
		||||
This file contains an xml description of a font, and will be read by the XNA
 | 
			
		||||
Framework Content Pipeline. Follow the comments to customize the appearance
 | 
			
		||||
of the font in your game, and to change the characters which are available to draw
 | 
			
		||||
with.
 | 
			
		||||
-->
 | 
			
		||||
<XnaContent xmlns:Graphics="Microsoft.Xna.Framework.Content.Pipeline.Graphics">
 | 
			
		||||
  <Asset Type="Graphics:FontDescription">
 | 
			
		||||
 | 
			
		||||
    <!--
 | 
			
		||||
    Modify this string to change the font that will be imported.
 | 
			
		||||
    -->
 | 
			
		||||
    <FontName>Bitstream Vera Sans Mono Bold</FontName>
 | 
			
		||||
 | 
			
		||||
    <!--
 | 
			
		||||
    Size is a float value, measured in points. Modify this value to change
 | 
			
		||||
    the size of the font.
 | 
			
		||||
    -->
 | 
			
		||||
    <Size>16</Size>
 | 
			
		||||
 | 
			
		||||
    <!--
 | 
			
		||||
    Spacing is a float value, measured in pixels. Modify this value to change
 | 
			
		||||
    the amount of spacing in between characters.
 | 
			
		||||
    -->
 | 
			
		||||
    <Spacing>0</Spacing>
 | 
			
		||||
 | 
			
		||||
    <!--
 | 
			
		||||
    UseKerning controls the layout of the font. If this value is true, kerning information
 | 
			
		||||
    will be used when placing characters.
 | 
			
		||||
    -->
 | 
			
		||||
    <UseKerning>true</UseKerning>
 | 
			
		||||
 | 
			
		||||
    <!--
 | 
			
		||||
    Style controls the style of the font. Valid entries are "Regular", "Bold", "Italic",
 | 
			
		||||
    and "Bold, Italic", and are case sensitive.
 | 
			
		||||
    -->
 | 
			
		||||
    <Style>Regular</Style>
 | 
			
		||||
 | 
			
		||||
    <!--
 | 
			
		||||
    If you uncomment this line, the default character will be substituted if you draw
 | 
			
		||||
    or measure text that contains characters which were not included in the font.
 | 
			
		||||
    -->
 | 
			
		||||
    <!-- <DefaultCharacter>*</DefaultCharacter> -->
 | 
			
		||||
 | 
			
		||||
    <!--
 | 
			
		||||
    CharacterRegions control what letters are available in the font. Every
 | 
			
		||||
    character from Start to End will be built and made available for drawing. The
 | 
			
		||||
    default range is from 32, (ASCII space), to 126, ('~'), covering the basic Latin
 | 
			
		||||
    character set. The characters are ordered according to the Unicode standard.
 | 
			
		||||
    See the documentation for more information.
 | 
			
		||||
    -->
 | 
			
		||||
    <CharacterRegions>
 | 
			
		||||
      <CharacterRegion>
 | 
			
		||||
        <Start> </Start>
 | 
			
		||||
        <End>~</End>
 | 
			
		||||
      </CharacterRegion>
 | 
			
		||||
    </CharacterRegions>
 | 
			
		||||
  </Asset>
 | 
			
		||||
</XnaContent>
 | 
			
		||||
@@ -0,0 +1,60 @@
 | 
			
		||||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<!--
 | 
			
		||||
This file contains an xml description of a font, and will be read by the XNA
 | 
			
		||||
Framework Content Pipeline. Follow the comments to customize the appearance
 | 
			
		||||
of the font in your game, and to change the characters which are available to draw
 | 
			
		||||
with.
 | 
			
		||||
-->
 | 
			
		||||
<XnaContent xmlns:Graphics="Microsoft.Xna.Framework.Content.Pipeline.Graphics">
 | 
			
		||||
  <Asset Type="Graphics:FontDescription">
 | 
			
		||||
 | 
			
		||||
    <!--
 | 
			
		||||
    Modify this string to change the font that will be imported.
 | 
			
		||||
    -->
 | 
			
		||||
    <FontName>Bitstream Vera Sans Mono Oblique</FontName>
 | 
			
		||||
 | 
			
		||||
    <!--
 | 
			
		||||
    Size is a float value, measured in points. Modify this value to change
 | 
			
		||||
    the size of the font.
 | 
			
		||||
    -->
 | 
			
		||||
    <Size>16</Size>
 | 
			
		||||
 | 
			
		||||
    <!--
 | 
			
		||||
    Spacing is a float value, measured in pixels. Modify this value to change
 | 
			
		||||
    the amount of spacing in between characters.
 | 
			
		||||
    -->
 | 
			
		||||
    <Spacing>0</Spacing>
 | 
			
		||||
 | 
			
		||||
    <!--
 | 
			
		||||
    UseKerning controls the layout of the font. If this value is true, kerning information
 | 
			
		||||
    will be used when placing characters.
 | 
			
		||||
    -->
 | 
			
		||||
    <UseKerning>true</UseKerning>
 | 
			
		||||
 | 
			
		||||
    <!--
 | 
			
		||||
    Style controls the style of the font. Valid entries are "Regular", "Bold", "Italic",
 | 
			
		||||
    and "Bold, Italic", and are case sensitive.
 | 
			
		||||
    -->
 | 
			
		||||
    <Style>Italic</Style>
 | 
			
		||||
 | 
			
		||||
    <!--
 | 
			
		||||
    If you uncomment this line, the default character will be substituted if you draw
 | 
			
		||||
    or measure text that contains characters which were not included in the font.
 | 
			
		||||
    -->
 | 
			
		||||
    <!-- <DefaultCharacter>*</DefaultCharacter> -->
 | 
			
		||||
 | 
			
		||||
    <!--
 | 
			
		||||
    CharacterRegions control what letters are available in the font. Every
 | 
			
		||||
    character from Start to End will be built and made available for drawing. The
 | 
			
		||||
    default range is from 32, (ASCII space), to 126, ('~'), covering the basic Latin
 | 
			
		||||
    character set. The characters are ordered according to the Unicode standard.
 | 
			
		||||
    See the documentation for more information.
 | 
			
		||||
    -->
 | 
			
		||||
    <CharacterRegions>
 | 
			
		||||
      <CharacterRegion>
 | 
			
		||||
        <Start> </Start>
 | 
			
		||||
        <End>~</End>
 | 
			
		||||
      </CharacterRegion>
 | 
			
		||||
    </CharacterRegions>
 | 
			
		||||
  </Asset>
 | 
			
		||||
</XnaContent>
 | 
			
		||||
@@ -0,0 +1,60 @@
 | 
			
		||||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<!--
 | 
			
		||||
This file contains an xml description of a font, and will be read by the XNA
 | 
			
		||||
Framework Content Pipeline. Follow the comments to customize the appearance
 | 
			
		||||
of the font in your game, and to change the characters which are available to draw
 | 
			
		||||
with.
 | 
			
		||||
-->
 | 
			
		||||
<XnaContent xmlns:Graphics="Microsoft.Xna.Framework.Content.Pipeline.Graphics">
 | 
			
		||||
  <Asset Type="Graphics:FontDescription">
 | 
			
		||||
 | 
			
		||||
    <!--
 | 
			
		||||
    Modify this string to change the font that will be imported.
 | 
			
		||||
    -->
 | 
			
		||||
    <FontName>Bitstream Vera Sans Mono Roman</FontName>
 | 
			
		||||
 | 
			
		||||
    <!--
 | 
			
		||||
    Size is a float value, measured in points. Modify this value to change
 | 
			
		||||
    the size of the font.
 | 
			
		||||
    -->
 | 
			
		||||
    <Size>16</Size>
 | 
			
		||||
 | 
			
		||||
    <!--
 | 
			
		||||
    Spacing is a float value, measured in pixels. Modify this value to change
 | 
			
		||||
    the amount of spacing in between characters.
 | 
			
		||||
    -->
 | 
			
		||||
    <Spacing>0</Spacing>
 | 
			
		||||
 | 
			
		||||
    <!--
 | 
			
		||||
    UseKerning controls the layout of the font. If this value is true, kerning information
 | 
			
		||||
    will be used when placing characters.
 | 
			
		||||
    -->
 | 
			
		||||
    <UseKerning>true</UseKerning>
 | 
			
		||||
 | 
			
		||||
    <!--
 | 
			
		||||
    Style controls the style of the font. Valid entries are "Regular", "Bold", "Italic",
 | 
			
		||||
    and "Bold, Italic", and are case sensitive.
 | 
			
		||||
    -->
 | 
			
		||||
    <Style>Regular</Style>
 | 
			
		||||
 | 
			
		||||
    <!--
 | 
			
		||||
    If you uncomment this line, the default character will be substituted if you draw
 | 
			
		||||
    or measure text that contains characters which were not included in the font.
 | 
			
		||||
    -->
 | 
			
		||||
    <!-- <DefaultCharacter>*</DefaultCharacter> -->
 | 
			
		||||
 | 
			
		||||
    <!--
 | 
			
		||||
    CharacterRegions control what letters are available in the font. Every
 | 
			
		||||
    character from Start to End will be built and made available for drawing. The
 | 
			
		||||
    default range is from 32, (ASCII space), to 126, ('~'), covering the basic Latin
 | 
			
		||||
    character set. The characters are ordered according to the Unicode standard.
 | 
			
		||||
    See the documentation for more information.
 | 
			
		||||
    -->
 | 
			
		||||
    <CharacterRegions>
 | 
			
		||||
      <CharacterRegion>
 | 
			
		||||
        <Start> </Start>
 | 
			
		||||
        <End>~</End>
 | 
			
		||||
      </CharacterRegion>
 | 
			
		||||
    </CharacterRegions>
 | 
			
		||||
  </Asset>
 | 
			
		||||
</XnaContent>
 | 
			
		||||
@@ -0,0 +1,19 @@
 | 
			
		||||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<XnaContent xmlns:ns="Microsoft.Xna.Framework">
 | 
			
		||||
  <Asset Type="GeonBit.UI.DataTypes.DefaultStyles">
 | 
			
		||||
    <Scale>2.2</Scale>
 | 
			
		||||
    <FillColor Null="true" />
 | 
			
		||||
    <OutlineColor Null="true" />
 | 
			
		||||
    <OutlineWidth Null="true" />
 | 
			
		||||
    <ForceAlignCenter Null="true" />
 | 
			
		||||
    <FontStyle Null="true" />
 | 
			
		||||
    <SelectedHighlightColor Null="true" />
 | 
			
		||||
    <ShadowColor Null="true" />
 | 
			
		||||
    <ShadowOffset Null="true" />
 | 
			
		||||
    <Padding Null="true" />
 | 
			
		||||
    <SpaceBefore Null="true" />
 | 
			
		||||
    <SpaceAfter Null="true" />
 | 
			
		||||
    <ShadowScale Null="true" />
 | 
			
		||||
  </Asset>
 | 
			
		||||
        
 | 
			
		||||
</XnaContent>
 | 
			
		||||
@@ -0,0 +1,19 @@
 | 
			
		||||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<XnaContent xmlns:ns="Microsoft.Xna.Framework">
 | 
			
		||||
  <Asset Type="GeonBit.UI.DataTypes.DefaultStyles">
 | 
			
		||||
    <Scale Null="true" />
 | 
			
		||||
    <FillColor Null="true" />
 | 
			
		||||
    <OutlineColor Null="true" />
 | 
			
		||||
    <OutlineWidth Null="true" />
 | 
			
		||||
    <ForceAlignCenter Null="true" />
 | 
			
		||||
    <FontStyle Null="true" />
 | 
			
		||||
    <SelectedHighlightColor Null="true" />
 | 
			
		||||
    <ShadowColor Null="true" />
 | 
			
		||||
    <ShadowOffset Null="true" />
 | 
			
		||||
    <Padding Null="true" />
 | 
			
		||||
    <SpaceBefore Null="true" />
 | 
			
		||||
    <SpaceAfter Null="true" />
 | 
			
		||||
    <ShadowScale Null="true" />
 | 
			
		||||
  </Asset>
 | 
			
		||||
        
 | 
			
		||||
</XnaContent>
 | 
			
		||||
@@ -0,0 +1,19 @@
 | 
			
		||||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<XnaContent xmlns:ns="Microsoft.Xna.Framework">
 | 
			
		||||
  <Asset Type="GeonBit.UI.DataTypes.DefaultStyles">
 | 
			
		||||
    <Scale Null="true" />
 | 
			
		||||
    <FillColor Null="true" />
 | 
			
		||||
    <OutlineColor Null="true" />
 | 
			
		||||
    <OutlineWidth Null="true" />
 | 
			
		||||
    <ForceAlignCenter Null="true" />
 | 
			
		||||
    <FontStyle Null="true" />
 | 
			
		||||
    <SelectedHighlightColor Null="true" />
 | 
			
		||||
    <ShadowColor Null="true" />
 | 
			
		||||
    <ShadowOffset Null="true" />
 | 
			
		||||
    <Padding Null="true" />
 | 
			
		||||
    <SpaceBefore Null="true" />
 | 
			
		||||
    <SpaceAfter Null="true" />
 | 
			
		||||
    <ShadowScale Null="true" />
 | 
			
		||||
  </Asset>
 | 
			
		||||
        
 | 
			
		||||
</XnaContent>
 | 
			
		||||
@@ -0,0 +1,19 @@
 | 
			
		||||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<XnaContent xmlns:ns="Microsoft.Xna.Framework">
 | 
			
		||||
  <Asset Type="GeonBit.UI.DataTypes.DefaultStyles">
 | 
			
		||||
    <Scale>1.2</Scale>
 | 
			
		||||
    <FillColor Null="true" />
 | 
			
		||||
    <OutlineColor Null="true" />
 | 
			
		||||
    <OutlineWidth Null="true" />
 | 
			
		||||
    <ForceAlignCenter Null="true" />
 | 
			
		||||
    <FontStyle Null="true" />
 | 
			
		||||
    <SelectedHighlightColor Null="true" />
 | 
			
		||||
    <ShadowColor Null="true" />
 | 
			
		||||
    <ShadowOffset Null="true" />
 | 
			
		||||
    <Padding Null="true" />
 | 
			
		||||
    <SpaceBefore Null="true" />
 | 
			
		||||
    <SpaceAfter Null="true" />
 | 
			
		||||
    <ShadowScale Null="true" />
 | 
			
		||||
  </Asset>
 | 
			
		||||
        
 | 
			
		||||
</XnaContent>
 | 
			
		||||
@@ -0,0 +1,19 @@
 | 
			
		||||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<XnaContent xmlns:ns="Microsoft.Xna.Framework">
 | 
			
		||||
  <Asset Type="GeonBit.UI.DataTypes.DefaultStyles">
 | 
			
		||||
    <Scale Null="true" />
 | 
			
		||||
    <FillColor>FFAAAAAA</FillColor>
 | 
			
		||||
    <OutlineColor Null="true" />
 | 
			
		||||
    <OutlineWidth Null="true" />
 | 
			
		||||
    <ForceAlignCenter Null="true" />
 | 
			
		||||
    <FontStyle Null="true" />
 | 
			
		||||
    <SelectedHighlightColor Null="true" />
 | 
			
		||||
    <ShadowColor Null="true" />
 | 
			
		||||
    <ShadowOffset Null="true" />
 | 
			
		||||
    <Padding Null="true" />
 | 
			
		||||
    <SpaceBefore Null="true" />
 | 
			
		||||
    <SpaceAfter Null="true" />
 | 
			
		||||
    <ShadowScale Null="true" />
 | 
			
		||||
  </Asset>
 | 
			
		||||
        
 | 
			
		||||
</XnaContent>
 | 
			
		||||
@@ -0,0 +1,19 @@
 | 
			
		||||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<XnaContent xmlns:ns="Microsoft.Xna.Framework">
 | 
			
		||||
  <Asset Type="GeonBit.UI.DataTypes.DefaultStyles">
 | 
			
		||||
    <Scale Null="true" />
 | 
			
		||||
    <FillColor Null="true" />
 | 
			
		||||
    <OutlineColor Null="true" />
 | 
			
		||||
    <OutlineWidth Null="true" />
 | 
			
		||||
    <ForceAlignCenter Null="true" />
 | 
			
		||||
    <FontStyle Null="true" />
 | 
			
		||||
    <SelectedHighlightColor Null="true" />
 | 
			
		||||
    <ShadowColor Null="true" />
 | 
			
		||||
    <ShadowOffset Null="true" />
 | 
			
		||||
    <Padding Null="true" />
 | 
			
		||||
    <SpaceBefore Null="true" />
 | 
			
		||||
    <SpaceAfter Null="true" />
 | 
			
		||||
    <ShadowScale Null="true" />
 | 
			
		||||
  </Asset>
 | 
			
		||||
        
 | 
			
		||||
</XnaContent>
 | 
			
		||||
@@ -0,0 +1,19 @@
 | 
			
		||||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<XnaContent xmlns:ns="Microsoft.Xna.Framework">
 | 
			
		||||
  <Asset Type="GeonBit.UI.DataTypes.DefaultStyles">
 | 
			
		||||
    <Scale Null="true" />
 | 
			
		||||
    <FillColor Null="true" />
 | 
			
		||||
    <OutlineColor Null="true" />
 | 
			
		||||
    <OutlineWidth Null="true" />
 | 
			
		||||
    <ForceAlignCenter Null="true" />
 | 
			
		||||
    <FontStyle Null="true" />
 | 
			
		||||
    <SelectedHighlightColor Null="true" />
 | 
			
		||||
    <ShadowColor Null="true" />
 | 
			
		||||
    <ShadowOffset Null="true" />
 | 
			
		||||
    <Padding Null="true" />
 | 
			
		||||
    <SpaceBefore Null="true" />
 | 
			
		||||
    <SpaceAfter Null="true" />
 | 
			
		||||
    <ShadowScale Null="true" />
 | 
			
		||||
  </Asset>
 | 
			
		||||
        
 | 
			
		||||
</XnaContent>
 | 
			
		||||
@@ -0,0 +1,19 @@
 | 
			
		||||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<XnaContent xmlns:ns="Microsoft.Xna.Framework">
 | 
			
		||||
  <Asset Type="GeonBit.UI.DataTypes.DefaultStyles">
 | 
			
		||||
    <Scale Null="true" />
 | 
			
		||||
    <FillColor Null="true" />
 | 
			
		||||
    <OutlineColor Null="true" />
 | 
			
		||||
    <OutlineWidth Null="true" />
 | 
			
		||||
    <ForceAlignCenter Null="true" />
 | 
			
		||||
    <FontStyle Null="true" />
 | 
			
		||||
    <SelectedHighlightColor Null="true" />
 | 
			
		||||
    <ShadowColor Null="true" />
 | 
			
		||||
    <ShadowOffset Null="true" />
 | 
			
		||||
    <Padding Null="true" />
 | 
			
		||||
    <SpaceBefore Null="true" />
 | 
			
		||||
    <SpaceAfter Null="true" />
 | 
			
		||||
    <ShadowScale Null="true" />
 | 
			
		||||
  </Asset>
 | 
			
		||||
        
 | 
			
		||||
</XnaContent>
 | 
			
		||||
@@ -0,0 +1,19 @@
 | 
			
		||||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<XnaContent xmlns:ns="Microsoft.Xna.Framework">
 | 
			
		||||
  <Asset Type="GeonBit.UI.DataTypes.DefaultStyles">
 | 
			
		||||
    <Scale Null="true" />
 | 
			
		||||
    <FillColor Null="true" />
 | 
			
		||||
    <OutlineColor Null="true" />
 | 
			
		||||
    <OutlineWidth Null="true" />
 | 
			
		||||
    <ForceAlignCenter Null="true" />
 | 
			
		||||
    <FontStyle Null="true" />
 | 
			
		||||
    <SelectedHighlightColor Null="true" />
 | 
			
		||||
    <ShadowColor Null="true" />
 | 
			
		||||
    <ShadowOffset Null="true" />
 | 
			
		||||
    <Padding Null="true" />
 | 
			
		||||
    <SpaceBefore Null="true" />
 | 
			
		||||
    <SpaceAfter Null="true" />
 | 
			
		||||
    <ShadowScale Null="true" />
 | 
			
		||||
  </Asset>
 | 
			
		||||
        
 | 
			
		||||
</XnaContent>
 | 
			
		||||
@@ -0,0 +1,19 @@
 | 
			
		||||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<XnaContent xmlns:ns="Microsoft.Xna.Framework">
 | 
			
		||||
  <Asset Type="GeonBit.UI.DataTypes.DefaultStyles">
 | 
			
		||||
    <Scale>1.15</Scale>
 | 
			
		||||
    <FillColor Null="true" />
 | 
			
		||||
    <OutlineColor Null="true" />
 | 
			
		||||
    <OutlineWidth Null="true" />
 | 
			
		||||
    <ForceAlignCenter Null="true" />
 | 
			
		||||
    <FontStyle Null="true" />
 | 
			
		||||
    <SelectedHighlightColor Null="true" />
 | 
			
		||||
    <ShadowColor Null="true" />
 | 
			
		||||
    <ShadowOffset Null="true" />
 | 
			
		||||
    <Padding Null="true" />
 | 
			
		||||
    <SpaceBefore Null="true" />
 | 
			
		||||
    <SpaceAfter Null="true" />
 | 
			
		||||
    <ShadowScale Null="true" />
 | 
			
		||||
  </Asset>
 | 
			
		||||
        
 | 
			
		||||
</XnaContent>
 | 
			
		||||
@@ -0,0 +1,19 @@
 | 
			
		||||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<XnaContent xmlns:ns="Microsoft.Xna.Framework">
 | 
			
		||||
  <Asset Type="GeonBit.UI.DataTypes.DefaultStyles">
 | 
			
		||||
    <Scale Null="true" />
 | 
			
		||||
    <FillColor>FF00FFFF</FillColor>
 | 
			
		||||
    <OutlineColor Null="true" />
 | 
			
		||||
    <OutlineWidth Null="true" />
 | 
			
		||||
    <ForceAlignCenter Null="true" />
 | 
			
		||||
    <FontStyle Null="true" />
 | 
			
		||||
    <SelectedHighlightColor Null="true" />
 | 
			
		||||
    <ShadowColor Null="true" />
 | 
			
		||||
    <ShadowOffset Null="true" />
 | 
			
		||||
    <Padding Null="true" />
 | 
			
		||||
    <SpaceBefore Null="true" />
 | 
			
		||||
    <SpaceAfter Null="true" />
 | 
			
		||||
    <ShadowScale Null="true" />
 | 
			
		||||
  </Asset>
 | 
			
		||||
        
 | 
			
		||||
</XnaContent>
 | 
			
		||||
@@ -0,0 +1,19 @@
 | 
			
		||||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<XnaContent xmlns:ns="Microsoft.Xna.Framework">
 | 
			
		||||
  <Asset Type="GeonBit.UI.DataTypes.DefaultStyles">
 | 
			
		||||
    <Scale Null="true" />
 | 
			
		||||
    <FillColor>FF00FFFF</FillColor>
 | 
			
		||||
    <OutlineColor Null="true" />
 | 
			
		||||
    <OutlineWidth Null="true" />
 | 
			
		||||
    <ForceAlignCenter Null="true" />
 | 
			
		||||
    <FontStyle Null="true" />
 | 
			
		||||
    <SelectedHighlightColor Null="true" />
 | 
			
		||||
    <ShadowColor Null="true" />
 | 
			
		||||
    <ShadowOffset Null="true" />
 | 
			
		||||
    <Padding Null="true" />
 | 
			
		||||
    <SpaceBefore Null="true" />
 | 
			
		||||
    <SpaceAfter Null="true" />
 | 
			
		||||
    <ShadowScale Null="true" />
 | 
			
		||||
  </Asset>
 | 
			
		||||
        
 | 
			
		||||
</XnaContent>
 | 
			
		||||
@@ -0,0 +1,19 @@
 | 
			
		||||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<XnaContent xmlns:ns="Microsoft.Xna.Framework">
 | 
			
		||||
  <Asset Type="GeonBit.UI.DataTypes.DefaultStyles">
 | 
			
		||||
    <Scale Null="true" />
 | 
			
		||||
    <FillColor>FFFFFFFF</FillColor>
 | 
			
		||||
    <OutlineColor>FF000000</OutlineColor>
 | 
			
		||||
    <OutlineWidth>2</OutlineWidth>
 | 
			
		||||
    <ForceAlignCenter Null="true" />
 | 
			
		||||
    <FontStyle Null="true" />
 | 
			
		||||
    <SelectedHighlightColor Null="true" />
 | 
			
		||||
    <ShadowColor Null="true" />
 | 
			
		||||
    <ShadowOffset Null="true" />
 | 
			
		||||
    <Padding Null="true" />
 | 
			
		||||
    <SpaceBefore Null="true" />
 | 
			
		||||
    <SpaceAfter Null="true" />
 | 
			
		||||
    <ShadowScale Null="true" />
 | 
			
		||||
  </Asset>
 | 
			
		||||
        
 | 
			
		||||
</XnaContent>
 | 
			
		||||
@@ -0,0 +1,19 @@
 | 
			
		||||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<XnaContent xmlns:ns="Microsoft.Xna.Framework">
 | 
			
		||||
  <Asset Type="GeonBit.UI.DataTypes.DefaultStyles">
 | 
			
		||||
    <Scale Null="true" />
 | 
			
		||||
    <FillColor Null="true" />
 | 
			
		||||
    <OutlineColor Null="true" />
 | 
			
		||||
    <OutlineWidth Null="true" />
 | 
			
		||||
    <ForceAlignCenter Null="true" />
 | 
			
		||||
    <FontStyle Null="true" />
 | 
			
		||||
    <SelectedHighlightColor Null="true" />
 | 
			
		||||
    <ShadowColor Null="true" />
 | 
			
		||||
    <ShadowOffset Null="true" />
 | 
			
		||||
    <Padding Null="true" />
 | 
			
		||||
    <SpaceBefore Null="true" />
 | 
			
		||||
    <SpaceAfter Null="true" />
 | 
			
		||||
    <ShadowScale Null="true" />
 | 
			
		||||
  </Asset>
 | 
			
		||||
        
 | 
			
		||||
</XnaContent>
 | 
			
		||||
@@ -0,0 +1,19 @@
 | 
			
		||||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<XnaContent xmlns:ns="Microsoft.Xna.Framework">
 | 
			
		||||
  <Asset Type="GeonBit.UI.DataTypes.DefaultStyles">
 | 
			
		||||
    <Scale Null="true" />
 | 
			
		||||
    <FillColor Null="true" />
 | 
			
		||||
    <OutlineColor Null="true" />
 | 
			
		||||
    <OutlineWidth Null="true" />
 | 
			
		||||
    <ForceAlignCenter Null="true" />
 | 
			
		||||
    <FontStyle Null="true" />
 | 
			
		||||
    <SelectedHighlightColor Null="true" />
 | 
			
		||||
    <ShadowColor Null="true" />
 | 
			
		||||
    <ShadowOffset Null="true" />
 | 
			
		||||
    <Padding Null="true" />
 | 
			
		||||
    <SpaceBefore Null="true" />
 | 
			
		||||
    <SpaceAfter Null="true" />
 | 
			
		||||
    <ShadowScale Null="true" />
 | 
			
		||||
  </Asset>
 | 
			
		||||
        
 | 
			
		||||
</XnaContent>
 | 
			
		||||
@@ -0,0 +1,19 @@
 | 
			
		||||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<XnaContent xmlns:ns="Microsoft.Xna.Framework">
 | 
			
		||||
  <Asset Type="GeonBit.UI.DataTypes.DefaultStyles">
 | 
			
		||||
    <Scale Null="true" />
 | 
			
		||||
    <FillColor Null="true" />
 | 
			
		||||
    <OutlineColor Null="true" />
 | 
			
		||||
    <OutlineWidth Null="true" />
 | 
			
		||||
    <ForceAlignCenter Null="true" />
 | 
			
		||||
    <FontStyle Null="true" />
 | 
			
		||||
    <SelectedHighlightColor Null="true" />
 | 
			
		||||
    <ShadowColor Null="true" />
 | 
			
		||||
    <ShadowOffset Null="true" />
 | 
			
		||||
    <Padding Null="true" />
 | 
			
		||||
    <SpaceBefore Null="true" />
 | 
			
		||||
    <SpaceAfter Null="true" />
 | 
			
		||||
    <ShadowScale Null="true" />
 | 
			
		||||
  </Asset>
 | 
			
		||||
        
 | 
			
		||||
</XnaContent>
 | 
			
		||||
@@ -0,0 +1,19 @@
 | 
			
		||||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<XnaContent xmlns:ns="Microsoft.Xna.Framework">
 | 
			
		||||
  <Asset Type="GeonBit.UI.DataTypes.DefaultStyles">
 | 
			
		||||
    <Scale Null="true" />
 | 
			
		||||
    <FillColor Null="true" />
 | 
			
		||||
    <OutlineColor Null="true" />
 | 
			
		||||
    <OutlineWidth Null="true" />
 | 
			
		||||
    <ForceAlignCenter Null="true" />
 | 
			
		||||
    <FontStyle Null="true" />
 | 
			
		||||
    <SelectedHighlightColor Null="true" />
 | 
			
		||||
    <ShadowColor Null="true" />
 | 
			
		||||
    <ShadowOffset Null="true" />
 | 
			
		||||
    <Padding Null="true" />
 | 
			
		||||
    <SpaceBefore Null="true" />
 | 
			
		||||
    <SpaceAfter Null="true" />
 | 
			
		||||
    <ShadowScale Null="true" />
 | 
			
		||||
  </Asset>
 | 
			
		||||
        
 | 
			
		||||
</XnaContent>
 | 
			
		||||
@@ -0,0 +1,19 @@
 | 
			
		||||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<XnaContent xmlns:ns="Microsoft.Xna.Framework">
 | 
			
		||||
  <Asset Type="GeonBit.UI.DataTypes.DefaultStyles">
 | 
			
		||||
    <Scale Null="true" />
 | 
			
		||||
    <FillColor Null="true" />
 | 
			
		||||
    <OutlineColor Null="true" />
 | 
			
		||||
    <OutlineWidth Null="true" />
 | 
			
		||||
    <ForceAlignCenter Null="true" />
 | 
			
		||||
    <FontStyle Null="true" />
 | 
			
		||||
    <SelectedHighlightColor Null="true" />
 | 
			
		||||
    <ShadowColor Null="true" />
 | 
			
		||||
    <ShadowOffset Null="true" />
 | 
			
		||||
    <Padding Null="true" />
 | 
			
		||||
    <SpaceBefore Null="true" />
 | 
			
		||||
    <SpaceAfter Null="true" />
 | 
			
		||||
    <ShadowScale Null="true" />
 | 
			
		||||
  </Asset>
 | 
			
		||||
        
 | 
			
		||||
</XnaContent>
 | 
			
		||||
@@ -0,0 +1,19 @@
 | 
			
		||||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<XnaContent xmlns:ns="Microsoft.Xna.Framework">
 | 
			
		||||
  <Asset Type="GeonBit.UI.DataTypes.DefaultStyles">
 | 
			
		||||
    <Scale Null="true" />
 | 
			
		||||
    <FillColor Null="true" />
 | 
			
		||||
    <OutlineColor Null="true" />
 | 
			
		||||
    <OutlineWidth Null="true" />
 | 
			
		||||
    <ForceAlignCenter Null="true" />
 | 
			
		||||
    <FontStyle Null="true" />
 | 
			
		||||
    <SelectedHighlightColor Null="true" />
 | 
			
		||||
    <ShadowColor Null="true" />
 | 
			
		||||
    <ShadowOffset Null="true" />
 | 
			
		||||
    <Padding Null="true" />
 | 
			
		||||
    <SpaceBefore Null="true" />
 | 
			
		||||
    <SpaceAfter Null="true" />
 | 
			
		||||
    <ShadowScale Null="true" />
 | 
			
		||||
  </Asset>
 | 
			
		||||
        
 | 
			
		||||
</XnaContent>
 | 
			
		||||
@@ -0,0 +1,19 @@
 | 
			
		||||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<XnaContent xmlns:ns="Microsoft.Xna.Framework">
 | 
			
		||||
  <Asset Type="GeonBit.UI.DataTypes.DefaultStyles">
 | 
			
		||||
    <Scale Null="true" />
 | 
			
		||||
    <FillColor Null="true" />
 | 
			
		||||
    <OutlineColor Null="true" />
 | 
			
		||||
    <OutlineWidth Null="true" />
 | 
			
		||||
    <ForceAlignCenter Null="true" />
 | 
			
		||||
    <FontStyle Null="true" />
 | 
			
		||||
    <SelectedHighlightColor Null="true" />
 | 
			
		||||
    <ShadowColor Null="true" />
 | 
			
		||||
    <ShadowOffset Null="true" />
 | 
			
		||||
    <Padding Null="true" />
 | 
			
		||||
    <SpaceBefore Null="true" />
 | 
			
		||||
    <SpaceAfter Null="true" />
 | 
			
		||||
    <ShadowScale Null="true" />
 | 
			
		||||
  </Asset>
 | 
			
		||||
        
 | 
			
		||||
</XnaContent>
 | 
			
		||||
@@ -0,0 +1,19 @@
 | 
			
		||||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<XnaContent xmlns:ns="Microsoft.Xna.Framework">
 | 
			
		||||
  <Asset Type="GeonBit.UI.DataTypes.DefaultStyles">
 | 
			
		||||
    <Scale Null="true" />
 | 
			
		||||
    <FillColor Null="true" />
 | 
			
		||||
    <OutlineColor Null="true" />
 | 
			
		||||
    <OutlineWidth Null="true" />
 | 
			
		||||
    <ForceAlignCenter Null="true" />
 | 
			
		||||
    <FontStyle Null="true" />
 | 
			
		||||
    <SelectedHighlightColor Null="true" />
 | 
			
		||||
    <ShadowColor Null="true" />
 | 
			
		||||
    <ShadowOffset Null="true" />
 | 
			
		||||
    <Padding Null="true" />
 | 
			
		||||
    <SpaceBefore Null="true" />
 | 
			
		||||
    <SpaceAfter Null="true" />
 | 
			
		||||
    <ShadowScale Null="true" />
 | 
			
		||||
  </Asset>
 | 
			
		||||
        
 | 
			
		||||
</XnaContent>
 | 
			
		||||
@@ -0,0 +1,19 @@
 | 
			
		||||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<XnaContent xmlns:ns="Microsoft.Xna.Framework">
 | 
			
		||||
  <Asset Type="GeonBit.UI.DataTypes.DefaultStyles">
 | 
			
		||||
    <Scale Null="true" />
 | 
			
		||||
    <FillColor Null="true" />
 | 
			
		||||
    <OutlineColor Null="true" />
 | 
			
		||||
    <OutlineWidth Null="true" />
 | 
			
		||||
    <ForceAlignCenter Null="true" />
 | 
			
		||||
    <FontStyle Null="true" />
 | 
			
		||||
    <SelectedHighlightColor Null="true" />
 | 
			
		||||
    <ShadowColor Null="true" />
 | 
			
		||||
    <ShadowOffset Null="true" />
 | 
			
		||||
    <Padding Null="true" />
 | 
			
		||||
    <SpaceBefore Null="true" />
 | 
			
		||||
    <SpaceAfter Null="true" />
 | 
			
		||||
    <ShadowScale Null="true" />
 | 
			
		||||
  </Asset>
 | 
			
		||||
        
 | 
			
		||||
</XnaContent>
 | 
			
		||||
@@ -0,0 +1,19 @@
 | 
			
		||||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<XnaContent xmlns:ns="Microsoft.Xna.Framework">
 | 
			
		||||
  <Asset Type="GeonBit.UI.DataTypes.DefaultStyles">
 | 
			
		||||
    <Scale Null="true" />
 | 
			
		||||
    <FillColor Null="true" />
 | 
			
		||||
    <OutlineColor Null="true" />
 | 
			
		||||
    <OutlineWidth Null="true" />
 | 
			
		||||
    <ForceAlignCenter Null="true" />
 | 
			
		||||
    <FontStyle Null="true" />
 | 
			
		||||
    <SelectedHighlightColor Null="true" />
 | 
			
		||||
    <ShadowColor Null="true" />
 | 
			
		||||
    <ShadowOffset Null="true" />
 | 
			
		||||
    <Padding Null="true" />
 | 
			
		||||
    <SpaceBefore Null="true" />
 | 
			
		||||
    <SpaceAfter Null="true" />
 | 
			
		||||
    <ShadowScale Null="true" />
 | 
			
		||||
  </Asset>
 | 
			
		||||
        
 | 
			
		||||
</XnaContent>
 | 
			
		||||
@@ -0,0 +1,19 @@
 | 
			
		||||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<XnaContent xmlns:ns="Microsoft.Xna.Framework">
 | 
			
		||||
  <Asset Type="GeonBit.UI.DataTypes.DefaultStyles">
 | 
			
		||||
    <Scale Null="true" />
 | 
			
		||||
    <FillColor Null="true" />
 | 
			
		||||
    <OutlineColor Null="true" />
 | 
			
		||||
    <OutlineWidth Null="true" />
 | 
			
		||||
    <ForceAlignCenter Null="true" />
 | 
			
		||||
    <FontStyle Null="true" />
 | 
			
		||||
    <SelectedHighlightColor Null="true" />
 | 
			
		||||
    <ShadowColor Null="true" />
 | 
			
		||||
    <ShadowOffset Null="true" />
 | 
			
		||||
    <Padding Null="true" />
 | 
			
		||||
    <SpaceBefore Null="true" />
 | 
			
		||||
    <SpaceAfter Null="true" />
 | 
			
		||||
    <ShadowScale Null="true" />
 | 
			
		||||
  </Asset>
 | 
			
		||||
        
 | 
			
		||||
</XnaContent>
 | 
			
		||||
@@ -0,0 +1,18 @@
 | 
			
		||||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<XnaContent xmlns:ns="Microsoft.Xna.Framework">
 | 
			
		||||
  <Asset Type="GeonBit.UI.DataTypes.DefaultStyles">
 | 
			
		||||
    <Scale>1</Scale>
 | 
			
		||||
    <FillColor>FFFFFFFF</FillColor>
 | 
			
		||||
    <OutlineColor>00000000</OutlineColor>
 | 
			
		||||
    <OutlineWidth>0</OutlineWidth>
 | 
			
		||||
    <ForceAlignCenter>false</ForceAlignCenter>
 | 
			
		||||
    <FontStyle>Regular</FontStyle>
 | 
			
		||||
    <SelectedHighlightColor>00000000</SelectedHighlightColor>
 | 
			
		||||
    <ShadowColor>00000000</ShadowColor>
 | 
			
		||||
    <ShadowOffset>0 0</ShadowOffset>
 | 
			
		||||
    <Padding>30 30</Padding>
 | 
			
		||||
    <SpaceBefore>0 0</SpaceBefore>
 | 
			
		||||
    <SpaceAfter>0 8</SpaceAfter>
 | 
			
		||||
    <ShadowScale>1</ShadowScale>
 | 
			
		||||
  </Asset>
 | 
			
		||||
</XnaContent>
 | 
			
		||||
@@ -0,0 +1,19 @@
 | 
			
		||||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<XnaContent xmlns:ns="Microsoft.Xna.Framework">
 | 
			
		||||
  <Asset Type="GeonBit.UI.DataTypes.DefaultStyles">
 | 
			
		||||
    <Scale Null="true" />
 | 
			
		||||
    <FillColor Null="true" />
 | 
			
		||||
    <OutlineColor Null="true" />
 | 
			
		||||
    <OutlineWidth Null="true" />
 | 
			
		||||
    <ForceAlignCenter Null="true" />
 | 
			
		||||
    <FontStyle Null="true" />
 | 
			
		||||
    <SelectedHighlightColor Null="true" />
 | 
			
		||||
    <ShadowColor Null="true" />
 | 
			
		||||
    <ShadowOffset Null="true" />
 | 
			
		||||
    <Padding Null="true" />
 | 
			
		||||
    <SpaceBefore Null="true" />
 | 
			
		||||
    <SpaceAfter Null="true" />
 | 
			
		||||
    <ShadowScale Null="true" />
 | 
			
		||||
  </Asset>
 | 
			
		||||
        
 | 
			
		||||
</XnaContent>
 | 
			
		||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user