-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from zxbmmmmmmmmm/gamebar
GameBar widget
- Loading branch information
Showing
6 changed files
with
227 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<Page | ||
x:Class="FluentWeather.Uwp.Pages.WidgetPage" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:behaviors="using:FluentWeather.Uwp.Behaviors" | ||
xmlns:behaviors1="using:Microsoft.Toolkit.Uwp.UI.Behaviors" | ||
xmlns:chart="using:Telerik.UI.Xaml.Controls.Chart" | ||
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls" | ||
xmlns:controls1="using:FluentWeather.Uwp.Controls" | ||
xmlns:converters="using:ValueConverters" | ||
xmlns:converters1="using:FluentWeather.Uwp.Shared.Helpers.ValueConverters" | ||
xmlns:core="using:Microsoft.Xaml.Interactions.Core" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:i="using:Microsoft.Xaml.Interactivity" | ||
muxc:BackdropMaterial.ApplyToRootOrPageBackground="True" | ||
xmlns:local="using:FluentWeather.Uwp.Pages" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:muxc="using:Microsoft.UI.Xaml.Controls" | ||
mc:Ignorable="d"> | ||
<Grid Padding="12,2,0,3" x:DefaultBindMode="OneWay"> | ||
<Button x:Name="WeatherButton" Click="WeatherButton_Click" IsEnabled="{x:Bind ViewModel.GetWeatherCommand.IsRunning,Converter={StaticResource BoolNegationConverter}}" VerticalAlignment="Bottom" Background="Transparent" BorderBrush="Transparent"> | ||
<i:Interaction.Behaviors> | ||
<core:EventTriggerBehavior EventName="DoubleTapped"> | ||
<core:InvokeCommandAction Command="{x:Bind ViewModel.RefreshCommand}"/> | ||
</core:EventTriggerBehavior> | ||
</i:Interaction.Behaviors> | ||
<StackPanel | ||
|
||
Orientation="Horizontal" Margin="0,0,0,0" | ||
Spacing="8"> | ||
<Image | ||
Width="28" | ||
Height="28" | ||
Source="{x:Bind converters1:ConverterMethods.GetIconByWeather(ViewModel.WeatherNow.WeatherType)}" /> | ||
<StackPanel Spacing="0" VerticalAlignment="Center"> | ||
<TextBlock Margin="0,0,0,0" > | ||
<Run Text="{x:Bind converters1:ConverterMethods.ConvertTemperatureUnit(ViewModel.WeatherNow.Temperature)}" /><Run Text="°" /> | ||
<Run Text="{x:Bind ViewModel.WeatherNow.Description}"/> | ||
</TextBlock> | ||
</StackPanel> | ||
|
||
</StackPanel> | ||
<Button.ContextFlyout> | ||
<Flyout x:Name="DetailFlyout"> | ||
<StackPanel> | ||
<TextBlock Text="{x:Bind ViewModel.WeatherNow.Description}"/> | ||
</StackPanel> | ||
</Flyout> | ||
</Button.ContextFlyout> | ||
</Button> | ||
</Grid> | ||
</Page> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using FluentWeather.Uwp.Shared; | ||
using FluentWeather.Uwp.ViewModels; | ||
using Microsoft.Gaming.XboxGameBar; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Runtime.InteropServices.WindowsRuntime; | ||
using Windows.Foundation; | ||
using Windows.Foundation.Collections; | ||
using Windows.UI.Xaml; | ||
using Windows.UI.Xaml.Controls; | ||
using Windows.UI.Xaml.Controls.Primitives; | ||
using Windows.UI.Xaml.Data; | ||
using Windows.UI.Xaml.Input; | ||
using Windows.UI.Xaml.Media; | ||
using Windows.UI.Xaml.Navigation; | ||
|
||
|
||
namespace FluentWeather.Uwp.Pages; | ||
|
||
public sealed partial class WidgetPage : Page | ||
{ | ||
public MainPageViewModel ViewModel { get; set; } = new(); | ||
private readonly DispatcherTimer _timer = new (){ Interval = TimeSpan.FromMinutes(20)}; | ||
private XboxGameBarWidget _widget; | ||
|
||
public WidgetPage() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
protected override void OnNavigatedTo(NavigationEventArgs e) | ||
{ | ||
base.OnNavigatedTo(e); | ||
ViewModel.CurrentGeolocation = Common.Settings.DefaultGeolocation!; | ||
_widget = e.Parameter as XboxGameBarWidget; | ||
_timer.Tick += OnTimerTicked; | ||
_timer.Start(); | ||
} | ||
|
||
private async void OnTimerTicked(object sender, object e) | ||
{ | ||
await ViewModel.RefreshCommand.ExecuteAsync(null); | ||
} | ||
|
||
private async void WeatherButton_Click(object sender, RoutedEventArgs e) | ||
{ | ||
await _widget.LaunchUriAsync(new Uri("weather:")); | ||
} | ||
} |