Example #1
0
        private void SyncTargetTreeView_AfterSelect(object sender, TreeViewEventArgs e)
        {
            string relativePath = DosUtils.PathMakeRelativePath(MOG_ControllerProject.GetWorkspaceDirectory(), e.Node.FullPath);

            SyncTargetTextBox.Text      = relativePath;
            SyncTargetTextBox.BackColor = Color.PaleGreen;
        }
Example #2
0
        /// <summary>
        /// Load saved ComboBoxItems from an Ini
        /// </summary>
        /// <param name="section">Section where to look for the items</param>
        /// <param name="ini">Ini in which to look for section</param>
        /// <returns>Array of MogTaggedStrings that can be placed directly into a ComboBox</returns>
        private MogTaggedString[] LoadComboBoxItems(string section, MOG_Ini ini)
        {
            int count = ini.CountKeys(section);

            MogTaggedString[] tbStrings = new MogTaggedString[count];

            // Determin the desired directory
            string directory = string.IsNullOrEmpty(this.FolderName) ? MOG_ControllerProject.GetWorkspaceDirectory() : this.FolderName;

            // Check if we are missing a root path?
            if (!Path.IsPathRooted(directory))
            {
                // Append on the current workspace directory
                directory = Path.Combine(MOG_ControllerProject.GetWorkspaceDirectory(), directory.Trim("\\".ToCharArray()));
            }

            // Load the items from the ini
            for (int i = 0; i < count; ++i)
            {
                string filename = ini.GetKeyByIndexSLOW(section, i);

                tbStrings[i] = new MogTaggedString(filename, filename, this.FilenameStyle, directory);
            }
            return(tbStrings);
        }
        public void InitializeVirtual(string platform)
        {
            // Default us to the current workspace directory
            string workspaceDirectory = MOG_ControllerProject.GetWorkspaceDirectory();

            // Check if we have no workspace directory?
            if (workspaceDirectory.Length == 0)
            {
                // Default to the project name
                workspaceDirectory = MOG_ControllerProject.GetProjectName();
            }

            InitializeVirtual(workspaceDirectory, platform);
        }
Example #4
0
        private void Clean_Worker(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker             = sender as BackgroundWorker;
            ArrayList        selectedItems      = e.Argument as ArrayList;
            string           workspaceDirectory = MOG_ControllerProject.GetWorkspaceDirectory() + "\\";

            for (int i = 0; i < selectedItems.Count && !worker.CancellationPending; i++)
            {
                string file         = selectedItems[i] as string;
                string relativeFile = file;
                if (file.StartsWith(workspaceDirectory, StringComparison.CurrentCultureIgnoreCase))
                {
                    relativeFile = file.Substring(workspaceDirectory.Length);
                }

                string message = "Deleting:\n" +
                                 "     " + Path.GetDirectoryName(relativeFile) + "\n" +
                                 "     " + Path.GetFileName(relativeFile);
                worker.ReportProgress(i * 100 / selectedItems.Count, message);

                // Check if this file really exists?
                if (DosUtils.FileExistFast(file))
                {
                    if (!DosUtils.Recycle(file))
                    {
                        // Error
                        MOG_Prompt.PromptMessage("Delete File", "Could not delete:\n" + file);
                    }
                    else
                    {
                        if (!DosUtils.DirectoryDeleteEmptyParentsFast(Path.GetDirectoryName(file), true))
                        {
                            if (DosUtils.GetLastError() != null && DosUtils.GetLastError().Length > 0)
                            {
                                // Error
                                MOG_Prompt.PromptMessage("Delete directory", "Could not delete directory:\n" + Path.GetDirectoryName(file));
                            }
                        }
                    }
                }
            }
        }
Example #5
0
        /// <summary>
        /// Initialize a new MogTaggedString, which can have an object it points to.
        /// </summary>
        /// <param name="nameString">The actual string to be displayed to the user</param>
        /// <param name="attachedItem">The attached object for design-time/run-time use</param>
        /// <param name="filenameStyle"></param>
        public MogTaggedString(string nameString, object attachedItem, FilenameStyleTypes filenameStyle, string relativeFolder)
        {
            this.FullName       = nameString;
            this.Name           = Path.GetFileName(FullName);
            this.mAttachedItem  = attachedItem;
            this.mFilenameStyle = filenameStyle;

            // Build the WorkspaceRelativeName
            this.mWorkspaceRelativeName = nameString;
            string testDirectory = MOG_ControllerProject.GetWorkspaceDirectory().TrimEnd("\\".ToCharArray()) + "\\";

            if (WorkspaceRelativeName.StartsWith(testDirectory, StringComparison.CurrentCultureIgnoreCase))
            {
                WorkspaceRelativeName = WorkspaceRelativeName.Substring(testDirectory.Length);
            }

            // Build the FolderRelativeName
            this.mFolderRelativeName = nameString;
            testDirectory            = relativeFolder.TrimEnd("\\".ToCharArray()) + "\\";
            if (FolderRelativeName.StartsWith(testDirectory, StringComparison.CurrentCultureIgnoreCase))
            {
                FolderRelativeName = FolderRelativeName.Substring(testDirectory.Length);
            }
        }
