writer.WriteStartAttribute ( pair_count );
writer.WriteEndAttribute ();
writer.WriteEndElement ();
writer.Close ();
}
XmlDocument document=new XmlDocument ();
document.Load (XMLPATH);
XmlElement pair=document.CreateElement ( pair );
XmlAttribute pair_id=document.CreateAttribute ( id );
int last_child_id=0;
try
{
int.TryParse (document.DocumentElement.LastChild.Attributes [ id ]. Value, out last_child_id);
}
catch (NullReferenceException)
{
last_child_id=0;
}
catch (Exception) {}
pair_id.Value=(last_child_id + 1) .ToString ();
pair.Attributes.Append (pair_id);
XmlElement key=document.CreateElement ( key );
key.InnerText=add_key;
pair.AppendChild (key);
XmlElement value=document.CreateElement ( value );
value.InnerText=add_value;
pair.AppendChild (value);
document.DocumentElement.AppendChild (pair);
if (document.DocumentElement.HasChildNodes)
document.DocumentElement.Attributes [ pair_count ]. Value=document.DocumentElement.ChildNodes.Count.ToString ();
document.Save (XMLPATH);
return Стаття успішно додана raquo ;;
}
public main_form ()
{
InitializeComponent ();
listbox.Size=new Size (search_text.Width, 0);
listbox.Margin=new System.Windows.Forms.Padding (0, 0, 0, 0);
listbox.Font=search_text.Font;
listbox.Parent=listbox_panel;
listbox_panel.Hide ();
SEARCH_BOX_DEFTEXT=search_text.Text;
MAINFORM_HEAD_TEXT=this.Text;
}
private void main_form_Load (object sender, EventArgs e)
{
listbox.MouseClick +=new MouseEventHandler (listbox_MouseClick);
allNodes_toolStripDropDownButton.Enabled=false;
allNodes_toolStripDropDownButton.DropDownItems.Clear ();
}
#region Події MenuStrip
//********************************************* *****************************
private void виходToolStripMenuItem_Click (object sender, EventArgs e)
{
Application.Exit ();
}
private void оПрограммеToolStripMenuItem_Click (object sender, EventArgs e)
{
about_form_RamGec about=new about_form_RamGec ();
about.ShowDialog ();
}
private void добавітьстатьюToolStripMenuItem_Click (object sender, EventArgs e)
{
if (XMLPATH == )
{
OpenFileDialog file_path=new OpenFileDialog ();
file_path.Filter= XML-документ (* .xml) | * .xml raquo ;;
if (file_path.ShowDialog () == System.Windows.Forms.DialogResult.OK)
{
XMLPATH=file_path.FileName;
LoadXML (file_path.FileName);
GetAllNodes (allNodes_toolStripDropDownButton);
}
else
{
MessageBox.Show (
this,
Необхідно вказати шлях до XML-файлу. ,
Попередження ,
MessageBoxButtons.OK,
MessageBoxIcon.Exclamation
);
return;
}
}
add_form add=new add_form ();
if (add.ShowDialog () == System.Windows.Forms.DialogResult.OK)
{
GetAllNodes (allNodes_toolStripDropDownButton);
}
}
private void сохранітьXMLToolStripMenuItem_Click (object sender, EventArgs e)
{
SaveFileDialog save_path=new SaveFileDialog ();
save_path.AddExtension=true;
save_path.DefaultExt= xml raquo ;;
save_path.Filter= XML-документ (* .xml) | * .xml raquo ;;
if (save_path.ShowDialog () == System.Windows.Forms.DialogResult.OK)
{
XMLPATH=save_path.FileName;
SaveXML (save_path.FileName);
this.Text=MAINFORM_HEAD_TEXT + - Raquo; + Save_path.FileName.Remove (0, save_path.FileName.LastIndexOf ('') + 1);
}
}
private void загрузітьІзXMLToolStripMenuItem_Click (object sender, EventArgs e)
{
OpenFileDialog file_path=new OpenFileDialog ();
file_path.Filter= XML-документ (* .xml) | * .xml raquo ;;
if (file_path.ShowDialog () == System.Windows.Forms.DialogResult.OK)
{
XMLPATH=file_path.FileName;
LoadXML (file_path.FileName);
GetAllNodes (allNodes_toolStripDropDownButton);
this.Text=MAINFORM_HEAD_TEXT + - Raquo; + File_path.SafeFileName;
}
}
private void очістітьХештабліцуToolStripMenuItem_Click (object sender, EventArgs e)
{
HASH.Clear ();
if (! sear...