Exemplo n.º 1
0
        private void createToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog dialog = new FolderBrowserDialog();
            DialogResult        result = dialog.ShowDialog();

            if (result != DialogResult.OK)
            {
                return;
            }
            if (string.IsNullOrWhiteSpace(dialog.SelectedPath))
            {
                return;
            }

            // check alreary have an account
            Account account = AccountLoader.load(dialog.SelectedPath);

            if (account != null)
            {
                MessageBox.Show("The folder already contains an account! Select another folder.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            // create new
            account = AccountLoader.create(dialog.SelectedPath);
            if (account == null)
            {
                MessageBox.Show("Cannot create an account!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            session   = new Session(account);
            this.Text = Path.GetFileName(Path.GetDirectoryName(account.filenameKnown));
        }
Exemplo n.º 2
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog dialog = new FolderBrowserDialog();
            DialogResult        result = dialog.ShowDialog();

            if (result != DialogResult.OK)
            {
                return;
            }
            if (string.IsNullOrWhiteSpace(dialog.SelectedPath))
            {
                return;
            }

            Account account = AccountLoader.load(dialog.SelectedPath);

            if (account == null)
            {
                MessageBox.Show("The folder doesn't contain an account!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            session   = new Session(account);
            this.Text = Path.GetFileName(Path.GetDirectoryName(account.filenameKnown));
        }