コード例 #1
0
        /**********************************************************************
         *********************************************************************/
        private static void CalculateNeededVariables()
        {
            /*important: the coordinate system starts in the upper left corner*/
            strokeWidth = 5;
            centerX     = info.Width / 2;
            centerY     = info.Height / 2;
            x1          = strokeWidth / 2;
            y1          = strokeWidth / 2;
            x2          = info.Width - strokeWidth / 2;
            y2          = info.Height - strokeWidth / 2;

            //other needed stuff
            textSize          = 0.05f;
            step              = 0.2f;
            backgWindowLength = xText(0.28f) + Deadlock.GetVectorC().Length *xText(0.05f);
            float xLengthLeftInCell = x2 - backgWindowLength * 3;

            spaceBetweenBackgWindows = xLengthLeftInCell / 4.0f;

            //TODO: should not be smaller than 0
            //Debug.WriteLine(string.Format($" spaceBetweenBackgWindows: {spaceBetweenBackgWindows}"));

            xStartBackgWindow1 = spaceBetweenBackgWindows;
            xStartBackgWindow2 = xStartBackgWindow1 + backgWindowLength + spaceBetweenBackgWindows;
            xStartBackgWindow3 = xStartBackgWindow2 + backgWindowLength + spaceBetweenBackgWindows;

            //Debug.WriteLine("t: " + Deadlock.GetTotalProcesses());
            backgWindowHeight = Deadlock.GetTotalProcesses() * yPercent(step);
            float yLengthLeftInCell = y2 - backgWindowHeight;

            yStartBackgWindow = yLengthLeftInCell / 2.0f;
            //Debug.WriteLine(string.Format($" centerX: {centerX}, centerY {centerY}, x1: {x1}, x2: {x2}, y1: {y1}, y2: {y2}"));
        }
コード例 #2
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();
            }
        }