Collections.cs :  » Game » RealmForge » CrayzEdsGui » Base » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Game » RealmForge 
RealmForge » CrayzEdsGui » Base » Collections.cs
#region LGPL License

/*************************************************************************
    Crazy Eddie's GUI System (http://crayzedsgui.sourceforge.net)
    Copyright (C)2004 Paul D Turner (crayzed@users.sourceforge.net)
  
  C# Port developed by Chris McGuirk (leedgitar@latenitegames.com)
  Compatible with the Axiom 3D Engine (http://axiomengine.sf.net)

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*************************************************************************/

#endregion LGPL License

#region Using directives

using System;
using System.Collections;
using System.Text;

#endregion

namespace CrayzEdsGui.Base{

  #region WindowList Collection

  public class WindowList {
    ArrayList list = new ArrayList();

    public void Add(Window window) {
      list.Add(window);
    }

    public void Clear() {
      list.Clear();
    }

    public void Insert(int position, Window window) {
      list.Insert(position, window);
    }

    /// <summary>
    ///    Removes an item from the collection.
    /// </summary>
    /// <param name="name"></param>
    public void Remove(string name) {
      Window window = null;

      for(int i = 0; i < list.Count; i++) {
        window = (Window)list[i];

        if(window.Name == name) {
          break;
        }
      }

      if(window != null) {
        list.Remove(window);
      }
    }

    public Window this[string name] {
      get {
        Window window = null;

        for(int i = 0; i < list.Count; i++) {
          window = (Window)list[i];

          if(window.Name == name) {
            return window;
          }
        }

        return null;
      }
    }

    public Window this[int index] {
      get {
        return (Window)list[index];
      }
    }

    public int Count {
      get {
        return list.Count;
      }
    }
  }

  #endregion WindowList Collection

  #region ImageList Collection

  public class ImageList {
    SortedList table = new SortedList();

    public void Add(string name, Image image) {
      table[name] = image;
    }

    public void Clear() {
      table.Clear();
    }

    /// <summary>
    ///    Removes an item from the collection.
    /// </summary>
    /// <param name="name"></param>
    public void Remove(string name) {
      if (table[name] != null) {
        table.Remove(name);
      }
    }

    public Image this[string name] {
      get {
        if (table[name] != null) {
          return (Image) table[name];
        }

        return null;
      }
      set {
        Add(name, value);
      }
    }

    public Image this[int index] {
      get {
        return (Image)table.GetByIndex(index);
      }
    }

    public int Count {
      get {
        return table.Count;
      }
    }
  }

  #endregion ImageList Collection

  #region ImagesetList Collection

  public class ImagesetList {
    SortedList table = new SortedList();

    public void Add(string name, Imageset image) {
      table[name] = image;
    }

    public void Clear() {
      table.Clear();
    }

    /// <summary>
    ///    Removes an item from the collection.
    /// </summary>
    /// <param name="name"></param>
    public void Remove(string name) {
      if (table[name] != null) {
        table.Remove(name);
      }
    }

    public Imageset this[string name] {
      get {
        if (table[name] != null) {
          return (Imageset) table[name];
        }

        return null;
      }
      set {
        Add(name, value);
      }
    }

    public Imageset this[int index] {
      get {
        return (Imageset)table.GetByIndex(index);
      }
    }

    public int Count {
      get {
        return table.Count;
      }
    }
  }

  #endregion ImagesetList Collection

  #region FontList Collection

  public class FontList {
    ArrayList list = new ArrayList();

    public void Add(Font font) {
      list.Add(font);
    }

    public void Clear() {
      list.Clear();
    }

    public void Insert(int position, Window font) {
      list.Insert(position, font);
    }

    /// <summary>
    ///    Removes an item from the collection.
    /// </summary>
    /// <param name="name"></param>
    public void Remove(string name) {
      Font font = null;

      for(int i = 0; i < list.Count; i++) {
        font = (Font)list[i];

        if(font.Name == name) {
          break;
        }
      }

      if(font != null) {
        list.Remove(font);
      }
    }

    public Font this[string name] {
      get {
        Font font = null;

        for(int i = 0; i < list.Count; i++) {
          font = (Font)list[i];

          if(font.Name == name) {
            return font;
          }
        }

        return null;
      }
    }

