void m_MenuAbout_Click(object sender, RoutedEventArgs e)
        {
            var win = new NavigationWindow();

            win.Content = new AboutPage();
            win.Width   = 360;
            win.Height  = 280;
            win.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
            win.Show();

            win.NavigationFailed += (w, arg) => arg.Handled = true;

            bool isFirst = true;

            win.Navigated += (w, arg) => {
                if (!isFirst)
                {
                    win.WindowState = System.Windows.WindowState.Maximized;
                }
                isFirst = false;
            };

            win.KeyDown += (w, arg) => {
                if (arg.Key == Key.Escape || arg.Key == Key.Enter)
                {
                    win.Close();
                }
            };
        }
 private void btnHide(object sender, RoutedEventArgs e)
 {
     if (winWait != null)
     {
         winWait.Close();
     }
 }
Example #3
0
        private void BtnCancel_Click(object sender, RoutedEventArgs e)
        {
            //exit
            NavigationWindow nav = (NavigationWindow)Window.GetWindow(this);

            nav.Close();
        }
Example #4
0
 private void KeyPress(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Enter)
     {
         CheckPassword();
         e.Handled = true;
     }
     if (e.Key == Key.Escape)
     {
         e.Handled = true;
         NavigationWindow win = (NavigationWindow)Window.GetWindow(this);
         win.Close();
     }
 }
Example #5
0
        private void OnFinishButton_Click(object sender, RoutedEventArgs e)
        {
            switch (m_state)
            {
            case ProcessingState.BeginProcessing:
            {
                m_state                     = ProcessingState.CurrentlyProcessing;
                m_btnBack.IsEnabled         = false;
                m_btnFinish.Content         = "Cancel";
                m_tbDesc.Visibility         = System.Windows.Visibility.Collapsed;
                m_gridProcessing.Visibility = System.Windows.Visibility.Visible;
                m_lblProgress.Content       = "Enumerating images...";

                m_thread              = new System.Threading.Thread(OnProcessImages);
                m_thread.Name         = "UpdateItemsPage.OnProcessImages";
                m_thread.IsBackground = true;
                m_thread.Start();

                break;
            }

            case ProcessingState.CurrentlyProcessing:
            {
                if (m_thread.IsAlive)
                {
                    m_thread.Abort();
                }

                m_state                     = ProcessingState.BeginProcessing;
                m_btnBack.IsEnabled         = true;
                m_btnFinish.Content         = "Next";
                m_tbDesc.Visibility         = System.Windows.Visibility.Visible;
                m_gridProcessing.Visibility = System.Windows.Visibility.Collapsed;
                m_lblProgress.Content       = "";

                break;
            }

            case ProcessingState.DoneProcessing:
            {
                NavigationWindow window = this.Parent as NavigationWindow;

                if (window != null)
                {
                    window.Close();
                }
                break;
            }
            }
        }
Example #6
0
        // this is called on worker thread
        private object StartResourceInvalidationTest(object obj)
        {
            _win2.SetResourceReference(Window.TitleProperty, _windowTextResourceKey);

            if (_win2.Title.Equals(_windowTextResourceValue) == true)
            {
                _win2ResourceInvalidationPassed = true;
            }
            _win2.Close();

            _win1.Dispatcher.BeginInvoke(
                DispatcherPriority.Background,
                new DispatcherOperationCallback(VerifyResourceInvalidationTestOnAppThread),
                null);
            return(null);
        }
        private void MakeAdmin(object sender, RoutedEventArgs e)
        {
            try
            {
                SetLanguageDictionary();

                DesktopUser newAdmin = ((FrameworkElement)sender).DataContext as DesktopUser;

                string messageboxContent = String.Format(LangResource.MBContentMakeUserAdmin, newAdmin.FullName);
                string messageboxTitle   = String.Format(LangResource.MBTitleMakeUserAdmin, newAdmin.FullName);

                MessageBoxManager.Yes = LangResource.Yes;
                MessageBoxManager.No  = LangResource.No;
                MessageBoxManager.Register();

                if (MessageBox.Show(messageboxContent,
                                    messageboxTitle,
                                    MessageBoxButton.YesNo,
                                    MessageBoxImage.Warning)
                    == MessageBoxResult.Yes)
                {
                    _userRepo.AssignNewAdmin(newAdmin);
                    _userRepo.SaveChangesAsync();

                    LoginWindow login = new LoginWindow();
                    login.Show();

                    NavigationWindow win = (NavigationWindow)Window.GetWindow(this);

                    win.Close();

                    MessageBoxManager.Unregister();
                }
                else
                {
                    MessageBoxManager.Unregister();
                }
            }
            catch (Exception)
            {
                MessageBox.Show(LangResource.ErrUpdateOverviewFailed);
                MessageBoxManager.Unregister();
            }
        }
Example #8
0
        private async Task <bool> CanConnectUsingOpenId(Connection connection)
        {
            try
            {
                using (var source = new CancellationTokenSource())
                {
                    var discoveryUrl = new Uri(new Uri(connection.Uri), "/" + OpenIdProviderMetadataNames.Discovery);
                    var config       = await OpenIdConnectConfigurationRetriever.GetAsync(discoveryUrl.ToString(), source.Token);

                    var result = false;
                    var closed = false;

                    var authEndpoint = config.AuthorizationEndpoint +
                                       "?scope=email%20profile" +
                                       "&response_type=code" +
                                       "&redirect_uri=http://localhost:" + connection.RedirectPort +
                                       "&client_id=" + WebUtility.UrlEncode(connection.ClientId);

                    await Runtime.InvokeAsync(() =>
                    {
                        var window = new NavigationWindow()
                        {
                            WindowStartupLocation = WindowStartupLocation.CenterOwner,
                            Owner             = Application.Current?.MainWindow,
                            Title             = "Authenticate",
                            ShowsNavigationUI = false,
                            Source            = new Uri(authEndpoint),
                            Width             = 500,
                            Height            = 400
                        };

                        var listener = new HttpListener();
                        listener.Prefixes.Add($"http://*:{ connection.RedirectPort }/");
                        listener.Start();

                        listener.BeginGetContext(x =>
                        {
                            if (!listener.IsListening || closed)
                            {
                                return;
                            }

                            var context = listener.EndGetContext(x);
                            var code    = context.Request.QueryString["code"];

                            Runtime.Invoke(() =>
                            {
                                result = !string.IsNullOrWhiteSpace(code);
                                window.Close();
                            });
                        }, null);

                        window.Closed += (s, e) =>
                        {
                            closed = true;
                            listener.Stop();
                        };

                        window.ShowDialog();
                    });

                    _log.DebugFormat("OpenID connection test {0}", result ? "passed" : "failed");
                    return(await Task.FromResult(result));
                }
            }
            catch (Exception ex)
            {
                _log.Error("OpenID connection test failed", ex);
                return(await Task.FromResult(false));
            }
        }
Example #9
0
 /// <summary>
 /// 关闭页面
 /// </summary>
 public void Close()
 {
     CanClose = true;
     NavigaionWin.Dispatcher.Invoke(new Action(() => { NavigaionWin.Close(); }));
 }
Example #10
0
        public void backfunction()
        {
            NavigationWindow nw = (NavigationWindow)Window.GetWindow(this);

            nw.Close();
        }