MainBBWIWARG.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Threading;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Net;
  9. using bbiwarg.Graphics;
  10. using bbiwarg.InputProviders;
  11. using bbiwarg.Server;
  12. namespace bbiwarg
  13. {
  14. class MainBBIWARG
  15. {
  16. static void Main(string[] args)
  17. {
  18. if (args.Length > 0)
  19. {
  20. handleArgs(args);
  21. }
  22. Console.SetWindowSize(Constants.ConsoleWidth, Constants.ConsoleHeight);
  23. InputProvider inputProvider;
  24. if (Constants.InputSource == InputType.Movie)
  25. inputProvider = new VideoInputProvider(Constants.InputMoviePath);
  26. else
  27. inputProvider = new InputProvider();
  28. inputProvider.start();
  29. InputHandler inputHandler = new InputHandler(inputProvider);
  30. OutputWindow outputWindow = new OutputWindow(inputProvider, inputHandler);
  31. outputWindow.Run(Constants.OutputUpdateRate, Constants.OutputRenderRate);
  32. inputProvider.stop();
  33. }
  34. private static void handleArgs(String[] args)
  35. {
  36. String ipString = null;
  37. String portString = null;
  38. if (args.Length == 2)
  39. {
  40. ipString = args[0];
  41. portString = args[1];
  42. }
  43. else if (args.Length == 1)
  44. {
  45. String[] parts = args[0].Split(':');
  46. ipString = parts[0];
  47. if(parts.Length == 2)
  48. portString = parts[1];
  49. }
  50. while (!TuioCommunicator.tryParseIPAddress(ipString, out Constants.TuioIP))
  51. {
  52. Console.WriteLine("Please insert the TUIO-Client's IP (Default is 127.0.0.1):");
  53. ipString = Console.ReadLine();
  54. }
  55. Console.WriteLine("TUIO-IP is set to:" + Constants.TuioIP.ToString());
  56. while (!TuioCommunicator.tryParsePort(portString, out Constants.TuioPort))
  57. {
  58. Console.WriteLine("Please insert the TUIO-Client's Port (Default is 3333):");
  59. portString = Console.ReadLine();
  60. }
  61. Console.WriteLine("TUIO-PORT is set to:" + Constants.TuioPort);
  62. Constants.TuioEnabled = true;
  63. }
  64. }
  65. }