Ejemplo n.º 1
0
        private void InstallDsOnClick(object sender, RoutedEventArgs routedEventArgs)
        {
            WdiErrorCode ds3Result = WdiErrorCode.WDI_SUCCESS, ds4Result = WdiErrorCode.WDI_SUCCESS;

            var ds3SToInstall =
                DualShockStackPanelHidUsb.Children.Cast <TextBlock>()
                .Select(c => c.Tag)
                .Cast <WdiDeviceInfo>()
                .Where(d => d.VendorId == _hidUsbDs3.VendorId && d.ProductId == _hidUsbDs3.ProductId)
                .ToList();

            if (ds3SToInstall.Any())
            {
                ds3Result = DriverInstaller.InstallDualShock3Controller(ds3SToInstall.First(), _hWnd);
            }

            var ds4SToInstall =
                DualShockStackPanelHidUsb.Children.Cast <TextBlock>()
                .Select(c => c.Tag)
                .Cast <WdiDeviceInfo>()
                .Where(d => d.VendorId == _hidUsbDs4.VendorId && d.ProductId == _hidUsbDs4.ProductId)
                .ToList();

            if (ds4SToInstall.Any())
            {
                ds4Result = DriverInstaller.InstallDualShock4Controller(ds4SToInstall.First(), _hWnd);
            }

            // display success or failure message
            if (ds3Result == WdiErrorCode.WDI_SUCCESS && ds4Result == WdiErrorCode.WDI_SUCCESS)
            {
                ExtendedMessageBox.Show(this,
                                        Properties.Resources.DsInstOk_Title,
                                        Properties.Resources.DsInstOk_Instruction,
                                        Properties.Resources.DsInstOk_Content,
                                        Properties.Resources.DsInstOk_Verbose,
                                        Properties.Resources.DsInstOk_Footer,
                                        TaskDialogIcon.Information);
            }
            else
            {
                if (ds3Result != WdiErrorCode.WDI_SUCCESS)
                {
                    ExtendedMessageBox.Show(this,
                                            Properties.Resources.DsInstError_Title,
                                            Properties.Resources.DsInstError_Instruction,
                                            Properties.Resources.DsInstError_Content,
                                            string.Format(Properties.Resources.DsInstError_Verbose,
                                                          WdiWrapper.Instance.GetErrorMessage(ds3Result), ds3Result),
                                            Properties.Resources.DsInstError_Footer,
                                            TaskDialogIcon.Error);
                    return;
                }

                if (ds4Result != WdiErrorCode.WDI_SUCCESS)
                {
                    ExtendedMessageBox.Show(this,
                                            Properties.Resources.DsInstError_Title,
                                            Properties.Resources.DsInstError_Instruction,
                                            Properties.Resources.DsInstError_Content,
                                            string.Format(Properties.Resources.DsInstError_Verbose,
                                                          WdiWrapper.Instance.GetErrorMessage(ds4Result), ds4Result),
                                            Properties.Resources.DsInstError_Footer,
                                            TaskDialogIcon.Error);
                }
            }
        }
Ejemplo n.º 2
0
 public string GetErrorMessage(WdiErrorCode errcode)
 {
     var msgPtr = wdi_strerror((int) errcode);
     return Marshal.PtrToStringAnsi(msgPtr);
 }
Ejemplo n.º 3
0
        public string GetErrorMessage(WdiErrorCode errcode)
        {
            var msgPtr = wdi_strerror((int)errcode);

            return(Marshal.PtrToStringAnsi(msgPtr));
        }