private void OpCombo_SelectedIndexChanged(object sender, EventArgs e) { if (OpCombo.SelectedItem is OpComboItem) { OpComboItem item = OpCombo.SelectedItem as OpComboItem; //item.UpdateSplash(); TextPassword.Enabled = File.Exists(item.Fullpath); TextPassword.Text = ""; TextPassword.Select(); CheckLoginButton(); return; } else { TextPassword.Enabled = ButtonLoad.Enabled = false; } if (OpCombo.SelectedItem is string) { //SplashBox.Image = InterfaceRes.splash; BrowseLink_LinkClicked(); } }
private void BrowseLink_LinkClicked() { try { OpenFileDialog open = new OpenFileDialog(); open.InitialDirectory = LastBrowse; open.Filter = "DeOps Identity (*.dop)|*.dop"; if (open.ShowDialog() == DialogResult.OK) { OpComboItem select = null; foreach (object item in OpCombo.Items) { if (item is OpComboItem) { if (((OpComboItem)item).Fullpath == open.FileName) { select = item as OpComboItem; break; } } } if (select == null) { select = new OpComboItem(this, open.FileName); OpCombo.Items.Insert(0, select); } OpCombo.SelectedItem = select; LastBrowse = open.FileName; TextPassword.Text = ""; TextPassword.Select(); } else { OpCombo.Text = ""; } } catch (Exception ex) { MessageBox.Show(this, ex.Message); } }
private void BrowseLink_LinkClicked() { try { OpenFileDialog open = new OpenFileDialog(); open.InitialDirectory = LastBrowse; open.Filter = "DeOps Identity (*.dop)|*.dop"; if (open.ShowDialog() == DialogResult.OK) { OpComboItem select = null; foreach(object item in OpCombo.Items) if(item is OpComboItem) if (((OpComboItem)item).Fullpath == open.FileName) { select = item as OpComboItem; break; } if (select == null) { select = new OpComboItem(this, open.FileName); OpCombo.Items.Insert(0, select); } OpCombo.SelectedItem = select; LastBrowse = open.FileName; TextPassword.Text = ""; TextPassword.Select(); } else OpCombo.Text = ""; } catch(Exception ex) { MessageBox.Show(this, ex.Message); } }
public LoginForm(AppContext app, string arg) { App = app; Context = app.Context; Arg = arg; InitializeComponent(); Text = "DeOps Alpha v" + DeOpsContext.CoreVersion; //+ app.Context.LocalSeqVersion.ToString(); //SplashBox.Image = InterfaceRes.splash; if (Context.Sim != null) // prevent sim recursion { EnterSimLink.Visible = false; } LastBrowse = Application.StartupPath; LastOpened = (arg != "") ? arg : App.Settings.LastOpened; // each profile (.rop) is in its own directory // /root/profiledirs[]/profile.rop if (App.Context.Sim == null) { LoadProfiles(Application.StartupPath); // if started with file argument, load profiles around the same location if (File.Exists(arg)) { LoadProfiles(Path.GetDirectoryName(Path.GetDirectoryName(arg))); } } else { LoadProfiles(App.Context.Sim.Internet.LoadedPath); } OpComboItem select = null; if (LastOpened != null) { foreach (OpComboItem item in OpCombo.Items) { if (item.Fullpath == LastOpened) { select = item; } } } if (select != null) { OpCombo.SelectedItem = select; } else if (OpCombo.Items.Count > 0) { OpCombo.SelectedIndex = 0; } OpCombo.Items.Add("Browse..."); if (OpCombo.SelectedItem != null) { TextPassword.Select(); } }
private void ButtonLoad_Click(object sender, EventArgs e) { Debug.WriteLine("GUI Thread: " + Thread.CurrentThread.ManagedThreadId); OpComboItem item = OpCombo.SelectedItem as OpComboItem; if (item == null) { return; } bool handled = false; // look for item in context cores, show mainGui, or notify user to check tray App.CoreUIs.LockReading(delegate() { foreach (var ui in App.CoreUIs) { if (ui.Core.User.ProfilePath == item.Fullpath) { if (ui.GuiMain != null) { ui.GuiMain.WindowState = FormWindowState.Normal; ui.GuiMain.Activate(); Close(); // user thinks they logged back on, window just brought to front } else { MessageBox.Show(this, "This profile is already loaded, check the system tray", "DeOps"); } handled = true; } } }); if (handled) { return; } OpCore newCore = null; try { App.LoadCore(item.Fullpath, TextPassword.Text); App.Settings.LastOpened = item.Fullpath; Close(); } catch (Exception ex) { // if interface threw exception, remove the added core if (newCore != null) { App.RemoveCore(newCore); } if (ex is System.Security.Cryptography.CryptographicException) { MessageBox.Show(this, "Wrong Passphrase"); } else { //crit - delete using (StreamWriter log = File.CreateText("debug.txt")) { log.Write(ex.Message); log.WriteLine(""); log.Write(ex.StackTrace); } new ErrorReport(ex).ShowDialog(); } } }