Beispiel #1
0
 /**********************************************************************
  ***********************************************************************/
 void CreateTopHalf(Grid grid)
 {
     draw       = new AllocationStrategiesDraw();
     canvasView = new SKCanvasView();
     canvasView = AllocationStrategiesDraw.ReturnCanvas();
     grid.Children.Add(canvasView, 0, 0);
 }
Beispiel #2
0
 /**********************************************************************
  *********************************************************************/
 void B_Restart_Clicked(object sender, EventArgs e)
 {
     algo = new AllocationStrategiesAlgorithm(strategy, allFragmentsList);
     CreateContent();
     AllocationStrategiesDraw.Paint();
     foreach (FragmentBlock fb in allFragmentsList)
     {
         //Debug.Write(" |" + fb.IsFree() + " " + fb.GetSize());
     }
 }
Beispiel #3
0
        /**********************************************************************
         *********************************************************************/
        async void B_Next_Clicked(object sender, EventArgs e)
        {
            AllocationStrategiesAlgorithm.Status status = AllocationStrategiesAlgorithm.GetStatus();

            // if new memory request was made
            if (b_Next.Text == "Confirm")
            {
                // if the memory request is valid
                if (ValidateMemoryRequestInput(e_MemoryRequest.Text))
                {
                    b_Next.Text = "Next";

                    // disable memory request entry and indicate that it's accepted
                    e_MemoryRequest.IsEnabled       = false;
                    e_MemoryRequest.BackgroundColor = Color.FromRgba(172, 255, 47, 30);

                    // enable restart button
                    b_Restart.IsEnabled = true;

                    // check first if memory is already full before you make a new request
                    if (AllocationStrategiesAlgorithm.MemoryIsFull())
                    {
                        await DisplayAlert("Alert", "Out of memory! Please restart.", "OK");

                        b_Next.Text = "Confirm";
                        e_MemoryRequest.IsEnabled       = true; // enable memory request entry
                        e_MemoryRequest.BackgroundColor = Color.White;
                        e_MemoryRequest.Text            = "";
                    }
                    else
                    {
                        AllocationStrategiesAlgorithm.Start(Int32.Parse(e_MemoryRequest.Text));
                    }
                }
                // otherwise wait until a valid memory request is made by the user
                else
                {
                    e_MemoryRequest.BackgroundColor = Color.FromRgba(238, 130, 238, 30);
                }
            }
            else
            {
                //Debug.WriteLine("next button text");

                // start or still searching
                if (status == AllocationStrategiesAlgorithm.Status.searching || status == AllocationStrategiesAlgorithm.Status.start)
                {
                    Debug.WriteLine("start or Still searching ");
                    AllocationStrategiesAlgorithm.Next();
                    status = AllocationStrategiesAlgorithm.GetStatus();
                    if (status == AllocationStrategiesAlgorithm.Status.successfull)
                    {
                        b_Next.Text = "Allocate";
                    }
                    else if (status == AllocationStrategiesAlgorithm.Status.unsuccessfull)
                    {
                        b_Next.Text = "Confirm";
                        e_MemoryRequest.IsEnabled       = true; // enable memory request entry
                        e_MemoryRequest.BackgroundColor = Color.White;
                        e_MemoryRequest.Text            = "";
                        await DisplayAlert("Alert", "Memory request was unsuccessfull.", "OK");
                    }
                }
                //sth found
                else if (status == AllocationStrategiesAlgorithm.Status.successfull)
                {
                    //Debug.WriteLine("Sth found");
                    AllocationStrategiesAlgorithm.UpdateAllFragmentsList();
                    b_Next.Text = "Confirm";
                    e_MemoryRequest.IsEnabled       = true; // enable memory request entry
                    e_MemoryRequest.BackgroundColor = Color.White;
                    e_MemoryRequest.Text            = "";
                }

                /*
                 * else if (status == AllocationStrategiesAlgorithm.Status.unsuccessfull)
                 * {
                 *  b_Next.Text = "Confirm";
                 *  e_MemoryRequest.IsEnabled = true; // enable memory request entry
                 *  e_MemoryRequest.BackgroundColor = Color.White;
                 *  e_MemoryRequest.Text = "";
                 *  await DisplayAlert("Alert", "Memory request was unsuccessfull.", "OK");
                 *
                 * }*/
            }
            AllocationStrategiesDraw.Paint();
        }