/// <summary>
        /// uses a scale transform to zoom
        /// </summary>
        /// <param name="delta">-1/1 - smaller/bigger</param>
        private void Zoom(double delta)
        {
            var st = (ScaleTransform)((TransformGroup)Media1.RenderTransform).Children.First(tr => tr is ScaleTransform);

            if (delta < 0 && st.ScaleX < _zoomMin || delta > 0 && st.ScaleX > _zoomMax)
            {
                return;
            }

            var tt = (TranslateTransform)((TransformGroup)Media1.RenderTransform).Children.First(tr => tr is TranslateTransform);

            double zoom = delta > 0 ? _zoomStep : 1.0 / _zoomStep;

            st.ScaleX = st.ScaleY *= zoom;

            if (st.ScaleX == 1.0)
            {
                _mode &= ~Modi.Zoom;
            }
            else
            {
                _mode |= Modi.Zoom;
            }

            SetMaxPanValues();

            tt.X = _maxX == 0 ? 0 : (Math.Abs(tt.X) > _maxX) ? Math.Sign(tt.X) * _maxX : tt.X;
            tt.Y = _maxY == 0 ? 0 : (Math.Abs(tt.Y) > _maxY) ? Math.Sign(tt.Y) * _maxY : tt.Y;
        }
Beispiel #2
0
    private void updateScalingManipulation()
    {
        if (Input.GetKey("down"))
        {
            scaleScript.ScaleKleiner();
        }
        if (Input.GetKey("up"))
        {
            scaleScript.ScaleGroter();
        }
        if (Input.GetKey("p"))
        {
            scaleScript.volgendeAs();
        }
        if (Input.GetKeyUp("p"))
        {
            scaleScript.releaseLock();
        }
        if (Input.GetKeyUp("o"))
        {
            scaleScript.End();             // end this manipulation
            modus = Modi.CHO_MAN;
        }

        checkForNewSelection();
    }
    // Use this for initialization
    void Start()
    {
        //Init controllers
        wiimote_start();

        //Turn off mouse pointer and set the cursorImage
        screenpointer                       = (GUITexture)Instantiate(baseGuiTexture);
        Screen.showCursor                   = false;
        screenpointer.texture               = cursorImage;
        screenpointer.color                 = Color.red;
        screenpointer.pixelInset            = new Rect(10, 10, 10, 10);
        screenpointer.transform.localScale -= new Vector3(1, 1, 0);

        //Set ref scripts
        raycastscript      = gameObject.GetComponent("RayCastScript") as RayCastScript;
        rotateScript       = gameObject.GetComponent("RotateScript") as RotateScript;
        scaleScript        = gameObject.GetComponent("ScaleScript") as ScaleScript;
        stackScript        = gameObject.GetComponent("StackScript") as StackScript;
        moveScript         = gameObject.GetComponent("MoveScript") as MoveScript;
        smoothCameraScript = gameObject.GetComponent("SmoothCameraScript") as SmoothCameraScript;
        verwijderScript    = gameObject.GetComponent("VerwijderScript") as VerwijderScript;
        selectieScript     = gameObject.GetComponent("SelectieScript") as SelectieScript;

        //Set initial values
        selectieScript.setSelectionmodeOn();
        selectieScript.playerCam = playerCam;
        modus = Modi.NAV_SEL;
    }
	// Use this for initialization
	void Start () {
		//selectieScript.lastGameObjectHit = null;
		lastHooveredGameObject = null;
	
		//Set ref script
		raycastscript = gameObject.GetComponent("RayCastScript") as RayCastScript;
		rotateScript = gameObject.GetComponent("RotateScript") as RotateScript;
		scaleScript = gameObject.GetComponent("ScaleScript") as ScaleScript;
		stackScript = gameObject.GetComponent("StackScript") as StackScript;
		moveScript = gameObject.GetComponent("MoveScript") as MoveScript;
		smoothCameraScript = gameObject.GetComponent("SmoothCameraScript") as SmoothCameraScript;
		verwijderScript = gameObject.GetComponent("VerwijderScript") as VerwijderScript;
		selectieScript = gameObject.GetComponent("SelectieScript") as SelectieScript;
		selectieScript.setSelectionmodeOn();
		selectieScript.playerCam = playerCam;
		
		//Turn off mouse pointer and set the cursorImage
		screenpointer = (GUITexture)Instantiate(baseGuiTexture);
		Screen.showCursor = false; 
		screenpointer.texture = cursorImage;
		screenpointer.color = Color.red;
		screenpointer.pixelInset = new Rect(-5, -5,10,10);
		screenpointer.transform.localScale -= new Vector3(1, 1, 0);
		
		modus = Modi.NAV_SEL;
	}
Beispiel #5
0
 private void updateDeletingManipulation()
 {
     verwijderScript.DeleteObject(selectieScript.lastGameObjectHit);
     selectieScript.lastGameObjectHit = null;
     modus = Modi.NAV_SEL;
     checkForNewSelection();
 }
 /// <summary>
 /// shows an overlay with help text
 /// </summary>
 private void ShopHelpText()
 {
     Label2.Content = "General\n" +
                      "---------\n" +
                      "H/I/F1  -  Show this help screen\n" +
                      "ESC       -  Close help / End slideshow / Close " + (_isApplication ? "application" : "window") + "\n" +
                      "Space   -  End zoom mode / Start/Stop slideshow\n" +
                      "\n" +
                      "Mouse Navigation\n" +
                      "---------------------\n" +
                      "Wheel  -  Change zoom level\n" +
                      "\n" +
                      "Clicks:\n" +
                      "Left double    -  Choose new image folder\n" +
                      "Middle           -  Open Explorer inside folder and select image file\n" +
                      "Right              -  Copy directory name to clipboard\n" +
                      "Right double  -  Copy filepath to clipboard\n" +
                      "\n" +
                      "Move/Drag:\n" +
                      "Click+Left/Right/Up/Down  -  Move the image\n" +
                      "\n" +
                      "Keyboard Navigation\n" +
                      "------------------------\n" +
                      "Left/Right   -  Show previous/next image\n" +
                      "Home/End  -  Show first/last image\n" +
                      "\n" +
                      "in zoom mode:\n" +
                      "Alt+Left/Right/Up/Down  -  Move the image\n" +
                      "\n" +
                      "in slideshow mode:\n" +
                      "PageUp/PageDown  -  Change image duration (1..30 seconds)";
     Label2.Visibility = Visibility.Visible;
     _mode            |= Modi.HelpShown;
 }
Beispiel #7
0
    private void updateStackingManipulation()
    {
        if (stackScript.isActive)
        {
            if (stackScript.gridModus)
            {
                if (Input.GetKeyUp("left"))
                {
                    stackScript.goToNextAvailablePositionLeft();
                }
                if (Input.GetKeyUp("right"))
                {
                    stackScript.goToNextAvailablePositionRight();
                }
                if (Input.GetKeyUp("up"))
                {
                    stackScript.goToNextAvailablePositionTop();
                }
                if (Input.GetKeyUp("down"))
                {
                    stackScript.goToNextAvailablePositionDown();
                }
            }
            else
            {
                if (Input.GetKey("left"))
                {
                    stackScript.goToLeft();
                }
                if (Input.GetKey("right"))
                {
                    stackScript.goToRight();
                }
                if (Input.GetKey("up"))
                {
                    stackScript.goToTop();
                }
                if (Input.GetKey("down"))
                {
                    stackScript.goToBottom();
                }
            }

            if (Input.GetKeyUp("k") && stackScript.gridModus)            //TODO: NOT IMPLEMENTED
            {
                stackScript.goToNextAvailablePosition();                 // scrolling  left-right, bottom-up
            }
            if (Input.GetKeyUp("i"))
            {
                stackScript.goToNextPossibleStackedObject();                 // scrolling between possible object
            }
            if (Input.GetKeyUp("o"))
            {
                stackScript.End();                 // end this manipulation
                modus = Modi.CHO_MAN;
            }
        }
    }
        /// <summary>
        /// resets the zoom level
        /// </summary>
        private void ResetZoomLevel()
        {
            _mode &= ~Modi.Zoom;

            Media1.RenderTransformOrigin = new Point(0.5, 0.5);
            var tg = new TransformGroup();

            tg.Children.Add(new ScaleTransform());
            tg.Children.Add(new TranslateTransform());
            Media1.RenderTransform = tg;

            SetMaxPanValues();
        }
 /// <summary>
 /// starts the slideshow
 /// </summary>
 /// <param name="showMessage">show message only on real slideshow starts</param>
 private void StartSlideshow(bool showMessage)
 {
     if (_isSlideshowRunning)
     {
         StopSlideshow(0);
     }
     if (showMessage)
     {
         ShowMessage("Slideshow started");
     }
     _mode |= Modi.Slideshow;
     _isSlideshowRunning      = true;
     _timerSlideshow.Interval = TimeSpan.FromSeconds(_imageDurationSeconds);
     _timerSlideshow.Tick    += TimerSlideshow_Tick;
     _timerSlideshow.Start();
 }
        /// <summary>
        /// pauses or stops the slideshow
        /// </summary>
        /// <param name="mode">0 - stop for restart, 1 - pause, 2 - stop</param>
        private void StopSlideshow(int mode)
        {
            _isSlideshowRunning = false;

            if (mode == 1)
            {
                ShowMessage("Slideshow paused");
            }
            else if (mode == 2)
            {
                _mode &= ~Modi.Slideshow;
                ShowMessage("Slideshow stopped");
            }

            _timerSlideshow.Stop();
            _timerSlideshow.Tick -= TimerSlideshow_Tick;
        }
