Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
88370b1
Syncing with upstream
pre10der89 Oct 31, 2016
f84414a
Merge branch 'master' of https://github.com/ReactWindows/react-native…
pre10der89 Oct 31, 2016
03ced95
Merge branch 'master' of https://github.com/ReactWindows/react-native…
pre10der89 Oct 31, 2016
06f707e
Merge branch 'master' of https://github.com/ReactWindows/react-native…
pre10der89 Nov 1, 2016
4a27072
Merge branch 'master' of https://github.com/ReactWindows/react-native…
pre10der89 Nov 1, 2016
95e155d
Adding shell/MainReactPackage to ReactNative.Net46
pre10der89 Nov 1, 2016
a468c89
Adding Playground.Net46 WPF application with basic ReactNative integr…
pre10der89 Nov 1, 2016
d0665a7
Added a bootstrapper for initializing the ReactPage and the applicati…
pre10der89 Nov 2, 2016
32a32a8
Merge branch 'master' of https://github.com/ReactWindows/react-native…
pre10der89 Nov 2, 2016
0182bf4
Reverting the Examples to the previous version
pre10der89 Nov 2, 2016
c14d959
Merge branch 'master' of https://github.com/ReactWindows/react-native…
pre10der89 Nov 2, 2016
08f2fed
* Restyling Net46 RedBoxDialog and ProgressDialog to fit WPF styling...
pre10der89 Nov 3, 2016
f9f14d2
Merge branch 'master' of https://github.com/pre10der89/react-native-w…
pre10der89 Nov 3, 2016
20e5573
* Moving Progress Design Data to its own file... Renaming existing de…
pre10der89 Nov 3, 2016
6abdbd4
* Implemented a mouse accelerator to invoke the developer support fea…
pre10der89 Nov 5, 2016
826f389
Merge branch 'master' of https://github.com/ReactWindows/react-native…
pre10der89 Nov 5, 2016
d882809
Merge branch 'master' of https://github.com/pre10der89/react-native-w…
pre10der89 Nov 5, 2016
e21fade
* Set RootView to be Focusable and its FocusVisualStyle to null and e…
pre10der89 Nov 8, 2016
f30bd7f
Fixing random issues everywhere...
pre10der89 Nov 8, 2016
d3ca586
Fixing Touch point issues
pre10der89 Nov 8, 2016
7cdbd8b
Final debugging of Playground.Net46 App
pre10der89 Nov 9, 2016
6867174
code cleanup
kevinvangelder Nov 9, 2016
de556c9
upgraded nuget package and implemented websocket module
kevinvangelder Nov 9, 2016
63f0152
Merge branch 'master' of https://github.com/ReactWindows/react-native…
pre10der89 Nov 9, 2016
496aebc
Merge branch 'master' of https://github.com/pre10der89/react-native-w…
pre10der89 Nov 9, 2016
4c2514f
Merge branch 'playground-net46' of https://github.com/pre10der89/reac…
pre10der89 Nov 9, 2016
0bb3309
Merge remote-tracking branch 'upstream2/master' into playground-net46
kevinvangelder Nov 9, 2016
10ae03a
Merge branch 'playground-net46' of https://github.com/pre10der89/reac…
kevinvangelder Nov 9, 2016
42ea822
Fixing failing tests on dispatcher null reference
pre10der89 Nov 9, 2016
e9ae10d
Migrated WebSocketModuleTests to Shared.Tests, Fixed Net46 WebSocketM…
pre10der89 Nov 9, 2016
5baa027
Merge branch 'playground-net46' of https://github.com/pre10der89/reac…
kevinvangelder Nov 10, 2016
680ad10
migrated image component
kevinvangelder Nov 10, 2016
094b92f
merged from upstream/master with playground.net46 changes
kevinvangelder Nov 15, 2016
34eaf63
removed unnecessary files and fixed one missed merge conflict
kevinvangelder Nov 15, 2016
655b654
cleanup to match feedback on initial Playground.Net46 PR
kevinvangelder Nov 17, 2016
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
2 changes: 1 addition & 1 deletion Examples
2 changes: 1 addition & 1 deletion ReactWindows/Playground.Net46/Playground.Net46.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
Expand Down
6 changes: 3 additions & 3 deletions ReactWindows/ReactNative.Net46/DevSupport/ProgressDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="{Binding Path=Heading, Mode=OneTime}"
Style="{DynamicResource ContentDialogStyle}"
Style="{DynamicResource ContentDialogStyle}"
WindowStartupLocation="CenterOwner"
mc:Ignorable="d" d:DesignHeight="125" d:DesignWidth="240">

