예제 #1
0
        private void Sair(object sender, RoutedEventArgs e)
        {
            song.Source = MediaSource.CreateFromUri(new Uri("ms-appx:///Assets/Musicas/ClickSound.mp3"));
            song.Play();

            CoreApplication.Exit();
        }
예제 #2
0
        private void OnBackRequested()
        {
            if (this.PreviewFrame.BackStack.Count > 0)
            {
                return;
            }

            if (this.Frame.CanGoBack)
            {
                this.Frame.GoBack(new DrillInNavigationTransitionInfo());
            }
            else
            {
                if (LeaveTip.Visibility == Visibility.Collapsed)
                {
                    LeaveTipEaseOut.Begin();

                    return;
                }
                if (LeaveTip.Opacity > 0.2)
                {
                    CoreApplication.Exit();
                }
                else
                {
                    LeaveTipEaseOut.Begin();
                }
            }
        }
예제 #3
0
        private async void startDetect()
        {
            // Create an instance of SpeechRecognizer.
            var speechRecognizer = new Windows.Media.SpeechRecognition.SpeechRecognizer();

            string[] responses = { "start", "quit" };
            // Add a list constraint to the recognizer.
            var listConstraint = new Windows.Media.SpeechRecognition.SpeechRecognitionListConstraint(responses, "startOrStart");

            speechRecognizer.Constraints.Add(listConstraint);

            // Compile the constraint.
            await speechRecognizer.CompileConstraintsAsync();

            // Start recognition.
            //textBlock1.Text = "Say Start";
            //Recognise with UI
            Windows.Media.SpeechRecognition.SpeechRecognitionResult speechRecognitionResult = await speechRecognizer.RecognizeWithUIAsync();

            //Recognise without UI
            //Windows.Media.SpeechRecognition.SpeechRecognitionResult speechRecognitionResult = await speechRecognizer.RecognizeAsync();

            if (speechRecognitionResult.Text == "start")
            {
                //textBlock2.Text = "Start detected";
                await Task.Delay(2000);

                startRecAsync();
            }
            if (speechRecognitionResult.Text == "quit")
            {
                CoreApplication.Exit();
            }
        }
예제 #4
0
        public static async System.Threading.Tasks.Task CheckAsync(ContentDialog LoginDialog)
        {
            var result = await LoginDialog.ShowAsync();

            if (result.ToString() == "Secondary")
            {
                CoreApplication.Exit();
            }
            else if (result.ToString() == "Primary")
            {
                StackPanel  stack       = (StackPanel)LoginDialog.Content;
                TextBox     textBox     = (TextBox)stack.Children[0];
                PasswordBox passwordBox = (PasswordBox)stack.Children[1];
                string      password    = passwordBox.Password;
                string      login       = textBox.Text;
                int         response    = DbUtils.CheckAccess(login, password);
                if (response == 1)
                {
                    MainPage.LoginDialog();
                }
                else
                {
                }
            }
        }
예제 #5
0
        private async Task FatalError(string error)
        {
            var dialog = new MessageDialog("Error:" + error);
            await dialog.ShowAsync();

            CoreApplication.Exit();
        }
예제 #6
0
        protected override void OnActivated(IActivatedEventArgs args)
        {
            base.OnActivated(args);

            if (args.Kind == ActivationKind.VoiceCommand)
            {
                VoiceCommandActivatedEventArgs cmd    = args as VoiceCommandActivatedEventArgs;
                SpeechRecognitionResult        result = cmd.Result;

                string commandName = result.RulePath[0];

                MessageDialog dialog = new MessageDialog("");

                switch (commandName)
                {
                case "TurnOnDeskLight":
                    test.turningOnLightMqtt();
                    break;

                case "TurnOffDeskLight":
                    test.turningOffLightMqtt();
                    break;

                default:
                    Debug.WriteLine("Couldn't find command name");
                    break;
                }
            }
            CoreApplication.Exit();
        }
예제 #7
0
        private async Task <bool> ExecuteMainMenuOption(WelcomeSplashResult result)
        {
            bool mainShouldShowAgain = false;

            switch (result)
            {
            case WelcomeSplashResult.Solo:
                isConnected        = false;
                loadBtn.IsEnabled  = true;
                loadBtn.Visibility = Visibility.Visible;
                break;

            case WelcomeSplashResult.Join:
                mainShouldShowAgain = await JoinSelected();

                break;

            case WelcomeSplashResult.Host:
                mainShouldShowAgain = await HostSelected();

                break;

            case WelcomeSplashResult.Exit:
                CoreApplication.Exit();
                break;
            }

            return(mainShouldShowAgain);
        }
