BF2Statistics.MedalData.Award.GetName C# (CSharp) Method

GetName() public static method

Returns the full string name of an award
public static GetName ( string AwardId ) : string
AwardId string The award ID
return string
        public static string GetName(string AwardId)
        {
            // Badges always have an underscore
            if (AwardId.Contains('_'))
            {
                // Make sure the award exists!
                string[] parts = AwardId.Split('_');
                if (!StatsConstants.Awards.ContainsKey(parts[0]))
                    throw new Exception("Not a valid badge ID");

                switch (parts[1])
                {
                    default:
                    case "1": return "Basic " + StatsConstants.Awards[parts[0]];
                    case "2": return "Veteran " + StatsConstants.Awards[parts[0]];
                    case "3": return "Expert " + StatsConstants.Awards[parts[0]];
                }
            }

            // Make sure the award exists
            if (!StatsConstants.Awards.ContainsKey(AwardId))
                throw new Exception("Invalid Award ID");

            return StatsConstants.Awards[AwardId];
        }

Usage Example

        /// <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();
            }
        }
All Usage Examples Of BF2Statistics.MedalData.Award::GetName