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)); }
public List <string> DrillToAsset_BuildDrillPathParts(MOG_Filename assetFilename, bool includeRevisions) { List <string> parts = new List <string>(); if (Nodes != null) { if (Nodes.Count > 0) { if (!String.IsNullOrEmpty(assetFilename.GetOriginalFilename())) { // Add classification elements string classification = assetFilename.GetAssetClassification(); if (!String.IsNullOrEmpty(classification)) { string[] classificationParts = MOG_Filename.SplitClassificationString(classification); parts.AddRange(classificationParts); // Add asset name elements string assetName = assetFilename.GetAssetName(); if (!String.IsNullOrEmpty(assetName)) { parts.Add(assetName); // Check if we have a version? if (!String.IsNullOrEmpty(assetFilename.GetVersionTimeStamp()) && includeRevisions) { // Date format string string dateFormat = MOG_Tokens.GetMonth_1() + "/" + MOG_Tokens.GetDay_1() + "/" + MOG_Tokens.GetYear_4() + " " + MOG_Tokens.GetHour_1() + ":" + MOG_Tokens.GetMinute_2() + " " + MOG_Tokens.GetAMPM(); parts.Add(Revisions_Text); parts.Add("<" + assetFilename.GetVersionTimeStampString(dateFormat) + ">"); } } } } } } return(parts); }
private ListViewItem CreateListViewItemForAsset(MOG_Filename asset) { ListViewItem item = null; // Only put the asset in the list if it is actually a library asset if (asset.IsLibrary()) { // Make sure we have something valid in our Filename if (asset.GetAssetLabel().Length > 0) { item = new ListViewItem(asset.GetAssetLabel()); // Get the source imported file MOG_Filename repositoryAssetFilename = MOG_ControllerRepository.GetAssetBlessedVersionPath(asset, asset.GetVersionTimeStamp()); string repositoryFile = MOG_ControllerLibrary.ConstructBlessedFilenameFromAssetName(repositoryAssetFilename); string localFile = MOG_ControllerLibrary.ConstructLocalFilenameFromAssetName(repositoryAssetFilename); string extension = DosUtils.PathGetExtension(localFile); // Populate the item item.SubItems.Add(extension); // Extension item.SubItems.Add(asset.GetAssetClassification()); // Classification item.SubItems.Add(""); // User item.SubItems.Add(""); // Comment item.SubItems.Add(""); // Local TimeStamp item.SubItems.Add(asset.GetVersionTimeStampString("")); // Server Timestamp item.SubItems.Add("New"); // Status item.SubItems.Add(asset.GetAssetFullName()); // Fullname item.SubItems.Add(localFile); // LocalFile item.SubItems.Add(repositoryFile); // RepositoryFile // Update the item UpdateItem(item); } } return(item); }
public override void MakeAssetCurrent(MOG_Filename assetFilename) { // Call our parent's MakeAssetCurrent base.MakeAssetCurrent(assetFilename); // Make sure this assetFilename has the info we want if (assetFilename != null && assetFilename.GetVersionTimeStamp().Length > 0) { TreeNode foundNode = FindNode(assetFilename.GetAssetFullName()); if (foundNode != null) { // Check if this node was previously marked as a deleted version? if (foundNode.ForeColor == Archive_Color) { // Collapse this baby and let it get rebuilt the next time the user expands it because it needs to change it internal structure foundNode.Collapse(); foundNode.Nodes.Clear(); foundNode.Nodes.Add(Blank_Node_Text); } // Reset the color foundNode.ForeColor = Color.Black; // Update this parent node with the new information concerning this asset Mog_BaseTag assetTag = foundNode.Tag as Mog_BaseTag; if (assetTag != null) { // Create a dateFormat just like that used in standard MS Windows USA regional date settings string dateFormat = MOG_Tokens.GetMonth_1() + "/" + MOG_Tokens.GetDay_1() + "/" + MOG_Tokens.GetYear_4() + " " + MOG_Tokens.GetHour_1() + ":" + MOG_Tokens.GetMinute_2() + " " + MOG_Tokens.GetAMPM(); // Scan the children nodes looking for other places needing to be fixed up foreach (TreeNode node in foundNode.Nodes) { // Make sure this is a valid node? if (node != null) { // Checkif this is the 'All Revisions'? if (node.Text == Revisions_Text) { bool bFoundCurrentRevisionNode = false; // Fixup this list of revisions foreach (TreeNode revisionNode in node.Nodes) { Mog_BaseTag baseTag = revisionNode.Tag as Mog_BaseTag; if (baseTag != null) { MOG_Filename revisionFilename = new MOG_Filename(baseTag.FullFilename); if (revisionFilename.GetVersionTimeStamp() == assetFilename.GetVersionTimeStamp()) { revisionNode.ForeColor = CurrentVersion_Color; bFoundCurrentRevisionNode = true; } else { revisionNode.ForeColor = Color.Black; } } } // Check if we need to add our new revision node? if (!bFoundCurrentRevisionNode) { // Looks like this is a new revision and needs to be added // Hey Whipple - What do I do here? // It seems like this is already added by an earlier event so I suspect we will never hit this. } } else { // Check if this is the 'Current <' node if (node.Text.StartsWith(Current_Text + " <")) { node.Text = Current_Text + " <" + assetFilename.GetVersionTimeStampString(dateFormat) + ">"; } // Update it's tag Mog_BaseTag currentTag = node.Tag as Mog_BaseTag; if (currentTag != null) { assetTag.FullFilename = assetFilename.GetOriginalFilename(); } // Finally collapse this baby and let it get rebuilt the next time the user expands it node.Collapse(); node.Nodes.Clear(); node.Nodes.Add(Blank_Node_Text); } } } } } } }
static protected void assetTreeViewCreate_AddVersionNodes(TreeView tree, TreeNode parent, int defaultIndex) { // Add version nodes TreeNode versionRoot = new TreeNode(VERSION_TOKEN, defaultIndex, 0); versionRoot.Tag = parent.Tag; parent.Nodes.Clear(); // Date format string string dateFormat = MOG_Tokens.GetMonth_1() + "/" + MOG_Tokens.GetDay_1() + "/" + MOG_Tokens.GetYear_4() + " " + MOG_Tokens.GetHour_1() + ":" + MOG_Tokens.GetMinute_2() + " " + MOG_Tokens.GetAMPM(); // Create a tag for ease of use guiAssetTreeTag parentTag = (guiAssetTreeTag)parent.Tag; // Get the lastest version string string versionStr = MOG_DBAssetAPI.GetAssetVersion(new MOG_Filename(parentTag.FullFilename)); // Populate HDD versions DirectoryInfo[] hddVersions = DosUtils.DirectoryGetList(parentTag.FullFilename, ""); // Arrange it latest date first Array.Reverse(hddVersions); // Populate DB versions ArrayList dbVersions = MOG_DBAssetAPI.GetAllAssetRevisions(new MOG_Filename(parentTag.FullFilename)); // Turn off sorting for this part of the tree tree.Sorted = false; foreach (DirectoryInfo version in hddVersions) { // Create a new versionNode MOG_Filename versionFile = new MOG_Filename(version.FullName); string textLabel = "<" + versionFile.GetVersionTimeStampString(dateFormat) + ">"; TreeNode versionNode = new TreeNode(textLabel, defaultIndex, 0); // Add guiAssetTreeTag and change color to indicate HDD-only status versionNode.Tag = new guiAssetTreeTag(version.FullName, guiAssetTreeTag.TREE_FOCUS.VERSION, true); // If this is a version matched in the DB, color is black if (assetTreeViewCreate_IsAssetVersionInDB(dbVersions, version.Name)) { versionNode.ForeColor = Color.Black; } // Else, turn color gray else { versionNode.ForeColor = Color.DarkGray; } //glk: This still needs to be tested against the case where there is no directory that matches the verion in versionStr // If this is the most recent asset, display it as such if (versionStr == versionFile.GetVersionTimeStamp()) { versionNode.ForeColor = Color.Blue; // Create a currentVersion node, manually cloning versionNode // glk: object.Clone() does not function properly TreeNode currentVersion = new TreeNode(textLabel, versionNode.ImageIndex, versionNode.SelectedImageIndex); currentVersion.ForeColor = Color.Blue; currentVersion.Tag = new guiAssetTreeTag(version.FullName, guiAssetTreeTag.TREE_FOCUS.VERSION, true); // Keep tree from drawing itself for a bit tree.BeginUpdate(); // Document the horizontal and vertical // positions of tree's scrollbar using extern functions int horizPos = GetHScrollPosition(tree); int vertPos = GetVScrollPosition(tree); // Expand the tree: This is the operation which causes // really erratic behavior from TreeView Control currentVersion.Expand(); // Add ghost node for further expansion currentVersion.Nodes.Add(new TreeNode("")); parent.Nodes.Add(currentVersion); // Set the scrollbar horizontal and vertical positions // back to what they were. SetHScrollPosition(tree, horizPos); SetVScrollPosition(tree, vertPos); // Allow tree to draw itself tree.EndUpdate(); } // Add new placeholder for further expansion versionNode.Nodes.Add(new TreeNode("")); versionRoot.Nodes.Add(versionNode); } parent.Nodes.Add(versionRoot); // Turn sorting back on tree.Sorted = true; }