Example #1
0
        /// <summary>
        /// Adds the execute recipe node.
        /// </summary>
        private ExtendedTreeNode AddExecuteRecipeNode(IAssetReference assetReference, ExtendedTreeNode recipeTreeNode)
        {
            ExtendedTreeNode executeTreeNode = new ExtendedTreeNode();

            if (assetReference is UnboundTemplateReference || assetReference is BoundTemplateReference)
            {
                executeTreeNode.Text = Properties.Resources.Navigator_UnfoldThisTemplate;
            }
            else
            {
                executeTreeNode.Text = Properties.Resources.Navigator_RunThisRecipe;
            }

            executeTreeNode.ToolTipText = String.Format(Properties.Resources.Reference_AppliesToTooltip, assetReference.AppliesTo);

            executeTreeNode.NodeFont           = (executeTreeNode.NodeFont != null) ? new Font(executeTreeNode.NodeFont, FontStyle.Bold) : new Font(SystemFonts.DefaultFont, FontStyle.Bold);
            executeTreeNode.Tag                = assetReference;
            executeTreeNode.ShowAsLink         = true;
            executeTreeNode.ImageIndex         = ImageExecuteIndex;
            executeTreeNode.SelectedImageIndex = ImageExecuteIndex;
            executeTreeNode.StateImageIndex    = ImageExecuteIndex;
            recipeTreeNode.Nodes.Add(executeTreeNode);

            return(executeTreeNode);
        }
Example #2
0
        private void AddExecuteRecipeHistoryNode(Recipe recipe, ExtendedTreeNode recipeTreeNode)
        {
            IAssetReference assetReference = GetAssetReferenceByName(recipe.Name);

            if (assetReference != null && recipe.Recurrent)
            {
                ExtendedTreeNode executeNode = AddExecuteRecipeNode(assetReference, recipeTreeNode);
                executeNode.Text = Resources.Navigator_RunThisRecipeAgain;
            }
        }
Example #3
0
        /// <summary>
        /// Adds the documentation node based on the specified Link configuration.
        /// </summary>
        /// <param name="recipeTreeNode">The recipe tree node.</param>
        /// <param name="documentationLink">The documentation link.</param>
        private void AddDocumentationNode(ExtendedTreeNode recipeTreeNode, Link documentationLink)
        {
            ExtendedTreeNode documentationTreeNode = new ExtendedTreeNode();

            documentationTreeNode.ShowAsLink         = true;
            documentationTreeNode.Text               = documentationLink.Caption;
            documentationTreeNode.Tag                = documentationLink;
            documentationTreeNode.ImageIndex         = ImageDocumentationIndex;
            documentationTreeNode.SelectedImageIndex = ImageDocumentationIndex;
            documentationTreeNode.StateImageIndex    = ImageDocumentationIndex;
            recipeTreeNode.Nodes.Add(documentationTreeNode);
        }
Example #4
0
        /// <summary>
        /// Adds a history recipe execution entry.
        /// </summary>
        private void AddHistoryRecipeEntry(GuidanceNavigatorManager.RecipeExecutionHistory recipeExecutionHistory)
        {
            Recipe recipe = guidanceNavigatorManager.GetRecipeConfiguration(selectedGuidancePackage, recipeExecutionHistory.RecipeName);

            if (recipe == null)
            {
                return;
            }

            ExtendedTreeNode recipeTreeNode = new ExtendedTreeNode();

            recipeTreeNode.Text            = recipe.Caption;
            recipeTreeNode.ToolTipText     = recipe.Description;
            recipeTreeNode.Tag             = recipeExecutionHistory;
            recipeTreeNode.ShowCloseButton = true;

            ExtendedTreeNode suggestedRecipesTreeNode = new ExtendedTreeNode();

            suggestedRecipesTreeNode.StateImageIndex    = ImageDocumentationIndex;
            suggestedRecipesTreeNode.ImageIndex         = ImageDocumentationIndex;
            suggestedRecipesTreeNode.SelectedImageIndex = ImageDocumentationIndex;
            suggestedRecipesTreeNode.ShowAsLink         = false;
            suggestedRecipesTreeNode.Text = Properties.Resources.Navigator_NextStepsTitle;

            // Recipe Documentation Nodes
            if (recipe.DocumentationLinks != null)
            {
                foreach (Link documentationLink in recipe.DocumentationLinks)
                {
                    if (documentationLink.Kind == DocumentationKind.Documentation)
                    {
                        AddDocumentationNode(recipeTreeNode, documentationLink);
                    }
                    else if (documentationLink.Kind == DocumentationKind.NextStep)
                    {
                        AddDocumentationNode(suggestedRecipesTreeNode, documentationLink);
                    }
                }
            }

            AddExecuteRecipeHistoryNode(recipe, recipeTreeNode);

            if (suggestedRecipesTreeNode.Nodes.Count > 0)
            {
                recipeTreeNode.Nodes.Add(suggestedRecipesTreeNode);
            }

            // collapse all history entries and show expand just the latest entry.
            this.historyRecipesTreeView.CollapseAll();
            recipeTreeNode.ExpandAll();
            this.historyRecipesTreeView.Nodes.Add(recipeTreeNode);
            historyRecipesTreeView.SelectedNode = recipeTreeNode;
        }
