Exemple #1
0
        //custom contructor unfortunately not possible...
        public DeadlockViewCell()
        {
            this.skiaview = new SKCanvasView();
            this.skiaview.BackgroundColor = App._viewBackground;
            this.skiaview.PaintSurface   += PaintSurface;
            this.View = this.skiaview;

            this.cellNumber       = Deadlock.GetCellNumber();
            this.vectorE          = Deadlock.GetVectorE();
            this.vectorB          = Deadlock.GetVectorB();
            this.vectorC          = Deadlock.GetVectorC();
            this.vectorCProcesses = Deadlock.GetVectorCProcesses();
            this.vectorBProcesses = Deadlock.GetVectorBProcesses();
            this.totalProcesses   = Deadlock.GetTotalProcesses();

            //NOTE: Lists and Arrays in C# do not stay the same
            //and are recreated a lot since they're not by reference.
            //somehow bool, int etc stay the same for this viewcellobject
            //once they're assinged
            this.P0done = Deadlock.P0done;
            this.P1done = Deadlock.P1done;
            this.P2done = Deadlock.P2done;
            this.P3done = Deadlock.P3done;
            this.P4done = Deadlock.P4done;

            touchable = true;

            if (cellNumber != -1)
            {
                this.history = Deadlock.GetHistory(cellNumber, 0);
                this.vectorA = Deadlock.GetHistory(cellNumber, 1);
                //.WriteLine("history of cell " + cellNumber + ": " + history);
                //Deadlock.deadLockViewCellCansvasList.Add(this.skiaview);
                //Deadlock.deadLockViewCellTouchableList.Add(this.touchable);
            }
            else
            {
                this.vectorA = Deadlock.GetVectorA();
            }
        }
Exemple #2
0
        private void DrawCalculation()
        {
            float starty    = 0.21f;
            float y1Backg   = 0.10f;
            float stepBackg = 0.20f;

            // vectors to display
            String oldVA = "";

            if (cellNumber == 0)
            {
                oldVA = Deadlock.GetVectorA();
            }
            else
            {
                oldVA = Deadlock.GetHistory(cellNumber - 1, 1);
            }
            String currVB = vectorBProcesses[Int16.Parse(history)];
            String currVC = vectorCProcesses[Int16.Parse(history)];
            String currVA = vectorA;

            //Fromat text
            String resultTextVAold = "Aold   = ( ";
            String resultTextVB    = "B(P" + history + ") = ( ";
            String resultTextVC    = "C(P" + history + ") = ( ";
            String resultTextVAnew = "Anew = ( ";
            String space           = "  ";

            for (int j = 0; j < currVB.Length; j++)
            {
                if (j == currVB.Length - 1)
                {
                    space = " )";
                }
                resultTextVB    = resultTextVB + currVB[j] + space;
                resultTextVC    = resultTextVC + currVC[j] + space;
                resultTextVAnew = resultTextVAnew + currVA[j] + space;
                resultTextVAold = resultTextVAold + oldVA[j] + space;
            }

            //Draw green background
            SKRect sk_rBackground0 = new SKRect(
                xStartBackgWindow1,
                yPercent(y1Backg),
                xStartBackgWindow1 + backgWindowLength,
                yPercent(y1Backg) + yPercent(stepBackg));         //left , top, right, bottom

            canvas.DrawRect(sk_rBackground0, sk_BackgroundWhite); //left, top, right, bottom, color
            canvas.DrawRect(sk_rBackground0, sk_BackgroundGreen); //left, top, right, bottom, color

            // Aold
            SKPoint textPosition0 = new SKPoint(
                xStartBackgWindow1 + xText(0.02f),
                yPercent(starty));

            canvas.DrawText(resultTextVAold, textPosition0, sk_blackText);

            //Draw yellow background
            SKRect sk_rBackground = new SKRect(
                xStartBackgWindow1,
                yPercent(y1Backg) + yPercent(stepBackg),
                xStartBackgWindow1 + backgWindowLength,
                yPercent(y1Backg) + yPercent(stepBackg * 2));     //left , top, right, bottom

            canvas.DrawRect(sk_rBackground, sk_BackgroundWhite);  //left, top, right, bottom, color
            canvas.DrawRect(sk_rBackground, sk_BackgroundYellow); //left, top, right, bottom, color
            // C(x)

            SKPoint textPosition2 = new SKPoint(
                xStartBackgWindow1 + xText(0.02f),
                yPercent(starty) + yPercent(step));

            canvas.DrawText(resultTextVC, textPosition2, sk_blackText);

            //Draw red background
            SKRect sk_rBackground2 = new SKRect(
                xStartBackgWindow1,
                yPercent(y1Backg) + yPercent(stepBackg * 2),
                xStartBackgWindow1 + backgWindowLength,
                yPercent(y1Backg) + yPercent(stepBackg * 3));     //left , top, right, bottom

            canvas.DrawRect(sk_rBackground2, sk_BackgroundWhite); //left, top, right, bottom, color
            canvas.DrawRect(sk_rBackground2, sk_BackgroundRed);   //left, top, right, bottom, color
            // B(x)
            SKPoint textPosition3 = new SKPoint(
                xStartBackgWindow1 + xText(0.02f),
                yPercent(starty) + yPercent(step * 2));

            canvas.DrawText(resultTextVB, textPosition3, sk_blackText);

            //Draw green background
            SKRect sk_rBackground4 = new SKRect(
                xStartBackgWindow1,
                yPercent(y1Backg) + yPercent(stepBackg * 3),
                xStartBackgWindow1 + backgWindowLength,
                yPercent(y1Backg) + yPercent(stepBackg * 4));     //left , top, right, bottom

            canvas.DrawRect(sk_rBackground4, sk_BackgroundWhite); //left, top, right, bottom, color
            canvas.DrawRect(sk_rBackground4, sk_BackgroundGreen); //left, top, right, bottom, color
            // Anew
            SKPoint textPosition4 = new SKPoint(
                xStartBackgWindow1 + xText(0.02f),
                yPercent(starty) + yPercent(step * 3));

            canvas.DrawText(resultTextVAnew, textPosition4, sk_blackText);
        }