protected override void OnContentChanged() { base.OnContentChanged(); if (engineTypes == null) { engineTypes = ApplicationManager.Manager.GetTypes(typeof(IEngine)). OrderBy(x => { string name = ItemAttribute.GetName(x); if (name != null) { return(name); } else { return(x.GetPrettyName()); } }).ToList(); foreach (Type t in engineTypes) { string name = ItemAttribute.GetName(t); if (name == null) { name = t.GetPrettyName(); } engineComboBox.Items.Add(name); } } if (Content == null) { engineViewHost.Content = null; operatorGraphViewHost.Content = null; } else { if (Content.Engine == null) { engineComboBox.SelectedIndex = -1; } else { engineComboBox.SelectedIndex = engineTypes.IndexOf(Content.Engine.GetType()); } engineViewHost.ViewType = null; engineViewHost.Content = Content.Engine; operatorGraphViewHost.ViewType = null; operatorGraphViewHost.Content = Content.OperatorGraph; } }
private void NewItemDialog_Load(object sender, EventArgs e) { if (isInitialized) { return; } // Sorted by hasOrdering to create category nodes first with concrete ordering. // Items with categoryname without ordering are inserted afterwards correctly var categories = from type in ApplicationManager.Manager.GetTypes(typeof(IItem)) where CreatableAttribute.IsCreatable(type) let category = CreatableAttribute.GetCategory(type) let hasOrdering = category.Contains(CreatableAttribute.Categories.OrderToken) let name = ItemAttribute.GetName(type) let priority = CreatableAttribute.GetPriority(type) let version = ItemAttribute.GetVersion(type) orderby category, hasOrdering descending, priority, name, version ascending group type by category into categoryGroup select categoryGroup; var rootNode = CreateCategoryTree(categories); CreateItemNodes(rootNode, categories); foreach (TreeNode topNode in rootNode.Nodes) { treeNodes.Add(topNode); } foreach (var node in treeNodes) { typesTreeView.Nodes.Add((TreeNode)node.Clone()); } typesTreeView.TreeViewNodeSorter = new ItemTreeNodeComparer(); typesTreeView.Sort(); isInitialized = true; }
private TreeNode CreateItemNode(Type creatable) { string name = ItemAttribute.GetName(creatable); var itemNode = new TreeNode(name) { ImageIndex = 0, Tag = creatable, Name = name }; var image = ItemAttribute.GetImage(creatable); if (image != null) { imageList.Images.Add(image); itemNode.ImageIndex = imageList.Images.Count - 1; } itemNode.SelectedImageIndex = itemNode.ImageIndex; return(itemNode); }
internal GESymbolicExpressionGrammar(IEnumerable <string> variableNames, int nConstants) : base(ItemAttribute.GetName(typeof(GESymbolicExpressionGrammar)), ItemAttribute.GetDescription(typeof(GESymbolicExpressionGrammar))) { // this ctor is called by the problem as only the problem knows the allowed input variables Initialize(variableNames, nConstants); }
public GESymbolicExpressionGrammar() : base(ItemAttribute.GetName(typeof(GESymbolicExpressionGrammar)), ItemAttribute.GetDescription(typeof(GESymbolicExpressionGrammar))) { // empty ctor is necessary to allow creation of new GEGrammars from the GUI. // the problem creates a new correctly configured grammar when the grammar is set }
public ArithmeticExpressionGrammar() : base(ItemAttribute.GetName(typeof(ArithmeticExpressionGrammar)), ItemAttribute.GetDescription(typeof(ArithmeticExpressionGrammar))) { Initialize(); }
public FullFunctionalExpressionGrammar() : base(ItemAttribute.GetName(typeof(FullFunctionalExpressionGrammar)), ItemAttribute.GetDescription(typeof(FullFunctionalExpressionGrammar))) { Initialize(); }
public TypeCoherentExpressionGrammar() : base(ItemAttribute.GetName(typeof(TypeCoherentExpressionGrammar)), ItemAttribute.GetDescription(typeof(TypeCoherentExpressionGrammar))) { Initialize(); }
public virtual void Configure(IEnumerable <Type> baseTypes, bool showNotInstantiableTypes, bool showGenericTypes, bool assignableToAllTypes, Func <Type, bool> typeCondition) { if (baseTypes == null) { throw new ArgumentNullException(); } if (InvokeRequired) { Invoke(new Action <IEnumerable <Type>, bool, bool, bool, Func <Type, bool> >(Configure), baseTypes, showNotInstantiableTypes, showGenericTypes, assignableToAllTypes, typeCondition); } else { this.baseTypes = baseTypes; this.showNotInstantiableTypes = showNotInstantiableTypes; this.showGenericTypes = showGenericTypes; bool selectedTypeFound = false; typeParametersSplitContainer.Panel2Collapsed = !showGenericTypes; TreeNode selectedNode = typesTreeView.SelectedNode; typesTreeView.Nodes.Clear(); treeNodes.Clear(); imageList.Images.Clear(); imageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.Class); // default icon imageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.Namespace); // plugins imageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.Interface); // interfaces imageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.Template); // generic types // additional dictionary for image indexes as imageList.ContainsKey and imageList.IndexOfKey are very slow! var imageNames = new Dictionary <string, int>(); var plugins = from p in ApplicationManager.Manager.Plugins orderby p.Name, p.Version ascending select p; foreach (IPluginDescription plugin in plugins) { TreeNode pluginNode = new TreeNode(); pluginNode.Text = string.Format("{0} {1}.{2}", plugin.Name, plugin.Version.Major, plugin.Version.Minor); pluginNode.ImageIndex = 1; pluginNode.SelectedImageIndex = pluginNode.ImageIndex; pluginNode.Tag = plugin; var types = from t in ApplicationManager.Manager.GetTypes(BaseTypes, plugin, !ShowNotInstantiableTypes, ShowGenericTypes, assignableToAllTypes) where typeCondition(t) orderby t.Name ascending select t; foreach (Type type in types) { bool valid = (ShowNotInstantiableTypes || type.GetConstructor(Type.EmptyTypes) != null); //check for public default ctor if (valid) { TreeNode typeNode = new TreeNode(); string name = ItemAttribute.GetName(type); typeNode.Text = name != null ? name : type.GetPrettyName(); typeNode.ImageIndex = 0; if (type.IsInterface) { typeNode.ImageIndex = 2; } else if (type.ContainsGenericParameters) { typeNode.ImageIndex = 3; } else if (imageNames.ContainsKey(type.FullName)) { typeNode.ImageIndex = imageNames[type.FullName]; } else { var image = ItemAttribute.GetImage(type); if (image != null) { imageList.Images.Add(image); typeNode.ImageIndex = imageList.Images.Count - 1; imageNames.Add(type.FullName, imageList.Images.Count - 1); } } typeNode.SelectedImageIndex = typeNode.ImageIndex; typeNode.Tag = type; pluginNode.Nodes.Add(typeNode); if (type.Equals(selectedType)) { selectedTypeFound = true; } } } if (pluginNode.Nodes.Count > 0) { treeNodes.Add(pluginNode); } } if (!selectedTypeFound) { SelectedType = null; } foreach (TreeNode node in treeNodes) { typesTreeView.Nodes.Add((TreeNode)node.Clone()); } RestoreSelectedNode(selectedNode); Filter(searchTextBox.Text); UpdateTypeParameters(); } }
public CFGExpressionGrammar() : base(ItemAttribute.GetName(typeof(CFGExpressionGrammar)), ItemAttribute.GetDescription(typeof(CFGExpressionGrammar))) { }