Browse Source

Add WPF variant

Ryan Linton 7 years ago
parent
commit
9f1265ff65

+ 9
- 0
jsconfig.json View File

@@ -0,0 +1,9 @@
1
+{
2
+    "compilerOptions": {
3
+        "allowJs": true,
4
+        "allowSyntheticDefaultImports": true
5
+    },
6
+    "exclude": [
7
+        "node_modules"
8
+    ]
9
+}

+ 36
- 0
windows/RNViewShot.Net46/Properties/AssemblyInfo.cs View File

@@ -0,0 +1,36 @@
1
+using System.Reflection;
2
+using System.Runtime.CompilerServices;
3
+using System.Runtime.InteropServices;
4
+
5
+// General Information about an assembly is controlled through the following 
6
+// set of attributes. Change these attribute values to modify the information
7
+// associated with an assembly.
8
+[assembly: AssemblyTitle("RNViewShot.Net46")]
9
+[assembly: AssemblyDescription("")]
10
+[assembly: AssemblyConfiguration("")]
11
+[assembly: AssemblyCompany("")]
12
+[assembly: AssemblyProduct("RNViewShot.Net46")]
13
+[assembly: AssemblyCopyright("Copyright ©  2017")]
14
+[assembly: AssemblyTrademark("")]
15
+[assembly: AssemblyCulture("")]
16
+
17
+// Setting ComVisible to false makes the types in this assembly not visible 
18
+// to COM components.  If you need to access a type in this assembly from 
19
+// COM, set the ComVisible attribute to true on that type.
20
+[assembly: ComVisible(false)]
21
+
22
+// The following GUID is for the ID of the typelib if this project is exposed to COM
23
+[assembly: Guid("1dd45d00-ddf4-43b4-ab28-f98e6dc325b5")]
24
+
25
+// Version information for an assembly consists of the following four values:
26
+//
27
+//      Major Version
28
+//      Minor Version 
29
+//      Build Number
30
+//      Revision
31
+//
32
+// You can specify all the values or you can default the Build and Revision Numbers 
33
+// by using the '*' as shown below:
34
+// [assembly: AssemblyVersion("1.0.*")]
35
+[assembly: AssemblyVersion("1.0.0.0")]
36
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 106
- 0
windows/RNViewShot.Net46/RNViewShot.Net46.csproj View File

