Пример #1
0
        /// <summary>
        /// When the selection is clicked, start playing the sequence
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void play_Click(object sender, EventArgs e)
        {
            // Play sprite sequence
            var imageLayoutName = comboBox1.SelectedItem;

            // stop timer
            timer1.Stop();
            // Get the composite image
            var compositeImage = assets.CompositeImageForTrigger((string)imageLayoutName);
            var list           = new List <SpriteControl>();

            spriteBoxes = list;
            // replace the contents
            panel1.Controls.Clear();
            panel1.BackColor = Color.Transparent;
            // Create the layers
            foreach (var layerName in compositeImage.LayerNames)
            {
                // Get the image name mapping
                var imageMap = (Dictionary <string, string>)compositeImage.ImageMap(layerName);
                var panel    = new Panel();
                panel.Size = panel1.Size;
                panel1.Controls.Add(panel);
                panel.BackColor = Color.Transparent;

                // Create the layout for this layer
                foreach (var spriteBox in compositeImage.Layout(layerName))
                {
                    var pictureBox = new PictureBox();
                    pictureBox.SizeMode  = PictureBoxSizeMode.Zoom;
                    pictureBox.Width     = (int)(spriteBox.width * zoom);
                    pictureBox.Height    = (int)(spriteBox.height * zoom);
                    pictureBox.Location  = new Point((int)(spriteBox.x * zoom), (int)(spriteBox.y * zoom));
                    pictureBox.BackColor = Color.Transparent;
                    // Add the sprite box to... the layers panel
                    panel.Controls.Add(pictureBox);

                    // Look up the sprite sequence used to drive this sprite box
                    if (null != imageMap && imageMap.TryGetValue(spriteBox.spriteBoxName, out var spriteSequenceName))
                    {
                        // note name and method
                        var a = new SpriteControl(pictureBox, assets.SpriteSequence(spriteSequenceName), spriteBox.spriteRenderMethod);
                        list.Add(a);
                    }
                }
            }
            // start the timer
            timer1.Start();
        }