Beispiel #11
0
    private void updateRotatingManipulation()
    {
        if (Input.GetKey("left"))
        {
            rotateScript.RotateLeft();
        }
        if (Input.GetKey("right"))
        {
            rotateScript.RotateRight();
        }
        if (Input.GetKeyUp("o"))
        {
            rotateScript.End();             // end this manipulation
            modus = Modi.CHO_MAN;
        }

        checkForNewSelection();
    }
Beispiel #12
0
 public void PlayModi(Modi modi)
 {
     TableController.StartModi(modi);
 }
Beispiel #13
0
    // Update is called once per frame
    void Update()
    {
        //Laat hier temp staan OVERGEZET
        selectieScript.updateSelection(Input.mousePosition.x, Input.mousePosition.y);
        smoothCameraScript.UpdateCamera();

        //check of we een nieuwe kamer geselecteerd hebben vanuit topview en navigeer daarnaar
        /* OVERZETTEN */
        if (moveToSelectedRoom)
        {
            smoothCameraScript.goToRoom(selectieScript.lastGameObjectHit.transform.position);
            modus = Modi.NAV_SEL;
        }

        /*OVERGEZET*/
        // aborting modus
        if (Input.GetKeyUp("q"))
        {
            Debug.Log("Abort");
            rotateScript.End();
            scaleScript.End();
            stackScript.Abort();
            moveScript.End();

            if (returnToCamShowAfterManipulation)
            {
                modus = Modi.CAM_SHO;
            }
            else
            {
                smoothCameraScript.GaNaarVorigePositie();
                modus = Modi.NAV_SEL;
            }

            deselectAll();
        }
        // go to moving/changing parent modus
        else if (selectieScript.lastGameObjectHit && modus == Modi.CHO_MAN && Input.GetButtonUp("Fire1"))
        {
            Debug.Log(selectieScript.getButtonOnPosition(Input.mousePosition.x, Input.mousePosition.y));
            if (selectieScript.getButtonOnPosition(Input.mousePosition.x, Input.mousePosition.y) == "Move")
            {
                Debug.Log("Move change parent");
                rotateScript.End();
                scaleScript.End();
                stackScript.End();

                modus = Modi.MOV;
                moveScript.Begin(selectieScript.lastGameObjectHit);
            }
            else if (selectieScript.getButtonOnPosition(Input.mousePosition.x, Input.mousePosition.y) == "Rotate")
            {
                Debug.Log("rotate");
                scaleScript.End();
                stackScript.End();
                moveScript.End();
                smoothCameraScript.GaNaarVorigePositie();

                modus = Modi.ROT;
                rotateScript.Begin(selectieScript.lastGameObjectHit);
            }
            else if (selectieScript.getButtonOnPosition(Input.mousePosition.x, Input.mousePosition.y) == "Add")
            {
                Debug.Log("stack");
                rotateScript.End();
                scaleScript.End();
                moveScript.End();

                modus = Modi.STA;
                stackScript.Begin(selectieScript.lastGameObjectHit);
            }
            else if (selectieScript.getButtonOnPosition(Input.mousePosition.x, Input.mousePosition.y) == "Delete")
            {
                Debug.Log("remove");
                rotateScript.End();
                scaleScript.End();
                stackScript.End();
                moveScript.End();

                modus = Modi.DEL;
            }
            else if (selectieScript.getButtonOnPosition(Input.mousePosition.x, Input.mousePosition.y) == "Scale")
            {
                Debug.Log("scale");
                rotateScript.End();
                stackScript.End();
                moveScript.End();
                smoothCameraScript.GaNaarVorigePositie();

                modus = Modi.SCA;
                scaleScript.Begin(selectieScript.lastGameObjectHit);
            }
            // go to scale modus
        }
        else if (selectieScript.lastGameObjectHit && modus == Modi.CHO_MAN && Input.GetKeyUp("e"))
        {
            Debug.Log("scale");
            rotateScript.End();
            stackScript.End();
            moveScript.End();
            smoothCameraScript.GaNaarVorigePositie();

            modus = Modi.SCA;
            scaleScript.Begin(selectieScript.lastGameObjectHit);
            // go to rotate modus
        }
        else if (selectieScript.lastGameObjectHit && modus == Modi.CHO_MAN && Input.GetKeyUp("r"))
        {
            Debug.Log("rotate");
            scaleScript.End();
            stackScript.End();
            moveScript.End();
            smoothCameraScript.GaNaarVorigePositie();

            modus = Modi.ROT;
            rotateScript.Begin(selectieScript.lastGameObjectHit);
            // go to stacking modus
        }
        else if (selectieScript.lastGameObjectHit && modus == Modi.CHO_MAN && Input.GetKeyUp("t"))
        {
            Debug.Log("stack");
            rotateScript.End();
            scaleScript.End();
            moveScript.End();

            modus = Modi.STA;
            stackScript.Begin(selectieScript.lastGameObjectHit);
            // go to removing status
        }
        else if (selectieScript.lastGameObjectHit && modus == Modi.CHO_MAN && Input.GetKeyUp("y"))
        {
            Debug.Log("remove");
            rotateScript.End();
            scaleScript.End();
            stackScript.End();
            moveScript.End();

            modus = Modi.DEL;
            // go to slideshow modus
        }
        else if (Input.GetKeyUp("u"))
        {
            Debug.Log("slideshow");
            rotateScript.End();
            scaleScript.End();
            stackScript.End();
            moveScript.End();

            deselectAll();
            smoothCameraScript.getNextCameraLokatie();
            modus = Modi.CAM_SHO;
        }

        //Select an object
        if (modus == Modi.CHO_MAN || modus == Modi.NAV_SEL)
        {
            if (selectieScript.isActive && Input.GetButtonUp("Fire1"))
            {
                if (selectieScript.GUIShown)
                {
                    selectieScript.hideUI();
                    selectieScript.GUIShown = false;
                    modus = Modi.NAV_SEL;
                }
                else
                {
                    ObjectScript script  = (ObjectScript)selectieScript.lastGameObjectHit.GetComponent("ObjectScript");
                    string[]     choices = { "Geen keuzes" };              //wordt overreden indien niet null
                    if (script != null)
                    {
                        choices = script.getObjectPossibilities();
                    }
                    selectieScript.showUi(Input.mousePosition.x, Input.mousePosition.y, choices);
                    selectieScript.GUIShown = true;
                    modus = Modi.CHO_MAN;
                }
            }

            /*
             * selectieScript.fireEvent = true; //Vuur een clickevent af in selectie
             * //TODO: if object selected?
             * if(selectieScript.lastGameObjectHit != null){
             *      Debug.Log("Naar manipulatiemode");
             *      modus = Modi.CHO_MAN;
             *      }*/
        }

        //DEEL PER DEEL DOEN -> KNOP PER KNOP IN WIIMOTE | STAAT "DONE" NA UPDATEFUNCT. INDIEN GEIMPLEMENTEERD
        switch (modus)
        {
        case Modi.NAV_SEL:                 /* DONE  */
            selectieScript.setSelectionmodeOn();
            updateNavigation();
            break;

        case Modi.CHO_MAN:                 /* DONE  */
            selectieScript.setSelectionmodeOn();
            updateManipulationChoosing();
            break;

        case Modi.MOV:                 /* DONE - TOTEST */
            selectieScript.setSelectionmodeOff();
            updateMovingManipulation();
            selectieScript.guiscript.hideGui();
            break;

        case Modi.ROT:                 /* DONE - TOTEST */
            selectieScript.setSelectionmodeOff();
            updateRotatingManipulation();
            selectieScript.guiscript.hideGui();
            break;

        case Modi.SCA:                 /* DONE - TOTEST */
            selectieScript.setSelectionmodeOff();
            updateScalingManipulation();
            selectieScript.guiscript.hideGui();
            break;

        case Modi.STA:                 /* DONE - TOTEST */
            selectieScript.setSelectionmodeOff();
            updateStackingManipulation();
            selectieScript.guiscript.hideGui();
            break;

        case Modi.DEL:                 /* DONE - TOTEST */
            selectieScript.setSelectionmodeOff();
            updateDeletingManipulation();
            selectieScript.guiscript.hideGui();
            break;

        case Modi.CAM_SHO:                 /* DONE |MERGED WITH NAV_SEL | TOTEST */
            //selectieScript.setSelectionmodeOn();
            updateCameraShow();
            //selectieScript.guiscript.hideGui();
            break;
        }

        //Set the gui shizzle
        Vector3 mousePos = Input.mousePosition;
        float   mouseX   = mousePos.x / Screen.width;
        float   mouseY   = mousePos.y / Screen.height;

        screenpointer.transform.position = new Vector3(mouseX, mouseY, 0);
        Rect cursloc = new Rect(mousePos.x, Screen.height - mousePos.y, cursorImage.width, cursorImage.height);
    }
	private void updateMovingManipulation(){
		if(moveScript.gridModus){
			if (Input.GetKeyUp("left")){
				moveScript.goToNextAvailablePositionLeft();	
				}
			if (Input.GetKeyUp("right"))
				moveScript.goToNextAvailablePositionRight();
			if (Input.GetKeyUp("up"))
				moveScript.goToNextAvailablePositionTop();
			if (Input.GetKeyUp("down"))
				moveScript.goToNextAvailablePositionDown();
		}else{
			if (Input.GetKey("left"))
				moveScript.goToLeft();	
			if (Input.GetKey("right"))
				moveScript.goToRight();
			if (Input.GetKey("up"))
				moveScript.goToTop();
			if (Input.GetKey("down"))
				moveScript.goToBottom();
		}			
		if (Input.GetKeyUp ("i") && moveScript.gridModus) /* WIIMOTE | NOT IMPLEMENTED */
			moveScript.goToNextAvailablePosition(); // scrolling  left-right, bottom-up
		if (Input.GetKeyUp ("o")){ /* IMPLEMENTED */
			moveScript.End(); // end this manipulation
			modus = Modi.CHO_MAN;
			
		}
		
		if(lastHooveredGameObject && (ObjectScript) lastHooveredGameObject.GetComponent("ObjectScript"))
			((ObjectScript) lastHooveredGameObject.GetComponent("ObjectScript")).hooverThis(false);
	
		GameObject newParent = raycastscript.getTargetObjects(Input.mousePosition, playerCam.camera);
		if(newParent != null){		/* TODO: Not implemented -> Needed? */	
			lastHooveredGameObject = newParent;
			if(((ObjectScript) newParent.GetComponent("ObjectScript")))
				((ObjectScript) newParent.GetComponent("ObjectScript")).hooverThis(true);			
		
			if (Input.GetButton("Fire1")) //click 
				moveScript.changeStackParent(selectieScript.lastGameObjectHit, newParent);
		}
		else
			lastHooveredGameObject = null;
	}
	private void updateRotatingManipulation(){
		if (Input.GetKey("left"))
			rotateScript.RotateLeft();
		if (Input.GetKey("right"))
			rotateScript.RotateRight();
		if (Input.GetKeyUp("o")){
			rotateScript.End(); // end this manipulation
			modus = Modi.CHO_MAN;
		}
		
		checkForNewSelection();
	}
	private void updateScalingManipulation(){
		if (Input.GetKey("down"))
			scaleScript.ScaleKleiner();
		if (Input.GetKey("up"))
			scaleScript.ScaleGroter();
		if (Input.GetKey("p"))
			scaleScript.volgendeAs();
		if (Input.GetKeyUp("p"))
			scaleScript.releaseLock();
		if (Input.GetKeyUp("o")){
			scaleScript.End(); // end this manipulation
			modus = Modi.CHO_MAN;
		}		
		
		checkForNewSelection();
	}
