コード例 #1
0
 private void FindAndUpdateNodeLockStatus(string nodeKey, MOG_Filename assetName, MogControl_BaseTreeView tree)
 {
     // Attempt to find this node in our tree
     TreeNode[] foundNodes = tree.Nodes.Find(nodeKey, true);
     if (foundNodes != null && foundNodes.Length > 0)
     {
         foreach (TreeNode node in foundNodes)
         {
             Mog_BaseTag tag = node.Tag as Mog_BaseTag;
             if (tag != null)
             {
                 // Is this a sync target node
                 if (tag.AttachedSyncTargetInfo != null)
                 {
                     // Update this assets status
                     string assetRepositoryName = tag.FullFilename + "\\Files.Imported\\" + tag.AttachedSyncTargetInfo.FilenameOnly;
                     node.ImageIndex         = MogUtil_AssetIcons.GetBinaryLockedOrUnlockedIcon(assetName.GetAssetFullName(), assetRepositoryName);
                     node.SelectedImageIndex = node.ImageIndex;
                 }
                 else
                 {
                     // Update this assets status
                     node.ImageIndex         = MogUtil_AssetIcons.GetAssetIconIndex(assetName.GetAssetFullName());
                     node.SelectedImageIndex = node.ImageIndex;
                 }
             }
         }
     }
 }
コード例 #2
0
ファイル: PackageCreator.cs プロジェクト: MOGwareSupport/MOG
        private void AddFolder_Click(object sender, EventArgs e)
        {
            ToolStripItem item = sender as ToolStripItem;

            if (item != null)
            {
                ContextMenuStrip strip = item.Owner as ContextMenuStrip;
                if (strip != null)
                {
                    TreeView treeview = strip.SourceControl as TreeView;
                    if (treeview != null)
                    {
                        TreeNode node = treeview.SelectedNode;
                        if (node != null)
                        {
                            node.Expand();
                            TreeNode newNode = node.Nodes.Add("New Folder");
                            newNode.ImageIndex         = MogUtil_AssetIcons.GetClassIconIndex("folder");
                            newNode.SelectedImageIndex = MogUtil_AssetIcons.GetClassIconIndex("folderactive");

                            node.Expand();
                            treeview.LabelEdit = true;
                            newNode.BeginEdit();
                        }
                    }
                }
            }
        }
コード例 #3
0
		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);
		}
コード例 #4
0
        private ListViewItem CreateListViewItemForFile(string localFile)
        {
            ListViewItem item = null;

            // Only put the asset in the list if it is actually a library asset
            if (MOG_ControllerLibrary.IsPathWithinLibrary(localFile))
            {
                item = new ListViewItem(Path.GetFileName(localFile));

                string classification = MOG_ControllerLibrary.ConstructLibraryClassificationFromPath(localFile);
                string localTimestamp = GetLocalFileTimestamp(localFile);
                string fullname       = localFile;
                string status         = "Unknown";
                string extension      = DosUtils.PathGetExtension(localFile);

                // Populate the item
                item.ImageIndex = MogUtil_AssetIcons.GetFileIconIndex(localFile);
                item.SubItems.Add(extension);               // Extension
                item.SubItems.Add(classification);          // Classification
                item.SubItems.Add("");                      // User
                item.SubItems.Add("");                      // Comment
                item.SubItems.Add(localTimestamp);          // Local TimeStamp
                item.SubItems.Add("");                      // Server Timestamp
                item.SubItems.Add(status);                  // Status
                item.SubItems.Add(fullname);                // Fullname
                item.SubItems.Add(localFile);               // LocalFile
                item.SubItems.Add("");                      // RepositoryFile

                UpdateListViewItemColors(item, status);
            }

            return(item);
        }
コード例 #5
0
ファイル: ListForm.cs プロジェクト: MOGwareSupport/MOG
        private ListViewItem AddItemToListView(MOG_Filename mogAsset, MOG_Properties pProperties, string fullPath)
        {
            ListViewItem item = new ListViewItem();

            foreach (ColumnHeader column in ListListView.Columns)
            {
                item.SubItems.Add("");
            }

            SetSubColumnText(item, "Name", mogAsset.GetAssetLabel());
            SetSubColumnText(item, "MOG Classification", mogAsset.GetAssetClassification());
            SetSubColumnText(item, "Platform", mogAsset.GetAssetPlatform());
            SetSubColumnText(item, "Version", mogAsset.GetVersionTimeStampString(""));

            if (pProperties != null)
            {
                SetSubColumnText(item, "Size", guiAssetController.FormatSize(pProperties.Size));
                SetSubColumnText(item, "Package", GetPackages(pProperties));
                SetSubColumnText(item, "Creator", pProperties.Creator);
                SetSubColumnText(item, "Last Bless", pProperties.Owner);
                SetSubColumnText(item, "Computer", pProperties.SourceMachine);
                SetSubColumnText(item, "GamePath", pProperties.SyncTargetPath);
                SetSubColumnText(item, "Last Comment", pProperties.LastComment);
            }

            SetSubColumnText(item, "Fullname", fullPath);

            // Icon
            item.ImageIndex = MogUtil_AssetIcons.GetAssetIconIndex(mogAsset.GetOriginalFilename(), pProperties, false);
            return(ListListView.Items.Add(item));
        }
コード例 #6
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);
            }
        }
