/// <summary> /// Updates the contents views based upon the selected index in the contentsListBox /// </summary> /// <param name="selectedIndex">The selected index in contentsListBox</param> private void updateContentObjectFields(int selectedIndex) { // If some content is selected, views need to be enabled and populated if(selectedIndex != -1) { // Set the current content object to the corresponding content object in the app store mContent = mApp.mContents.ElementAt(selectedIndex); // Enable all the following views and populate them with the correct data contentObjectNameTextBox.Enabled = true; contentObjectNameTextBox.Text = mContent.mName; contentObjectActorsCheckedListBox.Enabled = true; for(int i = 0; i < contentObjectActorsCheckedListBox.Items.Count; i++) contentObjectActorsCheckedListBox.SetItemCheckState(i, CheckState.Unchecked); // Check the correct actors in the contentObjectActorsCheckedListBox for (int i = 0; i < mContent.mActors.Count; i++) contentObjectActorsCheckedListBox.SetItemCheckState(contentObjectActorsCheckedListBox.FindString(mContent.mActors.ElementAt(i)), CheckState.Checked); contentObjectTextTextBox.Enabled = true; contentObjectTextTextBox.Text = mContent.mText; contentObjectVideosListBox.Enabled = true; contentObjectVideosListBox.Items.Clear(); foreach (var video in mContent.mVideos) contentObjectVideosListBox.Items.Add(video.mName); } // If nothing is selected, some views need to be disabled and cleared as there is not active selection else { // The current content object is set to a dummy object - any changes or references here will be discarded mContent = new Content(); // Disable and clear all the following controls contentObjectNameTextBox.Enabled = false; contentObjectNameTextBox.Text = ""; // Uncheck all actors in the contentObjectActorsCheckedListBox contentObjectActorsCheckedListBox.Enabled = false; for (int i = 0; i < contentObjectActorsCheckedListBox.Items.Count; i++) contentObjectActorsCheckedListBox.SetItemCheckState(i, CheckState.Unchecked); contentObjectTextTextBox.Enabled = false; contentObjectTextTextBox.Text = ""; contentObjectVideosListBox.Enabled = false; contentObjectVideosListBox.Items.Clear(); } }
private void newToolStripMenuItem_Click(object sender, EventArgs e) { DialogResult result = MessageBox.Show("Are you sure you wish to discard any unsaved progress?", "New App", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == System.Windows.Forms.DialogResult.Yes) { mApp = new App(); mContent = new Content(); mVideo = new Video(); applicationNameTextBox.Text = mApp.mName; MemoryStream ms = new MemoryStream(mApp.mIcon, 0, mApp.mIcon.Length); ms.Write(mApp.mIcon, 0, mApp.mIcon.Length); applicationIconPictureBox.Image = Image.FromStream(ms); actorsListBox.Items.Clear(); contentObjectActorsCheckedListBox.Items.Clear(); contentsListBox.SelectedIndex = -1; contentsListBox.Items.Clear(); } }
private void openToolStripMenuItem_Click(object sender, EventArgs e) { DialogResult result = openXMLFileDialog.ShowDialog(); if (result == DialogResult.OK) { mApp = App.load(openXMLFileDialog.FileName); mContent = new Content(); mVideo = new Video(); applicationNameTextBox.Text = mApp.mName; MemoryStream ms = new MemoryStream(mApp.mIcon, 0, mApp.mIcon.Length); ms.Write(mApp.mIcon, 0, mApp.mIcon.Length); applicationIconPictureBox.Image = Image.FromStream(ms); actorsListBox.Items.Clear(); contentObjectActorsCheckedListBox.Items.Clear(); foreach (string actor in mApp.mActors) { actorsListBox.Items.Add(actor); contentObjectActorsCheckedListBox.Items.Add(actor); } contentsListBox.SelectedIndex = -1; contentsListBox.Items.Clear(); foreach (Content content in mApp.mContents) contentsListBox.Items.Add(content.mName); } }
/// <summary> /// Called when the new content button is clicked. Creates a new content object. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void contentsListBoxNewButton_Click(object sender, EventArgs e) { // Create a new content object mContent = new Content(); // Assign it a default name mContent.mName = "My Content"; // Add it to the app store mApp.mContents.Add(mContent); // Add this to the contentsListBox and set it to be the current focus contentsListBox.Items.Add(mContent.mName); contentsListBox.SelectedIndex = contentsListBox.Items.Count - 1; }