ImageSetManager.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 » ImageSetManager.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.Text;

#endregion

namespace CrayzEdsGui.Base{

  /// <summary>
  ///    Class providing a shared library of Imageset objects to the system.
  /// </summary>
  /// <remarks>
  ///    The ImagesetManager is used to create, access, and destroy <see cref="Imageset"/> objects.  The idea is that
  ///    the ImagesetManager will function as a central repository for imagery used within the GUI system,
  ///    and that such imagery can be accessed, via a unique name, by any interested party within the system.
  /// </remarks>
  public class ImagesetManager {
    #region Singleton Implementation

    /// <summary>
    ///    Singlton instance of this class.
    /// </summary>
    private static ImagesetManager instance;

    /// <summary>
    ///    Default constructor.
    /// </summary>
    internal ImagesetManager() {
      // only create once instance
      if (instance == null) {
        instance = this;
      }
    }

    /// <summary>
    ///    Gets the singleton class instance.
    /// </summary>
    /// <value></value>
    public static ImagesetManager Instance {
      get {
        return instance;
      }
    }

    #endregion Singleton Implementation

    #region Fields

    /// <summary>
    ///    List of all image sets that exist within the system.
    /// </summary>
    private ImagesetList imagesets = new ImagesetList();

    #endregion Fields

    #region Public Methods

    /// <summary>
    ///    Create a Imageset object with the given name and Texture.
    /// </summary>
    /// <remarks>
    ///    The created Imageset will be of limited use, and will require one or more images to be defined for the set.
    /// </remarks>
    /// <param name="name">The unique name for the Imageset being created.</param>
    /// <param name="texture">Texture object to be associated with the Imageset.</param>
    /// <returns>A reference to the newly created Imageset object.</returns>
    /// <exception cref="AlreadyExistsException">If an Imageset with the specified <paramref name="name"/> already exists in the system.</exception>
    public Imageset CreateImageset(string name, Texture texture) {
      if (IsImagesetPresent(name)) {
        throw new AlreadyExistsException("An Imageset object named '{0}' already exists.", name);
      }

      Imageset temp = new Imageset(name, texture);

      imagesets.Add(name, temp);

      Logger.Instance.LogEvent(string.Format("Imageset '{0}' has been created with a texture only.", name), LoggingLevel.Informative);

      return temp;
    }

    /// <summary>
    ///    Create an Imageset object from the specified file.
    /// </summary>
    /// <param name="fileName">The name of the Imageset definition file which should be used to create the Imageset.</param>
    /// <returns>A reference to the newly created Imageset object.</returns>
    /// <exception cref="AlreadyExistsException">If an Imageset with the name specified in the file already exists in the system.</exception>
    /// <exception cref="FileIOException">If an error occurs while processing the file <paramref name="fileName"/>.</exception>
    public Imageset CreateImageset(string fileName) {
      Imageset temp = new Imageset(fileName);

      string tempName = temp.Name;

      if (IsImagesetPresent(tempName)) {
        throw new AlreadyExistsException("An Imageset object named '{0}' already exists.", tempName);
      }

      imagesets.Add(tempName, temp);

      Logger.Instance.LogEvent(string.Format("Imageset '{0}' has been created from the information specified in file '{1}'.", tempName, fileName), LoggingLevel.Informative);

      return temp;
    }

    /// <summary>
    ///    Destroys all Imageset objects registered in the system.
    /// </summary>
    public void DestroyAllImagesets() {
      throw new NotImplementedException();
    }

    /// <summary>
    ///    Destroys the specified Imageset.
    /// </summary>
    /// <param name="imageset">Reference to the Imageset to be destroyed.  If the Imageset is null, nothing happens.</param>
    public void DestroyImageset(Imageset imageset) {
      if(imageset != null) {
        DestroyImageset(imageset.Name);
      }
    }

    /// <summary>
    ///    Destroys the Imageset with the specified name.
    /// </summary>
    /// <param name="name">The name of the Imageset to be destroyed.  If no such Imageset exists, nothing happens.</param>
    public void DestroyImageset(string name) {
      Imageset imageset = imagesets[name];

      // log and dispose of resources
      if(imageset != null) {
        Logger.Instance.LogEvent(string.Format("Imageset '{0}' has been destroyed", name), LoggingLevel.Informative);
        imageset.Dispose();
      }
    }

    /// <summary>
    ///    Returns a reference to the Imageset object with the specified name.
    /// </summary>
    /// <param name="name">The name of the Imageset to return a reference to.</param>
    /// <return>Reference to the requested Imageset object.</return>
    public Imageset GetImageset(string name) {
      Imageset imageset = imagesets[name];

      if(imageset == null) {
        throw new UnknownObjectException("No Imageset named '{0}' is present in the system.", name);
      }

      return imageset;
    }

    /// <summary>
    ///    Check for the existence of a named Imageset.
    /// </summary>
    /// <param name="name">The name of the Imageset to look for.</param>
    /// <returns>Ttue if an Imageset named <paramref name="name"/> is presently loaded in the system, else false.</returns>
    public bool IsImagesetPresent(string name) {
      return imagesets[name] != null;
    }

    /// <summary>
    ///    Notify the ImagesetManager of the current (usually new) display resolution.
    /// </summary>
    /// <param name="size">Size describing the display resolution.</param>
    public void NotifyScreenResolution(Size size) {
      throw new NotImplementedException();
    }

    #endregion Public Methods
  }

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