Exemple #1
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            using (var sps = new XamlControlPhotoService())
            {
                sps.SetCaptureElement(Capature);
                await sps.InitializeAsync();

                var photo = await sps.GetPhotoStreamAsync();

                var bms = new BitmapImage();
                var ra  = new Windows.Storage.Streams.InMemoryRandomAccessStream();
                await photo.CopyToAsync(ra.AsStreamForWrite());

                await bms.SetSourceAsync(ra);

                Image.Source = bms;
                await sps.CleanupAsync();
            }
        }
Exemple #2
0
        public MainPage()
        {
            this.InitializeComponent();
            NavigationCacheMode = Windows.UI.Xaml.Navigation.NavigationCacheMode.Required;

            AppCallbacks appCallbacks = AppCallbacks.Instance;

            // Setup scripting bridge
            _bridge = new WinRTBridge.WinRTBridge();
            appCallbacks.SetBridge(_bridge);

            bool isWindowsHolographic = false;

#if UNITY_HOLOGRAPHIC
            // If application was exported as Holographic check if the deviceFamily actually supports it,
            // otherwise we treat this as a normal XAML application
            string deviceFamily = Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily;
            isWindowsHolographic = String.Compare("Windows.Holographic", deviceFamily) == 0;
#endif

            this.Loaded += (sender, args) =>
            {
                var svc = new XamlControlPhotoService();
                svc.SetCaptureElement(Capture);


                QRPhotoTakerXAML.Capture = svc;
                if (isWindowsHolographic)
                {
                    appCallbacks.InitializeViewManager(Window.Current.CoreWindow);
                }
                else
                {
                    appCallbacks.RenderingStarted += () => { RemoveSplashScreen(); };

#if UNITY_UWP
                    if (Windows.Foundation.Metadata.ApiInformation.IsApiContractPresent("Windows.Phone.PhoneContract", 1))
                    {
                        isPhone = true;
                    }
#endif
#if !UNITY_WP_8_1
                    appCallbacks.SetKeyboardTriggerControl(this);
#else
                    isPhone = true;
#endif
                    appCallbacks.SetSwapChainPanel(GetSwapChainPanel());
                    appCallbacks.SetCoreWindowEvents(Window.Current.CoreWindow);
                    appCallbacks.InitializeD3DXAML();

                    splash = ((App)App.Current).splashScreen;
                    GetSplashBackgroundColor();
                    OnResize();
                    onResizeHandler             = new WindowSizeChangedEventHandler((o, e) => OnResize());
                    Window.Current.SizeChanged += onResizeHandler;

#if UNITY_WP_8_1
                    onRotationChangedHandler = new TypedEventHandler <DisplayInformation, object>((di, o) => { OnRotate(di); });
                    ExtendedSplashImage.RenderTransformOrigin = new Point(0.5, 0.5);
                    var displayInfo = DisplayInformation.GetForCurrentView();
                    displayInfo.OrientationChanged += onRotationChangedHandler;
                    OnRotate(displayInfo);

                    SetupLocationService();
#endif
                }
            };
        }