void RunInstall() { driversToInstall = allDrivers.DownloadedDestinationOSDrivers.Where(d => d.SelectedForInstall).ToList(); if (driversToInstall.Count == 0) { WPFMessageBox.Show(WPFLocalizeExtensionHelpers.GetUIString("SelectAtLeastOneDriver"), WPFLocalizeExtensionHelpers.GetUIString("SelectDrivers"), WPFMessageBoxButton.OK, MessageBoxImage.Exclamation); return; } Progress = 0; InstallStatusTitle = WPFLocalizeExtensionHelpers.GetUIString("InstallingDrivers"); InstallStatusText = string.Empty; PanelScanHeader = WPFLocalizeExtensionHelpers.GetUIString("InstallingDrivers"); Status = InstallStatus.Started; DriverIndex = 0; if (ABORT) { ABORT = false; return; } bgInstall = new BackgroundWorker(); bgInstall.DoWork += DriverInstall; bgInstall.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bgInstall_RunWorkerCompleted); bgInstall.WorkerSupportsCancellation = true; bgInstall.RunWorkerAsync(); }
private void OptionChanged(object sender, SelectionChangedEventArgs e) { var context = (ComboBox)sender; if (context.SelectedIndex == 0) { if (PanelLicense.Visibility == Visibility.Visible) { ShowPanelPreferences2(); } else { ShowPanelPreferences(); } } if (context.SelectedIndex == 1) { OpenOSMigrationToolPopup(); } if (context.SelectedIndex == 2) { Process.Start(new ProcessStartInfo(WPFLocalizeExtensionHelpers.GetUIString("FeedbackUrl"))); } // This needed to save state unchecked context.SelectedIndex = -1; }
public void UnZipDriverData() { tempDirectory = String.Format(@"{0}\Freemium Driver Utilities\Temp", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)); try { Directory.Delete(tempDirectory); Directory.CreateDirectory(tempDirectory); } catch { } if (File.Exists(ZipToUnpack)) { string unpackDirectory = tempDirectory; using (ZipFile zipFile = ZipFile.Read(ZipToUnpack)) { // here we extract every entry foreach (ZipEntry e in zipFile) { e.Extract(unpackDirectory, ExtractExistingFileAction.OverwriteSilently); } } } else { WPFMessageBox.Show(WPFLocalizeExtensionHelpers.GetUIString("DriverDataNotFound"), WPFLocalizeExtensionHelpers.GetUIString("FileNotFound"), WPFMessageBoxButton.OK, MessageBoxImage.Error); Close(); } }
private void SelectDestinationDirectory_Click(object sender, System.Windows.RoutedEventArgs e) { VistaFolderBrowserDialog dialog = new VistaFolderBrowserDialog(); dialog.Description = WPFLocalizeExtensionHelpers.GetUIString("SelectFolderForDownloads"); dialog.UseDescriptionForTitle = true; // This applies to the Vista style dialog only, not the old dialog. if ((bool)dialog.ShowDialog()) { if (!String.IsNullOrEmpty(dialog.SelectedPath)) { DestinationDirectory.Text = dialog.SelectedPath; } } }
void SetDaysFromLastScanProgressBarValue(int daysFromLastScan) { int daysFromLastScanProgress = daysFromLastScan * 360 / MainWindowViewModel.DaysFromLastScanMax; if (daysFromLastScan == 0) { DaysFromLastScan.FontSize = 30; DaysFromLastScan.Margin = new Thickness(2, 56, 0, 0); LocalizeDictionary.Instance.Culture = CultureInfo.GetCultureInfo(CfgFile.Get("Lang")); DaysFromLastScan.Text = WPFLocalizeExtensionHelpers.GetUIString("Today"); DaysAgoText.Visibility = System.Windows.Visibility.Hidden; Gradient.Visibility = Visibility.Collapsed; MoreThan.Visibility = Visibility.Collapsed; return; } DaysFromLastScan.Text = daysFromLastScan.ToString(CultureInfo.InvariantCulture); if ((daysFromLastScanProgress < 359 && daysFromLastScanProgress > 0) || (daysFromLastScan <= MainWindowViewModel.DaysFromLastScanMax && daysFromLastScan > 0)) { Gradient.Visibility = Visibility.Visible; DaysFromLastScanProgressBar.Visibility = Visibility.Visible; MoreThan.Visibility = Visibility.Collapsed; DaysFromLastScanProgressBar.RotationAngle = daysFromLastScanProgress; DaysFromLastScanProgressBar.WedgeAngle = 360 - daysFromLastScanProgress; DaysFromLastScanProgressBar.Visibility = Visibility.Visible; } else { if (daysFromLastScan > 0) { MoreThan.Visibility = Visibility.Visible; DaysFromLastScan.Text = MainWindowViewModel.DaysFromLastScanMax.ToString(CultureInfo.InvariantCulture); DaysFromLastScanProgressBar.RotationAngle = 0; DaysFromLastScanProgressBar.WedgeAngle = 0; DaysFromLastScanProgressBar.Visibility = Visibility.Collapsed; } else { if (daysFromLastScan == 0) { Gradient.Visibility = Visibility.Collapsed; } } } if (daysFromLastScan == MainWindowViewModel.DaysFromLastScanMax) { DaysFromLastScanProgressBar.Visibility = Visibility.Collapsed; } }
void RunCancelInstall() { ABORT = true; if (bgInstall.IsBusy) { bgInstall.CancelAsync(); } CancelOperation(); InstallFinishTitle = String.Format("{0} " + WPFLocalizeExtensionHelpers.GetUIString("DriversInstalled"), DriverIndex + 1); Status = InstallStatus.NotStarted; InstallStatusTitle = InstallFinishTitle; InstallStatusText = string.Empty; Progress = 0; }
/// <summary> /// Opens a specified URL with a system default browser /// </summary> /// <param name="url">URL to open</param> /// <param name="e"></param> public void OpenUrl(string url, RoutedEventArgs e) { try { ProcessStartInfo psi = new ProcessStartInfo("iexplore", "-new " + url); Process.Start(psi); } catch (Exception) { MessageBox.Show(WPFLocalizeExtensionHelpers.GetUIString("UrlCannotBeOpenedMessage") + Environment.NewLine + url, WPFLocalizeExtensionHelpers.GetUIString("UrlCannotBeOpenedTitle"), MessageBoxButton.OK, MessageBoxImage.Information); } e.Handled = true; }
void selectRestoreZipPath_Click(object sender, RoutedEventArgs e) { var dialog = new VistaOpenFileDialog(); dialog.CheckFileExists = true; dialog.Filter = "|DriverData.zip"; dialog.Title = WPFLocalizeExtensionHelpers.GetUIString("SelectDriversZip"); var showDialog = dialog.ShowDialog(); if (showDialog != null && (bool)showDialog) { if (!String.IsNullOrEmpty(dialog.FileName)) { restoreZipPath.Text = dialog.FileName; } } }
void bgInstall_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (!ABORT) { if (CurrentDispatcher.Thread != null) { CurrentDispatcher.BeginInvoke((Action)(() => { InstallFinishTitle = String.Format("{0} " + WPFLocalizeExtensionHelpers.GetUIString("DriversInstalled"), driversToInstall.Count()); Status = InstallStatus.Finished; InstallStatusTitle = InstallFinishTitle; InstallStatusText = ""; DriverIndex = 0; })); } } }
private void selectBackupsFolder_Click(object sender, RoutedEventArgs e) { var dialog = new VistaFolderBrowserDialog { Description = WPFLocalizeExtensionHelpers.GetUIString("SelectFolderForBackups"), UseDescriptionForTitle = true }; // This applies to the Vista style dialog only, not the old dialog. var showDialog = dialog.ShowDialog(); if (showDialog != null && (bool)showDialog) { if (!String.IsNullOrEmpty(dialog.SelectedPath)) { backupsFolder.Text = dialog.SelectedPath; } } }
/// <summary> /// Reads driver data from the XML file /// </summary> public void ReadDriverDataFromXML() { string driverDataXMLFilePath = String.Format(@"{0}\DriverData.xml", tempDirectory); if (File.Exists(driverDataXMLFilePath)) { try { var xs = new XmlSerializer(typeof(DestinationOSDevices)); using (var rd = new StreamReader(driverDataXMLFilePath)) { allDrivers = xs.Deserialize(rd) as DestinationOSDevices; } UpdateGroupedDevices(); } catch { } } else { WPFMessageBox.Show(WPFLocalizeExtensionHelpers.GetUIString("DriverDataXMLNotFound"), WPFLocalizeExtensionHelpers.GetUIString("FileNotFound"), WPFMessageBoxButton.OK, MessageBoxImage.Error); Close(); } }
public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) { string tmpValue = WPFLocalizeExtensionHelpers.GetUIString(parameter.ToString()); return(new Thickness(System.Convert.ToDouble(tmpValue), 0, 0, 0)); }
/// <summary> /// Opens the Freemium Utilities Google+ page /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Click_GooglePlus(object sender, RoutedEventArgs e) { OpenUrl(WPFLocalizeExtensionHelpers.GetUIString("GooglePlusUrl"), e); }
/// <summary> /// Opens the Freemium Utilities Twitter page /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Click_Twitter(object sender, RoutedEventArgs e) { OpenUrl(WPFLocalizeExtensionHelpers.GetUIString("TwitterUrl"), e); }
/// <summary> /// Opens the Freemium Utilities Facebook page /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Click_Facebook(object sender, RoutedEventArgs e) { OpenUrl(WPFLocalizeExtensionHelpers.GetUIString("FBUrl"), e); }
/// <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); }
void RunOSMigrationRestoreTool(object sender, RoutedEventArgs e) { if (File.Exists(restoreZipPath.Text)) { var psi = new ProcessStartInfo(String.Format(@"{0}\DriversGalaxy.OSMigrationTool.Restore.exe", appDir)) { Arguments = "\"" + restoreZipPath.Text + "\"" }; Process.Start(psi); } else { WPFMessageBox.Show(Application.Current.MainWindow, LocalizeDictionary.Instance.Culture, WPFLocalizeExtensionHelpers.GetUIString("SelectMigrationDriversZip"), WPFLocalizeExtensionHelpers.GetUIString("SelectDriversZip"), WPFMessageBoxButton.OK, MessageBoxImage.Exclamation); } }
/// <summary> /// Opens the root URL of the Freemium Utilites website /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void OpenRootUrl(object sender, RoutedEventArgs e) { OpenUrl(WPFLocalizeExtensionHelpers.GetUIString("RootUrl"), e); }
void SaveTask() { bool isNewTask = true; try { var service = new TaskService(); TaskDefinition td = service.NewTask(); Microsoft.Win32.TaskScheduler.TriggerCollection trgCollection; var oldTriggerDate = new DateTime(); Task task = service.FindTask(MainWindowViewModel.DriversGalaxyTaskName); if (task != null) { isNewTask = false; oldTriggerDate = task.Definition.Triggers.Count > 0 ? task.Definition.Triggers[0].StartBoundary.Date : DateTime.Today; task.Definition.Triggers.Clear(); trgCollection = task.Definition.Triggers; } else { td.RegistrationInfo.Description = WPFLocalizeExtensionHelpers.GetUIString("WindowsTaskRegistrationInfo"); td.Settings.Enabled = true; td.Actions.Add(new ExecAction(Environment.CurrentDirectory + @"\1Click.exe")); trgCollection = td.Triggers; } TimeSpan selectedTime = TimeSpan.Parse(((ComboBoxItem)AutoScanTime.SelectedValue).Content.ToString()); switch (AutoScanPeriod.SelectedIndex) { case (int)Schedule.Daily: { var dTrigger = new DailyTrigger { DaysInterval = 1 }; if (isNewTask) { dTrigger.StartBoundary = DateTime.Today.Date + selectedTime; } else { dTrigger.StartBoundary = oldTriggerDate + selectedTime; } trgCollection.Add(dTrigger); break; } case (int)Schedule.Weekly: { var wTrigger = new WeeklyTrigger(); switch (AutoScanDay.SelectedIndex) { case (int)DayOfWeek.Monday: { wTrigger.DaysOfWeek = DaysOfTheWeek.Monday; break; } case (int)DayOfWeek.Tuesday: { wTrigger.DaysOfWeek = DaysOfTheWeek.Tuesday; break; } case (int)DayOfWeek.Wednesday: { wTrigger.DaysOfWeek = DaysOfTheWeek.Wednesday; break; } case (int)DayOfWeek.Thursday: { wTrigger.DaysOfWeek = DaysOfTheWeek.Thursday; break; } case (int)DayOfWeek.Friday: { wTrigger.DaysOfWeek = DaysOfTheWeek.Friday; break; } case (int)DayOfWeek.Saturday: { wTrigger.DaysOfWeek = DaysOfTheWeek.Saturday; break; } case (int)DayOfWeek.Sunday: { wTrigger.DaysOfWeek = DaysOfTheWeek.Sunday; break; } } trgCollection.Add(wTrigger); foreach (WeeklyTrigger trg in trgCollection) { if (isNewTask) { trg.StartBoundary = DateTime.Today.Date + selectedTime; } else { trg.StartBoundary = oldTriggerDate + selectedTime; } trg.WeeksInterval = 1; } break; } case (int)Schedule.Monthly: { var mTrigger = new MonthlyTrigger(); if (isNewTask) { mTrigger.StartBoundary = DateTime.Today.Date + selectedTime; } else { mTrigger.StartBoundary = oldTriggerDate + selectedTime; } mTrigger.MonthsOfYear = MonthsOfTheYear.AllMonths; mTrigger.DaysOfMonth = new int[] { Int16.Parse(((ComboBoxItem)AutoScanDate.SelectedValue).Content.ToString()) }; trgCollection.Add(mTrigger); break; } } // Register the task in the root folder if (isNewTask) { service.RootFolder.RegisterTaskDefinition(MainWindowViewModel.DriversGalaxyTaskName, td); } else { task.RegisterChanges(); } TaskManager.UpdateTaskStatus(MainWindowViewModel.DriversGalaxyTaskName, AutoScan.IsChecked == true); } catch { } }