コード例 #7
0
        private void GetAssignedAssets()
        {
            try
            {
                if (mTaskInfo.GetHasAsset())
                {
                    TaskAsscociatedAssetsListView.Items.Clear();
                    TaskAsscociatedAssetsListView.BeginUpdate();

                    foreach (MOG_Filename mogAssetName in MOG_DBTaskAPI.GetTaskAssetLinks(mTaskInfo.GetTaskID()))
                    {
                        ListViewItem item = new ListViewItem();

                        item.Text = mogAssetName.GetAssetLabel();
                        item.SubItems.Add(mogAssetName.GetAssetClassification());
                        item.SubItems.Add(mogAssetName.GetVersionTimeStampString(""));
                        item.SubItems.Add(mogAssetName.GetEncodedFilename());
                        item.ImageIndex = MogUtil_AssetIcons.GetClassIconIndex(mogAssetName.GetEncodedFilename());

                        TaskAsscociatedAssetsListView.Items.Add(item);
                    }

                    TaskAsscociatedAssetsListView.EndUpdate();
                }
            }
            catch
            {
            }
        }
コード例 #8
0
ファイル: guiProject.cs プロジェクト: MOGwareSupport/MOG
        static public bool SetLoginProject(string name, string branch)
        {
            // Initialize users on the Asset Manager page
            if (mainForm.mAssetManager != null)
            {
                mainForm.mAssetManager.DeInitialize();
            }

            if (MOG_ControllerProject.ProjectExists(name))
            {
                if (MOG_ControllerProject.LoginProject(name, branch) != null)
                {
                    // Initialize branches
                    MainMenuProjectsClass.MOGGlobalBranchesInit(true);
                    UpdateGuiBranch(MOG_ControllerProject.GetBranchName());

                    // Initialize the project icons (clear them first)
                    MogUtil_AssetIcons.ClassIconsClear();
                    MogUtil_AssetIcons.ClassIconInitialize();

                    // Initialize users on the Asset Manager page
                    if (mainForm.mAssetManager != null)
                    {
                        //mainForm.mAssetManager.DeInitialize();
                        mainForm.mAssetManager.Initialize();

                        List <string> departments = guiStartup.GetDepartments(name);
                        mainForm.AssetManagerActiveUserDepartmentsComboBox.Items.Clear();
                        mainForm.AssetManagerActiveUserDepartmentsComboBox.Items.AddRange(departments.ToArray());
                    }

                    // Load web tabs
                    if (mainForm.mWebTabManager != null)
                    {
                        mainForm.mWebTabManager.LoadTabs();
                    }

                    // Update the project related gui stuff
                    UpdateGuiProject(name);

                    // Check if we passed in a valid branch
                    if (branch.Length != 0)
                    {
                        UpdateGuiBranch(MOG_ControllerProject.GetBranchName());
                    }

                    // Save our prefs file
                    guiUserPrefs.SaveStatic_ProjectPrefs();

                    return(true);
                }
            }

            return(false);
        }
コード例 #9
0
        static protected TreeNode assetTreeViewCreate_GetTreeNodeWithIcon(string name, int defaultIndex)
        {
            // Set the imageIndex for a new TreeNode, create the TreeNode, and create a blank tag for the new node
            int imageIndex = MogUtil_AssetIcons.GetClassIconIndex(name);

            if (imageIndex == 0)
            {
                imageIndex = defaultIndex;
            }
            return(new TreeNode(name, imageIndex, 0));
        }
コード例 #10
0
        protected override void ExpandTreeDown()
        {
            UseWaitCursor = true;

            bool bCreateRootProjectNode = false;

            if (mRequiredClassifications.Count > 0)
            {
                bCreateRootProjectNode = true;
            }
            else
            {
                // Fixes a crash at startup when the project is totally empty
                if (MogPropertyList.Count > 0)
                {
                    // Check if the specified property is the Inclusion property
                    MOG_Property testProperty = MogPropertyList[0] as MOG_Property;
                    if (testProperty != null)
                    {
                        // Check if this is the 'FilterInclusion' property?
                        if (string.Compare("FilterInclusions", testProperty.mPropertyKey, true) == 0)
                        {
                            // Show the normal tree anytime we had an inclusion filter yet nothing was found
                            bCreateRootProjectNode = true;
                        }
                    }
                }
            }

            // Check if we decided to create the root project node?
            if (bCreateRootProjectNode)
            {
                Enabled = true;
                string   adamNodeName = MOG_ControllerProject.GetProjectName();
                TreeNode rootNode     = new TreeNode(adamNodeName, new TreeNode[] { new TreeNode(Blank_Node_Text) });
                rootNode.Checked            = NodesDefaultToChecked;
                rootNode.ImageIndex         = MogUtil_AssetIcons.GetClassIconIndex(adamNodeName);
                rootNode.SelectedImageIndex = rootNode.ImageIndex;
                rootNode.Tag  = new Mog_BaseTag(rootNode, rootNode.Text);
                rootNode.Name = rootNode.Text;
                ((Mog_BaseTag)rootNode.Tag).PackageNodeType = PackageNodeTypes.Class;
                Nodes.Add(rootNode);

                rootNode.Expand();
            }
            else
            {
                Enabled = false;
                Nodes.Add(NothingReturned_Text);
            }

            UseWaitCursor = false;
        }