@@ -0,0 +1,106 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4
+  <PropertyGroup>
5
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7
+    <ProjectGuid>{1DD45D00-DDF4-43B4-AB28-F98E6DC325B5}</ProjectGuid>
8
+    <OutputType>Library</OutputType>
9
+    <AppDesignerFolder>Properties</AppDesignerFolder>
10
+    <RootNamespace>RNViewShot.Net46</RootNamespace>
11
+    <AssemblyName>RNViewShot.Net46</AssemblyName>
12
+    <TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
13
+    <FileAlignment>512</FileAlignment>
14
+  </PropertyGroup>
15
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16
+    <DebugSymbols>true</DebugSymbols>
17
+    <DebugType>full</DebugType>
18
+    <Optimize>false</Optimize>
19
+    <OutputPath>bin\Debug\</OutputPath>
20
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
21
+    <ErrorReport>prompt</ErrorReport>
22
+    <WarningLevel>4</WarningLevel>
23
+  </PropertyGroup>
24
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
25
+    <DebugType>pdbonly</DebugType>
26
+    <Optimize>true</Optimize>
27
+    <OutputPath>bin\Release\</OutputPath>
28
+    <DefineConstants>TRACE</DefineConstants>
29
+    <ErrorReport>prompt</ErrorReport>
30
+    <WarningLevel>4</WarningLevel>
31
+  </PropertyGroup>
32
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
33
+    <DebugSymbols>true</DebugSymbols>
34
+    <OutputPath>bin\x86\Debug\</OutputPath>
35
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
36
+    <DebugType>full</DebugType>
37
+    <PlatformTarget>x86</PlatformTarget>
38
+    <ErrorReport>prompt</ErrorReport>
39
+    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
40
+  </PropertyGroup>
41
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
42
+    <OutputPath>bin\x86\Release\</OutputPath>
43
+    <DefineConstants>TRACE</DefineConstants>
44
+    <Optimize>true</Optimize>
45
+    <DebugType>pdbonly</DebugType>
46
+    <PlatformTarget>x86</PlatformTarget>
47
+    <ErrorReport>prompt</ErrorReport>
48
+    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
49
+  </PropertyGroup>
50
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
51
+    <DebugSymbols>true</DebugSymbols>
52
+    <OutputPath>bin\x64\Debug\</OutputPath>
53
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
54
+    <DebugType>full</DebugType>
55
+    <PlatformTarget>x64</PlatformTarget>
56
+    <ErrorReport>prompt</ErrorReport>
57
+    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
58
+  </PropertyGroup>
59
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
60
+    <OutputPath>bin\x64\Release\</OutputPath>
61
+    <DefineConstants>TRACE</DefineConstants>
62
+    <Optimize>true</Optimize>
63
+    <DebugType>pdbonly</DebugType>
64
+    <PlatformTarget>x64</PlatformTarget>
65
+    <ErrorReport>prompt</ErrorReport>
66
+    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
67
+  </PropertyGroup>
68
+  <ItemGroup>
69
+    <Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
70
+      <HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
71
+      <Private>True</Private>
72
+    </Reference>
73
+    <Reference Include="System" />
74
+    <Reference Include="System.Core" />
75
+    <Reference Include="System.Xml.Linq" />
76
+    <Reference Include="System.Data.DataSetExtensions" />
77
+    <Reference Include="Microsoft.CSharp" />
78
+    <Reference Include="System.Data" />
79
+    <Reference Include="System.Net.Http" />
80
+    <Reference Include="System.Xml" />
81
+  </ItemGroup>
82
+  <ItemGroup>
83
+    <Compile Include="Properties\AssemblyInfo.cs" />
84
+    <Compile Include="RNViewShotModule.cs" />
85
+    <Compile Include="RNViewShotPackage.cs" />
86
+    <Compile Include="ViewShot.cs" />
87
+  </ItemGroup>
88
+  <ItemGroup>
89
+    <ProjectReference Include="..\..\node_modules\react-native-windows\ReactWindows\ReactNative.Net46\ReactNative.Net46.csproj">
90
+      <Project>{22cbff9c-fe36-43e8-a246-266c7635e662}</Project>
91
+      <Name>ReactNative.Net46</Name>
92
+    </ProjectReference>
93
+  </ItemGroup>
94
+  <ItemGroup>
95
+    <None Include="app.config" />
96
+    <None Include="packages.config" />
97
+  </ItemGroup>
98
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
99
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
100
+       Other similar extension points exist, see Microsoft.Common.targets.
101
+  <Target Name="BeforeBuild">
102
+  </Target>
103
+  <Target Name="AfterBuild">
104
+  </Target>
105
+  -->
106
+</Project>

+ 78
- 0
windows/RNViewShot.Net46/RNViewShotModule.cs View File

