Esempio n. 1
0
        // Helper function for async Read callback
        protected virtual async void Characteristic_ReadRequested(
            GattLocalCharacteristic sender,
            GattReadRequestedEventArgs args,
            Deferral deferral = null
            )
        {
            Debug.WriteLine($"base.Characteristic_ReadRequested Entry");

            // Get an event deferral for async operations if we don't have one
            if (deferral == null)
            {
                deferral = args.GetDeferral();
            }

            //
            // Normally, GetRequestAsync() is recommended to run on a UI thread
            // because, even with paired devices, the device may prompt the
            // user for consent. But, we're running in a background service so
            // we won't run this on a UI thread. According to one of the devs
            // on the core Bluetooth team, because this is for a "test
            // application," consent prompts are not currently part of MS's
            // policy and it will be auto-accepted.
            //
            var request = await args.GetRequestAsync();

            request.RespondWithValue(Value);
            Debug.WriteLine($"Characteristic ReadRequested- Length: " +
                            $"{request.Length}, State: {request.State}, " +
                            $"Offset: {request.Offset}"
                            );

            deferral.Complete();

            Debug.WriteLine("base.Characteristic_ReadRequested Exit");
        }
Esempio n. 2
0
        private async void Close_Requested(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
        {
            Deferral deferral = e.GetDeferral();

            ContentDialog exitDialog = new ContentDialog
            {
                Title               = "Exit?",
                Content             = "Have you saved your latest Changes? They otherwise will be lost forever!",
                CloseButtonText     = "Cancel",
                PrimaryButtonText   = "Save",
                SecondaryButtonText = "Exit",
                DefaultButton       = ContentDialogButton.Secondary
            };

            ContentDialogResult result = await exitDialog.ShowAsync();

            if (result == ContentDialogResult.Primary)
            {
                e.Handled = true;
                Save_Click(null, null);
            }
            else if (result != ContentDialogResult.Secondary)
            {
                e.Handled = true;
            }

            deferral.Complete();
        }
Esempio n. 3
0
        public void OnCameraAdded(
            HolographicSpace sender,
            HolographicSpaceCameraAddedEventArgs args
            )
        {
            Deferral          deferral          = args.GetDeferral();
            HolographicCamera holographicCamera = args.Camera;

            Task task1 = new Task(() =>
            {
                //
                // TODO: Allocate resources for the new camera and load any content specific to
                //       that camera. Note that the render target size (in pixels) is a property
                //       of the HolographicCamera object, and can be used to create off-screen
                //       render targets that match the resolution of the HolographicCamera.
                //

                // Create device-based resources for the holographic camera and add it to the list of
                // cameras used for updates and rendering. Notes:
                //   * Since this function may be called at any time, the AddHolographicCamera function
                //     waits until it can get a lock on the set of holographic camera resources before
                //     adding the new camera. At 60 frames per second this wait should not take long.
                //   * A subsequent Update will take the back buffer from the RenderingParameters of this
                //     camera's CameraPose and use it to create the ID3D11RenderTargetView for this camera.
                //     Content can then be rendered for the HolographicCamera.
                deviceResources.AddHolographicCamera(holographicCamera);

                // Holographic frame predictions will not include any information about this camera until
                // the deferral is completed.
                deferral.Complete();
            });

            task1.Start();
        }
Esempio n. 4
0
        /// <summary>
        /// Handle the Print Task Setup Event
        /// Raised when the source app sets the Print Ticket. This event provides a callback method for the app to signal it is done handling this event
        /// and optionally specifying the need for UI, which will cause the UI part of this App to be launched in OnActivated() with ActivationKind.PrintWorkflowForegroundTask .
        /// </summary>
        /// <param name="sessionManager">Session manager</param>
        /// <param name="printTaskSetupArgs">Has the Configuration, which include the PrintTicket, and other information</param>
        private void OnSetupRequested(PrintWorkflowBackgroundSession sessionManager, PrintWorkflowBackgroundSetupRequestedEventArgs printTaskSetupArgs)
        {
            // Request a deferral if any of the calls here might result in an Async method being called
            Deferral setupRequestedDeferral = printTaskSetupArgs.GetDeferral();

            // Get information about the source application, print job title, and session ID
            string sourceApplicationName = printTaskSetupArgs.Configuration.SourceAppDisplayName;
            string jobTitle  = printTaskSetupArgs.Configuration.JobTitle;
            string sessionId = printTaskSetupArgs.Configuration.SessionId;

            // Check to see if user wanted to use the watermark already when the program was run "standalone" and saved in local storage
            // and not have UI every time. It can always be reset by running the app again and unchecking the check box
            localStorage = new LocalStorageUtilities();
            suppressUI   = localStorage.GetUseStandaloneSettings();
            if (!suppressUI)
            {
                // Indicate that we need to launch the UI, in this example, because we need to get watermarking text, and optionally an image
                printTaskSetupArgs.SetRequiresUI();
                // Set storage prefix so that foreground and background can pass properties
                string localStorageVariablePrefix = string.Format("{0}::", sessionId.Substring(0, 8));
                localStorage.SetStorageKeyPrefix(localStorageVariablePrefix);
            }
            else
            {
                // Use unprefixed default values set in "standalone" mode, without showing UI when activated in workflow mode
                localStorage.SetStorageKeyPrefix("");
            }

            // Complete the deferral taken out at the start of OnSetupRequested
            setupRequestedDeferral.Complete();
        }
Esempio n. 5
0
        // X 버튼 누르시에 할 일을 추가해야함
        private void SystemNavigationManager_CloseRequested(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
        {
            Deferral deferral = e.GetDeferral();


            e.Handled = false;
            deferral.Complete();
        }
Esempio n. 6
0
        private async void OnAppWindowCloseRequested(AppWindow sender, AppWindowCloseRequestedEventArgs e)
        {
            Deferral deferral = e.GetDeferral();

            e.Cancel = !await ViewModel.TryCloseAsync();

            deferral.Complete();
        }
Esempio n. 7
0
        private void OnEnteredBackground(object sender, EnteredBackgroundEventArgs e)
        {
            Deferral deferral = e.GetDeferral();

            IsForeground = false;
            NotificationSystem.RefreshCallNotification(CallSystem.CallManager.CurrentCalls);
            deferral.Complete();
        }
Esempio n. 8
0
        private void OnLeavingBackground(object sender, LeavingBackgroundEventArgs e)
        {
            Deferral deferral = e.GetDeferral();

            IsForeground = true;
            NotificationSystem.RemoveCallToastNotifications();
            deferral.Complete();
        }
Esempio n. 9
0
        private async void RefreshContainer_RefreshRequested(RefreshContainer sender, RefreshRequestedEventArgs e)
        {
            Deferral deferral = e.GetDeferral();

            await ViewModel.RefreshAsync();

            deferral.Complete();
        }
Esempio n. 10
0
        private async void OnCloseRequested(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
        {
            Deferral deferral = e.GetDeferral();

            e.Handled = await ViewModel.TabViewManager.TabViewManager.MainTabView.GetUnclosableTabsAsync().CountAsync() > 0 ||
                        await ViewModel.TabViewManager.TabViewManager.SolutionExplorerTabView.GetUnclosableTabsAsync().CountAsync() > 0;

            deferral.Complete();
        }
Esempio n. 11
0
        private async void CustomPairInfo_PairingRequested(DeviceInformationCustomPairing sender, DevicePairingRequestedEventArgs args)
        {
            Deferral PairDeferral = args.GetDeferral();

            try
            {
                PairConfirmaion = new TaskCompletionSource <bool>();

                switch (args.PairingKind)
                {
                case DevicePairingKinds.ConfirmPinMatch:
                {
                    await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                        {
                            Tips.Text             = $"{Globalization.GetString("BluetoothUI_Tips_Text_5")}{Environment.NewLine}{args.Pin}";
                            Tips.Visibility       = Visibility.Visible;
                            PinConfirm.Visibility = Visibility.Visible;
                            PinRefuse.Visibility  = Visibility.Visible;
                        });

                    if (await PairConfirmaion.Task)
                    {
                        args.Accept(args.Pin);
                    }

                    break;
                }

                case DevicePairingKinds.ConfirmOnly:
                {
                    await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                        {
                            Tips.Text             = Globalization.GetString("BluetoothUI_Tips_Text_6");
                            Tips.Visibility       = Visibility.Visible;
                            PinConfirm.Visibility = Visibility.Visible;
                            PinRefuse.Visibility  = Visibility.Visible;
                        });

                    if (await PairConfirmaion.Task)
                    {
                        args.Accept();
                    }

                    break;
                }
                }
            }
            catch (Exception ex)
            {
                LogTracer.Log(ex, $"An exception was threw in {nameof(CustomPairInfo_PairingRequested)}, pair with bluetooth failed");
            }
            finally
            {
                PairDeferral.Complete();
            }
        }
Esempio n. 12
0
        private async void OnRefreshContainerRefreshRequested(RefreshContainer sender, RefreshRequestedEventArgs e)
        {
            Deferral deferral = e.GetDeferral();

            if (ViewModel.RootFolder != null)
            {
                await ViewModel.RootFolder.FillAsync();
            }

            deferral.Complete();
        }
Esempio n. 13
0
 protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     base.OnElementPropertyChanged(sender, e);
     if (e.PropertyName == ListView.IsRefreshingProperty.PropertyName)
     {
         if (!Element.IsRefreshing && refreshDeferral != null)
         {
             refreshDeferral.Complete();
             refreshDeferral.Dispose();
         }
     }
 }