Example #6
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);
        }
Example #7
0
        string ResolveToken(string token)
        {
            string value = "";

            // Make sure this token starts with the '{'?
            if (token.StartsWith("{"))
            {
                // Get the name of this token
                string[] parts = token.Split("{}.".ToCharArray(), 3);
                // Make sure this resembled a real token?
                if (parts.Length == 3)
                {
                    // Check for any contained commands?
                    string testToken = "{" + parts[1] + "}";
                    // Determine which token we have?
                    switch (testToken)
                    {
                    // Repository Tokens
                    case TOKEN_Repository_Path:
                        value = MOG_ControllerSystem.GetSystemRepositoryPath();
                        break;

                    case TOKEN_Repository_ProjectsPath:
                        value = MOG_ControllerSystem.GetSystemProjectsPath();
                        break;

                    case TOKEN_Repository_ToolsPath:
                        value = MOG_ControllerSystem.GetSystemRepositoryPath() + "\\Tools";
                        break;

                    case TOKEN_Repository_Project_Path:
                        value = MOG_ControllerProject.GetProjectPath();
                        break;

                    case TOKEN_Repository_Project_ToolsPath:
                        value = MOG_ControllerProject.GetProjectPath() + "\\Tools";
                        break;

                    case TOKEN_Repository_Project_AssetsPath:
                        value = MOG_ControllerRepository.GetRepositoryPath();
                        break;

                    case TOKEN_Repository_Project_ArchivePath:
                        value = MOG_ControllerRepository.GetArchivePath();
                        break;

                    case TOKEN_Repository_Project_UsersPath:
                        value = MOG_ControllerProject.GetProjectPath() + "\\Users";
                        break;

                    // Project Tokens
                    case TOKEN_Project_Name:
                        value = MOG_ControllerProject.GetProjectName();
                        break;

                    case TOKEN_Project_BranchName:
                        value = MOG_ControllerProject.GetBranchName();
                        break;

                    case TOKEN_Project_UserName:
                        value = MOG_ControllerProject.GetUserName_DefaultAdmin();
                        break;

                    case TOKEN_Project_PlatformName:
                        value = MOG_ControllerProject.GetPlatformName();
                        break;

                    case TOKEN_Project_WorkspaceDirectory:
                        value = MOG_ControllerProject.GetWorkspaceDirectory();
                        break;

                    // Ripper Tokens
                    case TOKEN_Ripper_SourcePath:
                        value = mRipperSourcePath;
                        break;

                    case TOKEN_Ripper_SourceFilePattern:
                        value = mRipperSourceFilePattern;
                        break;

                    case TOKEN_Ripper_DestinationPath:
                        value = mRipperDestinationPath;
                        break;

                    // Package Tokens
                    case TOKEN_Package_WorkspaceDirectory:
                        if (mPackageFileInfo != null)
                        {
                            value = mPackageFileInfo.mPackageWorkspaceDirectory;
                        }
                        break;

                    case TOKEN_Package_DataDirectory:
                        if (mPackageFileInfo != null)
                        {
                            value = mPackageFileInfo.mPackageDataDirectory;
                        }
                        break;

                    case TOKEN_Package_PackageFile_Filename:
                        if (mPackageFileInfo != null)
                        {
                            value = mPackageFileInfo.mPackageFile;
                        }
                        break;

                    case TOKEN_Package_PackageFile_FullName:
                    {
                        MOG_Filename packageFilename = (mPackageFileInfo != null) ? mPackageFileInfo.mPackageAssetFilename : new MOG_Filename(MOG_ControllerPackage.GetPackageName(mPackageAssignment));
                        value = packageFilename.GetAssetFullName();
                    }
                    break;

                    case TOKEN_Package_PackageFile_Classification:
                    {
                        MOG_Filename packageFilename = (mPackageFileInfo != null) ? mPackageFileInfo.mPackageAssetFilename : new MOG_Filename(MOG_ControllerPackage.GetPackageName(mPackageAssignment));
                        value = packageFilename.GetAssetClassification();
                    }
                    break;

                    case TOKEN_Package_PackageFile_Label:
                    {
                        MOG_Filename packageFilename = (mPackageFileInfo != null) ? mPackageFileInfo.mPackageAssetFilename : new MOG_Filename(MOG_ControllerPackage.GetPackageName(mPackageAssignment));
                        value = packageFilename.GetAssetLabel();
                    }
                    break;

                    case TOKEN_Package_PackageFile_Platform:
                    {
                        MOG_Filename packageFilename = (mPackageFileInfo != null) ? mPackageFileInfo.mPackageAssetFilename : new MOG_Filename(MOG_ControllerPackage.GetPackageName(mPackageAssignment));
                        value = packageFilename.GetAssetPlatform();
                    }
                    break;

                    case TOKEN_Package_PackageFile_Group:
                        value = MOG_ControllerPackage.GetPackageGroups(mPackageAssignment);
                        break;

                    case TOKEN_Package_PackageFile_Object:
                        value = MOG_ControllerPackage.GetPackageObjects(mPackageAssignment);
                        break;

                    // Inbox Tokens
                    case TOKEN_Inbox_UserName:
                        value = mAssetFilename.GetUserName();
                        break;

                    case TOKEN_Inbox_UserPath:
                        value = mAssetFilename.GetUserPath();
                        break;

                    case TOKEN_Inbox_BoxName:
                        value = mAssetFilename.GetBoxName();
                        break;

                    case TOKEN_Inbox_BoxPath:
                        value = mAssetFilename.GetBoxPath();
                        break;

                    // Asset Tokens
                    case TOKEN_Asset_AssetName_Path:
                        value = mAssetFilename.GetPath();
                        break;

                    case TOKEN_Asset_AssetName_FullName:
                        value = mAssetFilename.GetAssetFullName();
                        break;

                    case TOKEN_Asset_AssetName_Classification:
                        value = mAssetFilename.GetAssetClassification();
                        break;

                    case TOKEN_Asset_AssetName_Name:
                        value = mAssetFilename.GetAssetName();
                        break;

                    case TOKEN_Asset_AssetName_PlatformName:
                        value = mAssetFilename.GetAssetPlatform();
                        break;

                    case TOKEN_Asset_AssetName_Label:
                        value = mAssetFilename.GetAssetLabel();
                        break;

                    case TOKEN_Asset_ImportedFile:
                    case TOKEN_Asset_RippedFile:
                        value = ResolveToken_AssetFile(token);
                        break;

                    case TOKEN_Asset_Property:
                        value = ResolveToken_Property(token);
                        break;

                    case TOKEN_Asset_ClassificationPath:
                        value = MOG_Filename.GetClassificationPath(mAssetFilename.GetAssetClassification());
                        break;

                    case TOKEN_Asset_VersionTimeStamp:
                        value = mAssetFilename.GetVersionTimeStamp();
                        break;
                    }

                    // Check if we have a command?
                    if (parts[2] != ".")
                    {
                    }
                }
            }

            return(value);
        }
