Пример #1
0
        private void SetupListViewColumns()
        {
            this.driverSizeColumn.AspectToStringConverter = size => DriverStoreEntry.GetBytesReadable((long)size);

            this.driverOemInfColumn.GroupKeyGetter           = rowObject => ((DriverStoreEntry)rowObject).OemId / 10;
            this.driverOemInfColumn.GroupKeyToTitleConverter = groupKey =>
            {
                int?valueBase = (groupKey as int?) * 10;

                return(valueBase == null
                    ? null
                    : $"oem {valueBase} - {valueBase + 9}");
            };

            this.driverVersionColumn.GroupKeyGetter = rowObject =>
            {
                DriverStoreEntry driver = (DriverStoreEntry)rowObject;
                return(new Version(driver.DriverVersion.Major, driver.DriverVersion.Minor));
            };

            this.driverDateColumn.GroupKeyGetter = rowObject =>
            {
                DriverStoreEntry driver = (DriverStoreEntry)rowObject;
                return(new DateTime(driver.DriverDate.Year, driver.DriverDate.Month, 1));
            };

            this.driverDateColumn.GroupKeyToTitleConverter = groupKey => ((DateTime)groupKey).ToString("yyyy-MM");

            this.driverSizeColumn.GroupKeyGetter =
                rowObject => DriverStoreEntry.GetSizeRange(((DriverStoreEntry)rowObject).DriverSize);

            this.driverSizeColumn.GroupKeyToTitleConverter =
                groupKey => DriverStoreEntry.GetSizeRangeName((long)groupKey);
        }
Пример #2
0
        public DSEForm()
        {
            if (!IsOSSupported())
            {
                MessageBox.Show(Language.Message_Requires_Later_OS, Language.Product_Name, MessageBoxButtons.OK, MessageBoxIcon.Information);
                Application.Exit();
            }

            var lang = Properties.Settings.Default.Language;

            if (lang != null && CultureInfo.InvariantCulture != lang)
            {
                Thread.CurrentThread.CurrentCulture   = lang;
                Thread.CurrentThread.CurrentUICulture = lang;
            }

            this.InitializeComponent();

            this.Icon = ExtractAssociatedIcon(Application.ExecutablePath);
            this.BuildLanguageMenu();

            this.lstDriverStoreEntries.PrimarySortColumn   = this.driverClassColumn;
            this.lstDriverStoreEntries.PrimarySortOrder    = SortOrder.Ascending;
            this.lstDriverStoreEntries.SecondarySortColumn = this.driverDateColumn;
            this.lstDriverStoreEntries.SecondarySortOrder  = SortOrder.Descending;
            this.lstDriverStoreEntries.CheckBoxes          = isRunAsAdministrator;
            this.driverSizeColumn.AspectToStringConverter  = size => DriverStoreEntry.GetBytesReadable((long)size);

            this.driverVersionColumn.GroupKeyGetter = (object rowObject) =>
            {
                DriverStoreEntry driver = (DriverStoreEntry)rowObject;
                return(new Version(driver.DriverVersion.Major, driver.DriverVersion.Minor));
            };

            this.driverDateColumn.GroupKeyGetter = (object rowObject) =>
            {
                DriverStoreEntry driver = (DriverStoreEntry)rowObject;
                return(new DateTime(driver.DriverDate.Year, driver.DriverDate.Month, 1));
            };

            this.driverDateColumn.GroupKeyToTitleConverter = (object groupKey) => ((DateTime)groupKey).ToString("yyyy-MM");

            this.driverSizeColumn.GroupKeyGetter = (object rowObject) =>
            {
                DriverStoreEntry driver = (DriverStoreEntry)rowObject;
                return(DriverStoreEntry.GetSizeRange(driver.DriverSize));
            };

            this.driverSizeColumn.GroupKeyToTitleConverter = (object groupKey) => DriverStoreEntry.GetSizeRangeName((long)groupKey);

            Trace.TraceInformation("---------------------------------------------------------------");
            Trace.TraceInformation($"{Application.ProductName} started");

            this.driverStore = new PNPUtil();
        }
