diff --git a/Source/Examples/Utilities.cs b/Source/Examples/Utilities.cs index f569d1b9..5f3981a6 100644 --- a/Source/Examples/Utilities.cs +++ b/Source/Examples/Utilities.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Text; using System.Drawing; +using OpenTK; namespace Examples { @@ -17,5 +18,27 @@ namespace Examples { return (int)((c.A << 24) | (c.B << 16) | (c.G << 8) | c.R); } + + public static void SetWindowTitle(GameWindow window) + { + ExampleAttribute info = GetExampleAttribute(window.GetType()); + window.Title = String.Format("OpenTK | {0} {1}: {2}", info.Category, info.Difficulty, info.Title); + } + + public static void SetWindowTitle(System.Windows.Forms.Form window) + { + ExampleAttribute info = GetExampleAttribute(window.GetType()); + window.Text = String.Format("OpenTK | {0} {1}: {2}", info.Category, info.Difficulty, info.Title); + } + + static ExampleAttribute GetExampleAttribute(Type type) + { + object[] attributes = type.GetCustomAttributes(false); + foreach (object attr in attributes) + if (attr is ExampleAttribute) + return attr as ExampleAttribute; + + return null; + } } }