Ejemplo n.º 1
0
        /// <summary>
        /// Initial settings.
        /// </summary>
        public static void Start()
        {
            // Sets the date format.
            if (DateTimeFormatInfo.CurrentInfo != null)
            {
                DF = DateTimeFormatInfo.CurrentInfo.ShortDatePattern;
            }
            if (DF == "dd/MM yyyy")
            {
                DF = "dd/MM/yyyy";    // Fixes the Uzbek (Latin) issue
            }
            DF = DF.Replace(" ", ""); // Fixes the Slovenian issue
            if (DateTimeFormatInfo.CurrentInfo != null)
            {
                char[]   acDS = DateTimeFormatInfo.CurrentInfo.DateSeparator.ToCharArray();
                string[] asSS = DF.Split(acDS, 3);
                asSS[0] = asSS[0].Substring(0, 1) + asSS[0].Substring(0, 1);
                asSS[1] = asSS[1].Substring(0, 1) + asSS[1].Substring(0, 1);
                asSS[2] = asSS[2].Substring(0, 1) + asSS[2].Substring(0, 1);
                DF      = asSS[0] + acDS[0] + asSS[1] + acDS[0] + asSS[2];

                if (asSS[0].ToUpper() == "YY")
                {
                    DFS = asSS[1] + acDS[0] + asSS[2];
                }
                else if (asSS[1].ToUpper() == "YY")
                {
                    DFS = asSS[0] + acDS[0] + asSS[2];
                }
                else
                {
                    DFS = asSS[0] + acDS[0] + asSS[1];
                }
            }

            // Point character
            CultureInfo cultureInfo = CultureInfo.CurrentCulture;

            PointChar = cultureInfo.NumberFormat.NumberDecimalSeparator.ToCharArray()[0];

            // Set the working directories
            ProgramDir            = Directory.GetCurrentDirectory();
            DefaultOfflineDataDir = Path.Combine(ProgramDir, OfflineDataDir);
            OfflineDataDir        = DefaultOfflineDataDir;
            OfflineDocsDir        = Path.Combine(ProgramDir, OfflineDocsDir);
            StrategyDir           = Path.Combine(ProgramDir, DefaultStrategyDir);
            SourceFolder          = Path.Combine(ProgramDir, SourceFolder);
            SystemDir             = Path.Combine(ProgramDir, SystemDir);
            LanguageDir           = Path.Combine(SystemDir, LanguageDir);
            ColorDir = Path.Combine(SystemDir, ColorDir);

            // Scanner colors
            PeriodColor.Add(DataPeriods.min1, Color.Yellow);
            PeriodColor.Add(DataPeriods.min5, Color.Lime);
            PeriodColor.Add(DataPeriods.min15, Color.Green);
            PeriodColor.Add(DataPeriods.min30, Color.Orange);
            PeriodColor.Add(DataPeriods.hour1, Color.DarkSalmon);
            PeriodColor.Add(DataPeriods.hour4, Color.Peru);
            PeriodColor.Add(DataPeriods.day, Color.Red);
            PeriodColor.Add(DataPeriods.week, Color.DarkViolet);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initial settings.
        /// </summary>
        public static void Start()
        {
            // Sets the date format.
            if (DateTimeFormatInfo.CurrentInfo != null)
            {
                DF = DateTimeFormatInfo.CurrentInfo.ShortDatePattern;
                if (DF == "dd/MM yyyy")
                {
                    DF = "dd/MM/yyyy";    // Fixes the Uzbek (Latin) issue
                }
                DF = DF.Replace(" ", ""); // Fixes the Sloven issue
                char[]   acDS = DateTimeFormatInfo.CurrentInfo.DateSeparator.ToCharArray();
                string[] asSS = DF.Split(acDS, 3);
                asSS[0] = asSS[0].Substring(0, 1) + asSS[0].Substring(0, 1);
                asSS[1] = asSS[1].Substring(0, 1) + asSS[1].Substring(0, 1);
                asSS[2] = asSS[2].Substring(0, 1) + asSS[2].Substring(0, 1);
                DF      = asSS[0] + acDS[0].ToString(CultureInfo.InvariantCulture) + asSS[1] +
                          acDS[0].ToString(CultureInfo.InvariantCulture) + asSS[2];

                if (asSS[0].ToUpper() == "YY")
                {
                    DFS = asSS[1] + acDS[0].ToString(CultureInfo.InvariantCulture) + asSS[2];
                }
                else if (asSS[1].ToUpper() == "YY")
                {
                    DFS = asSS[0] + acDS[0].ToString(CultureInfo.InvariantCulture) + asSS[2];
                }
                else
                {
                    DFS = asSS[0] + acDS[0].ToString(CultureInfo.InvariantCulture) + asSS[1];
                }
            }

            // Point character
            CultureInfo culInf = CultureInfo.CurrentCulture;

            PointChar = culInf.NumberFormat.NumberDecimalSeparator.ToCharArray()[0];

            // Set the working directories
            ProgramDir   = Directory.GetCurrentDirectory();
            StrategyDir  = Path.Combine(ProgramDir, DefaultStrategyDir);
            SourceFolder = Path.Combine(ProgramDir, SourceFolder);
            SystemDir    = Path.Combine(ProgramDir, SystemDir);
            LanguageDir  = Path.Combine(SystemDir, LanguageDir);
            ColorDir     = Path.Combine(SystemDir, ColorDir);

            try
            {
                SoundConnect         = new SoundPlayer(Path.Combine(SystemDir, @"Sounds\connect.wav"));
                SoundDisconnect      = new SoundPlayer(Path.Combine(SystemDir, @"Sounds\disconnect.wav"));
                SoundError           = new SoundPlayer(Path.Combine(SystemDir, @"Sounds\error.wav"));
                SoundOrderSent       = new SoundPlayer(Path.Combine(SystemDir, @"Sounds\order_sent.wav"));
                SoundPositionChanged = new SoundPlayer(Path.Combine(SystemDir, @"Sounds\position_changed.wav"));
            }
            catch
            {
                SoundConnect         = new SoundPlayer(Resources.sound_connect);
                SoundDisconnect      = new SoundPlayer(Resources.sound_disconnect);
                SoundError           = new SoundPlayer(Resources.sound_error);
                SoundOrderSent       = new SoundPlayer(Resources.sound_order_sent);
                SoundPositionChanged = new SoundPlayer(Resources.sound_position_changed);
            }

            Logger = new Logger();
        }
Ejemplo n.º 3
0
        public void Summary()
        {
            string[] dataFile = Directory.GetFiles(pathData, "*.data");

            foreach (string DF in dataFile)
            {
                string fileName = DF.Replace(pathData, "");
                if (IsNotInCollectingCounter(fileName))
                {
                    XmlDocument SummaryXML  = new XmlDocument();
                    string      counterName = fileName.Remove(fileName.Length - 5).Split(' ')[1];
                    string      summaryFile = pathSummary + "Summary " + counterName + ".xml";
                    if (!File.Exists(pathSummary + "Summary " + counterName + ".xml"))
                    {
                        XmlDeclaration xmlDeclaration = SummaryXML.CreateXmlDeclaration("1.0", "UTF-8", null);
                        XmlElement     DE             = SummaryXML.DocumentElement;
                        SummaryXML.InsertBefore(xmlDeclaration, DE);
                        XmlElement root = SummaryXML.CreateElement(counterName);
                        SummaryXML.AppendChild(root);
                    }
                    else
                    {
                        SummaryXML.Load(summaryFile);
                    }
                    StreamReader SR = new StreamReader(DF);

                    string     DateInFile  = fileName.Remove(10);
                    XmlElement dateElement = SummaryXML.CreateElement("Date");
                    dateElement.SetAttribute("Value", DateInFile);

                    char[] Data = SR.ReadToEnd().ToCharArray();

                    Dictionary <char, int> dict = new Dictionary <char, int>();
                    foreach (char c in Data)
                    {
                        if (dict.ContainsKey(c))
                        {
                            dict[c]++;
                        }
                        else
                        {
                            dict.Add(c, 1);
                        }
                    }

                    XmlElement dataElement;
                    XmlText    dataText;

                    for (int i = 0; i < levelCount; i++)
                    {
                        try
                        {
                            dataElement = SummaryXML.CreateElement("Range" + (i + 1).ToString());
                            dataText    = SummaryXML.CreateTextNode(dict[(i + 1).ToString().ToCharArray()[0]].ToString());
                            dataElement.AppendChild(dataText);
                            dateElement.AppendChild(dataElement);
                        }
                        catch
                        {
                            dataElement = SummaryXML.CreateElement("Range" + (i + 1).ToString());
                            dataText    = SummaryXML.CreateTextNode(Convert.ToString(0));
                            dataElement.AppendChild(dataText);
                            dateElement.AppendChild(dataElement);
                        }
                    }

                    SummaryXML.DocumentElement.AppendChild(dateElement);
                    SummaryXML.Save(summaryFile);
                    SR.Close();
                    File.Delete(pathData + fileName);
                }
            }
        }