MainBBWIWARG.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. Console.SetWindowSize(Parameters.ConsoleWidth, Parameters.ConsoleHeight);
  19. if (args.Length > 0)
  20. {
  21. handleArgs(args);
  22. }
  23. InputProvider inputProvider;
  24. if (Parameters.InputSource == InputType.Movie)
  25. inputProvider = new VideoInputProvider(Parameters.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(Parameters.OutputUpdateRate, Parameters.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 Parameters.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:" + Parameters.TuioIP.ToString());
  56. while (!TuioCommunicator.tryParsePort(portString, out Parameters.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:" + Parameters.TuioPort);
  62. Parameters.TuioEnabled = true;
  63. }
  64. }
  65. }