Esempio n. 1
0
        private void anyTextBox_DragOver(object sender, DragEventArgs e)
        {
            TextBox targetTextBox = (TextBox)sender;

            if (!e.Data.GetDataPresent(typeof(System.String)))
            {
                e.Effect = DragDropEffects.None;
                return;
            }
            string value = (string)e.Data.GetData(DataFormats.StringFormat);
            Object tag   = targetTextBox.Tag;

            if (targetTextBox.Text == value ||
                (tag != null && !AssetFile.AllExtensionsForEnum(((FileDescControls)tag).desc.FileTypeEnum).
                 Contains(Path.GetExtension(value).ToLower())))
            {
                e.Effect = DragDropEffects.None;
                return;
            }
            e.Effect = DragDropEffects.Copy;
        }
Esempio n. 2
0
        private void anyListBox_DragOver(object sender, DragEventArgs e)
        {
            ListBox targetListBox = (ListBox)sender;

            if (!e.Data.GetDataPresent(typeof(System.String)))
            {
                e.Effect = DragDropEffects.None;
                return;
            }
            string value = (string)e.Data.GetData(DataFormats.StringFormat);
            Object tag   = targetListBox.Tag;

            if (targetListBox.Items.Contains(value) ||
                (tag != null && !AssetFile.AllExtensionsForEnum(((FileDescControls)tag).desc.FileTypeEnum).
                 Contains(Path.GetExtension(value).ToLower())))
            {
                e.Effect = DragDropEffects.None;
                return;
            }
            e.Effect          = DragDropEffects.Copy;
            indexOfTargetItem = targetListBox.IndexFromPoint(targetListBox.PointToClient(new Point(e.X, e.Y)));
        }
Esempio n. 3
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();
            }
        }