예제 #8
0
 public async Task PromptForShutdown()
 {
     if (await QuranApp.NativeProvider.ShowQuestionMessageBox(Resources.please_restart))
     {
         CoreApplication.Exit();
     }
 }
예제 #9
0
        public async void SetWindow(CoreWindow window)
        {
            this.Window = window;

            if (!Windows.Foundation.Metadata.ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 2))
            {
                var dialog = new MessageDialog("This version of Windows does not support the Composition APIs.");
                await dialog.ShowAsync();

                CoreApplication.Exit();
                return;
            }

            window.PointerPressed += Window_PointerPressed;

            CoreApplication.Suspending += CoreApplication_Suspending;
            DisplayInformation.DisplayContentsInvalidated += DisplayInformation_DisplayContentsInvalidated;

            Compositor = new Compositor();

            CreateDevice();

            SwapChainRenderer = new SwapChainRenderer(Compositor);
            SwapChainRenderer.SetDevice(Device, new Size(window.Bounds.Width, window.Bounds.Height));

            SwapChainRenderer.Visual.Offset = new Vector3((float)window.Bounds.Width, (float)window.Bounds.Height, 0);

            RootVisual = Compositor.CreateContainerVisual();
            RootVisual.Children.InsertAtTop(SwapChainRenderer.Visual);

            CompositionTarget      = Compositor.CreateTargetForCurrentView();
            CompositionTarget.Root = RootVisual;

            var ignoredTask = UpdateVisualsLoop();
        }
예제 #10
0
 public App()
 {
     InitializeComponent();
     Suspending += OnSuspending;
     Globals.socket.On("welcome", (data) =>
     {
         Globals.PlayerID = (long)data;
         lock (connect_lock)
         {
             connected = true;
         }
         Globals.StartPing();
     });
     Globals.socket.On("disconnect", async() =>
     {
         Globals.socket.Off("disconnect");
         await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.High, async() =>
         {
             var dialog = new ContentDialog
             {
                 Title           = "Server Disconnect",
                 Content         = "You have lost connection to the server.  Press OK to close the app.",
                 CloseButtonText = "OK",
             };
             var result = await dialog.ShowAsync();
             Globals.StopPing();
             Globals.socket.Disconnect();
             CoreApplication.Exit();
         });
     });
     Globals.socket.Emit("new player", "");
 }
예제 #11
0
        public MainPage()
        {
            this.InitializeComponent();

            App.titleStack.Push("홈");
            // 내부 페이지에 HomePage 로드
            // MainSplitViewContent.Navigate(typeof(HomePage));
            HomeListBoxItem.IsSelected = false;

            // 뒤로가기 버튼
            SystemNavigationManager.GetForCurrentView().BackRequested += (s, a) =>
            {
                if ((MainSplitView.Content as Frame).CanGoBack)
                {
                    App.titleStack.Pop();
                    Title.Text = App.titleStack.Peek();
                    (MainSplitView.Content as Frame).GoBack();
                    a.Handled = true;
                }
                else
                {
                    if ((bool)(App.localSettings.Values["IsBackExit"]) == true)
                    {
                        CoreApplication.Exit();
                    }
                }
            };
        }
예제 #12
0
        async Task TraverseNodeTree()
        {
            bool isNext = true;

            // TODO: needs to be looped endlessly until the end of the tree is reached.
            do
            {
                IList <AMedium> mediaList = await this.nodeTree.CurrentNode.GetMedia();

                PlayTracks(mediaList);

                await WaitNodeCompletion();
                await GetUserInput();

                isNext = await this.nodeTree.MoveNext(this.userInput);

                ResetInput();

                PauseTracks(mediaList);
            } while (isNext);

            DisposeMedia();

            CoreApplication.Exit();
        }
예제 #13
0
        private void SpiltViewPaneListBox_ItemClick(object sender, ItemClickEventArgs e)
        {
            StackPanel item = (StackPanel)e.ClickedItem;

            if (item.Name.Equals("OpenFile"))
            {
                OpenFileAsync();
                MySplitView.IsPaneOpen = false;
            }
            else if (item.Name.Equals("Export"))
            {
                var task = ExportToExcelAsync(1);
                MySplitView.IsPaneOpen = false;
            }
            else if (item.Name.Equals("Exit"))
            {
                var task = ExportToExcelAsync(0);
                task.ContinueWith(t => CoreApplication.Exit());
                MySplitView.IsPaneOpen = false;
            }
            else if (item.Name.EndsWith("Menu"))
            {
                HamburgerButton_Click();
            }
        }