コード例 #11
0
        private void BuildWindowsFileNode(TreeNode parentNode, string displayString, string fullFilename)
        {
            // Split up str into the path and filename
            string[] parts = displayString.Split("\\".ToCharArray());

            TreeNode thisNode = FindNode(parentNode, parts[0]);

            if (thisNode == null)
            {
                string nodeText = parts[0];

                // Check if this is the final layer?
                if (parts.Length == 1)
                {
                    nodeText = displayString;
                }

                // Create a new node
                thisNode         = new TreeNode(nodeText);
                thisNode.Checked = true;
                thisNode.Tag     = fullFilename;
                // Check if this is the final item?
                if (parts.Length == 1)
                {
                    // Add this to the bottom because it is the final node
                    parentNode.Nodes.Add(thisNode);
                }
                else
                {
                    // Insert this at the top because it is a directory
                    parentNode.Nodes.Insert(0, thisNode);
                }

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

            // Check if we need to keep drilling?
            if (parts.Length > 1)
            {
                string remainingPath = displayString.Substring(parts[0].Length + 1);
                BuildWindowsFileNode(thisNode, remainingPath, fullFilename);
            }
        }
コード例 #12
0
        /// <summary>
        /// Generates the root node for our project
        /// </summary>
        private TreeNode CreateSyncTargetRootNode()
        {
            Nodes.Clear();
            string   projectName = MOG_ControllerProject.GetProjectName();
            TreeNode rootNode    = new TreeNode(projectName, new TreeNode[] { new TreeNode(Blank_Node_Text) });

            rootNode.Tag  = new Mog_BaseTag(rootNode, rootNode.Text);
            rootNode.Name = rootNode.Text;
            Nodes.Add(rootNode);
            rootNode.ImageIndex = MogUtil_AssetIcons.GetAssetIconIndex(rootNode.Text);

            rootNode.Expand();

            return(rootNode);
        }
コード例 #13
0
        private int AppendSummary(string section, string comment, Color nodeColor)
        {
            // Get all the file copies
            if (mSummary.SectionExist(section))
            {
                string[] keys = mSummary.GetSectionKeys(section);
                foreach (string key in keys)
                {
                    // Get the asset/file information from the summary file
                    string assetName = mSummary.GetString(section, key);
                    string fileName  = key;

                    // Trim any starting '\'
                    if (fileName != null && fileName.Length > 0)
                    {
                        fileName = fileName.TrimStart("\\".ToCharArray());
                    }

                    try
                    {
                        string fullfilename = MOG_ControllerProject.GetCurrentSyncDataController().GetSyncDirectory() + "\\" + fileName;

                        ListViewItem item = new ListViewItem();
                        item.Text      = Path.GetFileName(fileName);
                        item.ForeColor = nodeColor;

                        FileInfo file = new FileInfo(fullfilename);
                        item.SubItems.Add(file.LastWriteTime.ToShortDateString() + " " + file.LastWriteTime.ToShortTimeString());
                        item.SubItems.Add(comment);

                        item.ImageIndex = MogUtil_AssetIcons.GetFileIconIndex(fullfilename);

                        SummaryListView.Items.Add(item);
                    }
                    catch (Exception e)
                    {
                        MOG_Report.ReportMessage("Update Summary", e.Message, e.StackTrace, MOG.PROMPT.MOG_ALERT_LEVEL.ERROR);
                    }
                }

                return(mSummary.CountKeys(section));
            }

            return(0);
        }
コード例 #14
0
        /// <summary>
        /// Add all our Extra Icons inside ExtraImages (member variable) in the order
        ///  they exist in our ImageList.  If programmer does not add things in the
        ///  right order, an Exception will be thrown by this method (see Important Notes
        ///  above).
        /// </summary>
        protected void AddExtraIcons()
        {
            int    i = 0;
            string keyString;

            foreach (Image image in ExtraImages.Images)
            {
                switch (i)
                {
                case (int)ExtraImageTypes.Relationships:
                    keyString = Relationship_ImageText;
                    break;

                case (int)ExtraImageTypes.BaseFolder:
                    keyString = BaseFolder_ImageText;
                    break;

                case (int)ExtraImageTypes.PackageGroup:
                    keyString = PackageGroup_ImageText;
                    break;

                case (int)ExtraImageTypes.PackageObject:
                    keyString = PackageObject_ImageText;
                    break;

                case (int)ExtraImageTypes.Package:
                    keyString = Package_ImageText;
                    break;

                case (int)ExtraImageTypes.GeneralAsset:
                    keyString = Asset_ImageText;
                    break;

                default:
                    throw new Exception("Programmer has added an image to the 'ExtraImages' ImageList in "
                                        + "MogControl_BaseTreeView without properly adding a const string and or an enum "
                                        + "for that Image!!");
                }
                MogUtil_AssetIcons.AddIcon(image, keyString);
                ++i;
            }
        }
コード例 #15
0
        public void RefreshLockStatus(MOG_Command LockUpdate)
        {
            Color textColor = Color.Black;

            if (LockUpdate != null)
            {
                ListView currentView = mAssetManager.mainForm.AssetManagerInboxTabControl.SelectedTab.Controls[0] as ListView;

                if (currentView == null)
                {
                    return;
                }

                int index = mAssetManager.ListViewItemFindItem(LockUpdate.GetAssetFilename().GetAssetLabel(), currentView);
                if (index != -1)
                {
                    currentView.Items[index].ImageIndex = MogUtil_AssetIcons.GetAssetIconIndex(LockUpdate.GetAssetFilename().GetOriginalFilename());
                }
            }
        }
コード例 #16
0
ファイル: guiAssetTree.cs プロジェクト: MOGwareSupport/MOG
        /// <summary>
        /// Create one new node or update an existing node in the tree.
        /// </summary>
        /// <param name="tree"></param>
        /// <param name="assetName"></param>
        /// <param name="nodeColor"></param>
        static public void AssetTreeViewUpdateNode(string dir, TreeView tree, MOG_Filename assetName, Color nodeColor)
        {
            // Find the type in tree if exists
            TreeNode parent = FindAssetNodeInTree(tree, assetName);

            if (parent != null)
            {
                TreeNode node = new TreeNode();
                node.Text      = assetName.GetAssetLabel();                             // Name
                node.ForeColor = nodeColor;                                             // Color
                node.Checked   = true;

                node.ImageIndex = MogUtil_AssetIcons.GetClassIconIndex(assetName.GetEncodedFilename());

                string fullname = dir + "\\" + assetName.GetEncodedFilename();
                node.Tag = new guiAssetTreeTag(fullname, guiAssetTreeTag.TREE_FOCUS.SUBCLASS, true);

                // Add this asset to the tree
                parent.Nodes.Add(node);
            }
        }
コード例 #17
0
        /// <summary>
        /// Adds all the platforms we need for further expansion of the sync target tree
        /// </summary>
        /// <param name="rootNode"></param>
        private void ExpandSyncTargetPlatforms(TreeNode rootNode)
        {
            mSyncTargetFileManager.RemoveAllPlatforms();

            // Populate our platform nodes
            string[] platforms = MOG_ControllerProject.GetProject().GetPlatformNames();
            foreach (string platform in platforms)
            {
                TreeNode platformNode = new TreeNode(platform, new TreeNode[] { new TreeNode(Blank_Node_Text) });
                platformNode.Tag = new Mog_BaseTag(platformNode, platform);
                rootNode.Nodes.Add(platformNode);
                platformNode.ImageIndex         = MogUtil_AssetIcons.GetClassIconIndex(BaseFolder_ImageText);
                platformNode.SelectedImageIndex = platformNode.ImageIndex;

                ArrayList gamedataFiles = MOG_ControllerSyncData.GetAllSyncDataFileStructsForPlatform(platformNode.Text);

                // Initialize our tree to this platform
                InitializeSyncTargetFiles(platformNode.Text, gamedataFiles, platformNode.FullPath);

                // Automatically expand each of our platform nodes
                platformNode.Expand();
            }
        }
コード例 #18
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);
            }
        }
