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(); }
public CaNew(CaBase cab, string strTitle, string strKind, Type[] atype, string[] astrName) { // // Required for Windows Form Designer support // InitializeComponent(); m_atype = atype; m_cab = null; m_strParse = null; m_strKind = strKind; // To do - might want to pretty print these type names Text = strTitle; m_labelWhatType.Text = m_labelWhatType.Text.Replace("$1", strKind); m_labelText.Text = m_labelText.Text.Replace("$1", strKind); Array.Sort(astrName, atype); Array.Sort(astrName); m_comboBoxType.DataSource = astrName; m_cab = cab; if (cab != null) { m_comboBoxType.SelectedIndex = Array.IndexOf(atype, m_cab.GetType()); } else { m_comboBoxType.SelectedIndex = 0; } SelectCa(m_comboBoxType.SelectedIndex); }
public Artillery(Side side, int tx, int ty, Aggressiveness aggr, CaBase cab) : base(side, tx, ty, aggr, cab) { }
public TakeoverSpecialist(Side side, int tx, int ty, Aggressiveness aggr, CaBase cab) : base(side, tx, ty, aggr, cab) { m_aggr = Aggressiveness.Coward; }
public ShortRangeInfantry(Side side, int tx, int ty, Aggressiveness aggr, CaBase cab) : base(side, tx, ty, aggr, cab) { }
public RocketVehicle(Side side, int tx, int ty, Aggressiveness aggr, CaBase cab) : base(side, tx, ty, aggr, cab) { }
public MobileUnit(Side side, int tx, int ty, Aggressiveness aggr, CaBase cab) : base(side, tx, ty) { m_aggr = aggr; m_cab = cab; }
public MobileHeadquarters(Side side, int tx, int ty, Aggressiveness aggr, CaBase cab) : base(side, tx, ty, aggr, cab) { m_aggr = Aggressiveness.Coward; }
public MediumTank(Side side, int tx, int ty, Aggressiveness aggr, CaBase cab) : base(side, tx, ty, aggr, cab) { }
public MachineGunVehicle(Side side, int tx, int ty, Aggressiveness aggr, CaBase cab) : base(side, tx, ty, aggr, cab) { }
public GalaxMiner(Side side, int tx, int ty, Aggressiveness aggr, CaBase cab) : base(side, tx, ty, aggr, cab) { m_aggr = Aggressiveness.Coward; }
void SelectCa(int n) { if (m_cab == null || m_cab.GetType() != m_atype[n]) m_cab = (CaBase)System.Activator.CreateInstance(m_atype[n]); m_labelDescription.Text = Helper.GetDescription(m_cab.GetType()); m_richTextBox.Clear(); // String replacement, order independent string str = m_cab.GetString(); CaType[] acat = m_cab.GetTypes(); for (int j = 0; j < acat.Length; j++) str = str.Replace("$" + (j + 1), "~" + j + acat[j].ToString() + "~" + j); // Save this away for hittesting purposes m_strParse = (string)str.Clone(); // && delimited pieces are links while (str.Length != 0) { int ichT = str.IndexOf("~"); if (ichT == -1) { m_richTextBox.AppendText(str); break; } if (ichT != 0) m_richTextBox.AppendText(str.Substring(0, ichT)); str = str.Remove(0, ichT + 2); // Now add the underlined text int ichStart = m_richTextBox.TextLength; int cchLink = str.IndexOf("~"); Debug.Assert(cchLink != -1); m_richTextBox.AppendText(str.Substring(0, cchLink)); str = str.Remove(0, cchLink + 2); m_richTextBox.Select(ichStart, cchLink); Color clr = m_richTextBox.SelectionColor; Font fnt = m_richTextBox.SelectionFont; m_richTextBox.SelectionColor = Color.Blue; m_richTextBox.SelectionFont = new Font(fnt.FontFamily, fnt.Size, /* FontStyle.Bold | */ FontStyle.Underline); m_richTextBox.Select(m_richTextBox.TextLength, 0); m_richTextBox.SelectionFont = fnt; m_richTextBox.SelectionColor = clr; } }