Example #1
0
    private void button1_Click(object sender, RoutedEventArgs e)
    {
        timer = new Timer(new TimerCallback(timer_Tick), null, 0, 1300);

        MessageBoxResult alarmBox = MessageBox.Show("Press OK to stop alarm", "Timer Finished", MessageBoxButton.OK);

        if (alarmBox == MessageBoxResult.OK)
        {
            timer.Change(Timeout.Infinite, Timeout.Infinite);
            vibrate.Stop();
        }
    }
 void alarmTimer_Tick(object sender, EventArgs e)
 {
     if (alarmBox == MessageBoxResult.OK)
     {
         alarmTimer.Stop();
         vibrate.Stop();
     }
     else
     {
         vibrate.Start(new TimeSpan(0, 0, 0, 0, vibrationLength));
     }
 }
Example #3
0
        public void cancelar()
        {
            if (sonido != null)
            {
                sonido.Stop();
            }
            vibrar.Stop();
            bandDeteniendo = true;

            if (bw.WorkerSupportsCancellation == true)
            {
                bw.CancelAsync();
            }
            else
            {
            }
        }
Example #4
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }

            proceedText();

            base.Update(gameTime);

            bool nextLetter = true;

            foreach (TouchLocation location in TouchPanel.GetState())
            {
                // Letter control
                for (int i = 0; i < Braile.cBraileDotsNum; i++)
                {
                    if (braileData.braileLetter1[i].rect.Contains((int)location.Position.X, (int)location.Position.Y))
                    {
                        if (braileData.braileLetter1[i].state)
                        {
                            // start vibe
                            Debug.WriteLine("Yes vibe! {0}", i);
                            vibrate.Start(TimeSpan.FromMilliseconds(200));
                        }
                        else
                        {
                            // stop vibe
                            Debug.WriteLine("No vibe! {0}", i);
                            vibrate.Stop();
                        }

                        braileData.braileLetter1[i].touched = true;
                        nextLetter = false;
                    }
                }

                // Controls
                if (controls.letterControl.Contains((int)location.Position.X, (int)location.Position.Y))
                {
                    //Debug.WriteLine("Start controling letter");

                    while (TouchPanel.IsGestureAvailable)
                    {
                        GestureSample gs = TouchPanel.ReadGesture();
                        switch (gs.GestureType)
                        {
                        case GestureType.HorizontalDrag:
                            controls.letterControlDeltaX += gs.Delta.X;
                            Debug.WriteLine("VerticalDrag {0}", gs.Delta.X);
                            break;

                        case GestureType.DragComplete:
                            if (controls.letterControlDeltaX > 10.0)
                            {
                                if (wordPos + 1 < braileText.Length)
                                {
                                    wordPos++;
                                    letterPos = 0;
                                }
                                else
                                {
                                    Debug.WriteLine("End of text");
                                }

                                Debug.WriteLine("Next word!");
                            }
                            else if (controls.letterControlDeltaX < -10.0)
                            {
                                if (letterPos == 0 && wordPos != 0)
                                {
                                    wordPos--;
                                    Debug.WriteLine("Previous word");
                                }

                                letterPos = 0;
                                Debug.WriteLine("Begining of the word");
                            }

                            Debug.WriteLine("{0}", controls.letterControlDeltaX);

                            controls.letterControlDeltaX = 0;
                            break;
                        }
                    }
                }
            }

            if (braileData.braileLetter1.All(x => x.touched) && nextLetter)
            {
                Debug.WriteLine("Next letter!");
                if (letterPos + 1 < braileText[wordPos].Length)
                {
                    letterPos++;
                }
                else
                {
                    letterPos = 0;

                    if (wordPos + 1 < braileText.Length)
                    {
                        vibrate.Start(TimeSpan.FromMilliseconds(100));
                        System.Threading.Thread.Sleep(200);
                        vibrate.Start(TimeSpan.FromMilliseconds(100));

                        wordPos++;
                    }
                    else
                    {
                        Debug.WriteLine("End of text!");
                    }
                }

                for (int i = 0; i < braileData.braileLetter1.Length; i++)
                {
                    braileData.braileLetter1[i].touched = false;
                }
            }
        }
