void btnUpdateAniDBLogin_Click(object sender, RoutedEventArgs e) { InitialSetupForm frm = new InitialSetupForm(); frm.Owner = this; frm.ShowDialog(); }
void btnUpdateAniDBLogin_Click(object sender, RoutedEventArgs e) { if (AniDBLoginOpen && LoginWindow != null) { LoginWindow.Focus(); return; } LoginWindow = new InitialSetupForm(); LoginWindow.Owner = this; LoginWindow.ShowDialog(); }
public void ShowAniDBLoginDialog() { if (AniDBLoginOpen && LoginWindow != null) { LoginWindow.Focus(); return; } LoginWindow = new InitialSetupForm { Owner = this }; LoginWindow.ShowDialog(); }
private void SubscribeEvents() { ServerSettings.YesNoRequired += (sender, args) => { System.Windows.Forms.DialogResult dr = System.Windows.Forms.MessageBox.Show(args.Reason, args.FormTitle, MessageBoxButtons.YesNo); if (dr == System.Windows.Forms.DialogResult.No) { args.Cancel = true; } }; ServerSettings.LocateFile += (sender, args) => { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "JMM config|JMMServer.exe.config;settings.json"; DialogResult browseFile = openFileDialog.ShowDialog(); if (browseFile == System.Windows.Forms.DialogResult.OK && !string.IsNullOrEmpty(openFileDialog.FileName.Trim())) { args.FileName = openFileDialog.FileName; } }; Utils.ErrorMessage += (sender, args) => MessageBox.Show(this, args.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); AniDBHelper.LoginFailed += (a, e) => Application.Current.Dispatcher.Invoke(() => { MessageBox.Show(Shoko.Commons.Properties.Resources.InitialSetup_LoginFail, Shoko.Commons.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); InitialSetupForm frm = new InitialSetupForm(); frm.ShowDialog(); }); ShokoServer.Instance.LoginFormNeeded += (a, e) => Application.Current.Dispatcher.Invoke(() => new InitialSetupForm().ShowDialog()); ServerSettings.MigrationStarted += (a, e) => { // Display the migration form. var migrationForm = new MigrationForm(); migrationForm.Show(); }; ShokoServer.Instance.DBSetupCompleted += DBSetupCompleted; ShokoServer.Instance.DatabaseSetup += (sender, args) => ShowDatabaseSetup(); }
void workerSetupDB_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { bool setupComplete = bool.Parse(e.Result.ToString()); if (setupComplete) { ServerInfo.Instance.RefreshImportFolders(); ServerInfo.Instance.RefreshCloudAccounts(); ServerState.Instance.CurrentSetupStatus = Shoko.Commons.Properties.Resources.Server_Complete; ServerState.Instance.ServerOnline = true; tabControl1.SelectedIndex = 0; } else { ServerState.Instance.ServerOnline = false; if (string.IsNullOrEmpty(ServerSettings.DatabaseType)) { ServerSettings.DatabaseType = "SQLite"; ShowDatabaseSetup(); } } btnSaveDatabaseSettings.IsEnabled = true; cboDatabaseType.IsEnabled = true; btnRefreshMSSQLServerList.IsEnabled = true; if (setupComplete) { if (string.IsNullOrEmpty(ServerSettings.AniDB_Username) || string.IsNullOrEmpty(ServerSettings.AniDB_Password)) { InitialSetupForm frm = new InitialSetupForm(); frm.Owner = this; frm.ShowDialog(); } IReadOnlyList <SVR_ImportFolder> folders = RepoFactory.ImportFolder.GetAll(); if (folders.Count == 0) { tabControl1.SelectedIndex = 1; } } }
private void SubscribeEvents() { Utils.YesNoRequired += (sender, args) => { DialogResult dr = System.Windows.Forms.MessageBox.Show(args.Reason, args.FormTitle, MessageBoxButtons.YesNo); if (dr == System.Windows.Forms.DialogResult.No) { args.Cancel = true; } }; ServerSettings.LocateFile += (sender, args) => { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = @"JMM config|JMMServer.exe.config;settings.json"; DialogResult browseFile = openFileDialog.ShowDialog(); if (browseFile == System.Windows.Forms.DialogResult.OK && !string.IsNullOrEmpty(openFileDialog.FileName.Trim())) { args.FileName = openFileDialog.FileName; } }; Utils.ErrorMessage += (sender, args) => MessageBox.Show(this, args.Message, args.Title ?? (args.IsError ? "Error" : "Message"), MessageBoxButton.OK, args.IsError ? MessageBoxImage.Error : MessageBoxImage.Information); Utils.OnEvents += (sender, args) => { DoEvents(); }; Utils.OnDispatch += action => { Application.Current.Dispatcher.Invoke(action); }; AniDBHelper.LoginFailed += (a, e) => Application.Current.Dispatcher.Invoke(() => { if (AniDBLoginOpen && LoginWindow != null) { LoginWindow.Focus(); return; } LoginWindow = new InitialSetupForm(); LoginWindow.Owner = this; LoginWindow.ShowDialog(); }); ShokoServer.Instance.LoginFormNeeded += (a, e) => Application.Current.Dispatcher.Invoke(() => { if (AniDBLoginOpen && LoginWindow != null) { LoginWindow.Focus(); return; } LoginWindow = new InitialSetupForm(); LoginWindow.Owner = this; LoginWindow.ShowDialog(); }); ServerSettings.MigrationStarted += (a, e) => { Application.Current.Dispatcher.Invoke(() => { // Display the migration form. var migrationForm = new MigrationForm(); migrationForm.Show(); }); }; ShokoServer.Instance. DBSetupCompleted += DBSetupCompleted; ShokoServer.Instance.DatabaseSetup += (sender, args) => ShowDatabaseSetup(); }
public MainWindow() { InitializeComponent(); Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(ServerSettings.Culture); if (!ShokoServer.Instance.StartUpServer()) { MessageBox.Show(Commons.Properties.Resources.Server_Running, Commons.Properties.Resources.ShokoServer, MessageBoxButton.OK, MessageBoxImage.Error); Environment.Exit(0); } ServerSettings.DebugSettingsToLog(); //Create an instance of the NotifyIcon Class TippuTrayNotify = new System.Windows.Forms.NotifyIcon(); // This icon file needs to be in the bin folder of the application TippuTrayNotify = new System.Windows.Forms.NotifyIcon(); Stream iconStream = Application.GetResourceStream(new Uri("pack://application:,,,/ShokoServer;component/db.ico")).Stream; TippuTrayNotify.Icon = new System.Drawing.Icon(iconStream); iconStream.Dispose(); //show the Tray Notify IconbtnRemoveMissingFiles.Click TippuTrayNotify.Visible = true; //-- for winforms applications System.Windows.Forms.Application.ThreadException -= UnhandledExceptionManager.ThreadExceptionHandler; System.Windows.Forms.Application.ThreadException += UnhandledExceptionManager.ThreadExceptionHandler; CreateMenus(); ServerState.Instance.DatabaseAvailable = false; ServerState.Instance.ServerOnline = false; ServerState.Instance.BaseImagePath = ImageUtils.GetBaseImagesPath(); this.Closing += new System.ComponentModel.CancelEventHandler(MainWindow_Closing); this.StateChanged += new EventHandler(MainWindow_StateChanged); TippuTrayNotify.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(TippuTrayNotify_MouseDoubleClick); btnToolbarShutdown.Click += new RoutedEventHandler(btnToolbarShutdown_Click); btnHasherPause.Click += new RoutedEventHandler(btnHasherPause_Click); btnHasherResume.Click += new RoutedEventHandler(btnHasherResume_Click); btnGeneralPause.Click += new RoutedEventHandler(btnGeneralPause_Click); btnGeneralResume.Click += new RoutedEventHandler(btnGeneralResume_Click); btnImagesPause.Click += new RoutedEventHandler(btnImagesPause_Click); btnImagesResume.Click += new RoutedEventHandler(btnImagesResume_Click); btnAdminMessages.Click += btnAdminMessages_Click; btnRemoveMissingFiles.Click += new RoutedEventHandler(btnRemoveMissingFiles_Click); btnRunImport.Click += new RoutedEventHandler(btnRunImport_Click); btnSyncHashes.Click += BtnSyncHashes_Click; btnSyncMedias.Click += BtnSyncMedias_Click; btnSyncMyList.Click += new RoutedEventHandler(btnSyncMyList_Click); btnSyncVotes.Click += new RoutedEventHandler(btnSyncVotes_Click); btnUpdateTvDBInfo.Click += new RoutedEventHandler(btnUpdateTvDBInfo_Click); btnUpdateAllStats.Click += new RoutedEventHandler(btnUpdateAllStats_Click); btnSyncTrakt.Click += new RoutedEventHandler(btnSyncTrakt_Click); btnImportManualLinks.Click += new RoutedEventHandler(btnImportManualLinks_Click); btnUpdateAniDBInfo.Click += new RoutedEventHandler(btnUpdateAniDBInfo_Click); btnLaunchWebUI.Click += new RoutedEventHandler(btnLaunchWebUI_Click); btnUpdateImages.Click += new RoutedEventHandler(btnUpdateImages_Click); btnUploadAzureCache.Click += new RoutedEventHandler(btnUploadAzureCache_Click); btnUpdateTraktInfo.Click += BtnUpdateTraktInfo_Click; btnSyncPlex.Click += BtnSyncPlexOn_Click; this.Loaded += new RoutedEventHandler(MainWindow_Loaded); txtServerPort.Text = ServerSettings.JMMServerPort; btnToolbarHelp.Click += new RoutedEventHandler(btnToolbarHelp_Click); btnApplyServerPort.Click += new RoutedEventHandler(btnApplyServerPort_Click); btnUpdateMediaInfo.Click += new RoutedEventHandler(btnUpdateMediaInfo_Click); //StartUp(); cboDatabaseType.Items.Clear(); ShokoServer.Instance.GetSupportedDatabases().ForEach(s => cboDatabaseType.Items.Add(s)); cboDatabaseType.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(cboDatabaseType_SelectionChanged); btnChooseImagesFolder.Click += new RoutedEventHandler(btnChooseImagesFolder_Click); btnSetDefault.Click += BtnSetDefault_Click; btnSaveDatabaseSettings.Click += new RoutedEventHandler(btnSaveDatabaseSettings_Click); btnRefreshMSSQLServerList.Click += new RoutedEventHandler(btnRefreshMSSQLServerList_Click); // btnInstallMSSQLServer.Click += new RoutedEventHandler(btnInstallMSSQLServer_Click); btnMaxOnStartup.Click += new RoutedEventHandler(toggleMinimizeOnStartup); btnMinOnStartup.Click += new RoutedEventHandler(toggleMinimizeOnStartup); btnLogs.Click += new RoutedEventHandler(btnLogs_Click); btnChooseVLCLocation.Click += new RoutedEventHandler(btnChooseVLCLocation_Click); btnJMMEnableStartWithWindows.Click += new RoutedEventHandler(btnJMMEnableStartWithWindows_Click); btnJMMDisableStartWithWindows.Click += new RoutedEventHandler(btnJMMDisableStartWithWindows_Click); btnUpdateAniDBLogin.Click += new RoutedEventHandler(btnUpdateAniDBLogin_Click); btnHasherClear.Click += new RoutedEventHandler(btnHasherClear_Click); btnGeneralClear.Click += new RoutedEventHandler(btnGeneralClear_Click); btnImagesClear.Click += new RoutedEventHandler(btnImagesClear_Click); //automaticUpdater.MenuItem = mnuCheckForUpdates; ServerState.Instance.LoadSettings(); cboLanguages.SelectionChanged += new SelectionChangedEventHandler(cboLanguages_SelectionChanged); InitCulture(); Instance = this; ServerSettings.YesNoRequired += (sender, args) => { System.Windows.Forms.DialogResult dr = System.Windows.Forms.MessageBox.Show(args.Reason, args.FormTitle, MessageBoxButtons.YesNo); if (dr == System.Windows.Forms.DialogResult.No) { args.Cancel = true; } }; ServerSettings.LocateFile += (sender, args) => { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "JMM config|JMMServer.exe.config;settings.json"; DialogResult browseFile = openFileDialog.ShowDialog(); if (browseFile == System.Windows.Forms.DialogResult.OK && !string.IsNullOrEmpty(openFileDialog.FileName.Trim())) { args.FileName = openFileDialog.FileName; } }; Utils.ErrorMessage += (sender, args) => MessageBox.Show(this, args.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); AniDBHelper.LoginFailed += (a, e) => Application.Current.Dispatcher.Invoke(() => { MessageBox.Show(Shoko.Commons.Properties.Resources.InitialSetup_LoginFail, Shoko.Commons.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); InitialSetupForm frm = new InitialSetupForm(); frm.ShowDialog(); }); ServerSettings.MigrationStarted += (a, e) => { // Display the migration form. var migrationForm = new MigrationForm(); migrationForm.Show(); }; }
public bool Login() { // check if we are already logged in if (isLoggedOn) { return(true); } if (!ValidAniDBCredentials()) { return(false); } AniDBCommand_Login login = new AniDBCommand_Login(); login.Init(userName, password); string msg = login.commandText.Replace(userName, "******"); msg = msg.Replace(password, "******"); logger.Trace("udp command: {0}", msg); SetWaitingOnResponse(true); enHelperActivityType ev = login.Process(ref soUdp, ref remoteIpEndPoint, curSessionID, new UnicodeEncoding(true, false)); SetWaitingOnResponse(false); if (login.errorOccurred) { logger.Trace("error in login: {0}", login.errorMessage); } //else // logger.Info("socketResponse: {0}", login.socketResponse); Thread.Sleep(2200); if (ev != enHelperActivityType.LoggedIn) { Application.Current.Dispatcher.Invoke(() => { MessageBox.Show(Properties.Resources.InitialSetup_LoginFail, Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); InitialSetupForm frm = new InitialSetupForm(); frm.ShowDialog(); }); //BaseConfig.MyAnimeLog.Write("ProcessCommands: Login Failed!"); //OnAniDBStatusEvent(new AniDBStatusEventArgs(enHelperActivityType.LoginFailed, "")); //aniDBCommands.Clear(); //OnQueueUpdateEvent(new QueueUpdateEventArgs(this.QueueCount)); // this will exit the thread return(false); } else { curSessionID = login.SessionID; encoding = login.Encoding; this.isLoggedOn = true; this.IsInvalidSession = false; return(true); } }