Пример #1
0
        private void anyListBox_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
        {
            ListBox targetListBox = (ListBox)sender;

            if (e.Data.GetDataPresent(typeof(System.String)))
            {
                string s = (string)e.Data.GetData(typeof(System.String));
                if (targetListBox != filesListBox)
                {
                    s = RepositoryClass.MakeFullFilePath(lastSourceDirectory, s);
                }
                s = adjustForRepositoryPath(s);
                Object item = (Object)s;
                // Perform drag-and-drop, depending upon the effect.
                if (e.Effect == DragDropEffects.Copy ||
                    e.Effect == DragDropEffects.Move)
                {
                    // Insert the item.
                    deleteMatchingListBoxItem(targetListBox, s);
                    if (indexOfTargetItem != ListBox.NoMatches)
                    {
                        targetListBox.Items.Insert(indexOfTargetItem, item);
                    }
                    else
                    {
                        targetListBox.Items.Add(item);
                    }
                    setSomethingChanged();
                }
            }
        }
Пример #2
0
        private void anyTextBox_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
        {
            TextBox          targetTextBox = (TextBox)sender;
            FileDescControls c             = (FileDescControls)targetTextBox.Tag;

            if (e.Data.GetDataPresent(typeof(System.String)))
            {
                string value = (string)e.Data.GetData(typeof(System.String));
                // Perform drag-and-drop, depending upon the effect.
                if (e.Effect == DragDropEffects.Copy ||
                    e.Effect == DragDropEffects.Move)
                {
                    value = RepositoryClass.MakeFullFilePath(lastSourceDirectory, value);
                    value = adjustForRepositoryPath(value);
                    targetTextBox.Text = value;
                    if (c.index == 0 && assetNameTextBox.Text.Length == 0)
                    {
                        string fileName = Path.GetFileNameWithoutExtension(value);
                        assetNameTextBox.Text = Path.GetFileNameWithoutExtension(fileName) + "_" +
                                                AssetTypeDesc.AssetTypeEnumFileName((AssetTypeEnum)assetTypeComboBox.SelectedIndex + 1);
                    }
                    setSomethingChanged();
                }
            }
        }