Example #5
0
 void StopAll()
 {
     timer.Change(Timeout.Infinite, Timeout.Infinite);
     vibrate.Stop();
     alarmSound.Stop();
 }
Example #6
0
        void connectionManager_MessageReceived(string message)
        {
            string[] messageArray = message.Split(':');
            switch (messageArray[0])
            {
            case "THIEF":

                stateManager.Thief = messageArray[1] == "ON" ? true : false;
                Dispatcher.BeginInvoke(delegate()
                {
                    Status.Text = stateManager.Thief ?  "THIEF": "COUNT";
                    if (stateManager.Thief)
                    {
                        OSNum.Visibility       = Visibility.Collapsed;
                        Count_Title.Visibility = Visibility.Collapsed;
                        Update_but.Visibility  = Visibility.Collapsed;
                        Reset_but.Visibility   = Visibility.Collapsed;
                        Thief_Title.Visibility = Visibility.Visible;

                        IN_BUTTON.Visibility = Visibility.Collapsed;
                        OUT_BUT.Visibility   = Visibility.Collapsed;
                        NOW_BUT.Visibility   = Visibility.Collapsed;
                    }
                    else
                    {
                        OSNum.Visibility       = Visibility.Visible;
                        Count_Title.Visibility = Visibility.Visible;
                        Update_but.Visibility  = Visibility.Visible;
                        Reset_but.Visibility   = Visibility.Visible;
                        Thief_Title.Visibility = Visibility.Collapsed;

                        IN_BUTTON.Visibility = Visibility.Visible;
                        OUT_BUT.Visibility   = Visibility.Visible;
                        NOW_BUT.Visibility   = Visibility.Visible;
                    }
                });

                break;

            case "NEW":

                stateManager.NEW = messageArray[3] == "ON" ? true : false;
                Dispatcher.BeginInvoke(delegate()
                {
                    OSNum.Text = stateManager.NEW ? messageArray[1] : "";

                    switch (messageArray[2])
                    {
                    case "NOW":
                        IN_BUTTON.IsEnabled = true;
                        OUT_BUT.IsEnabled   = true;
                        NOW_BUT.IsEnabled   = false;
                        break;

                    case "IN":
                        IN_BUTTON.IsEnabled = false;
                        OUT_BUT.IsEnabled   = true;
                        NOW_BUT.IsEnabled   = true;
                        break;

                    case "OUT":
                        IN_BUTTON.IsEnabled = true;
                        OUT_BUT.IsEnabled   = false;
                        NOW_BUT.IsEnabled   = true;
                        break;
                    }
                });
                break;

            case "CONNECTED":
                stateManager.CONNECTION = messageArray[1] == "ON" ? true : false;
                Dispatcher.BeginInvoke(delegate()
                {
                    if (stateManager.CONNECTION == true)
                    {
                        sendCmd("CONNECTED");
                    }
                });
                break;

            case "THIEFDEC":
                stateManager.THIEFDEC = messageArray[1] == "ON" ? true : false;
                Dispatcher.BeginInvoke(delegate()
                {
                    if (stateManager.THIEFDEC == true)
                    {
                        Thief_Detec.Visibility = Visibility.Visible;
                        Maingrid.Visibility    = Visibility.Collapsed;
                        Thiefdetected();
                    }
                });
                break;

            case "COUNTING":
                stateManager.COUNTING = messageArray[1] == "ON" ? true : false;
                Dispatcher.BeginInvoke(delegate()
                {
                    if (stateManager.COUNTING == true)
                    {
                        Turnoncount.IsChecked = true;
                        Turnoncount.Content   = "Counting...";
                    }
                    else
                    {
                        Turnoncount.IsChecked = false;
                        Turnoncount.Content   = "Uncounting...";
                    }
                });
                break;

            case "IRSYNC":
                Dispatcher.BeginInvoke(delegate()
                {
                    IRIN_Text.Text  = messageArray[1];
                    IROUT_Text.Text = messageArray[2];
                });
                break;

            case "IRTESTSTOP":
                Dispatcher.BeginInvoke(delegate()
                {
                    IR_Testplace.Visibility = Visibility.Collapsed;
                    Maingrid.Visibility     = Visibility.Visible;
                });
                break;

            case "GETINDEFAULT":
                Dispatcher.BeginInvoke(delegate()
                {
                    sendCmd(IRIN_VALUE.Text);
                });
                break;

            case "GETINDEFAULT1":
                Dispatcher.BeginInvoke(delegate()
                {
                    sendCmd(IRIN_VALUE1.Text);
                });
                break;

            case "GETOUTDEFAULT":
                Dispatcher.BeginInvoke(delegate()
                {
                    sendCmd(IROUT_VALUE.Text);
                });
                break;

            case "GETOUTDEFAULT1":
                Dispatcher.BeginInvoke(delegate()
                {
                    sendCmd(IROUT_VALUE1.Text);
                });
                break;

            case "STARTIRTEST":
                Dispatcher.BeginInvoke(delegate()
                {
                    Maingrid.Visibility     = Visibility.Collapsed;
                    IR_Testplace.Visibility = Visibility.Visible;
                });
                break;

            case "ALLBREAKED":
                Dispatcher.BeginInvoke(delegate()
                {
                    Maingrid.Visibility     = Visibility.Visible;
                    IR_Testplace.Visibility = Visibility.Collapsed;
                    Thief_Detec.Visibility  = Visibility.Collapsed;
                    Rung.Stop();
                    Warningup.Stop();
                });
                break;

            case "COUNTCHECKOFF":
                Dispatcher.BeginInvoke(delegate()
                {
                    Turnoncount.IsChecked = false;
                    Turnoncount.Content   = "Uncounting...";
                });
                break;

            case "STOPEDTHIEF":
                Dispatcher.BeginInvoke(delegate()
                {
                    sendCmd("COUNT");
                });
                break;
            }
        }
