Scripts.cs :  » Game » RealmForge » RSL » UI » 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 » RSL » UI » Scripts.cs
using System;
using System.Collections;
using System.Xml;
using RealmForge.Scripting;
using RealmForge;
using RealmForge.UI;
using RealmForge.UI.Definitions;
using RealmForge.UI.Forms;
using System.Windows.Forms;
using RealmForge.UI.Forms.IDE.Docking;
using System.Drawing;
using ContentRealmForge.UI.Forms.IDE.Docking.Content;
using System.IO;
using System.ComponentModel;

namespace RSL.UI{

  /// <summary>
  /// The RSL.UI namespace contains scripts relating to GUI Toolkits such as WinForms for window creation and manipulation.
  /// </summary>
  internal class NamespaceDoc 
  {
  }
  #region Script Classes

  [Description("Creates a window creation script for the owner IWindowManager that creates the default Launcher formand registers it.")]
  public class CreateLauncher : IScript
  {
    #region Methods
    public void Execute(object owner, object args) 
    {
      try
      {
        string windowID = (string)args;
        Form f = new Launcher();
        f.Load += new EventHandler(BringToFront);
        ((IWindowManager)owner).Register(windowID,f);
      } 
      catch(Exception e) 
      {
        Log.Write(e);
      }
    }
    #endregion

    private void BringToFront(object sender, EventArgs e)
    {
      ((Form)sender).BringToFront();
    }
  }

  [Description("Creates and shows a form which acts as a black waiting screen showing RF.Config.GameLoadingTitleWithTroubleshootInformation as its text that can be closed with HideLoadingScreen().")]
  public class ShowLoadingScreen : IScript {
    #region Fields and Properties
    protected Form loadingScreen = null;
    protected Label waitLabel = null;
    #endregion

    #region Public Methods
    public void Execute(object owner, object args) 
    {
      Show();
    }
    public void Show() {
      Form f = new Form();
      f.Text = RF.Config.RenderWindowTitle;
      f.TopMost = true;//prevents render window loading from being seen, but is impossible to debug
      f.BackColor = Color.Black;
      f.WindowState = FormWindowState.Maximized;
      f.FormBorderStyle = FormBorderStyle.None;
      f.StartPosition = FormStartPosition.CenterScreen;
      f.Controls.Add(CreateWaitLabel());
      loadingScreen = f;
      loadingScreen.Show();
    }
    public Label CreateWaitLabel() {
      waitLabel = new Label();
      waitLabel.TextAlign = ContentAlignment.MiddleCenter;
      waitLabel.ForeColor = Color.White;
      waitLabel.BackColor = Color.Black;
      waitLabel.Text = RF.Config.GameLoadingTitleWithTroubleshootInformation;
      waitLabel.Font = new Font(StandardFonts.Arial, 24, GraphicsUnit.Point);
      waitLabel.Dock = DockStyle.Fill;
      return waitLabel;
    }
    public void HideLoadingScreen() {
      waitLabel.Hide();  //hide until closes
      loadingScreen.Close();  //close and clean up
    }
    #endregion
  }


  [Description("Performs the appropriate actions depending on the Text propety of the owner parameter representing the Control which was clicked.")]
  public class HandleLauncherButtonClick : IScript {
    #region Fields and Properties
    protected bool alreadyStarted = false;
    #endregion

    #region Public Methods
    public void ShowRenderWindow() 
    {
      RF.Windows.Hide("Launcher");
    }
    public void Execute(object owner, object args) {
      try{
        Control button  = (Control)owner;
        string windowID = (string)button.Tag;
        switch(windowID) {
          case "New":
            if(alreadyStarted)
              return;  //prevent from erroring when new is pressed 2x in a row
            alreadyStarted = true;
            ShowLoadingScreen loadingScreenController = new ShowLoadingScreen();
            loadingScreenController.Show();
            //General SwitchTo would be used to change to the RenderWindow from the Launcher, but Axiom automatically
            //shows its own window on startup... this also means that we have to wait to customize it until Axiom startup has finished
            //which leaves an ugly Axiom windows temporarily and also requires the AxiomIcon.ico to be present
            RF.Engine.Initialized.AddHandlers(new SimpleMethod(loadingScreenController.HideLoadingScreen),new SimpleMethod(ShowRenderWindow));
            RF.App.StartRendering();
            break;
          case "Load":
            //RF.Windows.Hide("Launcher");
            RF.Windows.Show("LoadScreen");
            break;
          case "Multiplayer":
            //RF.Windows.Hide("Launcher");
            RF.Windows.Show("PlayerLobby");
            break;
          case "Options":
            //RF.Windows.Hide("Launcher");
            RF.Windows.ShowDialog("OptionsDialog");
            break;
          case "Credits":
            //RF.Windows.Hide("Launcher");
            RF.Windows.ShowDialog("CreditsDialog");
            break;
          case "Readme":
            RealmForge.Utility.RunFile(StandardResources.ReadmeFile);
            break;
          case "Exit":
            RF.App.Shutdown();
            break;
        }
      } catch(Exception e) {
        Log.Write(e);
        Errors.RealmForge("Launcher Button Click failed to handle");
      }
    }

    #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.