Пример #3
0
        public DSEForm()
        {
            if (!IsOSSupported())
            {
                MessageBox.Show("This utility cannot be run in pre-Vista OS", "Rapr", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Application.Exit();
            }

            InitializeComponent();

            this.Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath);

            lstDriverStoreEntries.PrimarySortColumn   = this.driverClassColumn;
            lstDriverStoreEntries.PrimarySortOrder    = SortOrder.Ascending;
            lstDriverStoreEntries.SecondarySortColumn = this.driverDateColumn;
            lstDriverStoreEntries.SecondarySortOrder  = SortOrder.Descending;
            lstDriverStoreEntries.CheckBoxes          = isRunAsAdministrator;
            driverSizeColumn.AspectToStringConverter  = size => DriverStoreEntry.GetBytesReadable((long)size);

            this.driverVersionColumn.GroupKeyGetter = delegate(object rowObject)
            {
                DriverStoreEntry driver = (DriverStoreEntry)rowObject;
                return(new Version(driver.DriverVersion.Major, driver.DriverVersion.Minor));
            };

            this.driverDateColumn.GroupKeyGetter = delegate(object rowObject)
            {
                DriverStoreEntry driver = (DriverStoreEntry)rowObject;
                return(new DateTime(driver.DriverDate.Year, driver.DriverDate.Month, 1));
            };

            this.driverDateColumn.GroupKeyToTitleConverter = delegate(object groupKey)
            {
                return(((DateTime)groupKey).ToString("yyyy-MM"));
            };

            this.driverSizeColumn.GroupKeyGetter = delegate(object rowObject)
            {
                DriverStoreEntry driver = (DriverStoreEntry)rowObject;
                return(DriverStoreEntry.GetSizeRange(driver.DriverSize));
            };

            this.driverSizeColumn.GroupKeyToTitleConverter = delegate(object groupKey)
            {
                return(DriverStoreEntry.GetSizeRangeName((long)groupKey));
            };

            Trace.TraceInformation("---------------------------------------------------------------");
            Trace.TraceInformation($"{Application.ProductName} started");

            driverStore = new PNPUtil();
        }
