Ejemplo n.º 1
0
        /// <summary>
        /// Migrate configuration to a new schema
        /// </summary>
        public void Migrate()
        {
            if (SelectedPlaybackDeviceListId.Count > 0)
            {
                SelectedDevices.UnionWith(
                    SelectedPlaybackDeviceListId.Select((s => new DeviceInfo("", s, DataFlow.Render))));
                SelectedPlaybackDeviceListId.Clear();
            }

            if (SelectedRecordingDeviceListId.Count > 0)
            {
                SelectedDevices.UnionWith(
                    SelectedRecordingDeviceListId.Select((s => new DeviceInfo("", s, DataFlow.Capture))));
                SelectedRecordingDeviceListId.Clear();
            }

            if (NotificationSettings == NotificationTypeEnum.ToastNotification)
            {
                NotificationSettings = NotificationTypeEnum.BannerNotification;
            }

            if (!MigratedFields.Contains("KeepSystrayIcon"))
            {
                SwitchIcon = KeepSystrayIcon ? IconChangerFactory.ActionEnum.Never : IconChangerFactory.ActionEnum.Always;
                MigratedFields.Add("KeepSystrayIcon");
            }
        }
        /// <summary>
        /// Migrate configuration to a new schema
        /// </summary>
        public void Migrate()
        {
            if (SelectedPlaybackDeviceListId.Count > 0)
            {
                SelectedDevices.UnionWith(
                    SelectedPlaybackDeviceListId.Select((s => new DeviceInfo("", s, DataFlow.Render))));
                SelectedPlaybackDeviceListId.Clear();
            }

            if (SelectedRecordingDeviceListId.Count > 0)
            {
                SelectedDevices.UnionWith(
                    SelectedRecordingDeviceListId.Select((s => new DeviceInfo("", s, DataFlow.Capture))));
                SelectedRecordingDeviceListId.Clear();
            }
        }
        /// <summary>
        /// Migrate configuration to a new schema
        /// </summary>
        public void Migrate()
        {
            if (SelectedPlaybackDeviceListId.Count > 0)
            {
                SelectedDevices.UnionWith(
                    SelectedPlaybackDeviceListId.Select((s => new DeviceInfo("", s, DataFlow.Render))));
                SelectedPlaybackDeviceListId.Clear();
            }

            if (SelectedRecordingDeviceListId.Count > 0)
            {
                SelectedDevices.UnionWith(
                    SelectedRecordingDeviceListId.Select((s => new DeviceInfo("", s, DataFlow.Capture))));
                SelectedRecordingDeviceListId.Clear();
            }

            if (NotificationSettings == NotificationTypeEnum.ToastNotification)
            {
                NotificationSettings = NotificationTypeEnum.BannerNotification;
            }
        }
        /// <summary>
        /// Migrate configuration to a new schema
        /// </summary>
        public bool Migrate()
        {
            var migrated = false;

            if (SelectedPlaybackDeviceListId.Count > 0)
            {
                SelectedDevices.UnionWith(
                    SelectedPlaybackDeviceListId.Select((s => new DeviceInfo("", s, DataFlow.Render))));
                SelectedPlaybackDeviceListId.Clear();
                migrated = true;
            }

            if (SelectedRecordingDeviceListId.Count > 0)
            {
                SelectedDevices.UnionWith(
                    SelectedRecordingDeviceListId.Select((s => new DeviceInfo("", s, DataFlow.Capture))));
                SelectedRecordingDeviceListId.Clear();
                migrated = true;
            }

            if (NotificationSettings == NotificationTypeEnum.ToastNotification)
            {
                NotificationSettings = NotificationTypeEnum.BannerNotification;
            }

#pragma warning disable 612
            if (!MigratedFields.Contains(nameof(KeepSystrayIcon)))
            {
                SwitchIcon = KeepSystrayIcon ? IconChangerFactory.ActionEnum.Never : IconChangerFactory.ActionEnum.Always;
                MigratedFields.Add(nameof(KeepSystrayIcon));
                migrated = true;
            }

            if (!MigratedFields.Contains(nameof(ProfileSettings) + "_final"))
            {
                Profiles = ProfileSettings
                           .Select(setting =>
                {
                    var profile = new Profile.Profile
                    {
                        AlsoSwitchDefaultDevice = setting.AlsoSwitchDefaultDevice,
                        Communication           = null,
                        Playback  = setting.Playback,
                        Name      = setting.ProfileName,
                        Recording = setting.Recording
                    };
                    if (setting.HotKey != null)
                    {
                        profile.Triggers.Add(new Trigger(TriggerFactory.Enum.HotKey)
                        {
                            HotKey = setting.HotKey
                        });
                    }

                    if (!string.IsNullOrEmpty(setting.ApplicationPath))
                    {
                        profile.Triggers.Add(new Trigger(TriggerFactory.Enum.Process)
                        {
                            ApplicationPath = setting.ApplicationPath
                        });
                    }

                    return(profile);
                }).ToHashSet();
                MigratedFields.Add(nameof(ProfileSettings) + "_final");
                migrated = true;
            }

            if (!MigratedFields.Contains(nameof(LastDonationNagTime)))
            {
                LastDonationNagTime = DateTime.UtcNow - TimeSpan.FromDays(10);
                MigratedFields.Add(nameof(LastDonationNagTime));
                migrated = true;
            }

            return(migrated);

#pragma warning restore 612
        }