Пример #1
0
        private void encacheAssetDefinition(out List <string> filesToCopy, out List <string> fileDestinations)
        {
            assetDefinition             = new AssetDefinition();
            assetDefinition.Name        = assetNameTextBox.Text;
            assetDefinition.Description = descriptionTextBox.Text;
            assetDefinition.TypeEnum    = AssetTypeDesc.AssetTypeEnumFromName(assetTypeComboBox.Text);
            assetDefinition.Category    = categoryComboBox.Text;
            assetDefinition.Properties  = savedProperties;
            int fileNumber = 0;

            filesToCopy      = new List <string>();
            fileDestinations = new List <string>();
            foreach (FileDescControls desc in allControls)
            {
                AssetTypeFileDesc d = desc.desc;
                if (desc.useTextBox)
                {
                    if (desc.textBox.Text.Length > 0)
                    {
                        string    s          = desc.textBox.Text.ToString();
                        string    targetFile = MakeDestinationFile(assetDefinition.TypeEnum, s, d.FileTypeEnum, fileNumber);
                        AssetFile file       = new AssetFile(targetFile, d.FileTypeEnum);
                        if (copyFromSource(s))
                        {
                            filesToCopy.Add(s);
                            fileDestinations.Add(file.TargetFile);
                        }
                        assetDefinition.Files.Add(file);
                        fileNumber++;
                    }
                }
                else
                {
                    for (int i = 0; i < desc.listBox.Items.Count; i++)
                    {
                        AssetFile file = new AssetFile();
                        file.FileTypeEnum = d.FileTypeEnum;
                        string s          = desc.listBox.Items[i].ToString();
                        string targetFile = MakeDestinationFile(assetDefinition.TypeEnum, s, d.FileTypeEnum, fileNumber);
                        file.TargetFile = targetFile;
                        if (copyFromSource(s))
                        {
                            filesToCopy.Add(s);
                            fileDestinations.Add(file.TargetFile);
                        }
                        assetDefinition.Files.Add(file);
                        fileNumber++;
                    }
                }
            }
            assetDefinition.ComputeStatus();
        }
Пример #2
0
        private void displayAssetDefinition()
        {
            assetNameTextBox.Text   = assetDefinition.Name;
            descriptionTextBox.Text = assetDefinition.Description;
            assetTypeComboBox.Text  = AssetTypeDesc.AssetTypeEnumName(assetDefinition.TypeEnum);
            setupCategoryComboBox(assetDefinition.TypeEnum);
            setCategory(assetDefinition.Category);
            createControlsForAssetType(assetDefinition.TypeEnum);
            int fileIndex = 0;

            foreach (FileDescControls desc in allControls)
            {
                if (fileIndex >= assetDefinition.Files.Count)
                {
                    break;
                }
                AssetTypeFileDesc d    = desc.desc;
                AssetFile         file = assetDefinition.Files[fileIndex];
                if (desc.useTextBox)
                {
                    if (d.FileTypeEnum == file.FileTypeEnum)
                    {
                        desc.textBox.Text = file.TargetFile;
                        fileIndex++;
                    }
                }
                else
                {
                    while (fileIndex < assetDefinition.Files.Count)
                    {
                        file = assetDefinition.Files[fileIndex];
                        if (d.FileTypeEnum != file.FileTypeEnum)
                        {
                            break;
                        }
                        desc.listBox.Items.Add(file.TargetFile);
                        fileIndex++;
                    }
                }
            }
        }
Пример #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();
            }
        }
Пример #4
0
        private int createAssetTypeFileControls(int index, int y, AssetTypeFileDesc desc, out FileDescControls c)
        {
            Control parentControl = this;

            c          = new FileDescControls();
            c.desc     = desc;
            c.tabIndex = assetTypeComboBox.TabIndex + 1 + index * 2;
            c.index    = index;
            c.yCoord   = y;
            int labelHeight = 36;

            if (desc.MaxCount == 1)
            {
                c.labelText = (desc.MinCount == 0 ? "Optional " : "") +
                              (desc.AdditionalText != "" ? desc.AdditionalText + " " : "") +
                              AssetFile.AssetFileEnumName(desc.FileTypeEnum);
                c.height     = 40;
                c.useTextBox = true;
            }
            else
            {
                c.labelText = "Optional " + (desc.AdditionalText != "" ? desc.AdditionalText + " " : "") +
                              AssetFile.AssetFileEnumName(desc.FileTypeEnum) + "s";
                labelHeight  = 72;
                c.height     = 100;
                c.useTextBox = false;
            }
            int boxWidth   = this.Width - genOffset - 94 - 67 - 18;
            int buttonLeft = genOffset + 101 + boxWidth;

            c.labelText += ":";
            Label label = new System.Windows.Forms.Label();

            label.AutoSize  = false;
            label.TextAlign = ContentAlignment.MiddleRight;
            label.Location  = new System.Drawing.Point(genOffset + 5, y - 6);
            label.Name      = "AddLabel" + index;
            label.Size      = new System.Drawing.Size(85, labelHeight);
            label.TabStop   = false;
            label.Text      = c.labelText;
            label.Parent    = parentControl;
            c.label         = label;

            Button button = new System.Windows.Forms.Button();

            button.Location = new System.Drawing.Point(buttonLeft, y);
            button.Name     = "AddButton" + index;
            button.Size     = new System.Drawing.Size(63, 24);
            button.TabIndex = c.tabIndex;
            button.Text     = "Browse...";
            button.UseVisualStyleBackColor = true;
            button.Tag    = c;
            button.Click += buttonSelect_Click;
            button.Parent = parentControl;
            c.button      = button;

            if (c.useTextBox)
            {
                TextBox textBox = new System.Windows.Forms.TextBox();
                textBox.Location     = new System.Drawing.Point(genOffset + 94, y);
                textBox.Name         = "textBox1";
                textBox.Size         = new System.Drawing.Size(boxWidth, 20);
                textBox.TabIndex     = c.tabIndex + 1;
                textBox.Tag          = c;
                textBox.Parent       = parentControl;
                textBox.AllowDrop    = true;
                textBox.DragDrop    += new System.Windows.Forms.DragEventHandler(anyTextBox_DragDrop);
                textBox.DragOver    += new System.Windows.Forms.DragEventHandler(anyTextBox_DragOver);
                textBox.TextChanged += new System.EventHandler(someTextBoxChanged);
                c.textBox            = textBox;
            }
            else
            {
                ListBox listBox = new System.Windows.Forms.ListBox();
                listBox.FormattingEnabled = true;
                listBox.Location          = new System.Drawing.Point(genOffset + 94, y);
                listBox.Name       = "AddListBox" + index;
                listBox.Size       = new System.Drawing.Size(boxWidth, 82);
                listBox.TabIndex   = c.tabIndex + 1;
                listBox.Tag        = c;
                listBox.Parent     = parentControl;
                listBox.AllowDrop  = true;
                listBox.DragDrop  += new System.Windows.Forms.DragEventHandler(anyListBox_DragDrop);
                listBox.DragOver  += new System.Windows.Forms.DragEventHandler(anyListBox_DragOver);
                listBox.MouseUp   += new System.Windows.Forms.MouseEventHandler(anyListBox_MouseUp);
                listBox.MouseMove += new System.Windows.Forms.MouseEventHandler(anyListBox_MouseMove);
                listBox.MouseDown += new System.Windows.Forms.MouseEventHandler(anyListBox_MouseDown);

                c.listBox = listBox;
            }
            return(y + c.height);
        }