예제 #1
0
        private void buttonReplyAdd_Click(object sender, EventArgs e)
        {
            try
            {
                using (frmAdd form = new frmAdd())
                {
                    if (form.ShowDialog(this) != DialogResult.OK)
                        return;

                    if (form.Keyword != "" && form.Reply != "")
                    {
                        XElement node = new XElement("Operator",
                            new XElement("Keyword", form.Keyword),
                            new XElement("Reply", form.Reply)
                        );

                        XElement root = File.Exists(so_ConfigPath) ? XElement.Load(so_ConfigPath) : new XElement("Skype");
                        root.Add(node);
                        root.Save(so_ConfigPath);
                    }
                }

                RefreshItems();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #2
0
        private void listViewReply_ItemActivate(object sender, EventArgs e)
        {
            if ((sender as ListView).SelectedItems.Count == 0)
                return;

            try
            {
                int index = (sender as ListView).SelectedItems[0].Index;

                string keyword = (sender as ListView).SelectedItems[0].Text;
                string reply = (sender as ListView).SelectedItems[0].SubItems[1].Text;

                using (frmAdd form = new frmAdd(keyword, reply))
                {
                    if (form.ShowDialog(this) != DialogResult.OK)
                        return;

                    XElement root = XElement.Load(so_ConfigPath);
                    var node = root.Elements("Operator").ElementAt(index);
                    node.SetElementValue("Keyword", form.Keyword);
                    node.SetElementValue("Reply", form.Reply);
                    root.Save(so_ConfigPath);
                }

                RefreshItems();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Save failed\n\r" + ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }