示例#1
0
        private void EditConference(object sender, System.Windows.Forms.NodeLabelEditEventArgs e)
        {
            // Only allow renaming (re-describing) conferences only
            if (!(e.Node.Tag is Conference))
            {
                e.CancelEdit = true;
                return;
            }
            else if (e.Label == null)  // For some reason, this means the label was edited but not changed
            {
                return;
            }

            // Display wait cursor
            Cursor.Current = Cursors.WaitCursor;

            // Get conference info
            Conference conf = e.Node.Tag as Conference;

            // Test for someone leaving the time string at the beginning & remove it, if necessary
            string time = string.Format(CultureInfo.CurrentCulture, Strings.ConferenceLower,
                                        conf.Start.ToShortTimeString().ToLower(CultureInfo.InvariantCulture));
            string newLabel;

            if (e.Label.ToLower(CultureInfo.InvariantCulture).StartsWith(time))
            {
                // it's there, so remove it.
                newLabel = e.Label.Substring(time.Length);
            }
            else
            {
                newLabel = e.Label;
            }

            // Update DB
            if (DBHelper.RenameConference(conf.ConferenceID, newLabel))
            {
                conf.Description = newLabel;
                e.Node.Text      = string.Format(CultureInfo.CurrentCulture, Strings.Conference,
                                                 conf.Start.ToShortTimeString(), newLabel);
                e.CancelEdit = true; // we do this to prevent some base code from ignoring the line just above
            }

            // Return to normal cursor
            Cursor.Current = Cursors.Default;
        }