protected override void OnStartup(StartupEventArgs e) { //создаем глобальный обработчик исключений, который будет нам писать логи в папку данных приложения LogWriter logger = new LogWriter(); App.Current.DispatcherUnhandledException += logger.Handler; // Регистрация библиотек GemBox GemBox.Document.ComponentInfo.SetLicense("DH5L-PTFV-SL2S-5PCN"); GemBox.Spreadsheet.SpreadsheetInfo.SetLicense("E43Y-75J1-FTBX-2T9U"); //авторизация и запуск главного окна при успехе base.OnStartup(e); //авторизация и запуск главного окна при успехе var auth = new AuthWindow(); if (auth.ShowDialog() ?? false) { //создаем главное окно приложения DesktopWindow window = new DesktopWindow(); MainWindow = window; window.ShowDialog(); } App.Current.Shutdown(); }
public bool GetCredentialsFromUser(IWin32Window owner, Uri translationProviderUri, string translationProviderState, ITranslationProviderCredentialStore credentialStore, string initialAuthToken) { var authViewModel = new AuthViewModel(_client); string existingToken = credentialStore.GetCredential(translationProviderUri)?.Credential ?? initialAuthToken; authViewModel.AuthToken = existingToken; var authView = new AuthWindow(authViewModel); bool success = authView.ShowDialog() == true; if (!success) { return(false); } string authToken = authViewModel.AuthToken; if (authToken != null) { credentialStore.AddCredential(translationProviderUri, new TranslationProviderCredential(authToken, true)); return(true); } else { // the user has deleted the token using the logout button credentialStore.RemoveCredential(translationProviderUri); // TODO: return something that will make Trados disable the plugin. Currently I don't think it's possible, though. // Returning false indicates that the settings haven't changed which isn't true but if true is returned the user // gets endless prompts from Trados to input credentials. This seems like a bug, though, so hopefully this will change. return(false); } }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); Current.ShutdownMode = ShutdownMode.OnExplicitShutdown; AuthWindow authWnd = new AuthWindow(); if (!authWnd.ShowDialog().Value) { Current.Shutdown(); } Current.ShutdownMode = ShutdownMode.OnMainWindowClose; WorkerWindow workerWindow = new WorkerWindow(); OrdersWindow ordersWindow = new OrdersWindow(); MenuWindow menuWindow = new MenuWindow(); CreateOrderWindow createOrderWindow = new CreateOrderWindow(); try { workerWindow.Show(); ordersWindow.Show(); menuWindow.Show(); createOrderWindow.Show(); } catch { Application.Current.Shutdown(); } }
public static void GetAccessToken(User user, UserScope[] scopes, bool getNewAccessToken = false) { if (getNewAccessToken || string.IsNullOrEmpty(user.AccessToken)) { var authWindow = new AuthWindow(user, scopes); bool? result = authWindow.ShowDialog(); if (result.Value && !string.IsNullOrEmpty(authWindow.AccessToken)) { user.AccessToken = authWindow.AccessToken; } DataFileManager.SetUser(user); } }
public void Authorization() { this.Hide(); var authWindow = new AuthWindow(db); if (authWindow.ShowDialog() == true) { UsernameTextBlock.Text = authWindow.CurrentUser.Login; currentUser = authWindow.CurrentUser; this.Show(); } else { this.Close(); } }
public MainWindow() { try { AuthWindow w = new AuthWindow(); w.ShowDialog(); InitializeComponent(); MainViewModel.Instance.AudioPlayerVM.PropertyChanged += Instance_PropertyChanged; Grip.MouseDown += grip_MouseDown; Grip.MouseMove += Grip_MouseMove; Grip.MouseUp += grip_MouseUp; } catch (Exception e) { MessageBox.Show(e.Message); } }
void LoadSettings() { if (SettingHelper.ReadOldSettings() != null)//检测到旧配置文件 { var r = MessageBox.Show("软件已更新!检测到旧版本的用户列表,是否导入?", "提示", MessageBoxButton.YesNo); if (r == MessageBoxResult.Yes) { settings = SettingHelper.ReadOldSettings(); SetPasswordWindow spw = new SetPasswordWindow(); spw.ShowDialog(); SettingHelper.DeleteOldSettings(); InitLogin(); return; } else { SettingHelper.DeleteOldSettings(); MessageBox.Show("已删除旧版本的用户列表", "提示"); } } if (SettingHelper.ExistSettings()) //如果存在新版配置文件 { AuthWindow aw = new AuthWindow(); //开始验证 aw.ShowDialog(); if (settings != null) //如果验证通过,读取新配置文件成功 { InitLogin(); } else//如果读取配置文件失败 { SettingHelper.DeleteSettings(); MessageBox.Show("读取配置文件失败,已删除配置文件", "提示"); Environment.Exit(0); } } else { SetPasswordWindow spw = new SetPasswordWindow(); spw.ShowDialog(); InitLogin(); } }
private void Authorize() { Hide(); AuthWindow authWindow = new AuthWindow(); authWindow.ShowDialog(); if (authWindow.authData == null) { Close(); } else { Auth.id = authWindow.authData.userId; Auth.name = authWindow.authData.nickName; Auth.token = authWindow.authData.Token; lb_nickName.Content = Auth.name; Show(); } }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); // Запуск перехватчика ошибок App.Current.DispatcherUnhandledException += (new ExceptionDispatcher()).Handler; // Регистрация библиотек GemBox GemBox.Document.ComponentInfo.SetLicense("DH5L-PTFV-SL2S-5PCN"); GemBox.Spreadsheet.SpreadsheetInfo.SetLicense("E43Y-75J1-FTBX-2T9U"); // Авторизация var authWindow = new AuthWindow(); if (authWindow.ShowDialog() ?? false) { var desktop = new DesktopWindow(); MainWindow = desktop; desktop.ShowDialog(); } App.Current.Shutdown(); }
public async Task InitializeAsync() { for (var i = 0; i < 10; i++) { Debug.WriteLine("わああ"); } if (File.Exists(KEY_FILEPATH)) { using var fs = File.OpenRead(KEY_FILEPATH); var keys = await MessagePackSerializer.DeserializeAsync <KeyModel>(fs); this.Token = Tokens.Create(ConsumerKey, ConsumerSecret, keys.AccessToken, keys.AccessSecret); this.Publish(); } else { var model = new AuthModel(this); await model.InitializeAsync(); var vm = new AuthWindowViewModel(model); var authWin = new AuthWindow(vm); authWin.ShowDialog(); } }