コード例 #1
0
 private void onSelect(ComboBox combobox, int i)
 {
     if (combobox.SelectedIndex == (int)schedulerTypes.RoundRobbin)
     {
         EnterValueForm pop = new EnterValueForm("Enter quantum for Round Robbin:", EnterValueForm.PopUpType.Input);
         if (pop.ShowDialog() == DialogResult.OK)
         {
             queues[i] = new RoundRobinScheduler("RR:" + pop.value, pop.value, null);
         }
         else
         {
             combobox.SelectedItem = null;
         }
     }
     else if (combobox.SelectedIndex == (int)schedulerTypes.FirstComeFirstServe)
     {
         queues[i] = new FirstComeFirstServeScheduler("FCFS", null);
     }
 }
コード例 #2
0
        private void schedulersDataGrid_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 0)
            {
                if (e.RowIndex == schedulersDataGrid.Rows.Count - 1)
                {
                    AddSchedulerForm pop = new AddSchedulerForm();
                    if (pop.ShowDialog() == DialogResult.OK)
                    {
                        if (pop.scheduler == schedulerTypes.RoundRobbin)
                        {
                            string    name          = "RR(Q:" + pop.value + ")";
                            Scheduler tempScheduler = new RoundRobinScheduler(name, pop.value, new List <Process>(), pop.color);
                            simulationManager.schedulers.Add(tempScheduler);
                            int tempIndex = schedulersDataGrid.Rows.Add("x", name, string.Empty, tempScheduler);
                            schedulersDataGrid[2, tempIndex].Style.BackColor =
                                schedulersDataGrid[2, tempIndex].Style.SelectionBackColor = pop.color;
                        }
                        else if (pop.scheduler == schedulerTypes.FirstComeFirstServe)
                        {
                            string    name          = "FCFS";
                            Scheduler tempScheduler = new FirstComeFirstServeScheduler(name, new List <Process>(), pop.color);
                            simulationManager.schedulers.Add(tempScheduler);
                            int tempIndex = schedulersDataGrid.Rows.Add("x", name, string.Empty, tempScheduler);
                            schedulersDataGrid[2, tempIndex].Style.BackColor =
                                schedulersDataGrid[2, tempIndex].Style.SelectionBackColor = pop.color;
                        }
                        else if (pop.scheduler == schedulerTypes.HightstResponseRatioNext)
                        {
                            string    name          = "HRRN";
                            Scheduler tempScheduler = new HighestResponseRatioNextScheduler(name, new List <Process>(), pop.color);
                            simulationManager.schedulers.Add(tempScheduler);
                            int tempIndex = schedulersDataGrid.Rows.Add("x", name, string.Empty, tempScheduler);
                            schedulersDataGrid[2, tempIndex].Style.BackColor =
                                schedulersDataGrid[2, tempIndex].Style.SelectionBackColor = pop.color;
                        }
                        else if (pop.scheduler == schedulerTypes.EarliestDeadlineFirst)
                        {
                            string    name          = "EDF(D=x" + pop.value + ")";
                            Scheduler tempScheduler = new EarliestDeadlineFirstScheduler(name, new List <Process>(), pop.color, pop.value);
                            simulationManager.schedulers.Add(tempScheduler);
                            int tempIndex = schedulersDataGrid.Rows.Add("x", name, string.Empty, tempScheduler);
                            schedulersDataGrid[2, tempIndex].Style.BackColor =
                                schedulersDataGrid[2, tempIndex].Style.SelectionBackColor = pop.color;
                        }
                        else if (pop.scheduler == schedulerTypes.ShortestJobFirst)
                        {
                            string    name          = "SJF";
                            Scheduler tempScheduler = new EarliestDeadlineFirstScheduler(name, new List <Process>(), pop.color);
                            simulationManager.schedulers.Add(tempScheduler);
                            int tempIndex = schedulersDataGrid.Rows.Add("x", name, string.Empty, tempScheduler);
                            schedulersDataGrid[2, tempIndex].Style.BackColor =
                                schedulersDataGrid[2, tempIndex].Style.SelectionBackColor = pop.color;
                        }
                        else if (pop.scheduler == schedulerTypes.MultilevelFeedbackQueue)
                        {
                            string name = "MLFQ-" + pop.sch[0].name + "-" + pop.sch[1].name + "-" + pop.sch[2].name;
                            List <MultiLevelableScheduler> list = new List <MultiLevelableScheduler>();
                            for (int i = 0; i < 3; i++)
                            {
                                list.Add(pop.sch[i]);
                            }
                            Scheduler tempScheduler = new MultiLevelFeedbackQueueScheduler(name, pop.color, list);
                            simulationManager.schedulers.Add(tempScheduler);
                            int tempIndex = schedulersDataGrid.Rows.Add("x", name, string.Empty, tempScheduler);
                            schedulersDataGrid[2, tempIndex].Style.BackColor =
                                schedulersDataGrid[2, tempIndex].Style.SelectionBackColor = pop.color;
                        }
                    }
                }
                else
                {
                    simulationManager.schedulers.RemoveAt(e.RowIndex);
                    schedulersDataGrid.Rows.RemoveAt(e.RowIndex);
                }

                refreshStepDataGrid();
            }
            else if (e.ColumnIndex == 1 && e.RowIndex < schedulersDataGrid.Rows.Count - 1)
            {
                AddSchedulerForm pop = new AddSchedulerForm();
                if (pop.ShowDialog() == DialogResult.OK)
                {
                    if (pop.scheduler == schedulerTypes.RoundRobbin)
                    {
                        string    name = "RR(Q:" + pop.value + ")";
                        Scheduler previousScheduler = simulationManager.schedulers[e.RowIndex];
                        Scheduler tempScheduler     = new RoundRobinScheduler(name, pop.value, null, previousScheduler.graphColor);
                        simulationManager.schedulers[e.RowIndex]           = tempScheduler;
                        schedulersDataGrid.Rows[e.RowIndex].Cells[1].Value = name;
                    }
                    else if (pop.scheduler == schedulerTypes.EarliestDeadlineFirst)
                    {
                        string    name = "EDF(D=x" + pop.value + ")";
                        Scheduler previousScheduler = simulationManager.schedulers[e.RowIndex];
                        Scheduler tempScheduler     = new EarliestDeadlineFirstScheduler(name, null, previousScheduler.graphColor, pop.value);
                        simulationManager.schedulers[e.RowIndex]           = tempScheduler;
                        schedulersDataGrid.Rows[e.RowIndex].Cells[1].Value = name;
                    }
                }

                refreshStepDataGrid();
            }
            else if (e.ColumnIndex == 2 && e.RowIndex < schedulersDataGrid.Rows.Count - 1)
            {
                if (colorDialog1.ShowDialog() == DialogResult.OK)
                {
                    simulationManager.schedulers[e.RowIndex].graphColor            = colorDialog1.Color;
                    schedulersDataGrid[2, e.RowIndex].Style.BackColor              =
                        schedulersDataGrid[2, e.RowIndex].Style.SelectionBackColor = colorDialog1.Color;
                }
            }
        }