public MedalConditionForm(TreeNode Node) { InitializeComponent(); this.Node = Node; this.Obj = (MedalOrRankCondition)Node.Tag; List<string> Params = Obj.GetParams(); int I = 0; int Index = 0; // Set default award requirement type if (Params[0] == "has_medal") { AwardType Type = Award.GetType(Params[1]); switch (Type) { case AwardType.Badge: TypeSelect.SelectedIndex = 0; foreach (Award A in AwardCache.GetBadges()) { AwardSelect.Items.Add(new SelectItem(A.Id, A.Name)); if (A.Id == Params[1]) Index = I; I++; } break; case AwardType.Medal: TypeSelect.SelectedIndex = 1; foreach (Award A in AwardCache.GetMedals()) { AwardSelect.Items.Add(new SelectItem(A.Id, A.Name)); if (A.Id == Params[1]) Index = I; I++; } break; case AwardType.Ribbon: TypeSelect.SelectedIndex = 2; foreach (Award A in AwardCache.GetRibbons()) { AwardSelect.Items.Add(new SelectItem(A.Id, A.Name)); if (A.Id == Params[1]) Index = I; I++; } break; } } else { TypeSelect.SelectedIndex = 3; foreach (Rank R in AwardCache.GetRanks()) { AwardSelect.Items.Add(new SelectItem(R.Id.ToString(), R.Name)); if (R.Id.ToString() == Params[1]) Index = I; I++; } } // Add index change event AwardSelect.SelectedIndex = Index; TypeSelect.SelectedIndexChanged += new EventHandler(TypeSelect_SelectedIndexChanged); }
public MedalConditionForm(TreeNode Node) { InitializeComponent(); this.Node = Node; this.Obj = (MedalOrRankCondition)Node.Tag; List <string> Params = Obj.GetParams(); int I = 0; int Index = 0; // Set default award requirement type if (Params[0] == "has_medal") { AwardType Type = Award.GetType(Params[1]); switch (Type) { case AwardType.Badge: TypeSelect.SelectedIndex = 0; foreach (Award A in AwardCache.GetBadges()) { AwardSelect.Items.Add(new KeyValuePair(A.Id, A.Name)); if (A.Id == Params[1]) { Index = I; } I++; } break; case AwardType.Medal: TypeSelect.SelectedIndex = 1; foreach (Award A in AwardCache.GetMedals()) { AwardSelect.Items.Add(new KeyValuePair(A.Id, A.Name)); if (A.Id == Params[1]) { Index = I; } I++; } break; case AwardType.Ribbon: TypeSelect.SelectedIndex = 2; foreach (Award A in AwardCache.GetRibbons()) { AwardSelect.Items.Add(new KeyValuePair(A.Id, A.Name)); if (A.Id == Params[1]) { Index = I; } I++; } break; } } else { TypeSelect.SelectedIndex = 3; foreach (Rank R in AwardCache.GetRanks()) { AwardSelect.Items.Add(new KeyValuePair(R.Id.ToString(), R.Name)); if (R.Id.ToString() == Params[1]) { Index = I; } I++; } } // Add index change event AwardSelect.SelectedIndex = Index; TypeSelect.SelectedIndexChanged += new EventHandler(TypeSelect_SelectedIndexChanged); }