Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #124

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open

Dev #124

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions OpenHAB.Windows/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
<controls:MapViewWidget Widget="{Binding Mode=OneWay}" />
</DataTemplate>

<DataTemplate x:Key="WebViewTemplate">
<controls:WebViewWidget Widget="{Binding Mode=OneWay}" />
</DataTemplate>

<DataTemplate x:Key="RollershutterTemplate">
<controls:RollershutterWidget Widget="{Binding Mode=OneWay}" />
</DataTemplate>
Expand Down Expand Up @@ -84,6 +88,7 @@
SliderTemplate="{StaticResource SliderTemplate}"
SwitchTemplate="{StaticResource SwitchTemplate}"
MapViewTemplate="{StaticResource MapViewTemplate}"
WebViewTemplate="{StaticResource WebViewTemplate}"
TextTemplate="{StaticResource TextItemTemplate}" />
</ResourceDictionary>
</Application.Resources>
Expand Down
Binary file modified OpenHAB.Windows/Assets/background.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions OpenHAB.Windows/Controls/WebViewWidget.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<local:WidgetBase x:Class="OpenHAB.Windows.Controls.WebViewWidget"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:OpenHAB.Windows.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignHeight="150"
d:DesignWidth="300"
mc:Ignorable="d">

<Grid Width="300"
Height="150"
Background="{StaticResource OpenHABLightColor}"
CornerRadius="5"
Tapped="OnTapped">

<WebView x:Name="WebView">
<WebView.RenderTransform>
<CompositeTransform ScaleY="0.5" ScaleX="0.5"/>
</WebView.RenderTransform>
</WebView>

<Border Background="Transparent" CornerRadius="5" />

<ContentDialog x:Name="PopupDialog"
Title="{x:Bind Widget.Label}"
Background="{StaticResource OpenHABLightColor}"
IsPrimaryButtonEnabled="True"
PrimaryButtonText="Close">
<WebView x:Name="WebViewFull" Width="550" Height="300" />
</ContentDialog>

</Grid>
</local:WidgetBase>
39 changes: 39 additions & 0 deletions OpenHAB.Windows/Controls/WebViewWidget.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Input;

namespace OpenHAB.Windows.Controls
{
/// <summary>
/// Widget control that represents an OpenHab WebView
/// </summary>
public sealed partial class WebViewWidget : WidgetBase
{
/// <summary>
/// Initializes a new instance of the <see cref="WebViewWidget"/> class.
/// </summary>
public WebViewWidget()
{
this.InitializeComponent();
Loaded += OnLoaded;
}

private void OnLoaded(object sender, RoutedEventArgs e)
{
SetState();
}

private async void OnTapped(object sender, TappedRoutedEventArgs e)
{
await PopupDialog.ShowAsync();
}

internal override void SetState()
{
if (!string.IsNullOrEmpty(Widget?.Url))
{
WebView.Source = WebViewFull.Source = new Uri(Widget.Url);
}
}
}
}
7 changes: 7 additions & 0 deletions OpenHAB.Windows/Converters/WidgetTemplateSelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ protected override DataTemplate SelectTemplateCore(object item, DependencyObject
return MjpegTemplate;
case WidgetTypeEnum.Mapview:
return MapViewTemplate;
case WidgetTypeEnum.Webview:
return WebViewTemplate;
default:
return FrameTemplate;
}
Expand Down Expand Up @@ -131,6 +133,11 @@ protected override DataTemplate SelectTemplateCore(object item, DependencyObject
/// </summary>
public DataTemplate MapViewTemplate { get; set; }

/// <summary>
/// Gets or sets the template for a web view control
/// </summary>
public DataTemplate WebViewTemplate { get; set; }

private WidgetTypeEnum GetItemViewType(OpenHABWidget openHABWidget)
{
if (openHABWidget.Type.Equals("Switch"))
Expand Down
7 changes: 7 additions & 0 deletions OpenHAB.Windows/OpenHAB.Windows.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@
<Compile Include="Controls\TextWidget.xaml.cs">
<DependentUpon>TextWidget.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\WebViewWidget.xaml.cs">
<DependentUpon>WebViewWidget.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\WidgetBase.cs" />
<Compile Include="Converters\BoolToBackgroundColorConverter.cs" />
<Compile Include="Converters\IconToBitmapConverter.cs" />
Expand Down Expand Up @@ -305,6 +308,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Controls\WebViewWidget.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Generic.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
Expand Down
92 changes: 92 additions & 0 deletions OpenHAB.Windows/Styles/DefaultTheme.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -488,4 +488,96 @@
</Setter.Value>
</Setter>
</Style>

<Style x:Key="SettingsTogglePaneButtonStyle" TargetType="ToggleButton">
<Setter Property="FontSize" Value="20" />
<Setter Property="FontFamily" Value="{ThemeResource SymbolThemeFontFamily}" />
<Setter Property="MinHeight" Value="48" />
<Setter Property="MinWidth" Value="48" />
<Setter Property="Margin" Value="0" />
<Setter Property="Padding" Value="0" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Foreground" Value="{ThemeResource SystemControlForegroundBaseHighBrush}" />
<Setter Property="Content" Value="&#xE713;" />
<Setter Property="AutomationProperties.Name" Value="Menu" />
<Setter Property="UseSystemFocusVisuals" Value="True" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ToggleButton">
<Grid x:Name="LayoutRoot" Background="{TemplateBinding Background}">
<ContentPresenter x:Name="ContentPresenter"
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
AutomationProperties.AccessibilityView="Raw"
Content="{TemplateBinding Content}" />
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="PointerOver">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="LayoutRoot" Storyboard.TargetProperty="(Grid.Background)">
<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Null}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource OpenHABLightOrangeBrush}" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Pressed">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="LayoutRoot" Storyboard.TargetProperty="(Grid.Background)">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightListMediumBrush}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightAltBaseHighBrush}" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Disabled">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="(TextBlock.Foreground)">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlDisabledBaseLowBrush}" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Checked" />
<VisualState x:Name="CheckedPointerOver">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="LayoutRoot" Storyboard.TargetProperty="(Grid.Background)">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightListLowBrush}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightAltBaseHighBrush}" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="CheckedPressed">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="LayoutRoot" Storyboard.TargetProperty="(Grid.Background)">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightListMediumBrush}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightAltBaseHighBrush}" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="CheckedDisabled">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="(TextBlock.Foreground)">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlDisabledBaseLowBrush}" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
53 changes: 32 additions & 21 deletions OpenHAB.Windows/View/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,28 +103,38 @@
ItemsSource="{x:Bind Vm.Sitemaps, Mode=OneWay}"
SelectedItem="{x:Bind Vm.SelectedSitemap, Converter={StaticResource ObjectToSitemapConverter}, Mode=TwoWay}" />



