Exemple #1
0
        public override void KeyDown(KeyEventArgs e)
        {
            base.KeyDown(e);

            if (e.KeyCode == Keys.A)
            {
                PushState(new AboutScreenState());
            }
            else if (e.KeyCode == Keys.D)
            {
                PushState(new CurveDrawerScreenState());
            }
            else if (e.KeyCode == Keys.F)
            {
                var dlg = new OpenFileDialog();
                dlg.Filter     = "Text Files | *.txt";
                dlg.DefaultExt = "txt";
                dlg.FileOk    += (sender, args) =>
                {
                    var points = InputFactory.PointsFromFile(dlg.FileName);
                    PushState(new CurveDrawerScreenState(points));
                };
                dlg.ShowDialog();
            }

            else if (e.KeyCode == Keys.R)
            {
                var points = InputFactory.RandomPoints().TakeWhile(p => p.X < 760);
                PushState(new CurveDrawerScreenState(points));
            }
            else if (e.KeyCode == Keys.L)
            {
                var points = InputFactory.ManyRandomPoints().TakeWhile(p => p.X < 760);
                PushState(new CurveDrawerScreenState(points));
            }
        }