private void DupBtn_Click(object sender, EventArgs e) { int DuplicationIndex = listBox1.SelectedIndex; //Index of rail to duplicate; int OutputIndex = listBox1.Items.Count; //Index of duplicated rail. if (DuplicationIndex == -1 || listBox1.Items.Count == 0) //Make sure indicies make sense { return; } NameCheck nc = new NameCheck("New Rail"); if (nc.ShowDialog() != DialogResult.OK)//Cancel if no name is put in. { return; } if (file.ContainsRail(nc.name))//Check rail name { MessageBox.Show("There is already a path with this key name", "Key taken", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } else if (nc.Name == "") { MessageBox.Show("Invalid name", "Too short", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } file.AddRail(nc.name); //Add rail UpdateItems(); //Update for (int i = 0; i < file.GetAllRails()[DuplicationIndex].frames.Length; i++) //For each frame { KeyFrame rp = file.GetAllRails()[DuplicationIndex].frames[i]; //Keyframe = node KeyFrame new_rp = rp.DeepCopy(); file.GetAllRails()[OutputIndex].InsertFrame(new_rp, i); //add node to file } UpdateItems();//Update if (listBox2.Items.Count > 0) { listBox2.SelectedIndex = 0; } listBox1.SelectedIndex = OutputIndex; }
private void addButton_Click(object sender, EventArgs e) { NameCheck nc = new NameCheck("New Rail"); if (nc.ShowDialog() != DialogResult.OK) { return; } if (file.ContainsRail(nc.name)) { MessageBox.Show("There is already a path with this key name", "Key taken", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } file.AddRail(nc.name); UpdateItems(); }