Exemple #1
0
        private void saveButton_Button_Pressed(object sender, EventArgs e)
        {
            // Validate all the entered data
            if (!validate_entry())
            {
                return;
            }

            // Save all this data to the endpoint
            save_data_to_endpoint();

            if (during_connection)
            {
                // Need to get a name for this connection
                bool show_password_box = false;
                if (passwordTextBox.Text.Trim().Length > 0)
                {
                    show_password_box = true;
                }
                Z3950_Endpoint_Save_Dialog saveDialog = new Z3950_Endpoint_Save_Dialog(show_password_box, Endpoint.Name);
                Hide();
                DialogResult result = saveDialog.ShowDialog();
                if (result == DialogResult.OK)
                {
                    // Save the new name and password flag
                    Endpoint.Name = saveDialog.Endpoint_Name;
                    if (saveDialog.Save_Password)
                    {
                        Endpoint.Save_Password_Flag = true;
                    }

                    // Save this to the user settings
                    MetaTemplate_UserSettings.Add_Z3950_Endpoint(Endpoint);
                    MetaTemplate_UserSettings.Save();

                    // Close this form
                    Close();
                }
                else
                {
                    Show();
                }
            }
            else
            {
                if (passwordTextBox.Text.Trim().Length > 0)
                {
                    Endpoint.Password           = passwordTextBox.Text.Trim();
                    Endpoint.Save_Password_Flag = true;
                }

                // Save this to the user settings
                MetaTemplate_UserSettings.Add_Z3950_Endpoint(Endpoint);
                MetaTemplate_UserSettings.Save();

                // Close this form
                Close();
            }
        }
        private void editButton_Button_Pressed(object sender, EventArgs e)
        {
            if (listView1.SelectedItems.Count > 0)
            {
                string         name     = listView1.SelectedItems[0].SubItems[0].Text;
                Z3950_Endpoint endpoint = MetaTemplate_UserSettings.Get_Endpoint_By_Name(name);
                if (endpoint != null)
                {
                    Z3950_Endpoint_Form editForm = new Z3950_Endpoint_Form(endpoint, false);
                    Hide();
                    editForm.ShowDialog();
                    Show();
                    if (editForm.Endpoint != null)
                    {
                        MetaTemplate_UserSettings.Add_Z3950_Endpoint(editForm.Endpoint);
                        MetaTemplate_UserSettings.Save();
                    }
                }
            }

            refresh_endpoints();
        }