public void AddMathNode(Type type) { enumOperatorCategory category = MathNodeCategoryAttribute.GetTypeCategory(type); if ((category & enumOperatorCategory.Logic) != 0) { if (!typeIconsLogic.Contains(type)) { typeIconsLogic.AddIcon(type); } } if ((category & enumOperatorCategory.Integer) != 0) { if (!typeIconsInteger.Contains(type)) { typeIconsInteger.AddIcon(type); } } if ((category & enumOperatorCategory.String) != 0) { if (!typeIconsString.Contains(type)) { typeIconsString.AddIcon(type); } } if ((category & enumOperatorCategory.System) != 0) { if (!typeIconsOther.Contains(type)) { typeIconsOther.AddIcon(type); } } if ((category & enumOperatorCategory.Decimal) != 0) { if (!typeIcons1.Contains(type)) { typeIcons1.AddIcon(type); } } }
public MathExpEditor() { InitializeComponent(); // mathExpCtrl1.SetMathEditor(this); // List <Type> NodeTypes; List <Type> NodeTypesLogic; List <Type> NodeTypesInteger; List <Type> NodeTypesString; List <Type> NodeTypesOther; propertyGrid1.PropertyValueChanged += new PropertyValueChangedEventHandler(propertyGrid1_PropertyValueChanged); propertyGrid2.PropertyValueChanged += new PropertyValueChangedEventHandler(propertyGrid2_PropertyValueChanged); tabGreek.Text = new string((char)0x03b1, 1) + " - " + new string((char)0x03c9, 1); NodeTypes = new List <Type>(); //decimal nodes NodeTypesLogic = new List <Type>(); //logic nodes NodeTypesInteger = new List <Type>(); //integer nodes NodeTypesString = new List <Type>(); //string nodes NodeTypesOther = new List <Type>(); //other nodes //load types in this DLL Type[] tps0 = this.GetType().Assembly.GetExportedTypes(); List <Type> types = MathNode.MathNodePlugIns; Type[] tps = new Type[tps0.Length + types.Count]; tps0.CopyTo(tps, 0); types.CopyTo(tps, tps0.Length); for (int i = 0; i < tps.Length; i++) { enumOperatorCategory opCat = MathNodeCategoryAttribute.GetTypeCategory(tps[i]); if (opCat != enumOperatorCategory.Internal) { if (!tps[i].IsAbstract && tps[i].IsSubclassOf(typeof(MathNode))) { if (!tps[i].Equals(typeof(MathNodeRoot))) { if ((opCat & enumOperatorCategory.Logic) != 0) { NodeTypesLogic.Add(tps[i]); } if ((opCat & enumOperatorCategory.Integer) != 0) { NodeTypesInteger.Add(tps[i]); } if ((opCat & enumOperatorCategory.String) != 0) { NodeTypesString.Add(tps[i]); } if ((opCat & enumOperatorCategory.System) != 0) { if (ExcludeProjectItem) { object[] vs = tps[i].GetCustomAttributes(typeof(ProjectItemAttribute), true); if (vs != null && vs.Length > 0) { continue; } } NodeTypesOther.Add(tps[i]); } if ((opCat & enumOperatorCategory.Decimal) != 0) { NodeTypes.Add(tps[i]); } } } } } //load types from configuration XML string file = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(this.GetType().Assembly.Location), "MathTypes.xml"); if (System.IO.File.Exists(file)) { XmlDocument doc = new XmlDocument(); doc.Load(file); if (doc.DocumentElement != null) { for (int i = 0; i < doc.DocumentElement.ChildNodes.Count; i++) { try { Type t = XmlUtil.GetLibTypeAttribute(doc.DocumentElement.ChildNodes[i]); enumOperatorCategory opCat = MathNodeCategoryAttribute.GetTypeCategory(t); if (opCat != enumOperatorCategory.Internal) { if ((opCat & enumOperatorCategory.Logic) != 0) { if (!NodeTypesLogic.Contains(t)) { NodeTypesLogic.Add(t); } } } if ((opCat & enumOperatorCategory.Integer) != 0) { if (!NodeTypesInteger.Contains(t)) { NodeTypesInteger.Add(t); } } if ((opCat & enumOperatorCategory.String) != 0) { if (!NodeTypesString.Contains(t)) { NodeTypesString.Add(t); } } if ((opCat & enumOperatorCategory.System) != 0) { if (!NodeTypesOther.Contains(t)) { NodeTypesOther.Add(t); } } if ((opCat & enumOperatorCategory.Decimal) != 0) { if (!NodeTypes.Contains(t)) { NodeTypes.Add(t); } } } catch (Exception err) { MessageBox.Show(err.Message); } } } } typeIcons1.Category = enumOperatorCategory.Decimal; typeIcons1.lblTooltips = lblTooltips; typeIcons1.OnTypeSelected += new EventHandler(typeIcons1_OnTypeSelected); typeIcons1.LoadData(NodeTypes); typeIconsLogic.lblTooltips = lblTooltips; typeIconsLogic.Category = enumOperatorCategory.Logic; typeIconsLogic.OnTypeSelected += new EventHandler(typeIcons1_OnTypeSelected); typeIconsLogic.LoadData(NodeTypesLogic); typeIconsInteger.lblTooltips = lblTooltips; typeIconsInteger.Category = enumOperatorCategory.Integer; typeIconsInteger.OnTypeSelected += new EventHandler(typeIcons1_OnTypeSelected); typeIconsInteger.LoadData(NodeTypesInteger); typeIconsString.lblTooltips = lblTooltips; typeIconsString.Category = enumOperatorCategory.String; typeIconsString.OnTypeSelected += new EventHandler(typeIcons1_OnTypeSelected); typeIconsString.LoadData(NodeTypesString); typeIconsOther.lblTooltips = lblTooltips; typeIconsOther.Category = enumOperatorCategory.System; typeIconsOther.OnTypeSelected += new EventHandler(typeIcons1_OnTypeSelected); typeIconsOther.LoadData(NodeTypesOther); // greekLetters1.OnLetterSelected += new EventHandler(greekLetters1_OnLetterSelected); // mathExpCtrl1.OnFinish += new EventHandler(btOK_Click); mathExpCtrl1.OnCancel += new EventHandler(btCancel_Click); mathExpCtrl1.OnCreateCompound += new EventHandler(mathExpCtrl1_OnCreateCompound); // // MethodType mt = (MethodType)MathNode.GetService(typeof(MethodType)); typeIconsOther.SetIconVisible(typeof(MathNodeArgument), (mt != null && mt.ParameterCount > 0)); // propertyGrid2.SetOnValueChange(onValueChanged); // if (Clipboard.ContainsData("MathNode")) { btPaste.Enabled = true; btPaste.ImageIndex = IMG_Paste_Enable; } tabControl1.SelectedTab = tabPageOther; typeIconsOther.LoadIcons(); }