示例#1
0
        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;
        }
        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);
                                }
                            }
                        }
                    }
                }
            }
        }
        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);
        }