@@ -0,0 +1,78 @@
1
+using Newtonsoft.Json.Linq;
2
+using ReactNative.Bridge;
3
+using System;
4
+using System.Collections.Generic;
5
+//using Windows.ApplicationModel.Core;
6
+//using Windows.UI.Core;
7
+
8
+namespace RNViewShot
9
+{
10
+    /// <summary>
11
+    /// A module that allows JS to share data.
12
+    /// </summary>
13
+    class RNViewShotModule : ReactContextNativeModuleBase
14
+    {
15
+        private ReactContext reactContext;
16
+
17
+        /// <summary>
18
+        /// Instantiates the <see cref="RNViewShotModule"/>.
19
+        /// </summary>
20
+        public RNViewShotModule(ReactContext reactContext) : base(reactContext) 
21
+        {
22
+            this.reactContext = reactContext;
23
+        }
24
+
25
+        /// <summary>
26
+        /// The name of the native module.
27
+        /// </summary>
28
+        public override string Name
29
+        {
30
+            get
31
+            {
32
+                return "RNViewShot";
33
+            }
34
+        }
35
+
36
+        [ReactMethod]
37
+        public void takeSnapshot(int tag, JObject options, IPromise promise) {
38
+            // Android Equivalent Code
39
+            //ReactApplicationContext context = getReactApplicationContext();
40
+            //String format = options.hasKey("format") ? options.getString("format") : "png";
41
+            //Bitmap.CompressFormat compressFormat =
42
+            //        format.equals("png")
43
+            //                ? Bitmap.CompressFormat.PNG
44
+            //                : format.equals("jpg") || format.equals("jpeg")
45
+            //                ? Bitmap.CompressFormat.JPEG
46
+            //                : format.equals("webm")
47
+            //                ? Bitmap.CompressFormat.WEBP
48
+            //                : null;
49
+            //if (compressFormat == null)
50
+            //{
51
+            //    promise.reject(ViewShot.ERROR_UNABLE_TO_SNAPSHOT, "Unsupported image format: " + format + ". Try one of: png | jpg | jpeg");
52
+            //    return;
53
+            //}
54
+            //double quality = options.hasKey("quality") ? options.getDouble("quality") : 1.0;
55
+            //DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
56
+            //Integer width = options.hasKey("width") ? (int)(displayMetrics.density * options.getDouble("width")) : null;
57
+            //Integer height = options.hasKey("height") ? (int)(displayMetrics.density * options.getDouble("height")) : null;
58
+            //String result = options.hasKey("result") ? options.getString("result") : "file";
59
+            //Boolean snapshotContentContainer = options.hasKey("snapshotContentContainer") ? options.getBoolean("snapshotContentContainer") : false;
60
+            //try
61
+            //{
62
+            //    String name = options.hasKey("filename") ? options.getString("filename") : null;
63
+            //    File tmpFile = "file".equals(result) ? createTempFile(getReactApplicationContext(), format, name) : null;
64
+            //    UIManagerModule uiManager = this.reactContext.getNativeModule(UIManagerModule.class);
65
+            //    uiManager.addUIBlock(new ViewShot(tag, format, compressFormat, quality, width, height, tmpFile, result, snapshotContentContainer, promise));
66
+            //}
67
+            //catch (Exception e) {
68
+            //    promise.reject(ViewShot.ERROR_UNABLE_TO_SNAPSHOT, "Failed to snapshot view tag "+tag);
69
+            //}
70
+
71
+            //Bitmap bitmap = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
72
+            //Graphics graphics = Graphics.FromImage(bitmap as Image);
73
+            //graphics.CopyFromScreen(0, 0, 0, 0, bitmap.Size);
74
+            //bitmap.Save("c:\\screenshot.jpeg", ImageFormat.Jpeg);
75
+            promise.Resolve("This is working!");
76
+        }
77
+    }
78
+}

+ 53
- 0
windows/RNViewShot.Net46/RNViewShotPackage.cs View File

@@ -0,0 +1,53 @@
1
+using ReactNative.Bridge;
2
+using ReactNative.Modules.Core;
3
+using ReactNative.UIManager;
4
+using System;
5
+using System.Collections.Generic;
6
+
7
+namespace RNViewShot
8
+{
9
+    /// <summary>
10
+    /// Package defining core framework modules (e.g., <see cref="UIManagerModule"/>).
11
+    /// It should be used for modules that require special integration with
12
+    /// other framework parts (e.g., with the list of packages to load view
13
+    /// managers from).
14
+    /// </summary>
15
+    public class RNViewShotPackage : IReactPackage
16
+    {
17
+        /// <summary>
18
+        /// Creates the list of native modules to register with the react
19
+        /// instance.
20
+        /// </summary>
21
+        /// <param name="reactContext">The react application context.</param>
22
+        /// <returns>The list of native modules.</returns>
23
+        public IReadOnlyList<INativeModule> CreateNativeModules(ReactContext reactContext)
24
+        {
25
+            return new List<INativeModule>
26
+            {
27
+                new RNViewShotModule(reactContext),
28
+            };
29
+        }
30
+
31
+        /// <summary>
32
+        /// Creates the list of JavaScript modules to register with the
33
+        /// react instance.
34
+        /// </summary>
35
+        /// <returns>The list of JavaScript modules.</returns>
36
+        public IReadOnlyList<Type> CreateJavaScriptModulesConfig()
37
+        {
38
+            return new List<Type>(0);
39
+        }
40
+
41
+        /// <summary>
42
+        /// Creates the list of view managers that should be registered with
43
+        /// the <see cref="UIManagerModule"/>.
44
+        /// </summary>
45
+        /// <param name="reactContext">The react application context.</param>
46
+        /// <returns>The list of view managers.</returns>
47
+        public IReadOnlyList<IViewManager> CreateViewManagers(
48
+            ReactContext reactContext)
49
+        {
50
+            return new List<IViewManager>(0);
51
+        }
52
+    }
53
+}

