Esempio n. 1
0
        private void LoadClanIcons(WebIconList iconsList, string localPath)
        {
            var clanIcons = from icon in iconsList.Icons
                            where !string.IsNullOrEmpty(icon.ClanRank)
                            select icon;

            foreach (var clanIconEntry in clanIcons)
            {
                string[] appropriateRanks = clanIconEntry.ClanRank.Contains(",") ? clanIconEntry.ClanRank.Split(',') : new string[] { clanIconEntry.ClanRank };
                Image currentImage = null;
                try
                {
                    currentImage = LoadImageFromFile(Path.Combine(localPath, clanIconEntry.LocalName));
                }
                catch
                {
                    // TODO: Log the error or report it.
                    continue;
                }

                foreach (string rankName in appropriateRanks)
                {
                    try
                    {
                        ClanRank actualRank = (ClanRank)Enum.Parse(typeof(ClanRank), rankName);
                        m_ranksToImages.Add(actualRank, currentImage);
                    }
                    catch
                    {
                        // TODO: Log the error or report it.
                        continue;
                    }
                }
            }
        }
Esempio n. 2
0
        private void LoadFlagsIcons(WebIconList iconsList, string localPath)
        {
            var flagsIcons = from icon in iconsList.Icons
                             where !string.IsNullOrEmpty(icon.UserFlags)
                             select icon;

            foreach (var flagsIconEntry in flagsIcons)
            {
                string[] appropriateFlags = flagsIconEntry.UserFlags.Contains(",") ? flagsIconEntry.UserFlags.Split(',') : new string[] { flagsIconEntry.UserFlags };
                Image currentImage = null;
                try
                {
                    currentImage = LoadImageFromFile(Path.Combine(localPath, flagsIconEntry.LocalName));
                }
                catch
                {
                    // TODO: Log the error or report it.
                    continue;
                }

                foreach (string flagName in appropriateFlags)
                {
                    try
                    {
                        UserFlags actualFlag = (UserFlags)Enum.Parse(typeof(UserFlags), flagName);
                        m_flagsToImages.Add(actualFlag, currentImage);
                    }
                    catch
                    {
                        // TODO: Log the error or report it.
                        continue;
                    }
                }
            }
        }
Esempio n. 3
0
        private void LoadTieredClientIcons(WebIconList iconsList, string localPath)
        {
            WebIcon defaultTierIcon = (from icon in iconsList.Icons
                                       where !string.IsNullOrEmpty(icon.ClientID) && icon.Tier == 1
                                       select icon).FirstOrDefault();

            if (!object.ReferenceEquals(defaultTierIcon, null))
            {
                try
                {
                    m_defaultTierIcon = LoadImageFromFile(Path.Combine(localPath, defaultTierIcon.LocalName));
                }
                catch
                {
                    // TODO: Log the error or report it.
                }
            }

            var tieredClientIcons = from icon in iconsList.Icons
                                    where !string.IsNullOrEmpty(icon.ClientID) && icon.Tier > 1
                                    select icon;
            foreach (var tcIcon in tieredClientIcons)
            {
                // for tiered icons, assume each icon can only have one client.
                Image currentImage = null;
                try
                {
                    currentImage = LoadImageFromFile(Path.Combine(localPath, tcIcon.LocalName));
                }
                catch
                {
                    // TODO: Log the error or report it.
                    continue;
                }

                if (!m_tieredClientImages.ContainsKey(tcIcon.ClientID))
                    m_tieredClientImages.Add(tcIcon.ClientID, new Dictionary<int, Dictionary<char, Image>>());

                Dictionary<int, Dictionary<char, Image>> tierList = m_tieredClientImages[tcIcon.ClientID];

                if (!tierList.ContainsKey(tcIcon.Tier))
                    tierList.Add(tcIcon.Tier, new Dictionary<char, Image>());

                Dictionary<char, Image> raceList = tierList[tcIcon.Tier];
                raceList.Add(tcIcon.Race, currentImage);
            }
        }
Esempio n. 4
0
        private void LoadNonTieredClientIcons(WebIconList iconsList, string localPath)
        {
            var nonTieredClientIcons = from icon in iconsList.Icons
                                       where !string.IsNullOrEmpty(icon.ClientID) && icon.Tier == 0
                                       select icon;

            foreach (var ntcIcon in nonTieredClientIcons)
            {
                string[] clients = ntcIcon.ClientID.Contains(",") ? ntcIcon.ClientID.Split(',') : new string[] { ntcIcon.ClientID };
                Image currentImage = null;
                try
                {
                    currentImage = LoadImageFromFile(Path.Combine(localPath, ntcIcon.LocalName));
                }
                catch
                {
                    // TODO: Log the error or report it.
                    continue;
                }

                foreach (string clientName in clients)
                {
                    m_nonTieredClientImages.Add(clientName, currentImage);
                }
            }
        }
Esempio n. 5
0
        private void bwDownload_DoWork(object sender, DoWorkEventArgs e)
        {
            if (TaskbarManager.IsPlatformSupported)
            {
                //BeginInvoke((ThreadStart)delegate() { TaskbarManager.Instance.SetProgressState(TaskbarProgressBarState.Normal, Handle); });
            }

            bwDownload.ReportProgress(0, "icons.bni");

            BnFtpVersion1Request req = new BnFtpVersion1Request("STAR", "icons.bni", null);
            req.LocalFileName = Path.Combine(JinxBotConfiguration.ApplicationDataPath, "icons.bni");
            req.FilePartDownloaded += new DownloadStatusEventHandler(req_FilePartDownloaded);
            req.ExecuteRequest();
            JumpListIconManager.CreateJumpListImages(req.LocalFileName);

            WebIconList iconsList = null;

            string xml = DataResources.WebIconsList;
            using (StringReader sr = new StringReader(xml))
            using (XmlTextReader xtr = new XmlTextReader(sr))
            {
                try
                {
                    XmlSerializer ser = new XmlSerializer(typeof(WebIconList));
                    iconsList = ser.Deserialize(xtr) as WebIconList;
                }
                catch (Exception)
                {
                    // TODO: Log the exception.
                    MessageBox.Show("There was an error loading the icons list.", "Error Downloading Icons", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    iconsList = new WebIconList() { Icons = new WebIconList.Icon[0] };
                }
            }

            for (int i = 0; i < iconsList.Icons.Length; i++)
            {
                bwDownload.ReportProgress(i * 100 / iconsList.Icons.Length, iconsList.Icons[i].Uri);
                DownloadFile(iconsList.Icons[i]);
            }
        }