private void continueButton_Button_Pressed(object sender, EventArgs e) { if (textBox1.Text.Trim().Length > 0) { oaiUrl = textBox1.Text.Trim(); repositoryInfo = OAI_Repository_Stream_Reader.Identify(oaiUrl); if (repositoryInfo.Is_Valid) { OAI_Repository_Stream_Reader.List_Metadata_Formats(repositoryInfo); if (!repositoryInfo.Metadata_Formats.Contains("oai_dc")) { MessageBox.Show(repositoryInfo.Name + " does not support 'oai_dc' metadata format. ", "Failure", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MetaTemplate_UserSettings.Last_OAI_URL = oaiUrl; MetaTemplate_UserSettings.Save(); DialogResult = DialogResult.OK; Close(); } } else { MessageBox.Show("Unable to connect to the OAI-PMH repository listed.\n\nTry checking the URL or your network connections. ", "Error Encountered", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Enter the OAI-PMH Repository URL to continue. ", "Missing Information", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
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 showMetadataCheckBox_CheckedChanged(object sender, EventArgs e) { MetaTemplate_UserSettings.Show_Metadata_PostSave = showMetadataCheckBox.Checked; MetaTemplate_UserSettings.Save(); if (!MetaTemplate_UserSettings.Show_Metadata_PostSave) { MessageBox.Show("To make this form automatically appear again, you can \nset this value under Settings --> Metadata Preferences.", "Metadata Display Disabled", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void deleteButton_Button_Pressed(object sender, EventArgs e) { if (listView1.SelectedItems.Count > 0) { string name = listView1.SelectedItems[0].SubItems[0].Text; MetaTemplate_UserSettings.Delete_Z3950_Endpoint(name); MetaTemplate_UserSettings.Save(); } refresh_endpoints(); }
private void importButton_Button_Pressed(object sender, EventArgs e) { // Check the primary key is provided if (identifierTextBox.Text.Trim().Length == 0) { MessageBox.Show("Enter the primary identifier to import the Z39.50 records. ", "Missing Primary Identifier", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // Check the Z39.50 endpoint if (endpoint == null) { Z3950_Endpoint_Form endpointForm = new Z3950_Endpoint_Form(); Hide(); endpointForm.ShowDialog(); Show(); endpoint = endpointForm.Endpoint; if (endpoint == null) { MessageBox.Show("Select a Z39.50 endpoint or enter information for a new or temporary endpoint. ", "Missing Endpoint", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } // Since this was a VALID entry, save this as the last Z39.50 endpoint used if ((endpoint.Name != NEW) && (endpoint.Name != TEMP)) { MetaTemplate_UserSettings.Last_Z3950_Endpoint = endpoint.Name; MetaTemplate_UserSettings.Save(); } string identifier = identifierTextBox.Text.Trim(); string out_message = String.Empty; MARC_Record record_from_z3950 = MARC_Record_Z3950_Retriever.Get_Record_By_Primary_Identifier(identifier, endpoint, out out_message); if (record_from_z3950 == null) { if (out_message.Length > 0) { MessageBox.Show(out_message, "Error Encountered", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("Unknown error occurred during request", "Error Encountered", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { //MessageBox.Show("Found!!\n\n" + record_from_z3950.To_Machine_Readable_Record()); Record = record_from_z3950; } Close(); }
private void round_Button2_Button_Pressed(object sender, EventArgs e) { if ((locationTextBox.Text.Trim().Length == 0) || (!File.Exists(locationTextBox.Text.Trim()))) { MessageBox.Show("Select the ImageMagick executable file 'convert.exe' before continuing. ", "Information Missing", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } DialogResult = DialogResult.OK; MetaTemplate_UserSettings.ImageMagick_Executable = locationTextBox.Text; MetaTemplate_UserSettings.Save(); Close(); }
private void refresh_endpoints() { listView1.Items.Clear(); ReadOnlyCollection <string> endpoints = MetaTemplate_UserSettings.Z3950_Endpoint_Names; foreach (string thisEndpointName in endpoints) { Z3950_Endpoint thisEndpoint = MetaTemplate_UserSettings.Get_Endpoint_By_Name(thisEndpointName); ListViewItem newItem = new ListViewItem(new[] { thisEndpointName, thisEndpoint.URI, thisEndpoint.Port.ToString(), thisEndpoint.Database_Name }); listView1.Items.Add(newItem); } deleteButton.Button_Enabled = false; editButton.Button_Enabled = false; }
private void downloadUrlButton_Button_Pressed(object sender, EventArgs e) { // Also, set the setting from the checkbox if (alwaysCheckBox.Checked) { // Set the user settings to always include non-page image files MetaTemplate_UserSettings.Always_Add_NonPage_Files = true; MetaTemplate_UserSettings.Save(); // Show a message box MessageBox.Show("Non-page image files will now be automatically added to new resources. \n\nYou can change this option in the Metadata Preferences at any time.\n\nMain menu: Actions --> Metadata Preferences --> Resource Files.", "Preference Applied", MessageBoxButtons.OK, MessageBoxIcon.Information); } // Close this form Close(); }
private void yesButton_Button_Pressed(object sender, EventArgs e) { // Set the dialog result DialogResult = DialogResult.Yes; // Also, set the setting from the checkbox if (alwaysCheckBox.Checked) { // Set the user settings correspondingly MetaTemplate_UserSettings.Always_Add_Page_Images = true; MetaTemplate_UserSettings.Save(); // Show a message box MessageBox.Show("Page images will now be automatically added to new resources. \n\nYou can change this option in the Metadata Preferences at any time.\n\nMain menu: Actions --> Metadata Preferences --> Resource Files.", "Preference Applied", MessageBoxButtons.OK, MessageBoxIcon.Information); } // Close this form Close(); }
private void endpointComboBox_SelectedIndexChanged(object sender, EventArgs e) { if ((endpointComboBox.Text != NEW) && (endpointComboBox.Text != TEMP)) { endpoint = MetaTemplate_UserSettings.Get_Endpoint_By_Name(endpointComboBox.Text); if (endpoint == null) { endpointComboBox.Text = NEW; } } else if (endpointComboBox.Text == TEMP) { endpoint = temporaryEndpoint; } else if (endpointComboBox.Text == NEW) { endpoint = null; } }
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(); }
private void saveButton_Button_Pressed(object sender, EventArgs e) { try { MetaTemplate_UserSettings.ImageDeriv_Create_JPEG2000 = jp2CheckBox.Checked; if (jpegCheckBox.Checked) { int new_height = Convert.ToInt32(heightTextBox.Text); int new_width = Convert.ToInt32(widthTextBox.Text); if ((new_height > 0) && (new_width > 0)) { MetaTemplate_UserSettings.ImageDeriv_Height = new_height; MetaTemplate_UserSettings.ImageDeriv_Width = new_width; MetaTemplate_UserSettings.ImageDeriv_Create_JPEG = jpegCheckBox.Checked; } } else { MetaTemplate_UserSettings.ImageDeriv_Create_JPEG = jpegCheckBox.Checked; } int thumb_height = -1; int thumb_width = -1; if (thumbnailCheckBox.Checked) { thumb_height = Convert.ToInt32(thumbHeightTextBox.Text); thumb_width = Convert.ToInt32(thumbWidthTextBox.Text); if ((thumb_height > 0) && (thumb_width > 0)) { MetaTemplate_UserSettings.ImageDeriv_Thumbnail_Height = thumb_height; MetaTemplate_UserSettings.ImageDeriv_Thumbnail_Width = thumb_width; MetaTemplate_UserSettings.ImageDeriv_Create_Thumbnail = thumbnailCheckBox.Checked; } } else { MetaTemplate_UserSettings.ImageDeriv_Create_Thumbnail = thumbnailCheckBox.Checked; } MetaTemplate_UserSettings.Save(); // Check that ImageMagick exists if ((MetaTemplate_UserSettings.ImageMagick_Executable.Length == 0) || (!File.Exists(MetaTemplate_UserSettings.ImageMagick_Executable))) { ImageMagick_Location_Form findImageMagick = new ImageMagick_Location_Form(); if (findImageMagick.ShowDialog() != DialogResult.OK) { return; } } if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) { // Create the new processor Multiple_Folders_Processor processor = new Multiple_Folders_Processor(MetaTemplate_UserSettings.ImageDeriv_Create_JPEG, MetaTemplate_UserSettings.ImageDeriv_Create_JPEG2000, MetaTemplate_UserSettings.ImageDeriv_Width, MetaTemplate_UserSettings.ImageDeriv_Height, folderBrowserDialog1.SelectedPath, thumb_width, thumb_height); processor.New_Task_String += processor_New_Task_String; processor.New_Volume_String += processor_New_Volume_String; processor.New_Progress += processor_New_Progress; processor.Process_Complete += processor_Process_Complete; // Create the processor thread processorThread = new Thread(processor.Process); processorThread.Start(); } } catch { MessageBox.Show("Invalid entries for either width or height"); } }
static void Main(string[] args) { // Set the Gembox spreadsheet license key // SpreadsheetInfo.SetLicense("YOUR-CODE-HERE"); // Currently set this flag to false Control.CheckForIllegalCrossThreadCalls = false; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // Set some colors // Set some defaults for round buttons Round_Button.Inactive_Border_Color = Color.DarkGray; Round_Button.Inactive_Text_Color = Color.White; Round_Button.Inactive_Fill_Color = Color.DarkGray; Round_Button.Mouse_Down_Border_Color = Color.Gray; Round_Button.Mouse_Down_Text_Color = Color.White; Round_Button.Mouse_Down_Fill_Color = Color.Gray; Round_Button.Active_Border_Color = Color.FromArgb(25, 68, 141); Round_Button.Active_Fill_Color = Color.FromArgb(25, 68, 141); Round_Button.Active_Text_Color = Color.White; // If this was the first launch, show that form if (MetaTemplate_UserSettings.First_Launch) { // Show the welcome screen first First_Launch_Welcome welcomeForm = new First_Launch_Welcome(); if (welcomeForm.ShowDialog() == DialogResult.Cancel) { return; } int step = 0; while (step < 6) { switch (step) { case 0: // Get general use first First_Launch_Form1 firstForm = new First_Launch_Form1(); if (firstForm.ShowDialog() == DialogResult.Cancel) { return; } else { step++; } break; case 1: // Show options for the basic bibliographic metadata options First_Launch_Form2 secondForm = new First_Launch_Form2(); if (secondForm.ShowDialog() == DialogResult.Cancel) { step--; } else { step++; } break; case 2: // Show the basic template choices First_Launch_Form3 thirdForm = new First_Launch_Form3(); if (thirdForm.ShowDialog() == DialogResult.Cancel) { step--; } else { step++; } break; case 3: // Show options for any additional add-ons to the template First_Launch_Form4 fourthForm = new First_Launch_Form4(); if (fourthForm.ShowDialog() == DialogResult.Cancel) { step--; } else { if (MetaTemplate_UserSettings.AddOns_Enabled.Contains("FCLA")) { First_Launch_FDA_Constants fdaConstants = new First_Launch_FDA_Constants(); if (fdaConstants.ShowDialog() == DialogResult.Cancel) { step--; } } if ((step == 3) && (MetaTemplate_UserSettings.AddOns_Enabled.Contains("SOBEKCM"))) { First_Launch_SobekCM_Constants fdaConstants = new First_Launch_SobekCM_Constants(); if (fdaConstants.ShowDialog() == DialogResult.Cancel) { step--; } } step++; } break; case 4: // Show file options ( checksums, auto-include, etc.. ) First_Launch_Form5 fifthForm = new First_Launch_Form5(); if (fifthForm.ShowDialog() == DialogResult.Cancel) { step--; } else { step++; } break; case 5: // Show localization options First_Launch_Form6 sixthForm = new First_Launch_Form6(); if (sixthForm.ShowDialog() == DialogResult.Cancel) { step--; } else { // Save the set values MetaTemplate_UserSettings.Save(); step++; } break; } } } // Check version if ((Application.StartupPath.ToUpper().IndexOf("TOOLKIT") < 0) && ((!MetaTemplate_UserSettings.Perform_Version_Check_On_StartUp) || (Check_Version()))) { // Delete anything remaining in the temporary folder from a previous run string documents_folder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); string temp_folder = documents_folder + "\\METS Editor\\Temporary"; // If there is a temporary folder, delete all items if (Directory.Exists(temp_folder)) { string[] files = Directory.GetFiles(temp_folder); foreach (string thisFile in files) { try { File.Delete(thisFile); } catch { break; } } } // Make sure the TEMPLATES subdirectory exists if (!Directory.Exists(Application.StartupPath + "\\Templates")) { Directory.CreateDirectory(Application.StartupPath + "\\Templates"); } // Make sure the PROJECTS subdirectory exists if (!Directory.Exists(Application.StartupPath + "\\Projects")) { Directory.CreateDirectory(Application.StartupPath + "\\Projects"); } // Configure the metadata Metadata_Profile_Configurer.Configure_Metadata_From_UserSettings(); // Get the template and METS file from the argument list string template_file = Application.StartupPath + "\\Templates\\" + MetaTemplate_UserSettings.Default_Template + ".xml"; string mets_file = String.Empty; string save_directory = App_Config_Reader.METS_Save_Location; // Set the readonly attribute bool read_only = false; bool exclude_divisions = false; if ((args.Length > 0) && (args[0].ToUpper() == "TRUE")) { read_only = true; } // Get name of the template and METS file from the arguments foreach (string thisArgs in args) { // For backward compatability if (thisArgs == "TRUE") { read_only = true; } // Check for readonly flag if (thisArgs == "--readonly") { read_only = true; } // Check for no divisions if (thisArgs == "--nodiv") { exclude_divisions = true; } // Check for template name if (thisArgs.ToUpper().IndexOf(".MMT") >= 0) { template_file = thisArgs; } // Check for METS file if ((thisArgs.ToUpper().IndexOf(".METS") >= 0) || (thisArgs.ToUpper().IndexOf(".PMETS") >= 0)) { mets_file = thisArgs; if (mets_file.IndexOf("http:") < 0) { save_directory = (new FileInfo(mets_file)).Directory.FullName; } else { save_directory = App_Config_Reader.METS_Save_Location; } } } // If the template does not exist, throw a message if ((template_file.Length == 0) || (!File.Exists(template_file))) { MessageBox.Show("ERROR! No template file to load or template does not exist. ", "Template Error", MessageBoxButtons.OK, MessageBoxIcon.Error); // Look for the user's default template if (File.Exists(Application.StartupPath + "\\Templates\\" + MetaTemplate_UserSettings.Default_Template)) { template_file = Application.StartupPath + "\\Templates\\" + MetaTemplate_UserSettings.Default_Template; } else { // Look for the default template if (File.Exists(Application.StartupPath + "\\Templates\\default.mmt")) { template_file = Application.StartupPath + "\\Templates\\default.mmt"; MetaTemplate_UserSettings.Default_Template = (new FileInfo(template_file)).Name; MetaTemplate_UserSettings.Save(); } else { // Look for ANY template string[] templates = Directory.GetFiles(Application.StartupPath + "\\Templates\\", "*.mmt"); if (templates.Length > 0) { template_file = templates[0]; MetaTemplate_UserSettings.Default_Template = (new FileInfo(template_file)).Name; MetaTemplate_UserSettings.Save(); } else { // Create the default template Template_Creator.Create(Application.StartupPath + "\\Templates\\default.mmt"); template_file = Application.StartupPath + "\\Templates\\default.mmt"; MetaTemplate_UserSettings.Default_Template = (new FileInfo(template_file)).Name; MetaTemplate_UserSettings.Save(); } } } } // If the template does not exist, throw a message if ((template_file.Length == 0) || (!File.Exists(template_file))) { MessageBox.Show("ERROR! No template file to load or template does not exist. ", "Template Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { try { // Create the template form to display this Template_Form templateForm = new Template_Form(mets_file, save_directory, exclude_divisions); templateForm.ShowDialog(); } catch (Exception ee) { ErrorMessageBox.Show("An unexpected error occurred in the application.\n\nPlease report this issue to Mark Sullivan ([email protected]).", "Unexpected Error", ee); } } } }
private void continueButton_Button_Pressed(object sender, EventArgs e) { if ((parentDirTextBox.Text.Trim().Length == 0) || (!Directory.Exists(parentDirTextBox.Text.Trim()))) { MessageBox.Show("Enter a valid directory to recurse through all subdirectories recursively. ", "Invalid Entry", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if ((Directory.GetDirectories(parentDirTextBox.Text.Trim()).Length == 0) && (Directory.GetFiles(parentDirTextBox.Text.Trim()).Length == 0)) { MessageBox.Show("Parent directory has no subdirectories and no files! ", "Invalid Entry", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (metadataFilterComboBox.Text.Trim().Length == 0) { MessageBox.Show("You must enter a filter for the metadata file names. \n\nExamples: '*.mets.xml', '*.xml', '*.mods', etc.. ", "Invalid File Filter", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string bibid_start = String.Empty; int first_bibid_int = -1; if (objectIdFileNameRadioButton.Checked) { first_bibid_int = -2; } if (objectIdNewRadioButton.Checked) { string first_bibid = firstBibIdTextBox.Text.Trim(); if (first_bibid.Length < 3) { MessageBox.Show("You must enter a constant for the 'First BibID' value and it must begin with two letters. \n\nThis is the first ObjectID that will be used for the resulting METS files. ", "Choose First BibID", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (first_bibid.Length > 10) { MessageBox.Show("The complete BibID/ObjectID cannot be longer than 10 digits. ", "Invalid First BibID", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // Pad the bibid to 10 digits, in case it is not 10 first_bibid = first_bibid.PadRight(10, '0'); // First two must be characters if ((!Char.IsLetter(first_bibid[0])) || (!Char.IsLetter(first_bibid[1]))) { MessageBox.Show("You must enter a constant for the 'First BibID' value and it must begin with two letters. \n\nThis is the first ObjectID that will be used for the resulting METS files. ", "Choose First BibID", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // Check that it ends in numbers if ((!Char.IsNumber(first_bibid[9])) || (!Char.IsNumber(first_bibid[8])) || (!Char.IsNumber(first_bibid[7])) || (!Char.IsNumber(first_bibid[6]))) { MessageBox.Show("The last four digits of the BibID must be numeric. \n\nTry shortening the length or changing trailing characters to numers. ", "Invalid First BibID", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // Try to break the first_bibid up into character portion and number portion int numbers_start = 9; for (int i = 9; i >= 0; i--) { if (!Char.IsNumber(first_bibid[i])) { numbers_start = i + 1; break; } } bibid_start = first_bibid.Substring(0, numbers_start); first_bibid_int = Convert.ToInt32(first_bibid.Substring(numbers_start)); } string filter = metadataFilterComboBox.Text.Trim(); string directory = parentDirTextBox.Text.Trim(); string metadata_type = metadataComboBox.Text.Trim().ToUpper(); parentDirTextBox.Enabled = false; metadataComboBox.Enabled = false; metadataFilterComboBox.Enabled = false; browseButton.Enabled = false; objectIdFolderNameRadioButton.Enabled = false; objectIdFileNameRadioButton.Enabled = false; firstBibIdTextBox.Enabled = false; objectIdNewRadioButton.Enabled = false; // Also, save these settings for next time MetaTemplate_UserSettings.Directory_Batching_Metadata_Filter = metadataFilterComboBox.Text; MetaTemplate_UserSettings.Directory_Batching_Metadata_Type_Index = metadataComboBox.SelectedIndex; if ((objectIdNewRadioButton.Checked) || (objectIdFolderNameRadioButton.Checked)) { if (objectIdFolderNameRadioButton.Checked) { MetaTemplate_UserSettings.Directory_Batching_METS_ObjectID_Index = 1; } else { MetaTemplate_UserSettings.Directory_Batching_METS_ObjectID_Index = 2; } } else { MetaTemplate_UserSettings.Directory_Batching_METS_ObjectID_Index = 0; } MetaTemplate_UserSettings.Save(); Size = new Size(628, 490); Cursor = Cursors.WaitCursor; try { // Create the Processor and assign the Delegate method for event processing. Batch_Directory_Processor processor = new Batch_Directory_Processor(filter, directory, metadata_type, bibid_start, first_bibid_int); processor.New_Progress += processor_New_Progress; processor.Complete += processor_Complete; processor.New_Folder += processor_New_Folder; // Create the thread to do the processing work, and start it. processThread = new Thread(processor.Do_Work); processThread.SetApartmentState(ApartmentState.STA); processThread.Start(); } catch (Exception ee) { // display the error message ErrorMessageBox.Show("Error encountered while processing!\n\n" + ee.Message, "METS Editor - Directory Batch Error", ee); Close(); } }