Example #7
0
        void connectionManager_MessageReceived(string message)
        {
            string[] messageArray = message.Split(':');
            switch (messageArray[0])
            {
            case "THIEF":

                stateManager.Thief = messageArray[1] == "ON" ? true : false;
                Dispatcher.BeginInvoke(delegate()
                {
                    Status.Text = stateManager.Thief ? "THIEF" : "COUNT";
                    if (stateManager.Thief)
                    {
                        OSNum.Visibility       = Visibility.Collapsed;
                        Count_Title.Visibility = Visibility.Collapsed;
                        Update_but.Visibility  = Visibility.Collapsed;
                        Reset_but.Visibility   = Visibility.Collapsed;
                        Thief_Title.Visibility = Visibility.Visible;
                        Sync.Visibility        = Visibility.Collapsed;
                        IN_BUTTON.Visibility   = Visibility.Collapsed;
                        OUT_BUT.Visibility     = Visibility.Collapsed;
                        NOW_BUT.Visibility     = Visibility.Collapsed;
                        Zoom_But.Visibility    = Visibility.Collapsed;
                    }
                    else
                    {
                        OSNum.Visibility       = Visibility.Visible;
                        Count_Title.Visibility = Visibility.Visible;
                        Update_but.Visibility  = Visibility.Visible;
                        Reset_but.Visibility   = Visibility.Visible;
                        Thief_Title.Visibility = Visibility.Collapsed;
                        Sync.Visibility        = Visibility.Visible;
                        IN_BUTTON.Visibility   = Visibility.Visible;
                        OUT_BUT.Visibility     = Visibility.Visible;
                        NOW_BUT.Visibility     = Visibility.Visible;
                        Zoom_But.Visibility    = Visibility.Visible;
                    }
                });

                break;

            case "NEW":

                stateManager.NEW = messageArray[3] == "ON" ? true : false;
                Dispatcher.BeginInvoke(delegate()
                {
                    OSNum.Text      = stateManager.NEW ? messageArray[1] : "";
                    OSNum_Zoom.Text = stateManager.NEW ? messageArray[1] : "";
                    switch (messageArray[2])
                    {
                    case "NOW":
                        IN_BUTTON.IsEnabled      = true;
                        OUT_BUT.IsEnabled        = true;
                        NOW_BUT.IsEnabled        = false;
                        IN_BUTTON_Zoom.IsEnabled = true;
                        OUT_BUT_Zoom.IsEnabled   = true;
                        NOW_BUT_Zoom.IsEnabled   = false;
                        break;

                    case "IN":
                        IN_BUTTON.IsEnabled      = false;
                        OUT_BUT.IsEnabled        = true;
                        NOW_BUT.IsEnabled        = true;
                        IN_BUTTON_Zoom.IsEnabled = false;
                        OUT_BUT_Zoom.IsEnabled   = true;
                        NOW_BUT_Zoom.IsEnabled   = true;
                        break;

                    case "OUT":
                        IN_BUTTON.IsEnabled      = true;
                        OUT_BUT.IsEnabled        = false;
                        NOW_BUT.IsEnabled        = true;
                        IN_BUTTON_Zoom.IsEnabled = true;
                        OUT_BUT_Zoom.IsEnabled   = false;
                        NOW_BUT_Zoom.IsEnabled   = true;
                        break;
                    }
                });
                break;

            case "THIEFDEC":
                stateManager.THIEFDEC = messageArray[1] == "ON" ? true : false;
                Dispatcher.BeginInvoke(delegate()
                {
                    if (stateManager.THIEFDEC == true)
                    {
                        Thief_Detec.Visibility = Visibility.Visible;
                        Maingrid.Visibility    = Visibility.Collapsed;
                        Thiefdetected();
                    }
                });
                break;

            case "ALLBREAKED":
                Dispatcher.BeginInvoke(delegate()
                {
                    Maingrid.Visibility    = Visibility.Visible;
                    Thief_Detec.Visibility = Visibility.Collapsed;
                    Rung.Stop();
                    Warningup.Stop();
                });
                break;

            case "IRSYNC":
                Dispatcher.BeginInvoke(delegate()
                {
                    IRIN_Text.Text  = messageArray[1];
                    IROUT_Text.Text = messageArray[2];
                });
                break;

            case "GETIN1DEFAULT":
                Dispatcher.BeginInvoke(delegate()
                {
                    if (Autoset_Place.Visibility == Visibility.Collapsed)
                    {
                        if (IRIN_VALUE_1.Text == "")
                        {
                            sendCmd("-1");
                        }
                        else
                        {
                            sendCmd(IRIN_VALUE_1.Text);
                        }
                    }
                    else
                    {
                        sendCmd(A_IN_Value.ToString());
                    }
                });
                break;

            case "GETIN2DEFAULT":
                Dispatcher.BeginInvoke(delegate()
                {
                    if (Autoset_Place.Visibility == Visibility.Collapsed)
                    {
                        if (IRIN_VALUE_2.Text == "")
                        {
                            sendCmd("-1");
                        }
                        else
                        {
                            sendCmd(IRIN_VALUE_2.Text);
                        }
                    }
                    else
                    {
                        sendCmd(A_IN_Value2.ToString());
                    }
                });
                break;

            case "GETOUT1DEFAULT":
                Dispatcher.BeginInvoke(delegate()
                {
                    if (Autoset_Place.Visibility == Visibility.Collapsed)
                    {
                        if (IROUT_VALUE_1.Text == "")
                        {
                            sendCmd("-1");
                        }
                        else
                        {
                            sendCmd(IROUT_VALUE_1.Text);
                        }
                    }
                    else
                    {
                        sendCmd(A_OUT_Value.ToString());
                    }
                });
                break;

            case "GETOUT2DEFAULT":
                Dispatcher.BeginInvoke(delegate()
                {
                    if (Autoset_Place.Visibility == Visibility.Collapsed)
                    {
                        if (IROUT_VALUE_2.Text == "")
                        {
                            sendCmd("-1");
                        }
                        else
                        {
                            sendCmd(IROUT_VALUE_2.Text);
                        }
                    }
                    else
                    {
                        sendCmd(A_OUT_Value2.ToString());
                    }
                });

                break;

            case "STARTIRTEST":
                Dispatcher.BeginInvoke(delegate()
                {
                    Maingrid.Visibility     = Visibility.Collapsed;
                    IR_Testplace.Visibility = Visibility.Visible;
                });
                break;

            case "STOPEDTHIEF":
                Dispatcher.BeginInvoke(delegate()
                {
                    sendCmd("COUNT");
                });
                break;

            case "AUTOVALUE1_IN":
                Dispatcher.BeginInvoke(delegate()
                {
                    IN_Value1 = int.Parse(messageArray[1]);
                    IN_Value2 = int.Parse(messageArray[2]);
                    sendCmd("GETAUTOVALUE2_IN");
                });
                break;

            case "AUTOVALUE1_OUT":
                Dispatcher.BeginInvoke(delegate()
                {
                    OUT_Value1            = int.Parse(messageArray[1]);
                    OUT_Value2            = int.Parse(messageArray[2]);
                    Auto_Text2.Visibility = Visibility.Visible;
                    Auto_Text3.Visibility = Visibility.Visible;
                });
                break;

            case "AUTOVALUE2_IN":
                Dispatcher.BeginInvoke(delegate()
                {
                    double Temp              = (IN_Value1 + int.Parse(messageArray[1])) * 1.0 / 2;
                    A_IN_Value               = Math.Round(Temp, 0) + 3;
                    Temp                     = (IN_Value2 + int.Parse(messageArray[1])) * 1.0 / 2;
                    A_IN_Value2              = Math.Round(Temp, 0) + 3;
                    Auto_Text2.Text          = "IN Detected";
                    Auto_Text3.Text          = "IN:" + A_IN_Value.ToString();
                    But_Auto_Next.Visibility = Visibility.Visible;
                });
                break;

            case "AUTOVALUE2_OUT":
                Dispatcher.BeginInvoke(delegate()
                {
                    double Temp     = (OUT_Value1 + int.Parse(messageArray[1])) / 2;
                    A_OUT_Value     = Math.Round(Temp, 0) + 3;
                    Temp            = (OUT_Value2 + int.Parse(messageArray[2])) / 2;
                    A_OUT_Value2    = Math.Round(Temp, 0) + 3;
                    Auto_Text2.Text = "OUT Detected";
                    Auto_Text3.Text = "OUT:" + A_OUT_Value.ToString() + " & " + A_OUT_Value2.ToString();
                });
                break;

            case "AUTOIRTEST_ON":
                Dispatcher.BeginInvoke(delegate()
                {
                    Autoset_Place.Visibility = Visibility.Visible;
                    But_Auto_Next.Visibility = Visibility.Collapsed;
                    IR_Testplace.Visibility  = Visibility.Collapsed;
                });
                break;

            case "GETIRDEFAULT":
                Dispatcher.BeginInvoke(delegate()
                {
                    Auto_Text3.Text = "";
                    Auto_Text2.Text = "COMPLETED!";
                    sendCmd("SETIRDEFAULT");
                });
                break;

            case  "IRT_ON":
                Dispatcher.BeginInvoke(delegate()
                {
                    Maingrid.Visibility     = Visibility.Collapsed;
                    IR_Testplace.Visibility = Visibility.Visible;
                });
                break;
            }
        }