示例#1
0
        private static void ImportRemainingItems_Worker(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;
            List <Object>    args   = e.Argument as List <Object>;

            List <ImportFile> remainingItems = args[0] as List <ImportFile>;
            bool      useExtension           = (bool)args[1];
            string    classification         = args[2] as string;
            string    platform      = args[3] as string;
            ArrayList propertyArray = args[4] as ArrayList;

            int itemCount = 0;

            foreach (ImportFile remainingItem in remainingItems)
            {
                // Create the MOG asset name
                string       assetLabel = useExtension ? DosUtils.PathGetFileName(remainingItem.mImportFilename) : DosUtils.PathGetFileNameWithoutExtension(remainingItem.mImportFilename);
                MOG_Filename multiFile  = MOG_Filename.CreateAssetName(classification, platform, assetLabel);

                // Create our import file list
                ArrayList multiInFiles = new ArrayList();
                multiInFiles.Add(remainingItem.mImportFilename);

                string message = "Importing:\n" +
                                 "     " + classification + "\n" +
                                 "     " + Path.GetFileName(remainingItem.mImportFilename);
                worker.ReportProgress(itemCount++ *100 / remainingItems.Count, message);

                // Import the asset
                MOG_ControllerAsset.CreateAsset(multiFile, "", multiInFiles, null, propertyArray, false, false);

                // Check if the user canceled things?
                if (worker.CancellationPending)
                {
                    break;
                }
            }
        }
示例#2
0
        private void InitializeAssetNames(ArrayList sourceFiles)
        {
            RenameListView.Items.Clear();

            InitializePlatformComboBox();

            string listOfBlessedAssets = "";

            // Check for presence of wildcards
            foreach (string fullFilename in sourceFiles)
            {
                MOG_Filename asset = new MOG_Filename(fullFilename);
                // If this Asset has been previously blessed...
                if (CheckIfAssetHasBeenBlessed(asset))
                {
                    listOfBlessedAssets += asset.GetAssetFullName() + "\r\n";
                }

                // Get the imported filenames
                ArrayList importFiles = DosUtils.FileGetRecursiveList(MOG_ControllerAsset.GetAssetImportedDirectory(MOG_Properties.OpenFileProperties(fullFilename + "\\Properties.info")), "*.*");
                if (importFiles.Count > 1)
                {
                    // If there are more that one, then we cannot rename the files of this asset
                    RenameFiles.Checked = false;
                    RenameFiles.Enabled = false;
                    importFilename      = "*Complex asset*";
                }
                else
                {
                    String importFile = importFiles[0] as string;

                    // Does this asset label match the imported filename?
                    if (string.Compare(DosUtils.PathGetFileNameWithoutExtension(importFile), DosUtils.PathGetFileNameWithoutExtension(asset.GetAssetLabel()), true) == 0)
                    {
                        // All is good then
                        importFilename = DosUtils.PathGetFileName(importFile);
                    }
                    else
                    {
                        // We cannot rename the files of this asset because the label and the imported filename do not match
                        RenameFiles.Checked = false;
                        RenameFiles.Enabled = false;
                        importFilename      = string.Format("Asset label({0}) and imported filename({1}) do not match!", DosUtils.PathGetFileNameWithoutExtension(asset.GetAssetLabel()), DosUtils.PathGetFileNameWithoutExtension(importFile));
                    }
                }

                mFullFilename = fullFilename;
                ListViewItem item = RenameListView.Items.Add(asset.GetAssetFullName());
                item.SubItems.Add(asset.GetAssetFullName());
                item.SubItems.Add(asset.GetAssetEncodedPath());
                item.SubItems.Add(importFilename);
                item.Selected = true;

                CheckStringForMatch(ref mCommonClass, asset.GetAssetClassification());
                CheckStringForMatch(ref mCommonPlatform, asset.GetAssetPlatform());
                CheckStringForMatch(ref mCommonLabel, asset.GetAssetLabel());
            }

            // If we have any Blessed Assets and we don't have privilege to rename them, warn the user
            if (listOfBlessedAssets.Length > 0 && !CheckPrivilegeToRename())
            {
                MOG_Prompt.PromptMessage("Insufficient privileges to rename already blessed assets",
                                         "You do not have permission to rename these previously blessed assets:\r\n" + listOfBlessedAssets);
            }
            // Else, If we have any Blessed Assets, warn user about the rename
            else if (listOfBlessedAssets.Length > 0)
            {
                MOG_Prompt.PromptMessage("Inbox renames don't rename previously blessed assets",
                                         "The following blessed assets will still exist when renamed assets are blessed:\r\n" + listOfBlessedAssets);
            }

            RenameListView.Select();

            InitializeTextBoxes(mCommonClass, mCommonPlatform, mCommonLabel);

            // Make it so that our user will hopefully type over the "*" when assigning a classification...
            if (mCommonClass == "*")
            {
                this.RenameNewClassNameTextBox.SelectAll();
            }

            bInitialized = true;
        }         // end ()
