Example #1
0
        public static void SetBackgroundGradient(
            StyleSet classStyleSet,
            Color backgroundGradientColor,
            Color backgroundSelectedGradientColor,
            Color backgroundSelectedInactiveGradientColor,
            Diagram diagram,
            string surfaceTitle)
        {
            #region Set background gradient style and shape attributes

            // Fill brush settings for background (Start gradient color).
            BrushSettings backgroundBrush = new BrushSettings();
            backgroundBrush.Color = backgroundGradientColor;
            classStyleSet.OverrideBrush(DiagramBrushes.ShapeBackground, backgroundBrush);
            // Selected state
            backgroundBrush       = new BrushSettings();
            backgroundBrush.Color = backgroundSelectedGradientColor;
            classStyleSet.OverrideBrush(DiagramBrushes.ShapeBackgroundSelected, backgroundBrush);
            // SelectedInactive state
            backgroundBrush       = new BrushSettings();
            backgroundBrush.Color = backgroundSelectedInactiveGradientColor;
            classStyleSet.OverrideBrush(DiagramBrushes.ShapeBackgroundSelectedInactive, backgroundBrush);

            // We should find a "Background" field created when we set the
            // HasBackgroundGradient property to "true"
            AreaField background = diagram.FindShapeField("Background") as AreaField;
            if (background != null)
            {
                background.DefaultReflectParentSelectedState = true;
                //background.AnchoringBehavior.SetBottomAnchor(AnchoringBehavior.Edge.Bottom, diagram.MaximumSize.Height / 2);
            }

            #endregion

            #region Set Diagram font and text attributes

            // Custom font styles for diagram title
            FontSettings fontSettings;
            fontSettings       = new FontSettings();
            fontSettings.Style = FontStyle.Bold;
            fontSettings.Size  = 9 / 72.0F;
            classStyleSet.OverrideFont(DiagramFonts.ShapeTitle, fontSettings);

            // Create a text field for the Diagram Title
            TextField textField = new TextField("DiagramTitle");
            textField.DefaultText       = surfaceTitle;
            textField.DefaultVisibility = true;
            textField.DefaultAutoSize   = true;
            textField.DefaultFontId     = DiagramFonts.ShapeTitle;
            textField.AnchoringBehavior.SetLeftAnchor(AnchoringBehavior.Edge.Left, 0.33);
            textField.AnchoringBehavior.SetTopAnchor(AnchoringBehavior.Edge.Top, 0.07);

            diagram.ShapeFields.Add(textField);

            #endregion
        }
Example #2
0
        /// <summary>
        /// Initializes the Resources for the background.
        /// </summary>
        private void InitializeBackgroundResources(StyleSet styleSet)
        {
            ITailoredBackgroundStyles styles = this.GetBackgroundStyles();

            Color gradientStartColor     = styles.TitleGradientFillColor;
            Color gradientEndColor       = Color.Transparent;
            Color selectedColor          = gradientStartColor;
            Color selectedInnactiveColor = gradientStartColor;

            // Title Text
            DiagramTitleField.InitializeInstanceResources(styleSet, TitleFontSize, styles.TitleTextColor);

            // Background color
            BrushSettings backgroundBrush = new BrushSettings();

            backgroundBrush.Color = styles.BackgroundFillColor;
            styleSet.OverrideBrush(DiagramBrushes.DiagramBackground, backgroundBrush);

            // Start of title gradient
            BrushSettings titleGradientBrush = new BrushSettings();

            titleGradientBrush.Color = gradientStartColor;
            styleSet.OverrideBrush(DiagramBrushes.ShapeBackground, titleGradientBrush);

            // Selected state
            titleGradientBrush       = new BrushSettings();
            titleGradientBrush.Color = selectedColor;
            styleSet.OverrideBrush(DiagramBrushes.ShapeBackgroundSelected, titleGradientBrush);

            // SelectedInactive state
            titleGradientBrush       = new BrushSettings();
            titleGradientBrush.Color = selectedInnactiveColor;
            styleSet.OverrideBrush(DiagramBrushes.ShapeBackgroundSelectedInactive, titleGradientBrush);

            // Find the field for the background
            AreaField background = this.FindShapeField(DiagramBackgroundShapeName) as AreaField;

            if (background != null)
            {
                background.DefaultReflectParentSelectedState = true;
                background.GradientEndingColor = gradientEndColor;

                // Constrain the height of the shape
                background.AnchoringBehavior.SetBottomAnchor(AnchoringBehavior.Edge.Bottom, (this.MaximumSize.Height - GradientHeight));
            }
        }
