private void FinishBtn_Click(object sender, EventArgs e) { // Tell the base condition form that we modifed the condition base.Canceled = false; // First param is always the python method name List <string> Params = new List <string>(); KeyValuePair I = (KeyValuePair)AwardSelect.SelectedItem; Params.Add((TypeSelect.SelectedIndex < 3) ? "has_medal" : "has_rank"); Params.Add(I.Key); // Are we creating a new Object? if (Obj == null) { Obj = new MedalOrRankCondition(Params); } else { Obj.SetParams(Params); } // Close the form this.Node.Tag = Obj; MedalDataEditor.ChangesMade = true; this.DialogResult = DialogResult.OK; }
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); }
private void FinishBtn_Click(object sender, EventArgs e) { // Tell the base condition form that we modifed the condition base.Canceled = false; // First param is always the python method name List<string> Params = new List<string>(); SelectItem I = (SelectItem) AwardSelect.SelectedItem; Params.Add( (TypeSelect.SelectedIndex < 3) ? "has_medal" : "has_rank" ); Params.Add(I.Name); // Are we creating a new Object? if (Obj == null) Obj = new MedalOrRankCondition(Params); else Obj.SetParams(Params); // Close the form this.Node.Tag = Obj; MedalDataEditor.ChangesMade = true; this.DialogResult = DialogResult.OK; }
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); }