Esempio n. 1
0
 public WrappedTextField(TextField prototype)
     : base(prototype.Name)
 {
     // Copy the starting properties form the prototype
     DefaultText         = prototype.DefaultText;
     DefaultFocusable    = prototype.DefaultFocusable;
     DefaultAutoSize     = false;
     DefaultMultipleLine = true;
     AnchoringBehavior.Clear();
     AnchoringBehavior.CenterHorizontally(  );
     AnchoringBehavior.CenterVertically(  );
     DefaultAccessibleState = prototype.DefaultAccessibleState;
 }
        /// <summary>
        /// Associate the value of the text field with a property
        /// specified by the derived class. Called one per class type.
        /// </summary>
        /// <param name="shapeFields">ShapeFieldCollection to initialized</param>
        protected override void InitializeShapeFields(IList <ShapeField> shapeFields)
        {
            Store             store     = Store;
            AutoSizeTextField textField = CreateAutoSizeTextField("TextField");

            textField.AssociateValueWith(Store, AssociatedModelDomainPropertyId);
            textField.DefaultFocusable = true;
            shapeFields.Add(textField);

            // Adjust anchoring after all shape fields are added
            AnchoringBehavior anchor = textField.AnchoringBehavior;

            anchor.CenterHorizontally();
            anchor.CenterVertically();

            Debug.Assert(TextShapeField == null);             // This should only be called once per type
            TextShapeField = textField;
        }
        /// <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);
        }
Esempio n. 4
0
            private static void setAnchor(VDWidgetShape parentShape, VDContainer thisMEL, VDContainerShape thisPEL, 
                bool setAnchor, VDWidget sibling, AnchoringBehavior.Edge edge)
            {
                if (!setAnchor) return;

                if (sibling != null) // anchor to sibling
                {
                    VDWidgetShape siblingShape = parentShape.GetChildShape<VDWidgetShape>(sibling);
                    if (siblingShape != null)
                    {
                        switch (edge)
                        {
                            case AnchoringBehavior.Edge.Bottom:
                                thisPEL.Anchoring.SetBottomAnchor(siblingShape, AnchoringBehavior.Edge.Top, thisMEL.BottomMargin);
                                break;
                            case AnchoringBehavior.Edge.Left:
                                thisPEL.Anchoring.SetLeftAnchor(siblingShape, AnchoringBehavior.Edge.Right, thisMEL.LeftMargin);
                                break;
                            case AnchoringBehavior.Edge.Right:
                                thisPEL.Anchoring.SetRightAnchor(siblingShape, AnchoringBehavior.Edge.Left, thisMEL.RightMargin);
                                break;
                            case AnchoringBehavior.Edge.Top:
                                thisPEL.Anchoring.SetTopAnchor(siblingShape, AnchoringBehavior.Edge.Bottom, thisMEL.TopMargin);
                                break;
                        }
                    }
                }
                else // anchor to parent
                {
                    switch (edge)
                    {
                        case AnchoringBehavior.Edge.Bottom:
                            thisPEL.Anchoring.SetBottomAnchor(edge, thisMEL.BottomMargin);
                            break;
                        case AnchoringBehavior.Edge.Left:
                            thisPEL.Anchoring.SetLeftAnchor(edge, thisMEL.LeftMargin);
                            break;
                        case AnchoringBehavior.Edge.Right:
                            thisPEL.Anchoring.SetRightAnchor(edge, thisMEL.RightMargin);
                            break;
                        case AnchoringBehavior.Edge.Top:
                            thisPEL.Anchoring.SetTopAnchor(edge, thisMEL.TopMargin);
                            break;
                    }
                }
            }