Skip to content

Commit

Permalink
Accept all types of controls in meta element.
Browse files Browse the repository at this point in the history
  • Loading branch information
JornWildt committed Mar 13, 2015
1 parent 69a5b78 commit 3da3fc3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
Expand Up @@ -45,23 +45,23 @@
<axu:ShowSourceBehavior Source="{Binding Value.MetaJsonValue}" Prefix="{Binding Source={x:Static mn:MasonProperties.Meta}}"/>
</i:Interaction.Behaviors>
</TextBlock>
<!-- Meta links -->
<StackPanel Grid.Row="1" Visibility="{Binding Value.HasMetaLinks, Converter={axv:BoolToVisibilityConverter}}">
<TextBlock Text="Meta-links" FontStyle="Italic" FontWeight="Bold">
<!-- Show source for links -->
<!-- Meta controls -->
<StackPanel Grid.Row="1" Visibility="{Binding Value.HasMetaControls, Converter={axv:BoolToVisibilityConverter}}">
<TextBlock Text="Meta-controls" FontStyle="Italic" FontWeight="Bold">
<!-- Show source for controls -->
<i:Interaction.Behaviors>
<axu:ShowSourceBehavior Source="{Binding Value.MetaLinksJsonValue}" Prefix="{Binding Source={x:Static mn:MasonProperties.Control}}"/>
<axu:ShowSourceBehavior Source="{Binding Value.MetaControlsJsonValue}" Prefix="{Binding Source={x:Static mn:MasonProperties.Controls}}"/>
</i:Interaction.Behaviors>
</TextBlock>
<!-- Use styling to render links -->
<ItemsControl ItemsSource="{Binding Value.MetaLinks}" Margin="10 0 0 0"/>
<!-- Use styling to render controls -->
<ItemsControl ItemsSource="{Binding Value.MetaControls}" Margin="10 0 0 0"/>
</StackPanel>
<!-- Control elements -->
<StackPanel Grid.Row="2" Visibility="{Binding Value.HasControls, Converter={axv:BoolToVisibilityConverter}}">
<TextBlock Text="Controls" FontStyle="Italic" FontWeight="Bold">
<!-- Show source for links -->
<!-- Show source for controls -->
<i:Interaction.Behaviors>
<axu:ShowSourceBehavior Source="{Binding Value.ControlJsonValue}" Prefix="{Binding Source={x:Static mn:MasonProperties.Control}}"/>
<axu:ShowSourceBehavior Source="{Binding Value.ControlJsonValue}" Prefix="{Binding Source={x:Static mn:MasonProperties.Controls}}"/>
</i:Interaction.Behaviors>
</TextBlock>
<!-- Use styling to render control elements -->
Expand Down Expand Up @@ -106,7 +106,7 @@
<TextBlock Text="{Binding Description}"
Style="{StaticResource ResourceKey=Description}"
Visibility="{Binding Description, Converter={axv:EmptyStringToVisibilityConverter}}"/>
<!-- Use styling to render alternate links -->
<!-- Use styling to render alternate controls -->
<ItemsControl ItemsSource="{Binding AlternateControls}" Margin="30 0 0 0"/>
</StackPanel>
</Border>
Expand Down
Expand Up @@ -24,11 +24,11 @@ public class ResourceViewModel : JsonViewModel, IControlBuilder

public bool HasDescription { get { return !string.IsNullOrEmpty(Description); } }

public ObservableCollection<LinkViewModel> MetaLinks { get; private set; }
public ObservableCollection<ControlViewModel> MetaControls { get; private set; }

public bool HasMetaLinks { get { return MetaLinks != null && MetaLinks.Count > 0; } }
public bool HasMetaControls { get { return MetaControls != null && MetaControls.Count > 0; } }

public JToken MetaLinksJsonValue { get; private set; }
public JToken MetaControlsJsonValue { get; private set; }

public JToken MetaJsonValue { get; private set; }

Expand All @@ -55,7 +55,7 @@ public ResourceViewModel(ViewModel parent, JObject resource, BuilderContext cont
{
// Ignore - it has been handled
}
else if (pair.Key == MasonProperties.Control && pair.Value is JObject)
else if (pair.Key == MasonProperties.Controls && pair.Value is JObject)
{
ControlsJsonValue = pair.Value;
Controls = new ObservableCollection<ControlViewModel>(
Expand All @@ -65,12 +65,12 @@ public ResourceViewModel(ViewModel parent, JObject resource, BuilderContext cont
{
MetaJsonValue = pair.Value;
Description = GetValue<string>(pair.Value, MasonProperties.MetaProperties.Description);
JToken metaLinksProperty = pair.Value[MasonProperties.Control];
if (metaLinksProperty is JObject)
JToken metaControlsProperty = pair.Value[MasonProperties.Controls];
if (metaControlsProperty is JObject)
{
MetaLinksJsonValue = metaLinksProperty;
MetaLinks = new ObservableCollection<LinkViewModel>(
metaLinksProperty.Children().OfType<JProperty>().Select(l => new LinkViewModel(this, l.Name, l.Value as JObject, context, this)));
MetaControlsJsonValue = metaControlsProperty;
MetaControls = new ObservableCollection<ControlViewModel>(
metaControlsProperty.Children().OfType<JProperty>().Select(l => BuildControlElement(this, l.Name, l.Value as JObject, context)));
}
}
else if (pair.Key == MasonProperties.Error && pair.Value is JObject)
Expand Down
2 changes: 1 addition & 1 deletion MasonBuilder.Net/MasonProperties.cs
Expand Up @@ -9,7 +9,7 @@ public static class MasonProperties
public const string Namespaces = Prefix + "namespaces";
public const string Meta = Prefix + "meta";
public const string Profile = Prefix + "profile";
public const string Control = Prefix + "controls";
public const string Controls = Prefix + "controls";
public const string Error = Prefix + "error";

public static class NamespaceProperties
Expand Down

0 comments on commit 3da3fc3

Please sign in to comment.