Esempio n. 14
0
        private async void SystemNavigationManager_CloseRequested(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
        {
            Deferral deferral = e.GetDeferral();

            if (ApiInformation.IsApiContractPresent(
                    "Windows.ApplicationModel.FullTrustAppContract", 1, 0))
            {
                await FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync();
            }
            e.Handled = false;
            deferral.Complete();
        }
Esempio n. 15
0
        private async void OnEnteredBackground(object sender, EnteredBackgroundEventArgs e)
        {
            Deferral deferral = e.GetDeferral();

            try
            {
                await viewModel.Settings.Save(settingsFileName);
            }
            catch { }

            deferral.Complete();
        }
Esempio n. 16
0
        protected override void Dispose(bool disposing)
        {
            if (_isDisposed)
            {
                return;
            }

            if (Control != null && disposing)
            {
                Control.RefreshRequested -= OnRefresh;

                if (_refreshCompletionDeferral != null)
                {
                    _refreshCompletionDeferral.Complete();
                    _refreshCompletionDeferral.Dispose();
                    _refreshCompletionDeferral = null;
                }
            }

            _isDisposed = true;

            base.Dispose(disposing);
        }
Esempio n. 17
0
        /// <summary>
        /// 在应用程序由最终用户正常启动时进行调用。
        /// 将在启动应用程序以打开特定文件等情况下使用。
        /// </summary>
        /// <param name="e">有关启动请求和过程的详细信息。</param>
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
            Frame rootFrame = Window.Current.Content as Frame;

            // 不要在窗口已包含内容时重复应用程序初始化,
            // 只需确保窗口处于活动状态
            if (rootFrame == null)
            {
                // 创建要充当导航上下文的框架,并导航到第一页
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //ApplicationExecutionState.Terminated
                    //TODO: 从之前挂起的应用程序加载状态
                }

                // 将框架放在当前窗口中
                Window.Current.Content = rootFrame;
            }

            if (e.PrelaunchActivated == false)
            {
                if (rootFrame.Content == null)
                {
                    // 当导航堆栈尚未还原时,导航到第一页,
                    // 并通过将所需信息作为导航参数传入来配置
                    // 参数
                    rootFrame.Navigate(typeof(MainPage), e.Arguments);
                }
                SystemNavigationManagerPreview.GetForCurrentView().CloseRequested += async(_s, _e) => {
                    Deferral      deferral = _e.GetDeferral();
                    ContentDialog dialog   = new ContentDialog
                    {
                        Title               = "即将推退出应用",
                        PrimaryButtonText   = "退出",
                        SecondaryButtonText = "取消"
                    };
                    if (await dialog.ShowAsync() == ContentDialogResult.Secondary)
                    {
                        _e.Handled = true;
                    }
                    deferral.Complete();
                };
                // 确保当前窗口处于活动状态
                Window.Current.Activate();
            }
        }
        /// <summary>
        /// Handle the Print Task Setup Event
        /// Raised when the source app sets the Print Ticket. This event provides a callback method for the app to signal it is done handling this event
        /// and optionally specifying the need for UI, which will cause the UI part of this App to be launched in OnActivated() with ActivationKind.PrintWorkflowForegroundTask .
        /// </summary>
        /// <param name="sessionManager">Session manager</param>
        /// <param name="printTaskSetupArgs">Has the Configuration, which include the PrintTicket, and other information</param>
        private void OnSetupRequested(PrintWorkflowBackgroundSession sessionManager, PrintWorkflowBackgroundSetupRequestedEventArgs printTaskSetupArgs)
        {
            // Request a deferral if any of the calls here might result in an Async method being called
            Deferral setupRequestedDeferral = printTaskSetupArgs.GetDeferral();

            // Get information about the source application, print job title, and session ID
            string sourceApplicationName = printTaskSetupArgs.Configuration.SourceAppDisplayName;
            string jobTitle  = printTaskSetupArgs.Configuration.JobTitle;
            string sessionId = printTaskSetupArgs.Configuration.SessionId;

            // Check to see if user wanted to use the watermark already when the program was run "standalone" and saved in local storage
            // and not have UI every time. It can always be reset by running the app again and unchecking the check box
            localStorage = new LocalStorageUtilities();
            suppressUI   = localStorage.GetUseStandaloneSettings();
            if (!suppressUI)
            {
                // Indicate that we need to launch the UI, in this example, because we need to get watermarking text, and optionally an image
                printTaskSetupArgs.SetRequiresUI();
                // Set storage prefix so that foreground and background can pass properties
                string localStorageVariablePrefix = string.Format("{0}::{1}::", sourceApplicationName, sessionId.Substring(0, 8));
                localStorage.SetStorageKeyPrefix(localStorageVariablePrefix);
            }
            else
            {
                // Use unprefixed default values set in "standalone" mode, without showing UI when activated in workflow mode
                localStorage.SetStorageKeyPrefix("");
            }

            // Get the printer name
            try
            {
                // Get the PrinterExtensionContextNative from the activation arguments
                IntPtr ptr = GetPrintWorkflowConfigurationNativeAsIntPtr(printTaskSetupArgs);
                // Create the Print Helper
                PrintHelperClass printHelper = new PrintHelperClass(InitializationType.PrinterExtensionContextNativeType, (ulong)ptr);
                string           printerName = printHelper.GetPrinterName();
                // Save the name of the printer
                localStorage.SavePrinterNameToLocalStorage(printerName);
            }
            catch (Exception ex)
            {
                string errorMessage = ex.Message;
                Debug.WriteLine(errorMessage);
            }
            finally
            {
                // Complete the deferral taken out at the start of OnSetupRequested
                setupRequestedDeferral.Complete();
            }
        }