Expand All @@ -21,7 +21,7 @@
*****************************************************************
Colors
*****************************************************************
-->
-->
<SolidColorBrush x:Key="BackgroundBrush" Color="#FFF2F2F2"/>
<SolidColorBrush x:Key="ForegroundBrush" Color="Black"/>
<SolidColorBrush x:Key="BorderBrush" Color="Blue"/>
Expand All @@ -38,7 +38,7 @@
<RowDefinition Height="5" />
<RowDefinition Height="Auto" />
<RowDefinition Height="15" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>

<TextBlock x:Name="HeadingTextBlock" Grid.Row="0" HorizontalAlignment="Left"
Expand Down
14 changes: 7 additions & 7 deletions ReactWindows/ReactNative.Net46/DevSupport/RedBoxDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@
<RowDefinition/>
</Grid.RowDefinitions>

<TextBlock Grid.Row="0"
<TextBlock Grid.Row="0"
FontFamily="Monospace"
FontSize="12"
Foreground="{StaticResource ForegroundBrush}"
Text="{Binding Path=Method, Mode=OneTime}"/>

<TextBlock Grid.Row="1"
<TextBlock Grid.Row="1"
FontSize="10"
Foreground="LightGray"
TextWrapping="Wrap"
Expand All @@ -54,8 +54,8 @@
</DataTemplate>

</ResourceDictionary>
</Window.Resources>
</Window.Resources>

<Border x:Name="BackgroundElement" Background="{StaticResource BackgroundBrush}" BorderBrush="{StaticResource BorderBrush}" BorderThickness="1" Padding="10,10,10,10">
<Grid x:Name="LayoutRoot" VerticalAlignment="Stretch">
<Grid.RowDefinitions>
Expand All @@ -66,7 +66,7 @@
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>

<TextBlock Grid.Row="0"
<TextBlock Grid.Row="0"
FontFamily="Monospace"
FontSize="14"
FontWeight="SemiBold"
Expand All @@ -75,9 +75,9 @@
TextWrapping="Wrap" />

<ScrollViewer Grid.Row="2" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" ScrollViewer.CanContentScroll="True">
<ListView Background="Transparent"
<ListView Background="Transparent"
BorderThickness="0,0,0,0"
ItemsSource="{Binding Path=StackTrace, Mode=OneWay}"
ItemsSource="{Binding Path=StackTrace, Mode=OneWay}"
ItemTemplate="{StaticResource StackFrameTemplate}">
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
Expand Down
115 changes: 115 additions & 0 deletions ReactWindows/ReactNative.Net46/Modules/Image/BitmapImageHelpers.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
using System;
using System.IO;
using System.Net;
using System.Reactive;
using System.Reactive.Concurrency;
using System.Reactive.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using static System.FormattableString;

