private void btn_OK_Click(object sender, EventArgs e)
        {
            // Get all information in textbox
            string belongDevice = textBox1.Text;
            string programName  = textBox2.Text;
            string programPath  = textBox3.Text;
            string programArgs  = textBox4.Text;

            if (programName != "" && DataValidator.IsFilePath(programPath))
            {
                if (!XMLOperator.isProgramExists(belongDevice, programName))
                {
                    Bases.Program tempProgram = new Bases.Program(programName, programPath, programArgs, belongDevice);

                    XMLOperator.WriteProgram(tempProgram);
                }
                else
                {
                    MessageBox.Show("该程序已存在", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else
            {
                MessageBox.Show("输入信息不合法", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Exemple #2
0
        /// <summary>
        /// 构造将要发送的URL
        /// </summary>
        /// <param name="config">启动配置</param>
        /// <param name="device">程序所属的设备</param>
        /// <param name="program">选中的程序</param>
        /// <returns>URL</returns>
        private string generateURL(Configs config, Device device, Bases.Program program)
        {
            string result = "";
            string host   = "http://" + XMLOperator.GetHost() + "/PsExecProject/index.php";

            result  = host + "?r=" + device.DeviceIP + "&u=" + device.DeviceUser + "&p=" + device.DevicePwd;
            result += config.IsGUI ? "&i=1" : "&i=0";
            result += config.IsWait ? "&w=1" : "&w=0";
            result += config.IsSystem ? "&s=1" : "&s=0";
            result += "&e=" + HttpUtility.UrlEncode(program.Path) + "&args=" + HttpUtility.UrlEncode(program.Args);

            return(result);
        }
Exemple #3
0
        /// <summary>
        /// 第一次启动时添加xml地初始数据(弃用)
        /// </summary>
        private void GenerateInfo()
        {
            Configs myConfig = new Configs(true, false, true);
            Device  myDevice = new Device("Default Device", "192.168.1.118", "Learun", "116219");

            Bases.Program program1 = new Bases.Program("InternetExporer", "C:\\\\Program Files (x86)\\\\Internet Explorer\\\\iexplore.exe", "http://www.baidu.com", "Default Device");
            Bases.Program program2 = new Bases.Program("Media Player", "C:\\\\Program Files (x86)\\\\Windows Media PLayer\\\\wmplayer.exe", "C:\\\\Users\\\\Learun\\\\Documents\\\\Scrats.mp4", "Default Device");

            XMLOperator.WriteConfig(myConfig);
            XMLOperator.WriteDevice(myDevice);
            try
            {
                XMLOperator.WriteProgram(program1);
                XMLOperator.WriteProgram(program2);
            }catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Exemple #4
0
        private void refreshProgram(string deviceName, string programName)
        {
            // Set program groupbox's visibility to true, the other one is false.
            groupBox2.Visible = true;
            groupBox1.Visible = false;

            // Refresh Program's information
            Bases.Program tempProgram = XMLOperator.GetProgram(deviceName, programName);
            mCurProgram = tempProgram;
            try
            {
                textBox5.Text = tempProgram.Name;
                textBox6.Text = tempProgram.Path;
                textBox7.Text = tempProgram.Args;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
        /// <summary>
        /// 为程序列表绑定数据
        /// </summary>
        private void BindTreeView()
        {
            treeCombo.TreeView.LabelEdit = false;

            TreeNode root = new TreeNode();

            root.Tag  = "Root";
            root.Text = "我的程序";

            // 添加设备以及相关程序信息
            // 添加第一级节点(设备节点)
            //      添加第二级节点(程序节点)
            // 注意Count和Capacity的不同
            devices = XMLOperator.GetDevices();
            for (int i = 0; i < devices.Count; i++)
            {
                TreeNode curBranch = new TreeNode();
                Device   curDevice = devices[i];
                curBranch.Text = curDevice.DeviceName;
                curBranch.Tag  = "Device";
                programs       = XMLOperator.GetPrograms(curDevice.DeviceName);
                for (int j = 0; j < programs.Count; j++)
                {
                    TreeNode      pLeaf      = new TreeNode();
                    Bases.Program curProgram = programs[j];
                    pLeaf.Text = curProgram.Name;
                    pLeaf.Tag  = "Program";
                    curBranch.Nodes.Add(pLeaf);
                }
                root.Nodes.Add(curBranch);
                programs.Clear();
            }

            treeCombo.TreeView.Nodes.Add(root);
            this.Controls.Add(treeCombo);
        }
 public EditProgramForm()
 {
     InitializeComponent();
     mProgram = MainForm.Instance.CurProgram;
 }
Exemple #7
0
        /// <summary>
        /// 为TreeView绑定数据源
        /// </summary>
        private void BindTreeView()
        {
            // Cannot Edit
            treeView1.LabelEdit = false;

            // 添加根节点
            TreeNode root = new TreeNode();

            root.Text = "我的程序";
            root.Tag  = "Root";
            TreeNode root2 = new TreeNode();

            root2.Text = "我的分组";
            root2.Tag  = "GroupRoot";

            // 添加设备以及相关程序信息
            // 添加第一级节点(设备节点)
            //      添加第二级节点(程序节点)
            // 注意Count和Capacity的不同
            devices = XMLOperator.GetDevices();
            for (int i = 0; i < devices.Count; i++)
            {
                TreeNode curBranch = new TreeNode();
                Device   curDevice = devices[i];
                curBranch.Text = curDevice.DeviceName;
                curBranch.Tag  = "Device";
                programs       = XMLOperator.GetPrograms(curDevice.DeviceName);
                //Console.WriteLine("The Capacity of programs is "+programs.Capacity);
                for (int j = 0; j < programs.Count; j++)
                {
                    TreeNode pLeaf = new TreeNode();
                    //Console.WriteLine("j is " + j.ToString());
                    Bases.Program curProgram = programs[j];
                    pLeaf.Text = curProgram.Name;
                    pLeaf.Tag  = "Program";
                    curBranch.Nodes.Add(pLeaf);
                }
                root.Nodes.Add(curBranch);
                programs.Clear();
            }

            // 添加分组以及分组下程序信息
            // 添加第一级节点(分组节点)
            //      添加第二级节点(程序节点)
            groups = XMLOperator.GetGroups();
            for (int i = 0; i < groups.Count; i++)
            {
                TreeNode curBranch = new TreeNode();
                Group    curGroup  = groups[i];
                curBranch.Text = curGroup.groupName;
                curBranch.Tag  = "Group";
                programs       = XMLOperator.GetProgramsFromGroup(curGroup.groupName);
                for (int j = 0; j < programs.Count; j++)
                {
                    TreeNode      pLeaf      = new TreeNode();
                    Bases.Program curProgram = programs[j];
                    pLeaf.Text = curProgram.Name + "(" + curProgram.BelongDevice + ")";
                    pLeaf.Tag  = "GroupItem";
                    curBranch.Nodes.Add(pLeaf);
                }
                root2.Nodes.Add(curBranch);
                programs.Clear();
            }

            treeView1.Nodes.Add(root);
            treeView1.Nodes.Add(root2);
        }