Esempio n. 19
0
        protected override async void OnBackgroundActivated(BackgroundActivatedEventArgs args)
        {
            base.OnBackgroundActivated(args);

            if (args.TaskInstance.TriggerDetails is AppServiceTriggerDetails appService && string.Equals(appService.CallerPackageFamilyName, Package.Current.Id.FamilyName))
            {
                Connection = appService.AppServiceConnection;
                Deferral   = args.TaskInstance.GetDeferral();

                appService.AppServiceConnection.RequestReceived += AppServiceConnection_RequestReceived;
                args.TaskInstance.Canceled += (s, e) =>
                {
                    Deferral.Complete();
                };
            }
        private void Mgr_CloseRequested(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
        {
            // get deferral
            Deferral deferral = e.GetDeferral();

            // tell winfrm to exit
            ValueSet exit = new ValueSet();

            exit.Add("exit", null);
Send:
            if (!SendToWin32(exit).Result)
            {
                goto Send;
            }

            e.Handled = false;
            deferral.Complete();
        }
        /// <summary>
        /// Handle the Print Task XPS Data Available Event
        /// </summary>
        /// <param name="sessionManager">Session manager</param>
        /// <param name="printTaskXpsAvailableEventArgs">Has the Configuration and Controller</param>
        internal async void OnXpsDataAvailable(PrintWorkflowForegroundSession sessionManager, PrintWorkflowXpsDataAvailableEventArgs printTaskXpsAvailableEventArgs)
        {
            // Take out a deferral whilst getting the information
            Deferral xpsDataAvailableDeferral = printTaskXpsAvailableEventArgs.GetDeferral();

            if (sessionManager != null && printTaskXpsAvailableEventArgs != null)
            {
                // See if we already have the information required and it
                // were desireable to only have to enter this information once then
                // you could determine that here and not do WaitUntilTheUIHasAllRequiredData();
            }

            // Don't actually exit until all UI stuff is done
            await WaitUntilTheUIHasAllRequiredData();

            // Complete the deferral taken out at the start of OnSetupRequested
            xpsDataAvailableDeferral.Complete();
        }
Esempio n. 22
0
        private async void CustomPairInfo_PairingRequested(DeviceInformationCustomPairing sender, DevicePairingRequestedEventArgs args)
        {
            Deferral PairDeferral = args.GetDeferral();

            switch (args.PairingKind)
            {
            case DevicePairingKinds.ConfirmPinMatch:
            {
                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                    {
                        Tips.Text             = "请确认PIN码与配对设备一致\r" + args.Pin;
                        Tips.Visibility       = Visibility.Visible;
                        PinConfirm.Visibility = Visibility.Visible;
                        PinRefuse.Visibility  = Visibility.Visible;
                    });

                break;
            }

            case DevicePairingKinds.ConfirmOnly:
            {
                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                    {
                        Tips.Text             = "请确认是否与配对设备配对";
                        Tips.Visibility       = Visibility.Visible;
                        PinConfirm.Visibility = Visibility.Visible;
                        PinRefuse.Visibility  = Visibility.Visible;
                    });

                break;
            }
            }
            await Task.Run(() =>
            {
                PinLock.WaitOne();

                if (IsPinConfirm)
                {
                    args.Accept();
                }
            });

            PairDeferral.Complete();
        }
