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

FlashMX/Flex源码

开发平台:

C#

  1. using System;
  2. using System.Drawing;
  3. using System.Collections;
  4. using System.ComponentModel;
  5. using System.Windows.Forms;
  6. using System.Data;
  7. using System.Threading;
  8. namespace SharpFlash
  9. {
  10. /// <summary>
  11. /// SharpFlash GUI
  12. /// </summary>
  13. public class SharpFlash : System.Windows.Forms.Form
  14. {
  15. // :TODO: since most of the libraries
  16. // reference Mueller.WDDX for serializing data, it would
  17. // probably be best to create an instance once here, and
  18. // then just keep re-using that instance in every library
  19. // to save on memory.
  20. private AxShockwaveFlashObjects.AxShockwaveFlash flashApp;
  21. /// <summary>
  22. /// Required designer variable.
  23. /// </summary>
  24. private System.ComponentModel.Container components = null;
  25. public SharpFlash()
  26. {
  27. InitializeComponent();
  28. // register the .swf file for the active-x object
  29. flashApp.Movie = Application.StartupPath + "\SharpFlash.swf";
  30. // register the fscommand handler
  31. flashApp.FSCommand += new AxShockwaveFlashObjects._IShockwaveFlashEvents_FSCommandEventHandler(flashApp_FSCommandEventHandler);
  32. }
  33. protected override void Dispose( bool disposing )
  34. {
  35. if( disposing )
  36. {
  37. if (components != null) 
  38. {
  39. components.Dispose();
  40. }
  41. }
  42. base.Dispose( disposing );
  43. }
  44. #region Windows Form Designer generated code
  45. private void InitializeComponent()
  46. {
  47. System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(SharpFlash));
  48. this.flashApp = new AxShockwaveFlashObjects.AxShockwaveFlash();
  49. ((System.ComponentModel.ISupportInitialize)(this.flashApp)).BeginInit();
  50. this.SuspendLayout();
  51. // 
  52. // flashApp
  53. // 
  54. this.flashApp.Enabled = true;
  55. this.flashApp.Location = new System.Drawing.Point(0, 0);
  56. this.flashApp.Name = "flashApp";
  57. this.flashApp.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("flashApp.OcxState")));
  58. this.flashApp.Size = new System.Drawing.Size(500, 400);
  59. this.flashApp.TabIndex = 0;
  60. // 
  61. // SharpFlash
  62. // 
  63. this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
  64. this.ClientSize = new System.Drawing.Size(500, 400);
  65. this.Controls.Add(this.flashApp);
  66. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
  67. this.Name = "SharpFlash";
  68. this.Text = "SharpFlash";
  69. this.Closing += new System.ComponentModel.CancelEventHandler(this.SharpFlash_Closing);
  70. ((System.ComponentModel.ISupportInitialize)(this.flashApp)).EndInit();
  71. this.ResumeLayout(false);
  72. }
  73. #endregion
  74. [STAThread]
  75. static void Main() 
  76. {
  77. Application.Run(new SharpFlash());
  78. }
  79. private void flashApp_FSCommandEventHandler(object sender, AxShockwaveFlashObjects._IShockwaveFlashEvents_FSCommandEvent e)
  80. {
  81. // figure out which library is being invoked
  82. string library = e.command.Substring(0,e.command.IndexOf("."));
  83. // figure out which method of the library is being invoked
  84. string methodName = e.command.Substring(e.command.IndexOf(".")+1);
  85. // pass off the information to the library and let it
  86. // do it's job.
  87. switch(library) {
  88. case "sfFile":
  89. sfFile.Command(this, flashApp, e.args, methodName);
  90. break;
  91. case "sfPrivate":
  92. sfPrivate.Command(this, flashApp, e.args, methodName);
  93. break;
  94. // sfSystem has a similar switch statement
  95. // to handle things like sfSystem.Registry 
  96. // and sfSystem.MessageBox
  97. case "sfSystem":
  98. sfSystem.Command(this, flashApp, e.args, methodName);
  99. break;
  100. case "sfUI":
  101. sfUI.Command(this, flashApp, e.args, methodName);
  102. break;
  103. case "sfWindow":
  104. sfWindow.Command(this, flashApp, e.args, methodName);
  105. break;
  106. }
  107. }
  108. // exit the application when the x button is clicked
  109. private void SharpFlash_Closing(object sender, System.ComponentModel.CancelEventArgs e)
  110. {
  111. Application.Exit();
  112. }
  113. }
  114. }