+ 12
- 0
windows/RNViewShot.Net46/ViewShot.cs View File

@@ -0,0 +1,12 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+
7
+namespace RNViewShot
8
+{
9
+    class ViewShot
10
+    {
11
+    }
12
+}

+ 11
- 0
windows/RNViewShot.Net46/app.config View File

@@ -0,0 +1,11 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<configuration>
3
+  <runtime>
4
+    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
5
+      <dependentAssembly>
6
+        <assemblyIdentity name="System.Reactive.Core" publicKeyToken="94bc3704cddfc263" culture="neutral" />
7
+        <bindingRedirect oldVersion="0.0.0.0-3.0.3000.0" newVersion="3.0.3000.0" />
8
+      </dependentAssembly>
9
+    </assemblyBinding>
10
+  </runtime>
11
+</configuration>

+ 4
- 0
windows/RNViewShot.Net46/packages.config View File

@@ -0,0 +1,4 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<packages>
3
+  <package id="Newtonsoft.Json" version="9.0.1" targetFramework="net46" />
4
+</packages>

+ 51
- 0
windows/RNViewShot.sln View File

@@ -8,8 +8,13 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReactNative", "..\node_modu
8 8
 EndProject
9 9
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ChakraBridge", "..\node_modules\react-native-windows\ReactWindows\ChakraBridge\ChakraBridge.vcxproj", "{4B72C796-16D5-4E3A-81C0-3E36F531E578}"
10 10
 EndProject
11
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReactNative.Net46", "..\node_modules\react-native-windows\ReactWindows\ReactNative.Net46\ReactNative.Net46.csproj", "{22CBFF9C-FE36-43E8-A246-266C7635E662}"
12
+EndProject
13
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RNViewShot.Net46", "RNViewShot.Net46\RNViewShot.Net46.csproj", "{1DD45D00-DDF4-43B4-AB28-F98E6DC325B5}"
14
+EndProject
11 15
 Global
12 16
 	GlobalSection(SharedMSBuildProjectFiles) = preSolution
17
+		..\node_modules\react-native-windows\ReactWindows\ReactNative.Shared\ReactNative.Shared.projitems*{22cbff9c-fe36-43e8-a246-266c7635e662}*SharedItemsImports = 4
13 18
 		..\node_modules\react-native-windows\ReactWindows\ReactNative.Shared\ReactNative.Shared.projitems*{c7673ad5-e3aa-468c-a5fd-fa38154e205c}*SharedItemsImports = 4
14 19
 	EndGlobalSection
15 20
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -95,6 +100,52 @@ Global
95 100
 		{4B72C796-16D5-4E3A-81C0-3E36F531E578}.Release|x64.Build.0 = Release|x64
96 101
 		{4B72C796-16D5-4E3A-81C0-3E36F531E578}.Release|x86.ActiveCfg = Release|Win32
97 102
 		{4B72C796-16D5-4E3A-81C0-3E36F531E578}.Release|x86.Build.0 = Release|Win32
