예제 #1
0
        //Error event handler
        void ifKit_Error(object sender, ErrorEventArgs e)
        {
            Phidget      phid = (Phidget)sender;
            DialogResult result;

            switch (e.Type)
            {
            case PhidgetException.ErrorType.PHIDGET_ERREVENT_BADPASSWORD:
                phid.close();
                TextInputBox dialog = new TextInputBox("Error Event",
                                                       "Authentication error: This server requires a password.", "Please enter the password, or cancel.");
                result = dialog.ShowDialog();
                if (result == DialogResult.OK)
                {
                    openCmdLine(phid, dialog.password);
                }
                else
                {
                    Environment.Exit(0);
                }
                break;

            case PhidgetException.ErrorType.PHIDGET_ERREVENT_PACKETLOST:
                //Ignore this error - it's not useful in this context.
                return;

            default:
                if (!errorBox.Visible)
                {
                    errorBox.Show();
                }
                break;
            }
            errorBox.addMessage(DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString() + ": " + e.Description);
        }
예제 #2
0
 //Error event handler
 void ifKit_Error(object sender, ErrorEventArgs e)
 {
     Phidget phid = (Phidget)sender;
     DialogResult result;
     switch (e.Type)
     {
         case PhidgetException.ErrorType.PHIDGET_ERREVENT_BADPASSWORD:
             phid.close();
             TextInputBox dialog = new TextInputBox("Error Event",
                 "Authentication error: This server requires a password.", "Please enter the password, or cancel.");
             result = dialog.ShowDialog();
             if (result == DialogResult.OK)
                 openCmdLine(phid, dialog.password);
             else
                 Environment.Exit(0);
             break;
         case PhidgetException.ErrorType.PHIDGET_ERREVENT_PACKETLOST:
             //Ignore this error - it's not useful in this context.
             return;
         case PhidgetException.ErrorType.PHIDGET_ERREVENT_OVERRUN:
             //Ignore this error - it's not useful in this context.
             return;
         default:
             if (!errorBox.Visible)
                 errorBox.Show();
             break;
     }
     errorBox.addMessage(DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString() + ": " + e.Description);
 }