コード例 #19
0
ファイル: guiAssetTree.cs プロジェクト: MOGwareSupport/MOG
        /// <summary>
        /// Returns the parent node of this asset type.  We search the key then package and group to find the parent node.
        /// </summary>
        /// <param name="tree"></param>
        /// <param name="assetName"></param>
        /// <returns></returns>
        static protected TreeNode FindAssetNodeInTree(TreeView tree, MOG_Filename assetName)
        {
//			TreeNode keyNode, packageNode, groupNode, assetNode;
            int imageIndex = MogUtil_AssetIcons.GetClassIconIndex(assetName.GetAssetName());

            return(new TreeNode());
// TODO - Rebuild this code!!

//			// First find the key
//			foreach (TreeNode keyNodes in tree.Nodes)
//			{
//				if (string.Compare(keyNodes.Text, assetName.GetAssetClassification(), true) == 0)
//				{
//					// Find the package
//					packageNode = FindNode(keyNodes, assetName.GetAssetClassification());
//					if (packageNode != null)
//					{
//						// Find the group
//						groupNode = FindNode(packageNode, assetName.GetAssetSubClass());
//						if (groupNode != null)
//						{
//							// Find the asset
//							assetNode = FindNode(groupNode, assetName.GetAssetName());
//							if (assetNode != null)
//							{
//								assetNode.Remove();
//								return groupNode;
//							}
//							else
//							{
//								// This is the group of the new child asset
//								return groupNode;
//							}
//						}
//						else
//						{
//							// Create the group
//							groupNode = new TreeNode(assetName.GetAssetSubClass());
//							groupNode.ImageIndex = imageIndex;
//                            groupNode.Tag = new guiAssetTreeTag("", guiAssetTreeTag.TREE_FOCUS.SUBCLASS);
//
//							try
//							{
//								// Add this branch to the tree
//								packageNode.Nodes.Add(groupNode);
//
//								// This is the group of the new child asset
//								return groupNode;
//							}
//							catch(Exception e)
//							{
//								e.ToString();
//								return null;
//							}
//						}
//					}
//					else
//					{
//						// Create the package and the group
//						packageNode = new TreeNode(assetName.GetAssetClassification());
//						packageNode.ImageIndex = imageIndex;
//						packageNode.Tag = new guiAssetTreeTag("", guiAssetTreeTag.TREE_FOCUS.CLASS);
//
//						groupNode = new TreeNode(assetName.GetAssetSubClass());
//						groupNode.ImageIndex = imageIndex;
//						groupNode.Tag = new guiAssetTreeTag("", guiAssetTreeTag.TREE_FOCUS.SUBCLASS);
//
//						try
//						{
//							packageNode.Nodes.Add(groupNode);
//
//							// Add this branch to the tree
//							keyNodes.Nodes.Add(packageNode);
//
//							// This is the group of the new child asset
//							return groupNode;
//						}
//						catch(Exception e)
//						{
//							e.ToString();
//							return null;
//						}
//					}
//				}
//			}


//			// Create the key, package and the group
//			keyNode = new TreeNode(assetName.GetAssetKey(), imageIndex, 0);
//			keyNode.Tag = new guiAssetTreeTag("", guiAssetTreeTag.TREE_FOCUS.KEY);
//
//			packageNode = new TreeNode(assetName.GetAssetClassification());
//			packageNode.ImageIndex = imageIndex;
//			packageNode.Tag = new guiAssetTreeTag("", guiAssetTreeTag.TREE_FOCUS.CLASS);
//			keyNode.Nodes.Add(packageNode);
//
//			groupNode = new TreeNode(assetName.GetAssetSubClass());
//			groupNode.ImageIndex = imageIndex;
//			groupNode.Tag = new guiAssetTreeTag("", guiAssetTreeTag.TREE_FOCUS.SUBCLASS);
//			packageNode.Nodes.Add(groupNode);
//
//			try
//			{
//				// Add this branch to the tree
//				tree.Nodes.Add(keyNode);
//
//				// This is the group of the new child asset
//				return groupNode;
//			}
//			catch(Exception e)
//			{
//				e.ToString();
//				return null;
//			}
        }
