public DeviceSelection(IStreamablePlayerHost player, double?location_X = null, double?location_Y = null)
 {
     InitializeComponent();
     this.location_X            = location_X;
     this.location_Y            = location_Y;
     this.player                = player;
     this.SourceInitialized    += DeviceSelectionForm_SourceInitialized;
     this.lbl_close.MouseDown  += (s, e) => this.Close();
     this.player.DeviceChanged += delegate
     {
         Refresh();
     };
     Refresh();
 }
Example #2
0
        public MainWindow()
        {
            try
            {
                InitializeComponent();
                this.Background = System.Windows.Media.Brushes.Gray;

                InitWidth  = this.Width;
                InitHeight = this.Height;
                ResizeMode = ResizeMode.CanMinimize;
                Visibility = Visibility.Hidden;

                player  = ActivatorHelpers.LoadPlayerHost <Listener.Player.Spotify.SpotifyPlayerHost>();
                plugins = ActivatorHelpers.LoadPlugins().ToArray();
                ActivatorHelpers.LoadRazerChromaPlugins(this);

                var maxEffectCount = ActivatorHelpers.Effects.Count - 1;
                if (Properties.Settings.Default.RenderStyle > maxEffectCount)
                {
                    Properties.Settings.Default.RenderStyle = maxEffectCount;
                    Properties.Settings.Default.Save();
                }

                VolumePath.Fill           = playColor;
                VolumeProgress.Foreground = lbl_Album.Foreground;

                player.TrackChanged         += OnTrackChanged;
                player.DeviceChanged        += Player_OnDeviceChanged;
                player.TrackDurationChanged += (p) =>
                {
                    this.VolumePath.Fill = p.IsMute ? pauseColor : playColor;
                };

                player.TrackPlayStateChanged += (state) =>
                {
                    Dispatcher.InvokeAsync(() =>
                    {
                        StreamGeometry buttonShape;
                        SolidColorBrush color;
                        if (state == PlayState.Play)
                        {
                            buttonShape = (StreamGeometry)this.FindResource("pausePath");
                            color       = playColor;
                        }
                        else
                        {
                            buttonShape = (StreamGeometry)this.FindResource("playPath");
                            color       = pauseColor;
                        }
                        this.PlayPath.Data           = buttonShape;
                        this.PlayProgress.Foreground = color;
                    });
                };

                KeyDown                   += MainWindowGrid_PreviewKeyDown;
                Loaded                    += MainWindow_Loaded;
                MouseDown                 += Window_MouseDown;
                btn_Minimize.Click        += (s, e) => this.WindowState = WindowState.Minimized;
                btn_Close.Click           += (s, e) => this.Close();
                this.AlbumImage.MouseDown += AlbumImage_MouseDown;

                if (Properties.Settings.Default.ChromaSDKEnable)
                {
                    var chroma = ChromaWorker.Instance;
                    this.chroma          = chroma;
                    chromaTimer.Interval =
                        (int)Math.Round((1000.0 / Properties.Settings.Default.RenderFPS), 0);
                    chromaTimer.Tick += ChromaTimer_Tick;
                    chromaTimer.Start();
                }
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.ToString());
                Environment.Exit(1);
            }

            this.Visibility  = Visibility.Visible;
            this.DataContext = player;
        }
Example #3
0
        public SearchPanel(IStreamablePlayerHost player, Action callback = null)
        {
            Player = player;
            InitializeComponent();
            this.cb_searchBox.Focus();
            Callback = callback;
            playPath = (Geometry)this.Resources["playPath"];
            this.cb_searchBox.TextChanged += async(s, e) =>
            {
                var        q          = cb_searchBox.Text;
                string     query      = default;
                SearchType searchType = SearchType.All;
                if (q.Contains(":"))
                {
                    var data  = q.Split(':');
                    var qtype = data[0].ToLower();
                    if (qtype == "t" || qtype == "track")
                    {
                        searchType = SearchType.Track;
                    }
                    else if (qtype == "ab" || qtype == "album")
                    {
                        searchType = SearchType.Album;
                    }
                    else if (qtype == "a" || qtype == "artist")
                    {
                        searchType = SearchType.Artist;
                    }
                    else if (qtype == "p" || qtype == "playlist")
                    {
                        searchType = SearchType.Playlist;
                    }
                    query = data[1];
                }
                else
                {
                    query = q;
                }
                if (string.IsNullOrWhiteSpace(q) || string.IsNullOrWhiteSpace(query))
                {
                    this.Height = 300;
                    grid_searchResult.Children.Clear();
                    return;
                }
                var result = (await Player.SearchAsync(query, searchType, 10)).ToArray();
                if (result == null)
                {
                    return;
                }
                do
                {
                    grid_searchResult.Children.Clear();
                } while (grid_searchResult.Children.Count > 0);
                for (var i = 0; i < result.Count(); i++)
                {
                    var element = result[i];
                    var button  = new PathButton();
                    button.Data   = playPath;
                    button.Margin = new Thickness(10, (i + 1) * 50 - 2, 0, 0);
                    button.Width  = 20;
                    button.Height = 20;
                    button.HorizontalAlignment = HorizontalAlignment.Left;
                    button.VerticalAlignment   = VerticalAlignment.Top;
                    button.Background          = Brushes.Transparent;
                    button.BorderBrush         = Brushes.Transparent;
                    button.BorderThickness     = new Thickness(0, 0, 0, 0);
                    button.Fill          = Brushes.Gray;
                    button.ActiveColor   = Brushes.Green;
                    button.InactiveColor = Brushes.Gray;
                    button.Style         = (Style)this.Resources["PathButtonStyle"];
                    button.Click        += async delegate
                    {
                        switch (searchType)
                        {
                        case SearchType.Artist:
                            Process.Start(element.Uri.AbsoluteUri);
                            break;

                        case SearchType.Track:
                        case SearchType.All:
                            await Player.PlayTrackAsync(element.Uri.AbsoluteUri);

                            break;

                        default:
                            await Player.PlayAsync(element.Uri.AbsoluteUri);

                            break;
                        }
                    };
                    grid_searchResult.Children.Add(button);
                    var text = new TextBlock();
                    text.Text   = element.Track;
                    text.Margin = new Thickness(50, (i + 1) * 50, 0, 0);
                    text.Width  = 1920;
                    text.HorizontalAlignment = HorizontalAlignment.Left;
                    grid_searchResult.Children.Add(text);
                }
                if (grid_searchResult.Children.Count == 0)
                {
                    this.Height = 300;
                }
                else
                {
                    this.Height = grid_searchResult.Children.Count * (20) + 50;
                }
                //cb_searchBox.SetInternalValue(result);
            };
            this.Closing += delegate
            {
                Callback?.Invoke();
            };
        }