AddonManager.MainForm.checkedListBox_DragDrop C# (CSharp) Метод

checkedListBox_DragDrop() приватный Метод

private checkedListBox_DragDrop ( object sender, DragEventArgs e ) : void
sender object
e System.Windows.Forms.DragEventArgs
Результат void
        private void checkedListBox_DragDrop(object sender, DragEventArgs e)
        {
            CheckedListBox targetListBox = (CheckedListBox)sender;

            string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
            foreach (string file in files)
            {
                if (!File.Exists(file))
                    continue;
                try
                {
                    string fileName = Path.GetFileName(file);
                    int targetIndex = targetListBox.Items.IndexOf(targetListBox.Items.Cast<string>()
                        .Where(itemText => itemText.StartsWith(fileName))
                        .First());

                    targetListBox.Items[targetIndex] = String.Format("{0} ({1})", fileName, file);
                    ActiveCheckedListBox.managingLists = true;
                    targetListBox.SetItemChecked(targetIndex, true);
                    ActiveCheckedListBox.managingLists = false;
                    log.InfoFormat("Updated {0} on {1}.", fileName, targetListBox.Name);
                }
                catch (InvalidOperationException)
                {
                    log.InfoFormat("The file {0} was discarded as it is invalid.", file);
                }
                catch (ArgumentNullException)
                {
                    log.InfoFormat("The file {0} was discarded as it is invalid.", file);
                }
            }
        }
        #endregion