コード例 #20
0
        /// <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);
        }
コード例 #21
0
ファイル: ListForm.cs プロジェクト: MOGwareSupport/MOG
        /// <summary>
        /// Load a report form from a file and populate it
        /// </summary>
        /// <param name="filename"></param>
        public void LoadReportList(string filename)
        {
            MOG_Ini report = new MOG_Ini(filename);

            // Set the form title
            Text = Path.GetFileName(filename);

            if (report.SectionExist("ASSETS"))
            {
                ListListView.Items.Clear();

                ListListView.BeginUpdate();

                ProgressMax(report.CountKeys("ASSETS"));

                for (int x = 0; x < report.CountKeys("ASSETS"); x++)
                {
                    MOG_Filename mogAsset  = new MOG_Filename(report.GetKeyNameByIndexSLOW("ASSETS", x));
                    string       extraInfo = report.GetKeyByIndexSLOW("ASSETS", x);

                    MOG_Properties pProperties = new MOG_Properties(mogAsset);

                    string version        = mogAsset.GetVersionTimeStamp();
                    string currentVersion = MOG_DBAssetAPI.GetAssetVersion(mogAsset);                    //mCurrentInfo.GetString("ASSETS", mogAsset.GetAssetName());

                    MOG_Time assetTime        = new MOG_Time(version);
                    MOG_Time currentAssetTime = new MOG_Time(currentVersion);

                    ListViewItem item = new ListViewItem();

                    // We have support for the old lists as well as the new ones that have extra information stored.
                    if (string.Compare(extraInfo, "ReportList", true) != 0)
                    {
                        string [] extraItems = extraInfo.Split(",".ToCharArray());
                        foreach (string extra in extraItems)
                        {
                            if (item.Text.Length == 0)
                            {
                                item.Text = extra;
                            }
                            else
                            {
                                item.SubItems.Add(extra);
                            }
                        }

                        // Update the version
                        if (assetTime.Compare(currentAssetTime) != 0)
                        {
                            item.SubItems[FindColumn("Version")].Text      = currentAssetTime.FormatString("");
                            item.SubItems[FindColumn("Version")].ForeColor = Color.Red;
                        }
                    }
                    else
                    {
                        item = AddItemToListView(mogAsset, pProperties, MOG_ControllerRepository.GetAssetBlessedVersionPath(mogAsset, version).GetEncodedFilename());

                        // Get version
                        if (assetTime.Compare(currentAssetTime) != 0)                                                                                           // Version
                        {
                            item.SubItems[FindColumn("Version")].Text      = currentAssetTime.FormatString("");
                            item.SubItems[FindColumn("Version")].ForeColor = Color.Red;
                            version = currentVersion;
                        }
                        else
                        {
                            item.SubItems[FindColumn("Version")].Text = assetTime.FormatString("");
                        }
                    }

                    // Icon
                    item.ImageIndex = MogUtil_AssetIcons.GetAssetIconIndex(mogAsset.GetAssetFullName());

                    ListListView.Items.Add(item);

                    ProgressStep();
                }

                UpdateAssetTotals();
                ListListView.EndUpdate();
                ProgressReset();
            }
        }