示例#3
0
        private string FixName(string name, ImportFile fullFilename, ref ArrayList properties)
        {
            string newName = null;
            bool   succeed = false;
            bool   cancel  = false;

            // Have we previously specified whether or not to apply changes to all names?
            if (mOkToAll == false)
            {
                // Looks like we need to fix up the name...
                ImportAssetTreeForm mImportForm = new ImportAssetTreeForm(fullFilename);

                // Keep trying until we either fix the name or we cancel.
                while (!succeed && !cancel)
                {
                    // Show BlessDialog as a modal dialog and determine if DialogResult = OK.
                    mImportForm.ShowDialog(MogMainForm.MainApp);
                    DialogResult rc = mImportForm.DialogResult;

                    // Save our extension settings for multi import
                    mShowExtensions = mImportForm.MOGShowExtensions;

                    // Check dialog results
                    if (rc == DialogResult.Cancel)
                    {
                        // This means the user clicked cancel
                        cancel = true;
                    }
                    else
                    {
                        if (rc == DialogResult.Yes)
                        {
                            // This is the OkToAll button
                            mOkToAll = true;
                        }

                        // Construct the new name based on the dialog fields
                        newName = mImportForm.GetFixedAssetName();

                        // Always check each name to make sure it worked...
                        succeed = CheckName(newName);
                        if (succeed)
                        {
                            properties.AddRange(mImportForm.MOGPropertyArray);

                            // Set previous settings for future imports
                            mPreviousProperties = new ArrayList();
                            mPreviousProperties.AddRange(mImportForm.MOGPropertyArray);
                            mPreviousClassifiaton = mImportForm.FinalAssetName.GetAssetClassification();
                            mPreviousPlatform     = mImportForm.FinalAssetName.GetAssetPlatform();
                        }
                    }
                }
            }
            else
            {
                // Since the OkToAll button was previously selected, just fix this name the same way w/o asking
                // Make sure to create mog names that match our previous settings of 'Extension' or 'No Extension'
                if (mShowExtensions)
                {
                    name = DosUtils.PathGetFileName(fullFilename.mImportFilename);
                }
                else
                {
                    name = DosUtils.PathGetFileNameWithoutExtension(fullFilename.mImportFilename);
                }

                MOG_Filename newAssetName = MOG_Filename.CreateAssetName(mPreviousClassifiaton, mPreviousPlatform, name);
                newName = newAssetName.GetAssetFullName();

                // Always check each name to make sure it worked...
                succeed = CheckName(newName);
                if (succeed == false)
                {
                    // Wow, this current name failed after a previous one succeeded...force the dialog to display agian.
                    mOkToAll = false;
                    newName  = FixName(name, fullFilename, ref properties);
                }
                else
                {
                    // Load previous properties set on earlier imports
                    properties.AddRange(mPreviousProperties);
                }
            }

            return(newName);
        }