예제 #14
0
        private async void GameOver(string message)
        {
            var gameOverDialog = new MessageDialog(message + "\nYou got score : " + score);

            gameOverDialog.Commands.Add(new UICommand {
                Label = "New Game?", Id = 0
            });
            gameOverDialog.Commands.Add(new UICommand {
                Label = "Exit", Id = 1
            });
            var f = await gameOverDialog.ShowAsync();

            if ((int)f.Id == 0)
            {
                testing1        = null;
                bagging         = null;
                testing1        = new TetrisGridArray();
                bagging         = new TetrisBag();
                shapeCreate     = new TetrisShapes(bagging.GetCurrent(), testing1, false);
                waitingGameOver = false;
                score           = 0;
                rows            = 0;
                level           = 1;
            }
            else if ((int)f.Id == 1)
            {
                redrawTimer.Dispose();
                gravityTimer2.Dispose();
                CoreApplication.Exit();
            }
        }
예제 #15
0
        private void ExitButton_Click(object sender, RoutedEventArgs e)
        {
            CoreApplication.Exit();


            Debug.WriteLine("peli loppui");
        }
예제 #16
0
        //method to end game
        private async void methodGameOverAsync()
        {
            var dialog = new Windows.UI.Popups.MessageDialog("GAME OVER. THE MOUSE GOT DEAD!");
            var res    = await dialog.ShowAsync();

            CoreApplication.Exit();
        }
        private async void Theme_Toggled(object sender, RoutedEventArgs e)
        {
            ContentDialog dialog = new ContentDialog
            {
                Title             = "Confirmation",
                Content           = "Are you sure to change the theme?",
                PrimaryButtonText = "Yes",
                CloseButtonText   = "Cancel"
            };

            if (await dialog.EnqueueAndShowIfAsync() == ContentDialogResult.Primary)
            {
                if (sender is ToggleSwitch toggle)
                {
                    applicationDataContainer["theme"] = toggle.IsOn;
                    RequestedTheme = toggle.IsOn ? ElementTheme.Light : ElementTheme.Dark;

                    await new ContentDialog
                    {
                        Title           = "Alert",
                        Content         = "Please restart the system after applying the changed theme.",
                        CloseButtonText = "OK"
                    }.EnqueueAndShowIfAsync();

                    CoreApplication.Exit();
                }
            }
            else if (sender is ToggleSwitch toggle)
            {
                Theme.Toggled -= Theme_Toggled;
                toggle.IsOn    = !toggle.IsOn;
                Theme.Toggled += Theme_Toggled;
            }
        }
예제 #18
0
        public static void CreatePlatformWindow(this CoreApplication platformApplication, IApplication application)
        {
            if (application.Handler?.MauiContext is not IMauiContext applicationContext)
            {
                return;
            }

            var tizenWindow = GetDefaultWindow();

            if (tizenWindow == null)
            {
                throw new InvalidOperationException($"The {nameof(tizenWindow)} instance was not found.");
            }

            var mauiContext = applicationContext.MakeWindowScope(tizenWindow, out var windowScope);

            tizenWindow.SetWindowCloseRequestHandler(() => platformApplication.Exit());

            applicationContext.Services.InvokeLifecycleEvents <TizenLifecycle.OnMauiContextCreated>(del => del(mauiContext));

            var activationState = new ActivationState(mauiContext);
            var window          = application.CreateWindow(activationState);

            tizenWindow.SetWindowHandler(window, mauiContext);
        }
예제 #19
0
        private static void PerformComputations()
        {
            var jsonSource = Data.GetBigJson();

            var stopwatch = Stopwatch.StartNew();

            //var models = new List<SampleModel>(10000);

            //for (var i = 0; i < 10000; ++i)
            //{
            //    models.Add(JsonNetParseModel(jsonSource));
            //}

            var models = JsonNetParseArray(jsonSource);

            GC.Collect();

            stopwatch.Stop();

            var localSettingsValues = ApplicationData.Current.LocalSettings.Values;

            localSettingsValues["milliseconds"] = stopwatch.ElapsedMilliseconds;
            localSettingsValues["count"]        = models.Count;

            CoreApplication.Exit();
        }