コード例 #22
0
        public void RefreshItem(MOG_Command command)
        {
            // No reason to bother if they have no library working directory
            if (MOG_ControllerLibrary.GetWorkingDirectory().Length == 0)
            {
                return;
            }

            // Make sure this contains an encapsulated command?
            MOG_Command encapsulatedCommand = command.GetCommand();

            if (encapsulatedCommand != null)
            {
                // No reason to bother if they are in a different project
                if (string.Compare(MOG_ControllerProject.GetProjectName(), encapsulatedCommand.GetProject(), true) != 0)
                {
                    return;
                }

                // Check if this encapsulatedCommand contains a valid assetFilename?
                if (encapsulatedCommand.GetAssetFilename().GetFilenameType() == MOG_FILENAME_TYPE.MOG_FILENAME_Asset)
                {
                    // No reason to bother if this asset's classification doesn't match their mCurrentClassification
                    if (string.Compare(CurrentClassification, encapsulatedCommand.GetAssetFilename().GetAssetClassification(), true) != 0)
                    {
                        return;
                    }
                }

                // Can we find the asset node of this file?
                int itemid = FindListItem(encapsulatedCommand.GetAssetFilename().GetAssetFullName());
                if (itemid == -1)
                {
                    // Check if this was a post command?
                    if (encapsulatedCommand.GetCommandType() == MOG_COMMAND_TYPE.MOG_COMMAND_Post)
                    {
                        // Create a new item
                        ListViewItem item = CreateListViewItemForAsset(encapsulatedCommand.GetAssetFilename());
                        if (item != null)
                        {
                            LibraryListView.Items.Add(item);
                            itemid = FindListItem(encapsulatedCommand.GetAssetFilename().GetAssetFullName());
                        }
                    }
                }

                // Now check if we finally found our itemid?
                if (itemid != -1)
                {
                    ListViewItem item = LibraryListView.Items[itemid];
                    if (item != null)
                    {
                        int classificationIdx  = FindColumn("Classification");
                        int nameIdx            = FindColumn("Name");
                        int statusIdx          = FindColumn("Status");
                        int userIdx            = FindColumn("User");
                        int commentIdx         = FindColumn("Comment");
                        int localFileIdx       = FindColumn("LocalFile");
                        int repositoryFileIdx  = FindColumn("RepositoryFile");
                        int localTimestampIdx  = FindColumn("Local Timestamp");
                        int serverTimestampIdx = FindColumn("Server Timestamp");
                        int fullname           = FindColumn("Fullname");
                        int extensionIdx       = FindColumn("Extension");

                        // Determin the type of encapsulated command
                        switch (encapsulatedCommand.GetCommandType())
                        {
                        case MOG_COMMAND_TYPE.MOG_COMMAND_LockWriteRelease:
                        case MOG_COMMAND_TYPE.MOG_COMMAND_LockReadRelease:
                            UpdateItem(item);
                            break;

                        case MOG_COMMAND_TYPE.MOG_COMMAND_LockWriteRequest:
                        case MOG_COMMAND_TYPE.MOG_COMMAND_LockReadRequest:
                            string status   = "";
                            string comment  = encapsulatedCommand.GetDescription();
                            string username = encapsulatedCommand.GetUserName();
                            if (String.Compare(MOG_ControllerProject.GetUserName(), encapsulatedCommand.GetUserName(), true) == 0)
                            {
                                status = "CheckedOut";
                            }
                            else
                            {
                                status = "Locked";
                            }

                            item.ImageIndex = MogUtil_AssetIcons.GetLockedBinaryIcon(item.SubItems[repositoryFileIdx].Text);
                            item.SubItems[commentIdx].Text = comment;
                            item.SubItems[userIdx].Text    = username;
                            item.SubItems[statusIdx].Text  = status;

                            UpdateListViewItemColors(item, status);
                            break;

                        case MOG_COMMAND_TYPE.MOG_COMMAND_Post:
                            item.SubItems[repositoryFileIdx].Text = MOG_ControllerLibrary.ConstructBlessedFilenameFromAssetName(encapsulatedCommand.GetAssetFilename());
                            UpdateItem(item);
                            break;

                        case MOG_COMMAND_TYPE.MOG_COMMAND_RemoveAssetFromProject:
                            // Make sure to remove this file just incase it had been previously synced
                            MOG_ControllerLibrary.Unsync(encapsulatedCommand.GetAssetFilename());
                            // Proceed to delete this item
                            RemoveItem(itemid);
                            break;
                        }

                        // Update the item's colors
                        UpdateListViewItemColors(item, item.SubItems[statusIdx].Text);
                    }
                }
            }
        }
コード例 #23
0
 protected int GetSpecialImageIndex(string extraImageName)
 {
     return(MogUtil_AssetIcons.GetClassIconIndex(extraImageName));
 }
コード例 #24
0
        private void UpdateItem(ListViewItem item)
        {
            string status         = "";
            string username       = "";
            string comment        = "";
            string localTimestamp = "";

            // Find our desired columns
            int statusIdx          = FindColumn("Status");
            int userIdx            = FindColumn("User");
            int commentIdx         = FindColumn("Comment");
            int localTimestampIdx  = FindColumn("Local Timestamp");
            int serverTimestampIdx = FindColumn("Server Timestamp");
            int localFileIdx       = FindColumn("LocalFile");
            int repositoryFileIdx  = FindColumn("RepositoryFile");

            string       repositoryFile          = item.SubItems[repositoryFileIdx].Text;
            MOG_Filename repositoryAssetFilename = new MOG_Filename(repositoryFile);

            // Check if this file exist locally?
            string localFile = item.SubItems[localFileIdx].Text;

            if (localFile.Length != 0)
            {
                // Obtain the localFile info
                FileInfo fileInfo = new FileInfo(localFile);
                // Does this local file exist?
                if (fileInfo != null && fileInfo.Exists)
                {
                    // Compare our local file's timestamp to the server's revision
                    localTimestamp = MOG_Time.GetVersionTimestamp(fileInfo.LastWriteTime);
                    if (localTimestamp == repositoryAssetFilename.GetVersionTimeStamp())
                    {
                        // Indicate this item is synced and up-to-date
                        status = "Up-to-date";
                    }
                    else
                    {
                        // Indicate this item is synced
                        status = "Out-of-date";
                    }
                }
                else
                {
                    // Indicate this item is not synced
                    status = "unSynced";
                }
            }
            else
            {
                // Indicate this item is not synced
                status = "unSynced";
            }

            // Check if this file exists in the repository?
            if (repositoryFile.Length != 0)
            {
                // Check the lock statusIdx of the asset
                MOG_Command sourceLock = MOG_ControllerProject.PersistentLock_Query(repositoryAssetFilename.GetAssetFullName());
                if (sourceLock.IsCompleted() && sourceLock.GetCommand() != null)
                {
                    MOG_Command lockHolder = sourceLock.GetCommand();

                    // Obtain the lock info
                    item.ImageIndex = MogUtil_AssetIcons.GetLockedBinaryIcon(repositoryFile);
                    username        = lockHolder.GetUserName();
                    comment         = lockHolder.GetDescription();

                    // Check if this is locked by me?
                    if (username == MOG_ControllerProject.GetUserName())
                    {
                        status = "CheckedOut";
                    }
                    else
                    {
                        status = "Locked";
                    }
                }
                else
                {
                    // Update this file's icon
                    item.ImageIndex = MogUtil_AssetIcons.GetFileIconIndex(repositoryFile);
                }
            }

            // Update the item with the new information
            item.SubItems[statusIdx].Text          = status;
            item.SubItems[userIdx].Text            = username;
            item.SubItems[commentIdx].Text         = comment;
            item.SubItems[localTimestampIdx].Text  = MogUtils_StringVersion.VersionToString(localTimestamp);
            item.SubItems[serverTimestampIdx].Text = MogUtils_StringVersion.VersionToString(repositoryAssetFilename.GetVersionTimeStamp());

            // Update the color for this locked item
            UpdateListViewItemColors(item, status);
        }
