//返回登录按钮的事件 private void btn_Login_Click(object sender, EventArgs e) { OkClick = true; //点击单击了该按钮 Login login = new Login(); //实例化Login登录窗体对象 login.Show(); //显示登录窗体 login.Activate(); //给予焦点 this.Close(); //当前窗体关闭 }
private void Form1_Load(object sender, EventArgs e) { if (login == null) { login = new Login(); login.MdiParent = this; login.FormClosed += new FormClosedEventHandler(cerrarLogin); login.Show(); } else { login.Activate(); } }
public void LoadSettings() { if (ExchangeManager.SettingsAvailable()) { var login = new Login(); login.Closing += LoginOnClosing; login.Show(); login.Activate(); } else { var createPassword = new CreatePassword(); createPassword.Closing += CreatePasswordOnClosing; createPassword.Show(); createPassword.Activate(); } }
//METHODS private void CheckDeleteRecipe(object obj) { if (CurrentSelectedRecipe == null) { MessageBox.Show("Please select a recipe to be deleted"); return; } //IF specific admin user is logged in, no need to ask for login if (TitleMenuViewModel._username.Equals("Admin3")) { DeleteRecipe(); return; } //IF no user is logged in, ask user to login and make sure admin user with permissions var login = new Login(); var loginVM = new LoginViewModel(); bool isPassCorrect = false; //IF login is successful, do following code (SAME CODE AS THE ) loginVM.LoginCompleted += (sender, args) => { DeleteRecipe(); login.Close(); isPassCorrect = true; _eventAggregator.GetEvent <LoginUsernameEvent>().Publish(LoginViewModel._username); Username = LoginViewModel._username; }; login.DataContext = loginVM; login.ShowDialog(); login.Activate(); if (!isPassCorrect) { MessageBox.Show("Incorrect Login Information"); login.Close(); } }
public static void Main(string[] args) { string LogDirectory = Path.Combine(Application.StartupPath, "logs"); if (!Directory.Exists(LogDirectory)) { try { Directory.CreateDirectory(LogDirectory); // try making the cache directory Console.WriteLine("Creating log directory."); } catch (Exception ex) { Console.WriteLine("Unable to create log directory.\n{0}", ex.ToString()); return; } } Log mainLog; bool created; mutex = new Mutex(false, "Mist-AF12AF2", out created); if (!created) { int pid = 0; try { Random random = new Random(); pid = random.Next(0, 9999); pid += System.Diagnostics.Process.GetProcessesByName("Mist")[0].Id; } catch { Random random = new Random(); pid = random.Next(0, 9999); } mainLog = new Log(@"logs/Mist-" + pid + ".log", "Mist", Log.LogLevel.Debug); } else { mainLog = new Log(@"logs/Mist.log", "Mist", Log.LogLevel.Debug); } Application.EnableVisualStyles(); Login login = new Login(); mainLog.Info("Launching Mist..."); Configuration config = new Configuration(); Configuration.BotInfo info = new Configuration.BotInfo(); info.BotControlClass = "SteamBot.SimpleUserHandler"; login.Show(); login.Activate(); new Thread(() => { while (!Login.LoginClicked) { } int crashes = 0; while (crashes < 100) { try { new Bot(info, mainLog, login.APIKey, (Bot bot, SteamID sid) => { return (SteamBot.UserHandler)System.Activator.CreateInstance(Type.GetType(bot.BotControlClass), new object[] { bot, sid }); }, login, false); } catch (Exception e) { mainLog.Error("Error With Bot: " + e); crashes++; } } }).Start(); Application.Run(login); }