void lvShortcuts_SubItemEditing(object sender, ListViewSubItemEventArgs args)
 {
     if (args != null && args.Item != null && !args.Handled)
     {
         OPMShortcut cmd = (OPMShortcut)args.Item.Tag;
         if (ShortcutMapper.IsConfigurableShortcut(cmd))
         {
             if (args.SubItemIndex == hdrKey.Index)
             {
                 EditCommand(cmd, true);
             }
             else if (args.SubItemIndex == hdrAltkey.Index)
             {
                 EditCommand(cmd, false);
             }
         }
     }
 }
 void OnListEdited(object sender, ListViewSubItemEventArgs args)
 {
     BuildSubtitleDownloadURIsFromList();
     Modified = true;
 }
 void lvTracks_SubItemEdited(object sender, ListViewSubItemEventArgs args)
 {
     Track t = args.Item.Tag as Track;
     if (t != null)
     {
         if (args.SubItemIndex == colAlbum.Index)
         {
             t.Album = args.SubItem.Text;
         }
         else if (args.SubItemIndex == colArtist.Index)
         {
             t.Artist = args.SubItem.Text;
         }
         else if (args.SubItemIndex == colTitle.Index)
         {
             t.Title = args.SubItem.Text;
         }
         else if (args.SubItemIndex == colGenre.Index)
         {
             t.Genre = args.SubItem.Text;
         }
     }
 }
 void lvBookmarks_SubItemEdited(object sender, ListViewSubItemEventArgs args)
 {
     SaveBookmarks(true);
 }
 void lvConnFiles_SubItemEdited(object sender, ListViewSubItemEventArgs args)
 {
     RebuildDataTable();
 }
Beispiel #6
0
        private void lvPictures_SubItemEdited(object sender, ListViewSubItemEventArgs args)
        {
            if (lvPictures.SelectedItems.Count > 0)
            {
                PictureInfo pi = lvPictures.SelectedItems[0].Tag as PictureInfo;
                if (pi != null)
                {
                    string val = args.SubItem.Text;

                    if (args.SubItemIndex == colDescription.Index)
                    {
                        pi.Description = val;
                    }
                    else if (args.SubItemIndex == colImageType.Index)
                    {
                        if (!string.IsNullOrEmpty(val))
                        {
                            pi.PictureType = (PictureType)Enum.Parse(typeof(PictureType), val);
                        }
                    }
                }
            }
        }
Beispiel #7
0
        /// <summary>
        /// End the in-place editing action. It results in "hiding" the
        /// in-place edit control.
        /// </summary>
        /// <param name="acceptChanges">Set to true to accept the new value,
        /// that is resulting after the editing action.</param>
        public void EndEditing(bool acceptChanges)
        {
            if (1 == Interlocked.CompareExchange(ref endEditingPending, 1, 0))
                return;

            try
            {
                if (activeEditControl == null || !activeEditControl.Visible)
                    return;

                ThemeForm frm = FindForm() as ThemeForm;
                if (frm != null && _restoreKeyPreview)
                {
                    frm.SuppressKeyPress = false;
                    _restoreKeyPreview = false;
                }

                // Check the row bounds.
                if (row < 0 || row >= this.Items.Count)
                    return;
                // Check the column bounds.
                if (column < 0 || column >= this.Columns.Count)
                    return;

                ListViewItem editedItem = this.Items[row];
                ListViewItem.ListViewSubItem editedSubItem = editedItem.SubItems[column];
                if (acceptChanges)
                {
                    // Editing results should be handled differently
                    // for each type of supported in-place edit control.
                    OPMListViewSubItem customSubItem = editedSubItem as OPMListViewSubItem;


                    string text = "";
                    
                    if (activeEditControl is MultilineEditTextBox)
                        text = (activeEditControl as MultilineEditTextBox).MultiLineText;
                    else
                        text = activeEditControl.Text;

                    if (customSubItem != null)
                        customSubItem.Text = text;
                    else
                        editedSubItem.Text = text;

                    // Check if event handler available and if positive, raise the event
                    if (SubItemEdited != null)
                    {

                        ListViewSubItemEventArgs args =
                            new ListViewSubItemEventArgs(activeEditControl, editedItem,
                            editedSubItem, column);
                        SubItemEdited(this, args);

                        // Check if the event was handled - thus the in-place edit controls
                        // displayed.
                        if (args.Handled)
                        {
                            return;
                        }
                    }
                }
            }
            finally
            {
                // Nothing is edited right now.
                row = column = -1;

                // Disable the control and make it invisible ("hide" it).
                //>>>> FIXUP for nasty bug
                // for some strange reason (which we don't have time to investigate)
                // the SubItemEdited event f***s up the activeEditControl of the list.
                // So we put an extra protection here to prevent exceptions popping up
                if (activeEditControl != null)
                {
                    activeEditControl.Hide();
                    activeEditControl.Enabled = false;
                    activeEditControl.BringToFront();
                    // Unsubscribe for the event handlers.
                    activeEditControl.Leave -= new EventHandler(OnEditorLeave);
                    activeEditControl.KeyDown -= new KeyEventHandler(OnEditorKeyDown);

                    // Set activeEditControl as null
                    activeEditControl = null;
                }

                // Focus back to the list.
                Focus();

                Interlocked.Exchange(ref endEditingPending, 0);
                Invalidate();
            }
        }
Beispiel #8
0
        /// <summary>
        /// Displays the in-place edit control for a given list view subitem.
        /// It is assumed that the in-place edit control was previously created
        /// and assigned to the proper column, by means of the SetEditControl
        /// method.
        /// </summary>
		/// <param name="editedItem">The item to be edited.</param>
		/// <param name="editedSubItem">The subitem to be edited.</param>
        public void StartEditing(ListViewItem editedItem, OPMListViewSubItem editedSubItem)
        {
            if (_allowEdit == false)
                return;

            row = editedItem.Index;
            column = editedItem.SubItems.IndexOf(editedSubItem);

            if (row < 0 || column < 0 || editedSubItem == null)
                return;

            // Check if event handler available and if positive, raise the event

            Control editControl = null;
			
			// Override the editable control in the custom subitem, if such an item is used.
			OPMListViewSubItem customSubItem = editedSubItem as OPMListViewSubItem;
			if (customSubItem != null)
			{
				if (customSubItem.ReadOnly)
				{
					// non-editable item
					return;
				}
				else
				{
					// override the edit control
					editControl = customSubItem.EditControl;
				}
			}

            if (editControl == null)
                return;

			ListViewSubItemEventArgs args =
				new ListViewSubItemEventArgs(editControl, editedItem, 
				editedSubItem, column);
			if (SubItemEditing != null && editControl != null)
			{
				SubItemEditing(this, args);
			}

            if (!(editControl is LinkLabel))
            {
                // For link labels, we only raise the SubItemEditing event

                // Check if the event was handled - thus the in-place edit controls
                // displayed.
                if (!args.Handled)
                {
                    // Display edit control and also set text.
                    DisplayEditControl(false, editControl, editedSubItem);
                }

                ThemeForm frm = FindForm() as ThemeForm;
                if (frm != null)
                {
                    frm.SuppressKeyPress = true;
                    _restoreKeyPreview = true;
                }
            }
        }