Skip to content

Commit

Permalink
Finalize WPF changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmontemagno committed Apr 23, 2019
1 parent ae01242 commit 9f722d5
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 21 deletions.
4 changes: 2 additions & 2 deletions MyStreamTimer.Packaging/MyStreamTimer.Packaging.wapproj
Expand Up @@ -54,15 +54,15 @@
<TargetPlatformVersion>10.0.17763.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.17134.0</TargetPlatformMinVersion>
<DefaultLanguage>en-US</DefaultLanguage>
<PackageCertificateKeyFile>StreamTimer.pfx</PackageCertificateKeyFile>
<EntryPointProjectUniqueName>..\MyStreamTimer.WPF\MyStreamTimer.WPF.csproj</EntryPointProjectUniqueName>
<GenerateAppInstallerFile>True</GenerateAppInstallerFile>
<AppxAutoIncrementPackageRevision>True</AppxAutoIncrementPackageRevision>
<AppxBundlePlatforms>x86|x64</AppxBundlePlatforms>
<AppInstallerUpdateFrequency>1</AppInstallerUpdateFrequency>
<AppInstallerCheckForUpdateFrequency>Daily</AppInstallerCheckForUpdateFrequency>
<PackageCertificateThumbprint>9758D5C659AD11355664AC74E9AEC87D6633CC1E</PackageCertificateThumbprint>
<PackageCertificateThumbprint>BE02D22169ED57C4BB67D4CC19989FF5FF1B8676</PackageCertificateThumbprint>
<AppInstallerUri>https://mystreamtimer.azurewebsites.net</AppInstallerUri>
<PackageCertificateKeyFile>MyStreamTimer.Packaging_StoreKey.pfx</PackageCertificateKeyFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<AppxBundle>Always</AppxBundle>
Expand Down
4 changes: 2 additions & 2 deletions MyStreamTimer.Packaging/Package.appxmanifest
Expand Up @@ -8,8 +8,8 @@

<Identity
Name="23875RefractoredLLC.MyStreamTimer"
Publisher="CN=995C4AD9-3B22-4B61-B30F-3EAB23CDAEAE, O=Refractored LLC, C=US"
Version="1.0.6.0" />
Publisher="CN=995C4AD9-3B22-4B61-B30F-3EAB23CDAEAE"
Version="1.1.11.0" />

<Properties>
<DisplayName>My Stream Timer</DisplayName>
Expand Down
15 changes: 13 additions & 2 deletions MyStreamTimer.WPF/ClipboardImplementation.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Windows;
using MyStreamTimer.Shared.Interfaces;
Expand All @@ -8,8 +9,18 @@ namespace MyStreamTimer.WPF
{
public class ClipboardImplementation : IClipboard
{
public string BaseDirectory => Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
public string BaseDirectory =>
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);

public void CopyToClipboard(string text) => Clipboard.SetText(text);
public void CopyToClipboard(string text) =>
Clipboard.SetText(text);

public void OpenUrl(string url)
{
var process = new Process();
process.StartInfo.UseShellExecute = true;
process.StartInfo.FileName = url;
process.Start();
}
}
}
39 changes: 37 additions & 2 deletions MyStreamTimer.WPF/MainWindow.xaml
Expand Up @@ -9,7 +9,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:viewmodel="clr-namespace:MyStreamTimer.Shared.ViewModel;assembly=MyStreamTimer.Shared"
Title="My Stream Timer"
Width="500"
Width="540"
Height="400"
ResizeMode="NoResize"
mc:Ignorable="d">
Expand Down Expand Up @@ -370,6 +370,41 @@
</Border>
</Grid>
</mah:MetroTabItem>
<mah:MetroTabItem Header="Commands">
<mah:MetroTabItem.DataContext>
<viewmodel:CommandsViewModel />
</mah:MetroTabItem.DataContext>
<StackPanel Margin="10">
<TextBlock Text="You can launch My Stream Timer in popular stream tools or by command line with the following commands (tap to copy to clipboard):" TextWrapping="Wrap" />

