public static CaBase DoModal(CaBase cab, string strTitle, string strKind) { string strEndsWith = strKind; System.Reflection.Assembly ass = typeof(CaBase).Module.Assembly; Type[] atype = ass.GetTypes(); ArrayList alsType = new ArrayList(); ArrayList alsName = new ArrayList(); foreach (Type type in atype) { string strName = type.ToString(); if (strName.EndsWith(strEndsWith)) { alsType.Add(type); string strDisplayName = Helper.GetDisplayName(type); if (strDisplayName == null) { int ichDot = strName.IndexOf('.'); strDisplayName = strName.Substring(ichDot + 1, strName.Length - (ichDot + 1 + strEndsWith.Length)); } alsName.Add(strDisplayName); } } CaNew frmCaNew = new CaNew(cab, strTitle, strKind, (Type[])alsType.ToArray(typeof(Type)), (string[])alsName.ToArray(typeof(string))); frmCaNew.ShowDialog(); if (frmCaNew.DialogResult == DialogResult.Cancel) { return(null); } return(frmCaNew.GetCab()); }
// Displays the UI for value selection. public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { CaBase cab = (CaBase)value; cab = CaNew.DoModal(cab.Clone(), "Modify Action", "UnitAction"); return(cab == null ? value : cab); }
private void buttonNewAction_Click(object sender, System.EventArgs e) { CaBase cab = CaNew.DoModal(null, "New Action", "UnitGroupAction"); if (cab != null) { m_ugSelected.Actions.Add(cab); InitActionsListBox(m_ugSelected.Actions.Count - 1); } }
private void buttonNewCondition_Click(object sender, System.EventArgs e) { CaBase cab = CaNew.DoModal(null, "New Condition", "Condition"); if (cab != null) { m_tgr.Conditions.Add(cab); InitConditionsListBox(m_tgr.Conditions.Count - 1); } }
private void buttonModifyAction_Click(object sender, System.EventArgs e) { int n = checkedListBoxActions.SelectedIndex; if (n < 0) { return; } CaBase cab = (CaBase)m_ugSelected.Actions[n]; cab = CaNew.DoModal(cab.Clone(), "Modify Action", "UnitGroupAction"); if (cab != null) { m_ugSelected.Actions[n] = cab; InitActionsListBox(n); } }
public static CaBase DoModal(CaBase cab, string strTitle, string strKind) { string strEndsWith = strKind; System.Reflection.Assembly ass = typeof(CaBase).Module.Assembly; Type[] atype = ass.GetTypes(); ArrayList alsType = new ArrayList(); ArrayList alsName = new ArrayList(); foreach (Type type in atype) { string strName = type.ToString(); if (strName.EndsWith(strEndsWith)) { alsType.Add(type); string strDisplayName = Helper.GetDisplayName(type); if (strDisplayName == null) { int ichDot = strName.IndexOf('.'); strDisplayName = strName.Substring(ichDot + 1, strName.Length - (ichDot + 1 + strEndsWith.Length)); } alsName.Add(strDisplayName); } } CaNew frmCaNew = new CaNew(cab, strTitle, strKind, (Type[])alsType.ToArray(typeof(Type)), (string[])alsName.ToArray(typeof(string)) ); frmCaNew.ShowDialog(); if (frmCaNew.DialogResult == DialogResult.Cancel) return null; return frmCaNew.GetCab(); }