Beispiel #1
0
        private void editBtn_Click(object sender, EventArgs e)
        {
            Participant       selectedParticipant = (Participant)list.SelectedItems[0].Tag;
            ParticipantEditor editor = new ParticipantEditor(selectedParticipant);

            editor.Text = "Edit Participant";
            DialogResult dr = editor.ShowDialog();

            if (dr == DialogResult.OK)
            {
                Participant editedParticipant = editor.GetParticipant();

                Debug.Assert(editedParticipant.Identifier == editor.OriginalParticipant.Identifier);

                StorageFile.UpdateParticipant(editedParticipant);

                // Don't remove the image; it will screw up the images for all of the other participants
                // But we will check to see if the image has changed (if not, just use the old imageIndex)
                int imageIndex;
                if (editedParticipant.Icon == selectedParticipant.Icon)
                {
                    imageIndex = list.SelectedItems[0].ImageIndex;
                }
                else
                {
                    imageIndex = AddIcon(editedParticipant.Icon);
                }

                // Remove the old item
                list.Items.RemoveAt(list.SelectedIndices[0]);

                // Create and add the new item
                list.Items.Add(CreateLvi(editedParticipant, imageIndex));
            }
        }
        private void editBtn_Click(object sender, EventArgs e)
        {
            Participant selectedParticipant = (Participant)list.SelectedItems[0].Tag;
            ParticipantEditor editor = new ParticipantEditor(selectedParticipant);
            editor.Text = "Edit Participant";
            DialogResult dr = editor.ShowDialog();

            if (dr == DialogResult.OK)
            {
                Participant editedParticipant = editor.GetParticipant();

                Debug.Assert(editedParticipant.Identifier == editor.OriginalParticipant.Identifier);

                StorageFile.UpdateParticipant(editedParticipant);

                // Don't remove the image; it will screw up the images for all of the other participants
                // But we will check to see if the image has changed (if not, just use the old imageIndex)
                int imageIndex;
                if (editedParticipant.Icon == selectedParticipant.Icon)
                    imageIndex = list.SelectedItems[0].ImageIndex;
                else
                    imageIndex = AddIcon(editedParticipant.Icon);

                // Remove the old item
                list.Items.RemoveAt(list.SelectedIndices[0]);

                // Create and add the new item
                list.Items.Add (CreateLvi(editedParticipant, imageIndex));
            }
        }