Example #5
0
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.TreeView.DrawNode"></see> event.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Windows.Forms.DrawTreeNodeEventArgs"></see> that contains the event data.</param>
        protected override void OnDrawNode(DrawTreeNodeEventArgs e)
        {
            base.OnDrawNode(e);

            ExtendedTreeNode customTreeNode = e.Node as ExtendedTreeNode;
            Font             nodeFont       = (e.Node.NodeFont != null) ? e.Node.NodeFont : this.Font;
            Color            nodeColor      = (((e.State & TreeNodeStates.Selected) == TreeNodeStates.Selected) && e.Node.TreeView.Focused) ? SystemColors.HighlightText : ((e.Node.ForeColor != Color.Empty) ? e.Node.ForeColor : e.Node.TreeView.ForeColor);

            bool  showAsLink = (customTreeNode != null && customTreeNode.ShowAsLink);
            Brush textBrush  = SystemBrushes.MenuText;

            if (showAsLink)
            {
                nodeFont  = new Font(nodeFont, FontStyle.Underline);
                textBrush = Brushes.Navy;
                nodeColor = Color.Navy;
            }

            // Draw the background and node text for a selected node.
            if ((e.State & TreeNodeStates.Selected) != 0 || (e.State & TreeNodeStates.Focused) != 0)
            {
                Rectangle hoverRectangle = new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);
                e.Graphics.FillRectangle(SystemBrushes.Highlight, hoverRectangle);
                TextRenderer.DrawText(e.Graphics, e.Node.Text, nodeFont, e.Bounds, SystemColors.HighlightText, TextFormatFlags.VerticalCenter);
            }
            // Use the default background and node text.
            else
            {
                e.Graphics.FillRectangle(SystemBrushes.Window, NodeBounds(e.Node));
                TextRenderer.DrawText(e.Graphics, e.Node.Text, nodeFont, e.Bounds, nodeColor, TextFormatFlags.VerticalCenter);
            }

            Rectangle closeButtonRectangle = new Rectangle(e.Bounds.X + e.Bounds.Width, e.Bounds.Y, this.Bounds.Width - (e.Bounds.X + e.Bounds.Width) - verticalScrollPadding, e.Bounds.Height);

            e.Graphics.FillRectangle(SystemBrushes.Window, closeButtonRectangle);

            if (customTreeNode != null && customTreeNode.ShowCloseButton)
            {
                // Fix for more than 96dpi screen resolutions.
                if (SystemFonts.IconTitleFont.Size > closeButtonFont.Size)
                {
                    closeButtonFont = SystemFonts.IconTitleFont;
                }

                TextRenderer.DrawText(e.Graphics, "x", closeButtonFont, closeButtonRectangle, SystemColors.WindowText, TextFormatFlags.Right);
            }

            this.ResumeLayout();
        }
Example #6
0
        /// <summary>
        /// Determines whether is mouse is over a linkeable node.
        /// </summary>
        /// <param name="e">The <see cref="T:System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
        /// <returns>
        ///     <c>true</c> if [is on linkeable node] [the specified e]; otherwise, <c>false</c>.
        /// </returns>
        public bool IsOnLinkeableNode(MouseEventArgs e)
        {
            TreeNode         selectedNode   = base.GetNodeAt(e.X, e.Y);
            ExtendedTreeNode customTreeNode = selectedNode as ExtendedTreeNode;

            if (customTreeNode != null && customTreeNode.ShowAsLink)
            {
                if (e.X > customTreeNode.Bounds.Left && e.X < customTreeNode.Bounds.Right)
                {
                    return(true);
                }
            }

            return(false);
        }
