private void btnSave_Click(object sender, EventArgs e) { SaveFileDialog file = new SaveFileDialog(); file.Filter = "XML File |*.xml"; if (file.ShowDialog() == DialogResult.OK) { XmlSerializer ser = new XmlSerializer(typeof(ActionsEntry)); ActionsEntry tmpAction = new ActionsEntry(); List <ActionsEntryAction> tmpActionsEntryActions = new List <ActionsEntryAction>(); foreach (ListViewItem lvi in lvActions.Items) { ActionEntry tmpActionEntry = lvi.Tag as ActionEntry; ActionsEntryAction tmpActionsEntryAction = new ActionsEntryAction(); tmpActionsEntryAction.X = tmpActionEntry.X; tmpActionsEntryAction.Y = tmpActionEntry.Y; tmpActionsEntryAction.Text = tmpActionEntry.Text; tmpActionsEntryAction.interval = tmpActionEntry.Interval; tmpActionsEntryAction.Type = (int)tmpActionEntry.Type; tmpActionsEntryActions.Add(tmpActionsEntryAction); } tmpAction.Action = tmpActionsEntryActions.ToArray(); using (XmlWriter writer = XmlWriter.Create(file.FileName)) { ser.Serialize(writer, tmpAction); } } }
private void btnSave_Click(object sender, EventArgs e) { SaveFileDialog file = new SaveFileDialog(); file.Filter = "XML File |*.xml"; if (file.ShowDialog() == DialogResult.OK) { XmlSerializer ser = new XmlSerializer(typeof(ActionsEntry)); ActionsEntry tmpAction = new ActionsEntry(); List<ActionsEntryAction> tmpActionsEntryActions = new List<ActionsEntryAction>(); foreach (ListViewItem lvi in lvActions.Items) { ActionEntry tmpActionEntry = lvi.Tag as ActionEntry; ActionsEntryAction tmpActionsEntryAction = new ActionsEntryAction(); tmpActionsEntryAction.X = tmpActionEntry.X; tmpActionsEntryAction.Y = tmpActionEntry.Y; tmpActionsEntryAction.Text = tmpActionEntry.Text; tmpActionsEntryAction.interval = tmpActionEntry.Interval; tmpActionsEntryAction.Type = (int)tmpActionEntry.Type; tmpActionsEntryActions.Add(tmpActionsEntryAction); } tmpAction.Action = tmpActionsEntryActions.ToArray(); using (XmlWriter writer = XmlWriter.Create(file.FileName)) { ser.Serialize(writer, tmpAction); } } }