Example #3
0
        protected override void InitializeShapeFields(IList <ShapeField> shapeFields)
        {
            AreaField bkg = this.CreateBackgroundGradientField(FIELD_NAME_ACTIVE_TAB_BACKGROUND);

            bkg.DefaultFocusable         = false;
            bkg.DefaultSelectable        = false;
            bkg.DefaultVisibility        = true;
            bkg.DrawBorder               = false;
            bkg.FillBackground           = true;
            bkg.DefaultBackgroundBrushId = m_backgroundBrushId;
            bkg.AnchoringBehavior.SetTopAnchor(AnchoringBehavior.Edge.Top, 0.0);
            bkg.AnchoringBehavior.SetLeftAnchor(AnchoringBehavior.Edge.Left, 0.0);
            bkg.AnchoringBehavior.SetRightAnchor(AnchoringBehavior.Edge.Right, 0.0);
            bkg.AnchoringBehavior.SetBottomAnchor(AnchoringBehavior.Edge.Bottom, 0.0);
            shapeFields.Add(bkg);

            base.InitializeShapeFields(shapeFields);
        }
        /// <summary>
        /// Overridden to allow a read-only <see cref="T:Microsoft.VisualStudio.Modeling.Diagrams.ListField"/> to be added
        /// to the collection of <see cref="T:Microsoft.VisualStudio.Modeling.Diagrams.ShapeField"/> objects.
        /// </summary>
        /// <param name="shapeFields">A list of <see cref="T:Microsoft.VisualStudio.Modeling.Diagrams.ShapeField"/> objects
        /// which belong to the current shape.</param>
        protected override void InitializeShapeFields(IList <ShapeField> shapeFields)
        {
            base.InitializeShapeFields(shapeFields);
            // Removes the PlusMinusButtonField because we don't want the compartment expanded and collapsed.
            shapeFields.RemoveAt(2);

            //// Removes the HdrText fields because we don't need to see 'Columns' on every shape.
            shapeFields.RemoveAt(2);
            AreaField         headerField = (AreaField)shapeFields[1];
            AnchoringBehavior anchor      = headerField.AnchoringBehavior;

            anchor.ClearBottomAnchor();
            anchor.SetTopAnchor(AnchoringBehavior.Edge.Top, 0d);
            headerField.DefaultHeight = 1.5 / 72d;

            // The main list field is anchored off the header, which no longer has a bottom anchor.
            // Anchor directly to the top at the same size as the header field
            anchor = shapeFields[2].AnchoringBehavior;
            anchor.SetTopAnchor(AnchoringBehavior.Edge.Top, 1.5 / 72d);
        }
Example #5
0
        /// <summary>
        /// Initialize the collection of shape fields associated with this shape type.
        /// </summary>
        /// <param name="shapeFields"></param>
        protected override void InitializeShapeFields(IList <ShapeField> shapeFields)
        {
            base.InitializeShapeFields(shapeFields);

            AreaField area = new AreaField("HeaderArea", 0f);

            area.DrawBorder                        = false;
            area.DefaultVisibility                 = true;
            area.DefaultAccessibleDescription      = "Component Header";
            area.FillBackground                    = true;
            area.GradientEndingColor               = Color.White;
            area.DefaultLinearGradientMode         = LinearGradientMode.Vertical;
            area.DefaultBackgroundBrushId          = headerBackgroundBrushId;
            area.DefaultFocusable                  = false;
            area.DefaultReflectParentSelectedState = false;
            area.DefaultSelectable                 = false;
            area.AnchoringBehavior.SetTopAnchor(AnchoringBehavior.Edge.Top, 0.01);
            area.AnchoringBehavior.SetLeftAnchor(AnchoringBehavior.Edge.Left, 0.01);
            area.AnchoringBehavior.SetRightAnchor(AnchoringBehavior.Edge.Right, 0.01);
            area.DefaultHeight = HEADER_HEIGHT - 0.01;
            shapeFields.Insert(0, area);
        }