namespace ReactNative.Modules.Image
{
static class BitmapImageHelpers
{
public static bool IsBase64Uri(string uri)
{
if (uri == null)
{
throw new ArgumentNullException(nameof(uri));
}

return uri.StartsWith("data:");
}

public static Stream GetStreamAsync(string uri)
{
if (uri == null)
{
throw new ArgumentNullException(nameof(uri));
}

if (IsBase64Uri(uri))
{
var decodedData = Convert.FromBase64String(uri.Substring(uri.IndexOf(",") + 1));
return new MemoryStream(decodedData);
}
else
{
var uriValue = default(Uri);
if (!Uri.TryCreate(uri, UriKind.Absolute, out uriValue))
{
throw new ArgumentOutOfRangeException(nameof(uri), Invariant($"Invalid URI '{uri}' provided."));
}

var streamReference = new StreamReader(WebRequest.Create(uri).GetResponse().GetResponseStream()); //RandomAccessStreamReference.CreateFromUri(uriValue);
return streamReference.BaseStream;
}
}

public static IObservable<ImageStatusEventData> GetStreamLoadObservable(this BitmapImage image)
{
return image.GetOpenedObservable()
.Merge(image.GetFailedObservable(), Scheduler.Default)
.StartWith(new ImageStatusEventData(ImageLoadStatus.OnLoadStart));
}

public static IObservable<ImageStatusEventData> GetUriLoadObservable(this BitmapImage image)
{
return Observable.Merge(
Scheduler.Default,
image.GetDownloadingObservable(),
image.GetOpenedObservable(),
image.GetFailedObservable());
}

private static IObservable<ImageStatusEventData> GetOpenedObservable(this BitmapImage image)
{
return Observable.FromEventPattern<EventHandler, RoutedEventArgs>(
h => image.DownloadCompleted += h,
h => image.DownloadCompleted -= h)
.Select(args =>
{
var bitmapImage = args.Sender as BitmapImage;
if (bitmapImage != null)
{
return new ImageStatusEventData(
ImageLoadStatus.OnLoad,
new ImageMetadata(
image.UriSource?.AbsoluteUri,
image.PixelWidth,
image.PixelHeight));
}
else
{
return new ImageStatusEventData(ImageLoadStatus.OnLoad);
}
})
.Take(1)
.Concat(Observable.Return(new ImageStatusEventData(ImageLoadStatus.OnLoadEnd)));
}

private static IObservable<ImageStatusEventData> GetFailedObservable(this BitmapImage image)
{
return Observable.FromEventPattern<EventHandler<System.Windows.Media.ExceptionEventArgs>, ExceptionRoutedEventArgs>(
h => image.DownloadFailed += h,
h => image.DownloadFailed -= h)
.Select<EventPattern<ExceptionRoutedEventArgs>, ImageStatusEventData>(pattern =>
{
throw new InvalidOperationException(pattern.EventArgs.ErrorException.Message);
});
}

private static IObservable<ImageStatusEventData> GetDownloadingObservable(this BitmapImage image)
{
return Observable.FromEventPattern<EventHandler<DownloadProgressEventArgs>, DownloadProgressChangedEventArgs>(
h => image.DownloadProgress += h,
h => image.DownloadProgress -= h)
.Take(1)
.Select(_ => new ImageStatusEventData(ImageLoadStatus.OnLoadStart));
}
}
}
73 changes: 73 additions & 0 deletions ReactWindows/ReactNative.Net46/Modules/Image/ImageLoaderModule.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
using Newtonsoft.Json.Linq;
using ReactNative.Bridge;
using System;
using System.Reactive.Linq;
using System.Windows.Media.Imaging;

namespace ReactNative.Modules.Image
{
class ImageLoaderModule : NativeModuleBase
{
private const string ErrorInvalidUri = "E_INVALID_URI";
private const string ErrorPrefetchFailure = "E_PREFETCH_FAILURE";
private const string ErrorGetSizeFailure = "E_GET_SIZE_FAILURE";

public override string Name
{
get
{
return "ImageLoader";
}
}

[ReactMethod]
public void prefetchImage(string uriString, IPromise promise)
{
promise.Reject(ErrorPrefetchFailure, "Prefetch is not yet implemented.");
}

[ReactMethod]
public void getSize(string uriString, IPromise promise)
{
if (string.IsNullOrEmpty(uriString))
{
promise.Reject(ErrorInvalidUri, "Cannot get the size of an image for an empty URI.");
return;
}

DispatcherHelpers.RunOnDispatcher(async () =>
{
try
{
var bitmapImage = new BitmapImage();
bitmapImage.BeginInit();
var loadQuery = bitmapImage.GetStreamLoadObservable()
.Where(status => status.LoadStatus == ImageLoadStatus.OnLoadEnd)
.FirstAsync()
.Replay(1);

using (loadQuery.Connect())
{
using (var stream = BitmapImageHelpers.GetStreamAsync(uriString))
{
bitmapImage.StreamSource = stream;
}

await loadQuery;
bitmapImage.EndInit();

promise.Resolve(new JObject
{
{ "width", bitmapImage.PixelWidth },
{ "height", bitmapImage.PixelHeight },
});
}
}
catch (Exception ex)
{
promise.Reject(ErrorGetSizeFailure, ex.Message);
}
});
}
}
}
2 changes: 2 additions & 0 deletions ReactWindows/ReactNative.Net46/ReactNative.Net46.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@
</Compile>
<Compile Include="DevSupport\WebSocketJavaScriptExecutor.cs" />
<Compile Include="Modules\Dialog\DialogModule.cs" />
<Compile Include="Modules\Image\BitmapImageHelpers.cs" />
<Compile Include="Modules\Image\ImageLoaderModule.cs" />
<Compile Include="Modules\Storage\AsyncStorageModule.cs" />
<Compile Include="Modules\Clipboard\ClipboardModule.cs" />
<Compile Include="Modules\Clipboard\ClipboardInstance.cs" />
Expand Down
2 changes: 1 addition & 1 deletion ReactWindows/ReactNative.Net46/ReactPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ protected virtual ReactRootView CreateRootView()
}

