Esempio n. 1
0
        private void ChangeAssetImportnameInListView(string newName)
        {
            foreach (ListViewItem item in RenameListView.Items)
            {
                // Get the old name
                string importFileName = item.SubItems[3].Text;

                // Replace with the new name
                importFileName = importFileName.Replace(DosUtils.PathGetFileNameWithoutExtension(importFileName), newName);

                // Set it
                item.SubItems[3].Text = importFileName;
            }
        }
Esempio n. 2
0
 private void RenameFiles_CheckedChanged(object sender, EventArgs e)
 {
     if (bInitialized)
     {
         // Are we reverting?
         if (RenameFiles.Checked == false)
         {
             // If so, then reset this import filename to what it was on init
             ChangeAssetImportnameInListView(DosUtils.PathGetFileNameWithoutExtension(importFilename));
         }
         else
         {
             // If not, then update the import filename
             ChangeAssetImportnameInListView(RenameNewLabelTextBox.Text);
         }
     }
 }
Esempio n. 3
0
        public static MOG_Property RepairProperty(MOG_Property propertyObject)
        {
            MOG_Property fixedPropertyObject = null;

            string key             = propertyObject.mKey;
            string section         = propertyObject.mSection;
            string propertySection = propertyObject.mPropertySection;
            string propertyKey     = propertyObject.mPropertyKey;
            string propertyValue   = propertyObject.mPropertyValue;

            MOG_Property tempProperty           = MOG_PropertyFactory.MOG_Relationships.New_RelationshipAssignment("", "", "", "");
            MOG_Property tempPackageProperty    = MOG_PropertyFactory.MOG_Relationships.New_PackageAssignment("", "", "");
            MOG_Property tempSourceFileProperty = MOG_PropertyFactory.MOG_Relationships.New_AssetSourceFile("");

            // Check if this property is a package relationship?
            if (string.Compare(section, tempPackageProperty.mSection, true) == 0)
            {
                string assetName = MOG_ControllerPackage.GetPackageName(propertyKey);
                string groups    = MOG_ControllerPackage.GetPackageGroups(propertyKey);
                string objects   = MOG_ControllerPackage.GetPackageObjects(propertyKey);

                // Remap various properties making sure we correct any problem areas
                MOG_Filename assetFilename = null;

                // Check if this property is a SourceFile relationship?
                if (string.Compare(propertySection, tempSourceFileProperty.mPropertySection, true) == 0)
                {
                    // Check if the specified file is within the library?
                    if (MOG_ControllerLibrary.IsPathWithinLibrary(propertyKey))
                    {
                        // Map this library file to a real asset name
                        assetFilename = MOG_ControllerProject.MapFilenameToLibraryAssetName(assetName, MOG_ControllerProject.GetPlatformName());
                        if (assetFilename != null)
                        {
                            fixedPropertyObject = MOG_PropertyFactory.MOG_Relationships.New_AssetSourceFile(assetFilename.GetFullFilename());
                        }
                    }
                }
                else
                {
                    // Try to find the assetname for the specified asset
                    ArrayList assets = MOG_ControllerProject.MapFilenameToAssetName(assetName, MOG_ControllerProject.GetPlatformName(), MOG_ControllerProject.GetWorkspaceDirectory());
                    if (assets == null || assets.Count == 0)
                    {
                        // The package could not be found
                        if (string.Compare(propertySection, tempPackageProperty.mPropertySection, true) == 0)
                        {
                            // Check if we actually had something specified?
                            if (assetName.Length > 0)
                            {
                                // Set the deafult packageFilename info
                                string assetClassification = "";
                                string assetPlatformName   = "All";
                                string assetLabel          = DosUtils.PathGetFileNameWithoutExtension(assetName);
                                string syncTargetPath      = DosUtils.PathGetDirectoryPath(assetName);

                                // Check if the assetName was already a valid MOG_Filename?
                                MOG_Filename packageFilename = new MOG_Filename(assetName);
                                if (packageFilename.GetAssetClassification().Length > 0)
                                {
                                    assetClassification = MOG_Filename.AppendAdamObjectNameOnClassification(packageFilename.GetAssetClassification());
                                }
                                if (packageFilename.GetAssetPlatform().Length > 0)
                                {
                                    assetPlatformName = packageFilename.GetAssetPlatform();
                                }
                                if (packageFilename.GetAssetLabel().Length > 0)
                                {
                                    assetLabel = packageFilename.GetAssetLabel();
                                }

                                // Prompt user to complete the unknown information about this packageFile
                                string         message = "MOG has detected a new package assignment to a previously non-existing package.  Please complete the following red fields so that a proper package can be created in MOG.";
                                PackageCreator creator = new PackageCreator();
                                creator.Classification = assetClassification;
                                creator.PackageName    = assetLabel;
                                creator.SyncTarget     = syncTargetPath;
                                creator.Platform       = assetPlatformName;
                                if (creator.ShowDialog() == DialogResult.OK)
                                {
                                    // Use this newly created packageFilename as our assetFilename to be fixed
                                    assetFilename = creator.AssetName;
                                }
                                else
                                {
                                    // The PackageName is invalid
                                    message = "New Package Not Created.\n" +
                                              "The user chose not to create a new package.";
                                    MOG_Report.ReportMessage("Package Assignment", message, Environment.StackTrace, MOG_ALERT_LEVEL.ERROR);
                                }
                            }
                            else
                            {
                                // The PackageName is invalid
                                string message = "Invalid PackageName specified.\n" +
                                                 "The packaged asset was not assigned to a package.";
                                MOG_Report.ReportMessage("Package Assignment", message, Environment.StackTrace, MOG_ALERT_LEVEL.ERROR);
                            }
                        }
                    }
                    else
                    {
                        // Always use the first one
                        assetFilename = assets[0] as MOG_Filename;
                        MOG_ControllerProject.MapFilenameToAssetName_WarnAboutAmbiguousMatches(assetName, assets);
                    }

                    // Now do we finally have a package asset name?
                    if (assetFilename != null)
                    {
                        // Replace the propertyObject with the fixed up one
                        fixedPropertyObject = MOG_PropertyFactory.MOG_Relationships.New_RelationshipAssignment(propertySection, assetFilename.GetAssetFullName(), groups, objects);
                    }
                }
            }

            // Check if we fixed the property?
            if (fixedPropertyObject != null)
            {
                return(fixedPropertyObject);
            }
            return(propertyObject);
        }
Esempio n. 4
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;
                }
            }
        }
Esempio n. 5
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 ()
Esempio n. 6
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);
        }