Exemple #1
0
 private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listBox1.SelectedIndex >= 0)
     {
         AnimItem item = AnimItems[listBox1.SelectedIndex];
         label5.Text      = item.name;
         textBox3.Text    = item.x.ToString();
         textBox4.Text    = item.y.ToString();
         textBox5.Text    = item.delay.ToString();
         textBox3.Enabled = true;
         textBox4.Enabled = true;
         textBox5.Enabled = true;
         button6.Enabled  = true;
     }
     else
     {
         label5.Text      = "";
         textBox3.Text    = "";
         textBox4.Text    = "";
         textBox5.Text    = "";
         textBox3.Enabled = false;
         textBox4.Enabled = false;
         textBox5.Enabled = false;
         button6.Enabled  = false;
     }
 }
Exemple #2
0
 private void button4_Click(object sender, EventArgs e)
 {
     try
     {
         if (openFileDialog2.ShowDialog() == DialogResult.OK)
         {
             FileStream fs = File.Create(openFileDialog2.FileName);
             fs.Write(new byte[] { 65, 78, 73, 77 }, 0, 4); //ANIM
             fs.WriteByte((byte)textBox2.Text.Length);
             fs.Write(Encoding.UTF8.GetBytes(textBox2.Text), 0, textBox2.Text.Length);
             fs.WriteByte((byte)AnimItems.Count);
             fs.WriteByte((byte)(checkBox1.Checked ? 255 : 0));
             int count = AnimItems.Count;
             for (int i = 0; i < count; i++)
             {
                 AnimItem item = AnimItems[i];
                 fs.WriteByte((byte)item.path.Length);
                 fs.Write(Encoding.UTF8.GetBytes(item.path), 0, item.path.Length);
                 fs.Write(BitConverter.GetBytes(item.x), 0, 2);
                 fs.Write(BitConverter.GetBytes(item.y), 0, 2);
                 fs.Write(BitConverter.GetBytes(item.delay), 0, 2);
             }
             fs.Flush();
             fs.Close();
             openFileDialog2.FileName = "";
             MessageBox.Show("Written successfully");
         }
     }
     catch (Exception z) { MessageBox.Show("Error"); }
 }
Exemple #3
0
        private void button6_Click(object sender, EventArgs e)
        {
            AnimItem item  = AnimItems[listBox1.SelectedIndex];
            int      x     = -1;
            int      y     = -1;
            int      delay = -1;

            if (int.TryParse(textBox3.Text, out x))
            {
                if (0 <= x && x <= 65535)
                {
                    item.x = x;
                }
            }
            if (int.TryParse(textBox4.Text, out y))
            {
                if (0 <= y && y <= 65535)
                {
                    item.y = y;
                }
            }
            if (int.TryParse(textBox5.Text, out delay))
            {
                if (0 <= delay && delay <= 65535)
                {
                    item.delay = delay;
                }
            }
            if (item.x != x || item.y != y || item.delay != delay)
            {
                MessageBox.Show("Error");
            }
            else
            {
                MessageBox.Show("Saved");
            }
        }
Exemple #4
0
 private void button5_Click(object sender, EventArgs e)
 {
     if (openFileDialog1.ShowDialog() == DialogResult.OK)
     {
         int count = openFileDialog1.FileNames.Length;
         for (int i = 0; i < count; i++)
         {
             if (openFileDialog1.FileNames[i].Contains(root))
             {
                 string   path = openFileDialog1.FileNames[i].Substring(rootlength);
                 AnimItem item = new AnimItem();
                 item.name = openFileDialog1.SafeFileNames[i];
                 item.path = path;
                 AnimItems.Add(item);
                 listBox1.Items.Add(path);
             }
             else
             {
                 MessageBox.Show("File must be under the root directory");
             }
         }
         openFileDialog1.FileName = "";
     }
 }