home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 July / CMCD0704.ISO / Software / Freeware / Grafica / Animation / AnimationStudioSetup.msi / _3CA7015D32004C8B8FAB422593C47FB8 / _921879316B2F41E22C78A352A1D8039C < prev    next >
Text File  |  2004-05-14  |  17KB  |  462 lines

  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.  
  8. namespace Tutorial_3
  9. {
  10.     /// <summary>
  11.     /// Summary description for Form1.
  12.     /// </summary>
  13.     public class Form1 : System.Windows.Forms.Form
  14.     {
  15.         private AnimationStudio.SpritePanel spritePanel1;
  16.         private AnimationStudio.Sprite sprite1;
  17.         private AnimationStudio.KeyFrame keyFrame2;
  18.         private AnimationStudio.KeyFrame keyFrame3;
  19.         private AnimationStudio.KeyFrame keyFrame4;
  20.         private AnimationStudio.KeyFrame keyFrame5;
  21.         private AnimationStudio.Sprite sprite2;
  22.         private AnimationStudio.Sprite sprite4;
  23.         private AnimationStudio.KeyFrame keyFrame6;
  24.         private AnimationStudio.KeyFrame keyFrame7;
  25.         private AnimationStudio.KeyFrame keyFrame8;
  26.         private AnimationStudio.KeyFrame keyFrame9;
  27.         private AnimationStudio.KeyFrame keyFrame10;
  28.         private AnimationStudio.KeyFrame keyFrame16;
  29.         private AnimationStudio.KeyFrame keyFrame17;
  30.         private AnimationStudio.Sprite sprite3;
  31.         private AnimationStudio.KeyFrame keyFrame11;
  32.         private AnimationStudio.KeyFrame keyFrame12;
  33.         private AnimationStudio.KeyFrame keyFrame13;
  34.         private AnimationStudio.KeyFrame keyFrame14;
  35.         private System.Windows.Forms.RichTextBox richTextBox1;
  36.         private AnimationStudio.KeyFrame keyFrame1;
  37.         /// <summary>
  38.         /// Required designer variable.
  39.         /// </summary>
  40.         private System.ComponentModel.Container components = null;
  41.  
  42.         public Form1()
  43.         {
  44.             //
  45.             // Required for Windows Form Designer support
  46.             //
  47.             InitializeComponent();
  48.         }
  49.  
  50.         /// <summary>
  51.         /// Clean up any resources being used.
  52.         /// </summary>
  53.         protected override void Dispose( bool disposing )
  54.         {
  55.             if( disposing )
  56.             {
  57.                 if (components != null) 
  58.                 {
  59.                     components.Dispose();
  60.                 }
  61.             }
  62.             base.Dispose( disposing );
  63.         }
  64.  
  65.         #region Windows Form Designer generated code
  66.         /// <summary>
  67.         /// Required method for Designer support - do not modify
  68.         /// the contents of this method with the code editor.
  69.         /// </summary>
  70.         private void InitializeComponent()
  71.         {
  72.             System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
  73.             AnimationStudio.Sound sound1 = new AnimationStudio.Sound();
  74.             AnimationStudio.Sound sound2 = new AnimationStudio.Sound();
  75.             AnimationStudio.Sound sound3 = new AnimationStudio.Sound();
  76.             AnimationStudio.Sound sound4 = new AnimationStudio.Sound();
  77.             this.spritePanel1 = new AnimationStudio.SpritePanel();
  78.             this.richTextBox1 = new System.Windows.Forms.RichTextBox();
  79.             this.sprite1 = new AnimationStudio.Sprite(this.spritePanel1);
  80.             this.keyFrame2 = new AnimationStudio.KeyFrame();
  81.             this.keyFrame3 = new AnimationStudio.KeyFrame();
  82.             this.keyFrame4 = new AnimationStudio.KeyFrame();
  83.             this.keyFrame5 = new AnimationStudio.KeyFrame();
  84.             this.keyFrame1 = new AnimationStudio.KeyFrame();
  85.             this.sprite2 = new AnimationStudio.Sprite(this.spritePanel1);
  86.             this.keyFrame6 = new AnimationStudio.KeyFrame();
  87.             this.keyFrame7 = new AnimationStudio.KeyFrame();
  88.             this.keyFrame8 = new AnimationStudio.KeyFrame();
  89.             this.keyFrame9 = new AnimationStudio.KeyFrame();
  90.             this.keyFrame10 = new AnimationStudio.KeyFrame();
  91.             this.sprite4 = new AnimationStudio.Sprite(this.spritePanel1);
  92.             this.keyFrame16 = new AnimationStudio.KeyFrame();
  93.             this.keyFrame17 = new AnimationStudio.KeyFrame();
  94.             this.sprite3 = new AnimationStudio.Sprite(this.spritePanel1);
  95.             this.keyFrame11 = new AnimationStudio.KeyFrame();
  96.             this.keyFrame12 = new AnimationStudio.KeyFrame();
  97.             this.keyFrame13 = new AnimationStudio.KeyFrame();
  98.             this.keyFrame14 = new AnimationStudio.KeyFrame();
  99.             this.spritePanel1.SuspendLayout();
  100.             this.SuspendLayout();
  101.             // 
  102.             // spritePanel1
  103.             // 
  104.             this.spritePanel1.BackColor = System.Drawing.Color.Gray;
  105.             this.spritePanel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
  106.             this.spritePanel1.Controls.Add(this.richTextBox1);
  107.             this.spritePanel1.Location = new System.Drawing.Point(8, 8);
  108.             this.spritePanel1.Name = "spritePanel1";
  109.             this.spritePanel1.Size = new System.Drawing.Size(584, 384);
  110.             this.spritePanel1.Sprites.AddRange(new AnimationStudio.Sprite[] {
  111.                                                                                 this.sprite1,
  112.                                                                                 this.sprite2,
  113.                                                                                 this.sprite4,
  114.                                                                                 this.sprite3});
  115.             this.spritePanel1.TabIndex = 0;
  116.             this.spritePanel1.Paint += new System.Windows.Forms.PaintEventHandler(this.spritePanel1_Paint);
  117.             // 
  118.             // richTextBox1
  119.             // 
  120.             this.richTextBox1.BackColor = System.Drawing.Color.LightSkyBlue;
  121.             this.richTextBox1.Font = new System.Drawing.Font("Verdana", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
  122.             this.richTextBox1.ForeColor = System.Drawing.Color.Black;
  123.             this.richTextBox1.Location = new System.Drawing.Point(296, 248);
  124.             this.richTextBox1.Name = "richTextBox1";
  125.             this.richTextBox1.ReadOnly = true;
  126.             this.richTextBox1.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Vertical;
  127.             this.richTextBox1.ShowSelectionMargin = true;
  128.             this.richTextBox1.Size = new System.Drawing.Size(272, 120);
  129.             this.richTextBox1.TabIndex = 1;
  130.             this.richTextBox1.Text = @"1 Click Sprite1 and view the collision event handler in the property tab
  131. 2 Run the compiled example
  132. 3 To add own event handlers, double click the appropriate event in the property page of the sprite or select Collision Event from the context menu of the Sprite";
  133.             // 
  134.             // sprite1
  135.             // 
  136.             this.sprite1.BorderColor = System.Drawing.Color.WhiteSmoke;
  137.             this.sprite1.BorderWidth = 2F;
  138.             this.sprite1.DetectCollisions = true;
  139.             this.sprite1.DrawBorder = false;
  140.             this.sprite1.DrawPath = false;
  141.             this.sprite1.DrawText = false;
  142.             this.sprite1.Font = new System.Drawing.Font("Arial", 24F, System.Drawing.FontStyle.Bold);
  143.             this.sprite1.Image = ((System.Drawing.Bitmap)(resources.GetObject("sprite1.Image")));
  144.             this.sprite1.Position = new System.Drawing.Point(481, 66);
  145.             this.sprite1.Rotation = 270F;
  146.             this.sprite1.Size = new System.Drawing.Size(51, 51);
  147.             sound1.SoundFile = "50cal.wav";
  148.             this.sprite1.Sound = sound1;
  149.             this.sprite1.Text = "Sprite";
  150.             this.sprite1.TextColor = System.Drawing.Color.DarkRed;
  151.             this.sprite1.Timeline.AddRange(new AnimationStudio.KeyFrame[] {
  152.                                                                               this.keyFrame2,
  153.                                                                               this.keyFrame3,
  154.                                                                               this.keyFrame4,
  155.                                                                               this.keyFrame5,
  156.                                                                               this.keyFrame1});
  157.             this.sprite1.TransparentColor = System.Drawing.Color.Black;
  158.             this.sprite1.XScale = 1F;
  159.             this.sprite1.YScale = 1F;
  160.             this.sprite1.Collision += new AnimationStudio.SpriteCollisionHandler(this.sprite1_Collision);
  161.             // 
  162.             // keyFrame2
  163.             // 
  164.             this.keyFrame2.Duration = 32;
  165.             this.keyFrame2.Opacity = 1F;
  166.             this.keyFrame2.Position = new System.Drawing.Point(268, 41);
  167.             this.keyFrame2.Rotation = 0F;
  168.             this.keyFrame2.Visible = true;
  169.             this.keyFrame2.XScale = 1;
  170.             this.keyFrame2.YScale = 1;
  171.             this.keyFrame2.ZOrder = 0;
  172.             // 
  173.             // keyFrame3
  174.             // 
  175.             this.keyFrame3.Duration = 32;
  176.             this.keyFrame3.Opacity = 1F;
  177.             this.keyFrame3.Position = new System.Drawing.Point(574, 0);
  178.             this.keyFrame3.Rotation = 360F;
  179.             this.keyFrame3.Visible = true;
  180.             this.keyFrame3.XScale = 1;
  181.             this.keyFrame3.YScale = 1;
  182.             this.keyFrame3.ZOrder = 0;
  183.             // 
  184.             // keyFrame4
  185.             // 
  186.             this.keyFrame4.Duration = 32;
  187.             this.keyFrame4.Opacity = 1F;
  188.             this.keyFrame4.Position = new System.Drawing.Point(357, 365);
  189.             this.keyFrame4.Rotation = 720F;
  190.             this.keyFrame4.Visible = true;
  191.             this.keyFrame4.XScale = 5;
  192.             this.keyFrame4.YScale = 5;
  193.             this.keyFrame4.ZOrder = 0;
  194.             // 
  195.             // keyFrame5
  196.             // 
  197.             this.keyFrame5.Duration = 32;
  198.             this.keyFrame5.Opacity = 1F;
  199.             this.keyFrame5.Position = new System.Drawing.Point(0, 100);
  200.             this.keyFrame5.Rotation = 1080F;
  201.             this.keyFrame5.Visible = true;
  202.             this.keyFrame5.XScale = 1;
  203.             this.keyFrame5.YScale = 1;
  204.             this.keyFrame5.ZOrder = 0;
  205.             // 
  206.             // keyFrame1
  207.             // 
  208.             this.keyFrame1.Duration = 32;
  209.             this.keyFrame1.Opacity = 1F;
  210.             this.keyFrame1.Position = new System.Drawing.Point(256, 43);
  211.             this.keyFrame1.Rotation = 1440F;
  212.             this.keyFrame1.Visible = true;
  213.             this.keyFrame1.XScale = 1;
  214.             this.keyFrame1.YScale = 1;
  215.             this.keyFrame1.ZOrder = 0;
  216.             // 
  217.             // sprite2
  218.             // 
  219.             this.sprite2.BorderColor = System.Drawing.Color.WhiteSmoke;
  220.             this.sprite2.BorderWidth = 3F;
  221.             this.sprite2.DrawBorder = false;
  222.             this.sprite2.DrawPath = false;
  223.             this.sprite2.DrawText = false;
  224.             this.sprite2.Font = new System.Drawing.Font("Arial", 24F, System.Drawing.FontStyle.Bold);
  225.             this.sprite2.Image = ((System.Drawing.Bitmap)(resources.GetObject("sprite2.Image")));
  226.             this.sprite2.PathClosed = true;
  227.             this.sprite2.Position = new System.Drawing.Point(282, 41);
  228.             this.sprite2.Size = new System.Drawing.Size(51, 51);
  229.             sound2.SoundFile = "";
  230.             this.sprite2.Sound = sound2;
  231.             this.sprite2.Text = "Sprite";
  232.             this.sprite2.TextColor = System.Drawing.Color.DarkRed;
  233.             this.sprite2.Timeline.AddRange(new AnimationStudio.KeyFrame[] {
  234.                                                                               this.keyFrame6,
  235.                                                                               this.keyFrame7,
  236.                                                                               this.keyFrame8,
  237.                                                                               this.keyFrame9,
  238.                                                                               this.keyFrame10});
  239.             this.sprite2.TransparentColor = System.Drawing.Color.Black;
  240.             this.sprite2.XScale = 1F;
  241.             this.sprite2.YScale = 1F;
  242.             // 
  243.             // keyFrame6
  244.             // 
  245.             this.keyFrame6.Duration = 32;
  246.             this.keyFrame6.Opacity = 1F;
  247.             this.keyFrame6.Position = new System.Drawing.Point(155, 38);
  248.             this.keyFrame6.Rotation = 0F;
  249.             this.keyFrame6.Visible = true;
  250.             this.keyFrame6.XScale = 1;
  251.             this.keyFrame6.YScale = 1;
  252.             this.keyFrame6.ZOrder = 0;
  253.             // 
  254.             // keyFrame7
  255.             // 
  256.             this.keyFrame7.Duration = 32;
  257.             this.keyFrame7.Opacity = 1F;
  258.             this.keyFrame7.Position = new System.Drawing.Point(11, 97);
  259.             this.keyFrame7.Rotation = 0F;
  260.             this.keyFrame7.Visible = true;
  261.             this.keyFrame7.XScale = 1;
  262.             this.keyFrame7.YScale = 1;
  263.             this.keyFrame7.ZOrder = 0;
  264.             // 
  265.             // keyFrame8
  266.             // 
  267.             this.keyFrame8.Duration = 32;
  268.             this.keyFrame8.Opacity = 1F;
  269.             this.keyFrame8.Position = new System.Drawing.Point(310, 300);
  270.             this.keyFrame8.Rotation = 0F;
  271.             this.keyFrame8.Visible = true;
  272.             this.keyFrame8.XScale = 0;
  273.             this.keyFrame8.YScale = 0;
  274.             this.keyFrame8.ZOrder = 0;
  275.             // 
  276.             // keyFrame9
  277.             // 
  278.             this.keyFrame9.Duration = 32;
  279.             this.keyFrame9.Opacity = 1F;
  280.             this.keyFrame9.Position = new System.Drawing.Point(450, 158);
  281.             this.keyFrame9.Rotation = 0F;
  282.             this.keyFrame9.Visible = true;
  283.             this.keyFrame9.XScale = 1;
  284.             this.keyFrame9.YScale = 1;
  285.             this.keyFrame9.ZOrder = 0;
  286.             // 
  287.             // keyFrame10
  288.             // 
  289.             this.keyFrame10.Duration = 32;
  290.             this.keyFrame10.Opacity = 1F;
  291.             this.keyFrame10.Position = new System.Drawing.Point(267, 10);
  292.             this.keyFrame10.Rotation = 0F;
  293.             this.keyFrame10.Visible = true;
  294.             this.keyFrame10.XScale = 1;
  295.             this.keyFrame10.YScale = 1;
  296.             this.keyFrame10.ZOrder = 0;
  297.             // 
  298.             // sprite4
  299.             // 
  300.             this.sprite4.BorderColor = System.Drawing.Color.WhiteSmoke;
  301.             this.sprite4.BorderWidth = 3F;
  302.             this.sprite4.DrawBorder = false;
  303.             this.sprite4.DrawPath = false;
  304.             this.sprite4.DrawText = true;
  305.             this.sprite4.Font = new System.Drawing.Font("Arial Black", 27.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
  306.             this.sprite4.Image = ((System.Drawing.Bitmap)(resources.GetObject("sprite4.Image")));
  307.             this.sprite4.Position = new System.Drawing.Point(-100, 150);
  308.             this.sprite4.Rotation = 120F;
  309.             this.sprite4.Size = new System.Drawing.Size(39, 58);
  310.             sound3.SoundFile = "";
  311.             this.sprite4.Sound = sound3;
  312.             this.sprite4.Text = "Collision Events";
  313.             this.sprite4.TextColor = System.Drawing.Color.Yellow;
  314.             this.sprite4.Timeline.AddRange(new AnimationStudio.KeyFrame[] {
  315.                                                                               this.keyFrame16,
  316.                                                                               this.keyFrame17});
  317.             this.sprite4.TransparentColor = System.Drawing.Color.Black;
  318.             this.sprite4.XScale = 0.1666667F;
  319.             this.sprite4.YScale = 0.1666667F;
  320.             this.sprite4.ZOrder = 5;
  321.             // 
  322.             // keyFrame16
  323.             // 
  324.             this.keyFrame16.Duration = 150;
  325.             this.keyFrame16.Opacity = 1F;
  326.             this.keyFrame16.Position = new System.Drawing.Point(-300, 150);
  327.             this.keyFrame16.Rotation = 0F;
  328.             this.keyFrame16.Visible = true;
  329.             this.keyFrame16.XScale = 0;
  330.             this.keyFrame16.YScale = 0;
  331.             this.keyFrame16.ZOrder = 5;
  332.             // 
  333.             // keyFrame17
  334.             // 
  335.             this.keyFrame17.Duration = 32;
  336.             this.keyFrame17.Opacity = 1F;
  337.             this.keyFrame17.Position = new System.Drawing.Point(900, 150);
  338.             this.keyFrame17.Rotation = 720F;
  339.             this.keyFrame17.Visible = true;
  340.             this.keyFrame17.XScale = 1;
  341.             this.keyFrame17.YScale = 1;
  342.             this.keyFrame17.ZOrder = 5;
  343.             // 
  344.             // sprite3
  345.             // 
  346.             this.sprite3.BorderColor = System.Drawing.Color.WhiteSmoke;
  347.             this.sprite3.BorderWidth = 2F;
  348.             this.sprite3.DrawBorder = false;
  349.             this.sprite3.DrawPath = false;
  350.             this.sprite3.DrawText = false;
  351.             this.sprite3.Font = new System.Drawing.Font("Arial", 24F, System.Drawing.FontStyle.Bold);
  352.             this.sprite3.Image = ((System.Drawing.Bitmap)(resources.GetObject("sprite3.Image")));
  353.             this.sprite3.PathClosed = true;
  354.             this.sprite3.Position = new System.Drawing.Point(279, 274);
  355.             this.sprite3.Size = new System.Drawing.Size(51, 51);
  356.             sound4.SoundFile = "";
  357.             this.sprite3.Sound = sound4;
  358.             this.sprite3.Text = "Sprite";
  359.             this.sprite3.TextColor = System.Drawing.Color.DarkRed;
  360.             this.sprite3.Timeline.AddRange(new AnimationStudio.KeyFrame[] {
  361.                                                                               this.keyFrame11,
  362.                                                                               this.keyFrame12,
  363.                                                                               this.keyFrame13,
  364.                                                                               this.keyFrame14});
  365.             this.sprite3.TransparentColor = System.Drawing.Color.Black;
  366.             this.sprite3.XScale = 1F;
  367.             this.sprite3.YScale = 1F;
  368.             this.sprite3.Collision += new AnimationStudio.SpriteCollisionHandler(this.sprite3_Collision);
  369.             // 
  370.             // keyFrame11
  371.             // 
  372.             this.keyFrame11.Duration = 32;
  373.             this.keyFrame11.Opacity = 1F;
  374.             this.keyFrame11.Position = new System.Drawing.Point(249, 101);
  375.             this.keyFrame11.Rotation = 180F;
  376.             this.keyFrame11.Visible = true;
  377.             this.keyFrame11.XScale = 1;
  378.             this.keyFrame11.YScale = 1;
  379.             this.keyFrame11.ZOrder = 0;
  380.             // 
  381.             // keyFrame12
  382.             // 
  383.             this.keyFrame12.Duration = 32;
  384.             this.keyFrame12.Opacity = 1F;
  385.             this.keyFrame12.Position = new System.Drawing.Point(535, 3);
  386.             this.keyFrame12.Rotation = 0F;
  387.             this.keyFrame12.Visible = true;
  388.             this.keyFrame12.XScale = 1;
  389.             this.keyFrame12.YScale = 1;
  390.             this.keyFrame12.ZOrder = 0;
  391.             // 
  392.             // keyFrame13
  393.             // 
  394.             this.keyFrame13.Duration = 32;
  395.             this.keyFrame13.Opacity = 1F;
  396.             this.keyFrame13.Position = new System.Drawing.Point(353, 322);
  397.             this.keyFrame13.Rotation = 0F;
  398.             this.keyFrame13.Visible = true;
  399.             this.keyFrame13.XScale = 1;
  400.             this.keyFrame13.YScale = 1;
  401.             this.keyFrame13.ZOrder = 0;
  402.             // 
  403.             // keyFrame14
  404.             // 
  405.             this.keyFrame14.Duration = 32;
  406.             this.keyFrame14.Opacity = 1F;
  407.             this.keyFrame14.Position = new System.Drawing.Point(2, 184);
  408.             this.keyFrame14.Rotation = 0F;
  409.             this.keyFrame14.Visible = true;
  410.             this.keyFrame14.XScale = 1;
  411.             this.keyFrame14.YScale = 1;
  412.             this.keyFrame14.ZOrder = 0;
  413.             // 
  414.             // Form1
  415.             // 
  416.             this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
  417.             this.ClientSize = new System.Drawing.Size(600, 398);
  418.             this.Controls.Add(this.spritePanel1);
  419.             this.Name = "Form1";
  420.             this.Text = "Tutorial 3 - Events";
  421.             this.Load += new System.EventHandler(this.Form1_Load);
  422.             this.spritePanel1.ResumeLayout(false);
  423.             this.ResumeLayout(false);
  424.  
  425.         }
  426.         #endregion
  427.  
  428.         /// <summary>
  429.         /// The main entry point for the application.
  430.         /// </summary>
  431.         [STAThread]
  432.         static void Main() 
  433.         {
  434.             Application.Run(new Form1());
  435.         }
  436.  
  437.         private void sprite1_Collision(object sender, AnimationStudio.CollisionEventArgs e)
  438.         {
  439.             sprite1.Sound.Play = true;
  440.             if(!e.Collider.DrawBorder)
  441.                 e.Collider.DrawBorder = true;
  442.             else
  443.                 e.Collider.DrawBorder = false;
  444.         }
  445.  
  446.         private void spritePanel1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
  447.         {
  448.         
  449.         }
  450.  
  451.         private void Form1_Load(object sender, System.EventArgs e)
  452.         {
  453.         
  454.         }
  455.  
  456.         private void sprite3_Collision(object sender, AnimationStudio.CollisionEventArgs e)
  457.         {
  458.         
  459.         }
  460.     }
  461. }
  462.