12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- using Newtonsoft.Json.Linq;
- using ReactNative.Bridge;
- using ReactNative.UIManager;
- using System;
- using System.IO;
- using System.Collections.Generic;
- using Windows.ApplicationModel.Core;
- using Windows.UI.Core;
-
- namespace RNViewShot
- {
-
-
-
- class RNViewShotModule : ReactContextNativeModuleBase
- {
- private const string ErrorUnableToSnapshot = "E_UNABLE_TO_SNAPSHOT";
- private readonly ReactContext _reactContext;
-
-
-
-
- public RNViewShotModule(ReactContext reactContext) : base(reactContext)
- {
- this._reactContext = reactContext;
- }
-
-
-
-
- public override string Name
- {
- get
- {
- return "RNViewShot";
- }
- }
-
- [ReactMethod]
- public void takeSnapshot(int tag, JObject options, IPromise promise)
- {
- string format = options["format"] != null ? options.Value<string>("format") : "png";
-
-
-
-
-
-
-
-
-
-
-
-
-
- double quality = options["quality"] != null ? options.Value<double>("quality") : 1.0;
- int? width = options["width"] != null ? options.Value<int?>("width") : null;
- int? height = options["height"] != null ? options.Value<int?>("height") : null;
- string result = options["result"] != null ? options.Value<string>("result") : "file";
- bool snapshotContentContainer = options["snapshotContentContainer"] != null ? options.Value<bool>("snapshotContentContainer") : false;
-
- UIManagerModule uiManager = this._reactContext.GetNativeModule<UIManagerModule>();
- uiManager.AddUIBlock(new ViewShot(tag));
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- promise.Resolve("Format: " + format + " Quality: " + quality);
- }
- }
- }
|