コード例 #1
0
        /// <summary>
        /// 按键
        /// </summary>
        /// <param name="enumKeyboardKey"></param>
        private void keyoption(OptionKeys enumKeyboardKey)
        {
            //if (Config.ScreenMode == ScreenMode.Desktop)
            //{
            //    WindowsAPI.KeyDown(enumKeyboardKey.Key);
            //    Thread.Sleep(300);
            //    WindowsAPI.KeyUp(enumKeyboardKey.Key);
            //    Write("按下:" + enumKeyboardKey.Key.ToString());
            //}
            //else if (Config.ScreenMode == ScreenMode.Window || Config.ScreenMode == ScreenMode.Vriual)
            //{
            string s = "";

            if (enumKeyboardKey.IsDrag)
            {
                s = "shell input swipe " + (enumKeyboardKey.Position.X + Random.Next(-5, 5)).ToString()
                    + " " + (enumKeyboardKey.Position.Y + Random.Next(-5, 5)).ToString() + " " + (enumKeyboardKey.EndPosition.X + Random.Next(-5, 5)).ToString()
                    + " " + (enumKeyboardKey.EndPosition.Y + Random.Next(-5, 5)).ToString() + " 600";
            }
            else
            {
                s = "shell input tap " + (enumKeyboardKey.Position.X + Random.Next(-5, 5))
                    + " " + (enumKeyboardKey.Position.Y + Random.Next(-5, 5));
                //Write(s);
            }
            Martian.startADBEXE(s, Config.VriualExePath);
            //}

            Thread.Sleep(Random.Next(Config.KeyPressWaitMinTime, Config.KeyPressWaitMaxTime));
            //Write("按下了 : " + enumKeyboardKey);
        }
コード例 #2
0
ファイル: MainViewModel.cs プロジェクト: shad0w008/NLTest
 void OnRemoveMartian(Martian martian)
 {
     if (martian != null)
     {
         Martians.Remove(martian);
         _removedMartians.Add(martian);
     }
 }
コード例 #3
0
        public void TestCase01()
        {
            const string message = "STATUS";

            var cameraRotations = Martian.GetCameraRotations(message).ToArray();

            const double tolerance = 0.001;

            Assert.IsTrue(Math.Abs(cameraRotations[0] - 1.963) <= tolerance);  // 5 * PI/8
            Assert.IsTrue(Math.Abs(cameraRotations[1] - 1.178) <= tolerance);  // 3 * PI/8
            Assert.IsTrue(Math.Abs(cameraRotations[2] - 1.963) <= tolerance);  // 5 * PI/8
            Assert.IsTrue(Math.Abs(cameraRotations[3] - 1.570) <= tolerance);  // PI/2
            Assert.IsTrue(Math.Abs(cameraRotations[4] - 1.570) <= tolerance);  // PI/2
            Assert.IsTrue(Math.Abs(cameraRotations[5] - 0.392) <= tolerance);  // PI/8
            Assert.IsTrue(Math.Abs(cameraRotations[6] - 1.963) <= tolerance);  // 5 * PI/8
            Assert.IsTrue(Math.Abs(cameraRotations[7] - 1.570) <= tolerance);  // PI/2
            Assert.IsTrue(Math.Abs(cameraRotations[8] - 1.963) <= tolerance);  // 5 * PI/8
            Assert.IsTrue(Math.Abs(cameraRotations[9] - 1.963) <= tolerance);  // 5 * PI/8
            Assert.IsTrue(Math.Abs(cameraRotations[10] - 1.963) <= tolerance); // 5 * PI/8
            Assert.IsTrue(Math.Abs(cameraRotations[11] - 1.178) <= tolerance); // 3 * PI/8
        }
コード例 #4
0
ファイル: MainViewModel.cs プロジェクト: shad0w008/NLTest
        async Task OnImportDataAsync()
        {
            var openFileDialog = new OpenFileDialog
            {
                Filter           = "CSV files (*.csv)|*.csv|TSV files (*.tsv)|*.tsv",
                RestoreDirectory = true
            };

            if (openFileDialog.ShowDialog() == true)
            {
                try
                {
                    var martians = new List <Martian>();
                    using (var parser = new TextFieldParser(openFileDialog.OpenFile()))
                    {
                        parser.TextFieldType = FieldType.Delimited;
                        parser.SetDelimiters(openFileDialog.FilterIndex == 1 ? "," : "\t");
                        while (!parser.EndOfData)
                        {
                            var martian = new Martian(parser.ReadFields());
                            if (!string.IsNullOrEmpty(martian.FullName) && !string.IsNullOrEmpty(martian.BirthDate) && (!string.IsNullOrEmpty(martian.Phone) || !string.IsNullOrEmpty(martian.Email)))
                            {
                                martians.Add(martian);
                            }
                        }
                        AddMartians(martians);
                    }
                    Bootstrapper.DataBaseContext.Martians.AddRange(martians);
                    await Bootstrapper.DataBaseContext.SaveChangesAsync();

                    MessageBox.Show("Импорт данных завершен");
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message);
                }
            }
        }
コード例 #5
0
    static void Main(string[] args)
    {
        DateTime       next;
        bool           quit = false;
        ConsoleKeyInfo cki;
        Directions     direction = Directions.None;

        Console.Clear();
        Console.CursorVisible = false;
        var m = new Martian();
        var s = new SpaceShip();

        m.Draw(true);
        s.Draw(true);
        do
        {
            // wait for next keypress, or next movement
            next = new DateTime(Math.Min(m.nextMovement.Ticks, s.nextMovement.Ticks));
            while (!Console.KeyAvailable && DateTime.Now < next)
            {
                System.Threading.Thread.Sleep(10);
            }
            // was a key pressed?
            if (Console.KeyAvailable)
            {
                cki = Console.ReadKey(true);
                switch (cki.Key)
                {
                case ConsoleKey.UpArrow:
                    direction = Directions.Up;
                    break;

                case ConsoleKey.DownArrow:
                    direction = Directions.Down;
                    break;

                case ConsoleKey.Escape:
                    quit = true;
                    break;
                }
            }
            // does anything need to move?
            if (DateTime.Now >= m.nextMovement)
            {
                switch (direction)
                {
                case Directions.Up:
                    m.MoveUp();
                    break;

                case Directions.Down:
                    m.MoveDown();
                    break;

                case Directions.None:
                    m.UpdateNextMovement();
                    break;
                }
            }
            if (DateTime.Now >= s.nextMovement)
            {
                s.MoveToward(m);
            }
        } while (!quit);
    }