public void addRow(DataGridView view, FileDirectory fd, string config)
        {
            DirectoryDataGridViewRow directoryDataGridViewRow = new DirectoryDataGridViewRow(fd);

            string text = DirectoryHandler.getInstance().getPathFromParent(fd, fd.getPath());
            DirectoryDataGridViewTextBoxCell directories = new DirectoryDataGridViewTextBoxCell(text);
            DataGridViewComboBoxCell commands = new DataGridViewComboBoxCell();
            DataGridViewCheckBoxCell include = new DataGridViewCheckBoxCell();
            DataGridViewCheckBoxCell echo = new DataGridViewCheckBoxCell();
            DataGridViewCheckBoxCell display = new DataGridViewCheckBoxCell();
            DataGridViewCheckBoxCell autoExit = new DataGridViewCheckBoxCell();
            DataGridViewCheckBoxCell waitForExit = new DataGridViewCheckBoxCell();
            if (text.Length > 50)
            {
                int i = text.Length;
                int num = 20;
                while (i > 50)
                {
                    i--;
                    num++;
                }
                text = text.Substring(0, 5) + "....." + text.Substring(num);
            }
            directories.Value = text;

            foreach(Command c in PreloadedConfigurationGetterService.getInstance().getCommandsFromXMLConfiguration(config)){
                commands.Items.Add(c.getName());
            }
            if(commands.Items.Count == 0) return;
            commands.Value = commands.Items[0];

            include.Value = true;
            echo.Value = true;
            display.Value = true;
            autoExit.Value = true;
            waitForExit.Value = true;
            directoryDataGridViewRow.Cells.Add(directories);
            directoryDataGridViewRow.Cells.Add(commands);
            directoryDataGridViewRow.Cells.Add(include);
            directoryDataGridViewRow.Cells.Add(display);
            directoryDataGridViewRow.Cells.Add(autoExit);
            directoryDataGridViewRow.Cells.Add(waitForExit);

            directories.ReadOnly = true;
            commands.ReadOnly = false;
            include.ReadOnly = false;
            echo.ReadOnly = false;
            display.ReadOnly = false;
            autoExit.ReadOnly = false;
            view.Rows.Add(directoryDataGridViewRow);
        }
Exemplo n.º 2
0
        public void addToDataView(ProcessHandle ph)
        {
            ProcessHandleDataGridViewRow processHandleDataGridViewRow = new ProcessHandleDataGridViewRow(ph);
            string dir = ph.getProcessCaller().getDirectory();

            DirectoryDataGridViewTextBoxCell pid        = new DirectoryDataGridViewTextBoxCell(ph.getPID());
            DirectoryDataGridViewTextBoxCell directory  = new DirectoryDataGridViewTextBoxCell(dir);
            DirectoryDataGridViewTextBoxCell command    = new DirectoryDataGridViewTextBoxCell(ph.getProcessCaller().getCmd());
            DirectoryDataGridViewTextBoxCell cpu        = new DirectoryDataGridViewTextBoxCell(ph.getCPUUsage());
            DirectoryDataGridViewTextBoxCell ram        = new DirectoryDataGridViewTextBoxCell(ph.getRAMUsage());
            DirectoryDataGridViewTextBoxCell runTime    = new DirectoryDataGridViewTextBoxCell(ph.getRunningTime());
            DirectoryDataGridViewTextBoxCell blocker    = new DirectoryDataGridViewTextBoxCell(ph.getBlockedBy() != null ? ph.getBlockedBy().getPID() : "");
            DataGridViewButtonCell kill                 = new DataGridViewButtonCell();

            if (dir.Length > 50){
                int i = dir.Length;
                int num = 20;
                while (i > 50){
                    i--;
                    num++;
                }
                dir = dir.Substring(0, 5) + "....." + dir.Substring(num);
            }
            pid.Value = ph.getPID();
            directory.Value = dir;
            command.Value = ph.getProcessCaller().getCmd();
            cpu.Value = ph.getCPUUsage();
            ram.Value = ph.getRAMUsage();
            runTime.Value = ph.getRunningTime();
            blocker.Value = ph.getBlockedBy() != null ? ph.getBlockedBy().getPID() : "";
            kill.Value = "KILL";

            processHandleDataGridViewRow.Cells.Add(pid);
            processHandleDataGridViewRow.Cells.Add(directory);
            processHandleDataGridViewRow.Cells.Add(command);
            processHandleDataGridViewRow.Cells.Add(cpu);
            processHandleDataGridViewRow.Cells.Add(ram);
            processHandleDataGridViewRow.Cells.Add(runTime);
            processHandleDataGridViewRow.Cells.Add(blocker);
            processHandleDataGridViewRow.Cells.Add(kill);

            this.bottomUserControlProcessHandleDataGridView.Rows.Add(processHandleDataGridViewRow);
        }