103
+		{22CBFF9C-FE36-43E8-A246-266C7635E662}.Debug|Any CPU.ActiveCfg = Debug|x86
104
+		{22CBFF9C-FE36-43E8-A246-266C7635E662}.Debug|ARM.ActiveCfg = Debug|ARM
105
+		{22CBFF9C-FE36-43E8-A246-266C7635E662}.Debug|ARM.Build.0 = Debug|ARM
106
+		{22CBFF9C-FE36-43E8-A246-266C7635E662}.Debug|x64.ActiveCfg = Debug|x64
107
+		{22CBFF9C-FE36-43E8-A246-266C7635E662}.Debug|x64.Build.0 = Debug|x64
108
+		{22CBFF9C-FE36-43E8-A246-266C7635E662}.Debug|x86.ActiveCfg = Debug|x86
109
+		{22CBFF9C-FE36-43E8-A246-266C7635E662}.Debug|x86.Build.0 = Debug|x86
110
+		{22CBFF9C-FE36-43E8-A246-266C7635E662}.Development|Any CPU.ActiveCfg = Release|ARM
111
+		{22CBFF9C-FE36-43E8-A246-266C7635E662}.Development|Any CPU.Build.0 = Release|ARM
112
+		{22CBFF9C-FE36-43E8-A246-266C7635E662}.Development|ARM.ActiveCfg = Debug|ARM
113
+		{22CBFF9C-FE36-43E8-A246-266C7635E662}.Development|ARM.Build.0 = Debug|ARM
114
+		{22CBFF9C-FE36-43E8-A246-266C7635E662}.Development|x64.ActiveCfg = Debug|x64
115
+		{22CBFF9C-FE36-43E8-A246-266C7635E662}.Development|x64.Build.0 = Debug|x64
116
+		{22CBFF9C-FE36-43E8-A246-266C7635E662}.Development|x86.ActiveCfg = Debug|x86
117
+		{22CBFF9C-FE36-43E8-A246-266C7635E662}.Development|x86.Build.0 = Debug|x86
118
+		{22CBFF9C-FE36-43E8-A246-266C7635E662}.Release|Any CPU.ActiveCfg = Release|x86
119
+		{22CBFF9C-FE36-43E8-A246-266C7635E662}.Release|ARM.ActiveCfg = Release|ARM
120
+		{22CBFF9C-FE36-43E8-A246-266C7635E662}.Release|ARM.Build.0 = Release|ARM
121
+		{22CBFF9C-FE36-43E8-A246-266C7635E662}.Release|x64.ActiveCfg = Release|x64
122
+		{22CBFF9C-FE36-43E8-A246-266C7635E662}.Release|x64.Build.0 = Release|x64
123
+		{22CBFF9C-FE36-43E8-A246-266C7635E662}.Release|x86.ActiveCfg = Release|x86
124
+		{22CBFF9C-FE36-43E8-A246-266C7635E662}.Release|x86.Build.0 = Release|x86
125
+		{1DD45D00-DDF4-43B4-AB28-F98E6DC325B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
126
+		{1DD45D00-DDF4-43B4-AB28-F98E6DC325B5}.Debug|Any CPU.Build.0 = Debug|Any CPU
127
+		{1DD45D00-DDF4-43B4-AB28-F98E6DC325B5}.Debug|ARM.ActiveCfg = Debug|x86
128
+		{1DD45D00-DDF4-43B4-AB28-F98E6DC325B5}.Debug|ARM.Build.0 = Debug|x86
129
+		{1DD45D00-DDF4-43B4-AB28-F98E6DC325B5}.Debug|x64.ActiveCfg = Debug|x64
130
+		{1DD45D00-DDF4-43B4-AB28-F98E6DC325B5}.Debug|x64.Build.0 = Debug|x64
131
+		{1DD45D00-DDF4-43B4-AB28-F98E6DC325B5}.Debug|x86.ActiveCfg = Debug|x86
132
+		{1DD45D00-DDF4-43B4-AB28-F98E6DC325B5}.Debug|x86.Build.0 = Debug|x86
133
+		{1DD45D00-DDF4-43B4-AB28-F98E6DC325B5}.Development|Any CPU.ActiveCfg = Debug|Any CPU
134
+		{1DD45D00-DDF4-43B4-AB28-F98E6DC325B5}.Development|Any CPU.Build.0 = Debug|Any CPU
135
+		{1DD45D00-DDF4-43B4-AB28-F98E6DC325B5}.Development|ARM.ActiveCfg = Debug|x86
136
+		{1DD45D00-DDF4-43B4-AB28-F98E6DC325B5}.Development|ARM.Build.0 = Debug|x86
137
+		{1DD45D00-DDF4-43B4-AB28-F98E6DC325B5}.Development|x64.ActiveCfg = Debug|x64
138
+		{1DD45D00-DDF4-43B4-AB28-F98E6DC325B5}.Development|x64.Build.0 = Debug|x64
139
+		{1DD45D00-DDF4-43B4-AB28-F98E6DC325B5}.Development|x86.ActiveCfg = Debug|x86
140
+		{1DD45D00-DDF4-43B4-AB28-F98E6DC325B5}.Development|x86.Build.0 = Debug|x86
141
+		{1DD45D00-DDF4-43B4-AB28-F98E6DC325B5}.Release|Any CPU.ActiveCfg = Release|Any CPU
142
+		{1DD45D00-DDF4-43B4-AB28-F98E6DC325B5}.Release|Any CPU.Build.0 = Release|Any CPU
143
+		{1DD45D00-DDF4-43B4-AB28-F98E6DC325B5}.Release|ARM.ActiveCfg = Release|x86
144
+		{1DD45D00-DDF4-43B4-AB28-F98E6DC325B5}.Release|ARM.Build.0 = Release|x86
145
+		{1DD45D00-DDF4-43B4-AB28-F98E6DC325B5}.Release|x64.ActiveCfg = Release|x64
146
+		{1DD45D00-DDF4-43B4-AB28-F98E6DC325B5}.Release|x64.Build.0 = Release|x64
147
+		{1DD45D00-DDF4-43B4-AB28-F98E6DC325B5}.Release|x86.ActiveCfg = Release|x86
148
+		{1DD45D00-DDF4-43B4-AB28-F98E6DC325B5}.Release|x86.Build.0 = Release|x86
98 149
 	EndGlobalSection
99 150
 	GlobalSection(SolutionProperties) = preSolution
100 151
 		HideSolutionNode = FALSE

+ 3
- 2
windows/RNViewShot/RNViewShot.csproj View File

@@ -16,7 +16,7 @@
16 16
     <MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
17 17
     <FileAlignment>512</FileAlignment>
18 18
     <ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
19
-    <ReactWindowsRoot>..\..\node_modules</ReactWindowsRoot>
19
+    <ReactWindowsRoot>$(SolutionDir)..\node_modules</ReactWindowsRoot>
20 20
   </PropertyGroup>
21 21
   <PropertyGroup Condition=" '$(Configuration)' != 'Development'">
22 22
     <ReactWindowsRoot>..\..</ReactWindowsRoot>
@@ -114,10 +114,11 @@
114 114
     <Compile Include="Properties\AssemblyInfo.cs" />
115 115
     <Compile Include="RNViewShotModule.cs" />
116 116
     <Compile Include="RNViewShotPackage.cs" />
117
+    <Compile Include="ViewShot.cs" />
117 118
     <EmbeddedResource Include="Properties\RNViewShot.rd.xml" />
118 119
   </ItemGroup>
119 120
   <ItemGroup>
120
-    <ProjectReference Include="..\..\node_modules\react-native-windows\ReactWindows\ReactNative\ReactNative.csproj">
121
+    <ProjectReference Include="$(SolutionDir)..\node_modules\react-native-windows\ReactWindows\ReactNative\ReactNative.csproj">
121 122
       <Project>{c7673ad5-e3aa-468c-a5fd-fa38154e205c}</Project>
122 123
       <Name>ReactNative</Name>
123 124
     </ProjectReference>

+ 46
- 5
windows/RNViewShot/RNViewShotModule.cs View File

@@ -5,19 +5,21 @@ using System.Collections.Generic;
5 5
 using Windows.ApplicationModel.Core;
6 6
 using Windows.UI.Core;
7 7
 
8
-namespace Com.Reactlibrary.RNViewShot
8
+namespace RNViewShot
9 9
 {
10 10
     /// <summary>
11 11
     /// A module that allows JS to share data.
12 12
     /// </summary>
13
-    class RNViewShotModule : NativeModuleBase
13
+    class RNViewShotModule : ReactContextNativeModuleBase
14 14
     {
15
+        private ReactContext reactContext;
16
+
15 17
         /// <summary>
16 18
         /// Instantiates the <see cref="RNViewShotModule"/>.
17 19
         /// </summary>
18
-        internal RNViewShotModule()
20
+        public RNViewShotModule(ReactContext reactContext) : base(reactContext) 
19 21
         {
20
-
22
+            this.reactContext = reactContext;
21 23
         }
22 24
 
23 25
         /// <summary>
@@ -32,6 +34,45 @@ namespace Com.Reactlibrary.RNViewShot
32 34
         }
33 35
 
34 36
         [ReactMethod]
35
-        public void takeSnapshot(int tag, JObject options, IPromise promise) {}
37
+        public void takeSnapshot(int tag, JObject options, IPromise promise) {
38
+            // Android Equivalent Code
39
+            //ReactApplicationContext context = getReactApplicationContext();
40
+            //String format = options.hasKey("format") ? options.getString("format") : "png";
41
+            //Bitmap.CompressFormat compressFormat =
42
+            //        format.equals("png")
43
+            //                ? Bitmap.CompressFormat.PNG
44
+            //                : format.equals("jpg") || format.equals("jpeg")
45
+            //                ? Bitmap.CompressFormat.JPEG
46
+            //                : format.equals("webm")
47
+            //                ? Bitmap.CompressFormat.WEBP
48
+            //                : null;
49
+            //if (compressFormat == null)
50
+            //{
51
+            //    promise.reject(ViewShot.ERROR_UNABLE_TO_SNAPSHOT, "Unsupported image format: " + format + ". Try one of: png | jpg | jpeg");
52
+            //    return;
53
+            //}
54
+            //double quality = options.hasKey("quality") ? options.getDouble("quality") : 1.0;
55
+            //DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
56
+            //Integer width = options.hasKey("width") ? (int)(displayMetrics.density * options.getDouble("width")) : null;
57
+            //Integer height = options.hasKey("height") ? (int)(displayMetrics.density * options.getDouble("height")) : null;
58
+            //String result = options.hasKey("result") ? options.getString("result") : "file";
59
+            //Boolean snapshotContentContainer = options.hasKey("snapshotContentContainer") ? options.getBoolean("snapshotContentContainer") : false;
60
+            //try
61
+            //{
62
+            //    String name = options.hasKey("filename") ? options.getString("filename") : null;
63
+            //    File tmpFile = "file".equals(result) ? createTempFile(getReactApplicationContext(), format, name) : null;
64
+            //    UIManagerModule uiManager = this.reactContext.getNativeModule(UIManagerModule.class);
65
+            //    uiManager.addUIBlock(new ViewShot(tag, format, compressFormat, quality, width, height, tmpFile, result, snapshotContentContainer, promise));
66
+            //}
67
+            //catch (Exception e) {
68
+            //    promise.reject(ViewShot.ERROR_UNABLE_TO_SNAPSHOT, "Failed to snapshot view tag "+tag);
69
+            //}
70
+
71
+            //Bitmap bitmap = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
72
+            //Graphics graphics = Graphics.FromImage(bitmap as Image);
73
+            //graphics.CopyFromScreen(0, 0, 0, 0, bitmap.Size);
74
+            //bitmap.Save("c:\\screenshot.jpeg", ImageFormat.Jpeg);
75
+            promise.Resolve("This is working!");
76
+        }
36 77
     }
37 78
 }

+ 2
- 2
windows/RNViewShot/RNViewShotPackage.cs View File

@@ -4,7 +4,7 @@ using ReactNative.UIManager;
4 4
 using System;
5 5
 using System.Collections.Generic;
6 6
 
7
-namespace Com.Reactlibrary.RNViewShot
7
+namespace RNViewShot
8 8
 {
9 9
     /// <summary>
10 10
     /// Package defining core framework modules (e.g., <see cref="UIManagerModule"/>).
@@ -24,7 +24,7 @@ namespace Com.Reactlibrary.RNViewShot
24 24
         {
25 25
             return new List<INativeModule>
26 26
             {
27
-                new RNViewShotModule(),
27
+                new RNViewShotModule(reactContext),
28 28
             };
29 29
         }
30 30
 

+ 12
- 0
windows/RNViewShot/ViewShot.cs View File

@@ -0,0 +1,12 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+
7
+namespace RNViewShot
8
+{
9
+    class ViewShot
10
+    {
11
+    }
12
+}