Beispiel #1
0
        private void ReNameContols(string ControlType)
        {
            bool     IsReNameAll = GlobalMethods.Misc.IsEmptyString(ControlType);
            IControl control     = null;

            if (ControlType == "XCheckBox" || IsReNameAll)
            {
                control = new XCheckBox();
                this.RefreshContols(control, "XCheckBox");
            }
            if (ControlType == "XDateTime" || IsReNameAll)
            {
                control = new XDateTime();
                this.RefreshContols(control, "XDateTime");
            }
            if (ControlType == "XRadioButton" || IsReNameAll)
            {
                control = new XRadioButton();
                this.RefreshContols(control, "XRadioButton");
            }
            if (ControlType == "XTextBox" || IsReNameAll)
            {
                control = new XTextBox();
                this.RefreshContols(control, "XTextBox");
            }
            if (ControlType == "XComboBox" || IsReNameAll)
            {
                control = new XComboBox();
                this.RefreshContols(control, "XComboBox");
            }
        }
        private static void Main(string[] args)
        {
            const double maxAmplitude = 1000;
            double       coefLong     = 36; // I want my sine function to have period of 36 units
            double       coefShort    = 13; // I want my sine function to have period of 7 units

            double degreeCoefLong   = 360 / coefLong;
            double degreeCoefShort  = 360 / coefShort;
            double halfAmplitude    = maxAmplitude / 2;
            double quarterAmplitude = maxAmplitude / 4;


            // The code provided will print ‘Hello World’ to the console.
            // Press Ctrl+F5 (or go to Debug > Start Without Debugging) to run your app.
            Console.WriteLine("MathTest Console");
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();

            // Open csv file
            IoHelper.CreateDirectory(path);
            var fullFilePath = path + baseFileName + XDateTime.NowToFileSuffix() + fileExt;

            TextFileHelper.OpenTextFileForWrite(fullFilePath, false);
            // Write header
            TextFileHelper.AppendLine("Degrees," +
                                      "Sin," +
                                      "Sin+1," +
                                      "Amplified Sin + 1," +
                                      "Amplified SinShort + 1," +
                                      "Amplified SinLong + 1," +
                                      "Mixed,"
                                      );

            for (int degree = 0; degree < 720; degree++)
            {
                var sin      = Math.Sin(degree * Math.PI / 180);
                var sinShort = Math.Sin(degreeCoefShort * degree * Math.PI / 180);
                var sinLong  = Math.Sin(degreeCoefLong * degree * Math.PI / 180);
                //Console.WriteLine($"{degree}°: Sin={sin:f4}");
                // write data to CSV file
                TextFileHelper.AppendLine($"{degree}," +
                                          $"{sin}," +
                                          $"{sin+1}," +
                                          $"{halfAmplitude * (sin + 1)}," +
                                          $"{halfAmplitude * (sinShort + 1)}," +
                                          $"{halfAmplitude * (sinLong + 1)}," +
                                          $"{quarterAmplitude * (sinShort + sinLong + 2)},"
                                          );
            }

            TextFileHelper.CloseWriteTextFile();
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("Press any key ...");
            //Console.ReadKey();

            GlobalHelper.ProcessStart(fullFilePath);
        }
        private static void Report()
        {
            var elapsed = DateTime.Now - _startTime;
            var estimatedMilliseconds = elapsed.TotalMilliseconds / World.TimeIdx * (SimDuration - World.TimeIdx);
            var estimatedFinish       = XDateTime.MilliSecParseToSec(estimatedMilliseconds);

            ConsoleHelper.Black();
            Console.Write($"{Simulator.TimeIndex}:");
            ConsoleHelper.DarkRed();
            Console.Write($" Population: {World.Population}".PadRight(20));
            ConsoleHelper.DarkGreen();
            Console.Write($" Resources: {World.ResourceLevel:n0}".PadRight(22));
            ConsoleHelper.Black();
            Console.Write($" Dying: {World.LastDyingCount}".PadRight(16));
            ConsoleHelper.White();
            Console.Write($" Born: {World.LastBabyCount}".PadRight(16));
            ConsoleHelper.Red();
            Console.WriteLine($" ETA: {estimatedFinish}");


            ConsoleHelper.Black();
        }