Esempio n. 23
0
        private async void CustomPairInfo_PairingRequested(DeviceInformationCustomPairing sender, DevicePairingRequestedEventArgs args)
        {
            Deferral PairDeferral = args.GetDeferral();

            switch (args.PairingKind)
            {
            case DevicePairingKinds.ConfirmPinMatch:
            {
                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                    {
                        Tips.Text             = $"{Globalization.GetString("BluetoothUI_Tips_Text_5")}{Environment.NewLine}{args.Pin}";
                        Tips.Visibility       = Visibility.Visible;
                        PinConfirm.Visibility = Visibility.Visible;
                        PinRefuse.Visibility  = Visibility.Visible;
                    });

                break;
            }

            case DevicePairingKinds.ConfirmOnly:
            {
                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                    {
                        Tips.Text             = Globalization.GetString("BluetoothUI_Tips_Text_6");
                        Tips.Visibility       = Visibility.Visible;
                        PinConfirm.Visibility = Visibility.Visible;
                        PinRefuse.Visibility  = Visibility.Visible;
                    });

                break;
            }
            }
            await Task.Run(() =>
            {
                PinLock.WaitOne();

                if (IsPinConfirm)
                {
                    args.Accept();
                }
            }).ConfigureAwait(false);

            PairDeferral.Complete();
        }
        /// <summary>
        /// Handle the Print Task Setup Event
        /// </summary>
        /// <param name="sessionManager">Session manager</param>
        /// <param name="printTaskSetupArgs">Has the Configuration and Controller</param>
        internal void OnSetupRequested(PrintWorkflowForegroundSession sessionManager, PrintWorkflowForegroundSetupRequestedEventArgs printTaskSetupArgs)
        {
            // If anything asynchronous is going to be done, you need to take out a deferral here,
            // since otherwise the next callback happens once this one exits, which may be premature
            Deferral setupRequestedDeferral = printTaskSetupArgs.GetDeferral();

            // Get information about the source application, print job title, and session ID
            string sourceApplicationName = printTaskSetupArgs.Configuration.SourceAppDisplayName;
            string jobTitle  = printTaskSetupArgs.Configuration.JobTitle;
            string sessionId = printTaskSetupArgs.Configuration.SessionId;
            string localStorageVariablePrefix = string.Format("{0}::", sessionId);

            localStorage.SetStorageKeyPrefix(localStorageVariablePrefix);

            // Get the PrinterExtensionContextNative from the activation arguments
            IntPtr ptr = GetPrintWorkflowConfigurationNativeAsIntPtr(printTaskSetupArgs);

            // Create the Print Helper
            PrintHelperClass printHelper = new PrintHelperClass(InitializationType.PrinterExtensionContextNativeType, (ulong)ptr);

            printerName          = printHelper.GetPrinterName();
            WorkflowHeadingLabel = string.Format(workflowHeadingFormat, sourceApplicationName, printerName);

            // Add callback handler on main page
            try
            {
                printHelper.OnInkLevelReceived += OnQueryResultReceived;
                // Send the BiDi query
                printHelper.SendInkLevelQuery();
            }
            catch (Exception ex)
            {
                string errorMessage = ex.Message;
                Debug.WriteLine(errorMessage);
            }
            finally
            {
                // Complete the deferral taken out at the start of OnSetupRequested
                setupRequestedDeferral.Complete();
            }
        }