예제 #20
0
 private async void App_EnteredBackground(object sender, EnteredBackgroundEventArgs e)
 {
     try
     {
         //GNARLY_TODO: Save the visual state.
         var frame      = Window.Current.Content as Frame;
         var mainWindow = frame.Content as MainPage;
         if (mainWindow != null && mainWindow.ActiveChannel != null)
         {
             _cachedMessages = await mainWindow.ActiveChannel.DownloadMessages(MainPage.MaxMessageDownloadCount);
         }
         _appPreviouslyRunning = true;
         GnarlyClient.Instance.Disconnect();
     }
     catch (TaskCanceledException)
     {
         CoreApplication.Exit();
     }
     catch (OperationCanceledException)
     {
         CoreApplication.Exit();
     }
     catch (HttpRequestException)
     {
         CoreApplication.Exit();
     }
     catch (Exception exception)
     {
         ExceptionUploader.UploadException(exception.Message, exception.StackTrace);
     }
     // RegisterTask(BackgroundClientTask, BackgroundClientTaskEntryPoint);
 }
예제 #21
0
 public static void TryGracefulRelaunch()
 {
     try
     {
         Frame rootFrame = Window.Current.Content as Frame;
         if (rootFrame != null)
         {
             if (GnarlyClient.Instance.Connected)
             {
                 rootFrame.Navigate(typeof(MainPage));
             }
             else
             {
                 if (TryConnect())
                 {
                     rootFrame.Navigate(typeof(MainPage));
                 }
                 else
                 {
                     rootFrame.Navigate(typeof(LoginSelection));
                 }
             }
         }
     }
     catch (Exception exception)
     {
         ExceptionUploader.UploadException(exception.Message, exception.StackTrace);
         CoreApplication.Exit();
     }
 }
예제 #22
0
        private static void Compute()
        {
            if (Debugger.IsAttached)
            {
                Debug.WriteLine(ApplicationData.Current.LocalSettings.Values["Result"]);
                Debug.Write(ApplicationData.Current.LocalSettings.Values["Time"]);
            }
            else
            {
                var hasher = HashAlgorithmProvider.OpenAlgorithm("SHA256");

                const String initialText = "wdmpOY6OosH6ltmhqxQAkt6yWRkiokDPgZCnsYHIgvNI9eClMEl7xTkxCW6uOlLU";
                var          input       = Encoding.ASCII.GetBytes(initialText).AsBuffer();

                var sw = Stopwatch.StartNew();

                for (var i = 0; i < 1000000; i++)
                {
                    input = hasher.HashData(input);
                    input = CryptographicBuffer.ConvertStringToBinary(CryptographicBuffer.EncodeToBase64String(input), BinaryStringEncoding.Utf8);
                }

                GC.Collect(2, GCCollectionMode.Forced, true);

                sw.Stop();

                ApplicationData.Current.LocalSettings.Values["Result"] = CryptographicBuffer.EncodeToHexString(input);
                ApplicationData.Current.LocalSettings.Values["Time"]   = sw.ElapsedMilliseconds;

                CoreApplication.Exit();
            }
        }
예제 #23
0
    public void Quitt()
    {
#if UNITY_WSA && !UNITY_EDITOR
        CoreApplication.Exit();
#else
        Application.Quit();
#endif
    }
예제 #24
0
 private void TabStrip_TabClosing(object sender, TabClosingEventArgs e)
 {
     e.Tab.Content = null;
     if (TabStrip.Items.Count == 1)
     {
         CoreApplication.Exit();
     }
 }
예제 #25
0
        /// <summary>
        /// This can be called to programmatically exit the application,
        /// As an alternative to the app being closed with the close button.
        /// </summary>
        public void Exit()
        {
            Debug.LogMessage("App.Exit");

            // close any objects here...

            CoreApplication.Exit();
        }
