Server.cs 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Runtime.Serialization;
  5. using System.ServiceModel;
  6. using System.ServiceModel.Web;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. namespace BBIWARG.API
  10. {
  11. // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Server" in both code and config file together.
  12. public class Server : IServer
  13. {
  14. [WebInvoke(Method = "GET",
  15. ResponseFormat = WebMessageFormat.Json,
  16. UriTemplate = "grid")]
  17. public Grid getGrid()
  18. {
  19. return Grid.getInctance();
  20. }
  21. [WebInvoke(Method = "POST",
  22. RequestFormat = WebMessageFormat.Json,
  23. ResponseFormat = WebMessageFormat.Json,
  24. UriTemplate = "grid")]
  25. public string setGrid(Grid grid)
  26. {
  27. try
  28. {
  29. Grid.getInctance().Cols = grid.Cols;
  30. Grid.getInctance().Rows = grid.Rows;
  31. /*Output.DebugOutput.DebugWindow.palmGridNumColumnsTrackBar.Invoke((MethodInvoker)delegate {
  32. Output.DebugOutput.DebugWindow.palmGridNumColumnsTrackBar.Value = grid.Cols;
  33. });
  34. Output.DebugOutput.DebugWindow.palmGridNumRowsTrackBar.Invoke((MethodInvoker)delegate {
  35. Output.DebugOutput.DebugWindow.palmGridNumRowsTrackBar.Value = grid.Rows;
  36. });*/
  37. return "Done!";
  38. }
  39. catch(Exception e)
  40. { return e.ToString(); }
  41. }
  42. [WebInvoke(Method = "GET",
  43. ResponseFormat = WebMessageFormat.Json,
  44. UriTemplate = "slider")]
  45. public Slider getSlider()
  46. {
  47. Slider.getInctance().Cur = Parameters.PalmSliderCurr;
  48. Slider.getInctance().Pos = Parameters.PalmSliderPos;
  49. Slider.getInctance().Max = Parameters.PalmSliderMax;
  50. return Slider.getInctance();
  51. }
  52. [WebInvoke(Method = "POST",
  53. RequestFormat = WebMessageFormat.Json,
  54. ResponseFormat = WebMessageFormat.Json,
  55. UriTemplate = "slider")]
  56. public string setSlider(Slider slider)
  57. {
  58. try
  59. {
  60. Slider.getInctance().Cur = slider.Cur;
  61. Slider.getInctance().Pos = slider.Pos;
  62. Slider.getInctance().Max = slider.Max;
  63. Parameters.PalmSliderCurr = slider.Cur;
  64. Parameters.PalmSliderPos = slider.Pos;
  65. Parameters.PalmSliderMax = slider.Max;
  66. return "Done!";
  67. }
  68. catch (Exception e)
  69. { return e.ToString(); }
  70. }
  71. }
  72. }