コード例 #25
0
        /// <summary>
        /// Update an existing ListView node for the asset manager inboxes
        /// </summary>
        /// <param name="pProperties"></param>
        /// <param name="nodeColor"></param>
        /// <returns></returns>
        public static void UpdateListViewItem(ListViewItem item, MOG_Filename asset, string status, MOG_Properties pProperties)
        {
            string date    = "";
            string size    = "";
            string creator = "";
            string owner   = "";
            string group   = "";
            string target  = "";

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

                // Gather the following info from our properties
                date    = MOG_Time.FormatTimestamp(pProperties.CreatedTime, "");
                size    = guiAssetController.FormatSize(pProperties.Size);
                creator = pProperties.Creator;
                owner   = pProperties.Owner;
                group   = pProperties.Group;

                // Check if this is a packaged asset?
                if (pProperties.IsPackagedAsset)
                {
                    // Check if we have have any package assignments in our propeerties?
                    ArrayList packages = pProperties.GetPackages();
                    if (packages.Count == 0)
                    {
                        // Indicate this is a packaged asset w/o any package assignments
                        target = "Missing package assignment...";
                    }
                    else if (packages.Count == 1)
                    {
                        MOG_Property package          = packages[0] as MOG_Property;
                        MOG_Filename packageName      = new MOG_Filename(MOG_ControllerPackage.GetPackageName(package.mPropertyKey));
                        string       packageGroupPath = MOG_ControllerPackage.GetPackageGroups(package.mPropertyKey);
                        string       displayString    = MOG_ControllerPackage.CombinePackageAssignment(packageName.GetAssetLabel(), packageGroupPath, "");
                        target = "{Package} " + displayString + "  in  " + MOG_Filename.GetAdamlessClassification(packageName.GetAssetClassification());
                    }
                    else
                    {
                        target = "{Package} " + packages.Count + " Assignments...";
                    }
                }
                else if (pProperties.SyncFiles)
                {
                    // Get the formatted SyncTarget of this asset
                    target = MOG_Tokens.GetFormattedString("{Workspace}\\" + pProperties.SyncTargetPath, asset, pProperties.GetPropertyList());
                }
            }

            item.Text = asset.GetAssetLabel();

            // Populate the item's SubItems
            // I tried for a long time to be smart here and use ColumnNameFind(thisListView.Columns, "Name") but
            // I kept running into walls because this function is used by a lot of workers outside of the ListView's thread.
            // So, I gave up and am just going to do it the ugly brute force way!  YUCK!!
            item.SubItems[(int)AssetBoxColumns.NAME].Text       = asset.GetAssetLabel();
            item.SubItems[(int)AssetBoxColumns.CLASS].Text      = asset.GetAssetClassification();
            item.SubItems[(int)AssetBoxColumns.TARGETPATH].Text = target;
            item.SubItems[(int)AssetBoxColumns.DATE].Text       = date;
            item.SubItems[(int)AssetBoxColumns.SIZE].Text       = size;
            item.SubItems[(int)AssetBoxColumns.PLATFORM].Text   = asset.GetAssetPlatform();
            item.SubItems[(int)AssetBoxColumns.STATE].Text      = status;
            item.SubItems[(int)AssetBoxColumns.CREATOR].Text    = creator;
            item.SubItems[(int)AssetBoxColumns.RESPPARTY].Text  = owner;
            item.SubItems[(int)AssetBoxColumns.OPTIONS].Text    = "";
            item.SubItems[(int)AssetBoxColumns.FULLNAME].Text   = asset.GetEncodedFilename();
            item.SubItems[(int)AssetBoxColumns.BOX].Text        = asset.GetBoxName();
            item.SubItems[(int)AssetBoxColumns.GROUP].Text      = group;

            // Set the item's Icons
            item.ImageIndex = MogUtil_AssetIcons.GetFileIconIndex(asset.GetEncodedFilename(), pProperties);

            if (MogMainForm.MainApp != null &&
                MogMainForm.MainApp.mAssetManager != null)
            {
                // mAssetStatus.GetStatusInfo() is sort of a black sheep and should maybe become static
                item.StateImageIndex = MogMainForm.MainApp.mAssetManager.mAssetStatus.GetStatusInfo(status).IconIndex;
            }

            // Set the item's color
            item.ForeColor = MOG_AssetStatus.GetColor(status);
            // Check if this is a local item that has been blessed?
            if (asset.IsLocal() &&
                string.Compare(status, MOG_AssetStatus.GetText(MOG_AssetStatusType.Blessed), true) == 0)
            {
                // Mark local blessed items with light gray
                item.ForeColor = Color.LightGray;
            }
        }
コード例 #26
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);
                    }
                }
            }
        }