Example #6
0
        protected override void InitializeShapeFields(IList <ShapeField> shapeFields)
        {
            double vertMargin     = 0.01;
            double horiMargin     = 0.02;
            double marginToParent = 0.01;

            // ++ HEAD ++
            AreaField head = this.CreateBackgroundGradientField(FieldName_Head);

            head.DefaultFocusable  = false;
            head.DefaultSelectable = false;
            head.DefaultVisibility = true;
            head.DrawBorder        = false;
            head.FillBackground    = true;
            //head.GradientEndingColor = Color;
            head.DefaultBackgroundBrushId = m_headFootBrushId;
            head.AnchoringBehavior.SetTopAnchor(AnchoringBehavior.Edge.Top, marginToParent);
            head.AnchoringBehavior.SetLeftAnchor(AnchoringBehavior.Edge.Left, marginToParent);
            head.AnchoringBehavior.SetRightAnchor(AnchoringBehavior.Edge.Right, marginToParent);
            //head.AnchoringBehavior.SetBottomAnchor(AnchoringBehavior.Edge.Bottom, marginToParent);
            head.DefaultHeight = 0.15;
            shapeFields.Add(head);

            // ++ OpenTag ++
            HtmlTagTextField openTag = new HtmlTagTextField(FieldName_OpenTag);

            openTag.DefaultFocusable  = true;
            openTag.DefaultSelectable = true;
            openTag.DefaultVisibility = true;
            openTag.DefaultAutoSize   = true;
            openTag.DrawBorder        = false;
            openTag.FillBackground    = false;
            openTag.AnchoringBehavior.SetTopAnchor(AnchoringBehavior.Edge.Top, vertMargin);
            openTag.AnchoringBehavior.SetLeftAnchor(AnchoringBehavior.Edge.Left, marginToParent);
            openTag.AnchoringBehavior.MinimumHeightInLines     = 1;
            openTag.AnchoringBehavior.MinimumWidthInCharacters = 1;
            openTag.DefaultFontId = m_FontId;
            shapeFields.Add(openTag);

            // ++ Text ++
            TextField tagText = new TextField(FieldName_Text);

            tagText.DefaultFocusable  = true;
            tagText.DefaultSelectable = true;
            tagText.DefaultVisibility = true;
            tagText.DefaultAutoSize   = true;
            tagText.DrawBorder        = false;
            tagText.FillBackground    = false;
            tagText.AnchoringBehavior.SetTopAnchor(AnchoringBehavior.Edge.Top, vertMargin);
            tagText.AnchoringBehavior.SetLeftAnchor(openTag, AnchoringBehavior.Edge.Right, horiMargin);
            tagText.AnchoringBehavior.MinimumHeightInLines = 1;
            //tagText.AnchoringBehavior.MinimumWidthInCharacters = 1;
            tagText.AnchoringBehavior.InvisibleCollapseFlags = InvisibleCollapseFlags.HorizontallyToLeft;
            shapeFields.Add(tagText);

            // ++ Close Tag in Header
            TextField closeTag = new TextField(FieldName_HeaderCloseTag);

            closeTag.DefaultFocusable  = false;
            closeTag.DefaultSelectable = false;
            closeTag.DefaultVisibility = true;
            closeTag.DefaultAutoSize   = true;
            closeTag.DrawBorder        = false;
            closeTag.FillBackground    = false;
            closeTag.AnchoringBehavior.SetTopAnchor(AnchoringBehavior.Edge.Top, vertMargin);
            closeTag.AnchoringBehavior.SetLeftAnchor(tagText, AnchoringBehavior.Edge.Right, horiMargin);
            closeTag.AnchoringBehavior.InvisibleCollapseFlags = InvisibleCollapseFlags.HorizontallyToLeft;
            closeTag.AnchoringBehavior.MinimumHeightInLines   = 1;
            //closeTag.AnchoringBehavior.MinimumWidthInCharacters = 1;
            closeTag.DefaultFontId = m_FontId;
            shapeFields.Add(closeTag);

            // ++ Foot ++
            AreaField footer = this.CreateBackgroundGradientField(FieldName_Foot);

            footer.DefaultFocusable  = false;
            footer.DefaultSelectable = false;
            footer.DefaultVisibility = false;
            footer.DrawBorder        = false;
            footer.FillBackground    = true;
            //item.GradientEndingColor = Color.Red;
            footer.DefaultBackgroundBrushId = m_headFootBrushId;
            //item.AnchoringBehavior.SetBottomAnchor(AnchoringBehavior.Edge.Bottom, 0.0); //!!!! this doesn't work!!, user negative top anchor to bypass
            footer.AnchoringBehavior.SetTopAnchor(AnchoringBehavior.Edge.Bottom, -0.2);
            footer.AnchoringBehavior.SetLeftAnchor(AnchoringBehavior.Edge.Left, marginToParent);
            footer.AnchoringBehavior.SetRightAnchor(AnchoringBehavior.Edge.Right, marginToParent);
            footer.DefaultHeight = 0.15;
            shapeFields.Add(footer);

            // ++ close tag in footer ++
            TextField closeTag2 = new TextField(FieldName_FooterCloseTag);

            closeTag2.DefaultFocusable  = false;
            closeTag2.DefaultSelectable = false;
            closeTag2.DefaultVisibility = false;
            closeTag2.DefaultAutoSize   = true;
            closeTag2.DrawBorder        = false;
            closeTag2.FillBackground    = false;
            closeTag2.AnchoringBehavior.SetBottomAnchor(AnchoringBehavior.Edge.Bottom, vertMargin);
            closeTag2.AnchoringBehavior.SetLeftAnchor(AnchoringBehavior.Edge.Left, marginToParent);
            closeTag2.AnchoringBehavior.MinimumHeightInLines     = 1;
            closeTag2.AnchoringBehavior.MinimumWidthInCharacters = 1;
            closeTag2.DefaultFontId = m_FontId;
            shapeFields.Add(closeTag2);

            base.InitializeShapeFields(shapeFields);
        }