Esempio n. 25
0
        private async void App_EnteredBackground(object sender, EnteredBackgroundEventArgs args)
        {
            Deferral deferral = args.GetDeferral();

            _logHelper.Log(LogLevel.Trace, "In App_EnteredBackground");
            try
            {
                StorageFolder localFolder = ApplicationData.Current.LocalFolder;
                await localFolder.SaveAsync(PropertiesDictionaryFileName, Properties);

                await SuspendAndResumeService.Instance.SaveStateAsync();

                await MainViewModel.Instance.UpdateDownloadedBulletinsAsync();
            }
            catch (Exception e)
            {
                _logHelper.Log(LogLevel.Error, $"{e.Message}");
            }

            deferral.Complete();
        }
Esempio n. 26
0
        public void RefreshCompletedDeferralCompletedOffUIThread()
        {
            RunOnUIThread.Execute(() =>
            {
                RefreshVisualizer refreshVisualizer = new RefreshVisualizer();
                Compositor compositor = ElementCompositionPreview.GetElementVisual(refreshVisualizer).Compositor;
                RefreshInfoProviderImpl refreshInfoProviderImpl             = new RefreshInfoProviderImpl(compositor);
                ((IRefreshVisualizerPrivate)refreshVisualizer).InfoProvider = refreshInfoProviderImpl;
                refreshVisualizer.RefreshRequested += (RefreshVisualizer sender, RefreshRequestedEventArgs args) =>
                {
                    Deferral def = args.GetDeferral();

                    Windows.System.Threading.ThreadPool.RunAsync(
                        (IAsyncAction action) =>
                    {
                        Log.Comment("RefreshVisualizer.RefreshRequested event handler");
                        def.Complete();
                    }).AsTask().Wait();
                };

                Verify.AreEqual <int>(0, refreshInfoProviderImpl.OnRefreshStartedCalls);
                Verify.AreEqual <int>(0, refreshInfoProviderImpl.OnRefreshCompletedCalls);

                MUXControlsTestApp.App.TestContentRoot = refreshVisualizer;

                refreshVisualizer.RequestRefresh();
            });

            IdleSynchronizer.Wait();

            RunOnUIThread.Execute(() =>
            {
                RefreshVisualizer refreshVisualizer             = (RefreshVisualizer)MUXControlsTestApp.App.TestContentRoot;
                RefreshInfoProviderImpl refreshInfoProviderImpl = ((RefreshInfoProviderImpl)((IRefreshVisualizerPrivate)refreshVisualizer).InfoProvider);

                Verify.AreEqual <int>(1, refreshInfoProviderImpl.OnRefreshStartedCalls);
                //Since we are completing the deferral off the UI thread the refresh never completed.
                Verify.AreEqual <int>(0, refreshInfoProviderImpl.OnRefreshCompletedCalls);
            });
        }
