示例#1
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();
                }
            }
        }
示例#2
0
        private void buttonSelect_Click(object sender, EventArgs e)
        {
            Button            button = (Button)sender;
            FileDescControls  c      = (FileDescControls)button.Tag;
            AssetTypeFileDesc desc   = c.desc;

            // Invoke the file open dialog
            openSourceFileDialog.FileName = "";
            List <string> extensions    = AssetFile.AllExtensionsForEnum(desc.FileTypeEnum);
            string        extList       = "";
            string        extListHidden = "";

            foreach (string ext in extensions)
            {
                if (extList.Length > 0)
                {
                    extList += ";";
                }
                extList += "*" + ext;
                if (extListHidden.Length > 0)
                {
                    extListHidden += ";";
                }
                extListHidden += "*" + ext + ";" + "*" + ext.ToUpper();
            }
            string filter = string.Format("All {0} Files ({1})|{2}|All Files (*.*)|*.*",
                                          AssetFile.AssetFileEnumName(desc.FileTypeEnum),
                                          extList, extListHidden);

            openSourceFileDialog.Filter      = filter;
            openSourceFileDialog.Multiselect = c.listBox != null;
            if (openSourceFileDialog.ShowDialog() == DialogResult.OK)
            {
                foreach (string fileName in openSourceFileDialog.FileNames)
                {
                    string extension = Path.GetExtension(fileName);
                    if (c.index == 0 && assetNameTextBox.Text.Length == 0)
                    {
                        assetNameTextBox.Text = Path.GetFileNameWithoutExtension(fileName) + "_" +
                                                AssetTypeDesc.AssetTypeEnumFileName((AssetTypeEnum)assetTypeComboBox.SelectedIndex + 1);
                    }
                    //              if (extension.ToLower() == ".mesh") {
                    //                  string materialName;
                    //                  string skeletonName;
                    //                  RepositoryClass.Instance.ReadMeshMaterialAndSkeleton(fileName, out materialName, out skeletonName);
                    //              }
                    maybeUpdateSourceDirectory(fileName);
                    string adjustedFileName = adjustForRepositoryPath(fileName);
                    if (c.useTextBox)
                    {
                        c.textBox.Text = adjustedFileName;
                    }
                    else
                    {
                        deleteMatchingListBoxItem(c.listBox, adjustedFileName);
                        c.listBox.Items.Add(adjustedFileName);
                    }
                }
                setSomethingChanged();
            }
        }