public void ShowLayer(int layerPos, bool doShow) { if (layerPos < 0 && layerPos >= _ParentGrid.Children.Count) { return; } FgLayer layer = _ParentGrid.Children[layerPos] as FgLayer; layer.Visibility = doShow ? Visibility.Visible : Visibility.Hidden; }
private void EnableLayerSelectively(int layerPos) { for (int i = 0; i < _ParentGrid.Children.Count; i++) { FgLayer layer = _ParentGrid.Children[i] as FgLayer; layer.Visibility = (layerPos == (int)SelectiveLayerEnableProperty.DefaultMetadata.DefaultValue ? Visibility.Visible : (layerPos == i ? Visibility.Visible : Visibility.Hidden ) ); } }
private void SetPropertyValuesInLayers(string explicitAttrString, string readyMadeAttrString, [CallerMemberName] string propertyName = "") { PropertyInfo layerPropInfo = typeof(FgLayer).GetProperty(propertyName); int layerNo = 0; foreach (var effectivePerLayerValue in ComputeEffectivePerLayerValues(readyMadeAttrString, explicitAttrString)) { FgLayer layer = GetOrCreateNthLayer(layerNo); layerPropInfo.SetValue(layer, effectivePerLayerValue); layerNo++; } if (SelectiveLayerEnable != (int)SelectiveLayerEnableProperty.DefaultMetadata.DefaultValue) { EnableLayerSelectively(SelectiveLayerEnable); } }
// see FontogramBaseProps.cs, generated from FontogramBaseProps.tt #endregion private FgLayer GetOrCreateNthLayer(int n) { if (n < _ParentGrid.Children.Count) { return(_ParentGrid.Children[n] as FgLayer); } if (n > _ParentGrid.Children.Count) { return(null); } // 'n' is 1 past the end of the current list -> add new layer FgLayer newLayer = new FgLayer(); _ParentGrid.Children.Add(newLayer); return(newLayer); }