private void btnUpdate_Click(object sender, RoutedEventArgs e) { HostAPI2 api = new HostAPI2(); api.StringValue = txtVal21.Text; api.BooleanValue = chkVal22.IsChecked.Value; api.IntValue = Int32.Parse(txtVal23.Text); api.DoubleValue = Double.Parse(txtVal24.Text); sc.SetClientData(api); }
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; } }