<Label
Margin="0,10,0,0"
Content="Count down from X minutes:"
FontWeight="Bold" />
<Label
x:Name="LabelCommandsMins"
Content="mystreamtimer://countdown/?mins=15"
MouseLeftButtonUp="LabelCommandsMins_MouseLeftButtonUp" />

<Label
Margin="0,10,0,0"
Content="Count down to specific time (24 hour clock):"
FontWeight="Bold" />
<Label
x:Name="LabelCommandsTo"
Content="mystreamtimer://countdown/?to=15:30"
MouseLeftButtonUp="LabelCommandsMins_MouseLeftButtonUp" />

<Label
Margin="0,10,0,0"
Content="Count down to top of the hour."
FontWeight="Bold" />
<Label
x:Name="LabelCommandsTopOfHour"
Content="mystreamtimer://countdown/?topofhour"
MouseLeftButtonUp="LabelCommandsMins_MouseLeftButtonUp" />
</StackPanel>
</mah:MetroTabItem>
<mah:MetroTabItem Header="About">
<StackPanel Margin="10">
<TextBlock Text="My Stream Timer is an open source project by James Montemagno." />
Expand Down Expand Up @@ -400,7 +435,7 @@
</Hyperlink>
</TextBlock>

<Label Margin="0,10,0,0" Content="Version 1.0.0" />
<Label Margin="0,10,0,0" Content="Version 1.1" />
</StackPanel>
</mah:MetroTabItem>

Expand Down
34 changes: 21 additions & 13 deletions MyStreamTimer.WPF/MainWindow.xaml.cs
@@ -1,6 +1,7 @@
using MahApps.Metro.Controls;
using MahApps.Metro.Controls.Dialogs;
using MyStreamTimer.Shared.Helpers;
using MyStreamTimer.Shared.Interfaces;
using MyStreamTimer.Shared.ViewModel;
using System;
using System.Collections.Generic;
Expand All @@ -17,6 +18,7 @@
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Utils = MyStreamTimer.Shared.Helpers.Utils;

namespace MyStreamTimer.WPF
{
Expand All @@ -31,18 +33,11 @@ public MainWindow()
InitializeComponent();

var start = false;
var mins = -1;
float mins = -1;
try
{
var first = StartArgs?.Args?.FirstOrDefault();
if (first != null)
{
var uri = new Uri(first);
if(uri.Host.ToLower() == "countdown" && uri.Query.ToLower().Contains("?mins=") && int.TryParse(uri.Query.Remove(0, 6), out mins))
{
start = true;
}
}
(start, mins) = Utils.ParseStartupArgs(first);
}
catch (Exception)
{
Expand All @@ -56,11 +51,24 @@ public MainWindow()

void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e)
{
var process = new Process();
process.StartInfo.UseShellExecute = true;
process.StartInfo.FileName = e.Uri.OriginalString;
process.Start();
var clipboard = ServiceContainer.Resolve<IClipboard>();
if (clipboard == null)
throw new Exception("Clipboard must be implemented");

clipboard.OpenUrl(e.Uri.OriginalString);

e.Handled = true;
}

private void LabelCommandsMins_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{

var clipboard = ServiceContainer.Resolve<IClipboard>();
if (clipboard == null)
throw new Exception("Clipboard must be implemented");

var text = ((Label)sender).Content as string;
clipboard.CopyToClipboard(text);
}
}
}
1 change: 1 addition & 0 deletions MyStreamTimer.WPF/MyStreamTimer.WPF.csproj
Expand Up @@ -22,6 +22,7 @@
<PackageReference Include="MahApps.Metro" Version="2.0.0-alpha0262" />
<PackageReference Include="MahApps.Metro.IconPacks.FontAwesome" Version="3.0.0-alpha0137" />
<PackageReference Include="Refractored.MvvmHelpers" Version="1.3.0" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="Xam.Plugins.Settings" Version="4.1.0-beta" />
</ItemGroup>

Expand Down

0 comments on commit 9f722d5

Please sign in to comment.