/// <summary>
 /// Edits the currently selected status
 /// </summary>
 /// <param name="sender">not used</param>
 /// <param name="e">not used</param>
 private void editButton_Click(object sender, RoutedEventArgs e)
 {
     int index = (int)cursor.Margin.Top / 20;
     status = StatusData.GetStatusNames()[index];
     StatusEditor editor = new StatusEditor(status);
     editor.Owner = this;
     editor.ShowDialog();
     (grid1.Children[index + 1] as Label).Content = StatusData.GetStatusNames()[index];
 }
        /// <summary>
        /// Creates a new status
        /// </summary>
        /// <param name="sender">not used</param>
        /// <param name="e">not used</param>
        private void newButton_Click(object sender, RoutedEventArgs e)
        {
            // Move the cursor to the end
            cursor.Margin = new Thickness(8, 20 * grid1.Children.Count - 16, 0, 0);

            // Get an available name
            string name = "NewStatus1";
            int index = 1;
            Boolean valid;
            do
            {
                valid = true;
                foreach (string s in StatusData.GetStatusNames())
                    if (s.Equals(name))
                    {
                        name = name.Replace(index + "", ++index + "");
                        valid = false;
                    }
            }
            while (!valid);

            // Add the status to the window and to the level data
            StatusData.UpdateStatus(new Status(name, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0));
            StatusEditor editor = new StatusEditor(name);
            try
            {
                editor.Owner = this;
            }
            catch (Exception)
            {
                editor.Left = (SystemParameters.PrimaryScreenWidth - editor.Width) / 2;
                editor.Top = (SystemParameters.PrimaryScreenHeight - editor.Height) / 2;
            }
            editor.ShowDialog();

            AddLabel(StatusData.GetStatusNames()[StatusData.GetStatusNames().Length - 1], grid1.Children.Count - 1);
        }