public static string ReadFile(Form1 form, string path, FitnessCalc calc)
        {
            try
            {
                using (StreamReader sr = new StreamReader(path))
                {
                    return(sr.ReadToEnd());

                    /*
                     * float fitnessValue = 0;
                     * while (sr.Peek() >= 0)
                     * {
                     *
                     *  fitnessValue += calc.InputCharacter((char)sr.Read());
                     *
                     *  form.PrintChar((char)sr.Read());
                     * }
                     *
                     */
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("The process failed: {0}", e.ToString());
                return(null);
            }
        }
        public GAController(KeyboardManager _kbManager, FitnessCalc _fitnessCalc, SettingsManager _settingsManager, string _stringToCalc)
        {
            kbManager = _kbManager;
            fitnessCalc = _fitnessCalc;
            settingsManager = _settingsManager;
            stringToCalc = _stringToCalc;

            population = new List<KeyValuePair<char[][], float>>();

            
            


        }
Пример #3
0
        public Form1()
        {
            InitializeComponent();
            keyboardManager = new KeyboardManager();
            settingsManager = new SettingsManager();
            fitnessValue    = new FitnessCalc();



            this.KeyPress += new KeyPressEventHandler(Form1_KeyPress);

            settingsManager.currentFingerSetting = FingerKeySet.FingerSettings.SimpleSetting;

            PrintKeyBoard(keyboardManager.ReturnQWERTY());

            //Console.WriteLine(fitnessValue.CalcDistance(Utilities.FindInDimensions(shownKeyboard, 'E'), Utilities.FindInDimensions(shownKeyboard, 'V'), 0));

            SetKeyColors();
        }