Esempio n. 27
0
        private async void MainPage_CloseRequested(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
        {
            Deferral Deferral = e.GetDeferral();

            if (IsAnyTaskRunning || GeneralTransformer.IsAnyTransformTaskRunning || FullTrustExcutorController.Current.IsNowHasAnyActionExcuting)
            {
                QueueContentDialog Dialog = new QueueContentDialog
                {
                    Title             = Globalization.GetString("Common_Dialog_WarningTitle"),
                    Content           = Globalization.GetString("QueueDialog_WaitUntilFinish_Content"),
                    PrimaryButtonText = Globalization.GetString("QueueDialog_WaitUntilFinish_PrimaryButton"),
                    CloseButtonText   = Globalization.GetString("QueueDialog_WaitUntilFinish_CloseButton")
                };

                if ((await Dialog.ShowAsync().ConfigureAwait(true)) != ContentDialogResult.Primary)
                {
                    e.Handled = true;
                }
                else
                {
                    IsAnyTaskRunning = false;
                    GeneralTransformer.IsAnyTransformTaskRunning = false;
                    ToastNotificationManager.History.Clear();
                }
            }

            try
            {
                if (!e.Handled && Clipboard.GetContent().Contains(StandardDataFormats.StorageItems))
                {
                    Clipboard.Flush();
                }
            }
            catch
            {
            }

            Deferral.Complete();
        }
        private async void OnEnteredBackground(object sender, EnteredBackgroundEventArgs e)
        {
            ServiceBuild build = viewModel.Service.ServiceOpenBuild;

            if (build?.CompleteToken.IsEnded.HasValue != false)
            {
                return;
            }

            Deferral deferral = e.GetDeferral();

            try
            {
                await viewModel.Service.CloseAsync();

                canceledBuild = true;
            }
            finally
            {
                deferral.Complete();
            }
        }
Esempio n. 29
0
        private void Initlalize()
        {
            //ApplicationView.PreferredLaunchViewSize = new Size(820, 520);
            //ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.PreferredLaunchViewSize;

            // 扩展标题栏
            var coreTitleBar = CoreApplication.GetCurrentView().TitleBar;

            coreTitleBar.ExtendViewIntoTitleBar = true;
            /// 将亚克力效果应用到标题栏
            ApplicationViewTitleBar titleBar = ApplicationView.GetForCurrentView().TitleBar;

            titleBar.ButtonBackgroundColor         = Colors.Transparent;
            titleBar.ButtonInactiveBackgroundColor = Colors.Transparent;

            MessageManager.Initialize();
            PipeBridge.Bridge.LaunchThenConnectServer();
            SettingsClerk.Clerk.InitlailzeLocalSettings();

            // 退出确认
            SystemNavigationManagerPreview.GetForCurrentView().CloseRequested += async(s, _e) => {
                Deferral      deferral = _e.GetDeferral();
                ContentDialog dialog   = new ContentDialog
                {
                    Title               = "即将推退出应用",
                    PrimaryButtonText   = "退出",
                    SecondaryButtonText = "取消"
                };
                _e.Handled = true;
                if (await dialog.ShowAsync() == ContentDialogResult.Primary)
                {
                    _e.Handled = false;
                    ActionManager.TryExitApp();
                }
                deferral.Complete();
            };
        }
        private async void SystemNavigationManager_CloseRequested(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
        {
            Deferral deferral = e.GetDeferral();

            //ConfirmCloseDialog dlg = new ConfirmCloseDialog();
            //ContentDialogResult result = await dlg.ShowAsync();
            //if (result == ContentDialogResult.Secondary)
            //{
            //    // user cancelled the close operation
            //    e.Handled = true;
            //    deferral.Complete();
            //}
            //else
            //{
            //    switch (dlg.Result)
            //    {
            //        case CloseAction.Terminate:
            //            e.Handled = false;
            //            deferral.Complete();
            //            break;

            //        case CloseAction.Systray:
            if (ApiInformation.IsApiContractPresent("Windows.ApplicationModel.FullTrustAppContract", 1, 0))
            {
                ApplicationData.Current.LocalSettings.Values["processId"] = Process.GetCurrentProcess().Id;
                //App.AppServiceConnected += AppServiceConnected; // this was used in newer GlobalHotkey desktop extensions sample to facilitate uwp app processing of hotkeys
                await FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync();

                ApplicationData.Current.LocalSettings.Values["systrayComponentRunning"] = true;
            }
            e.Handled = false;
            deferral.Complete();
            //            break;
            //    }
            //}
        }