Forex_Strategy_Builder.Starting_Tips.LoadStartingTips C# (CSharp) Méthode

LoadStartingTips() private méthode

Load tips config file
private LoadStartingTips ( ) : void
Résultat void
        void LoadStartingTips()
        {
            // Header
            header  = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">";
            header += "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">";
            header += "<head><meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\" />";
            header += "<title>Tip of the Day</title><style>";
            header += "body {margin: 0px; font-size: 14px; background-color: #fffffd}";
            header += ".number {font-size: 9px}";
            header += ".content {padding: 0 5px 5px 5px;}";
            header += ".content h1 {margin: 0; font-weight: bold; font-size: 14px; color: #000033; text-align: center;}";
            header += ".content p {margin-top: 0.5em; margin-bottom: 2px; color: #000033; text-indent: 1em;}";
            header += "</style></head>";
            header += "<body>";
            header += "<div class=\"content\">";
            header += "<div class=\"number\">(###)</div>";

            // Footer
            footer = "</div></body></html>";

            indexTip = Configs.CurrentTipNumber + 1;

            if (showAllTips) indexTip = 0;

            string sStartingTipsDir = Data.SystemDir + @"StartingTips";

            if (Directory.Exists(sStartingTipsDir) && Directory.GetFiles(sStartingTipsDir).Length > 0)
            {
                string[] asLangFiles = Directory.GetFiles(sStartingTipsDir);

                foreach (string sLangFile in asLangFiles)
                {
                    if (sLangFile.EndsWith(".xml", true, null))
                    {
                        try
                        {
                            XmlDocument xmlLanguage = new XmlDocument();
                            xmlLanguage.Load(sLangFile);
                            XmlNode node = xmlLanguage.SelectSingleNode("tips//language");

                            if (node == null)
                            {   // There is no language specified int the lang file
                                string sMessageText = "Starting tip file: " + sLangFile + Environment.NewLine + Environment.NewLine + "The language is not specified!";
                                MessageBox.Show(sMessageText, "Tips of the Day File Loading", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            }
                            else if (node.InnerText == Configs.Language)
                            {   // It looks OK
                                xmlTips.Load(sLangFile);
                                tipsCount = xmlTips.SelectNodes("tips/tip").Count;
                            }
                        }
                        catch (Exception e)
                        {
                            string sMessageText = "Starting tip file: " + sLangFile + Environment.NewLine + Environment.NewLine +
                                "Error in the starting tip file!" + Environment.NewLine + Environment.NewLine + e.Message;
                            MessageBox.Show(sMessageText, "Tips of the Day File Loading", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                    }
                }
            }

            if (Configs.Language != "English" && tipsCount == 0)
            {
                try
                {   // The tips file
                    xmlTips.Load(Data.SystemDir + "StartingTips" + Path.DirectorySeparatorChar + "English.xml");
                    tipsCount = xmlTips.SelectNodes("tips/tip").Count;
                }
                catch (Exception e)
                {
                    string sMessageText = "Starting tip file \"English.xml\"" + Environment.NewLine + Environment.NewLine +
                        "Error in the starting tip file!" + Environment.NewLine + Environment.NewLine + e.Message;
                    MessageBox.Show(sMessageText, "Tips of the Day File Loading", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }

            return;
        }