예제 #26
0
        /// <summary>
        /// Handle the result of the update process and update the UI accordingly.
        /// </summary>
        private async Task HandleUpdateResultAsync(
            IReadOnlyList <StorePackageUpdate> updates, StorePackageUpdateResult result)
        {
            if (result == null)
            {
                VisualStateManager.GoToState(this, this.UpdateFailedState.Name, false);
                Debug.WriteLine($"{this.GetType()}: HandleUpdateResultAsync: result was null");
                return;
            }

            switch (result.OverallState)
            {
            // When the app has updated successfully, attempt to restart it,
            // or show a notification to user and exit.
            case StorePackageUpdateState.Completed: {
                Debug.WriteLine($"{this.GetType()}: HandleUpdateResultAsync: Update successful");
                if (!await this.RestartAppAsync())
                {
                    // We expect the Microsoft Store to show a notification that
                    // the app was updated.
                    CoreApplication.Exit();
                }
                break;
            }

            // If the update was cancelled by the user, allow them to try again.
            case StorePackageUpdateState.Canceled: {
                Debug.WriteLine($"{this.GetType()}: HandleUpdateResultAsync: Update cancelled");
                VisualStateManager.GoToState(this, this.UpdateAvailableState.Name, false);
                break;
            }

            // When the update failed for whatever reason, indicate this to
            // the user and what to do next.
            default: {
                Debug.WriteLine($"{this.GetType()}: HandleUpdateResultAsync: " +
                                $"Update failed {result.OverallState}");
                VisualStateManager.GoToState(this, this.UpdateFailedState.Name, false);

                IEnumerable <StorePackageUpdateStatus> failedUpdates =
                    result.StorePackageUpdateStatuses.Where(
                        status => status.PackageUpdateState != StorePackageUpdateState.Completed);

                foreach (StorePackageUpdateStatus failedUpdate in failedUpdates)
                {
                    Debug.WriteLine($"{this.GetType()}: HandleUpdateResultAsync: " +
                                    $"{failedUpdate.PackageFamilyName} state is {failedUpdate.PackageUpdateState}");
                }
                if (updates.Any(u => u.Mandatory && failedUpdates.Any(
                                    failed => failed.PackageFamilyName == u.Package.Id.FamilyName)))
                {
                    Debug.WriteLine($"{this.GetType()}: HandleUpdateResultAsync: " +
                                    $"Mandatory updates remaining");
                }
                break;
            }
            }
        }
예제 #27
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (e.PrelaunchActivated == false)
            {
                if (rootFrame.Content == null)
                {
                    // When the navigation stack isn't restored navigate to the first page,
                    // configuring the new page by passing required information as a navigation
                    // parameter
                    rootFrame.Navigate(typeof(MainPage), e.Arguments);
                }
                // Ensure the current window is active
                Window.Current.Activate();
            }

            string AppData    = ApplicationData.Current.RoamingFolder.Path;
            string AppName    = Assembly.GetExecutingAssembly().GetName().Name;
            string AppVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();

            string DatabasePath = AppData + @"\" + AppName + @"\" + AppVersion;

            if (!Directory.Exists(DatabasePath))
            {
                try
                {
                    Directory.CreateDirectory(DatabasePath);
                }
                catch (Exception ex)
                {
                    CoreApplication.Exit();
                }
            }

            //DataAccess.InitializeDatabase(DatabasePath + @"\Stores", "StoreDirectories");
            //StoreDirectories.Stores = DataAccess.GetStores().Result;

            CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;
        }
예제 #28
0
        private async void Btn_app_beenden_Click(object sender, RoutedEventArgs e)
        {
            await User_Check("Soll Weinkeller wirklich beendet werden?", "App beenden");

            if (result)
            {
                CoreApplication.Exit();
            }
        }
예제 #29
0
        private async void _stopTimer_Tick(object sender, object e)
        {
            // Stop everything
            Debug.WriteLine("Stopping the program");
            _getFrameTimer.Stop();

            await GetServerTimeOffsetAsync();

            CoreApplication.Exit();
        }
예제 #30
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            //try
            //{
            //    Application.Current.Resources["DefaultBackgroundColor"] = Helper.GetColorBrush("#18227c");
            //}
            //catch (Exception ex)
            //{
            //}

            try
            {
                if (DeviceUtil.IsXbox)
                {
                    FullscreenModeInXbox();
                }
            }
            catch { }
            ChangeTileBarTheme();
            CreateCachedFilesFolder();
            NavigationService.StartService();
            ScreenOnRequest = new Windows.System.Display.DisplayRequest();
            if (!DeviceHelper.IsThisMinista())
            {
                await new MessageDialog("Oops, It seems you changed my app package to crack it.\r\n" +
                                        "Well done, now use my app, if you can:d\r\n" +
                                        "Pay the price dude, don't be cheap:d\r\n" +
                                        "Bye bye").ShowAsync();
                try
                {
                    CoreApplication.Exit();
                }
                catch
                {
                    try
                    {
                        Application.Current.Exit();
                    }
                    catch { }
                }
                return;
            }
            try
            {
                var flag = await GetLicenseState();

                if (!flag)
                {
                    PurchaseMessage();
                }
            }
            catch { }
        }