コード例 #1
0
        private void ExecuteConvertToUserOverriddenInstallationCommand(object parameter)
        {
            if (null != SelectedItem)
            {
                if (SelectedItem.Path != null)
                {
                    Installation new_installation = new Installation(SelectedItem.Path);

                    bool disable_updates = ((string)parameter ?? "").ToLowerInvariant() == "disableupdatescheck";
                    if (disable_updates)
                    {
                        new_installation.CheckForUpdatesFlag = false;
                    }

                    ConfiguredInstallations.Add(new_installation);
                }
            }
        }
コード例 #2
0
        private void ExecuteAddInstallationCommand(object parameter)
        {
            var installationToAdd = newItem;

            NewItem = new Installation();

            installationToAdd.CheckForUpdatesFlag = true;

            var same = from i in InstallationsList
                       where
                       i.WatchedRelease == installationToAdd.WatchedRelease &&
                       i.ImageType == installationToAdd.ImageType &&
                       i.JVM_Implementation == installationToAdd.JVM_Implementation &&
                       i.HeapSize == installationToAdd.HeapSize &&
                       i.Arch == installationToAdd.Arch      /*&&
                                                              * ((i.IsAutodiscoveredInstance && i.CheckForUpdatesFlag) || !i.IsAutodiscoveredInstance)*/

                       select i;

            if (same.Count() > 0)
            {
                var same_paths = from i in same
                                 /*where (i.IsAutodiscoveredInstance && i.CheckForUpdatesFlag) || !i.IsAutodiscoveredInstance*/
                                 select $"[{i.InstallationTypeText}{(i.CheckForUpdatesFlag?"":", Disabled")}] (set to {i.WatchedRelease}):{Environment.NewLine}{i.DisplayPath}";
                if (MessageBox.Show(
                        $"You already have {same_paths.Count()} installation{(same_paths.Count() > 1 ? "s" : "")} with the same parameters in the list:" + Environment.NewLine + Environment.NewLine +
                        $"{String.Join(Environment.NewLine, same_paths)}" + Environment.NewLine + Environment.NewLine +
                        $"Do you really want to add one more? [not recommended]", Branding.MessageBoxHeader, MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No
                        ) == MessageBoxResult.No)
                {
                    NewItem = installationToAdd;
                    return;
                }
            }

            InstallationsList.Add(installationToAdd);

            if (DownloadImmediately)
            {
                App.ShowNewVersionWindow(true);
            }

            App.AddInstallationFromWebWindowInstance.Close();
        }
コード例 #3
0
ファイル: Machine.cs プロジェクト: tushev/aojdk-updatewatcher
        private void DiscoverAndAddInstallationsFromRegistry(bool user_scope)
        {
            RemoveRegistryAutoDiscoveredInstallations(user_scope);

            var _installs = user_scope ? AdoptiumInstallationsDiscoverer.DiscoverInstallationsByRegistryHKCU() :
                            AdoptiumInstallationsDiscoverer.DiscoverInstallationsByRegistryHKLM();

            HoldAutoReCheckForUpdateSuggested = true;
            for (int k = 0; k < _installs.Count; k++)
            {
                DiscoveredInstallation i = _installs[k];

                // we want to reset HoldAutoReCheckForUpdateSuggested at the last element
                if (k == _installs.Count - 1)
                {
                    HoldAutoReCheckForUpdateSuggested = false;
                }

                Installation inst = new Installation(i, true, user_scope);
                Installations.Add(inst);
            }
        }
コード例 #4
0
ファイル: Machine.cs プロジェクト: tushev/aojdk-updatewatcher
 public void RemoveSkippedReleaseForInstallation(Installation i)
 {
     i?.RemoveSkippedRelease();
     SomethingHasBeenChangedSinceUpdateCheck = true;
 }
コード例 #5
0
ファイル: Machine.cs プロジェクト: tushev/aojdk-updatewatcher
 public void SkipDiscoveredNewVersionForInstallation(Installation i)
 {
     i?.SkipDiscoveredNewVersion();
     //SomethingHasBeenChangedSinceUpdateCheck = true;
 }
コード例 #6
0
        static public Machine TryLoad(string filename)
        {
            if (File.Exists(filename))
            {
                try
                {
                    using (var sr = new StreamReader(filename))
                    {
                        XmlSerializer xs     = new XmlSerializer(typeof(Machine));
                        Machine       loaded = (Machine)xs.Deserialize(sr);

                        Machine machine = new Machine();

                        foreach (Installation i in loaded.Installations)
                        {
                            // we should re-discover them again, they should not be persistent
                            if (i.IsAutodiscoveredInstance)
                            {
                                continue;
                            }

                            if (String.IsNullOrEmpty(i.Path))
                            {
                                continue;
                            }

                            Installation new_installation;

                            if (i.java_home_instance)
                            {
                                new_installation = new Installation(true);
                            }
                            else
                            {
                                new_installation = new Installation(i.Path);
                            }

                            // we need to set these up after initialization to override constructor/propertychanged logic
                            // except for autodiscovered instances
                            if (!i.IsAutodiscoveredInstance) // normally this should always be triggered
                            {
                                new_installation.WatchedRelease     = i.WatchedRelease;
                                new_installation.JVM_Implementation = i.JVM_Implementation;
                                new_installation.ImageType          = i.ImageType;
                                new_installation.Arch                = i.Arch;
                                new_installation.HeapSize            = i.HeapSize;
                                new_installation.SkippedReleaseName  = i.SkippedReleaseName;
                                new_installation.CheckForUpdatesFlag = i.CheckForUpdatesFlag;
                            }

                            machine.Installations.Add(new_installation);
                        }

                        machine.ActivateAutoDiscoveryOnPropertyChange();

                        machine.DiscoverMachineWideInstallations = loaded.DiscoverMachineWideInstallations;
                        machine.DiscoverUserScopeInstallations   = loaded.DiscoverUserScopeInstallations;
                        machine.ShowShadowedInstallations        = loaded.ShowShadowedInstallations;

                        foreach (Installation ai in loaded.Installations.Where(x => x.IsAutodiscoveredInstance && x.HasSkippedRelease))
                        {
                            (machine.Installations.Where(m => m.IsAutodiscoveredInstance && m.Path == ai.Path).First()).SkippedReleaseName = ai.SkippedReleaseName;
                        }

                        machine.SomethingHasBeenChangedSinceUpdateCheck = false;

                        return(machine);
                    }

                    //using (Stream stream = File.Open(filename, FileMode.Open))
                    //{
                    //    var binaryFormatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                    //    return (Machine)binaryFormatter.Deserialize(stream);
                    //}
                }
                catch (Exception ex) { MessageBox.Show($"There was an error: [ {ex.Message} ].", "Error while loading the configuration", MessageBoxButton.OK, MessageBoxImage.Error); }
            }
            // quasi - else:
            Debug.WriteLine($"Machine settings [{filename}] not found, loading default machine with auto-discovery enabled.");

            // create new Machine with default settings
            Machine default_machine = new Machine();

            default_machine.ActivateAutoDiscoveryOnPropertyChange(); // not needed now, required for further changes
            default_machine.RefreshAutoDiscoveredInstallations();    // actually try to find the installations

            return(default_machine);
        }