/// <summary> /// Adds the schema namespaces to the list. /// </summary> void PopulateSchemaListBox() { foreach (XmlSchemaCompletionData schema in XmlSchemaManager.SchemaCompletionDataItems) { XmlSchemaListBoxItem item = new XmlSchemaListBoxItem(schema.NamespaceUri, schema.ReadOnly); schemaListBox.Items.Add(item); } }
void RemoveButtonClick(object source, EventArgs e) { // Remove selected schema. XmlSchemaListBoxItem item = schemaListBox.SelectedItem as XmlSchemaListBoxItem; if (item != null) { RemoveSchema(item.NamespaceUri); changed = true; } }
/// <summary> /// Returns an array of schema namespace strings that will be displayed /// when the user chooses to associated a namespace to a file extension /// by default. /// </summary> string[] GetSchemaListBoxNamespaces() { string[] namespaces = new string[schemaListBox.Items.Count]; for (int i = 0; i < schemaListBox.Items.Count; ++i) { XmlSchemaListBoxItem item = (XmlSchemaListBoxItem)schemaListBox.Items[i]; namespaces[i] = item.NamespaceUri; } return(namespaces); }
/// <summary> /// Enables the remove button if a list box item is selected. /// </summary> void SchemaListBoxSelectedIndexChanged(object source, EventArgs e) { XmlSchemaListBoxItem item = schemaListBox.SelectedItem as XmlSchemaListBoxItem; if (item != null) { if (item.ReadOnly) { removeButton.Enabled = false; } else { removeButton.Enabled = true; } } else { removeButton.Enabled = false; } }
/// <summary> /// Draws the list box items so we can show the read only schemas in /// a different colour. /// </summary> void SchemaListBoxDrawItem(object sender, DrawItemEventArgs e) { e.DrawBackground(); if (e.Index >= 0) { XmlSchemaListBoxItem item = (XmlSchemaListBoxItem)schemaListBox.Items[e.Index]; if (IsListBoxItemSelected(e.State)) { e.Graphics.DrawString(item.NamespaceUri, schemaListBox.Font, selectedTextBrush, e.Bounds); } else if (item.ReadOnly) { e.Graphics.DrawString(item.NamespaceUri, schemaListBox.Font, readonlyTextBrush, e.Bounds); } else { e.Graphics.DrawString(item.NamespaceUri, schemaListBox.Font, normalTextBrush, e.Bounds); } } e.DrawFocusRectangle(); }
/// <summary> /// Adds the schema namespaces to the list. /// </summary> void PopulateSchemaListBox() { foreach (XmlSchemaCompletionData schema in XmlSchemaManager.SchemaCompletionDataItems) { XmlSchemaListBoxItem item = new XmlSchemaListBoxItem(schema.NamespaceUri, schema.ReadOnly); schemaListBox.Items.Add(item); } }