/// <summary>-
        /// receives the progress of driver scan
        /// </summary>
        /// <param name="progressType"></param>
        /// <param name="data"></param>
        /// <param name="currentItemPos"></param>
        /// <param name="nTotalDriversToScan"></param>
        /// <param name="progress"></param>
        /// <returns></returns>
        public bool progressCallback(DUSDKHandler.PROGRESS_TYPE progressType, IntPtr data, int currentItemPos, int nTotalDriversToScan, int progress)
        {
            // here we will get the progress of driver scan.
            DriverData? dd = null;
            string category = string.Empty;
            string VersionInstalled = string.Empty;
            string VersionUpdated = string.Empty;
            DateTime dtInstalled;

            if (data != IntPtr.Zero)
            {
                dd = (DriverData)Marshal.PtrToStructure(
                            (IntPtr)(data.ToInt64() + currentItemPos * Marshal.SizeOf(typeof(DriverData))),
                            typeof(DriverData)
                            );

            }

            switch (progressType)
            {
                case DUSDKHandler.PROGRESS_TYPE.PROGRESS_SIZE_SCAN_DATA:
                    nTotalDrivers = nTotalDriversToScan;
                    driverData = new DriverData[nTotalDriversToScan];
                    UserUpdates = new Dictionary<int, DriverData>();
                    break;
                case DUSDKHandler.PROGRESS_TYPE.PROGRESS_SCANNING:
                    if (data != IntPtr.Zero && !bIsStopped)
                    {
                        driverData[currentItemPos] = (DriverData)dd;
                        string infName = string.Empty;
                        try
                        {
                            infName = new FileInfo(driverData[currentItemPos].location).Name;
                        }
                        catch
                        {
                        }
                        DeviceInfo item = new DeviceInfo(
                        null,
                        driverData[currentItemPos].category,
                        driverData[currentItemPos].driverName,
                        infName,
                        string.IsNullOrEmpty(driverData[currentItemPos].version) || driverData[currentItemPos].version == "null" ? string.Empty : driverData[currentItemPos].version,
                        currentItemPos.ToString(),
                        driverData[currentItemPos].hardwareId,
                        driverData[currentItemPos].CompatibleIdIndex.ToString()
                        );

                        dtInstalled = DateTime.FromFileTime(driverData[currentItemPos].ulDateTimeQuadPart);
                        item.InstalledDriverDate = dtInstalled.ToShortDateString();

                        string driverName = driverData[currentItemPos].driverName;
                        if (driverName.Length > 46)
                            driverName = driverName.Substring(0, 43) + "...";

                        if (CurrentDispatcher.Thread != null)
                        {
                            CurrentDispatcher.Invoke((MethodInvoker)delegate
                            {
                                ScanStatusText = driverName;

                                var excludedDevice = ExcludedDevices.FirstOrDefault(d => d.Id == item.Id);
                                if (excludedDevice != null)
                                {
                                    item.IsExcluded = excludedDevice.IsExcluded;
                                }
                                if (!item.IsExcluded)
                                {
                                    DevicesForScanning.Add(item);
                                }
                                AllDevices.Add(item);
                            }
                            , null);
                        }
                    }
                    break;
                case DUSDKHandler.PROGRESS_TYPE.PROGRESS_RETRIEVING_UPDATES_DATA:
                    if (CurrentDispatcher.Thread != null)
                    {
                        CurrentDispatcher.Invoke((MethodInvoker)delegate
                        {
                            ScanStatusText = string.Empty;
                            ScanStatusTitle = WPFLocalizeExtensionHelpers.GetUIString("ContactingServer");
                        }, null);
                    }
                    break;
                //case DUSDKHandler.PROGRESS_TYPE.PROGRESS_RETRIEVING_UPDATES_FAILED_INET:
                //    break;
                case DUSDKHandler.PROGRESS_TYPE.PROGRESS_FILTERING_UPDATES:
                    if (data != IntPtr.Zero && !bIsStopped)
                    {
                        // get driver update information
                        DriverData DriverUpdate = (DriverData)Marshal.PtrToStructure(
                              (IntPtr)(data.ToInt64() + currentItemPos * Marshal.SizeOf(typeof(DriverData))),
                              typeof(DriverData)
                              );

                        if (CurrentDispatcher.Thread != null)
                        {
                            CurrentDispatcher.Invoke((MethodInvoker)delegate
                            {
                                DeviceInfo deviceInfo = DevicesForScanning.Where(wh => wh.Id == currentItemPos.ToString()).FirstOrDefault();
                                if (deviceInfo != null)
                                {
                                    deviceInfo.NeedsUpdate = true;
                                    deviceInfo.SelectedForUpdate = true;
                                    deviceInfo.NewDriverDate = DateTime.FromFileTime(DriverUpdate.ulDateTimeQuadPart).ToShortDateString();
                                    deviceInfo.DownloadLink = DriverUpdate.libURL;
                                    deviceInfo.InstallCommand = DriverUpdate.SetupLaunchParam;
                                }

                                UserUpdates.Add(currentItemPos, DriverUpdate);
                            }
                            , null);
                        }
                    }
                    break;
                case DUSDKHandler.PROGRESS_TYPE.PROGRESS_SCANNED:
                    //if (CurrentDispatcher.Thread != null)
                    //{
                    //    CurrentDispatcher.BeginInvoke((Action)(() =>
                    //    {
                    //        ScanStatusTitle = WPFLocalizeExtensionHelpers.GetUIString("ScanCompleted");
                    //        ScanStatusText = "";
                    //    }));
                    //}
                    break;
                case DUSDKHandler.PROGRESS_TYPE.PROGRESS_UPDATE_STARTED_FOR_SINGLE:
                    {
                        if (data != IntPtr.Zero && dd.HasValue)
                        {
                            if (CurrentDispatcher.Thread != null)
                            {
                                CurrentDispatcher.BeginInvoke((Action)(() =>
                                {
                                    DownloadedDrivers.Add(new DownloadingDriverModel(WPFLocalizeExtensionHelpers.GetUIString("InstallingDriver"), devicesForUpdate[currentItemPos]));
                                    ScanStatusTitle = WPFLocalizeExtensionHelpers.GetUIString("InstallingDriver");
                                    ScanStatusText = devicesForUpdate[currentItemPos].DeviceName;
                                    //Progress = 0;
                                }));
                            }
                        }
                    }
                    break;
                case DUSDKHandler.PROGRESS_TYPE.PROGRESS_UPDATE_END_FOR_SINGLE:
                    {
                        if (data != IntPtr.Zero && dd.HasValue)
                        {
                            if (CurrentDispatcher.Thread != null)
                            {
                                CurrentDispatcher.BeginInvoke((Action)(() =>
                                {
                                    //ScanStatusTitle =
                                    ScanStatusText = WPFLocalizeExtensionHelpers.GetUIString("UpdateCompleted") + " " + ((DriverData)dd).driverName;
                                }));
                            }
                        }
                    }
                    break;
                case DUSDKHandler.PROGRESS_TYPE.PROGRESS_UPDATE_SUCCESSFUL:
                    {
                    }
                    break;
                case DUSDKHandler.PROGRESS_TYPE.PROGRESS_UPDATE_FAILED:
                    {
                        if (data != IntPtr.Zero && dd.HasValue)
                        {
                            string driverName = ((DriverData)dd).driverName;
                            if (driverName.Length > 37)
                                driverName = driverName.Substring(0, 34) + "...";
                            if (CurrentDispatcher.Thread != null)
                            {
                                CurrentDispatcher.BeginInvoke((Action)(() =>
                                {
                                    ScanStatusTitle = WPFLocalizeExtensionHelpers.GetUIString("UpdateFailed") + " " + driverName;
                                    ScanStatusText = string.Empty;
                                }));
                            }
                        }
                    }
                    break;
                case DUSDKHandler.PROGRESS_TYPE.PROGRESS_DOWNLOAD_STARTED_FOR_SINGLE:
                    {
                        if (data != IntPtr.Zero && dd.HasValue)
                        {
                            string driverName = ((DriverData)dd).driverName;
                            if (driverName.Length > 23)
                                driverName = driverName.Substring(0, 20) + "...";

                            if (CurrentDispatcher.Thread != null)
                            {
                                CurrentDispatcher.BeginInvoke((Action)(() =>
                                {
                                    DownloadedDrivers.Add(new DownloadingDriverModel(WPFLocalizeExtensionHelpers.GetUIString("DownloadingDriver"), devicesForUpdate[currentItemPos]));
                                    ScanStatusTitle = WPFLocalizeExtensionHelpers.GetUIString("DownloadingDriver");
                                    ScanStatusText = driverName;// ((DriverData)dd).driverName;
                                }));
                            }
                        }
                    }
                    break;
                case DUSDKHandler.PROGRESS_TYPE.PROGRESS_DOWNLOAD_END_FOR_SINGLE:
                    {
                        if (data != IntPtr.Zero && dd.HasValue)
                        {
                            if (CurrentDispatcher.Thread != null)
                            {
                                CurrentDispatcher.BeginInvoke((Action)(() =>
                                {
                                    ScanStatusTitle = WPFLocalizeExtensionHelpers.GetUIString("DownloadComplete") + " " + ((DriverData)dd).driverName;
                                    ScanStatusText = string.Empty;
                                }));
                            }
                        }
                    }
                    break;
                case DUSDKHandler.PROGRESS_TYPE.PROGRESS_DOWNLOAD_END_FOR_SINGLE_UNREG:
                    {

                        // download failed as user is unregistered
                    }
                    break;
                case DUSDKHandler.PROGRESS_TYPE.PROGRESS_DOWNLOAD_END_FOR_SINGLE_INET_ERROR:
                    {
                        // download failed because of Internet Error
                    }
                    break;
                default:
                    break;
            }

            if (progress > 0)
            {
                if (CurrentDispatcher.Thread != null)
                {
                    CurrentDispatcher.BeginInvoke((Action)(() =>
                    {
                        Progress = progress;
                    }));
                }
            }

            return true;
        }
        /// <summary>
        /// Driver download progress
        /// </summary>
        /// <param name="progressType"></param>
        /// <param name="iTotalDownloaded"></param>
        /// <param name="iTotalSize"></param>
        /// <param name="iRetCode"></param>
        /// <param name="iPercentageCompleted"></param>
        /// <param name="progress"></param>
        /// <returns></returns>
        public bool downloadProgressCallback(
           DUSDKHandler.PROGRESS_TYPE progressType,
           long iTotalDownloaded,
           long iTotalSize,
           int iRetCode,
           int iPercentageCompleted,
           int progress
           )
        {
            if (iTotalDownloaded >= 0 && iTotalSize > 0)
            {
                string strDownloadedSize = string.Empty, strTotalSize = string.Empty;
                CommonMethods.getSizeInKBMBGB((double)iTotalDownloaded, ref strDownloadedSize);
                CommonMethods.getSizeInKBMBGB((double)iTotalSize, ref strTotalSize);
                if (string.IsNullOrEmpty(strDownloadedSize)) { strDownloadedSize = "0 KB"; }

                if (CurrentDispatcher.Thread != null)
                {
                    CurrentDispatcher.BeginInvoke((Action)(() =>
                    {
                        //ScanStatusTitle = WPFLocalizeExtensionHelpers.GetUIString("DownloadingDriver");
                        ScanStatusTitle = String.Format(WPFLocalizeExtensionHelpers.GetUIString("DownloadStatus"), strDownloadedSize, strTotalSize);
                        ScanStatusText = string.Empty;
                        Progress = progress;
                    }));
                }
            }

            return true;
        }
        /// <summary>-
        /// receives the progress of driver scan
        /// </summary>
        /// <param name="progressType"></param>
        /// <param name="data"></param>
        /// <param name="currentItemPos"></param>
        /// <param name="nTotalDriversToScan"></param>
        /// <param name="progress"></param>
        /// <returns></returns>
        public bool progressCallback(DUSDKHandler.PROGRESS_TYPE progressType, IntPtr data, int currentItemPos, int nTotalDriversToScan, int progress)
        {
            // here we will get the progress of driver scan.
            DriverData? dd = null;
            string category = string.Empty;

            if (data != IntPtr.Zero)
            {
                dd = (DriverData)Marshal.PtrToStructure(
                            (IntPtr)(data.ToInt64() + currentItemPos * Marshal.SizeOf(typeof(DriverData))),
                            typeof(DriverData)
                            );

            }

            switch (progressType)
            {
                case DUSDKHandler.PROGRESS_TYPE.PROGRESS_UPDATE_STARTED_FOR_SINGLE:
                    {
                        if (data != IntPtr.Zero && dd.HasValue)
                        {
                            if (CurrentDispatcher.Thread != null)
                            {
                                CurrentDispatcher.BeginInvoke((Action)(() =>
                                {
                                    // DownloadedDrivers.Add(new DownloadingDriverModel(WPFLocalizeExtensionHelpers.GetUIString("InstallingDriver"), devicesForUpdate[currentItemPos]));
                                    //ScanStatusTitle = WPFLocalizeExtensionHelpers.GetUIString("InstallingDriver");
                                    // ScanStatusText = devicesForUpdate[currentItemPos].DeviceName;
                                }));
                            }
                        }
                    }
                    break;
                case DUSDKHandler.PROGRESS_TYPE.PROGRESS_UPDATE_END_FOR_SINGLE:
                    {
                        if (data != IntPtr.Zero && dd.HasValue)
                        {
                            if (CurrentDispatcher.Thread != null)
                            {
                                CurrentDispatcher.BeginInvoke((Action)(() =>
                                {
                                    InstallFinishTitle = String.Format("{0} " + WPFLocalizeExtensionHelpers.GetUIString("DriversInstalled"), driversToInstall.Count());
                                    Status = InstallStatus.Finished;
                                    InstallStatusTitle = InstallFinishTitle;
                                    InstallStatusText = "";
                                    DriverIndex = 0;
                                }));
                            }
                        }
                    }
                    break;
                case DUSDKHandler.PROGRESS_TYPE.PROGRESS_UPDATE_SUCCESSFUL:
                    {
                    }
                    break;
                case DUSDKHandler.PROGRESS_TYPE.PROGRESS_UPDATE_FAILED:
                    {
                        if (data != IntPtr.Zero && dd.HasValue)
                        {
                            string driverName = ((DriverData)dd).driverName;
                            if (driverName.Length > 37)
                                driverName = driverName.Substring(0, 34) + "...";
                            if (CurrentDispatcher.Thread != null)
                            {
                                CurrentDispatcher.BeginInvoke((Action)(() =>
                                {
                                    //          ScanStatusTitle = WPFLocalizeExtensionHelpers.GetUIString("UpdateFailed") + " " + driverName;
                                    //        ScanStatusText = string.Empty;
                                }));
                            }
                        }
                    }
                    break;
                case DUSDKHandler.PROGRESS_TYPE.PROGRESS_UPDATE_END_FOR_ALL:
                    if (CurrentDispatcher.Thread != null)
                    {
                        CurrentDispatcher.BeginInvoke((Action)(() =>
                        {
                            CurrentDispatcher.BeginInvoke((Action)(() =>
                            {
                                //ScanFinishTitle = String.Format("{0} " + WPFLocalizeExtensionHelpers.GetUIString("DriversDownloaded"), DevicesForDestinationOS.Count());
                                //Status = ScanStatus.DownloadFinished;
                                //driverDownloading = false;
                                //ScanStatusTitle = ScanFinishTitle;
                                //ScanStatusText = string.Empty;
                                //driverIndex = 0;
                                Progress = 0;
                            }));
                        }));
                    }
                    break;
                case DUSDKHandler.PROGRESS_TYPE.PROGRESS_DOWNLOAD_END_FOR_SINGLE_INET_ERROR:
                    {
                        // download failed because of Internet Error
                    }
                    break;

                case DUSDKHandler.PROGRESS_TYPE.PROGRESS_OSMT_RST_FAILED_OS_NOTMATCHED:
                    //OS aren't match
                    if (CurrentDispatcher.Thread != null)
                    {
                        CurrentDispatcher.BeginInvoke((Action)(() =>
                        {
                            CurrentDispatcher.BeginInvoke((Action)(() =>
                            {
                                string OSInfo = GetOSInfo();
                                string OSName = OsList[allDrivers.OS].Key.ToString();//((DU_SUPPORTED_OS_NAMES)allDrivers.OS).ToString();
                                WPFMessageBox.Show(
                                       String.Format(WPFLocalizeExtensionHelpers.GetUIString("OSMismatchText"), OSName, OSInfo),
                                       WPFLocalizeExtensionHelpers.GetUIString("OSMismatch"),
                                       WPFMessageBoxButton.OK,
                                       MessageBoxImage.Error
                                   );
                                Close();
                            }));
                        }));
                    }
                    break;
                default:
                    break;
            }

            if (progress > 0)
            {
                if (CurrentDispatcher.Thread != null)
                {
                    CurrentDispatcher.BeginInvoke((Action)(() =>
                    {
                        Progress = progress;
                    }));
                }
            }

            return true;
        }
 public bool downloadProgressCallback(
   DUSDKHandler.PROGRESS_TYPE progressType,
   long iTotalDownloaded,
   long iTotalSize,
   int iRetCode,
   int iPercentageCompleted,
   int progress
   )
 {
     return true;
 }
        /// <summary>
        /// call to SDK for driver update function
        /// </summary>
        /// <param name="arrUserDrivers"></param>
        /// <param name="arrUserUpdates"></param>
        public int UpdateDrivers(DriverData[] arrUserDrivers, DriverData[] arrUserUpdates, int nOsId, DUSDKHandler.UPDATE_FLAGS updateFlag, string archivePath)
        {
            int retval = 0;
            IntPtr pUnmanagedUserDrivers = IntPtr.Zero;
            IntPtr pUnmanagedUserUpdates = IntPtr.Zero;

            try
            {
                if (arrUserDrivers != null)
                {
                    // marshal input
                    pUnmanagedUserDrivers = MarshalHelper.MarshalArray(ref arrUserDrivers);
                }

                if (arrUserUpdates != null)
                {
                    pUnmanagedUserUpdates = MarshalHelper.MarshalArray(ref arrUserUpdates);
                }

                int arrLen = 0;

                if (arrUserDrivers != null)
                {
                    arrLen = arrUserDrivers.Length;
                }

                if ((updateFlag & DUSDKHandler.UPDATE_FLAGS.UPDATE_FLAG_RESTORE_ARCHIVE_ONLY) == DUSDKHandler.UPDATE_FLAGS.UPDATE_FLAG_RESTORE_ARCHIVE_ONLY)
                {
                    // call driver update function
                    retval = DUSDKHandler.OSMT_updateDeviceDriversEx(
                        progressCallback,
                        szProductKey,
                        szAppDataLoc,
                        szTempLoc,
                        szRegistryLoc,
                        downloadProgressCallback,
                        pUnmanagedUserDrivers,
                        pUnmanagedUserUpdates,
                        arrLen,
                        szRestorePointName,
                        nOsId,
                        (uint)updateFlag,
                        new StringBuilder(archivePath)
                        );
                }
                else
                {
                    if (nOsId == -1)
                    {
                        // call driver update function
                        retval = DUSDKHandler.updateDeviceDriversEx(
                            progressCallback,
                            szProductKey,
                            szAppDataLoc,
                            szTempLoc,
                            szRegistryLoc,
                            downloadProgressCallback,
                            pUnmanagedUserDrivers,
                            pUnmanagedUserUpdates,
                            arrLen,
                            szRestorePointName
                            );
                    }
                    else
                    {
                        // call driver update function
                        retval = DUSDKHandler.OSMT_updateDeviceDriversEx(
                            progressCallback,
                            szProductKey,
                            szAppDataLoc,
                            szTempLoc,
                            szRegistryLoc,
                            downloadProgressCallback,
                            pUnmanagedUserDrivers,
                            pUnmanagedUserUpdates,
                            arrLen,
                            szRestorePointName,
                            nOsId,
                            (uint)updateFlag,
                            new StringBuilder(archivePath)
                            );
                    }
                }

                if (retval == DUSDKHandler.DefineConstants.SUCCESS)
                {
                }
                else if (retval == DUSDKHandler.DefineConstants.CANCEL_INSTALL)
                {
                }
                else if (retval == DUSDKHandler.DefineConstants.FAIL)
                {
                    if (CurrentDispatcher.Thread != null)
                    {
                        CurrentDispatcher.BeginInvoke((Action)(() =>
                        {
                            ScanStatusTitle = WPFLocalizeExtensionHelpers.GetUIString("UpdateFailed");
                            ScanStatusText = string.Empty;
                        }));
                    }
                }
                else
                {
                    ; // check for error code
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString());
                System.Diagnostics.Trace.WriteLine(ex.ToString());
            }
            finally
            {
                // free memory
                if (pUnmanagedUserDrivers != IntPtr.Zero)
                {
                    Marshal.FreeHGlobal(pUnmanagedUserDrivers);
                }

                if (pUnmanagedUserUpdates != IntPtr.Zero)
                {
                    Marshal.FreeHGlobal(pUnmanagedUserUpdates);
                }

                pUnmanagedUserDrivers = IntPtr.Zero;
                pUnmanagedUserUpdates = IntPtr.Zero;

                bDriverUpdateIsGoingOn = false;
            }

            return retval;
        }
        /// <summary>-
        /// receives the progress of driver scan
        /// </summary>
        /// <param name="progressType"></param>
        /// <param name="data"></param>
        /// <param name="currentItemPos"></param>
        /// <param name="nTotalDriversToScan"></param>
        /// <param name="progress"></param>
        /// <returns></returns>
        public bool progressCallback(DUSDKHandler.PROGRESS_TYPE progressType, IntPtr data, int currentItemPos, int nTotalDriversToScan, int progress)
        {
            // here we will get the progress of driver scan.
            DriverData? dd = null;
            string category = string.Empty;
            string VersionInstalled = string.Empty;
            string VersionUpdated = string.Empty;
            DateTime dtInstalled;

            if (data != IntPtr.Zero)
            {
                dd = (DriverData)Marshal.PtrToStructure(
                            (IntPtr)(data.ToInt64() + currentItemPos * Marshal.SizeOf(typeof(DriverData))),
                            typeof(DriverData)
                            );

            }

            switch (progressType)
            {
                case DUSDKHandler.PROGRESS_TYPE.PROGRESS_SIZE_SCAN_DATA:
                    nTotalDrivers = nTotalDriversToScan;
                    driverData = new DriverData[nTotalDriversToScan];
                    UserUpdates = new Dictionary<int, DriverData>();
                    break;
                case DUSDKHandler.PROGRESS_TYPE.PROGRESS_SCANNING:
                    if (data != IntPtr.Zero && !bIsStopped)
                    {
                        driverData[currentItemPos] = (DriverData)dd;
                        string infName = string.Empty;
                        try
                        {
                            infName = new FileInfo(driverData[currentItemPos].location).Name;
                        }
                        catch
                        {
                        }
                        MigrationDeviceInfo item = new MigrationDeviceInfo(
                        null,
                        driverData[currentItemPos].category,
                        driverData[currentItemPos].driverName,
                        infName,
                        string.IsNullOrEmpty(driverData[currentItemPos].version) || driverData[currentItemPos].version == "null" ? string.Empty : driverData[currentItemPos].version,
                        currentItemPos.ToString(),
                        driverData[currentItemPos].hardwareId,
                        driverData[currentItemPos].CompatibleIdIndex.ToString()
                        );

                        dtInstalled = DateTime.FromFileTime(driverData[currentItemPos].ulDateTimeQuadPart);

                        string driverName = driverData[currentItemPos].driverName;
                        if (driverName.Length > 46)
                            driverName = driverName.Substring(0, 43) + "...";

                        if (CurrentDispatcher.Thread != null)
                        {
                            CurrentDispatcher.Invoke((MethodInvoker)delegate
                            {
                                ScanStatusText = driverName;
                                AllDevices.Add(item);
                            }
                            , null);
                        }
                    }
                    break;
                case DUSDKHandler.PROGRESS_TYPE.PROGRESS_RETRIEVING_UPDATES_DATA:
                    if (CurrentDispatcher.Thread != null)
                    {
                        CurrentDispatcher.Invoke((MethodInvoker)delegate
                        {
                            ScanStatusText = string.Empty;
                            ScanStatusTitle = WPFLocalizeExtensionHelpers.GetUIString("ContactingServer");
                        }, null);
                    }
                    break;
                //case DUSDKHandler.PROGRESS_TYPE.PROGRESS_RETRIEVING_UPDATES_FAILED_INET:
                //    break;
                case DUSDKHandler.PROGRESS_TYPE.PROGRESS_FILTERING_UPDATES:
                    if (data != IntPtr.Zero && !bIsStopped)
                    {
                        // get driver update information
                        DriverData DriverUpdate = (DriverData)Marshal.PtrToStructure(
                              (IntPtr)(data.ToInt64() + currentItemPos * Marshal.SizeOf(typeof(DriverData))),
                              typeof(DriverData)
                              );

                        if (CurrentDispatcher.Thread != null)
                        {
                            CurrentDispatcher.Invoke((MethodInvoker)delegate
                            {
                                MigrationDeviceInfo migrationDeviceInfo = AllDevices.Where(wh => wh.Id == currentItemPos.ToString()).FirstOrDefault();
                                if (migrationDeviceInfo != null)
                                {
                                    migrationDeviceInfo.IsDestOSDriverAvailable = true;
                                    migrationDeviceInfo.SelectedForDestOSDriverDownload = true;
                                    migrationDeviceInfo.DownloadLink = DriverUpdate.libURL;
                                }

                                UserUpdates.Add(currentItemPos, DriverUpdate);
                            }
                            , null);
                        }
                    }
                    break;
                case DUSDKHandler.PROGRESS_TYPE.PROGRESS_SCANNED:
                    //if (CurrentDispatcher.Thread != null)
                    //{
                    //    CurrentDispatcher.BeginInvoke((Action)(() =>
                    //    {
                    //        ScanStatusTitle = WPFLocalizeExtensionHelpers.GetUIString("ScanCompleted");
                    //        ScanStatusText = "";
                    //    }));
                    //}
                    break;
                case DUSDKHandler.PROGRESS_TYPE.PROGRESS_UPDATE_STARTED_FOR_SINGLE:
                    {
                        if (data != IntPtr.Zero && dd.HasValue)
                        {
                            if (CurrentDispatcher.Thread != null)
                            {
                                CurrentDispatcher.BeginInvoke((Action)(() =>
                                {
                                    // DownloadedDrivers.Add(new DownloadingDriverModel(WPFLocalizeExtensionHelpers.GetUIString("InstallingDriver"), devicesForUpdate[currentItemPos]));
                                    ScanStatusTitle = WPFLocalizeExtensionHelpers.GetUIString("InstallingDriver");
                                    // ScanStatusText = devicesForUpdate[currentItemPos].DeviceName;
                                }));
                            }
                        }
                    }
                    break;
                case DUSDKHandler.PROGRESS_TYPE.PROGRESS_UPDATE_END_FOR_SINGLE:
                    {
                        if (data != IntPtr.Zero && dd.HasValue)
                        {
                            if (CurrentDispatcher.Thread != null)
                            {
                                CurrentDispatcher.BeginInvoke((Action)(() =>
                                {
                                    //ScanStatusTitle =
                                    ScanStatusText = WPFLocalizeExtensionHelpers.GetUIString("UpdateCompleted") + " " + ((DriverData)dd).driverName;
                                }));
                            }
                        }
                    }
                    break;
                case DUSDKHandler.PROGRESS_TYPE.PROGRESS_UPDATE_SUCCESSFUL:
                    {
                    }
                    break;
                case DUSDKHandler.PROGRESS_TYPE.PROGRESS_UPDATE_FAILED:
                    {
                        if (data != IntPtr.Zero && dd.HasValue)
                        {
                            string driverName = ((DriverData)dd).driverName;
                            if (driverName.Length > 37)
                                driverName = driverName.Substring(0, 34) + "...";
                            if (CurrentDispatcher.Thread != null)
                            {
                                CurrentDispatcher.BeginInvoke((Action)(() =>
                                {
                                    ScanStatusTitle = WPFLocalizeExtensionHelpers.GetUIString("UpdateFailed") + " " + driverName;
                                    ScanStatusText = string.Empty;
                                }));
                            }
                        }
                    }
                    break;
                case DUSDKHandler.PROGRESS_TYPE.PROGRESS_UPDATE_END_FOR_ALL:
                    if (CurrentDispatcher.Thread != null)
                    {
                        CurrentDispatcher.BeginInvoke((Action)(() =>
                        {
                            CurrentDispatcher.BeginInvoke((Action)(() =>
                                {
                                    ScanFinishTitle = String.Format("{0} " + WPFLocalizeExtensionHelpers.GetUIString("DriversDownloaded"), DevicesForDestinationOS.Count());
                                    Status = ScanStatus.DownloadFinished;
                                    driverDownloading = false;
                                    ScanStatusTitle = ScanFinishTitle;
                                    ScanStatusText = string.Empty;
                                    driverIndex = 0;
                                    Progress = 0;
                                }));
                        }));
                    }
                    break;
                case DUSDKHandler.PROGRESS_TYPE.PROGRESS_DOWNLOAD_STARTED_FOR_SINGLE:
                    {
                        if (data != IntPtr.Zero && dd.HasValue)
                        {
                            string driverName = ((DriverData)dd).driverName;
                            if (driverName.Length > 23)
                                driverName = driverName.Substring(0, 20) + "...";

                            if (CurrentDispatcher.Thread != null)
                            {
                                CurrentDispatcher.BeginInvoke((Action)(() =>
                                {
                                    ScanStatusTitle = WPFLocalizeExtensionHelpers.GetUIString("DownloadingDriver");
                                    //string driverDownloadingDirectory = "";
                                    //string clearedDeviceName = DevicesForDestinationOS[driverIndex].DeviceName.Replace(" ", "").Replace(@"/", "");

                                    //try
                                    //{
                                    //    driverDownloadingDirectory = String.Format(@"{0}\{1}", DownloadsDirectory, clearedDeviceName);
                                    //    Directory.CreateDirectory(driverDownloadingDirectory);
                                    //}
                                    //catch { }
                                    //DriverUtils.SaveDir = driverDownloadingDirectory;
                                }));
                            }
                        }
                    }
                    break;
                case DUSDKHandler.PROGRESS_TYPE.PROGRESS_DOWNLOAD_END_FOR_SINGLE:
                    {
                        if (data != IntPtr.Zero && dd.HasValue)
                        {
                            if (CurrentDispatcher.Thread != null)
                            {
                                CurrentDispatcher.BeginInvoke((Action)(() =>
                                {
                                    ScanStatusTitle = WPFLocalizeExtensionHelpers.GetUIString("DownloadComplete") + " " + ((DriverData)dd).driverName;
                                    ScanStatusText = string.Empty;
                                    DestinationOSDevices.DownloadedDestinationOSDrivers.Add(
                                        new DestinationOSDeviceInfo(
                                            DevicesForDestinationOS[driverIndex].DeviceClass,
                                            DevicesForDestinationOS[driverIndex].DeviceClassName,
                                            DevicesForDestinationOS[driverIndex].DeviceName,
                                            DevicesForDestinationOS[driverIndex].InfName,
                                            DevicesForDestinationOS[driverIndex].Version,
                                            DevicesForDestinationOS[driverIndex].Id,
                                            DevicesForDestinationOS[driverIndex].HardwareID,
                                            DevicesForDestinationOS[driverIndex].CompatID
                                        )
                                    );
                                    driverIndex++;
                                }));
                            }
                        }
                    }
                    break;
                case DUSDKHandler.PROGRESS_TYPE.PROGRESS_DOWNLOAD_END_FOR_SINGLE_UNREG:
                    {
                        // download failed as user is unregistered
                    }
                    break;
                case DUSDKHandler.PROGRESS_TYPE.PROGRESS_DOWNLOAD_END_FOR_SINGLE_INET_ERROR:
                    {
                        // download failed because of Internet Error
                    }
                    break;
                default:
                    break;
            }

            if (progress > 0)
            {
                if (CurrentDispatcher.Thread != null)
                {
                    CurrentDispatcher.BeginInvoke((Action)(() =>
                    {
                        Progress = progress;
                    }));
                }
            }

            return true;
        }