Exemplo n.º 1
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            m_theTool.SetName(txtName.Text);
            m_theTool.SetCommand(txtCommand.Text);
            m_theTool.SetCmdLine(txtParams.Text);

            string icon = txtIconFileName.Text;

            if (icon.IndexOf(Application.StartupPath + "\\icons") == 0)
            {
                icon = icon.Replace(Application.StartupPath + "\\icons", ".\\icons");
            }

            m_theTool.SetIconFileName(icon);

            this.DialogResult = DialogResult.OK;
            Close();
        }
Exemplo n.º 2
0
        void ModifyToolToolStripMenuItemClick(object sender, EventArgs e)
        {
            if (listView1.SelectedItems.Count > 0)
            {
                ListViewItem i = listView1.SelectedItems[0];

                if (i != null)
                {
                    WOL2Tool    nt  = new WOL2Tool(i.Text, i.SubItems[1].Text, i.SubItems[2].Text, i.ImageKey);
                    DlgEditTool dlg = new DlgEditTool(nt);

                    if (dlg.ShowDialog(this) == DialogResult.OK &&
                        nt.IsValid())
                    {
                        i.SubItems[0].Text = nt.GetName();
                        i.SubItems[1].Text = nt.GetCommand();
                        i.SubItems[2].Text = nt.GetCmdLine();

                        // Load the icon
                        string icon = nt.GetIconFileName();
                        i.ImageKey = nt.GetIconFileName();

                        if (icon != null && File.Exists(icon))
                        {
                            if (!imgLstTools.Images.ContainsKey(icon))
                            {
                                imgLstTools.Images.Add(icon, Image.FromFile(icon));
                            }
                            i.ImageKey = icon;
                        }

                        WOL2Tool t = (WOL2Tool)i.Tag;
                        if (t != null)
                        {
                            t.SetName(nt.GetName());
                            t.SetCommand(nt.GetCommand());
                            t.SetCmdLine(nt.GetCmdLine());
                            t.SetIconFileName(nt.GetIconFileName());
                        }
                    }
                }
            }
        }