sfWindow.cs
上传用户:lctyggxszx
上传日期:2022-06-30
资源大小:280k
文件大小:2k
源码类别:

FlashMX/Flex源码

开发平台:

C#

  1. using System;
  2. using System.Collections;
  3. using System.ComponentModel;
  4. using System.Windows.Forms;
  5. using AxShockwaveFlashObjects;
  6. using Mueller.Wddx;
  7. namespace SharpFlash
  8. {
  9. /// <summary>
  10. /// Summary description for sfWindow.
  11. /// </summary>
  12. public class sfWindow
  13. {
  14. private static WddxSerializer wddxSerializer = new WddxSerializer();
  15. public sfWindow() {}
  16. // Main library method, determines what was sent from Flash and
  17. // calls the appropriate worker function.
  18. public static void Command(Form form, AxShockwaveFlash flashApp, string list, string method) {
  19. switch(method) {
  20. case "getApplicationPath":
  21. sfWindow.getApplicationPath(form, flashApp, list);
  22. break;
  23. case "getWindowText":
  24. sfWindow.getWindowText(form, flashApp, list);
  25. break;
  26. case "hide":
  27. sfWindow.hide(form);
  28. break;
  29. case "moveTo":
  30. sfWindow.moveTo(form, flashApp, list);
  31. break;
  32. case "setWindowText":
  33. sfWindow.setWindowText(form, flashApp, list);
  34. break;
  35. case "show":
  36. sfWindow.show(form);
  37. break;
  38. case "toggleVisibility":
  39. sfWindow.toggleVisibility(form);
  40. break;
  41. }
  42. }
  43. public static void moveTo(Form form, AxShockwaveFlash flashApp, string list) {
  44. string[] temp = list.Split(',');
  45. int x = Int32.Parse(temp[0]); 
  46. int y = Int32.Parse(temp[1]); 
  47. form.Location = new System.Drawing.Point(x,y);
  48. }
  49. public static void getWindowText(Form form, AxShockwaveFlash flashApp, string list) 
  50. {
  51. flashApp.SetVariable("$SFData", "<sf><callback><id>" + list + "</id>" 
  52. + "<args>"
  53. + "<arg>" + wddxSerializer.Serialize(form.Text).ToString() + "</arg>"
  54. + "</args></callback></sf>");
  55. }
  56. public static void getApplicationPath(Form form, AxShockwaveFlash flashApp, string list) 
  57. {
  58. flashApp.SetVariable("$SFData", "<sf><callback><id>" + list + "</id>" 
  59. + "<args>"
  60. + "<arg>" + wddxSerializer.Serialize(Application.StartupPath).ToString() + "</arg>"
  61. + "</args></callback></sf>");
  62. }
  63. public static void setWindowText(Form form, AxShockwaveFlash flashApp, string list) 
  64. {
  65. form.Text = list;
  66. }
  67. public static void hide(Form form) 
  68. {
  69. form.Visible = false;
  70. }
  71. public static void show(Form form) 
  72. {
  73. form.Visible = true;
  74. }
  75. public static void toggleVisibility(Form form) 
  76. {
  77. form.Visible = !form.Visible;
  78. }
  79. }
  80. }