Example #8
0
        /// <summary>
        /// Update the inboxes with the new command that just came in
        /// </summary>
        /// <param name="command"></param>
        public void RefreshWindowsBoth(MOG_Command command)
        {
            MOG_Filename del = new MOG_Filename(command.GetSource());
            MOG_Filename add = new MOG_Filename(command.GetDestination());

            // We need to strip off the root folder so that we get a more accurate user path
            // Without this change, we got y:\\Projects\Users when we selected a root drive at the repository
            string userPath = MOG_ControllerProject.GetActiveUser().GetUserPath().ToLower();

            // Check if the add is within the inboxes
            if (add.IsWithinInboxes())
            {
                // Check if we are not within the path that is relevant for this user?
                if (!add.IsWithinPath(userPath))
                {
                    // Eat it
                    add.SetFilename("");
                }
            }
            // Check if this is outside our current workspace directory?
            else if (add.IsLocal())
            {
                // Check if we are not within the path that is relevant for this user?
                if (!add.IsWithinPath(MOG_ControllerProject.GetWorkspaceDirectory()))
                {
                    // Eat it
                    add.SetFilename("");
                }
            }

            // Check if the del is within the inboxes
            if (del.IsWithinInboxes())
            {
                // Check if we are not within the path that is relevant for this user?
                if (!del.IsWithinPath(userPath))
                {
                    // Eat it
                    del.SetFilename("");
                }
            }
            // Check if this is outside our current workspace directory?
            else if (del.IsLocal())
            {
                // Check if we are not within the path that is relevant for this user?
                if (!del.IsWithinPath(MOG_ControllerProject.GetWorkspaceDirectory()))
                {
                    // Eat it
                    del.SetFilename("");
                }
            }

            // Determin which one we can test for the asset type?
            MOG_Filename check = (add.GetOriginalFilename().Length != 0) ? add : del;

            switch (check.GetFilenameType())
            {
            case MOG_FILENAME_TYPE.MOG_FILENAME_Group:
            case MOG_FILENAME_TYPE.MOG_FILENAME_Asset:
            case MOG_FILENAME_TYPE.MOG_FILENAME_Link:
                if (mAssets != null)
                {
                    mAssets.RefreshBox(add, del, command);
                }
                break;
            }

            //Application.DoEvents();
        }
