Esempio n. 1
0
        private void CreateLateResolverItem(MOG_DBPackageCommandInfo packageCommand)
        {
            MOG_Filename assetName = new MOG_Filename(packageCommand.mAssetName);

            if (assetName.GetFilenameType() == MOG_FILENAME_TYPE.MOG_FILENAME_Asset)
            {
                ListViewItem item = new ListViewItem();

                // "NAME, CLASSIFICATION, DATE, TARGET PACKAGE, OWNER, FULLNAME, COMMANDID, LABEL, VERSION"

                item.Text = assetName.GetAssetLabel();
                item.SubItems.Add(assetName.GetAssetClassification());                 // Class
                item.SubItems.Add(MogUtils_StringVersion.VersionToString(packageCommand.mAssetVersion));
                item.SubItems.Add(packageCommand.mPackageName);
                item.SubItems.Add((packageCommand.mBlessedBy.Length != 0) ? packageCommand.mBlessedBy : packageCommand.mCreatedBy);
                item.SubItems.Add(packageCommand.mAssetName);
                item.SubItems.Add(packageCommand.mID.ToString());
                item.SubItems.Add(packageCommand.mLabel);
                item.SubItems.Add(packageCommand.mAssetVersion);

                item.ImageIndex = MogUtil_AssetIcons.GetAssetIconIndex(packageCommand.mAssetName, null, false);

                mainForm.ConnectionManagerLateResolversListView.Items.Add(item);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Make sure this asset is MOG Compliant
        /// </summary>
        private bool CheckName(string filename)
        {
            MOG_Filename assetName;

            try
            {
                assetName = new MOG_Filename(filename);
            }
            catch
            {
                throw new Exception("Unable to convert filename, '" + filename + "' to a valid MOG Filename.");
            }

            // No asset is valid if it has the '[' character
            // Original string == "[]'`,$^:?*<>/\\%#!|="
            // glk:  Kier and I changed this so that ONLY Windows, MOG-Specific, and INI chars are filtered
            if (assetName.GetAssetLabel().Split(ImportFilter_String.ToCharArray()).Length > 1)
            {
                throw new Exception("Non-valid character in import file: \n\n\t " + ImportFilter_String);
            }

            // Make sure the asset name is valid
            if (assetName.GetFilenameType() == MOG_FILENAME_TYPE.MOG_FILENAME_Unknown && MOG_ControllerProject.ValidateAssetFilename(assetName) == false)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Esempio n. 3
0
        /// <summary> SetAssetIcon
        /// Searches through mAssetTypes to find the matching key with
        /// that of the filename.  Then returns the index
        /// </summary>
        /// <param name="filename"></param>
        /// <returns>index of icon in the mAssetTypeImages list</returns>
        static public int GetClassIconIndex(String filename)
        {
            // Construct a filename
            MOG_Filename file = null;

            try
            {
                file = new MOG_Filename(filename);
            }
            catch (Exception e)
            {
                e.ToString();
                return(0);
            }

            string classification;

            switch (file.GetFilenameType())
            {
            case MOG_FILENAME_TYPE.MOG_FILENAME_Asset:
                classification = file.GetAssetClassification();
                break;

            case MOG_FILENAME_TYPE.MOG_FILENAME_Group:
                classification = "group";
                break;

            default:
                classification = filename;
                break;
            }

            // Get the index of the key in the types array
            int x = 0;

            foreach (string classType in mAssetTypes)
            {
                if (string.Compare(classType, classification, true) == 0)
                {
                    break;
                }
                else
                {
                    x++;
                }
            }

            // If the asset was not found, return  for first icon in the list
            if (x >= mAssetTypes.Count)
            {
                return(0);
            }

            // Return the index of the icon
            return(x);
        }         // end ()
Esempio n. 4
0
        /// <summary>
        /// Makes the selected assets the current version in the current branch
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MakeCurrentMenuItem_Click(object sender, System.EventArgs e)
        {
            try
            {
                ArrayList selectedItems  = ControlGetSelectedItems();
                ArrayList assetFilenames = new ArrayList();

                // Scan the list and prepare it for delivery to the DLL
                string message = "";
                foreach (guiAssetTreeTag tag in selectedItems)
                {
                    if (tag.Execute)
                    {
                        MOG_Filename filename = new MOG_Filename(tag.FullFilename);
                        if (filename.GetFilenameType() == MOG_FILENAME_TYPE.MOG_FILENAME_Asset)
                        {
                            assetFilenames.Add(filename);
                        }

                        message = message + filename.GetAssetFullName() + "\n";
                    }
                }

                // Check if this request effects more than 1 asset??
                if (selectedItems.Count > 1)
                {
                    if (MOG_Prompt.PromptResponse("Are you sure you want to make all of these assets the current versions?", message, MOGPromptButtons.OKCancel) != MOGPromptResult.OK)
                    {
                        return;
                    }
                }

                // Stamp all the specified assets
                if (MOG_ControllerProject.MakeAssetCurrentVersion(assetFilenames, "Made current by " + MOG_ControllerProject.GetUserName_DefaultAdmin()))
                {
                    // Check if this request effects more than 1 asset??
                    if (selectedItems.Count > 1)
                    {
                        // Inform the user this may take a while
                        MOG_Prompt.PromptResponse("Completed",
                                                  "This change requires Slave processing.\n" +
                                                  "The project will not reflect these changes until all slaves have finished processing the generated commands.\n" +
                                                  "The progress of this task can be monitored in the Connections Tab.");
                    }
                }
                else
                {
                    MOG_Prompt.PromptMessage("Make Current Failed", "The system was unable to fully complete the task!", Environment.StackTrace);
                }
            }
            catch (Exception ex)
            {
                MOG_Report.ReportMessage("MakeCurrent Exception", ex.Message, ex.StackTrace, MOG.PROMPT.MOG_ALERT_LEVEL.CRITICAL);
            }
        }
Esempio n. 5
0
        /// <summary> SetAssetIcon
        /// Searches through mAssetTypes to find the matching key with
        /// that of the filename.  Then returns the index
        /// </summary>
        /// <param name="filename"></param>
        /// <returns>index of icon in the mAssetTypeImages list</returns>
        static public int GetClassIconIndex(string filename, MOG_Properties properties)
        {
            // Construct a filename
            MOG_Filename file = null;

            try
            {
                file = new MOG_Filename(filename);
            }
            catch (Exception e)
            {
                e.ToString();
                return(0);
            }

            string classification;

            switch (file.GetFilenameType())
            {
            case MOG_FILENAME_TYPE.MOG_FILENAME_Asset:
                classification = file.GetAssetClassification();
                break;

            case MOG_FILENAME_TYPE.MOG_FILENAME_Group:
                classification = "group";
                break;

            default:
                classification = filename;
                break;
            }

            try
            {
                TstDictionaryEntry node = mAssetTypes.Find(classification);
                if (node != null && node.IsKey)
                {
                    return((int)node.Value);
                }
                else
                {
                    if (properties == null)
                    {
                        // If we didn't get anything, we need to load this icon into our array
                        properties = new MOG_Properties(classification);
                    }
                    return(MogUtil_AssetIcons.LoadIcon(properties.ClassIcon, classification));
                }
            }
            catch
            {
                return(0);
            }
        }         // end ()
Esempio n. 6
0
        /// <summary> SetAssetIcon
        /// Searches through mAssetTypes to find the matching key with
        /// that of the filename.  Then returns the index
        /// </summary>
        /// <param name="filename"></param>
        /// <returns>index of icon in the mAssetTypeImages list</returns>
        static public int GetClassIconIndex(string filename, MOG_Properties properties)
        {
            // Construct a filename
            MOG_Filename file = null;

            try
            {
                file = new MOG_Filename(filename);
            }
            catch (Exception e)
            {
                e.ToString();
                return(0);
            }

            string classification;
            string lockName;

            switch (file.GetFilenameType())
            {
            case MOG_FILENAME_TYPE.MOG_FILENAME_Asset:
                classification = file.GetAssetClassification();
                lockName       = file.GetAssetFullName();
                break;

            case MOG_FILENAME_TYPE.MOG_FILENAME_Group:
                classification = "group";
                lockName       = file.GetAssetFullName();
                break;

            default:
                classification = filename;
                lockName       = classification;
                break;
            }

            // Check for locks on this asset
            if (MOG_ControllerProject.IsLocked(lockName))
            {
                // Currently we dont distinguish between read and write locks
                return(GetLockedIcon(lockName, IconType.CLASS, properties));
            }
            else
            {
                return(FindOrAddIcon(ref properties, IconType.CLASS, classification, classification));
            }
        }         // end ()
        protected override void ExpandTreeDown(TreeNode node)
        {
            if (node != null && node.Nodes.Count > 0 && node.Nodes[0].Text == Blank_Node_Text)
            {
                UseWaitCursor = true;
                this.Cursor   = System.Windows.Forms.Cursors.WaitCursor;

                if (IsAtAssetLevel(node) && this.ExpandAssets)
                {
                    // Expand our Asset/Package nodes
                    base.ExpandTreeDown(node);
                }
                else
                {
                    node.Nodes.Clear();

                    if (node.FullPath.IndexOf(PathSeparator) == -1)
                    {
                        // This is our first node, populate platform(s)
                        ExpandSyncTargetPlatforms(node);
                    }
                    else
                    {
                        //This is a platform-specific node...
                        string nodePlatform = GetPlatformNameFromFullPath(node.FullPath);

                        Mog_BaseTag tag = node.Tag as Mog_BaseTag;
                        if (tag != null)
                        {
                            MOG_Filename filename = new MOG_Filename(tag.FullFilename);
                            if (filename.GetFilenameType() == MOG_FILENAME_TYPE.MOG_FILENAME_Asset)
                            {
                                ExpandSyncTargetAssetNode(node, nodePlatform);
                            }
                            else
                            {
                                ExpandSyncTargetSubNodes(node, nodePlatform);
                            }
                        }
                    }
                }
                this.Cursor   = System.Windows.Forms.Cursors.Default;
                UseWaitCursor = false;
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Update populated tree node icons or status based on updated commands from the eventManager
        /// </summary>
        /// <param name="asset"></param>
        public void UpdateAsset(MOG_Command asset)
        {
            // Encapsulate this method in a try-catch
            try
            {
                // Update code for all persistent lock changes
                if (asset.GetCommand() != null && (asset.ToString().ToLower().IndexOf("lock") != -1))
                {
                    MOG_Command  userLock  = asset.GetCommand();
                    MOG_Filename assetName = userLock.GetAssetFilename();

                    string nodeKey = assetName.GetAssetFullName();

                    // Is this a class?
                    if (assetName.GetFilenameType() != MOG_FILENAME_TYPE.MOG_FILENAME_Asset)
                    {
                        nodeKey = assetName.GetOriginalFilename().TrimEnd("*".ToCharArray());
                    }

                    if (mainForm.ProjectManagerClassificationTreeView.IsInitialized)
                    {
                        FindAndUpdateNodeLockStatus(nodeKey, assetName, mainForm.ProjectManagerClassificationTreeView);
                    }
                    if (mainForm.ProjectManagerPackageTreeView.IsInitialized)
                    {
                        FindAndUpdateNodeLockStatus(nodeKey, assetName, mainForm.ProjectManagerPackageTreeView);
                    }
                    if (mainForm.ProjectManagerArchiveTreeView.IsInitialized)
                    {
                        FindAndUpdateNodeLockStatus(nodeKey, assetName, mainForm.ProjectManagerArchiveTreeView);
                    }
                    if (mainForm.ProjectManagerSyncTargetTreeView.IsInitialized)
                    {
                        FindAndUpdateNodeLockStatus(nodeKey, assetName, mainForm.ProjectManagerSyncTargetTreeView);
                    }
                }
            }
            // Catch any .NET-standard errors
            catch (Exception ex)
            {
                // Add MOG_Report stuff here.
                MOG_Report.ReportSilent("UpdateAsset", ex.Message, ex.StackTrace);
            }
        }
Esempio n. 9
0
        static public int GetAssetIconIndex(string filename, MOG_Properties properties, bool bCheckLockedIcons)
        {
            // Construct a filename
            MOG_Filename file = null;

            try
            {
                file = new MOG_Filename(filename);
            }
            catch (Exception e)
            {
                e.ToString();
                return(0);
            }

            string assetName = "default";

            switch (file.GetFilenameType())
            {
            case MOG_FILENAME_TYPE.MOG_FILENAME_Asset:
                assetName = file.GetAssetClassification();
                break;

            case MOG_FILENAME_TYPE.MOG_FILENAME_Group:
                assetName = "group";
                break;

            default:
                assetName = filename;
                break;
            }

            // Check for locks on this asset
            if (bCheckLockedIcons == true &&
                MOG_ControllerProject.IsLocked(file.GetAssetFullName()))
            {
                // Currently we dont distinguish between read and write locks
                return(GetLockedIcon(assetName, IconType.ASSET, properties));
            }
            else
            {
                return(FindOrAddIcon(ref properties, IconType.ASSET, assetName, assetName + "_ASSET"));
            }
        }
Esempio n. 10
0
        static protected void assetTreeViewCreate_AddIndividualNodes(string versionInfoFilename, string name,
                                                                     TreeView tree, TreeNode parent, guiAssetGamedataTreeTag.TREE_FOCUS level, int defaultImageIndex, bool createChildNode)
        {
            // Set the imageIndex for a new TreeNode, create the TreeNode, and create a blank tag for the new node
            TreeNode        node = assetTreeViewCreate_GetTreeNodeWithIcon(name, defaultImageIndex);
            guiAssetTreeTag tag  = null;

            // If `name` already has the project and projectpath, we need to get rid of it.
            string projectPath = MOG_ControllerProject.GetProject().GetProjectPath() + "\\";
            string newName     = name.Replace(projectPath, "");

            // Get the blessed path for this assetname
            MOG_Filename asset = new MOG_Filename(projectPath + newName);

            if (asset.GetFilenameType() == MOG_FILENAME_TYPE.MOG_FILENAME_Asset)
            {
                MOG_Filename fullname = GetAssetFullname(asset, versionInfoFilename);
                tag = new guiAssetGamedataTreeTag(fullname.GetEncodedFilename(), level, true);
            }
            else
            {
                tag = new guiAssetGamedataTreeTag(asset.GetEncodedFilename(), level, false);
            }

            // Save the type of node this is (Key, Class, Group...)
            node.Tag = tag;

            // Don't add an extra child if we are at the end of the chain
            if (/*level != guiAssetGamedataTreeTag.TREE_FOCUS.LABEL ||*/ createChildNode)
            {
                // Add a blank for this keys child
                node.Nodes.Add("");
            }

            // Check if we should add to the base or to a child
            if (parent == null)
            {
                tree.Nodes.Add(node);
            }
            else
            {
                parent.Nodes.Add(node);
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Remove packages from Assets currently selected.  Use CheckForBlessedAssetMessage() before calling.
        /// </summary>
        /// <param name="packagesToRemove">ArrayList of MOG_Property objects for packages to be removed</param>
        private void RemovePackageLinkFromAssets(ArrayList packagesToRemove)
        {
            foreach (ListViewItem item in AssetList.Items)
            {
                MOG_Filename assetFilename = item.Tag as MOG_Filename;
                if (assetFilename != null)
                {
                    // If this asset is not a blessed Asset, and it's not a classification...
                    if (!assetFilename.IsBlessed() && assetFilename.GetFilenameType() != MOG_FILENAME_TYPE.MOG_FILENAME_Unknown)
                    {
                        // Open up this asset so we can remove the package relationships
                        MOG_ControllerAsset asset = MOG_ControllerAsset.OpenAsset(assetFilename);
                        if (asset != null)
                        {
                            // Remove the packages
                            asset.GetProperties().RemovePackages(packagesToRemove);
                            // Depending on how the user clicked, it is possible that an inherited package assignment can be left behind as a non-inherited property
                            // The following code ensures all non-inherited package assignments are flushed by restamping any non-inherited assignemnts.
                            asset.GetProperties().SetProperties(asset.GetProperties().GetNonInheritedPackages());

                            // Make sure we keep the group in sync with our new assignment
                            MOG_ControllerAsset.SetDefaultGroup(asset);

                            // Change the state of the asset to indicate it has been modified
                            MOG_ControllerInbox.UpdateInboxView(asset, MOG_AssetStatusType.Modifying);
                            ModifyingAssets = true;

                            asset.Close();
                        }
                    }
                    else
                    {
                        // We should be looking at a classification, so treat it as such...
                        MOG_Properties properties = MOG_Properties.OpenClassificationProperties(assetFilename.GetOriginalFilename());
                        if (properties != null)
                        {
                            properties.RemovePackages(packagesToRemove);
                            properties.Close();
                        }
                    }
                }
            }
        }
Esempio n. 12
0
        /// <summary>
        /// Open an explorer window in the target of the selected asset(s)
        /// </summary>
        /// <param name="sender"> Must be a ListView and have a string[] in its Tag describing the columns</param>
        /// <param name="e"></param>
        private void RemoveMenuItem_Click(object sender, System.EventArgs e)
        {
            ArrayList selectedItems = ControlGetSelectedItems();

            string message = "";

            foreach (guiAssetTreeTag tag in selectedItems)
            {
                if (tag.Execute)
                {
                    message = message + tag.FullFilename + "\n";
                }
            }

            if (MOG_Prompt.PromptResponse("Are you sure you want to remove all of these assets from the project?", message, MOGPromptButtons.OKCancel) == MOGPromptResult.OK)
            {
                // Obtain a unique bless label
                string jobLabel = "RemoveAsset." + MOG_ControllerSystem.GetComputerName() + "." + MOG_Time.GetVersionTimestamp();

                foreach (guiAssetTreeTag tag in selectedItems)
                {
                    if (tag.Execute)
                    {
                        MOG_Filename filename = new MOG_Filename(tag.FullFilename);

                        // Make sure we are an asset before showing log
                        if (filename.GetFilenameType() == MOG_FILENAME_TYPE.MOG_FILENAME_Asset)
                        {
                            if (guiAssetController.RemoveBlessed(filename, jobLabel))
                            {
                                tag.ItemRemove();
                            }
                        }
                    }
                }

                // Start the job
                MOG_ControllerProject.StartJob(jobLabel);
            }
        }
        /// <summary>
        /// Remove a Package from the PackageManagement Tree.
        ///  Adapted from MogControl_AssetContextMenu.cs::MenuItemRemoveFromProject_Click()
        /// </summary>
        private void RemovePackageFromProject(Mog_BaseTag packageTag)
        {
            try
            {
                string message = "Are you sure you want to remove this package from the game?\r\n" + packageTag.PackageFullName;

                // If user OKs our removal...
                if (MOG_Prompt.PromptResponse("Remove Asset From Project", message, MOGPromptButtons.OKCancel) == MOGPromptResult.OK)
                {
                    if (packageTag.Execute)
                    {
                        MOG_Filename filename = new MOG_Filename(packageTag.FullFilename);

                        // Make sure we are an asset before showing log
                        if (filename.GetFilenameType() == MOG_FILENAME_TYPE.MOG_FILENAME_Asset)
                        {
                            // Proceed to remove this package from the project; skiping the unpackage merge event
                            if (MOG_ControllerProject.RemoveAssetFromProject(filename, "No longer needed", false))
                            {
                                // Go ahead and actually remove the node
                                packageTag.ItemRemove();
                            }
                            else
                            {
                                MOG_Prompt.PromptMessage("Remove Package From Project Failed",
                                                         "The package could not be removed from the project.\n" +
                                                         "PACKAGE: " + filename.GetAssetFullName() + "\n\n" +
                                                         "We are now aborting the remove process.\n", Environment.StackTrace);
                                return;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MOG_Report.ReportMessage("Remove From Project", ex.Message, ex.StackTrace, MOG.PROMPT.MOG_ALERT_LEVEL.CRITICAL);
            }
        }
Esempio n. 14
0
        private void CreatePostItem(MOG_DBPostInfo post)
        {
            MOG_Filename assetName = new MOG_Filename(post.mAssetName);

            if (assetName.GetFilenameType() == MOG_FILENAME_TYPE.MOG_FILENAME_Asset)
            {
                ListViewItem item = new ListViewItem();

                // "NAME, CLASSIFICATION, DATE, OWNER, FULLNAME, COMMANDID"

                item.Text = assetName.GetAssetLabel();
                //item.SubItems.Add(assetName.GetAssetLabel());
                item.SubItems.Add(assetName.GetAssetClassification());
                item.SubItems.Add(MogUtils_StringVersion.VersionToString(post.mAssetVersion));
                item.SubItems.Add(post.mBlessedBy);
                item.SubItems.Add(post.mAssetName);
                item.SubItems.Add(post.mID.ToString());
                item.SubItems.Add(post.mLabel);
                item.SubItems.Add(post.mAssetVersion);
                item.ImageIndex = MogUtil_AssetIcons.GetAssetIconIndex(post.mAssetName, null, false);

                mainForm.ConnectionManagerPostingListView.Items.Add(item);
            }
        }
        /// <summary>
        /// Mother of all ImageIndex getting, not meant to be used outside this class
        /// </summary>
        private int GetImageIndex(string filename, bool searchFileSystem, bool isClassification)
        {
            // If we are a Classification, return our GetClassIconIndex
            if (isClassification)
            {
                return(MogUtil_AssetIcons.GetClassIconIndex(filename));
            }

            int iconIndex = 0;

            // If we need to search the FileSystem, do so...
            if (searchFileSystem)
            {
                iconIndex = MogUtil_AssetIcons.GetFileIconIndex(filename);
                // If we got an iconIndex other than 0, return our value...
                if (iconIndex != 0)
                {
                    return(iconIndex);
                }
                // Else, continue processing
            }

            // Try getting our index through GetAssetIconIndex
            iconIndex = MogUtil_AssetIcons.GetAssetIconIndex(filename);
            // If we got an iconIndex other than 0, return...
            if (iconIndex != 0)
            {
                return(iconIndex);
            }

            // Look for our index using our MOG_Filename and MOG_Properties
            MOG_Filename   realFile   = new MOG_Filename(filename);
            MOG_Properties properties = null;

            // If we have an Asset, get its properties
            if (realFile.GetFilenameType() == MOG_FILENAME_TYPE.MOG_FILENAME_Asset)
            {
                properties = new MOG_Properties(realFile);

                // So long as we got a properties...
                if (properties != null)
                {
                    iconIndex = MogUtil_AssetIcons.GetAssetIconIndex(properties.AssetIcon);
                    // If we have a valid iconIndex, return it
                    if (iconIndex != 0)
                    {
                        return(iconIndex);
                    }
                    // Else if Package, return our default Package icon
                    else if (properties.IsPackage)
                    {
                        return(MogUtil_AssetIcons.GetClassIconIndex(Package_ImageText));
                    }
                    // Else, return our default Asset icon
                    else
                    {
                        return(MogUtil_AssetIcons.GetClassIconIndex(Asset_ImageText));
                    }
                }
            }

            // If after all our work, we still didn't find an icon (and we know we're not a
            //  Classification) throw an exception to the programmer
            if (iconIndex == 0)
            {
                // KLK - There is no need to thow if the icon could not be located.  Just return a bogus icon
                //throw new Exception(ToString() + ": Error with TreeNode.ImageIndex on a non-Classification.\r\n"
                //	+ "ImageIndex should not be 0 for a non-Classification");
            }

            return(iconIndex);
        }
Esempio n. 16
0
        /// <summary>
        /// Refresh an assets status from a ViewUpdate Command
        /// </summary>
        public void RefreshBox(MOG_Filename add, MOG_Filename del, MOG_Command command)
        {
            lock (mAssetManager)
            {
                ListView currentViewAdd = mAssetManager.IsolateListView(add.GetBoxName(), add.GetFilenameType(), add.GetUserName());
                ListView currentViewDel = mAssetManager.IsolateListView(del.GetBoxName(), del.GetFilenameType(), del.GetUserName());

                // Don't continue if we don't have a valid add and del box
                if ((currentViewAdd == null) && (currentViewDel == null))
                {
                    return;
                }

                // Begin the update
                if (currentViewAdd != null)
                {
                    currentViewAdd.BeginUpdate();
                }
                if (currentViewDel != null)
                {
                    currentViewDel.BeginUpdate();
                }

                string status = command.GetDescription();

                mAssetManager.mainForm.mSoundManager.PlayStatusSound("AssetEvents", status);

                try
                {
                    // Obtain the properties from the command
                    MOG_Properties pProperties  = null;
                    string[]       commandProps = command.GetVeriables().Split("$".ToCharArray());
                    if (commandProps != null)
                    {
                        ArrayList realProps = new ArrayList();

                        // Convert the commandProps into a list of real Properties
                        for (int i = 0; i < commandProps.Length; i++)
                        {
                            // Confirm this appears to be a valid prop?
                            if (commandProps[i].StartsWith("["))
                            {
                                MOG_Property commandProp = new MOG_Property(commandProps[i]);

                                // Make sure the property was initialized correctly?
                                if (commandProp.mSection.Length > 0 &&
                                    commandProp.mKey.Length > 0)
                                {
                                    // Add this realProp
                                    realProps.Add(commandProp);
                                }
                            }
                        }

                        // Construct the pProperties from the realProps
                        pProperties = new MOG_Properties(realProps);

                        // If we have a valid gameDataController, set our platform scope
                        if (MOG_ControllerProject.GetCurrentSyncDataController() != null)
                        {
                            pProperties.SetScope(MOG_ControllerProject.GetCurrentSyncDataController().GetPlatformName());
                        }
                    }

                    // Check if we are just updating an item in the same list?
                    if (currentViewAdd == currentViewDel)
                    {
                        // Check to see if this item already exists?
                        int targetIndex = mAssetManager.ListViewItemFindFullItem(del, currentViewDel);
                        int sourceIndex = mAssetManager.ListViewItemFindFullItem(add, currentViewAdd);
                        if (sourceIndex != -1)
                        {
                            // Update the existing item
                            ListViewItem item = currentViewAdd.Items[sourceIndex];
                            guiAssetManager.UpdateListViewItem(item, add, status, pProperties);

                            // If there was also a target index, we need to delete it because the source became the target.
                            if (targetIndex != -1 &&
                                targetIndex != sourceIndex)
                            {
                                ListViewItem removeItem = currentViewAdd.Items[targetIndex];

                                // Make sure to clear our stateImage index which will clear the checked state before we attempt to remove the node or we will throw
                                removeItem.StateImageIndex = 0;

                                currentViewAdd.Items.Remove(removeItem);
                            }
                        }
                        // Special case when we are dealing with a renamed file
                        else if (targetIndex != -1 && sourceIndex == -1)
                        {
                            // Get the old item
                            ListViewItem item = currentViewDel.Items[targetIndex];

                            // Update it to the new renamed item
                            guiAssetManager.UpdateListViewItem(item, add, status, pProperties);
                        }
                        else
                        {
                            // Add a new item
                            CreateListViewItem(currentViewAdd, add, status, pProperties);
                            // Make sure we always keep our tab's text up-to-date
                            mAssetManager.UpdateAssetManagerTabText(add);
                        }
                    }
                    else
                    {
                        // Looks like we may need to do both the add and the remove
                        // Check if we have the currentViewDel?
                        if (currentViewDel != null)
                        {
                            int index = mAssetManager.ListViewItemFindFullItem(del, currentViewDel);
                            if (index != -1)
                            {
                                ListViewItem item = currentViewDel.Items[index];

                                // Make sure to clear our stateImage index which will clear the checked state before we attempt to remove the node or we will throw
                                item.StateImageIndex = 0;

                                // Remove the item from the list
                                currentViewDel.Items.Remove(item);

                                // Make sure we always keep our tab's text up-to-date
                                mAssetManager.UpdateAssetManagerTabText(del);
                            }
                        }

                        // Check if we have the currentViewAdd?
                        if (currentViewAdd != null)
                        {
                            // Check to see if this item already exists?
                            int sourceIndex = mAssetManager.ListViewItemFindFullItem(add, currentViewAdd);
                            if (sourceIndex != -1)
                            {
                                // Update the existing item
                                ListViewItem item = currentViewAdd.Items[sourceIndex];
                                guiAssetManager.UpdateListViewItem(item, add, status, pProperties);
                            }
                            else
                            {
                                // Add a new item
                                CreateListViewItem(currentViewAdd, add, status, pProperties);
                                // Make sure we always keep our tab's text up-to-date
                                mAssetManager.UpdateAssetManagerTabText(add);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MOG_Report.ReportSilent("RefreshBox", ex.Message, ex.StackTrace);
                }

                // End the update
                if (currentViewAdd != null)
                {
                    currentViewAdd.EndUpdate();
                }
                if (currentViewDel != null)
                {
                    currentViewDel.EndUpdate();
                }
            }
        }
Esempio n. 17
0
        private void DialogInitialize_Worker(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker      = sender as BackgroundWorker;
            List <Object>    args        = e.Argument as List <Object>;
            string           parentPath  = args[0] as string;
            ArrayList        assets      = args[1] as ArrayList;
            ArrayList        assetLabels = args[2] as ArrayList;
            TreeNode         parentNode  = null;

            for (int counter = 0; counter < assets.Count; counter++)
            {
                string rawString   = assets[counter] as string;
                string labelString = (assetLabels != null) ? assetLabels[counter] as string : "";

                worker.ReportProgress(counter * 100 / assets.Count);

                // Determin if we should use the label or the str
                string displayString = (labelString.Length > 0) ? labelString : rawString;

                // Check if this is an official MOG_Filename? and
                // Make sure it contains no path!
                MOG_Filename filename = new MOG_Filename(displayString);
                if (filename.GetFilenameType() != MOG_FILENAME_TYPE.MOG_FILENAME_Unknown &&
                    filename.GetPath().Length == 0)
                {
                    if (ConfirmTreeView.ImageList != MogUtil_AssetIcons.Images)
                    {
                        ConfirmTreeView.ImageList = MogUtil_AssetIcons.Images;
                    }

                    // Build the node
                    BuildMogFilenameNode(filename, rawString, labelString);
                }
                // Check if this resembles a path?
                else if (displayString.Contains("\\"))
                {
                    // Is this the first node?
                    if (ConfirmTreeView.Nodes.Count == 0)
                    {
                        // Check if we are missing a parentPath?
                        if (parentPath.Length == 0)
                        {
                            // Use the root of the file as our parentPath
                            parentPath = displayString.Substring(0, displayString.IndexOf("\\"));
                        }

                        // Create the start node
                        parentNode         = ConfirmTreeView.Nodes.Add(parentPath);
                        parentNode.Checked = true;

                        try
                        {
                            // Select file icon
                            parentNode.ImageIndex = MogUtil_AssetIcons.GetFileIconIndex(parentNode.FullPath);
                        }
                        catch (Exception ex)
                        {
                            ex.ToString();
                        }
                    }

                    // Figure out what...if any...remainingPath
                    string remainingPath = "";
                    if (displayString.StartsWith(parentPath, StringComparison.CurrentCultureIgnoreCase))
                    {
                        remainingPath = displayString.Substring(parentPath.Length).Trim("\\".ToCharArray());
                    }

                    // Build the Node path
                    BuildWindowsFileNode(parentNode, remainingPath, rawString);
                }
                else
                {
                    // Check if we have a parentNode?
                    if (parentNode != null)
                    {
                        // Just add the basic node
                        TreeNode thisNode = new TreeNode(displayString);
                        thisNode.Checked = true;
                        parentNode.Nodes.Add(thisNode);
                    }
                }
            }
        }
Esempio n. 18
0
        private bool AddPackageLinkToAssets(string packageName, Color color, bool markAsInherited, bool setPackageProperties)
        {
            bool success = true;

            ListViewItem item = FindAssignmentListItem(packageName);

            if (item == null)
            {
                item           = new ListViewItem(packageName);
                item.ForeColor = color;
                AssignmentList.Items.Add(item);

                if (setPackageProperties)
                {
                    success = false;

                    ArrayList PackageAssignmentProps = new ArrayList();
                    PackageAssignmentProps.Add(CreatePackageAssignmentProperty(packageName));

                    // Go through our listview items again to Add or Remove assets we found in the previous foreach loop
                    foreach (ListViewItem assetItem in AssetList.Items)
                    {
                        MOG_Filename assetFilename = assetItem.Tag as MOG_Filename;
                        if (assetFilename != null &&
                            assetFilename.GetFilenameType() == MOG_FILENAME_TYPE.MOG_FILENAME_Asset)
                        {
                            // If this asset is not a blessed Asset, and it's not a classification...
                            if (!assetFilename.IsBlessed())
                            {
                                MOG_ControllerAsset asset = MOG_ControllerAsset.OpenAsset(assetFilename);
                                if (asset != null)
                                {
                                    if (asset.GetProperties().AddPackages(PackageAssignmentProps))
                                    {
                                        success = true;

                                        // Make sure we keep the group in sync with our new assignment
                                        MOG_ControllerAsset.SetDefaultGroup(asset);

                                        // Change the state of the asset to indicate it has been modified
                                        MOG_ControllerInbox.UpdateInboxView(asset, MOG_AssetStatusType.Modifying);
                                        ModifyingAssets = true;
                                    }

                                    asset.Close();
                                }
                            }
                            else
                            {
                                MOG_Prompt.PromptMessage("Cannot add PackageAssignments to Blessed Assets",
                                                         "Please copy the Asset to your Inbox and change its package assignments from there so it can be properly processed and re-Blessed.",
                                                         "",
                                                         MOG.PROMPT.MOG_ALERT_LEVEL.ALERT);
                            }
                        }
                        else if (assetFilename.GetFilenameType() == MOG_FILENAME_TYPE.MOG_FILENAME_Unknown)
                        {
                            // We should be looking at a classification, so treat it as such...
                            MOG_Properties properties = MOG_Properties.OpenClassificationProperties(assetFilename.GetOriginalFilename());
                            if (properties != null)
                            {
                                if (properties.AddPackages(PackageAssignmentProps))
                                {
                                    success = true;
                                }
                                properties.Close();
                            }
                        }
                    }
                }
            }

            if (item != null && markAsInherited)
            {
                item.Font = new Font(AssignmentList.Font, FontStyle.Italic);
            }

            if (!success)
            {
                MOG_Report.ReportMessage("Error Adding Package Assignment", "Failed to add package assignment!", Environment.StackTrace, MOG_ALERT_LEVEL.ERROR);
            }

            return(success);
        }
Esempio n. 19
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();
        }
Esempio n. 20
0
        public void MogControl_LibraryTreeView_DragDrop(object sender, DragEventArgs args)
        {
            if (this.dragOverNode != null)
            {
                // Restore node's original colors
                this.dragOverNode.BackColor = SystemColors.Window;
                this.dragOverNode.ForeColor = SystemColors.ControlText;
            }

            // Get node we want to drop at
            TreeNode targetNode = this.GetNodeAt(this.PointToClient(new Point(args.X, args.Y)));

            // and select it so it'll show up in the ListView
            this.SelectedNode = targetNode;

            if (args.Data.GetDataPresent("FileDrop"))
            {
                // Extract the filenames and import
                string[] filenames = (string[])args.Data.GetData("FileDrop", false);
                if (filenames != null && filenames.Length > 0)
                {
                    bool bCopyFiles    = true;
                    bool bAutoAddFiles = false;
                    bool bPromptUser   = false;
                    bool bCancel       = false;

                    // Check if thes files are coming from the same spot?
                    string classification     = targetNode.FullPath;
                    string classificationPath = MOG_ControllerLibrary.ConstructPathFromLibraryClassification(classification);
                    // Get the common directory scope of the items
                    ArrayList items    = new ArrayList(filenames);
                    string    rootPath = MOG_ControllerAsset.GetCommonDirectoryPath("", items);
                    if (rootPath.StartsWith(classificationPath))
                    {
                        bCopyFiles = false;
                    }

                    // Check if auto import is checked?
                    if (this.LibraryExplorer.IsAutoImportChecked())
                    {
                        // Automatically add the file on the server
                        bAutoAddFiles = true;
                        bPromptUser   = true;

                        // Check if these files are already within the library?
                        if (MOG_ControllerLibrary.IsPathWithinLibrary(rootPath))
                        {
                            // Ignore what the user specified and rely on the classification generated from the filenames
                            classification = "";
                            bPromptUser    = false;
                            bCopyFiles     = false;
                        }
                    }

                    // Promt the user for confirmation before we import these files
                    if (bPromptUser)
                    {
                        // Prompt the user and allow them to cancel
                        if (LibraryFileImporter.PromptUserForConfirmation(filenames, classification) == false)
                        {
                            bCancel = true;
                        }
                    }

                    // Make sure we haven't canceled
                    if (!bCancel)
                    {
                        if (bCopyFiles)
                        {
                            // Import the files
                            List <object> arguments = new List <object>();
                            arguments.Add(filenames);
                            arguments.Add(classification);
                            ProgressDialog progress = new ProgressDialog("Copying Files", "Please wait while the files are copied", LibraryFileImporter.CopyFiles, arguments, true);
                            progress.ShowDialog();
                        }
                    }

                    // Make sure we haven't canceled
                    if (!bCancel)
                    {
                        if (bAutoAddFiles)
                        {
                            // Import the files
                            List <object> arguments = new List <object>();
                            arguments.Add(filenames);
                            arguments.Add(classification);
                            ProgressDialog progress = new ProgressDialog("Copying Files", "Please wait while the files are copied", LibraryFileImporter.ImportFiles, arguments, true);
                            progress.ShowDialog();
                        }
                    }

                    // Refresh view
                    DeInitialize();
                    Initialize();
                }
            }
            else if (args.Data.GetDataPresent("LibraryListItems"))
            {
                ArrayList items = args.Data.GetData("LibraryListItems") as ArrayList;

                foreach (string item in items)
                {
                    // Move library asset here
                    MOG_Filename assetName = new MOG_Filename(item);
                    // Check if this was an asset?
                    if (assetName.GetFilenameType() == MOG_FILENAME_TYPE.MOG_FILENAME_Asset)
                    {
                        bool success = MOG_ControllerProject.GetProject().AssetRename(assetName.GetAssetFullName(), SelectedNode.FullPath + assetName.GetAssetName());
                        // Make sure we unsync this asset just in case it had already been synced
                        MOG_ControllerLibrary.Unsync(assetName);
                    }
                    // Check if this was a file?
                    else if (DosUtils.FileExistFast(item))
                    {
                        string dstPath   = MOG_ControllerLibrary.ConstructPathFromLibraryClassification(SelectedNode.FullPath);
                        string dstTarget = Path.Combine(dstPath, Path.GetFileName(item));
                        DosUtils.FileMoveFast(item, dstTarget, true);
                    }
                }
            }
            else if (args.Data.GetDataPresent("LibraryTreeNode"))
            {
                string classification = args.Data.GetData("LibraryTreeNode") as string;

                if (classification != null && classification.Length > 0)
                {
                    //Move classification here
                    string[] parts = classification.Split("~".ToCharArray());
                    if (parts.Length > 0)
                    {
                        string lastPart = parts[parts.Length - 1];

                        bool success = MOG_ControllerProject.GetProject().ClassificationRename(classification, SelectedNode.FullPath + "~" + lastPart);
                    }
                    else
                    {
                        MOG_Prompt.PromptResponse("Cannot move classification", "MOG was unable to move the classification", Environment.StackTrace, MOGPromptButtons.OK);
                    }
                }
            }
        }
Esempio n. 21
0
        private static void UpdateLocalProgress_Worker(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            int autoCount = 0;
            int userCount = 0;

            // Suspend the auto packaging
            WorkspaceManager.SuspendPackaging(true);

            // Begin this GetLatest
            WorkspaceManager.ModifyLocalWorkspace_Begin();

            while (true)
            {
                MOG_Filename filename      = new MOG_Filename();
                bool         userInitiated = false;

                lock (mAutoUpdateQueue)
                {
                    // See if there are any auto update items needing to be processed?
                    if (mAutoUpdateQueue.Count > 0)
                    {
                        filename = mAutoUpdateQueue.Dequeue();
                        autoCount++;
                    }
                    // See if there are any user initiated items needing to be processed?
                    else if (mUserUpdateQueue.Count > 0)
                    {
                        filename = mUserUpdateQueue.Dequeue();
                        userCount++;
                        userInitiated = true;
                    }
                }

                // Recalulate total within this loop because it can be changing outside of us in another thread...
                int    total   = (mAutoUpdateQueue.Count + autoCount) + (mUserUpdateQueue.Count + userCount);
                string message = "Updating:\n" +
                                 "     " + filename.GetAssetClassification() + "\n" +
                                 "     " + filename.GetAssetName();
                worker.ReportProgress((autoCount + userCount) * 100 / total, message);

                // Only allow updates of valid assets
                if (filename.GetFilenameType() == MOG_FILENAME_TYPE.MOG_FILENAME_Asset ||
                    filename.GetFilenameType() == MOG_FILENAME_TYPE.MOG_FILENAME_Group)
                {
                    // Add this asset to all of our active workspaces
                    WorkspaceManager.AddAssetToWorkspaces(filename, userInitiated, worker);
                }

                lock (mUpdateQueueLock)
                {
                    if (mAutoUpdateQueue.Count == 0 &&
                        mUserUpdateQueue.Count == 0)
                    {
                        mAutoUpdateQueue = null;
                        mUserUpdateQueue = null;
                        break;
                    }

                    // Check if the user canceled things?
                    if (worker.CancellationPending)
                    {
                        mAutoUpdateQueue = null;
                        mUserUpdateQueue = null;
                        break;
                    }
                }
            }

            // Restore the auto packaging
            WorkspaceManager.SuspendPackaging(false);

            // End this GetLatest
            WorkspaceManager.ModifyLocalWorkspace_Complete();
        }