<TextBlock x:Name="openHabTextBlock"
Margin="0,15,0,0"
Grid.Row="1"
HorizontalAlignment="Center"
Foreground="{StaticResource OpenHABLightColor}"
Style="{StaticResource FlyoutPickerTitleTextBlockStyle}"
Text="Sitemaps"
TextWrapping="Wrap" />

<StackPanel Grid.Row="2"
Margin="12,0,0,8"
Margin="0,0,0,8"
VerticalAlignment="Bottom"
Orientation="Horizontal">
<interactivity:Interaction.Behaviors>
<core:EventTriggerBehavior EventName="Tapped">
<core:NavigateToPageAction TargetPage="OpenHAB.Windows.View.SettingsPage" />
</core:EventTriggerBehavior>
</interactivity:Interaction.Behaviors>
<TextBlock VerticalAlignment="Center"
AutomationProperties.Name="Favorite"
FontFamily="Segoe MDL2 Assets"
FontSize="36"
Foreground="{StaticResource OpenHABLightColor}"
Text="&#xE713;" />
<TextBlock x:Name="textBlock"
Margin="12,0,0,0"
VerticalAlignment="Center"
Foreground="{StaticResource OpenHABLightColor}"
Style="{StaticResource FlyoutPickerTitleTextBlockStyle}"
Text="Settings"
TextWrapping="Wrap" />

<ToggleButton x:Name="ToggleSettingsButton"
Grid.Row="2"
Foreground="White"
Style="{StaticResource SettingsTogglePaneButtonStyle}"
TabIndex="1"
ToolTipService.ToolTip="Settings"
Checked="ToggleSettingsButton_Checked" />

<TextBlock x:Name="settingsTextBlock"
Margin="12,0,0,0"
VerticalAlignment="Center"
Foreground="{StaticResource OpenHABLightColor}"
Style="{StaticResource FlyoutPickerTitleTextBlockStyle}"
Text="Settings"
TextWrapping="Wrap" />

</StackPanel>
</Grid>
</SplitView.Pane>
Expand Down Expand Up @@ -165,11 +175,12 @@

<ToggleButton x:Name="TogglePaneButton"
Grid.Row="0"
Foreground="White"
Foreground="{StaticResource OpenHABLightColor}"
IsChecked="{Binding IsPaneOpen, ElementName=SitemapSplitView, Mode=TwoWay}"
Style="{StaticResource SplitViewTogglePaneButtonStyle}"
TabIndex="1"
ToolTipService.ToolTip="Menu" />
ToolTipService.ToolTip="Menu"/>

<!--<Grid Grid.Column="1">
<interactivity:Interaction.Behaviors>
<behaviors:Blur x:Name="BlurBehavior"
Expand Down
10 changes: 10 additions & 0 deletions OpenHAB.Windows/View/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,15 @@ private void MasterListView_OnItemClick(object sender, ItemClickEventArgs e)
{
Messenger.Default.Send(new WidgetClickedMessage(e.ClickedItem as OpenHABWidget));
}

private void ToggleSettingsButton_Checked(object sender, RoutedEventArgs e)
{
this.Frame.Navigate(typeof(OpenHAB.Windows.View.SettingsPage), null);
}

private void MasterListView_SelectionChanged(object sender, RoutedEventArgs e)
{

}
}
}
7 changes: 4 additions & 3 deletions OpenHAB.Windows/View/SettingsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@
Text="Settings"
TextWrapping="Wrap" />
<Grid Grid.Row="1"
Background="{StaticResource OpenHABLightColor}"
CornerRadius="5">
Background="{StaticResource OpenHABLightGreyBrush}"
CornerRadius="6">
<ScrollViewer VerticalScrollBarVisibility="Auto">
<StackPanel Margin="12,12,0,0">
<TextBlock Text="Demo mode" />
<TextBlock Text="Demo mode"
Margin="0,0,0,0"/>
<CheckBox x:Name="CheckBoxDemoMode"
Margin="0,0,0,12"
HorizontalAlignment="Stretch"
Expand Down