private void btnClose_Click(object sender, EventArgs e) { if (editModeEnabled) { try { bool cancelEdit = true; if (dirtyUI) { DialogResult dialogResult = MessageBox.Show(this, "Do you want to cancel and discard changes?", "EQUELLA Metadata Utility", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); if (dialogResult == DialogResult.No) { cancelEdit = false; } } if (cancelEdit) { this.Cursor = Cursors.WaitCursor; // cancel item edit and reload XML equellaClient.cancelItemEdit(itemID, itemVersion); RefreshXML(true); dirtyUI = false; equellaClient.logout(); // reset form to read-only mode this.Text = "Viewing " + itemID + "/" + itemVersion.ToString(); fctbItemXml.ReadOnly = true; fctbItemXml.AcceptsTab = false; btnEditSave.Text = "Edit"; btnClose.Text = "Close"; editModeEnabled = false; btnRefresh.Enabled = true; btnGoDown.Enabled = true; btnGoUp.Enabled = true; this.Enabled = true; toolStripViewXml.BackColor = SystemColors.Control; chkHideSystemMetadata.BackColor = toolStripViewXml.BackColor; this.Cursor = Cursors.Arrow; } } catch (Exception err) { this.Cursor = Cursors.Arrow; MessageBox.Show(err.Message, "Error on cancel", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { this.Close(); } }
private void Collections_Load(object sender, EventArgs e) { try { this.Cursor = Cursors.WaitCursor; XmlDocument xmlCollections = new XmlDocument(); // get list of contributable collections xmlCollections.LoadXml(equellaClient.getContributableCollections()); int contributableCollectionsCount = xmlCollections.ChildNodes[0].ChildNodes.Count; for (int i = 0; i < contributableCollectionsCount; i++) { // CollectionItem collectionItem = new CollectionItem(xmlCollections.ChildNodes[0].ChildNodes[i].SelectSingleNode("id").InnerXml, xmlCollections.ChildNodes[0].ChildNodes[i].SelectSingleNode("name").InnerXml); lstCollections.Items.Add(xmlCollections.ChildNodes[0].ChildNodes[i].SelectSingleNode("name").InnerXml); } equellaClient.logout(); this.Cursor = Cursors.Arrow; } catch (Exception err) { this.Cursor = Cursors.Arrow; MessageBox.Show(err.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void RefreshXML(bool refreshFromServer) { int cursorPos = getLineNumberOfCaret(); int selectionStart = fctbItemXml.SelectionStart; if (refreshFromServer) { try { mainForm.login(); equellaClient = mainForm.equellaClient; string unindentedItemXML = equellaClient.getItem(itemID, itemVersion, ""); equellaClient.logout(); // load the filtered and unfiltered XML itemXMLDoc.LoadXml(unindentedItemXML); updateFilteredXmlfromUnfiltered(true); } catch (Exception err) { MessageBox.Show(err.Message, "Error retrieving item", MessageBoxButtons.OK, MessageBoxIcon.Error); } } StringWriter sw = new StringWriter(); XmlTextWriter xw = new XmlTextWriter(sw); xw.Formatting = Formatting.Indented; if (chkHideSystemMetadata.Checked) { itemXMLFilteredDoc.WriteTo(xw); } else { itemXMLDoc.WriteTo(xw); } string indentedItemXMLString = sw.ToString(); fctbItemXml.Text = indentedItemXMLString; fctbItemXml.SelectionStart = cursorPos; fctbItemXml.Navigate(cursorPos); fctbItemXml.SelectionStart = selectionStart; }