GetType() public static method

Returns the Award type of an award.
public static GetType ( string AwardId ) : AwardType
AwardId string The award ID
return AwardType
        /// <summary>
        /// An event called everytime a new award is selected...
        /// It repaints the current award info
        /// </summary>
        private void AwardTree_AfterSelect(object sender, TreeViewEventArgs e)
        {
            // Set our award globally
            SelectedAwardNode = e.Node;

            // Only proccess child Nodes
            if (SelectedAwardNode.Nodes.Count == 0)
            {
                // Set Award Image
                SetAwardImage(SelectedAwardNode.Name);

                // Set award name and type
                switch (Award.GetType(SelectedAwardNode.Name))
                {
                case AwardType.Badge:
                    AwardTypeBox.Text = "Badge";
                    AwardNameBox.Text = Award.GetName(SelectedAwardNode.Name);
                    break;

                case AwardType.Medal:
                    AwardTypeBox.Text = "Medal";
                    AwardNameBox.Text = Award.GetName(SelectedAwardNode.Name);
                    break;

                case AwardType.Ribbon:
                    AwardTypeBox.Text = "Ribbon";
                    AwardNameBox.Text = Award.GetName(SelectedAwardNode.Name);
                    break;

                case AwardType.Rank:
                    AwardTypeBox.Text = "Rank";
                    AwardNameBox.Text = Rank.GetName(Int32.Parse(SelectedAwardNode.Name));
                    break;
                }

                // Delay or tree redraw
                AwardConditionsTree.BeginUpdate();

                // Clear all Nodes
                AwardConditionsTree.Nodes.Clear();

                // Parse award conditions into tree view
                SelectedAward = AwardCache.GetAward(SelectedAwardNode.Name);
                TreeNode Conds = SelectedAward.ToTree();
                if (Conds != null)
                {
                    AwardConditionsTree.Nodes.Add(Conds);
                }

                // Conditions tree's are to be expanded at all times
                AwardConditionsTree.ExpandAll();

                // Redraw the tree
                AwardConditionsTree.EndUpdate();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Used by the parser to add found awards to the list
        /// </summary>
        /// <param name="A">The Award Object To Add</param>
        public static void AddAward(Award A)
        {
            // Add award to individual award type collection
            switch (Award.GetType(A.Id))
            {
            case AwardType.Badge:
                Badges.Add(A);
                break;

            case AwardType.Medal:
                Medals.Add(A);
                break;

            case AwardType.Ribbon:
                Ribbons.Add(A);
                break;
            }

            // Add the award to the overall awards cache
            Awards.Add(A.Id, A);

            // Build the award tree here to Initially check for condition errors
            A.ToTree();
        }
        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);
        }