// The class is double-derived so that we can override this method. // Called once for each class. protected override void InitializeDecorators(IList <ShapeField> shapeFields, IList <Decorator> decorators) { // TODO: Allow user to change text align. // Set up the decorators defined in the DSL Definition: base.InitializeDecorators(shapeFields, decorators); //this.HasShadow = false; // Look up the text decorator, which is called "Comment". TextField commentField = (TextField)ShapeElement.FindShapeField(shapeFields, "Comment"); // This sets the wrapping behavior, but we need a couple of other things too: commentField.DefaultMultipleLine = true; // Autosize is incompatible with multiple line: commentField.DefaultAutoSize = false; //commentField.AllowInPlaceEditorAutoSize(this); // Need to anchor the field sides to the parent box to get sensible size: commentField.AnchoringBehavior.Clear(); commentField.AnchoringBehavior.SetLeftAnchor(AnchoringBehavior.Edge.Left, 0.01); commentField.AnchoringBehavior.SetRightAnchor(AnchoringBehavior.Edge.Right, 0.01); commentField.AnchoringBehavior.SetTopAnchor(AnchoringBehavior.Edge.Top, 0.01); commentField.AnchoringBehavior.SetBottomAnchor(AnchoringBehavior.Edge.Bottom, 0.01); // Note that this method is called just once per class. // commentField is a field definition, attached to the class, not instances. }
/// <summary>Associate shape field's content and visibility with IMS properties</summary> /// <param name="shape">The shape containing the shape field</param> /// <param name="fieldname">Field name</param> /// <param name="valuePropertyId">property to associate with the content of shape field</param> /// <param name="isValuePropertyOfShape">does 'valuePropertyId' belong to a shape object (PEL, not MEL)</param> /// <param name="visibilityPropertyId">property to associate with the visibility of shape field</param> /// <param name="isVisibilityPropOfShape">does 'visibilityPropertyId' belong to a shape object, instead of a MEL</param> /// <param name="visibilityFiltervalues">values to filter the visibility</param> static protected void associateProperty(ShapeElement shape, string fieldname, Guid valuePropertyId, bool isValuePropertyOfShape, /* associate value */ Guid visibilityPropertyId, bool isVisibilityPropOfShape, params object[] visibilityFiltervalues) /* associate visibility*/ { if (valuePropertyId != Guid.Empty) { AssociatedPropertyInfo propertyInfo = new AssociatedPropertyInfo(valuePropertyId); propertyInfo.IsShapeProperty = isValuePropertyOfShape; ShapeElement.FindShapeField(shape.ShapeFields, fieldname).AssociateValueWith(shape.Store, propertyInfo); } if (visibilityPropertyId != Guid.Empty) { AssociatedPropertyInfo propertyInfo = new AssociatedPropertyInfo(visibilityPropertyId); propertyInfo.IsShapeProperty = isVisibilityPropOfShape; if (visibilityFiltervalues != null) { for (int i = 0; i < visibilityFiltervalues.Length; i++) { propertyInfo.FilteringValues.Add(visibilityFiltervalues[i]); } } ShapeElement.FindShapeField(shape.ShapeFields, fieldname).AssociateVisibilityWith(shape.Store, propertyInfo); } }
/// <summary> /// Initialize the collection of decorators associated with this shape type. This method also /// creates shape fields for outer decorators, because these are not part of the shape fields collection /// associated with the shape, so they must be created here rather than in InitializeShapeFields. /// </summary> //protected override void InitializeDecorators(global::System.Collections.Generic.IList<ShapeField> shapeFields, global::System.Collections.Generic.IList<Decorator> decorators) //{ // base.InitializeDecorators(shapeFields, decorators); //} internal static void BindShapeFields(object sender, EventArgs e) { ShapeElement shape = (ShapeElement)sender; ShapeElement.FindShapeField(shape.ShapeFields, "WidgetTitleText").AssociateValueWith(shape.Store, new AssociatedPropertyInfo( VDWidgetShape.titleTextDomainPropertyId, new PresentationDomainNavigator(presentationToDomain), new DomainPresentationNavigator(domainToRelativePresentation)) { IsShapeProperty = true } ); ShapeElement.FindShapeField(shape.ShapeFields, "WidgetTitleIcon").AssociateValueWith(shape.Store, new AssociatedPropertyInfo( VDWidgetShape.titleIconDomainPropertyId, new PresentationDomainNavigator(presentationToDomain), new DomainPresentationNavigator(domainToRelativePresentation)) { IsShapeProperty = true } ); Guid[] propIds = { VDWidgetShape.titleIcon0DomainPropertyId, VDWidgetShape.titleIcon1DomainPropertyId, VDWidgetShape.titleIcon2DomainPropertyId, VDWidgetShape.titleIcon3DomainPropertyId, VDWidgetShape.titleIcon4DomainPropertyId, }; for (int i = 0; i < VDWidgetTitlePort.ADDITIONAL_TITLE_ICON_COUNT; i++) { ShapeElement.FindShapeField(shape.ShapeFields, "WidgetTitleIcon" + i).AssociateValueWith(shape.Store, new AssociatedPropertyInfo( propIds[i], new PresentationDomainNavigator(presentationToDomain), new DomainPresentationNavigator(domainToRelativePresentation)) { IsShapeProperty = true } ); } ShapeElement.FindShapeField(shape.ShapeFields, "WidgetTitlePinIcon").AssociateValueWith(shape.Store, new AssociatedPropertyInfo( VDWidgetShape.isPinnedDomainPropertyId, new PresentationDomainNavigator(presentationToDomain), new DomainPresentationNavigator(domainToRelativePresentation)) { IsShapeProperty = true } ); }
/// <summary> /// Initialize the collection of decorators associated with this shape type. This method also /// creates shape fields for outer decorators, because these are not part of the shape fields collection /// associated with the shape, so they must be created here rather than in InitializeShapeFields. /// </summary> protected override void InitializeDecorators(IList <ShapeField> shapeFields, IList <Decorator> decorators) { Guard.NotNull(() => shapeFields, shapeFields); Guard.NotNull(() => decorators, decorators); base.InitializeDecorators(shapeFields, decorators); var frameField = ShapeElement.FindShapeField(shapeFields, DiagramTitleShapeName); decorators.Add(new ShapeDecorator(frameField, ShapeDecoratorPosition.InnerTopLeft, titleLocation)); }
static partial void onBindShapeFields(object sender, EventArgs e) { ShapeElement shape = (ShapeElement)sender; AssociatedPropertyInfo propInfo = new AssociatedPropertyInfo(VDTabHeadShape.isActiveTabDomainPropertyId); propInfo.IsShapeProperty = true; propInfo.FilteringValues.Add(true); ShapeElement.FindShapeField(shape.ShapeFields, FIELD_NAME_ACTIVE_TAB_BACKGROUND).AssociateVisibilityWith(shape.Store, propInfo); }
public override RectangleD GetCompliantBounds(ShapeElement portShape, RectangleD proposedBounds) { if (portShape == null) { throw new ArgumentNullException("portShape"); } VDWidgetShape parentShape = portShape.ParentShape as VDWidgetShape; if (parentShape == null || portShape.Store.InUndoRedoOrRollback) { return(proposedBounds); } PointD location = new PointD(0, -portShape.DefaultSize.Height - portShape.OutlinePenWidth * 2); SizeD size = portShape.DefaultSize; TextField titleTextField = portShape.FindShapeField("WidgetTitleText") as TextField; if (titleTextField != null) { size.Width = titleTextField.GetMinimumSize(portShape).Width; size.Width += size.Height + 0.03; } if (parentShape.HasWidgetTitleIcon) { size.Width += size.Height + 0.02; // add more space for icon } for (int i = 0; i < ADDITIONAL_TITLE_ICON_COUNT; i++) { // add more space for additional title icon if (parentShape.HasAdditionalWidgetTitleIcon(i)) { size.Width += size.Height + 0.02; } } // should be smaller than parent shape if (size.Width > parentShape.Size.Width) { size.Width = parentShape.Size.Width; } return(new RectangleD(location, size)); }
//Called once for each shape instance. protected override void InitializeDecorators(IList <ShapeField> shapeFields, IList <Decorator> decorators) { base.InitializeDecorators(shapeFields, decorators); //Look up the shape field, which is called "Comment." TextField commentField = (TextField)ShapeElement.FindShapeField(shapeFields, "Comment"); // Allow multiple lines of text. commentField.DefaultMultipleLine = true; // Autosize not supported for multi-line fields. commentField.DefaultAutoSize = false; // Anchor the field slightly inside the container shape. commentField.AnchoringBehavior.Clear(); commentField.AnchoringBehavior.SetLeftAnchor(AnchoringBehavior.Edge.Left, 0.01); commentField.AnchoringBehavior.SetRightAnchor(AnchoringBehavior.Edge.Right, 0.01); commentField.AnchoringBehavior.SetTopAnchor(AnchoringBehavior.Edge.Top, 0.01); commentField.AnchoringBehavior.SetBottomAnchor(AnchoringBehavior.Edge.Bottom, 0.01); }
public override RectangleD GetCompliantBounds(ShapeElement portShape, RectangleD proposedBounds) { if (portShape == null) { throw new ArgumentNullException("portShape"); } VDWidgetShape parentShape = portShape.ParentShape as VDWidgetShape; if (parentShape == null || portShape.Store.InUndoRedoOrRollback) { return proposedBounds; } PointD location = new PointD(0, -portShape.DefaultSize.Height - portShape.OutlinePenWidth * 2); SizeD size = portShape.DefaultSize; TextField titleTextField = portShape.FindShapeField("WidgetTitleText") as TextField; if (titleTextField != null) { size.Width = titleTextField.GetMinimumSize(portShape).Width; size.Width += size.Height + 0.03; } if (parentShape.HasWidgetTitleIcon) { size.Width += size.Height + 0.02; // add more space for icon } for (int i = 0; i < ADDITIONAL_TITLE_ICON_COUNT; i++) { // add more space for additional title icon if (parentShape.HasAdditionalWidgetTitleIcon(i)) { size.Width += size.Height + 0.02; } } // should be smaller than parent shape if (size.Width > parentShape.Size.Width) size.Width = parentShape.Size.Width; return new RectangleD(location, size); }