Exemple #1
0
 //Change to Scan scheduling.
 public void ScanCommand()
 {
     Context          = new DiskSchedulingContext(new ScanDiskScheduling(), _requests, _currentRequest);
     _currentStrategy = "Scan strategy";
 }
Exemple #2
0
        public MainWindow()
        {
            InitializeComponent();
            _timer = new Timer {
                Interval = 1000
            };
            _timer.Elapsed += TimerOnTick;

            //Creates a random list of requests.
            SetNewRandomList();

            //Set current reuest as first.
            _currentRequest = _requests[0];

            //Set Fifo by default.
            Context          = new DiskSchedulingContext(new FifoScheduling(), _requests, _requests[0]);
            _currentStrategy = "Fifo strategy";

            //Initialize the plot model.
            var plotModel = CreatePlotModel(_size, _requests.Count, _requestList, -1);

            //Initilize the view model.
            _diskSchedulingViewModel =
                new DiskSchedulingViewModel
            {
                CurrectRunningProceses = new ObservableCollection <string>(),
                PlotSeries             = new ObservableCollection <DataPoint>(),
                RequestList            = new ObservableCollection <int>(),
                Color     = "Black",
                PlotModel = plotModel,

                AddRequestsManuallyVisibility = Visibility = Visibility.Collapsed,

                IsAddRandomCommandEnabled    = true,
                IsAddListCommandEnabled      = true,
                IsAddRequestsManuallyCommand = true,
                IsCancelCommandEnabled       = true,

                IsFifoButtonEnabled = false,
                IsSstfButtonEnabled = true,
                IsScanButtonEnabled = true,

                IsStartButtonEnabled = true,
                IsStopButtonEnabled  = false,
                List = "",

                DprStrategyPatternMainWindow = this
            };
            //This fuction sets the bindings from DiskSchedulingViewModel to the UI.
            DataContext = _diskSchedulingViewModel;

            //Creates a new series list for the plot.
            _diskSchedulingViewModel.PlotModel.Series.Add
            (
                new LineSeries
            {
                StrokeThickness = 1,
                Color           = OxyColors.Black,
                MarkerType      = MarkerType.Circle,
                MarkerFill      = OxyColors.Black,
                ItemsSource     = _diskSchedulingViewModel.PlotSeries,
                Background      = OxyColors.Transparent
            });

            //Updtae the UI list with new request list.
            AddToUi();
        }
Exemple #3
0
 //Change to Fifo scheduling.
 public void FifoCommand()
 {
     Context          = new DiskSchedulingContext(new FifoScheduling(), _requests, _currentRequest);
     _currentStrategy = "Fifo strategy";
 }