Esempio n. 1
0
        static private int LoadIcon(string imageFileName, string assetClassName)
        {
            try
            {
                if (imageFileName != null && imageFileName.Length > 0)
                {
                    // Load the icon specified by the Icon= key
                    string iconName = imageFileName;

                    // Make sure this is a full path, if not append the tools directory to it?
                    iconName = MOG_ControllerSystem.LocateTool(imageFileName);

                    // Make sure that the icon file exists
                    if (iconName.Length > 0 && DosUtils.FileExist(iconName))
                    {
                        // Get the image
                        Image image = new Bitmap(iconName);

                        return(InternalAddIconToLists(assetClassName, iconName, image));
                    }
                }
            }
            catch (Exception e)
            {
                MOG_Report.ReportSilent("Load Icon", e.Message, e.StackTrace, MOG_ALERT_LEVEL.CRITICAL);
            }

            return(0);
        }
Esempio n. 2
0
        private void MogProcess()
        {
            // Loop until we shutdown
            while (!MOG_Main.IsShutdown())
            {
                // Only process while we are not shutting down?
                if (!MOG_Main.IsShutdownInProgress())
                {
                    try
                    {
                        MOG_Main.Process();
                    }
                    catch (Exception ex)
                    {
                        MOG_Report.ReportSilent("MogProcess", ex.Message, ex.StackTrace, MOG_ALERT_LEVEL.CRITICAL);
                    }
                }

                Thread.Sleep(1);
            }

            // Inform our parent thread that we have exited
            mMogProcess = null;

            // Gracefully wait a while to see if our parent thread will terminate the application for us?
            Thread.Sleep(500);
            // At this point, let's take the inititive and shut ourselves down
            Application.Exit();
        }
		private void AttachValidatedTagToNewObjectOrGroup(TreeNode package, TreeNode newNode, PackageNodeTypes nodeType)
		{
			// If this thing is a Group or Object, we need to do this algorithm
			string fullFilename = null;
			MOG_Filename assetFile = null;

			int imageIndex = 0;

			switch (nodeType)
			{
			case PackageNodeTypes.Group:
				imageIndex = MogUtil_AssetIcons.GetClassIconIndex(PackageGroup_ImageText);
				break;
			case PackageNodeTypes.Object:
				imageIndex = MogUtil_AssetIcons.GetClassIconIndex(PackageObject_ImageText);
				break;
			default:
				MOG_Report.ReportSilent("Got Unexpected PackageNodeTypes",
					"Unexpected PackageNodeTypes enum given for MOG_ControlsLibrary.Controls",
					Environment.StackTrace);
				break;
			}

			string groupPath = newNode.FullPath.Substring(package.FullPath.Length).Trim(PathSeparator.ToCharArray()).Replace(PathSeparator, "/");
			fullFilename = package.FullPath + "/" + groupPath;
			assetFile = new MOG_Filename(((Mog_BaseTag)package.Tag).FullFilename);

			// Now that we've got our initial information, add our tag
			newNode.Tag = new Mog_BaseTag(newNode, assetFile.GetEncodedFilename(), this.FocusForAssetNodes, true);
			((Mog_BaseTag)newNode.Tag).PackageNodeType = nodeType;
			((Mog_BaseTag)newNode.Tag).PackageFullName = fullFilename;
			SetImageIndices(newNode, imageIndex);
		}
Esempio n. 4
0
        static public void MOGGlobalViewRefresh(MogMainForm mainForm, string tabName)
        {
            switch (tabName)
            {
            case "MainTabStartupTabPage":
                mainForm.MOGWelcomeWebBrowser.Refresh();
                break;

            case "MainTabProjectManagerTabPage":
                mainForm.mProjectManager.BuildRepositoryTrees(true);
                //mainForm.ProjectManagerTaskWindow.InitializeForProject();
                break;

            case "MainTabAssetManagerTabPage":
                mainForm.RefreshClientAssetWindow();
                mainForm.mAssetManager.mLocal.RefreshWindow();
                //mainForm.AssetManagerTaskWindow.InitializeForUser();
                break;

            case "MainTabConnectionManagerTabPage":
                if (connectionRefreshTimer == null)                        //mainForm.AllowConnectionsRefresh)
                {
                    mainForm.mConnectionManager.Refresh();
                    connectionRefreshTimer          = new System.Windows.Forms.Timer();
                    connectionRefreshTimer.Interval = 1000;
                    connectionRefreshTimer.Tick    += new EventHandler(connectionRefreshTimer_Tick);
                    connectionRefreshTimer.Start();
                }
                break;

            case "MainTabLockManagerTabPage":
                if (mainForm.mLockManager != null)
                {
                    mainForm.mLockManager.Initialize();
                }
                break;

            case "MainTabLibraryTabPage":
                if (mainForm.mLibraryManager != null)
                {
                    mainForm.mLibraryManager.Refresh();
                }

                break;

            default:
                MOG_Report.ReportSilent("Error In MOG_Client.Client_Mog_Utilities.MainMenuViewClass.MOGGlobalViewRefresh",
                                        "Error finding tab page to refresh: \r\n\r\n"
                                        + mainForm.MOGTabControl.SelectedTab.Name, Environment.StackTrace);
                break;
            }
        }
