Ejemplo n.º 1
0
        void sc_OnRecvClientData(SimConnect sender, SIMCONNECT_RECV_CLIENT_DATA data)
        {
            switch ((Requests)data.dwRequestID)
            {
            case Requests.HostAPI0:
            {
                HostAPI0 api0 = (HostAPI0)data.dwData;
            }
            break;

            case Requests.HostAPI1:
            {
                HostAPI1 api1 = (HostAPI1)data.dwData;
                if (api1.RequestedDataIndex < 0 ||
                    api1.RequestedDataIndex > 4)
                {
                    HostException1 exc = new HostException1();
                    exc.RequestorID        = api1.RequestorID;
                    exc.ReqeustedDataIndex = api1.RequestedDataIndex;
                    exc.szErrorMessage     = "HostAPI1: RequestedDataIndex out of range";
                    sender.SetClientData(exc);
                    return;
                }

                HostResponse1 resp = new HostResponse1();

                resp.RequestorID        = api1.RequestorID;
                resp.RequestedDataIndex = api1.RequestedDataIndex;
                switch (api1.RequestedDataIndex)
                {
                case 0:
                    // return the highest valid value for RequestDataIndex
                    resp.RequestedDataValue = 4;
                    break;

                case 1:
                    // return var 1
                    resp.RequestedDataValue = double.Parse(txtVal1.Text);
                    break;

                case 2:
                    // return var 2
                    resp.RequestedDataValue = double.Parse(txtVal2.Text);
                    break;

                case 3:
                    // return var 3
                    resp.RequestedDataValue = double.Parse(txtVal3.Text);
                    break;

                case 4:
                    // return var 4
                    resp.RequestedDataValue = double.Parse(txtVal4.Text);
                    break;
                }
                sender.SetClientData(resp);
            }
            break;
            }
        }
Ejemplo n.º 2
0
        void sc_OnRecvClientData(SimConnect sender, SIMCONNECT_RECV_CLIENT_DATA data)
        {
            switch ((Requests)data.dwRequestID)
            {
            case Requests.HostResponse1:
            {
                HostResponse1 resp = (HostResponse1)data.dwData;
                if (resp.RequestorID == guidClient)
                {           // only process replies meant for us
                    switch (resp.RequestedDataIndex)
                    {
                    case 1:
                        txtVal1.Text = resp.RequestedDataValue.ToString();
                        break;

                    case 2:
                        txtVal2.Text = resp.RequestedDataValue.ToString();
                        break;

                    case 3:
                        txtVal3.Text = resp.RequestedDataValue.ToString();
                        break;

                    case 4:
                        txtVal4.Text = resp.RequestedDataValue.ToString();
                        break;

                    case 5:
                        txtVal5.Text = resp.RequestedDataValue.ToString();
                        break;
                    }
                }
            }
            break;

            case Requests.HostException1:
            {
                HostException1 exc = (HostException1)data.dwData;
                if (exc.RequestorID == guidClient)
                {
                    switch (exc.ReqeustedDataIndex)
                    {
                    case 1:
                        txtVal1.Text = exc.szErrorMessage;
                        break;

                    case 2:
                        txtVal2.Text = exc.szErrorMessage;
                        break;

                    case 3:
                        txtVal3.Text = exc.szErrorMessage;
                        break;

                    case 4:
                        txtVal4.Text = exc.szErrorMessage;
                        break;

                    case 5:
                        txtVal5.Text = exc.szErrorMessage;
                        break;
                    }
                }
            }
            break;

            case Requests.HostAPI2:
            {
                HostAPI2 api = (HostAPI2)data.dwData;

                txtVal21.Text = api.StringValue;
                txtVal22.Text = api.BooleanValue ? "True" : "False";
                txtVal23.Text = api.IntValue.ToString();
                txtVal24.Text = api.DoubleValue.ToString();
            }
            break;
            }
        }