scaling, rotating

Status
Niet open voor verdere reacties.

savant11

Gebruiker
Lid geworden
7 jan 2008
Berichten
153
Hoi allemaal,

heb dit:

Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CharacterEditor;
using HelperClasses;
//using CharacterEditor;
using xCharEdit;
using xCharEdit.Character;

namespace xCharEdit//CharacterEditor
{
    public partial class MainForm : Form
    {

        public Game1 game;
        CharacterEditor.Controller.AdminAnnimation_controller _controller;

        //Constructor
        public MainForm()
        {
            InitializeComponent();

            _controller = new CharacterEditor.Controller.AdminAnnimation_controller(this);

            AnimationBox.Items.Add(new Animation(AnimationBox.Items.Count));
        }

        xCharEdit.Model.AdminAnnimation temp = new xCharEdit.Model.AdminAnnimation();
        //public xCharEdit.Model.AdminAnnimation currentAdminAnnimation
        //{
        //get;
        // set;
        //}

        public string Naam
        {
            get { return textBox1.Text; }


        }

        public IntPtr getDrawSurface()
        {
            return panel1.Handle;
        }

        public void setGame(Game1 game)
        {
            this.game = game;
        }

        //FrameList
        private void SelectedPartChanged(object sender, EventArgs e)
        {

            if (FrameList.SelectedIndex >= 0)
            {
                int index = FrameList.SelectedIndex;
                game.selPart = index;
                partGrid.SelectedObject = game.charDef.frame[game.selFrame].partList[index];
            }

           /*
            if (FrameList.SelectedItem != null)
            {
                game.selFrame = FrameList.SelectedIndex;
            }
            

            if (FrameList.SelectedIndex >= 0)
            {
                int index = FrameList.SelectedIndex;
                game.selPart = index;
                //partGrid.SelectedObject = game.charDef.frame[game.selFrame].partList[index];

                //game.FrameList.Name.Replace;

            }
            */ 
            
              
            
            

        }

        private void newCharDef(object sender, EventArgs e)
        {
            game.charDef = new xCharEdit.Character.CharDef();
        }

        private void saveCharDef(object sender, EventArgs e)
        {
            SaveFileDialog sd = new SaveFileDialog();
            if (sd.ShowDialog() == DialogResult.OK)
            {
                XMLFileManager<xCharEdit.Character.CharDef>.WriteToFile(sd.FileName, game.charDef);
            }
        }

        private void openCharDef(object sender, EventArgs e)
        {
            OpenFileDialog od = new OpenFileDialog();
            if (od.ShowDialog() == DialogResult.OK)
            {
                game.charDef = XMLFileManager<xCharEdit.Character.CharDef>.OpenFromFile(od.FileName);
            }
            //game.DrawPartList();
        }

        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            game.Exit();
        }

        private void RemoveFrame(object sender, EventArgs e)
        {
            if (FrameList.SelectedItems.Count >= 1 && FrameList.SelectedIndex > -1)
            {
                int index = FrameList.SelectedIndex;
                FrameList.Items.RemoveAt(index);
                game.charDef.frame[game.selFrame].partList.RemoveAt(index);
            }
            if (AnimationBox.SelectedItem != null)
            {
                Animation a = ((Animation)AnimationBox.SelectedItem);
                a.KeyFrame.Remove((KeyFrame)FrameList.SelectedItem);
                FrameList.DataSource = null;
                FrameList.DataSource = ((Animation)AnimationBox.SelectedItem).KeyFrame;
            }
        }

        //Box where u can rotate the selected object!!
        private void partGrid_Click(object sender, EventArgs e)
        {
            
            



        }