Esempio n. 5
0
        private System.Drawing.Bitmap SetIcon(string filename)
        {
            try
            {
                return(new System.Drawing.Bitmap(MOG_ControllerSystem.LocateTool("\\Images\\States", filename)));
            }
            catch (Exception e1)
            {
                MOG_Report.ReportSilent("Initialize state icon", "Icon:\n" + "\\Images\\States\\" + filename +
                                        "\nCould not be loaded\n\n" + e1.Message, e1.StackTrace, MOG_ALERT_LEVEL.ERROR);

                return(null);
            }
        }
Esempio n. 6
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. 7
0
        static public int GetLockedBinaryIcon(string filename)
        {
            try
            {
                // Check to see if we can find this loced icon in our cache
                TstDictionaryEntry assetLocked = mAssetTypes.Find(Path.GetFileName(filename) + "_locked");
                if (assetLocked != null && assetLocked.IsKey)
                {
                    // Yup, return the index
                    return((int)assetLocked.Value);
                }
                else
                {
                    // Nope, We are going to have to create it

                    // Setup some new containers
                    Bitmap newLockedIcon   = null;
                    Bitmap lockIconSource  = null;
                    Bitmap assetIconSource = null;


                    // Can we find the locked image
                    TstDictionaryEntry nodeLocked = mAssetTypes.Find("locked");
                    if (nodeLocked != null && nodeLocked.IsKey)
                    {
                        // Great, get a copy of that
                        lockIconSource = (Bitmap)mAssetTypeImages.Images[(int)nodeLocked.Value];

                        // Now try and get the icon of this asset
                        // Have we seen this type of asset by its extension?
                        if (mFileTypeManager.ExtensionListHasKey(filename))
                        {
                            // Great get a copy of that
                            assetIconSource = (Bitmap)mFileTypeManager.GetImage(filename);
                        }
                        else
                        {
                            // No, ok try and add it from the file its self
                            if (File.Exists(filename))
                            {
                                mFileTypeManager.AddFileIcon(filename);
                                assetIconSource = (Bitmap)mFileTypeManager.GetImage(filename);
                            }
                            else
                            {
                                // Use the default icon
                                assetIconSource = (Bitmap)mAssetTypeImages.Images[0];
                            }
                        }

                        // Ok, if we got a lockSource and a class source icon, lets attempt to overlay them
                        if (assetIconSource != null && lockIconSource != null)
                        {
                            newLockedIcon = BitmapManipulator.OverlayBitmap(assetIconSource, lockIconSource, 100, BitmapManipulator.ImageCornerEnum.BottomRight);
                        }

                        // Did the overlay work?
                        if (newLockedIcon != null)
                        {
                            // Add the image and the type to the arrayLists
                            string iconName = Path.GetFileName(filename) + "_locked";
                            return(InternalAddIconToLists(iconName, newLockedIcon));
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MOG_Report.ReportSilent("Get Locked Binary Icon", e.Message, e.StackTrace, MOG_ALERT_LEVEL.CRITICAL);
            }

            return(0);
        }
Esempio n. 8
0
        static public int GetLockedAssetIcon(MOG_Filename file)
        {
            try
            {
                // Check to see if we can find this loced icon in our cache
                TstDictionaryEntry assetLocked = mAssetTypes.Find(file.GetAssetClassification() + "ASSETICON_locked");
                if (assetLocked != null)
                {
                    // Yup, return the index
                    return((int)assetLocked.Value);
                }
                else
                {
                    // Nope, We are going to have to create it

                    // Setup some new containers
                    Bitmap myImage    = null;
                    Bitmap lockSource = null;
                    Bitmap source     = null;

                    // Can we find the locked image
                    TstDictionaryEntry nodeLocked = mAssetTypes.Find("locked");
                    if (nodeLocked != null && nodeLocked.IsKey)
                    {
                        // Great, get a copy of that
                        lockSource = (Bitmap)mAssetTypeImages.Images[(int)nodeLocked.Value];

                        // Can we find the class icon for this asset
                        TstDictionaryEntry nodeSource = mAssetTypes.Find(file.GetAssetClassification() + "_ASSET");
                        if (nodeSource != null && nodeSource.IsKey)
                        {
                            // Great get a copy of that
                            source = (Bitmap)mAssetTypeImages.Images[(int)nodeSource.Value];
                        }
                        else
                        {
                            // If we didn't get anything, we need to load this icon into our array
                            MOG_Properties properties = new MOG_Properties(file.GetAssetClassification());
                            source = (Bitmap)mAssetTypeImages.Images[LoadIcon(properties.AssetIcon, file.GetAssetClassification() + "_ASSET")];
                        }

                        // Ok, if we got a lockSource and a class source icon, lets attempt to overlay them
                        if (source != null && lockSource != null)
                        {
                            myImage = BitmapManipulator.OverlayBitmap(source, lockSource, 100, BitmapManipulator.ImageCornerEnum.BottomRight);
                        }

                        // Did the overlay work?
                        if (myImage != null)
                        {
                            // Add the image and the type to the arrayLists
                            string iconName = file.GetAssetClassification() + "ASSETICON_locked";
                            return(InternalAddIconToLists(iconName, myImage));
                        }
                    }
                    else
                    {
                        // Try to just turn the source icon red or something
                        string message = "We could not locate the (FileLocked.png)lock icon! Make sure that it is located in one of your images directories within the MOG repository!";
                        MOG_Report.ReportSilent("Load Icon", message, "No StackTrace available", MOG_ALERT_LEVEL.ERROR);
                    }
                }
            }
            catch (Exception e)
            {
                MOG_Report.ReportSilent("Get Locked Icon", e.Message, e.StackTrace, MOG_ALERT_LEVEL.CRITICAL);
            }

            return(0);
        }
Esempio n. 9
0
        }         // end ()

        static public int GetLockedIcon(string assetName, IconType iconType, MOG_Properties properties)
        {
            try
            {
                // Check to see if we can find this loced icon in our cache
                string             lockedIconKeyName = assetName + "_" + iconType.ToString() + "_locked";
                TstDictionaryEntry assetLocked       = mAssetTypes.Find(lockedIconKeyName);
                if (assetLocked != null)
                {
                    // Yup, return the index
                    return((int)assetLocked.Value);
                }
                else
                {
                    // *******************************************
                    // Nope, We are going to have to create it
                    // *******************************************
                    // We need 3 things:
                    // 1) Lock icon
                    // 2) Asset or class icon
                    // 3) New overlayed icon

                    // Setup some new containers
                    Bitmap myImage    = null;
                    Bitmap lockSource = null;
                    Bitmap source     = null;

                    // 1) Can we find the locked image
                    TstDictionaryEntry nodeLocked = mAssetTypes.Find("locked");
                    if (nodeLocked != null && nodeLocked.IsKey)
                    {
                        // Great, get a copy of that
                        lockSource = (Bitmap)mAssetTypeImages.Images[(int)nodeLocked.Value];

                        // Do we have a valid properties object?
                        if (properties == null)
                        {
                            // If we didn't get anything, we need to load this icon into our array
                            properties = new MOG_Properties(assetName);
                        }

                        // Lets now populate our icon name to load
                        string assetIconName = "";
                        string nodeIconName  = "";

                        // What kind of icon is this?
                        switch (iconType)
                        {
                        case IconType.ASSET:
                            assetIconName = properties.AssetIcon;
                            nodeIconName  = assetName + "_ASSET";
                            break;

                        case IconType.CLASS:
                            assetIconName = properties.ClassIcon;
                            nodeIconName  = assetName + "_CLASS";
                            break;

                        default:
                            return(0);
                        }

                        // 2) Can we find the class icon for this asset
                        TstDictionaryEntry nodeSource = mAssetTypes.Find(nodeIconName);
                        if (nodeSource != null && nodeSource.IsKey)
                        {
                            // Great get a copy of that
                            source = (Bitmap)mAssetTypeImages.Images[(int)nodeSource.Value];
                        }
                        else
                        {
                            // If we didn't get anything, we need to load this icon into our array
                            int newIconIndex = LoadIcon(assetIconName, nodeIconName);
                            source = (Bitmap)mAssetTypeImages.Images[newIconIndex];
                        }

                        // 3) Ok, if we got a lockSource and a class source icon, lets attempt to overlay them
                        if (source != null && lockSource != null)
                        {
                            myImage = BitmapManipulator.OverlayBitmap(source, lockSource, 100, BitmapManipulator.ImageCornerEnum.BottomRight);
                        }

                        // Did the overlay work?
                        if (myImage != null)
                        {
                            //Debug.WriteLine("Requesting icon - " + lockedIconKeyName);
                            return(InternalAddIconToLists(lockedIconKeyName, myImage));
                        }
                    }
                    else
                    {
                        // Try to just turn the source icon red or something
                        string message = "We could not locate the (FileLocked.png)lock icon! Make sure that it is located in one of your images directories within the MOG repository!";
                        MOG_Report.ReportSilent("Load Icon", message, Environment.StackTrace, MOG_ALERT_LEVEL.ERROR);
                    }
                }
            }
            catch (Exception e)
            {
                MOG_Report.ReportSilent("Get Locked Icon", e.Message, e.StackTrace, MOG_ALERT_LEVEL.CRITICAL);
            }

            return(0);
        }
Esempio n. 10
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();
                }
            }
        }