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); }
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(); } } } } }
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 { } }
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)); }
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; }
/// <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); } }
/// <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(); } }
/// <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; // } }
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); }
/// <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; } } } }
protected int GetSpecialImageIndex(string extraImageName) { return(MogUtil_AssetIcons.GetClassIconIndex(extraImageName)); }
/// <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); }