Example #9
0
        private static void ImportPrevious_Worker(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker        = sender as BackgroundWorker;
            List <object>    args          = e.Argument as List <object>;
            bool             looseMatching = (bool)args[0];

            string[] sourceFullNames = (args[1]) as string[];

            //string[] sourceFullNames = e.Argument as string[];

            mInvalidAssetNames.Clear();
            mNewAssetNames.Clear();
            mNewAssetProperties.Clear();

            // Check if asset has been previously imported into the system
            for (int i = 0; i < sourceFullNames.Length && !worker.CancellationPending; i++)
            {
                string    sourceFullName      = sourceFullNames[i];
                ArrayList previousSourceFiles = new ArrayList();

                string message = "Importing:\n" +
                                 "     " + Path.GetDirectoryName(sourceFullName) + "\n" +
                                 "     " + Path.GetFileName(sourceFullName);
                worker.ReportProgress(i * 100 / sourceFullNames.Length, message);

                // Check if this is a directory?
                if (DosUtils.DirectoryExistFast(sourceFullName))
                {
                    // Obtain the list of contained files
                    ArrayList containedFiles = DosUtils.FileGetRecursiveList(sourceFullName, "*.*");
                    if (containedFiles != null)
                    {
                        // Map these filenames to all the possible assetnames
                        previousSourceFiles = MOG_ControllerProject.MapFilenamesToAssetNames(containedFiles, MOG_ControllerProject.GetPlatformName(), null);
                    }
                }
                else
                {
                    // Map this filename to all possible assetnames
                    previousSourceFiles = MOG_ControllerProject.MapFilenameToAssetName(sourceFullName, MOG_ControllerProject.GetPlatformName(), MOG_ControllerProject.GetWorkspaceDirectory());
                }

                // Are we loose matching?
                if (looseMatching)
                {
                    // Did we get back only 2 files
                    if (previousSourceFiles.Count == 2)
                    {
                        // Is the second one a blank?
                        MOG_Filename file = previousSourceFiles[1] as MOG_Filename;
                        if (file.GetFullFilename().Length == 0)
                        {
                            // Then remove it!
                            previousSourceFiles.RemoveAt(1);
                        }
                    }
                }

                if (previousSourceFiles.Count == 1)
                {
                    MOG_Filename previousFile = previousSourceFiles[0] as MOG_Filename;

                    if (MogMainForm.MainApp.AssetManagerAutoImportCheckBox.Checked)
                    {
                        // Create the correct controller
                        MOG_ControllerAsset.CreateAsset(sourceFullName, previousFile.GetEncodedFilename(), false);
                    }
                    else
                    {
                        // Create a new invalid name
                        ImportFile invalidName = new ImportFile(sourceFullName);

                        // Add all possible matches to this name
                        foreach (MOG_Filename potentialMatch in previousSourceFiles)
                        {
                            // Make sure we have a valid match?
                            if (potentialMatch != null &&
                                potentialMatch.GetOriginalFilename().Length > 0)
                            {
                                invalidName.mPotentialFileMatches.Add(potentialMatch);
                            }
                        }

                        // Add to our invalidNames array
                        mInvalidAssetNames.Add(invalidName);
                    }
                }
                else
                {
                    // Create a new invalid name
                    ImportFile invalidName = new ImportFile(sourceFullName);

                    // Add all possible matches to this name
                    foreach (MOG_Filename potentialMatch in previousSourceFiles)
                    {
                        // Make sure we have a valid match?
                        if (potentialMatch != null &&
                            potentialMatch.GetOriginalFilename().Length > 0)
                        {
                            invalidName.mPotentialFileMatches.Add(potentialMatch);
                        }
                    }

                    // Add to our invalidNames array
                    mInvalidAssetNames.Add(invalidName);
                }
            }
        }