Added a null check to examples selection. Pre-selected first example. Remove console browser attempt. it still did not work on OSX.

svn path=/trunk/tao/; revision=72039
This commit is contained in:
David Hudson 2007-01-31 17:46:49 +00:00
Родитель 23f6308026
Коммит 94fec4da4c
10 изменённых файлов: 75 добавлений и 114 удалений

Просмотреть файл

@ -26,6 +26,10 @@ namespace CgExamples
{
lstExamples.Items.Add(type.Name);
}
if (lstExamples.Items.Count > 0)
{
this.lstExamples.SelectedIndex = 0;
}
}
}
@ -36,8 +40,11 @@ namespace CgExamples
private void SelectExample()
{
Type example = Assembly.GetExecutingAssembly().GetType("CgExamples." + lstExamples.SelectedItem.ToString(), true, true);
example.InvokeMember("Run", BindingFlags.InvokeMethod, null, null, null);
if (lstExamples.SelectedItem != null)
{
Type example = Assembly.GetExecutingAssembly().GetType("CgExamples." + lstExamples.SelectedItem.ToString(), true, true);
example.InvokeMember("Run", BindingFlags.InvokeMethod, null, null, null);
}
}
private void lstExamples_SelectedIndexChanged(object sender, EventArgs e)

Просмотреть файл

@ -26,6 +26,10 @@ namespace GeWangExamples
{
lstExamples.Items.Add(type.Name);
}
if (lstExamples.Items.Count > 0)
{
this.lstExamples.SelectedIndex = 0;
}
}
}
@ -36,8 +40,11 @@ namespace GeWangExamples
private void SelectExample()
{
Type example = Assembly.GetExecutingAssembly().GetType("GeWangExamples." + lstExamples.SelectedItem.ToString(), true, true);
example.InvokeMember("Run", BindingFlags.InvokeMethod, null, null, null);
if (lstExamples.SelectedItem != null)
{
Type example = Assembly.GetExecutingAssembly().GetType("GeWangExamples." + lstExamples.SelectedItem.ToString(), true, true);
example.InvokeMember("Run", BindingFlags.InvokeMethod, null, null, null);
}
}
private void lstExamples_SelectedIndexChanged(object sender, EventArgs e)

Просмотреть файл

@ -26,6 +26,10 @@ namespace GlfwExamples
{
lstExamples.Items.Add(type.Name);
}
if (lstExamples.Items.Count > 0)
{
this.lstExamples.SelectedIndex = 0;
}
}
}
@ -36,8 +40,11 @@ namespace GlfwExamples
private void SelectExample()
{
Type example = Assembly.GetExecutingAssembly().GetType("GlfwExamples." + lstExamples.SelectedItem.ToString(), true, true);
example.InvokeMember("Run", BindingFlags.InvokeMethod, null, null, null);
if (lstExamples.SelectedItem != null)
{
Type example = Assembly.GetExecutingAssembly().GetType("GlfwExamples." + lstExamples.SelectedItem.ToString(), true, true);
example.InvokeMember("Run", BindingFlags.InvokeMethod, null, null, null);
}
}
private void lstExamples_SelectedIndexChanged(object sender, EventArgs e)

Просмотреть файл

@ -26,6 +26,10 @@ namespace NateRobins
{
lstExamples.Items.Add(type.Name);
}
if (lstExamples.Items.Count > 0)
{
this.lstExamples.SelectedIndex = 0;
}
}
}
@ -36,8 +40,11 @@ namespace NateRobins
private void SelectExample()
{
Type example = Assembly.GetExecutingAssembly().GetType("NateRobins." + lstExamples.SelectedItem.ToString(), true, true);
example.InvokeMember("Run", BindingFlags.InvokeMethod, null, null, null);
if (lstExamples.SelectedItem != null)
{
Type example = Assembly.GetExecutingAssembly().GetType("NateRobins." + lstExamples.SelectedItem.ToString(), true, true);
example.InvokeMember("Run", BindingFlags.InvokeMethod, null, null, null);
}
}
private void lstExamples_SelectedIndexChanged(object sender, EventArgs e)

Просмотреть файл

@ -26,6 +26,10 @@ namespace NeHe
{
lstExamples.Items.Add(type.Name);
}
if (lstExamples.Items.Count > 0)
{
this.lstExamples.SelectedIndex = 0;
}
}
}
@ -36,8 +40,11 @@ namespace NeHe
private void SelectExample()
{
Type example = Assembly.GetExecutingAssembly().GetType("NeHe." + lstExamples.SelectedItem.ToString(), true, true);
example.InvokeMember("Run", BindingFlags.InvokeMethod, null, null, null);
if (lstExamples.SelectedItem != null)
{
Type example = Assembly.GetExecutingAssembly().GetType("NeHe." + lstExamples.SelectedItem.ToString(), true, true);
example.InvokeMember("Run", BindingFlags.InvokeMethod, null, null, null);
}
}
private void lstExamples_SelectedIndexChanged(object sender, EventArgs e)