Beispiel #17
0
    private void updateMovingManipulation()
    {
        if (moveScript.gridModus)
        {
            if (Input.GetKeyUp("left"))
            {
                moveScript.goToNextAvailablePositionLeft();
            }
            if (Input.GetKeyUp("right"))
            {
                moveScript.goToNextAvailablePositionRight();
            }
            if (Input.GetKeyUp("up"))
            {
                moveScript.goToNextAvailablePositionTop();
            }
            if (Input.GetKeyUp("down"))
            {
                moveScript.goToNextAvailablePositionDown();
            }
        }
        else
        {
            if (Input.GetKey("left"))
            {
                moveScript.goToLeft();
            }
            if (Input.GetKey("right"))
            {
                moveScript.goToRight();
            }
            if (Input.GetKey("up"))
            {
                moveScript.goToTop();
            }
            if (Input.GetKey("down"))
            {
                moveScript.goToBottom();
            }
        }
        if (Input.GetKeyUp("i") && moveScript.gridModus) /* WIIMOTE | NOT IMPLEMENTED */
        {
            moveScript.goToNextAvailablePosition();      // scrolling  left-right, bottom-up
        }
        if (Input.GetKeyUp("o"))                         /* IMPLEMENTED */
        {
            moveScript.End();                            // end this manipulation
            modus = Modi.CHO_MAN;
        }

        if (lastHooveredGameObject && (ObjectScript)lastHooveredGameObject.GetComponent("ObjectScript"))
        {
            ((ObjectScript)lastHooveredGameObject.GetComponent("ObjectScript")).hooverThis(false);
        }

        GameObject newParent = raycastscript.getTargetObjects(Input.mousePosition, playerCam.camera);

        if (newParent != null)                  /* TODO: Not implemented -> Needed? */
        {
            lastHooveredGameObject = newParent;
            if (((ObjectScript)newParent.GetComponent("ObjectScript")))
            {
                ((ObjectScript)newParent.GetComponent("ObjectScript")).hooverThis(true);
            }

            if (Input.GetButton("Fire1"))             //click
            {
                moveScript.changeStackParent(selectieScript.lastGameObjectHit, newParent);
            }
        }
        else
        {
            lastHooveredGameObject = null;
        }
    }
	void FixedUpdate(){
		wiimoteCount = wiimote_count();
		if (wiimoteCount > 0)
		{
			//Nota: alleen 1 wiimote is rekening mee gehouden, 2x privates nodig voor 2e of afwisselend behandelen
			x = wiimote_getAccX(0);
			y = wiimote_getAccY(0);
			z = wiimote_getAccZ(0);
			roll = Mathf.Round(wiimote_getRoll(0) + rollFudge);
			pitch = Mathf.Round(wiimote_getPitch(0) + pitchFudge);
			yaw = Mathf.Round(wiimote_getYaw(0));
			
			//Orientation vectors				
			if (!float.IsNaN(roll) && !float.IsNaN(pitch)) {
					vec = new Vector3(pitch, 0 , -1 * roll);
/*					vec = new Vector3(pitch, yaw , -1 * roll);*/
					vec = Vector3.Lerp(oldVec, vec, Time.deltaTime * sensitivity);
					oldVec = vec;
				}

			/* ir Gui  */
			ir_x = wiimote_getIrX(0);
			ir_y = wiimote_getIrY(0);
			//F**k off basic zooi die er al was, Jens coming through
			if ( (ir_x != -100) && (ir_y != -100) ) {
				temp_x = (ir_x + 1)/2;
				temp_y = (ir_y + 1)/2;
				screenpointer.transform.position = new Vector3(temp_x, temp_y, 0);
			}
			
			//Updaten van muispointers
			selectieScript.updateSelection(temp_x * Screen.width, temp_y * Screen.height);
			smoothCameraScript.UpdateCamera();
			
			//wanneer we gemerkt hebben dat de gebruiker in topview een vloer heeft geselecteerd, zetten we hem eerst terug op de grond voor iets anders te doen
			//de camera gaat in de smoothcamerascript de gebruiker terug in een draaiende beweging in het midden van de geselecteerde kamer zetten
			if(moveToSelectedRoom){
				smoothCameraScript.goToRoom(selectieScript.lastGameObjectHit.transform.position);
				modus = Modi.NAV_SEL;
				topview = false;
			}
			//Hier komen alle eigen manipulaties
			
			/*Klikken op A en B */ //TODO:single - pulse - klik :/
			if (wiimote_getButtonA(0) && wiimote_getButtonB(0) && !buttonpulse)
			{
				buttonpulse = true;
				switch(modus){
					//TOONT HET MENU in selectie of manipulatiemode
					case Modi.NAV_SEL: //In selectiemodus: klikken = selecteren
							if(selectieScript.GUIShown)
							{
								selectieScript.hideUI();
								selectieScript.GUIShown = false;
								modus = Modi.NAV_SEL;
							}
							else{
								ObjectScript script = (ObjectScript)selectieScript.lastGameObjectHit.GetComponent("ObjectScript");
								string[] choices = {"Geen keuzes"};
								if (script != null)
									choices = script.getObjectPossibilities();
								selectieScript.showUi(temp_x * Screen.width, temp_y * Screen.height, choices);
								selectieScript.GUIShown = true;
								modus = Modi.CHO_MAN;
							}
						break;
					case Modi.CHO_MAN:
						//Zelfde als selectie -> terug naar nav gaan
						if(selectieScript.GUIShown)
						{
							selectieScript.hideUI();
							selectieScript.GUIShown = false;
							modus = Modi.NAV_SEL;
						}
						else{
							ObjectScript script = (ObjectScript)selectieScript.lastGameObjectHit.GetComponent("ObjectScript");
							string[] choices = {"Geen keuzes"};
							if (script != null)
								choices = script.getObjectPossibilities();
							selectieScript.showUi(temp_x * Screen.width, temp_y * Screen.height, choices);
							selectieScript.GUIShown = true;
							modus = Modi.CHO_MAN;
						}
						break;
					case Modi.MOV:
						GameObject newParent = raycastscript.getTargetObjects(new Vector3(temp_x * Screen.width, temp_y * Screen.height, 0), playerCam.camera);
						if (newParent != null && newParent != selectieScript.lastGameObjectHit){
							moveScript.changeStackParent(selectieScript.lastGameObjectHit, newParent);
						}
						break;
				}
			}else if (wiimote_getButtonA(0)) //Alleen A ingedrukt = menu kiezen
			{
				//buttonpulse = true;
				if (selectieScript.lastGameObjectHit && modus == Modi.CHO_MAN){
					//Recalculate the gui pixel values from ir values
					float realvalX = temp_x * Screen.width;
					float realvalY = temp_y * Screen.height;
					Debug.Log(selectieScript.getButtonOnPosition(realvalX, realvalY));
					if (selectieScript.getButtonOnPosition(realvalX, realvalY) == "Move"){		
						Debug.Log("Move change parent");	
						rotateScript.End();
						scaleScript.End();
						stackScript.End();					
						modus = Modi.MOV;
						moveScript.Begin(selectieScript.lastGameObjectHit);	
					}
					else if (selectieScript.getButtonOnPosition(realvalX, realvalY) == "Rotate"){
						Debug.Log("rotate");
						scaleScript.End();
						stackScript.End();
						moveScript.End();
						smoothCameraScript.GaNaarVorigePositie();												
						modus = Modi.ROT;
						rotateScript.Begin(selectieScript.lastGameObjectHit);
					}
					else if (selectieScript.getButtonOnPosition(realvalX, realvalY) == "Add"){
						Debug.Log("stack");
						rotateScript.End();
						scaleScript.End();
						moveScript.End();								
						modus = Modi.STA;	
						stackScript.Begin(selectieScript.lastGameObjectHit);
					}
					else if (selectieScript.getButtonOnPosition(realvalX, realvalY) == "Delete"){
						Debug.Log("remove");
						rotateScript.End();
						scaleScript.End();
						stackScript.End();
						moveScript.End();								
						//modus = Modi.DEL;	//Niet nodig: alles gebeurt hier
						verwijderScript.DeleteObject(selectieScript.lastGameObjectHit);
						selectieScript.lastGameObjectHit = null;
						selectieScript.hideUI();
						selectieScript.GUIShown = false;
						modus = Modi.NAV_SEL;
					}
					else if (selectieScript.getButtonOnPosition(realvalX, realvalY) == "Scale"){
						Debug.Log("scale");
						rotateScript.End();
						stackScript.End();
						moveScript.End();
						smoothCameraScript.GaNaarVorigePositie();									
						modus = Modi.SCA;		
						scaleScript.Begin(selectieScript.lastGameObjectHit);
					}							
				}
			}else if(wiimote_getButtonB(0)){
				//buttonpulse = true;
				//Alleen knop B: niks in zetten dat al in A+B zit -> conflicten
			}else{
				//Geen knop ingedrukt
				buttonpulse = false;
			}
			
			if (wiimote_getButtonMinus(0) && !minbuttonpulse) //Terug naar vorige modus
			{
				minbuttonpulse = true;
				if (modus == Modi.NAV_SEL){
					smoothCameraScript.returnFromTopview2();
					topview = false;
				}
				else if (modus == Modi.MOV){ //FROM move TO choicemodus
					moveScript.End();
					modus = Modi.NAV_SEL; 
				}
				else if (modus == Modi.ROT){
					rotateScript.End();
					modus = Modi.NAV_SEL; 
				}
				else if (modus == Modi.SCA){
					scaleScript.End();
					modus = Modi.NAV_SEL; 
				}
				else if (modus == Modi.STA){
					stackScript.End();
					modus = Modi.NAV_SEL; 
				}
			}else{
				minbuttonpulse = false;
			}
			
			if (wiimote_getButtonPlus(0) )
			{
				if(modus == Modi.NAV_SEL){
						if (topview){
							if(selectieScript.lastGameObjectHit != null && selectieScript.lastGameObjectHit.tag == "vloer"){
								moveToSelectedRoom = true;
								returnToCamShowAfterManipulation = false;
								topview = false;
							}

							else if(selectieScript.lastGameObjectHit != null && selectieScript.lastGameObjectHit.tag != "vloer"){
								moveToSelectedRoom = false;
								returnToCamShowAfterManipulation = true;
								topview = true;
							}

							else if(selectieScript.lastGameObjectHit == null){
								returnToCamShowAfterManipulation = false;
								moveToSelectedRoom = false;
								topview = true;
							}
						}
				}
				if (modus == Modi.SCA && !plusbuttonpulse){
					plusbuttonpulse = true;
					scaleScript.releaseLock();
					scaleScript.volgendeAs();
				}
			}else{
				plusbuttonpulse = false;
			}
			
			if (wiimote_getButtonHome(0) && !homebuttonpulse){ //Abort all
				homebuttonpulse = true;
				Debug.Log("Abort");
				rotateScript.End();
				scaleScript.End();
				stackScript.Abort();
				moveScript.End();
				smoothCameraScript.GaNaarVorigePositie();
				modus = Modi.NAV_SEL;
				selectieScript.hideUI();
				selectieScript.GUIShown = false;
				topview = false;
			}else{
				homebuttonpulse = false;
			}
			
			if (wiimote_getButton1(0) && !button1pulse){ //Wisselen van camhoek
				button1pulse = true;
				if (modus == Modi.NAV_SEL){
					smoothCameraScript.getNextCameraLokatie();
				}
			}else{
				button1pulse = false;
			}
			
			if (wiimote_getButton2(0) && !button1pulse){ //Wisselen van camhoek
				button2pulse = true;
				if (modus == Modi.NAV_SEL){
					smoothCameraScript.getVorigCameraLokatie();
				}
			}else{
				button2pulse = false;
			}
			
			if (wiimote_getButtonLeft(0)){
				padbuttonpulse = true;
				if (modus == Modi.NAV_SEL)
					moveCameraLeft();
				else if (modus == Modi.MOV){
					if (moveScript.gridModus)
						moveScript.goToNextAvailablePositionLeft();	
					else
						moveScript.goToLeft();	
				}
				else if (modus == Modi.ROT){
					rotateScript.RotateLeft();
				}
				else if (modus == Modi.STA ){
					if (stackScript.isActive){
						if (stackScript.gridModus){
							stackScript.goToNextAvailablePositionLeft();
						}
						else{
							stackScript.goToLeft();	
						}
					}
				}		
			}
			else if (wiimote_getButtonRight(0)){
				padbuttonpulse = true;
				if (modus == Modi.NAV_SEL)
					moveCameraRight();
				else if (modus == Modi.MOV){
					if (moveScript.gridModus)
						moveScript.goToNextAvailablePositionRight();	
					else
						moveScript.goToRight();	
				}
				else if (modus == Modi.ROT){
					rotateScript.RotateRight();
				}
				else if (modus == Modi.STA){
					if (stackScript.isActive){
						if (stackScript.gridModus){
							stackScript.goToNextAvailablePositionRight();
						}
						else{
							stackScript.goToRight();	
						}
					}
				}
			}
			else if (wiimote_getButtonUp(0)){
				padbuttonpulse = true;
				if (modus == Modi.NAV_SEL && !topview)
					moveCameraForward();
				else if (modus == Modi.MOV){
					if (moveScript.gridModus)
						moveScript.goToNextAvailablePositionTop();	
					else
						moveScript.goToTop();	
				}
				else if (modus == Modi.STA){
					if (stackScript.isActive){
						if (stackScript.gridModus){
							stackScript.goToNextAvailablePositionTop();
						}
						else{
							stackScript.goToTop();	
						}
					}
				}
			}
			else if (wiimote_getButtonDown(0)){
				padbuttonpulse = true;
				if (modus == Modi.NAV_SEL && !topview)
					moveCameraBackward();
				else if (modus == Modi.MOV){
					if (moveScript.gridModus)
						moveScript.goToNextAvailablePositionDown();	
					else
						moveScript.goToBottom();	
				}
				else if (modus == Modi.STA){
					if (stackScript.isActive){
						if (stackScript.gridModus){
							stackScript.goToNextAvailablePositionDown();
						}
						else{
							stackScript.goToBottom();	
						}
					}
				}
			}else{
				padbuttonpulse = false;
			}
			
			//TODO: roll moet 0.5 sec ingehouden worden voordat deze reageert
			//Dus: functie aanroepen die 0.5 sec telt en dan pas bool op false zet
			if (!checkRollOutOfBounds()){
				Debug.Log("Roll in bounds");
				if (roll <= -20 ){ //Wiimote links kantelen
					if (modus == Modi.NAV_SEL && !topview && !rollpulse){ //In navigatie
						rollpulse = true;	
						rotateCameraLeft90Degrees();
					}
					else if (modus == Modi.ROT){
						rotateScript.RotateLeft();
					}
					else if (modus == Modi.STA && !rollpulse){
						rollpulse = true;
						if (stackScript.isActive){
							stackScript.goToNextPossibleStackedObject();
						}
					}else if (modus == Modi.CHO_MAN && !rollpulse){
						rollpulse = true;
						selectieScript.getNextChild();
					}
				}else if (roll >= 120){ //Wiimote rechts kantelen
					if (modus == Modi.NAV_SEL && !topview && !rollpulse){
						rollpulse = true;
						rotateCameraRight90Degrees();
					}	
					else if (modus == Modi.ROT){
						rotateScript.RotateRight();
					}
					else if (modus == Modi.STA && !rollpulse){
						rollpulse = true;
						if (stackScript.isActive)
							stackScript.goToNextPossibleStackedObject();
					}
				}
				else{
					rollpulse = false;
				}
			}
			
			//Pitch gebruiken voor schaleren
			if (!checkPitchOutOfBounds()){
				Debug.Log("Pitch in bounds");
				if (pitch <= -30){ //Wiimote licht recht houden
					if (modus == Modi.SCA)
						scaleScript.ScaleGroter();
				}else if (pitch >= 100 ) { //TESTEN!
					if (modus == Modi.SCA)
						scaleScript.ScaleKleiner();
				}
						
				if (pitch <= -70 && !topview){
					if (modus == Modi.NAV_SEL && checkRollOutOfBounds()){
						smoothCameraScript.GaNaarTopView();
						topview = true;
					}
				}
			}
				
			//Laatste check om te zien of selectiemode aan of uit moet (anders ingewikkeld in overzetten)
			//Reden: nu per key -> dan naar navigatie gemapt wegens wiimote - issues
			if(modus == Modi.NAV_SEL || modus == Modi.CHO_MAN)
				selectieScript.setSelectionmodeOn();
			else{
				selectieScript.setSelectionmodeOff();
				selectieScript.guiscript.hideGui();
				}
				
		}
		
		//Debug
		if (showDebugGUI)
			DoDebugStr(0);	
	}
    // Use this for initialization
    void Start()
    {
        //Init controllers
        wiimote_start();

        //Turn off mouse pointer and set the cursorImage
        screenpointer = (GUITexture)Instantiate(baseGuiTexture);
        Cursor.visible = false;
        screenpointer.texture = cursorImage;
        screenpointer.color = Color.red;
        screenpointer.pixelInset = new Rect(10,10,10,10);
        screenpointer.transform.localScale -= new Vector3(1,1,0);

        //Set ref scripts
        raycastscript = gameObject.GetComponent("RayCastScript") as RayCastScript;
        rotateScript = gameObject.GetComponent("RotateScript") as RotateScript;
        scaleScript = gameObject.GetComponent("ScaleScript") as ScaleScript;
        stackScript = gameObject.GetComponent("StackScript") as StackScript;
        moveScript = gameObject.GetComponent("MoveScript") as MoveScript;
        smoothCameraScript = gameObject.GetComponent("SmoothCameraScript") as SmoothCameraScript;
        verwijderScript = gameObject.GetComponent("VerwijderScript") as VerwijderScript;
        selectieScript = gameObject.GetComponent("SelectieScript") as SelectieScript;

        //Set initial values
        selectieScript.setSelectionmodeOn();
        selectieScript.playerCam = playerCam;
        modus = Modi.NAV_SEL;
    }
 /// <summary>
 /// Initializes a new instance of the <see cref="ChannelConfigurationResponseEventArgs" /> class.
 /// </summary>
 /// <param name="channel">The channel.</param>
 /// <param name="modi">The modi input.</param>
 public ChannelConfigurationResponseEventArgs(uint channel, Modi modi)
 {
     this.Channel = channel;
     this.Modi    = modi;
 }
	private void updateStackingManipulation(){
		if(stackScript.isActive){
			if(stackScript.gridModus){
				if (Input.GetKeyUp("left"))
					stackScript.goToNextAvailablePositionLeft();	
				if (Input.GetKeyUp("right"))
					stackScript.goToNextAvailablePositionRight();
				if (Input.GetKeyUp("up"))
					stackScript.goToNextAvailablePositionTop();
				if (Input.GetKeyUp("down"))
					stackScript.goToNextAvailablePositionDown();
			}else{
				if (Input.GetKey("left"))
					stackScript.goToLeft();	
				if (Input.GetKey("right"))
					stackScript.goToRight();
				if (Input.GetKey("up"))
					stackScript.goToTop();
				if (Input.GetKey("down"))
					stackScript.goToBottom();
			}			
				
			if (Input.GetKeyUp ("k") && stackScript.gridModus) //TODO: NOT IMPLEMENTED
				stackScript.goToNextAvailablePosition(); // scrolling  left-right, bottom-up
			if (Input.GetKeyUp ("i"))
				stackScript.goToNextPossibleStackedObject(); // scrolling between possible object
			if (Input.GetKeyUp ("o")){
				stackScript.End(); // end this manipulation
				modus = Modi.CHO_MAN;
			}
		}	
	}
	private void updateDeletingManipulation(){
		verwijderScript.DeleteObject(selectieScript.lastGameObjectHit);
		selectieScript.lastGameObjectHit = null;	
		modus = Modi.NAV_SEL;
		checkForNewSelection();
	}
	// Update is called once per frame
	void Update () {
		//Laat hier temp staan OVERGEZET
		selectieScript.updateSelection(Input.mousePosition.x, Input.mousePosition.y);
		smoothCameraScript.UpdateCamera();
	
		//check of we een nieuwe kamer geselecteerd hebben vanuit topview en navigeer daarnaar
		/* OVERZETTEN */
		if(moveToSelectedRoom){
			smoothCameraScript.goToRoom(selectieScript.lastGameObjectHit.transform.position);
			modus = Modi.NAV_SEL;
		}
		
		/*OVERGEZET*/
		// aborting modus
		if (Input.GetKeyUp("q")){			
			Debug.Log("Abort");
			rotateScript.End();
			scaleScript.End();
			stackScript.Abort();
			moveScript.End();
			
			if(returnToCamShowAfterManipulation)
				modus = Modi.CAM_SHO;
			else {
				smoothCameraScript.GaNaarVorigePositie();		
				modus = Modi.NAV_SEL;
			}
				
			deselectAll();		
		} 
		// go to moving/changing parent modus
		else if(selectieScript.lastGameObjectHit && modus == Modi.CHO_MAN && Input.GetButtonUp("Fire1")) {
			Debug.Log(selectieScript.getButtonOnPosition(Input.mousePosition.x, Input.mousePosition.y));
			if (selectieScript.getButtonOnPosition(Input.mousePosition.x, Input.mousePosition.y) == "Move"){		
				Debug.Log("Move change parent");	
				rotateScript.End();
				scaleScript.End();
				stackScript.End();
			
				modus = Modi.MOV;
				moveScript.Begin(selectieScript.lastGameObjectHit);	
			}
			else if (selectieScript.getButtonOnPosition(Input.mousePosition.x, Input.mousePosition.y) == "Rotate"){
				Debug.Log("rotate");
				scaleScript.End();
				stackScript.End();
				moveScript.End();
				smoothCameraScript.GaNaarVorigePositie();			
							
				modus = Modi.ROT;
				rotateScript.Begin(selectieScript.lastGameObjectHit);
			}
			else if (selectieScript.getButtonOnPosition(Input.mousePosition.x, Input.mousePosition.y) == "Add"){
				Debug.Log("stack");
				rotateScript.End();
				scaleScript.End();
				moveScript.End();			
				
				modus = Modi.STA;	
				stackScript.Begin(selectieScript.lastGameObjectHit);
			}
			else if (selectieScript.getButtonOnPosition(Input.mousePosition.x, Input.mousePosition.y) == "Delete"){
				Debug.Log("remove");
				rotateScript.End();
				scaleScript.End();
				stackScript.End();
				moveScript.End();			
			
				modus = Modi.DEL;	
			}
			else if (selectieScript.getButtonOnPosition(Input.mousePosition.x, Input.mousePosition.y) == "Scale"){
				Debug.Log("scale");
				rotateScript.End();
				stackScript.End();
				moveScript.End();
				smoothCameraScript.GaNaarVorigePositie();			
				
				modus = Modi.SCA;		
				scaleScript.Begin(selectieScript.lastGameObjectHit);
			}
		// go to scale modus
		} else if(selectieScript.lastGameObjectHit && modus == Modi.CHO_MAN && Input.GetKeyUp("e")){		
			Debug.Log("scale");
			rotateScript.End();
			stackScript.End();
			moveScript.End();
			smoothCameraScript.GaNaarVorigePositie();			
				
			modus = Modi.SCA;		
			scaleScript.Begin(selectieScript.lastGameObjectHit);
		// go to rotate modus		
		}  else if(selectieScript.lastGameObjectHit && modus == Modi.CHO_MAN && Input.GetKeyUp("r")){		
			Debug.Log("rotate");
			scaleScript.End();
			stackScript.End();
			moveScript.End();
			smoothCameraScript.GaNaarVorigePositie();			
						
			modus = Modi.ROT;
			rotateScript.Begin(selectieScript.lastGameObjectHit);
		// go to stacking modus
		} else if(selectieScript.lastGameObjectHit && modus == Modi.CHO_MAN && Input.GetKeyUp("t")){		
			Debug.Log("stack");
			rotateScript.End();
			scaleScript.End();
			moveScript.End();			
			
			modus = Modi.STA;	
			stackScript.Begin(selectieScript.lastGameObjectHit);
		// go to removing status
		} else if(selectieScript.lastGameObjectHit && modus == Modi.CHO_MAN && Input.GetKeyUp("y")){	
			Debug.Log("remove");
			rotateScript.End();
			scaleScript.End();
			stackScript.End();
			moveScript.End();			
			
			modus = Modi.DEL;	
		// go to slideshow modus
		} else if(Input.GetKeyUp("u")){			
			Debug.Log("slideshow");
			rotateScript.End();
			scaleScript.End();
			stackScript.End();
			moveScript.End();			
			
			deselectAll();
			smoothCameraScript.getNextCameraLokatie();
			modus = Modi.CAM_SHO;	
		} 
		
		//Select an object
		if (modus == Modi.CHO_MAN || modus == Modi.NAV_SEL){
			if(selectieScript.isActive && Input.GetButtonUp("Fire1")){
				if(selectieScript.GUIShown)
				{
					selectieScript.hideUI();
					selectieScript.GUIShown = false;
					modus = Modi.NAV_SEL;
				}
				else
				{
					ObjectScript script = (ObjectScript)selectieScript.lastGameObjectHit.GetComponent("ObjectScript");
					string[] choices={ "Geen keuzes"}; //wordt overreden indien niet null
					if (script != null){
						choices = script.getObjectPossibilities();
					}
					selectieScript.showUi(Input.mousePosition.x, Input.mousePosition.y, choices);
					selectieScript.GUIShown = true;
					modus = Modi.CHO_MAN;
				}
			}
			/*
			selectieScript.fireEvent = true; //Vuur een clickevent af in selectie
			//TODO: if object selected?
			if(selectieScript.lastGameObjectHit != null){
				Debug.Log("Naar manipulatiemode");
				modus = Modi.CHO_MAN;
				}*/
		}
		
		//DEEL PER DEEL DOEN -> KNOP PER KNOP IN WIIMOTE | STAAT "DONE" NA UPDATEFUNCT. INDIEN GEIMPLEMENTEERD
		switch(modus){
			case Modi.NAV_SEL: /* DONE  */
				selectieScript.setSelectionmodeOn();
				updateNavigation();
				break;
			case Modi.CHO_MAN: /* DONE  */
				selectieScript.setSelectionmodeOn();
				updateManipulationChoosing();
				break;
			case Modi.MOV: /* DONE - TOTEST */ 
				selectieScript.setSelectionmodeOff();
				updateMovingManipulation();
				selectieScript.guiscript.hideGui();
				break;
			case Modi.ROT: /* DONE - TOTEST */
				selectieScript.setSelectionmodeOff();
				updateRotatingManipulation();
				selectieScript.guiscript.hideGui();
				break;
			case Modi.SCA: /* DONE - TOTEST */ 
				selectieScript.setSelectionmodeOff();
				updateScalingManipulation();
				selectieScript.guiscript.hideGui();
				break;
			case Modi.STA: /* DONE - TOTEST */
				selectieScript.setSelectionmodeOff();
				updateStackingManipulation();
				selectieScript.guiscript.hideGui();
				break;
			case Modi.DEL: /* DONE - TOTEST */
				selectieScript.setSelectionmodeOff();
				updateDeletingManipulation();
				selectieScript.guiscript.hideGui();
				break;
			case Modi.CAM_SHO: /* DONE |MERGED WITH NAV_SEL | TOTEST */
				//selectieScript.setSelectionmodeOn();
				updateCameraShow();
				//selectieScript.guiscript.hideGui();
				break;
		}
		
		//Set the gui shizzle
		Vector3 mousePos= Input.mousePosition;
		float mouseX = mousePos.x/Screen.width;
		float mouseY = mousePos.y/Screen.height;
		screenpointer.transform.position = new Vector3(mouseX, mouseY, 0);
		Rect cursloc = new Rect(mousePos.x, Screen.height - mousePos.y, cursorImage.width, cursorImage.height);
	}
        private void Window1_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            if ((_mode & Modi.HelpShown) != 0 && !(Keyboard.Modifiers == ModifierKeys.None && (e.Key == Key.H || e.Key == Key.I || e.Key == Key.F1)))
            {
                Label2.Visibility = Visibility.Hidden;
                _mode            &= ~Modi.HelpShown;
                return;
            }

            if (Keyboard.Modifiers == ModifierKeys.None)
            {
                switch (e.Key)
                {
                case Key.H:
                case Key.I:
                case Key.F1:
                    ShopHelpText();
                    break;

                case Key.Escape:
                    if ((_mode & Modi.Slideshow) != 0)
                    {
                        StopSlideshow(2);
                    }
                    else
                    {
                        Close();
                    }
                    break;

                case Key.Left:
                    if (_currentFileIndex > 0)
                    {
                        _currentFileIndex--;
                        ResetZoomLevel();
                        SetImage();
                    }
                    break;

                case Key.Right:
                    if (_currentFileIndex < _fileList.Count() - 1)
                    {
                        _currentFileIndex++;
                        ResetZoomLevel();
                        SetImage();
                    }
                    break;

                case Key.Home:
                    if (_currentFileIndex > 0)
                    {
                        _currentFileIndex = 0;
                        ResetZoomLevel();
                        SetImage();
                    }
                    break;

                case Key.End:
                    if (_currentFileIndex < _fileList.Count() - 1)
                    {
                        _currentFileIndex = _fileList.Count() - 1;
                        ResetZoomLevel();
                        SetImage();
                    }
                    break;

                case Key.Space:
                    if ((_mode & Modi.Zoom) != 0)
                    {
                        ResetZoomLevel();
                    }
                    else
                    {
                        if (_isSlideshowRunning)
                        {
                            StopSlideshow(1);
                        }
                        else
                        {
                            StartSlideshow(true);
                        }
                    }
                    break;

                case Key.Add:
                case Key.OemPlus:
                    Zoom(1);
                    break;

                case Key.Subtract:
                case Key.OemMinus:
                    Zoom(-1);
                    break;

                case Key.PageDown:
                    if (_imageDurationSeconds > 1)
                    {
                        _imageDurationSeconds--;
                    }
                    ShowMessage($"Image duration: {_imageDurationSeconds} sec");
                    StartSlideshow(false);
                    break;

                case Key.PageUp:
                    if (_imageDurationSeconds < 30)
                    {
                        _imageDurationSeconds++;
                    }
                    ShowMessage($"Image duration: {_imageDurationSeconds} sec");
                    StartSlideshow(false);
                    break;

                default:
                    break;
                }
            }
            else if (Keyboard.Modifiers == ModifierKeys.Alt)
            {
                switch (e.SystemKey)
                {
                case Key.Left:
                    AdjustKeyboardVector(-1, 0);
                    MoveToNewPosition(_kv);
                    break;

                case Key.Right:
                    AdjustKeyboardVector(1, 0);
                    MoveToNewPosition(_kv);
                    break;

                case Key.Up:
                    AdjustKeyboardVector(0, -1);
                    MoveToNewPosition(_kv);
                    break;

                case Key.Down:
                    AdjustKeyboardVector(0, 1);
                    MoveToNewPosition(_kv);
                    break;

                default:
                    if (_isImageLoaded)
                    {
                        var tt = (TranslateTransform)((TransformGroup)Media1.RenderTransform).Children.First(tr => tr is TranslateTransform);
                        _origin = new Point(0, 0);
                        _kv     = new Vector(-tt.X, -tt.Y);
                    }
                    break;
                }
            }
        }
    void FixedUpdate()
    {
        wiimoteCount = wiimote_count();
        if (wiimoteCount > 0)
        {
            //Nota: alleen 1 wiimote is rekening mee gehouden, 2x privates nodig voor 2e of afwisselend behandelen
            x     = wiimote_getAccX(0);
            y     = wiimote_getAccY(0);
            z     = wiimote_getAccZ(0);
            roll  = Mathf.Round(wiimote_getRoll(0) + rollFudge);
            pitch = Mathf.Round(wiimote_getPitch(0) + pitchFudge);
            yaw   = Mathf.Round(wiimote_getYaw(0));

            //Orientation vectors
            if (!float.IsNaN(roll) && !float.IsNaN(pitch))
            {
                vec = new Vector3(pitch, 0, -1 * roll);
/*					vec = new Vector3(pitch, yaw , -1 * roll);*/
                vec    = Vector3.Lerp(oldVec, vec, Time.deltaTime * sensitivity);
                oldVec = vec;
            }

            /* ir Gui  */
            ir_x = wiimote_getIrX(0);
            ir_y = wiimote_getIrY(0);
            //F**k off basic zooi die er al was, Jens coming through
            if ((ir_x != -100) && (ir_y != -100))
            {
                temp_x = (ir_x + 1) / 2;
                temp_y = (ir_y + 1) / 2;
                screenpointer.transform.position = new Vector3(temp_x, temp_y, 0);
            }

            //Updaten van muispointers
            selectieScript.updateSelection(temp_x * Screen.width, temp_y * Screen.height);
            smoothCameraScript.UpdateCamera();

            //wanneer we gemerkt hebben dat de gebruiker in topview een vloer heeft geselecteerd, zetten we hem eerst terug op de grond voor iets anders te doen
            //de camera gaat in de smoothcamerascript de gebruiker terug in een draaiende beweging in het midden van de geselecteerde kamer zetten
            if (moveToSelectedRoom)
            {
                smoothCameraScript.goToRoom(selectieScript.lastGameObjectHit.transform.position);
                modus   = Modi.NAV_SEL;
                topview = false;
            }
            //Hier komen alle eigen manipulaties

            /*Klikken op A en B */             //TODO:single - pulse - klik :/
            if (wiimote_getButtonA(0) && wiimote_getButtonB(0) && !buttonpulse)
            {
                buttonpulse = true;
                switch (modus)
                {
                //TOONT HET MENU in selectie of manipulatiemode
                case Modi.NAV_SEL:                         //In selectiemodus: klikken = selecteren
                    if (selectieScript.GUIShown)
                    {
                        selectieScript.hideUI();
                        selectieScript.GUIShown = false;
                        modus = Modi.NAV_SEL;
                    }
                    else
                    {
                        ObjectScript script  = (ObjectScript)selectieScript.lastGameObjectHit.GetComponent("ObjectScript");
                        string[]     choices = { "Geen keuzes" };
                        if (script != null)
                        {
                            choices = script.getObjectPossibilities();
                        }
                        selectieScript.showUi(temp_x * Screen.width, temp_y * Screen.height, choices);
                        selectieScript.GUIShown = true;
                        modus = Modi.CHO_MAN;
                    }
                    break;

                case Modi.CHO_MAN:
                    //Zelfde als selectie -> terug naar nav gaan
                    if (selectieScript.GUIShown)
                    {
                        selectieScript.hideUI();
                        selectieScript.GUIShown = false;
                        modus = Modi.NAV_SEL;
                    }
                    else
                    {
                        ObjectScript script  = (ObjectScript)selectieScript.lastGameObjectHit.GetComponent("ObjectScript");
                        string[]     choices = { "Geen keuzes" };
                        if (script != null)
                        {
                            choices = script.getObjectPossibilities();
                        }
                        selectieScript.showUi(temp_x * Screen.width, temp_y * Screen.height, choices);
                        selectieScript.GUIShown = true;
                        modus = Modi.CHO_MAN;
                    }
                    break;

                case Modi.MOV:
                    GameObject newParent = raycastscript.getTargetObjects(new Vector3(temp_x * Screen.width, temp_y * Screen.height, 0), playerCam.camera);
                    if (newParent != null && newParent != selectieScript.lastGameObjectHit)
                    {
                        moveScript.changeStackParent(selectieScript.lastGameObjectHit, newParent);
                    }
                    break;
                }
            }
            else if (wiimote_getButtonA(0))              //Alleen A ingedrukt = menu kiezen
            {
                //buttonpulse = true;
                if (selectieScript.lastGameObjectHit && modus == Modi.CHO_MAN)
                {
                    //Recalculate the gui pixel values from ir values
                    float realvalX = temp_x * Screen.width;
                    float realvalY = temp_y * Screen.height;
                    Debug.Log(selectieScript.getButtonOnPosition(realvalX, realvalY));
                    if (selectieScript.getButtonOnPosition(realvalX, realvalY) == "Move")
                    {
                        Debug.Log("Move change parent");
                        rotateScript.End();
                        scaleScript.End();
                        stackScript.End();
                        modus = Modi.MOV;
                        moveScript.Begin(selectieScript.lastGameObjectHit);
                    }
                    else if (selectieScript.getButtonOnPosition(realvalX, realvalY) == "Rotate")
                    {
                        Debug.Log("rotate");
                        scaleScript.End();
                        stackScript.End();
                        moveScript.End();
                        smoothCameraScript.GaNaarVorigePositie();
                        modus = Modi.ROT;
                        rotateScript.Begin(selectieScript.lastGameObjectHit);
                    }
                    else if (selectieScript.getButtonOnPosition(realvalX, realvalY) == "Add")
                    {
                        Debug.Log("stack");
                        rotateScript.End();
                        scaleScript.End();
                        moveScript.End();
                        modus = Modi.STA;
                        stackScript.Begin(selectieScript.lastGameObjectHit);
                    }
                    else if (selectieScript.getButtonOnPosition(realvalX, realvalY) == "Delete")
                    {
                        Debug.Log("remove");
                        rotateScript.End();
                        scaleScript.End();
                        stackScript.End();
                        moveScript.End();
                        //modus = Modi.DEL;	//Niet nodig: alles gebeurt hier
                        verwijderScript.DeleteObject(selectieScript.lastGameObjectHit);
                        selectieScript.lastGameObjectHit = null;
                        selectieScript.hideUI();
                        selectieScript.GUIShown = false;
                        modus = Modi.NAV_SEL;
                    }
                    else if (selectieScript.getButtonOnPosition(realvalX, realvalY) == "Scale")
                    {
                        Debug.Log("scale");
                        rotateScript.End();
                        stackScript.End();
                        moveScript.End();
                        smoothCameraScript.GaNaarVorigePositie();
                        modus = Modi.SCA;
                        scaleScript.Begin(selectieScript.lastGameObjectHit);
                    }
                }
            }
            else if (wiimote_getButtonB(0))
            {
                //buttonpulse = true;
                //Alleen knop B: niks in zetten dat al in A+B zit -> conflicten
            }
            else
            {
                //Geen knop ingedrukt
                buttonpulse = false;
            }

            if (wiimote_getButtonMinus(0) && !minbuttonpulse)             //Terug naar vorige modus
            {
                minbuttonpulse = true;
                if (modus == Modi.NAV_SEL)
                {
                    smoothCameraScript.returnFromTopview2();
                    topview = false;
                }
                else if (modus == Modi.MOV)                  //FROM move TO choicemodus
                {
                    moveScript.End();
                    modus = Modi.NAV_SEL;
                }
                else if (modus == Modi.ROT)
                {
                    rotateScript.End();
                    modus = Modi.NAV_SEL;
                }
                else if (modus == Modi.SCA)
                {
                    scaleScript.End();
                    modus = Modi.NAV_SEL;
                }
                else if (modus == Modi.STA)
                {
                    stackScript.End();
                    modus = Modi.NAV_SEL;
                }
            }
            else
            {
                minbuttonpulse = false;
            }

            if (wiimote_getButtonPlus(0))
            {
                if (modus == Modi.NAV_SEL)
                {
                    if (topview)
                    {
                        if (selectieScript.lastGameObjectHit != null && selectieScript.lastGameObjectHit.tag == "vloer")
                        {
                            moveToSelectedRoom = true;
                            returnToCamShowAfterManipulation = false;
                            topview = false;
                        }

                        else if (selectieScript.lastGameObjectHit != null && selectieScript.lastGameObjectHit.tag != "vloer")
                        {
                            moveToSelectedRoom = false;
                            returnToCamShowAfterManipulation = true;
                            topview = true;
                        }

                        else if (selectieScript.lastGameObjectHit == null)
                        {
                            returnToCamShowAfterManipulation = false;
                            moveToSelectedRoom = false;
                            topview            = true;
                        }
                    }
                }
                if (modus == Modi.SCA && !plusbuttonpulse)
                {
                    plusbuttonpulse = true;
                    scaleScript.releaseLock();
                    scaleScript.volgendeAs();
                }
            }
            else
            {
                plusbuttonpulse = false;
            }

            if (wiimote_getButtonHome(0) && !homebuttonpulse)              //Abort all
            {
                homebuttonpulse = true;
                Debug.Log("Abort");
                rotateScript.End();
                scaleScript.End();
                stackScript.Abort();
                moveScript.End();
                smoothCameraScript.GaNaarVorigePositie();
                modus = Modi.NAV_SEL;
                selectieScript.hideUI();
                selectieScript.GUIShown = false;
                topview = false;
            }
            else
            {
                homebuttonpulse = false;
            }

            if (wiimote_getButton1(0) && !button1pulse)              //Wisselen van camhoek
            {
                button1pulse = true;
                if (modus == Modi.NAV_SEL)
                {
                    smoothCameraScript.getNextCameraLokatie();
                }
            }
            else
            {
                button1pulse = false;
            }

            if (wiimote_getButton2(0) && !button1pulse)              //Wisselen van camhoek
            {
                button2pulse = true;
                if (modus == Modi.NAV_SEL)
                {
                    smoothCameraScript.getVorigCameraLokatie();
                }
            }
            else
            {
                button2pulse = false;
            }

            if (wiimote_getButtonLeft(0))
            {
                padbuttonpulse = true;
                if (modus == Modi.NAV_SEL)
                {
                    moveCameraLeft();
                }
                else if (modus == Modi.MOV)
                {
                    if (moveScript.gridModus)
                    {
                        moveScript.goToNextAvailablePositionLeft();
                    }
                    else
                    {
                        moveScript.goToLeft();
                    }
                }
                else if (modus == Modi.ROT)
                {
                    rotateScript.RotateLeft();
                }
                else if (modus == Modi.STA)
                {
                    if (stackScript.isActive)
                    {
                        if (stackScript.gridModus)
                        {
                            stackScript.goToNextAvailablePositionLeft();
                        }
                        else
                        {
                            stackScript.goToLeft();
                        }
                    }
                }
            }
            else if (wiimote_getButtonRight(0))
            {
                padbuttonpulse = true;
                if (modus == Modi.NAV_SEL)
                {
                    moveCameraRight();
                }
                else if (modus == Modi.MOV)
                {
                    if (moveScript.gridModus)
                    {
                        moveScript.goToNextAvailablePositionRight();
                    }
                    else
                    {
                        moveScript.goToRight();
                    }
                }
                else if (modus == Modi.ROT)
                {
                    rotateScript.RotateRight();
                }
                else if (modus == Modi.STA)
                {
                    if (stackScript.isActive)
                    {
                        if (stackScript.gridModus)
                        {
                            stackScript.goToNextAvailablePositionRight();
                        }
                        else
                        {
                            stackScript.goToRight();
                        }
                    }
                }
            }
            else if (wiimote_getButtonUp(0))
            {
                padbuttonpulse = true;
                if (modus == Modi.NAV_SEL && !topview)
                {
                    moveCameraForward();
                }
                else if (modus == Modi.MOV)
                {
                    if (moveScript.gridModus)
                    {
                        moveScript.goToNextAvailablePositionTop();
                    }
                    else
                    {
                        moveScript.goToTop();
                    }
                }
                else if (modus == Modi.STA)
                {
                    if (stackScript.isActive)
                    {
                        if (stackScript.gridModus)
                        {
                            stackScript.goToNextAvailablePositionTop();
                        }
                        else
                        {
                            stackScript.goToTop();
                        }
                    }
                }
            }
            else if (wiimote_getButtonDown(0))
            {
                padbuttonpulse = true;
                if (modus == Modi.NAV_SEL && !topview)
                {
                    moveCameraBackward();
                }
                else if (modus == Modi.MOV)
                {
                    if (moveScript.gridModus)
                    {
                        moveScript.goToNextAvailablePositionDown();
                    }
                    else
                    {
                        moveScript.goToBottom();
                    }
                }
                else if (modus == Modi.STA)
                {
                    if (stackScript.isActive)
                    {
                        if (stackScript.gridModus)
                        {
                            stackScript.goToNextAvailablePositionDown();
                        }
                        else
                        {
                            stackScript.goToBottom();
                        }
                    }
                }
            }
            else
            {
                padbuttonpulse = false;
            }

            //TODO: roll moet 0.5 sec ingehouden worden voordat deze reageert
            //Dus: functie aanroepen die 0.5 sec telt en dan pas bool op false zet
            if (!checkRollOutOfBounds())
            {
                Debug.Log("Roll in bounds");
                if (roll <= -20)                                         //Wiimote links kantelen
                {
                    if (modus == Modi.NAV_SEL && !topview && !rollpulse) //In navigatie
                    {
                        rollpulse = true;
                        rotateCameraLeft90Degrees();
                    }
                    else if (modus == Modi.ROT)
                    {
                        rotateScript.RotateLeft();
                    }
                    else if (modus == Modi.STA && !rollpulse)
                    {
                        rollpulse = true;
                        if (stackScript.isActive)
                        {
                            stackScript.goToNextPossibleStackedObject();
                        }
                    }
                    else if (modus == Modi.CHO_MAN && !rollpulse)
                    {
                        rollpulse = true;
                        selectieScript.getNextChild();
                    }
                }
                else if (roll >= 120)                   //Wiimote rechts kantelen
                {
                    if (modus == Modi.NAV_SEL && !topview && !rollpulse)
                    {
                        rollpulse = true;
                        rotateCameraRight90Degrees();
                    }
                    else if (modus == Modi.ROT)
                    {
                        rotateScript.RotateRight();
                    }
                    else if (modus == Modi.STA && !rollpulse)
                    {
                        rollpulse = true;
                        if (stackScript.isActive)
                        {
                            stackScript.goToNextPossibleStackedObject();
                        }
                    }
                }
                else
                {
                    rollpulse = false;
                }
            }

            //Pitch gebruiken voor schaleren
            if (!checkPitchOutOfBounds())
            {
                Debug.Log("Pitch in bounds");
                if (pitch <= -30)                  //Wiimote licht recht houden
                {
                    if (modus == Modi.SCA)
                    {
                        scaleScript.ScaleGroter();
                    }
                }
                else if (pitch >= 100)                     //TESTEN!
                {
                    if (modus == Modi.SCA)
                    {
                        scaleScript.ScaleKleiner();
                    }
                }

                if (pitch <= -70 && !topview)
                {
                    if (modus == Modi.NAV_SEL && checkRollOutOfBounds())
                    {
                        smoothCameraScript.GaNaarTopView();
                        topview = true;
                    }
                }
            }

            //Laatste check om te zien of selectiemode aan of uit moet (anders ingewikkeld in overzetten)
            //Reden: nu per key -> dan naar navigatie gemapt wegens wiimote - issues
            if (modus == Modi.NAV_SEL || modus == Modi.CHO_MAN)
            {
                selectieScript.setSelectionmodeOn();
            }
            else
            {
                selectieScript.setSelectionmodeOff();
                selectieScript.guiscript.hideGui();
            }
        }

        //Debug
        if (showDebugGUI)
        {
            DoDebugStr(0);
        }
    }
 /// <summary>
 ///     Initializes a new instance of the <see cref="ChannelConfigurationDto" /> class.
 /// </summary>
 /// <param name="channel">The channel.</param>
 /// <param name="modi">The modi info.</param>
 public ChannelConfigurationDto(uint channel, Modi modi)
 {
     this.Channel = channel;
     this.Modi    = modi;
 }