Пример #1
0
        private void tsAddSprite_Click(object sender, EventArgs e)
        {
            if (tvSequences.SelectedNode == null)
            {
                return;
            }

            OpenFileDialog dia = new OpenFileDialog();

            dia.Multiselect      = true;
            dia.Filter           = "PNG|*.png|JPEG|*.jpg|BMP|*.bmp|GIF|*.bmp|All Files|*.*";
            dia.InitialDirectory = Globals.AppSettings.ContentPath;

            if (dia.ShowDialog() == DialogResult.OK)
            {
                for (int i = 0; i < dia.FileNames.Length; i++)
                {
                    string filename = Path.GetFileNameWithoutExtension(dia.FileNames[i]);

                    TreeNode node = new TreeNode();
                    node.Tag      = Path.GetFileName(dia.FileNames[i]);
                    node.ImageKey = dia.FileNames[i];
                    if (filename != null)
                    {
                        node.Text = filename;
                    }

                    if (tvSequences.SelectedNode.Parent != null)
                    {
                        tvSequences.SelectedNode.Parent.Nodes.Add(node);
                    }
                    else
                    {
                        tvSequences.SelectedNode.Nodes.Add(node);
                    }

                    // Move the texture to our project -> textures directory
                    File.Copy(dia.FileNames[i], Utilitys.GetDestinationTexturePath(dia.FileNames[i]), true);

                    loadedTextures.Add(Utilitys.GetDestinationTexturePath(dia.FileNames[i]));
                }
            }
        }
Пример #2
0
        private void tsAddFrame_Click(object sender, EventArgs e)
        {
            HasFramesBeenAdded = true;

            if (CurrentSequence == null)
            {
                return;
            }

            OpenFileDialog dia = new OpenFileDialog();

            dia.Multiselect      = true;
            dia.Filter           = "PNG|*.png|JPEG|*.jpg|BMP|*.bmp|GIF|*.bmp|All Files|*.*";
            dia.InitialDirectory = Globals.AppSettings.ContentPath;

            if (dia.ShowDialog() == DialogResult.OK)
            {
                for (int i = 0; i < dia.FileNames.Length; i++)
                {
                    if (!Directory.Exists(Globals.AppSettings.ProjectPath + @"\Temp\"))
                    {
                        Directory.CreateDirectory(Globals.AppSettings.ProjectPath + @"\Temp\");
                    }

                    // Move the texture to our project -> textures directory
                    File.Copy(dia.FileNames[i], Utilitys.GetDestinationTexturePath(dia.FileNames[i]), true);

                    KeyFrame2D frame = new KeyFrame2D();
                    frame.AssetFilename = Path.GetFileName(dia.FileNames[i]);
                    frame.Duration      = 1;

                    CurrentSequence.Frames.Add(frame);
                }
            }

            lsFrames.DataSource    = null;
            lsFrames.DataSource    = CurrentSequence.Frames;
            lsFrames.DisplayMember = "AssetFilename";
        }