    public Font this[int index] {
      get {
        return (Font)list[index];
      }
    }

    public int Count {
      get {
        return list.Count;
      }
    }
  }

  #endregion FontList Collection

  #region ListboxItem Collection

  public class ListboxItemList {
    ArrayList list = new ArrayList();

    public int Find(ListboxItem item) {
      return list.IndexOf(item);
    }

    public void Add(ListboxItem item) {
      list.Add(item);
    }

    public void Clear() {
      list.Clear();
    }

    public void Insert(int position, ListboxItem item) {
      list.Insert(position, item);
    }

    /// <summary>
    ///    Removes an item from the collection.
    /// </summary>
    /// <param name="name"></param>
    public void Remove(ListboxItem item) {
      list.Remove(item);
    }

    public void RemoveAt(int index) {
      list.RemoveAt(index);
    }

    public void Resize(int count) {
      // add some null entries...
      for ( ; list.Count < count; list.Add(null));
    }

    public void Sort() {
      list.Sort();
    }

    public int Count {
      get {
        return list.Count;
      }
    }

    public ListboxItem this[int index] {
      get {
        return (ListboxItem)list[index];
      }

      set {
        list[index] = value;
      }
    }

  }
  #endregion

  #region GridRow Collection

  public class GridRowList 
  {
    ArrayList list = new ArrayList();

    public int Find(Widgets.GridRow row) 
    {
      return list.IndexOf(row);
    }

    public void Add(Widgets.GridRow row) 
    {
      list.Add(row);
    }

    public void Clear() 
    {
      list.Clear();
    }

    public void Insert(int position, Widgets.GridRow row) 
    {
      if (position >= list.Count) 
      {
        list.Add(row);
      }
      else 
      {
        list.Insert(position, row);
      }

    }

    public void Remove(Widgets.GridRow row) 
    {
      list.Remove(row);
    }

    public void RemoveAt(int index) 
    {
      list.RemoveAt(index);
    }

    public void SortAscending()
    {
      list.Sort(new GridRowLTComparer());
    }

    public void SortDescending()
    {
      list.Sort(new GridRowGTComparer());
    }

    public int Count 
    {
      get 
      {
        return list.Count;
      }
    }

    public Widgets.GridRow this[int index] 
    {
      get 
      {
        return (Widgets.GridRow)list[index];
      }
    }

  }
  #endregion

  #region ListHeaderSegment collection

  public class HeaderSegmentList 
  {
    ArrayList list = new ArrayList();

    public int Find(Widgets.ListHeaderSegment item) 
    {
      return list.IndexOf(item);
    }

    public void Add(Widgets.ListHeaderSegment item) 
    {
      list.Add(item);
    }

    public void Clear() 
    {
      list.Clear();
    }

    public void Insert(int position, Widgets.ListHeaderSegment item) 
    {
      if (position >= list.Count) {
        list.Add(item);
      }
      else {
        list.Insert(position, item);
      }
    }

    public void Remove(Widgets.ListHeaderSegment item) 
    {
      list.Remove(item);
    }

    public int Count 
    {
      get 
      {
        return list.Count;
      }
    }

    public Widgets.ListHeaderSegment this[int index] 
    {
      get 
      {
        return (Widgets.ListHeaderSegment)list[index];
      }
    }

  }
  #endregion



  #region Comparers for GridRow Sorting

  /// <summary>
  ///    Greater-than Comparer used for GridRows
  /// </summary>
  public class GridRowGTComparer : System.Collections.IComparer 
  {
    #region IComparer Members

    public int Compare(object x, object y) 
    {
      Widgets.GridRow itemA = (Widgets.GridRow)x;
      Widgets.GridRow itemB = (Widgets.GridRow)y;

      if(itemA < itemB) {
        return -1;
      }
      else if(itemA > itemB) {
        return 1;
      }
      // items are equal
      else {
        return 0;
      }
    }

    #endregion
  }

  /// <summary>
  ///    Less-than Comparer used for GridRows
  /// </summary>
  public class GridRowLTComparer : System.Collections.IComparer 
  {
    #region IComparer Members

    public int Compare(object x, object y) 
    {
      return (new GridRowGTComparer()).Compare(y, x);
    }

    #endregion
  }

  #endregion

}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.