Skip to content

Commit

Permalink
Merge pull request #60 from Sparkiy/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
AleksandarDev committed Jan 12, 2015
2 parents be27a9e + e56ce83 commit e61156d
Show file tree
Hide file tree
Showing 29 changed files with 380 additions and 109 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.ObjectModel;
using System.Threading.Tasks;
using Windows.System.UserProfile;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
Expand Down Expand Up @@ -36,6 +37,8 @@ public CreateProjectPageViewModel(IProjectService projectService, INavigationSer

this.Project = new Project()
{
Description = "Amazing new project. Touch Play button and try it out yourself. It's great!",
Author = "Unknown",
Files = new ObservableCollection<CodeFile>()
{
new Script()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ public interface IMainPageViewModel : IViewModelBase
{
bool RequiresWorkspaceInitialization { get; }

TimeSpan NextReleaseCountdown { get; }

bool IsNextReleaseReady { get; }

ObservableCollection<Project> Projects { get; }

RelayCommand InitializeWorkspaceCommand { get; }
Expand All @@ -40,6 +44,8 @@ public class MainPageViewModel : ExtendedViewModel, IMainPageViewModel
private readonly IStorageService storageService;
private readonly IProjectService projectService;

private readonly DispatcherTimer nextReleaseCountdownTimer;


public MainPageViewModel(INavigationService navigationService, IAlertMessageService alertMessageService, IStorageService storageService, IProjectService projectService)
{
Expand All @@ -53,8 +59,14 @@ public MainPageViewModel(INavigationService navigationService, IAlertMessageServ
this.InitializeWorkspaceCommand = new RelayCommand(this.InitializeWorkspaceCommandExecuteAsync);
this.ProjectSelectedCommand = new RelayCommand<Project>(this.ProjectSelectedCommandExecute);
this.NewProjectCommand = new RelayCommand(this.NewProjectCommandExecute);
}

this.NextReleaseCountdown = (new DateTime(2015, 1, 26, 0, 0, 0)) - DateTime.Now;
this.nextReleaseCountdownTimer = new DispatcherTimer();
this.nextReleaseCountdownTimer.Interval = TimeSpan.FromSeconds(1);
this.nextReleaseCountdownTimer.Tick += NextReleaseCountdownTimerOnTick;
this.nextReleaseCountdownTimer.Start();
this.NextReleaseCountdownTimerOnTick(null, null);
}

public override async void OnNavigatedTo(NavigationEventArgs e)
{
Expand All @@ -67,7 +79,14 @@ public override async void OnNavigatedTo(NavigationEventArgs e)
}
}

private async Task LoadProjectsAsync()
private void NextReleaseCountdownTimerOnTick(object sender, object o)
{
this.NextReleaseCountdown = NextReleaseCountdown - TimeSpan.FromSeconds(1);
if (NextReleaseCountdown.TotalSeconds <= 0)
this.IsNextReleaseReady = true;
}

private async Task LoadProjectsAsync()
{
Log.Debug("Loading project...");
if (this.storageService.RequiresHardStorageInitialization())
Expand Down Expand Up @@ -110,6 +129,18 @@ public bool RequiresWorkspaceInitialization
protected set { this.SetProperty(value); }
}

public TimeSpan NextReleaseCountdown
{
get { return this.GetProperty<TimeSpan>(); }
protected set { this.SetProperty(value); }
}

public bool IsNextReleaseReady
{
get { return this.GetProperty<bool>(); }
protected set { this.SetProperty(value); }
}

public RelayCommand InitializeWorkspaceCommand { get; }

public RelayCommand<Project> ProjectSelectedCommand { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ public void AssignProject(Project project)
this.project = project;

this.RebuildEngine();

this.isInitialized = true;
}

private void StopProject()
Expand All @@ -75,7 +73,7 @@ private void StopProject()

public void PlayProject()
{
if (this.IsPlaying)
if (!this.IsInitialized || this.IsPlaying)
return;

this.Engine.Play();
Expand All @@ -87,7 +85,7 @@ public void PlayProject()

public void PauseProject()
{
if (this.IsPause)
if (!this.IsInitialized || this.IsPause)
return;

this.Engine.Pause();
Expand Down Expand Up @@ -138,8 +136,12 @@ private void RebuildEngine()
// TODO Add assets to the engine

// Add scripts to the engine
bool allScriptsValid = true;
foreach (var script in this.project.Files.OfType<Script>())
this.engine.AddScript(script.Name, classesCombined + script.Code);
allScriptsValid &= this.engine.AddScript(script.Name, classesCombined + script.Code);
if (!allScriptsValid)
this.isInitialized = false;
else this.isInitialized = true;
}

public void TakeScreenshot()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Media;

namespace SparkiyClient.Converters
{
public class BooleanToBrushConverter : IValueConverter
{
public Brush TrueBrush { get; set; }

public Brush FalseBrush { get; set; }


public object Convert(object value, Type targetType, object parameter, string language)
{
if (value == null)
return FalseBrush;

if (!(value is bool))
throw new NotSupportedException();

return (bool) value ? TrueBrush : FalseBrush;
}

public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ public class StringFormatConverter : Windows.UI.Xaml.Data.IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
string arg = System.Convert.ToString(value);

return string.Format((string)parameter, arg);
return string.Format((string)parameter, value);
}

public object ConvertBack(object value, Type targetType, object parameter, string language)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Controls\TopNavigationControl.xaml.cs">
<DependentUpon>TopNavigationControl.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Converters\BooleanToBrushConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Converters\BooleanToVisibilityConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Converters\StringFormatConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Services\AlertMessageService.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@
<Color x:Key="AccentColorGreen">#92CA45</Color>
<Color x:Key="AccentColorDark">#2F4750</Color>
<Color x:Key="AccentColorLight">#FFFFFF</Color>
<Color x:Key="AccentColorDarkLighter3">#F8F9F9</Color>
<SolidColorBrush x:Key="AccentBrushBlue" Color="{StaticResource AccentColorBlue}" />
<SolidColorBrush x:Key="AccentBrushRed" Color="{StaticResource AccentColorRed}" />
<SolidColorBrush x:Key="AccentBrushGreen" Color="{StaticResource AccentColorGreen}" />
<SolidColorBrush x:Key="AccentBrushDark" Color="{StaticResource AccentColorDark}" />
<SolidColorBrush x:Key="AccentBrushLight" Color="{StaticResource AccentColorLight}" />
<SolidColorBrush x:Key="AccentBrushDarkLighter3" Color="{StaticResource AccentColorDarkLighter3}" />



</ResourceDictionary>
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
</SemanticZoom.ZoomedOutView>

<SemanticZoom.ZoomedInView>
<Hub>
<Hub Background="{StaticResource AccentBrushDarkLighter3}" >
<Hub.Header>
<StackPanel Orientation="Horizontal">
<Grid Margin="5 0 20 0">
Expand All @@ -80,12 +80,14 @@
</Hub.Header>

<!-- Content -->
<HubSection Width="780">
<HubSection Background="{StaticResource AccentBrushLight}" Width="780" VerticalContentAlignment="Stretch">
<DataTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>

<!-- Select workspace folder message -->
Expand Down Expand Up @@ -119,6 +121,31 @@
Grid.Column="2"/>
</Grid>
</Border>

<Grid Grid.Row="2">
<Grid.Resources>
<Style TargetType="TextBlock" x:Key="TextBlockCountdownStyle">
<Setter Property="FontSize" Value="28" />
<Setter Property="FontWeight" Value="ExtraLight" />
</Style>
</Grid.Resources>
<StackPanel Orientation="Horizontal"
Visibility="{Binding IsNextReleaseReady, Converter={StaticResource NegatedBooleanToVisibilityConverter}}">
<TextBlock Text="Next release in" Style="{StaticResource TextBlockCountdownStyle}" Margin="0 0 20 0" />
<TextBlock Text="{Binding NextReleaseCountdown.Days, Converter={StaticResource StringFormatConverter}, ConverterParameter=\{0\:00\}}" Style="{StaticResource TextBlockCountdownStyle}" />
<TextBlock Text=":" Style="{StaticResource TextBlockCountdownStyle}" />
<TextBlock Text="{Binding NextReleaseCountdown.Hours, Converter={StaticResource StringFormatConverter}, ConverterParameter=\{0\:00\}}" Style="{StaticResource TextBlockCountdownStyle}" />
<TextBlock Text=":" Style="{StaticResource TextBlockCountdownStyle}" />
<TextBlock Text="{Binding NextReleaseCountdown.Minutes, Converter={StaticResource StringFormatConverter}, ConverterParameter=\{0\:00\}}" Style="{StaticResource TextBlockCountdownStyle}" />
<TextBlock Text=":" Style="{StaticResource TextBlockCountdownStyle}" />
<TextBlock Text="{Binding NextReleaseCountdown.Seconds, Converter={StaticResource StringFormatConverter}, ConverterParameter=\{0\:00\}}" Style="{StaticResource TextBlockCountdownStyle}" />
</StackPanel>
<TextBlock Text="New release will be available soon."
Style="{StaticResource TextBlockCountdownStyle}"
Visibility="{Binding IsNextReleaseReady, Converter={StaticResource BooleanToVisibilityConverter}}" />
</Grid>

<TextBlock Text="v1.3.0" FontSize="16" FontWeight="ExtraLight" Margin="0 4" Grid.Row="3" />
</Grid>
</DataTemplate>
</HubSection>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@
<Grid>
<TextBlock Text="{Binding Project.Description}"
Foreground="#333333"
Style="{StaticResource BodyTextBlockStyle}"
VerticalAlignment="Center"
FontSize="15"
TextWrapping="Wrap"
Padding="0 10 0 0"
Visibility="{Binding IsEditMode, Converter={StaticResource NegatedBooleanToVisibilityConverter}}" />
<TextBox Text="{Binding Project.Description, Mode=TwoWay}"
Visibility="{Binding IsEditMode, Converter={StaticResource BooleanToVisibilityConverter}}"
Expand All @@ -89,7 +90,10 @@
Margin="0,8,8,8"
VerticalAlignment="Center" />
<TextBlock Text="{Binding Project.Author}"
Style="{StaticResource SubtitleTextBlockStyle}"
FontSize="15"
TextWrapping="NoWrap"
TextTrimming="CharacterEllipsis"
Padding="0 10 0 0"
Margin="8" Foreground="#666666" Grid.Column="1"
Visibility="{Binding IsEditMode, Converter={StaticResource NegatedBooleanToVisibilityConverter}}"/>
<TextBox Text="{Binding Project.Author, Mode=TwoWay}" Margin="8" Grid.Column="1"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
MainPackage=C:\Users\Aleksandar\Documents\GitHub\sparkiy-client\SparkiyClient\SparkiyClient\SparkiyClient.Windows\bin\ARM\Release\SparkiyClient.Windows_1.2.0.2_ARM.appx
SymbolPackage=C:\Users\Aleksandar\Documents\GitHub\sparkiy-client\SparkiyClient\SparkiyClient\SparkiyClient.Windows\AppPackages\SparkiyClient.Windows_1.2.0.2_Test\SparkiyClient.Windows_1.2.0.2_ARM.appxsym
ResourcePack=C:\Users\Aleksandar\Documents\GitHub\sparkiy-client\SparkiyClient\SparkiyClient\SparkiyClient.Windows\bin\ARM\Release\SparkiyClient.Windows_1.2.0.2_scale-140.appx
ResourcePack=C:\Users\Aleksandar\Documents\GitHub\sparkiy-client\SparkiyClient\SparkiyClient\SparkiyClient.Windows\bin\ARM\Release\SparkiyClient.Windows_1.2.0.2_scale-180.appx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
MainPackage=C:\Users\Aleksandar\Documents\GitHub\sparkiy-client\SparkiyClient\SparkiyClient\SparkiyClient.Windows\bin\x64\Release\SparkiyClient.Windows_1.2.0.2_x64.appx
SymbolPackage=C:\Users\Aleksandar\Documents\GitHub\sparkiy-client\SparkiyClient\SparkiyClient\SparkiyClient.Windows\AppPackages\SparkiyClient.Windows_1.2.0.2_Test\SparkiyClient.Windows_1.2.0.2_x64.appxsym
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
MainPackage=C:\Users\Aleksandar\Documents\GitHub\sparkiy-client\SparkiyClient\SparkiyClient\SparkiyClient.Windows\bin\x86\Release\SparkiyClient.Windows_1.2.0.2_x86.appx
SymbolPackage=C:\Users\Aleksandar\Documents\GitHub\sparkiy-client\SparkiyClient\SparkiyClient\SparkiyClient.Windows\AppPackages\SparkiyClient.Windows_1.2.0.2_Test\SparkiyClient.Windows_1.2.0.2_x86.appxsym
Original file line number Diff line number Diff line change
Expand Up @@ -357,5 +357,33 @@
<MainPackageIdentityName>53858AleksandarToplek.Project-Code</MainPackageIdentityName>
<MainPackageIdentityName>53858AleksandarToplek.Quantastic</MainPackageIdentityName>
</AccountPackageIdentityNames>
<PackageInfoList LandingUrl="https://appdev.microsoft.com:443/StorePortals/Developer/Catalog/ReleaseAnchor/b06800e1-6a95-4d7b-9feb-32a371613afd" />
<PackageInfoList LandingUrl="https://appdev.microsoft.com:443/StorePortals/Developer/Catalog/ReleaseAnchor/b06800e1-6a95-4d7b-9feb-32a371613afd">
<BundleInfo>
<PackageInfo>
<OsMinVersion>6.3.0.0</OsMinVersion>
<PackageArchitecture>X86</PackageArchitecture>
<PackageMaxArchitectureVersion>1.1.1.1</PackageMaxArchitectureVersion>
</PackageInfo>
<PackageInfo>
<OsMinVersion>6.3.0.0</OsMinVersion>
<PackageArchitecture>X64</PackageArchitecture>
<PackageMaxArchitectureVersion>1.1.1.1</PackageMaxArchitectureVersion>
</PackageInfo>
<PackageInfo>
<OsMinVersion>6.3.0.0</OsMinVersion>
<PackageArchitecture>Neutral</PackageArchitecture>
<PackageMaxArchitectureVersion>1.1.1.1</PackageMaxArchitectureVersion>
</PackageInfo>
<PackageInfo>
<OsMinVersion>6.3.0.0</OsMinVersion>
<PackageArchitecture>Neutral</PackageArchitecture>
<PackageMaxArchitectureVersion>1.1.1.1</PackageMaxArchitectureVersion>
</PackageInfo>
<PackageInfo>
<OsMinVersion>6.3.0.0</OsMinVersion>
<PackageArchitecture>ARM</PackageArchitecture>
<PackageMaxArchitectureVersion>1.1.1.1</PackageMaxArchitectureVersion>
</PackageInfo>
</BundleInfo>
</PackageInfoList>
</StoreAssociation>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest" xmlns:m2="http://schemas.microsoft.com/appx/2013/manifest">
<Identity Name="53858AleksandarToplek.Sparkiy" Publisher="CN=E746B84B-09A1-43E8-B524-41758B02DFE1" Version="1.1.1.0" />
<Identity Name="53858AleksandarToplek.Sparkiy" Publisher="CN=E746B84B-09A1-43E8-B524-41758B02DFE1" Version="1.3.0.0" />
<Properties>
<DisplayName>Sparkiy</DisplayName>
<PublisherDisplayName>Aleksandar Toplek</PublisherDisplayName>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<NuGetPackageImportStamp>60303db4</NuGetPackageImportStamp>
<AppxAutoIncrementPackageRevision>True</AppxAutoIncrementPackageRevision>
<AppxBundlePlatforms>x86|x64|arm</AppxBundlePlatforms>
<AppxBundle>Always</AppxBundle>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>x86</PlatformTarget>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,18 @@
xmlns:engine="using:SparkiyEngine.Bindings.Component.Engine"
xmlns:playbackControls="using:SparkiyClient.Controls.PlaybackControls"
xmlns:controls="using:SparkiyClient.Controls"
xmlns:converters="using:SparkiyClient.Converters"
mc:Ignorable="d"
RequestedTheme="Light"
DataContext="{Binding Source={StaticResource Locator}, Path=DebugPage}">

<common:PageBase.Resources>
<SolidColorBrush Color="#444" x:Key="NormalMessageForegroundBrush" />
<SolidColorBrush Color="OrangeRed" x:Key="ErrorMessageForegroundBrush" />

<converters:BooleanToBrushConverter x:Key="BooleanToBrushConverterMessages" TrueBrush="{StaticResource ErrorMessageForegroundBrush}" FalseBrush="{StaticResource NormalMessageForegroundBrush}" />
</common:PageBase.Resources>

<common:PageBase.TopAppBar>
<AppBar RequestedTheme="Dark" Background="#111">
<controls:TopNavigationControl Header="{Binding Project.Name, Converter={StaticResource StringFormatConverter}, ConverterParameter=\{0\}\ \-\ Editor}"
Expand Down Expand Up @@ -78,7 +86,7 @@
FontSize="16"
TextWrapping="Wrap"
Padding="8 10 2 10"
Foreground="#444"/>
Foreground="{Binding IsError, Converter={StaticResource BooleanToBrushConverterMessages}}" />
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public sealed class EngineMessage

public BindingTypes SourceType { get; set; }

public bool IsError { get; set; }


public override string ToString()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public interface IEngineBindings : IBindingsBase

#region Scripts

void AddScript(string name, string code);
bool AddScript(string name, string code);

#endregion Scripts

Expand Down
Loading

0 comments on commit e61156d

Please sign in to comment.