示例#1
0
        public void display()
        {
            keepImageNumberInsideRange();

            string imagePath = imageFolder + System.IO.Path.GetFileName(filesInFolder[imageNumber]);

            try
            {
                var uri = new Uri(imagePath);
                // if the image is found (name is correct)
                var bitmap = new BitmapImage(uri);
                image.Source = bitmap;
            }
            catch (FileNotFoundException)
            {
                notificationsWindow notificationsWindow = new notificationsWindow();
                notificationsWindow.textBlockMessage.Text = "Oops! No images in this Folder!";
                notificationsWindow.Show();

                variables.currentWindow = variables.previousCurrentWindow;
                this.Close();
            }
            catch (IndexOutOfRangeException)
            {
                notificationsWindow notificationsWindow = new notificationsWindow();
                notificationsWindow.textBlockMessage.Text = "Oops! No images in this Folder!";
                notificationsWindow.Show();

                variables.currentWindow = variables.previousCurrentWindow;
                this.Close();
            }
        }
        private void activateActions()
        {
            // For Instructions
            //firstLineOfInstruction.Content = "- Move Mouse with your right hand!";
            //secondLineOfInstruction.Content = "- Click with your left arm (slowly rise it up then  down)!";
            //thirdLineOfInstruction.Content = "- If mouse shakes, Change position (slightly left or right)!";

            notificationsWindow notificationsWindow = new notificationsWindow();

            notificationsWindow.textBlockMessage.Text = "Control activated. Read instruction Please!";
            notificationsWindow.ShowDialog();

            // this timer to get out of a stuck if the detection stopped (indicated by no movement of cursor)
            mouseStuckTimer.Start();
            stuckMouseX = mouseX;
            stuckMouseY = mouseY;

            // this timer to click if the cursor stopped for sometime
            clickingTimer.Start();
            clickMouseX = mouseX;
            clickMouseY = mouseY;

            // since a control change happened under the specified time, then just restart the timer, waiting for next change
            programStuckTimer.Stop();
            programStuckTimer.Start();
        }
示例#3
0
        public folderOfImagesWindow()
        {
            InitializeComponent();

            imageFolder = variables.currentSubDirectorySelected + "//";


            filesInFolder = Directory.GetFiles(variables.currentSubDirectorySelected);
            numberOfFiles = filesInFolder.Length;


            imageNumber = 5;
            try
            {
                display();
            }
            catch (IndexOutOfRangeException)
            {
                notificationsWindow notificationsWindow = new notificationsWindow();
                notificationsWindow.textBlockMessage.Text = "Oops! No images in this Folder!";
                notificationsWindow.Show();

                // this was causing the problem in the following scenario
                // 1) open empty folder 2) go out of range 3) control is retained normally but not going to main screen
                // 1) open empty folder 2) open another folder 3) control not retained and not going to main screen
                //variables.currentWindow = variables.previousCurrentWindow;
                this.Close();
            }
        }
        private void deactivateActions()
        {
            justDeactivated  = true;
            skeletonId       = -1;
            skeletonSelected = false;
            kinectTimer.Start();


            // For Instructions
            //firstLineOfInstruction.Content = "- Stand in the box drawn on the ground to control!";
            //secondLineOfInstruction.Content = "- Only one user at a time!";
            //thirdLineOfInstruction.Content = "- If no response, Please inform server room!";


            notificationsWindow notificationsWindow = new notificationsWindow();

            notificationsWindow.textBlockMessage.Text = "Control De-Activated. Thanks for using!";

            //// if deactivation was due to going out of box and not some guy crossing
            //// then close all previous windows, set cursor on corner, and intilize the main window again
            //if (someoneCrossedInFrontOfUser == false)
            //{
            if (variables.previousCurrentWindow != null)
            {
                variables.previousCurrentWindow.Close();
            }
            if (variables.currentWindow != this)
            {
                variables.currentWindow.Close();
            }

            SetCursorPos(0, 0);
            this.InitializeComponent();
            setWindowVariables();
            //}

            notificationsWindow.ShowDialog();

            mouseStuckTimer.Stop();


            // since a control change happened under the specified time, then just restart the timer, waiting for next change
            programStuckTimer.Stop();
            programStuckTimer.Start();
        }