コード例 #1
0
        public IObservable <Settings> SaveInternal(Settings settings)
        {
            var result = new Subject <Settings>();

            Task.Run(async() => {
                Settings.Copy(settings, Settings);
                await Settings.WriteInternalToStorage(_storage);
                result.OnNext(settings);
                result.OnCompleted();
            });
            return(result);
        }
コード例 #2
0
        public IObservable <Settings> Save(Settings settings)
        {
            if (!settings.IsValidated)
            {
                throw new InvalidOperationException("Settings must be validated before saved.");
            }
            var result = new Subject <Settings>();

            Task.Run(async() => {
                Settings.Copy(settings, Settings);
                await Settings.WriteToStorage(_storage);

                // handle startup settings todo test!
                if (Settings.StartWithWindows)
                {
                    var linkPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Microsoft", "Windows", "Start Menu", "Programs", "VPDB", "VPDB Agent.lnk");
                    string cmd;
                    if (File.Exists(linkPath))
                    {
                        var lnk = new ShellShortcut(linkPath);
                        cmd     = $"cmd /c \"cd /d {lnk.WorkingDirectory} && {lnk.Path} {lnk.Arguments} --process-start-args \\\"--minimized\\\"\"";
                    }
                    else
                    {
                        cmd = File.Exists(linkPath) ? linkPath : Assembly.GetEntryAssembly().Location;
                    }
                    _registryKey.SetValue("VPDB Agent", cmd);
                }
                else
                {
                    if (_registryKey.GetValue("VPDB Agent") != null)
                    {
                        _registryKey.DeleteValue("VPDB Agent");
                    }
                }

                result.OnNext(Settings);
                result.OnCompleted();
            });

            CanCancel = true;
            return(result);
        }