HOI , HEB DIT:
En heb op deze regel een breakpoint:
dan versprint ie naar deze regel:
En hier de classe Animation:
Alvast THX
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;
String name;
//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)
{
/*
try
{
partGrid = null;
}
catch (Exception e)
{
Console.WriteLine(e.ToString);
}
*/
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;
}
if (FrameList.SelectedIndex >= 0)
{
int index = FrameList.SelectedIndex;
game.selPart = index;
//partGrid.SelectedObject = null ;
partGrid.SelectedObject = game.charDef.frame[game.selFrame].partList[index];
//Frame frame = new Frame();
if (partGrid == null)
{
Console.WriteLine(partGrid.Size);
}
}
}
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 heb op deze regel een breakpoint:
Code:
partGrid.SelectedObject = game.charDef.frame[game.selFrame].partList[index];
dan versprint ie naar deze regel:
Code:
FrameList.DataSource = ((Animation)AnimationBox.SelectedItem).KeyFrame;
En hier de classe Animation:
Code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
namespace xCharEdit.Character
{
public class Animation
{
public String name;
List<KeyFrame> keyFrame;
public Animation(int index)
{
name = "animDef" + index.ToString();
//keyFrame = new KeyFrame[256];//128
keyFrame = new List<KeyFrame>();
//for (int i = 0; i < keyFrame.Count; i++)
//keyFrame[i] = new KeyFrame();
KeyFrame k = new KeyFrame(0);
keyFrame.Add(k);
if (keyFrame == null)
{
System.Windows.Forms.MessageBox.Show("is null");
}
}
public List<KeyFrame> KeyFrame
{
//for(int i = 0; i < keyFrame; i++)
set { keyFrame = value; }
get { return keyFrame; }
}
public KeyFrame GetKeyFrame(int idx)
{
return keyFrame[idx];
if (keyFrame == null)
MessageBox.Show("Null");
}
public void SetKeyFrame(int idx, KeyFrame _keyFrame)
{
keyFrame[idx] = _keyFrame;
}
public List<KeyFrame> getKeyFrameArray()
{
return keyFrame;
}
public override string ToString()
{
return this.name;
}
public void annimationSpeed(int index)
{
name = "speedAnnimation" + ToString();
keyFrame = new List<KeyFrame>();
//for (int i = 0; i < keyFrame.Length; i++)
//keyFrame[i] = new KeyFrame();
KeyFrame k = new KeyFrame(1);
keyFrame.Add(k);
//return index;
}
}
}
Alvast THX