Пример #4
0
        public DSEForm()
        {
            InitializeComponent();

            lstDriverStoreEntries.PrimarySortColumn   = this.driverClassColumn;
            lstDriverStoreEntries.PrimarySortOrder    = SortOrder.Ascending;
            lstDriverStoreEntries.SecondarySortColumn = this.driverDateColumn;
            lstDriverStoreEntries.SecondarySortOrder  = SortOrder.Descending;
            lstDriverStoreEntries.CheckBoxes          = isRunAsAdministrator;
            driverSizeColumn.AspectToStringConverter  = size => DriverStoreEntry.GetBytesReadable((long)size);

            this.driverVersionColumn.GroupKeyGetter = delegate(object rowObject)
            {
                DriverStoreEntry driver = (DriverStoreEntry)rowObject;
                return(new Version(driver.DriverVersion.Major, driver.DriverVersion.Minor));
            };

            this.driverDateColumn.GroupKeyGetter = delegate(object rowObject)
            {
                DriverStoreEntry driver = (DriverStoreEntry)rowObject;
                return(new DateTime(driver.DriverDate.Year, driver.DriverDate.Month, 1));
            };

            this.driverDateColumn.GroupKeyToTitleConverter = delegate(object groupKey)
            {
                return(((DateTime)groupKey).ToString("yyyy-MM"));
            };

            this.driverSizeColumn.GroupKeyGetter = delegate(object rowObject)
            {
                DriverStoreEntry driver = (DriverStoreEntry)rowObject;
                return(DriverStoreEntry.GetSizeRange(driver.DriverSize));
            };

            this.driverSizeColumn.GroupKeyToTitleConverter = delegate(object groupKey)
            {
                return(DriverStoreEntry.GetSizeRangeName((long)groupKey));
            };

            AppContext.MainForm = this;
            AppContext.EnableLogging();
            driverStore = AppContext.GetDriverStoreHandler();
            if (!AppContext.IsOSSupported())
            {
                MessageBox.Show("This utility cannot be run in pre-Vista OS", "Rapr", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Application.Exit();
            }
        }
Пример #5
0
        private void SwitchCulture(object sender, EventArgs e, string cultureString)
        {
            CultureInfo ci = CultureInfo.GetCultureInfo(cultureString);

            Thread.CurrentThread.CurrentCulture   = ci;
            Thread.CurrentThread.CurrentUICulture = ci;

            // Clear and redraw the window
            this.Controls.Clear();
            this.InitializeComponent();
            this.lstDriverStoreEntries.PrimarySortColumn   = this.driverClassColumn;
            this.lstDriverStoreEntries.PrimarySortOrder    = SortOrder.Ascending;
            this.lstDriverStoreEntries.SecondarySortColumn = this.driverDateColumn;
            this.lstDriverStoreEntries.SecondarySortOrder  = SortOrder.Descending;
            this.driverSizeColumn.AspectToStringConverter  = size => DriverStoreEntry.GetBytesReadable((long)size);
            this.DSEForm_Shown(sender, e);
            Application.DoEvents();
        }
Пример #6
0
        public DSEForm()
        {
            InitializeComponent();
            lstDriverStoreEntries.AlwaysGroupByColumn    = this.driverClassColumn;
            lstDriverStoreEntries.AlwaysGroupBySortOrder = SortOrder.Ascending;
            lstDriverStoreEntries.PrimarySortColumn      = this.driverInfColumn;
            lstDriverStoreEntries.PrimarySortOrder       = SortOrder.Ascending;
            lstDriverStoreEntries.SecondarySortColumn    = this.driverVersionColumn;
            lstDriverStoreEntries.SecondarySortOrder     = SortOrder.Descending;
            driverSizeColumn.AspectToStringConverter     = size => DriverStoreEntry.GetBytesReadable((long)size);

            AppContext.MainForm = this;
            AppContext.EnableLogging();
            driverStore = AppContext.GetDriverStoreHandler();
            if (!AppContext.IsOSSupported())
            {
                MessageBox.Show("This utility cannot be run in pre-Vista OS", "Rapr", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Application.Exit();
            }
        }
Пример #7
0
        private void lstDriverStoreEntries_ItemChecked(object sender, ItemCheckedEventArgs e)
        {
            IList checkedObjects = lstDriverStoreEntries.CheckedObjects;

            if (checkedObjects != null && checkedObjects.Count > 0)
            {
                long totalSize = 0;

                foreach (DriverStoreEntry item in checkedObjects)
                {
                    totalSize += item.DriverSize;
                }

                ShowStatus($"Selected {checkedObjects.Count} Driver(s). Total size: {DriverStoreEntry.GetBytesReadable(totalSize)}.", Status.Normal);
            }
            else
            {
                ShowStatus($"Selected 0 Driver.", Status.Normal);
            }
        }
Пример #8
0
        private void SetupListViewColumns()
        {
            this.driverExtensionIdColumn.AspectToStringConverter = id => (Guid)id == Guid.Empty ? String.Empty : id.ToString();
            this.driverSizeColumn.AspectToStringConverter        = size => DriverStoreEntry.GetBytesReadable((long)size);

            this.driverOemInfColumn.GroupKeyGetter           = rowObject => ((DriverStoreEntry)rowObject).OemId / 10;
            this.driverOemInfColumn.GroupKeyToTitleConverter = groupKey =>
            {
                int?valueBase = (groupKey as int?) * 10;

                return(valueBase == null
                    ? null
                    : $"oem {valueBase} - {valueBase + 9}");
            };

            this.driverVersionColumn.GroupKeyGetter = rowObject =>
            {
                DriverStoreEntry driver = (DriverStoreEntry)rowObject;

                return(driver.DriverVersion == null
                    ? null
                    : new Version(driver.DriverVersion.Major, driver.DriverVersion.Minor));
            };

            this.driverDateColumn.GroupKeyGetter = rowObject =>
            {
                DriverStoreEntry driver = (DriverStoreEntry)rowObject;
                return(new DateTime(driver.DriverDate.Year, driver.DriverDate.Month, 1));
            };

            this.driverDateColumn.GroupKeyToTitleConverter = groupKey => ((DateTime)groupKey).ToString("yyyy-MM");

            this.driverSizeColumn.GroupKeyGetter =
                rowObject => DriverStoreEntry.GetSizeRange(((DriverStoreEntry)rowObject).DriverSize);

            this.driverSizeColumn.GroupKeyToTitleConverter =
                groupKey => DriverStoreEntry.GetSizeRangeName((long)groupKey);

            this.bootCriticalColumn.AspectToStringConverter = condition => (bool)(condition ?? false) ? Language.Column_Text_True : Language.Column_Text_False;
        }
Пример #9
0
        private void SwitchCulture(object sender, EventArgs e)
        {
            if ((sender as ToolStripMenuItem)?.Tag is CultureInfo ci)
            {
                Thread.CurrentThread.CurrentCulture   = ci;
                Thread.CurrentThread.CurrentUICulture = ci;

                // Clear and redraw the window
                this.Controls.Clear();
                this.InitializeComponent();
                this.BuildLanguageMenu();
                this.lstDriverStoreEntries.PrimarySortColumn   = this.driverClassColumn;
                this.lstDriverStoreEntries.PrimarySortOrder    = SortOrder.Ascending;
                this.lstDriverStoreEntries.SecondarySortColumn = this.driverDateColumn;
                this.lstDriverStoreEntries.SecondarySortOrder  = SortOrder.Descending;
                this.driverSizeColumn.AspectToStringConverter  = size => DriverStoreEntry.GetBytesReadable((long)size);
                this.DSEForm_Shown(sender, e);
                Application.DoEvents();

                Properties.Settings.Default.Language = ci;
                Properties.Settings.Default.Save();
            }
        }
Пример #10
0
        private void LstDriverStoreEntries_ItemChecked(object sender, ItemCheckedEventArgs e)
        {
            IList checkedObjects = this.lstDriverStoreEntries.CheckedObjects;

            if (checkedObjects?.Count > 0)
            {
                long totalSize = 0;

                foreach (DriverStoreEntry item in checkedObjects)
                {
                    totalSize += item.DriverSize;
                }

                this.ShowStatus(string.Format(
                                    Language.Status_Selected_Drivers,
                                    checkedObjects.Count.ToString(),
                                    DriverStoreEntry.GetBytesReadable(totalSize)),
                                Status.Normal);
            }
            else
            {
                this.ShowStatus(Language.Status_No_Drivers_Selected, Status.Normal);
            }
        }
Пример #11
0
        private void UpdateCheckedItemSize()
        {
            IList checkedObjects = this.lstDriverStoreEntries.CheckedObjects;

            if (checkedObjects?.Count > 0)
            {
                long totalSize = 0;

                foreach (DriverStoreEntry item in checkedObjects)
                {
                    totalSize += item.DriverSize;
                }

                this.ShowStatus(
                    Status.Normal,
                    string.Format(Language.Status_Selected_Drivers, checkedObjects.Count, DriverStoreEntry.GetBytesReadable(totalSize)));
            }
            else
            {
                this.ShowStatus(Status.Normal, Language.Status_No_Drivers_Selected);
            }

            this.buttonDeleteDriver.Enabled = this.lstDriverStoreEntries.CheckedObjects.Count > 0;
            this.cbForceDeletion.Enabled    = this.buttonDeleteDriver.Enabled;
        }
Пример #12
0
        private void UpdateCheckedItemSize()
        {
            IList checkedObjects = this.lstDriverStoreEntries.CheckedObjects;

            if (checkedObjects?.Count > 0)
            {
                long          totalSize  = 0;
                List <string> driverList = new List <string>();

                foreach (DriverStoreEntry item in checkedObjects)
                {
                    totalSize += item.DriverSize;
                    driverList.Add($"{item.DriverPublishedName} - {item.DriverFolderName} - {DriverStoreEntry.GetBytesReadable(item.DriverSize)}");
                }

                string message = string.Format(Language.Status_Selected_Drivers, checkedObjects.Count, DriverStoreEntry.GetBytesReadable(totalSize));
                this.ShowStatus(
                    Status.Normal,
                    message,
                    message + Environment.NewLine + string.Join(Environment.NewLine, driverList));
            }
            else
            {
                this.ShowStatus(Status.Normal, Language.Status_No_Drivers_Selected);
            }

            this.buttonDeleteDriver.Enabled = this.lstDriverStoreEntries.CheckedObjects.Count > 0;
            this.cbForceDeletion.Enabled    = this.buttonDeleteDriver.Enabled;
        }
Пример #13
0
        private async Task DeleteDriverStorePackages(List <DriverStoreEntry> driverStoreEntries)
        {
            StringBuilder details = new StringBuilder();

            foreach (DriverStoreEntry item in driverStoreEntries)
            {
                details.AppendLine($"{item.DriverPublishedName} - {item.DriverFolderName} - {DriverStoreEntry.GetBytesReadable(item.DriverSize)}");
            }

            bool force = this.cbForceDeletion.Checked;

            try
            {
                this.StartOperation();

                this.ShowStatus(
                    Status.Normal,
                    Language.Status_Deleting_Packages,
                    $"{Language.Status_Deleting_Packages}{Environment.NewLine}{details.ToString().Trim()}");

                (bool allSucceeded, string detailResult, List <DriverStoreEntry> allDriverStoreEntries) = await Task.Run(() =>
                {
                    bool totalResult = true;
                    StringBuilder sb = new StringBuilder();

                    if (driverStoreEntries.Count == 1)
                    {
                        totalResult = this.driverStore.DeleteDriver(driverStoreEntries[0], force);
                    }
                    else
                    {
                        foreach (DriverStoreEntry entry in driverStoreEntries)
                        {
                            bool succeeded   = this.driverStore.DeleteDriver(entry, force);
                            string resultTxt = string.Format(
                                succeeded ? Language.Message_Delete_Success : Language.Message_Delete_Fail,
                                entry.DriverPublishedName,
                                entry.DriverFolderName);

                            Trace.TraceInformation(resultTxt);

                            sb.AppendLine(resultTxt);
                            totalResult &= succeeded;
                        }
                    }

                    var updatedDriverStoreEntries = totalResult
                        ? new List <DriverStoreEntry>()
                        : this.driverStore.EnumeratePackages();

                    return(totalResult, sb.ToString(), updatedDriverStoreEntries);
                }).ConfigureAwait(true);

                if (allSucceeded)
                {
                    this.lstDriverStoreEntries.RemoveObjects(driverStoreEntries);
                }
                else
                {
                    this.lstDriverStoreEntries.SetObjects(allDriverStoreEntries);
                    this.UpdateColumnSize();
                }

                string resultText;
                if (allSucceeded)
                {
                    if (driverStoreEntries.Count == 1)
                    {
                        resultText = string.Format(
                            Language.Message_Delete_Package,
                            driverStoreEntries[0].DriverInfName,
                            driverStoreEntries[0].DriverPublishedName);
                    }
                    else
                    {
                        resultText = string.Format(
                            Language.Message_Delete_Packages,
                            driverStoreEntries.Count.ToString());
                    }

                    this.ShowStatus(Status.Success, resultText);
                }
                else
                {
                    string fullResult = null;

                    if (driverStoreEntries.Count == 1)
                    {
                        resultText = string.Format(
                            Language.Message_Delete_Package_Error,
                            driverStoreEntries[0].DriverInfName,
                            driverStoreEntries[0].DriverPublishedName);

                        if (!force)
                        {
                            resultText += Environment.NewLine + Language.Tip_Driver_In_Use;
                        }
                    }
                    else
                    {
                        resultText = Language.Message_Delete_Packages_Error;

                        if (!force)
                        {
                            resultText += Environment.NewLine + Language.Tip_Driver_In_Use;
                        }

                        fullResult = $"{resultText}{Environment.NewLine}{detailResult}";
                    }

                    this.ShowStatus(Status.Error, resultText, fullResult, true);
                }

                this.cbForceDeletion.Checked = false;
            }
            catch (Exception ex)
            {
                this.ShowStatus(Status.Error, ex.Message, ex.ToString(), true);
            }
            finally
            {
                this.EndOperation();
            }
        }
Пример #14
0
        private async Task DeleteDriverStoreEntries(List <DriverStoreEntry> driverStoreEntries)
        {
            StringBuilder msgWarning = new StringBuilder();

            if (driverStoreEntries?.Count > 0)
            {
                if (driverStoreEntries.Count == 1)
                {
                    msgWarning.AppendFormat(
                        this.cbForceDeletion.Checked ? Language.Message_ForceDelete_Single_Package : Language.Message_Delete_Single_Package,
                        driverStoreEntries[0].DriverPublishedName,
                        driverStoreEntries[0].DriverFolderName);
                }
                else
                {
                    msgWarning.AppendFormat(
                        this.cbForceDeletion.Checked ? Language.Message_ForceDelete_Multiple_Packages : Language.Message_Delete_Multiple_Packages,
                        driverStoreEntries.Count);

                    msgWarning.AppendLine();

                    foreach (DriverStoreEntry item in driverStoreEntries)
                    {
                        msgWarning.AppendLine($"{item.DriverPublishedName} - {item.DriverFolderName} - {DriverStoreEntry.GetBytesReadable(item.DriverSize)}");
                    }
                }

                msgWarning.AppendLine().Append(Language.Message_Sure);

                if (DialogResult.OK == this.ShowMessageBox(
                        msgWarning.ToString(),
                        Language.Message_Title_Warning,
                        MessageBoxButtons.OKCancel,
                        MessageBoxIcon.Warning))
                {
                    await this.DeleteDriverStorePackages(driverStoreEntries).ConfigureAwait(true);
                }
            }
        }