        //load the images
        private void ItemTabControl_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void fileToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }

        private void importImageToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {

                OpenFileDialog open = new OpenFileDialog();

                open.Filter = "Image Files(*.jpg; *.jpeg; *.gif; *.bmp)|*.jpg; *.jpeg; *.gif; *.bmp";

                if (open.ShowDialog() == DialogResult.OK)
                {

                    //ItemTabContr.I = new Bitmap(open.FileName);

                }

            }

            catch (Exception)
            {

                throw new ApplicationException("Failed loading image");

            }
        }

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void panel1_Paint(object sender, PaintEventArgs e)
        {

        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void textBox1_TextChanged_1(object sender, EventArgs e)
        {
            //listBox1.Items.Add(((TextBox)sender).Text);

        }

        private void button1_Click(object sender, EventArgs e)
        {

        }

        private void addAnimation(object sender, EventArgs e)
        {
            //AnimationBox.Items.Add(new Animation(AnimationBox.Items.Count));

            Animation ani = new Animation(AnimationBox.Items.Count);
            AnimationBox.Items.Add(ani);

            //CharDef charDef = new CharDef();

            game.charDef.animation.Add(ani);


            //charDef.idx.GetAnimation.add(ani);// animation.Add(ani);


            
        }

        private void btVerwijden_Click(object sender, EventArgs e)
        {
            if (AnimationBox.SelectedItem != null)
                AnimationBox.Items.Remove(AnimationBox.SelectedItem);
            if (AnimationBox.SelectedIndex == -1)
            
                MessageBox.Show("Please select an item first.", "No item selected", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            
            //else
            //{
                //AnimationBox.Items.RemoveAt(AnimationBox.SelectedIndex);
           // }

        }

        private void btWijzigen_Click(object sender, EventArgs e)
        {
            if(AnimationBox.SelectedIndex == 1)
            {
                //MessageBox.Show("U didnt select an item!!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);   
            }    
        
       // else
       // {
           // listBox1.Items.Insert(listBox1.SelectedItem);   
       // }
       }

        private void ChangeAnimation(object sender, EventArgs e)
        {
            if (AnimationBox.SelectedItem != null)//|| (AnimationBox.SelectedIndex <= null))
            {
                game.selAnim = AnimationBox.SelectedIndex;
                FrameList.DataSource = ((Animation)AnimationBox.SelectedItem).KeyFrame;

                MessageBox.Show("Selected Item Text: " + AnimationBox.SelectedItem.ToString() + "\n" +
                    "Index: " + AnimationBox.SelectedIndex.ToString());
            }
            if (AnimationBox.SelectedItem == null)
            {
                MessageBox.Show("U didnt select a item!! Think better!!");
            
            }
            


        }

        private void AddFrame(object sender, EventArgs e)
        {
            ((Animation)AnimationBox.SelectedItem).KeyFrame.Add(new KeyFrame(FrameList.Items.Count));
            FrameList.DataSource = null;
            FrameList.DataSource = ((Animation)AnimationBox.SelectedItem).KeyFrame;
        }

        private void listbSpeedAnnimatie_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listbSpeedAnnimatie.SelectedItem != null)
            {
                game.selAnim = listbSpeedAnnimatie.SelectedIndex;
                FrameList.DataSource = ((Animation)listbSpeedAnnimatie.SelectedItem).KeyFrame;
            }
        }

        private void button1_Click_1(object sender, EventArgs e)
        {
           listbSpeedAnnimatie.Items.Add(new Animation(listbSpeedAnnimatie.Items.Count));


        }

        private void panel1_Paint_1(object sender, PaintEventArgs e)
        {
            //Frame _frame = new Frame(Naam);
            //CharDef charDef = new CharDef();
            
           // game.charDef.addFrame = ItemTabControl.SelectedIndex();
             
            //CharDef _frame = new CharDef(_frame);

            //game.charDef.addFrame();   //(idx = selIndex);
            //game.charDef.addFrame(idx);
        }

        private void textBox1_TextChanged_2(object sender, EventArgs e)
        {

        }
    }
}

En de classe:Frame:

Code:
using System;
using System.Collections.Generic;
using System.Text;

namespace xCharEdit.Character
{
    public class Frame
    {
        public List<Part> partList;
        public String name;

        public Frame(String name)
        {
            partList = new List<Part>();
            for (int i = 0; i < partList.Count; i++)
               partList[i] = new Part();
            this.name = name;
        }

        //public Part addPart(int idx, String name)
        //{
            //name.Insert(idx, name);
           // return null;
        
        //}

        public Part GetPart(int idx)
        {
            return partList[idx];
        }

        public void SetPart(int idx, Part _part)
        {
            partList[idx] = _part;
        }

        public List<Part> GetPartArray()
        {
            return partList;
        }
    }
}

maar nu krijg ik bij deze regel:

[code]
 partGrid.SelectedObject = game.charDef.frame[game.selFrame].partList[index];

De volgende fout:

Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

Hoe dit op te lossen?

Alvast bedankt!!
[/code]
 
Status
Niet open voor verdere reacties.
Steun Ons

Nieuwste berichten

Terug
Bovenaan Onderaan