/// <summary>
/// Captures the all key downs and Ups.
/// Captures the all key downs and Ups.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
Expand Down
9 changes: 6 additions & 3 deletions ReactWindows/ReactNative.Net46/Shell/MainReactPackage.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
using ReactNative.Bridge;
using ReactNative.Animated;
using ReactNative.Bridge;
using ReactNative.Modules.AppState;
using ReactNative.Modules.Clipboard;
using ReactNative.Modules.Core;
using ReactNative.Modules.Dialog;
using ReactNative.Modules.Image;
using ReactNative.Modules.I18N;
using ReactNative.Modules.NetInfo;
using ReactNative.Modules.Network;
using ReactNative.Modules.Storage;
using ReactNative.Modules.WebSocket;
using ReactNative.UIManager;
using ReactNative.Views.Image;
using ReactNative.Views.Text;
using ReactNative.Views.View;
using System;
Expand Down Expand Up @@ -36,7 +39,7 @@ public IReadOnlyList<INativeModule> CreateNativeModules(ReactContext reactContex
//new CameraRollManager(reactContext),
new ClipboardModule(),
new DialogModule(reactContext),
//new ImageLoaderModule(),
new ImageLoaderModule(),
new I18NModule(),
//new LauncherModule(reactContext),
//new LocationModule(reactContext),
Expand Down Expand Up @@ -71,7 +74,7 @@ public IReadOnlyList<IViewManager> CreateViewManagers(
return new List<IViewManager>
{
//new ReactFlipViewManager(),
//new ReactImageManager(),
new ReactImageManager(),
//new ReactProgressBarViewManager(),
//new ReactProgressRingViewManager(),
//new ReactPickerManager(),
Expand Down
6 changes: 3 additions & 3 deletions ReactWindows/ReactNative.Net46/UIManager/UIManagerModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public UIImplementation UIImplementation
/// <param name="rootView">The root view instance.</param>
/// <returns>The root view tag.</returns>
/// <remarks>
/// JavaScript can use the returned tag with to add or remove children
/// JavaScript can use the returned tag with to add or remove children
/// to this view through <see cref="manageChildren(int, int[], int[], int[], int[], int[])"/>.
/// </remarks>
public int AddMeasuredRootView(SizeMonitoringCanvas rootView)
Expand Down Expand Up @@ -213,7 +213,7 @@ public void manageChildren(
}

/// <summary>
/// Interface for fast tracking the initial adding of views.Children
/// Interface for fast tracking the initial adding of views.Children
/// view tags are assumed to be in order.
/// </summary>
/// <param name="viewTag">The view tag of the parent view.</param>
Expand All @@ -231,7 +231,7 @@ public void setChildren(
/// <summary>
/// Replaces the view specified by the <paramref name="oldTag"/> with
/// the view specified by <paramref name="newTag"/> within
/// <paramref name="oldTag"/>'s parent. This resolves to a simple
/// <paramref name="oldTag"/>'s parent. This resolves to a simple
/// <see cref="manageChildren(int, int[], int[], int[], int[], int[])"/>
/// call, but React does not have enough information in JavaScript to
/// formulate it itself.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Linq;
Copy link
Contributor Author

@kevinvangelder kevinvangelder Nov 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

¯\_(ツ)_/¯

using NUnit.Framework;
using ReactNative.Bridge;
using ReactNative.Modules.Core;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ public bool IsReloadOnJavaScriptChangeEnabled
}
}


//TODO: Git Issue #878
private T GetSetting<T>(string key, T defaultValue)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ private async Task ReloadJavaScriptFromServerAsync(Action dismissProgress, Cance
if (temporaryFile != null)
{
await temporaryFile.DeleteAsync(token).ConfigureAwait(false);
}
}
}
}
#endif
Expand Down
Loading