示例#1
0
        private static void StartupTaskPreSettings()
        {
            if (logger.IsDebugEnabled)
            {
                logger.Debug($"[{nameof(StartupTaskPreSettings)}]");
            }

            // Convert the settings file
            if (File.Exists(Settings.SettingsFilePath))
            {
                JObject jSettings;

                try
                {
                    using (var sr = new StreamReader(Settings.SettingsFilePath))
                    {
                        using (var jsonReader = new JsonTextReader(sr))
                        {
                            jSettings = JObject.Load(jsonReader);
                        }
                    }
                }
                catch (JsonReaderException jrEx)
                {
                    ResetSettingsFile(jrEx);
                    jSettings = null;
                }

                if (jSettings != null)
                {
                    JToken jPreviousV = jSettings["PreviousVersion"];
                    var    previousV  = new Version(jPreviousV?.Value <string>() ?? "0");

                    // [IDO] Hotkeys
                    if (previousV < new Version("1.10.10"))
                    {
                        // pre-1.10.10 hotkeys must be converted to the current format
                        logger.Info("Converting old hotkeys to the current format...");

                        JToken jHotkeys = jSettings["HotKeys"];
                        if (jHotkeys?.HasValues == true)
                        {
                            var convertedHotkeys = new JArray();

                            foreach (JToken jHotkey in jHotkeys.Children())
                            {
                                JToken jKeyOrButton = jHotkey["KeyOrButton"];
                                JToken jKey         = jKeyOrButton?["Key"];

                                ModifierKeys modifiers = (jHotkey["Alt"]?.Value <bool>() == true ? ModifierKeys.Alt : ModifierKeys.None) |
                                                         (jHotkey["Ctrl"]?.Value <bool>() == true ? ModifierKeys.Control : ModifierKeys.None) |
                                                         (jHotkey["Shift"]?.Value <bool>() == true ? ModifierKeys.Shift : ModifierKeys.None) |
                                                         (jHotkey["WindowsKey"]?.Value <bool>() == true ? ModifierKeys.Windows : ModifierKeys.None);

                                ToastifyActionEnum toastifyActionEnum = Enum.TryParse(jHotkey["Action"]?.Value <string>(), out ToastifyActionEnum tae) ? tae : ToastifyActionEnum.None;
                                ToastifyAction     action             = App.Container.Resolve <IToastifyActionRegistry>().GetAction(toastifyActionEnum);
                                bool enabled = jHotkey["Enabled"]?.Value <bool>() ?? false;

                                Hotkey h = jKeyOrButton?["IsKey"]?.Value <bool>() ?? jKey != null
                                    ? new KeyboardHotkey
                                {
                                    Modifiers = modifiers,
                                    Key       = Enum.TryParse(jKey?.Value <string>(), out Key k) ? k : (Key?)null,
                                    Action    = action,
                                    Enabled   = enabled
                                } as Hotkey
示例#2
0
        public void Default()
        {
            AlwaysStartSpotify       = null;
            CloseSpotifyWithToastify = true;

            FadeOutTime   = 2000;
            GlobalHotKeys = true;
            DisableToast  = false;

            ToastColorTop    = "#FF999999";
            ToastColorBottom = "#FF353535";
            ToastBorderColor = "#FF292929";

            ToastBorderThickness = 1.0;

            ToastWidth  = 300;
            ToastHeight = 75;

            ToastBorderCornerRadiusTopLeft     = 4.0;
            ToastBorderCornerRadiusTopRight    = 4.0;
            ToastBorderCornerRadiusBottomRight = 4.0;
            ToastBorderCornerRadiusBottomLeft  = 4.0;

            OffsetRight  = 5.0;
            OffsetBottom = 5.0;

            ClipboardTemplate = "I'm currently listening to {0}";

            Hotkey.ClearAll();

            HotKeys = new List <Hotkey>
            {
                new Hotkey {
                    Ctrl = true, Alt = true, Key = System.Windows.Input.Key.Up, Action = SpotifyAction.PlayPause
                },
                new Hotkey {
                    Ctrl = true, Alt = true, Key = System.Windows.Input.Key.Down, Action = SpotifyAction.Stop
                },
                new Hotkey {
                    Ctrl = true, Alt = true, Key = System.Windows.Input.Key.Left, Action = SpotifyAction.PreviousTrack
                },
                new Hotkey {
                    Ctrl = true, Alt = true, Key = System.Windows.Input.Key.Right, Action = SpotifyAction.NextTrack
                },
                new Hotkey {
                    Ctrl = true, Alt = true, Key = System.Windows.Input.Key.M, Action = SpotifyAction.Mute
                },
                new Hotkey {
                    Ctrl = true, Alt = true, Key = System.Windows.Input.Key.PageDown, Action = SpotifyAction.VolumeDown
                },
                new Hotkey {
                    Ctrl = true, Alt = true, Key = System.Windows.Input.Key.PageUp, Action = SpotifyAction.VolumeUp
                },
                new Hotkey {
                    Ctrl = true, Alt = true, Key = System.Windows.Input.Key.Space, Action = SpotifyAction.ShowToast
                },
                new Hotkey {
                    Ctrl = true, Alt = true, Key = System.Windows.Input.Key.S, Action = SpotifyAction.ShowSpotify
                },
                new Hotkey {
                    Ctrl = true, Alt = true, Key = System.Windows.Input.Key.C, Action = SpotifyAction.CopyTrackInfo
                }
            };

            Plugins = new List <PluginDetails>();
        }
示例#3
0
 internal static void ActionHookCallback(Hotkey hotkey)
 {
 }