public override AppliedProperties GetAppliedProperties(IDataModel dataModel, bool ignoreDynamic = false) { var applied = new AppliedProperties { X = X, Y = Y, Width = Width, Height = Height, Opacity = Opacity, Brush = Brush.CloneCurrentValue() }; if (ignoreDynamic) { return(applied); } foreach (var dynamicProperty in DynamicProperties) { dynamicProperty.ApplyProperty(dataModel, ref applied); } if (Math.Abs(applied.Opacity - 1) > 0.001) { applied.Brush = Brush.CloneCurrentValue(); applied.Brush.Opacity = applied.Opacity; } return(applied); }
internal void ApplyProperty(IDataModel dataModel, ref AppliedProperties properties) { if (LayerPropertyType == LayerPropertyType.PercentageOf) { ApplyPercentageOf(dataModel, ref properties, PercentageSource); } if (LayerPropertyType == LayerPropertyType.PercentageOfProperty) { ApplyPercentageOfProperty(dataModel, ref properties); } }
private void ApplyHeight(ref AppliedProperties properties, double percentage) { var newHeight = percentage * properties.Height; var difference = properties.Height - newHeight; properties.Height = newHeight; if (LayerPropertyOptions == LayerPropertyOptions.Downwards) { properties.Y = properties.Y + difference; } }
private void ApplyWidth(ref AppliedProperties properties, double percentage) { var newWidth = percentage * properties.Width; var difference = properties.Width - newWidth; properties.Width = newWidth; // Apply the right to left option if (LayerPropertyOptions == LayerPropertyOptions.RightToLeft) { properties.X = properties.X + difference; } }
private void ApplyOpacity(ref AppliedProperties properties, double percentage) { properties.Opacity = percentage * properties.Opacity; if (properties.Opacity < 0.0) { properties.Opacity = 0.0; } if (properties.Opacity > 1.0) { properties.Opacity = 1.0; } // Apply the inverse/decrease option if (LayerPropertyOptions == LayerPropertyOptions.Decrease) { properties.Opacity = 1.0 - properties.Opacity; } }
private void ApplyPercentageOf(IDataModel dataModel, ref AppliedProperties properties, double src) { if (GameProperty == null) { return; } var gameProperty = dataModel.GetPropValue <int>(GameProperty); var percentage = ToDouble(gameProperty) / src; if (LayerProperty == "Width") { ApplyWidth(ref properties, percentage); } else if (LayerProperty == "Height") { ApplyHeight(ref properties, percentage); } else if (LayerProperty == "Opacity") { ApplyOpacity(ref properties, percentage); } }
private void ApplyPercentageOfProperty(IDataModel dataModel, ref AppliedProperties properties) { var value = dataModel.GetPropValue <int>(PercentageProperty); ApplyPercentageOf(dataModel, ref properties, value); }