コード例 #27
0
        private ListViewItem InitNewLockItem(MOG_Command command)
        {
            if (command != null)
            {
                if ((command.GetCommandType() == MOG_COMMAND_TYPE.MOG_COMMAND_LockWriteRequest) || (command.GetCommandType() == MOG_COMMAND_TYPE.MOG_COMMAND_LockReadRequest))
                {
                    ListViewItem item = new ListViewItem();
                    MOG_Time     time = new MOG_Time();
                    time.SetTimeStamp(command.GetCommandTimeStamp());

                    // Gather appropriate lock info from the command's MOG_Filename
                    string label          = "";
                    string classification = "";

                    // Check if this is an asset?
                    if (command.GetAssetFilename().GetFilenameType() == MOG_FILENAME_TYPE.MOG_FILENAME_Asset)
                    {
                        // Get the label and classifciation of the asset
                        label          = command.GetAssetFilename().GetAssetLabel();
                        classification = command.GetAssetFilename().GetAssetClassification();

                        // Obtain the proper icon
                        item.ImageIndex = MogUtil_AssetIcons.GetAssetIconIndex(command.GetAssetFilename().GetOriginalFilename());
                    }
                    // Check if this is a classification-level by seeing if it ends with a '*'?
                    else if (command.GetAssetFilename().GetOriginalFilename().EndsWith("*"))
                    {
                        // Do our best to illustrate a classification-level lock
                        label          = "*";
                        classification = command.GetAssetFilename().GetOriginalFilename().Trim("*".ToCharArray());

                        // Obtain the proper icon
                        item.ImageIndex = MogUtil_AssetIcons.GetClassIconIndex(classification);
                    }

                    //LOCK_COLUMNS {LABEL, CLASSIFICATION, USER, DESCRIPTION, MACHINE, IP, ID, TIME, FULLNAME, TYPE};
                    item.Text = label;
                    item.SubItems.Add(classification);
                    item.SubItems.Add(command.GetUserName());
                    item.SubItems.Add(command.GetDescription());
                    item.SubItems.Add(command.GetComputerName());
                    item.SubItems.Add(command.GetComputerIP());
                    item.SubItems.Add(Convert.ToString(command.GetNetworkID()));
                    item.SubItems.Add(time.FormatString(""));
                    item.SubItems.Add(command.GetAssetFilename().GetOriginalFilename());

                    switch (command.GetCommandType())
                    {
                    case MOG_COMMAND_TYPE.MOG_COMMAND_LockReadRequest:
                        item.SubItems.Add("Read Lock");
                        item.ForeColor = Color.Green;
                        break;

                    case MOG_COMMAND_TYPE.MOG_COMMAND_LockWriteRequest:
                        item.SubItems.Add("Write Lock");
                        item.ForeColor = Color.Red;
                        break;
                    }

                    return(item);
                }
            }
            return(null);
        }
コード例 #28
0
        /// <summary>
        /// Parses through our mSyncTargetFiles to figure out what should be added where
        /// </summary>
        private void ExpandSyncTargetSubNodes(TreeNode node, string platformName)
        {
            SyncTargetPlatform platform  = mSyncTargetFileManager.GetPlatform(platformName);
            ArrayList          fileNodes = new ArrayList();
            int baseFolderIndex          = MogUtil_AssetIcons.GetClassIconIndex(BaseFolder_ImageText);

            // Go through each entry we created when we initialized
            foreach (KeyValuePair <string, SyncTargetFolder> entry in platform.Folders)
            {
                SyncTargetFolder folder       = entry.Value as SyncTargetFolder;
                string           relativePath = folder.Path;
                string           nodePath     = node.FullPath;

                if (String.Compare(relativePath, node.FullPath, true) == 0)
                {
                    //This is the folder that matches the node we're expanding
                    //Go through and get all the files from the folder so we can add nodes for them
                    //We will add these to the current node after we finish going through and adding all the folders
                    foreach (MOG_DBSyncTargetInfo info in folder.Files)
                    {
                        TreeNode fileNode = CreateSyncTargetTreeNode(info, platformName);
                        fileNodes.Add(fileNode);
                    }
                }
                else if (relativePath.StartsWith(nodePath + PathSeparator, StringComparison.CurrentCultureIgnoreCase))
                {
                    // We found a node with a path that is a parent to us in the hiererchy
                    // Get rid of our current node's path (preparatory to using relativePath as a node.Text)
                    relativePath = relativePath.Substring(nodePath.Length + PathSeparator.Length);
                    if (relativePath.Length > 0)
                    {
                        //If there's a path separator we only want the first part before the separator
                        if (relativePath.Contains(PathSeparator))
                        {
                            //Just grab the first part of the string, everything before the ~
                            relativePath = relativePath.Substring(0, relativePath.IndexOf(PathSeparator));
                        }

                        if (!SyncTargetSubNodeExists(node, relativePath))
                        {
                            // create a new subnode to represent this folder
                            TreeNode temp = new TreeNode(relativePath, new TreeNode[] { new TreeNode(Blank_Node_Text) });
                            temp.Tag = new Mog_BaseTag(temp, temp.Text);
                            node.Nodes.Add(temp);
                            temp.ImageIndex         = baseFolderIndex;
                            temp.SelectedImageIndex = temp.ImageIndex;
                        }
                    }
                }
            }

            // Add all the file nodes we found above...
            foreach (TreeNode fileNode in fileNodes)
            {
                // Add each node and set its icon
                node.Nodes.Add(fileNode);
                Mog_BaseTag tag = fileNode.Tag as Mog_BaseTag;
                if (tag != null)
                {
                    string assetFullFilename = tag.FullFilename;
                    string foundFilename     = FindAssetsFile(fileNode.Text, assetFullFilename);

                    //Set the image for this node
                    if (foundFilename.Length > 0 || (new MOG_Filename(assetFullFilename)).GetFilenameType() == MOG_FILENAME_TYPE.MOG_FILENAME_Asset)
                    {
                        //This is either a file or an asset
                        SetImageIndices(fileNode, GetAssetFileImageIndex(foundFilename));
                    }
                    else
                    {
                        //This is a folder
                        fileNode.ImageIndex         = baseFolderIndex;
                        fileNode.SelectedImageIndex = fileNode.ImageIndex;
                    }
                }
            }
        }