示例#1
0
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            String to_save = "alias,full_path,parameters\n";

            foreach (Alias alias in AliasGrid.ItemsSource.Cast <Alias>())
            {
                to_save += alias.alias + "," + alias.full_path + "," + alias.parameters + "\n";
            }
            try
            {
                File.WriteAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/FLauncher" + "/Aliases.csv", to_save);
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Save Failed", AdonisUI.Controls.MessageBoxButton.OK);
            }
            Settings1.Default.Save();

            if (Settings1.Default.PromptApplyChanges == true)
            {
                MessageBox.Show(applyChanges);

                if (applyChanges.Result == AdonisUI.Controls.MessageBoxResult.Custom)
                {
                    Settings1.Default.PromptApplyChanges = false;
                    Settings1.Default.Save();
                }
            }
        }
        public bool Show()
        {
            var messageBox = new MessageBoxModel {
                Text    = "Baza danych już istnieje. Czy chcesz ją usunąć?",
                Caption = "Info",
                Icon    = MessageBoxImage.Question,
                Buttons = new[] {
                    MessageBoxButtons.Yes("Tak"),
                    MessageBoxButtons.No("Nie")
                },
                IsSoundEnabled = false
            };
            var buttons = messageBox.Buttons.ToArray();

            buttons[0].IsDefault = false;
            buttons[1].IsDefault = true;
            MessageBox.Show(messageBox);

            switch (messageBox.Result)
            {
            case MessageBoxResult.No:
                return(false);

            case MessageBoxResult.Yes:
                return(true);

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        public bool Show()
        {
            var messageBox = new MessageBoxModel {
                Text    = "Czy na pewno chcesz usunąć książkę?",
                Caption = "Info",
                Icon    = MessageBoxImage.Warning,
                Buttons = new[] {
                    MessageBoxButtons.Yes("Tak"),
                    MessageBoxButtons.No("Nie")
                },
                IsSoundEnabled = false
            };

            MessageBox.Show(messageBox);

            switch (messageBox.Result)
            {
            case MessageBoxResult.No:
                return(false);

            case MessageBoxResult.Yes:
                return(true);

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
示例#4
0
        private void DebugToolstripItem_Click(object sender, RoutedEventArgs e)
        {
            if (settings.AdvancedMode)
            {
                var parent = Application.Current.MainWindow;
                if (parent != null)
                {
                    var debugWnd = new DebugDialog(cpu, modules, MEMCFG, BMC, AsusWmi)
                    {
                        Owner = parent, Width = parent.Width, Height = parent.Height
                    };
                    debugWnd.ShowDialog();
                }
            }
            else
            {
                var messageBox = new MessageBoxModel
                {
                    Text = "Debug functionality requires Advanced Mode.\n\n" +
                           "Do you want to enable it now (the application will restart automatically)?",
                    Caption = "Debug Report",
                    Buttons = MessageBoxButtons.YesNoCancel()
                };

                MessageBox.Show(messageBox);

                if (messageBox.Result == MessageBoxResult.Yes)
                {
                    settings.AdvancedMode = true;
                    Restart();
                }
            }
        }
示例#5
0
        private void OnUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
        {
            Log.Error("{Exception}", e.Exception);

            var messageBox = new MessageBoxModel
            {
                Text    = $"An unhandled exception occurred: {e.Exception.Message}",
                Caption = "Fatal Error",
                Icon    = MessageBoxImage.Error,
                Buttons = new[]
                {
                    MessageBoxButtons.Custom("Reset Settings", EErrorKind.ResetSettings),
                    MessageBoxButtons.Custom("Restart", EErrorKind.Restart),
                    MessageBoxButtons.Custom("OK", EErrorKind.Ignore)
                },
                IsSoundEnabled = false
            };

            MessageBox.Show(messageBox);
            if (messageBox.Result == MessageBoxResult.Custom && (EErrorKind)messageBox.ButtonPressed.Id != EErrorKind.Ignore)
            {
                if ((EErrorKind)messageBox.ButtonPressed.Id == EErrorKind.ResetSettings)
                {
                    UserSettings.Delete();
                }

                ApplicationService.ApplicationView.Restart();
            }

            e.Handled = true;
        }
示例#6
0
        private void PInfoListItem_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            ListBoxItem senderItem = sender as ListBoxItem;
            string      toDownload = senderItem.Tag.ToString();

            MessageBoxModel downloadMsg = new MessageBoxModel
            {
                Text    = "Downloading file from this url: " + toDownload,
                Caption = "Confirm download",
                Icon    = AdonisUI.Controls.MessageBoxImage.Information,
                Buttons = new[]
                {
                    MessageBoxButtons.Ok(),
                            MessageBoxButtons.Cancel(),
                },
            };

            MessageBox.Show(downloadMsg);

            if (downloadMsg.Result == AdonisUI.Controls.MessageBoxResult.OK)
            {
                new WebClient().DownloadFile(new Uri(toDownload), Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\FLauncher\Plugins\" + senderItem.Content + ".dll");
                MessageBox.Show("Plugin download complete, restart FLauncher to use it", "Download Complete");
            }
        }
示例#7
0
        private void LoadPlugins()
        {
            var github = new GitHubClient(new ProductHeaderValue("FLauncher"));

            github.Credentials = creds;

            var contents = github.Repository.Content.GetAllContents("Oliveoil1", "Flauncher.Plugins", "metadata").Result;

            foreach (RepositoryContent r in contents)
            {
                try
                {
                    var pInfo = JsonSerializer.Deserialize <PluginInfo>(new WebClient().DownloadString(r.DownloadUrl));

                    var pInfoListItem = new ListBoxItem();
                    pInfoListItem.Content           = pInfo.Name;
                    pInfoListItem.ToolTip           = pInfo.Description + " | Version " + pInfo.Version;
                    pInfoListItem.MouseDoubleClick += PInfoListItem_MouseDoubleClick;
                    pInfoListItem.Tag = pInfo.DownloadUrl;

                    PluginInfoList.Items.Add(pInfoListItem);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error");
                }
            }
        }
示例#8
0
 public void HandleError(string message, string title = "Error")
 {
     MessageBox.Show(
         message,
         title,
         MessageBoxButton.OK,
         MessageBoxImage.Error
         );
 }
示例#9
0
        /// <summary>
        /// Uncaught exceptions handler implementation
        /// </summary>
        /// <param name="exceptionObject"></param>
        /// <param name="isTerminating">true if exception is not resumable</param>
        static void MyExceptionHandler(object exceptionObject, bool isTerminating)
        {
            if (!isTerminating)
            {
                Logger?.Error(exceptionObject as Exception, "Intercepted resumable unhandled exception.");
                return;
            }

            // Process unhandled exception
            try
            {
                if (Logger != null)
                {
                    var m = $"Something went wrong... The application will now close. {_osInfo}";
                    if (exceptionObject is Exception e)
                    {
                        Logger.Error(e, m);
                        m += $"Exception was: {e}";
                    }
                    else
                    {
                        Logger.Error(m);
                        Logger.Info("Exception object is {0}", exceptionObject);
                    }
                    MessageBox.Show($"{m}", "Application Crash Report", MessageBoxButton.OK, MessageBoxImage.Error);
                }


                try
                {
                    // https://stackoverflow.com/questions/10492720/should-nlog-flush-all-queued-messages-in-the-asynctargetwrapper-when-flush-is
                    LogManager.Flush();
                    LogManager.Shutdown();
                }
                catch (Exception ex)
                {
                    try
                    {
                        Logger?.Error(ex, "Failed to shutdown NLog gracefully.");
                    }
                    catch (Exception)
                    {
                        // ignored
                    } // nothing to do really here but at least don't prevent critical code to continue to run below...
                }

                Environment.Exit(-1);
            }

            catch (Exception)
            {
                // if we are here, it means everything else failed,
                // so just exit as fast as possible (if BE is present watchdog timers will then invalidate HW ASAP) ...
                Process.GetCurrentProcess().Kill();
            }
        }
示例#10
0
 private void OnRemoveAllDlls(object sender, RoutedEventArgs args)
 {
     if (!(DllList.Items.Count > 0))
     {
         return;
     }
     if (MessageBox.Show("Are you sure you want to remove all libraries?", "Libjector", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
     {
         Context.DllList.Clear();
     }
 }
示例#11
0
 private void OnRemoveDll(object sender, RoutedEventArgs args)
 {
     if (DllList.SelectedItem is not DllItemModel item)
     {
         return;
     }
     if (MessageBox.Show("Are you sure you want to remove this library?", "Libjector", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
     {
         Context.DllList.Remove(item);
     }
 }
示例#12
0
        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxResult result = MessageBox.Show("Are you sure you want to delete this item?",
                                                      "Delete item", MessageBoxButton.YesNo);

            if (result == MessageBoxResult.Yes)
            {
                DataChanged = false;
                this.Close();
            }
        }
        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxResult result = MessageBox.Show(
                "Are you sure you want to cancel? All changes or potential additions could be lost.",
                "Sure?", MessageBoxButton.YesNo);

            if (result == MessageBoxResult.Yes)
            {
                this.Close();
            }
        }
示例#14
0
        public MainWindow()
        {
            ToolTipService.InitialShowDelayProperty.OverrideMetadata(
                typeof(FrameworkElement), new FrameworkPropertyMetadata(250));
            ToolTipService.ShowDurationProperty.OverrideMetadata(
                typeof(FrameworkElement), new FrameworkPropertyMetadata(int.MaxValue));

            InitializeComponent();

            DataContext = _vm;

            if (ApplicationConfiguration.Instance.HasAcknowledgedDonationDialog)
            {
                return;
            }

            var messageBox = new MessageBoxModel
            {
                Text =
                    "Hello, Gamer! \r\n\r\nDid you know this project was only possible with years of dedication and enthusiasm? " +
                    "You're receiving this work for absolutely free. If it brings you joy please consider giving back to the "
                    + "author's efforts and show your appreciation through a donation. \r\n\r\nThanks for your attention ❤️",
                Caption = "May I have your attention",
                Icon    = MessageBoxImage.Question,
                Buttons = new[]
                {
                    MessageBoxButtons.Cancel("Acknowledged"),
                    MessageBoxButtons.Yes("Sure, show me how!")
                },
                CheckBoxes = new[]
                {
                    new MessageBoxCheckBoxModel("I've already donated or will consider it")
                    {
                        IsChecked = false,
                        Placement = MessageBoxCheckBoxPlacement.BelowText
                    }
                },
                IsSoundEnabled = false
            };

            MessageBox.Show(messageBox);

            switch (messageBox.Result)
            {
            case MessageBoxResult.Yes:
                Process.Start("https://vigem.org/Donations/");
                break;
            }

            ApplicationConfiguration.Instance.HasAcknowledgedDonationDialog =
                messageBox.CheckBoxes.First().IsChecked;
        }
示例#15
0
        private async void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxResult results = MessageBox.Show("Ae you sure you want to delete this item?", "Confirm deletion", MessageBoxButton.YesNo);

            if (results == MessageBoxResult.Yes)
            {
                var selected = (CovidResponses)lvResponses.SelectedItems[0];

                await _context.DeleteItemAsync <CovidResponses>(selected.Id,
                                                                new Microsoft.Azure.Cosmos.PartitionKey(selected.Date),
                                                                _context.CovidResponsesContainer);
                await UpdateData();
            }
        }
示例#16
0
        private void Install_Plugin_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "Dynamic-Link Libraries (*.dll)|*.dll|All Files (*.*)|*.*";

            Nullable <bool> result = openFileDialog.ShowDialog();

            if (result == true)
            {
                File.Copy(openFileDialog.FileName, Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/FLauncher/Plugins/" + openFileDialog.SafeFileName);
                MessageBox.Show(installedPlugin);
            }
        }
示例#17
0
        private void OnOverwriteMaterialClick(object sender, RoutedEventArgs e)
        {
            _applicationView.CUE4Parse.ModelIsOverwritingMaterial = true;
            if (!_messageShown)
            {
                MessageBox.Show(new MessageBoxModel
                {
                    Text           = "Simply extract a material once FModel will be brought to the foreground. This message will be shown once per Model Viewer's lifetime, close it to begin.",
                    Caption        = "How To Overwrite Material?",
                    Icon           = MessageBoxImage.Information,
                    IsSoundEnabled = false
                });
                _messageShown = true;
            }

            MainWindow.YesWeCats.Activate();
        }
示例#18
0
        public async void Overwrite(UMaterialInstance materialInstance)
        {
            var sucess = await _applicationView.ModelViewer.TryOverwriteMaterial(materialInstance);

            if (sucess)
            {
                _applicationView.CUE4Parse.ModelIsOverwritingMaterial = false;
            }
            else
            {
                MessageBox.Show(new MessageBoxModel
                {
                    Text           = "An attempt to load a material failed.",
                    Caption        = "Error",
                    Icon           = MessageBoxImage.Error,
                    Buttons        = MessageBoxButtons.OkCancel(),
                    IsSoundEnabled = false
                });
            }
        }
示例#19
0
    private void OnInject(object sender, RoutedEventArgs args)
    {
        if (Context.InjectionMode)
        {
            if (!Utilities.IsRunningAsAdministrator()) // checks whether the app is running as administrator
            {
                MessageBox.Show("Administrative privileges is required in order to inject a DLL into a process!", "Libjector");
                return;
            }
            if (_targetProcessId is null) // checks whether the target process is selected yet
            {
                MessageBox.Show("Select a target process before continuing!", "Libjector");
                return;
            }
            if (DllList.SelectedItem is not DllItemModel dllItem) // checks whether the dll is selected yet
            {
                MessageBox.Show("Select a DLL before continuing!", "Libjector");
                return;
            }
            try
            {
                if (Context.SelectedMethodIndex == 3)
                {
                    var mappingFlags = MappingFlags.None;
                    if (Context.DiscardHeadersFlag)
                    {
                        mappingFlags |= MappingFlags.DiscardHeaders;
                    }
                    if (Context.SkipInitializationRoutinesFlag)
                    {
                        mappingFlags |= MappingFlags.SkipInitialisationRoutines;
                    }
                    _libraryMapper = new LibraryMapper(Process.GetProcessById(_targetProcessId.Value), dllItem.Path, mappingFlags);
                    _libraryMapper.MapLibrary();
                }
                else
                {
                    var injectionFlags = InjectionFlags.None;
                    if (Context.HideDllFlag) // adds hide from peb flag
                    {
                        injectionFlags |= InjectionFlags.HideDllFromPeb;
                    }
                    if (Context.RandomizeHeadersFlag) // adds randomize headers flag
                    {
                        injectionFlags |= InjectionFlags.RandomiseDllHeaders;
                    }
                    if (Context.RandomizeNameFlag) // adds randomize name flag
                    {
                        injectionFlags |= InjectionFlags.RandomiseDllName;
                    }
                    var injectionMethod = Context.SelectedMethodIndex switch
                    {
                        1 => InjectionMethod.HijackThread,
                        2 => InjectionMethod.ManualMap,
                        _ => InjectionMethod.CreateThread
                    };
                    _injectorService?.Dispose();  // disposes any existing injector service
                    _injectorService = new Injector(_targetProcessId.Value, dllItem.Path, injectionMethod, injectionFlags);
                    _injectorService.InjectDll(); // injects dll into the target process
                    if (injectionFlags.HasFlag(InjectionFlags.HideDllFromPeb))
                    {
                        _injectorService.Dispose(); // disposes the injector service; if the specific flag is used
                        goto InjectionCompleted;
                    }
                }
                _processHandler?.Dispose(); // disposes any existing process handler
                _processHandler = new BackgroundWorker {
                    WorkerSupportsCancellation = true
                };
                _processHandler.DoWork += delegate
                {
                    try
                    {
                        using var process = Process.GetProcessById(_targetProcessId.Value);
                        process.WaitForExit(); // waits for the target process to exit
                    }
                    catch
                    {
                        // do nothing
                    }
                };
                _processHandler.RunWorkerCompleted += delegate
                {
                    // disposes any existing services; as the target process has been closed
                    _injectorService?.Dispose();
                    _libraryMapper?.UnmapLibrary();
                    ToggleInjectionMode(true);
                };
                _processHandler.RunWorkerAsync(); // runs until the dll is ejected or the target process is closed
                ToggleInjectionMode(false);
InjectionCompleted:
                MessageBox.Show("The DLL has been injected into the process!", "Libjector");
            }
            catch (Exception exception)
            {
                MessageBox.Show("An error occurred while injecting! " + exception.Message, "Libjector");
            }
        }
        else
        {
            try
            {
                _injectorService?.EjectDll();
                _injectorService?.Dispose();
                _libraryMapper?.UnmapLibrary();
            }
            catch (Exception exception)
            {
                MessageBox.Show("An error occurred while ejecting! " + exception.Message, "Libjector");
            }
            if (_processHandler?.IsBusy == true)
            {
                _processHandler?.CancelAsync(); // cancels the process handler; as the dll has been ejected
            }
            _processHandler?.Dispose();
            ToggleInjectionMode(true);
            MessageBox.Show("The DLL has been ejected from the process!", "Libjector");
        }
    }
示例#20
0
        public ImagesView()
        {
            InitializeComponent();

            this.WhenActivated(disposableRegistration =>
            {
                this.OneWayBind(ViewModel,
                                vm => vm.SelectedImage,
                                view => view.SelectedImage.Source,
                                PathToImage)
                .DisposeWith(disposableRegistration);

                this.OneWayBind(ViewModel,
                                vm => vm.Images,
                                view => view.Images.ItemsSource)
                .DisposeWith(disposableRegistration);

                this.Bind(ViewModel,
                          vm => vm.SelectedIndex,
                          view => view.Images.SelectedIndex)
                .DisposeWith(disposableRegistration);

                this.Bind(ViewModel,
                          vm => vm.SearchTerm,
                          view => view.SearchTerm.Text)
                .DisposeWith(disposableRegistration);

                this.BindCommand(ViewModel,
                                 vm => vm.GoLeft,
                                 view => view.GoLeft)
                .DisposeWith(disposableRegistration);

                this.BindCommand(ViewModel,
                                 vm => vm.GoRight,
                                 view => view.GoRight)
                .DisposeWith(disposableRegistration);

                this.BindCommand(ViewModel,
                                 vm => vm.RenameImage,
                                 view => view.Rename)
                .DisposeWith(disposableRegistration);

                ViewModel.PromptForNewFileName.RegisterHandler(ic =>
                {
                    var inputBox = new InputBox(Text.RenameImagePromptText, Text.RenameImagePromptTitle);

                    if (inputBox.ShowDialog() == true)
                    {
                        ic.SetOutput(inputBox.Answer);
                    }
                    else
                    {
                        ic.SetOutput(null);
                    }
                });

                ViewModel.NotifyUserOfError.RegisterHandler(ic =>
                {
                    var messageBox = new MessageBoxModel
                    {
                        Caption = Text.Error,
                        Text    = ic.Input,
                        Buttons = new[] { MessageBoxButtons.Ok(Text.OK) },
                        Icon    = MessageBoxImage.Error
                    };

                    MessageBox.Show(messageBox);

                    ic.SetOutput(Unit.Default);
                });

                ViewModel.GoLeft
                .Merge(ViewModel.GoRight)
                .Subscribe(_ =>
                {
                    if (Images.ItemContainerGenerator.ContainerFromItem(Images.SelectedItem) is ListBoxItem item)
                    {
                        item.Focus();
                    }
                })
                .DisposeWith(disposableRegistration);
            });
        }
示例#21
0
        private void ReadMemoryConfig()
        {
            var scope     = @"root\wmi";
            var className = "AMD_ACPI";

            try
            {
                WMI.Connect($@"{scope}");

                var instanceName = WMI.GetInstanceName(scope, className);

                var classInstance = new ManagementObject(scope,
                                                         $"{className}.InstanceName='{instanceName}'",
                                                         null);

                // Get possible values (index) of a memory option in BIOS

                /*pack = WMI.InvokeMethod(classInstance, "Getdvalues", "pack", "ID", 0x20007);
                 * if (pack != null)
                 * {
                 *  uint[] DValuesBuffer = (uint[])pack.GetPropertyValue("DValuesBuffer");
                 *  for (var i = 0; i < DValuesBuffer.Length; i++)
                 *  {
                 *      Debug.WriteLine("{0}", DValuesBuffer[i]);
                 *  }
                 * }
                 */


                // Get function names with their IDs
                string[] functionObjects = { "GetObjectID", "GetObjectID2" };
                foreach (var functionObject in functionObjects)
                {
                    try
                    {
                        var pack = WMI.InvokeMethod(classInstance, functionObject, "pack", null, 0);
                        if (pack != null)
                        {
                            var ID       = (uint[])pack.GetPropertyValue("ID");
                            var IDString = (string[])pack.GetPropertyValue("IDString");
                            var Length   = (byte)pack.GetPropertyValue("Length");

                            for (var i = 0; i < Length; ++i)
                            {
                                biosFunctions.Add(new BiosACPIFunction(IDString[i], ID[i]));
                                Debug.WriteLine("{0}: {1:X8}", IDString[i], ID[i]);
                            }
                        }
                    }
                    catch
                    {
                        // ignored
                    }
                }

                // Get APCB config from BIOS. Holds memory parameters.
                BiosACPIFunction cmd = GetFunctionByIdString("Get APCB Config");
                if (cmd == null)
                {
                    throw new Exception();
                }

                var apcbConfig = WMI.RunCommand(classInstance, cmd.ID);

                cmd = GetFunctionByIdString("Get memory voltages");
                if (cmd != null)
                {
                    var voltages = WMI.RunCommand(classInstance, cmd.ID);

                    // MEM_VDDIO is ushort, offset 27
                    // MEM_VTT is ushort, offset 29
                    for (var i = 27; i <= 30; i++)
                    {
                        var value = voltages[i];
                        if (value > 0)
                        {
                            apcbConfig[i] = value;
                        }
                    }
                }

                BMC.Table = apcbConfig;

                // When ProcODT is 0, then all other resistance values are 0
                // Happens when one DIMM installed in A1 or A2 slot
                if (BMC.Table == null || cpu.utils.AllZero(BMC.Table) || BMC.Config.ProcODT < 1)
                {
                    throw new Exception();
                }

                var vdimm = Convert.ToSingle(Convert.ToDecimal(BMC.Config.MemVddio) / 1000);
                if (vdimm > 0)
                {
                    textBoxMemVddio.Text = $"{vdimm:F4}V";
                }
                else if (AsusWmi != null && AsusWmi.Status == 1)
                {
                    var sensor = AsusWmi.FindSensorByName("DRAM Voltage");
                    if (sensor != null)
                    {
                        textBoxMemVddio.Text = sensor.Value;
                    }
                    else
                    {
                        labelMemVddio.IsEnabled = false;
                    }
                }
                else
                {
                    labelMemVddio.IsEnabled = false;
                }

                var vtt = Convert.ToSingle(Convert.ToDecimal(BMC.Config.MemVtt) / 1000);
                if (vtt > 0)
                {
                    textBoxMemVtt.Text = $"{vtt:F4}V";
                }
                else
                {
                    labelMemVtt.IsEnabled = false;
                }

                textBoxProcODT.Text = BMC.GetProcODTString(BMC.Config.ProcODT);

                textBoxClkDrvStren.Text      = BMC.GetDrvStrenString(BMC.Config.ClkDrvStren);
                textBoxAddrCmdDrvStren.Text  = BMC.GetDrvStrenString(BMC.Config.AddrCmdDrvStren);
                textBoxCsOdtCmdDrvStren.Text = BMC.GetDrvStrenString(BMC.Config.CsOdtCmdDrvStren);
                textBoxCkeDrvStren.Text      = BMC.GetDrvStrenString(BMC.Config.CkeDrvStren);

                textBoxRttNom.Text  = BMC.GetRttString(BMC.Config.RttNom);
                textBoxRttWr.Text   = BMC.GetRttWrString(BMC.Config.RttWr);
                textBoxRttPark.Text = BMC.GetRttString(BMC.Config.RttPark);

                textBoxAddrCmdSetup.Text = $"{BMC.Config.AddrCmdSetup}";
                textBoxCsOdtSetup.Text   = $"{BMC.Config.CsOdtSetup}";
                textBoxCkeSetup.Text     = $"{BMC.Config.CkeSetup}";
            }
            catch (Exception ex)
            {
                compatMode = true;

                MessageBox.Show(
                    "Failed to read AMD ACPI. Odt, Setup and Drive strength parameters will be empty.",
                    "Warning",
                    MessageBoxButton.OK,
                    MessageBoxImage.Warning);
                Console.WriteLine(ex.Message);
            }

            BMC.Dispose();
        }
示例#22
0
        private void ReadMemoryModulesInfo()
        {
            using (var searcher = new ManagementObjectSearcher("select * from Win32_PhysicalMemory"))
            {
                bool connected = false;
                try
                {
                    WMI.Connect(@"root\cimv2");

                    connected = true;

                    foreach (var queryObject in searcher.Get().Cast <ManagementObject>())
                    {
                        var capacity      = 0UL;
                        var clockSpeed    = 0U;
                        var partNumber    = "N/A";
                        var bankLabel     = "";
                        var manufacturer  = "";
                        var deviceLocator = "";

                        var temp = WMI.TryGetProperty(queryObject, "Capacity");
                        if (temp != null)
                        {
                            capacity = (ulong)temp;
                        }

                        temp = WMI.TryGetProperty(queryObject, "ConfiguredClockSpeed");
                        if (temp != null)
                        {
                            clockSpeed = (uint)temp;
                        }

                        temp = WMI.TryGetProperty(queryObject, "partNumber");
                        if (temp != null)
                        {
                            partNumber = (string)temp;
                        }

                        temp = WMI.TryGetProperty(queryObject, "BankLabel");
                        if (temp != null)
                        {
                            bankLabel = (string)temp;
                        }

                        temp = WMI.TryGetProperty(queryObject, "Manufacturer");
                        if (temp != null)
                        {
                            manufacturer = (string)temp;
                        }

                        temp = WMI.TryGetProperty(queryObject, "DeviceLocator");
                        if (temp != null)
                        {
                            deviceLocator = (string)temp;
                        }

                        modules.Add(new MemoryModule(partNumber.Trim(), bankLabel.Trim(), manufacturer.Trim(),
                                                     deviceLocator, capacity, clockSpeed));

                        //string bl = bankLabel.Length > 0 ? new string(bankLabel.Where(char.IsDigit).ToArray()) : "";
                        //string dl = deviceLocator.Length > 0 ? new string(deviceLocator.Where(char.IsDigit).ToArray()) : "";

                        //comboBoxPartNumber.Items.Add($"#{bl}: {partNumber}");
                        //comboBoxPartNumber.SelectedIndex = 0;
                    }
                }
                catch (Exception ex)
                {
                    var title = connected ? @"Failed to get installed memory parameters." : $@"{ex.Message}";
                    MessageBox.Show(
                        title,
                        "Warning",
                        MessageBoxButton.OK,
                        MessageBoxImage.Warning);
                }
            }

            if (modules.Count > 0)
            {
                ReadChannelsInfo();

                var totalCapacity = 0UL;

                foreach (var module in modules)
                {
                    var rank = module.DualRank ? "DR" : "SR";
                    totalCapacity += module.Capacity;
                    comboBoxPartNumber.Items.Add(
                        $"{module.Slot}: {module.PartNumber} ({module.Capacity / 1024 / (1024 * 1024)}GB, {rank})");
                }

                if (modules[0].ClockSpeed != 0)
                {
                    MEMCFG.Frequency = modules[0].ClockSpeed;
                }

                if (totalCapacity != 0)
                {
                    MEMCFG.TotalCapacity = $"{totalCapacity / 1024 / (1024 * 1024)}GB";
                }

                comboBoxPartNumber.SelectedIndex     = 0;
                comboBoxPartNumber.SelectionChanged += ComboBoxPartNumber_SelectionChanged;
            }
        }
示例#23
0
        private void AutoUpdaterOnCheckForUpdateEvent(UpdateInfoEventArgs args)
        {
            if (args.Error == null)
            {
                if (args.IsUpdateAvailable)
                {
                    var messageBox = new MessageBoxModel
                    {
                        Text = $"There is new version {args.CurrentVersion} available.{Environment.NewLine}" +
                               $"You are using version {args.InstalledVersion}.{Environment.NewLine}" +
                               $"{ChangelogText}{Environment.NewLine}" +
                               "Do you want to update the application now?",
                        Caption = @"Update Available",
                        Buttons = MessageBoxButtons.YesNo()
                    };

                    MessageBox.Show(messageBox);

                    if (!manual)
                    {
                        SplashWindow.splash.Hide();
                    }

                    if (messageBox.Result.Equals(MessageBoxResult.Yes))
                    {
                        try
                        {
                            if (AutoUpdater.DownloadUpdate(args))
                            {
                                if (!manual)
                                {
                                    SplashWindow.Stop();
                                }
                                Application.Current.Shutdown();
                                Environment.Exit(0);
                            }
                        }
                        catch (Exception exception)
                        {
                            MessageBox.Show(
                                exception.Message,
                                exception.GetType().ToString(),
                                MessageBoxButton.OK,
                                MessageBoxImage.Error);
                        }
                    }

                    if (!manual)
                    {
                        SplashWindow.splash.Show();
                    }
                }
                else if (manual)
                {
                    OnUpdateCheckCompleteEvent(new EventArgs());
                }
            }
            else
            {
                if (args.Error is WebException)
                {
                    MessageBox.Show(
                        @"There is a problem reaching update server. Please check your internet connection and try again later.",
                        @"Update Check Failed",
                        MessageBoxButton.OK,
                        MessageBoxImage.Error);
                }
                else
                {
                    MessageBox.Show(
                        args.Error.Message,
                        args.Error.GetType().ToString(),
                        MessageBoxButton.OK,
                        MessageBoxImage.Error);
                }
            }
            AutoUpdater.ParseUpdateInfoEvent -= AutoUpdaterOnParseUpdateInfoEvent;
            AutoUpdater.CheckForUpdateEvent  -= AutoUpdaterOnCheckForUpdateEvent;
        }