/// <summary> /// Sets the window title to the name of the sample. /// </summary> /// <param name="window"></param> 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); window.Icon = OpenTK.Examples.Properties.Resources.Game; }
void LoadSamplesFromAssembly(Assembly assembly) { if (assembly == null) { throw new ArgumentNullException("assembly"); } Type[] types = assembly.GetTypes(); foreach (Type type in types) { object[] attributes = type.GetCustomAttributes(false); ExampleAttribute example = null; foreach (object attr in attributes) { if (attr is ExampleAttribute) { example = (ExampleAttribute)attr; if (example.Visible) { // Add this example to the sample TreeView. // First check whether the ExampleCategory exists in the tree (and add it if it doesn't). // Then add the example as a child node on this category. if (!treeViewSamples.Nodes.ContainsKey(example.Category.ToString())) { int category_index = GetImageIndexForSample(imageListSampleCategories, example.Category.ToString(), String.Empty); treeViewSamples.Nodes.Add(example.Category.ToString(), String.Format("{0} samples", example.Category), category_index, category_index); } int image_index = GetImageIndexForSample(imageListSampleCategories, example.Category.ToString(), example.Subcategory); TreeNode node = new TreeNode(example.Title, image_index, image_index); node.Name = example.Title; node.Tag = new ExampleInfo(type, example); treeViewSamples.Nodes[example.Category.ToString()].Nodes.Add(node); } } } } treeViewSamples.Sort(); }
public ExampleInfo(Type example, ExampleAttribute attr) { Example = example; Attribute = attr; }