Просмотреть файл

@ -26,6 +26,10 @@ namespace OpenAlExamples
{
lstExamples.Items.Add(type.Name);
}
if (lstExamples.Items.Count > 0)
{
this.lstExamples.SelectedIndex = 0;
}
}
}
@ -36,8 +40,11 @@ namespace OpenAlExamples
private void SelectExample()
{
Type example = Assembly.GetExecutingAssembly().GetType("OpenAlExamples." + lstExamples.SelectedItem.ToString(), true, true);
example.InvokeMember("Run", BindingFlags.InvokeMethod, null, null, null);
if (lstExamples.SelectedItem != null)
{
Type example = Assembly.GetExecutingAssembly().GetType("OpenAlExamples." + lstExamples.SelectedItem.ToString(), true, true);
example.InvokeMember("Run", BindingFlags.InvokeMethod, null, null, null);
}
}
private void lstExamples_SelectedIndexChanged(object sender, EventArgs e)

Просмотреть файл

@ -26,6 +26,10 @@ namespace Redbook
{
lstExamples.Items.Add(type.Name);
}
if (lstExamples.Items.Count > 0)
{
this.lstExamples.SelectedIndex = 0;
}
}
}
@ -36,8 +40,11 @@ namespace Redbook
private void SelectExample()
{
Type example = Assembly.GetExecutingAssembly().GetType("Redbook." + lstExamples.SelectedItem.ToString(), true, true);
example.InvokeMember("Run", BindingFlags.InvokeMethod, null, null, null);
if (lstExamples.SelectedItem != null)
{
Type example = Assembly.GetExecutingAssembly().GetType("Redbook." + lstExamples.SelectedItem.ToString(), true, true);
example.InvokeMember("Run", BindingFlags.InvokeMethod, null, null, null);
}
}
private void lstExamples_SelectedIndexChanged(object sender, EventArgs e)

Просмотреть файл

@ -12,27 +12,9 @@ namespace SdlExamples
[STAThread]
static void Main(string[] args)
{
bool consoleMode = false;
foreach (string arg in args)
{
if (arg == "--console")
{
consoleMode = true;
}
}
if (consoleMode)
{
SdlExamplesConsole t = new SdlExamplesConsole();
t.Go();
}
else
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new SdlExamples());
}
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new SdlExamples());
}
}
}

Просмотреть файл

@ -26,6 +26,10 @@ namespace SdlExamples
{
lstExamples.Items.Add(type.Name);
}
if (lstExamples.Items.Count > 0)
{
this.lstExamples.SelectedIndex = 0;
}
}
}
@ -36,8 +40,11 @@ namespace SdlExamples
private void SelectExample()
{
Type example = Assembly.GetExecutingAssembly().GetType("SdlExamples." + lstExamples.SelectedItem.ToString(), true, true);
example.InvokeMember("Run", BindingFlags.InvokeMethod, null, null, null);
if (lstExamples.SelectedItem != null)
{
Type example = Assembly.GetExecutingAssembly().GetType("SdlExamples." + lstExamples.SelectedItem.ToString(), true, true);
example.InvokeMember("Run", BindingFlags.InvokeMethod, null, null, null);
}
}
private void lstExamples_SelectedIndexChanged(object sender, EventArgs e)

Просмотреть файл

@ -1,77 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Reflection;
using System.IO;
namespace SdlExamples
{
class SdlExamplesConsole
{
public SdlExamplesConsole()
{
Initialize();
}
List<string> lstExamples = new List<string>();
private void Initialize()
{
Type[] types = Assembly.GetExecutingAssembly().GetTypes();
foreach (Type type in types)
{
MemberInfo[] runMethods = type.GetMember("Run");
foreach (MemberInfo run in runMethods)
{
this.lstExamples.Add(type.Name);
}
}
}
public void Go()
{
Console.WriteLine("Press a number to run an example.");
Console.WriteLine("Press a 'Q' to quit");
Console.WriteLine();
foreach (string s in lstExamples)
{
Console.Write(lstExamples.IndexOf(s) + ") ");
Console.WriteLine(s);
}
bool quit = false;
while (!quit)
{
try
{
string input = Console.ReadLine();
int i;
if (Int32.TryParse(input.Trim(), out i))
{
if (i >= 0 && i < lstExamples.Count)
{
Type example = Assembly.GetExecutingAssembly().GetType("SdlExamples." + lstExamples[i], true, true);
example.InvokeMember("Run", BindingFlags.InvokeMethod, null, null, null);
}
}
else if (input.ToUpper() == "Q")
{
quit = true;
}
}
catch (NullReferenceException e)
{
Console.WriteLine(e.ToString());
quit = true;
}
catch (IOException e)
{
e.ToString();
quit = true;
}
}
}
}
}