Example #7
0
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Control.MouseClick"></see> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.Windows.Forms.MouseEventArgs"></see> that contains the event data.</param>
        protected override void OnMouseClick(MouseEventArgs e)
        {
            base.OnMouseClick(e);

            TreeNode         selectedNode   = base.GetNodeAt(e.X, e.Y);
            ExtendedTreeNode customTreeNode = selectedNode as ExtendedTreeNode;

            if (IsOnCloseButton(e))
            {
                if (this.NodeClose != null)
                {
                    this.NodeClose(this, new TreeNodeMouseClickEventArgs(customTreeNode, e.Button, e.Clicks, e.X, e.Y));
                }
            }
        }
Example #8
0
        /// <summary>
        /// Determines whether is mouse over a close button.
        /// </summary>
        /// <param name="e">The <see cref="T:System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
        /// <returns>
        ///     <c>true</c> if [is on close button] [the specified e]; otherwise, <c>false</c>.
        /// </returns>
        public bool IsOnCloseButton(MouseEventArgs e)
        {
            TreeNode         selectedNode   = base.GetNodeAt(e.X, e.Y);
            ExtendedTreeNode customTreeNode = selectedNode as ExtendedTreeNode;

            if (customTreeNode != null && customTreeNode.ShowCloseButton)
            {
                SizeF closeButtonSize;
                int   leftPosition;
                int   topPosition;
                GetCloseButtonPosition(customTreeNode, out leftPosition, out topPosition, out closeButtonSize);

                if (e.X >= leftPosition && e.X <= leftPosition + (int)closeButtonSize.Width + 5)
                {
                    if (e.Y >= topPosition - 5 && e.Y <= topPosition + (int)closeButtonSize.Height - 5)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Example #9
0
        /// <summary>
        /// Updates the available guidance.
        /// </summary>
        private void UpdateAvailableGuidance()
        {
            if (selectedGuidancePackage == null)
            {
                return;
            }

            this.SuspendLayout();
            availableRecipesTreeView.Nodes.Clear();
            Dictionary <String, IAssetReference> references = GetAvailableReferencesCache();

            foreach (IAssetReference assetReference in references.Values)
            {
                ExtendedTreeNode recipeTreeNode = null;

                recipeTreeNode = new ExtendedTreeNode();
                Recipe recipe = guidanceNavigatorManager.GetRecipeConfiguration(selectedGuidancePackage, assetReference.AssetName);

                string caption    = assetReference.Caption;
                int    imageIndex = ImageRecipeIndex;

                if (assetReference is BoundTemplateReference || assetReference is UnboundTemplateReference)
                {
                    caption    = string.Format(Properties.Resources.Navigator_TemplateCaptionMask, assetReference.Caption);
                    imageIndex = ImageTemplateIndex;
                    if (!String.IsNullOrEmpty(assetReference.Description))
                    {
                        recipeTreeNode.ToolTipText = assetReference.Description;
                    }
                }

                recipeTreeNode.Text               = caption;
                recipeTreeNode.Tag                = recipe;
                recipeTreeNode.ShowCloseButton    = false;
                recipeTreeNode.ImageIndex         = imageIndex;
                recipeTreeNode.SelectedImageIndex = imageIndex;
                recipeTreeNode.StateImageIndex    = imageIndex;

                // Bound template references doesn't have an associated recipe
                if (recipe != null)
                {
                    if (!String.IsNullOrEmpty(recipe.Description))
                    {
                        recipeTreeNode.ToolTipText = recipe.Description;
                    }

                    // Recipe Documentation Nodes
                    if (recipe.DocumentationLinks != null)
                    {
                        foreach (Link documentationLink in recipe.DocumentationLinks)
                        {
                            if (documentationLink.Kind == DocumentationKind.Documentation)
                            {
                                AddDocumentationNode(recipeTreeNode, documentationLink);
                            }
                        }
                    }
                }
                AddExecuteRecipeNode(assetReference, recipeTreeNode);
                availableRecipesTreeView.Nodes.Add(recipeTreeNode);
            }

            this.ResumeLayout();
        }