Changeset 172

Show
Ignore:
Timestamp:
03/09/07 04:53:32 (2 years ago)
Author:
bsmith7
Message:

Playing and pausing supported

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • dmp/trunk/BadClient/Form1.cs

    r164 r172  
    110110        { 
    111111            int songId = int.Parse(dgvSongs.CurrentRow.Cells[0].Value.ToString()); 
    112             //String songURL = this.myBridge.getSongURL(songId); 
    113             //vlcPlayer.AddAndPlay(songURL,""); 
     112            String songURL = this.myBridge.getSongURL(songId); 
    114113 
    115114             
    116             vlcPlayer.PlaySong(songId); 
     115            //vlcPlayer.PlaySong(songId); 
    117116            this.button3.Text = "Pause"; 
    118117        } 
  • dmp/trunk/client/wpfclient/ControlTemplates.xaml

    r148 r172  
    1010                        <Trigger Property="IsPressed" Value="true"> 
    1111                                <Setter TargetName="Icon" Property="Image.Source" Value="pack://application:,,/resources/Play_pressed.png"/> 
     12                        </Trigger> 
     13                </ControlTemplate.Triggers> 
     14        </ControlTemplate> 
     15         
     16                <ControlTemplate x:Key="PauseIcon" TargetType="{x:Type Button}"> 
     17                <Image Name="Icon" Source="pack://application:,,/resources/Pause_nohover.png" Width="50" Height="50"/> 
     18                <ControlTemplate.Triggers> 
     19                        <Trigger Property="UIElement.IsMouseOver" Value="true"> 
     20                                <Setter TargetName="Icon" Property="Image.Source" Value="pack://application:,,/resources/Pause_hover.png"/> 
     21                        </Trigger> 
     22                        <Trigger Property="IsPressed" Value="true"> 
     23                                <Setter TargetName="Icon" Property="Image.Source" Value="pack://application:,,/resources/Pause_pressed.png"/> 
    1224                        </Trigger> 
    1325                </ControlTemplate.Triggers> 
  • dmp/trunk/client/wpfclient/SongViewer.cs

    r162 r172  
    5353 
    5454                        HighlightedRow.SongId = -1; 
    55                         HighlightedRow.LibId = -1; 
    5655                        HighlightedRow.LastIndex = -1; 
    5756 
     
    5958        } 
    6059 
    61                 struct RowRecord{ 
     60                public struct RowRecord{ 
    6261                        public int SongId; 
    63                         public int LibId; 
    6462                        public int LastIndex; 
    6563                } 
     
    203201                Brush currentBrush; 
    204202 
    205                                 bool rowHighlighted = ((int)currentView[i]["id"] == HighlightedRow.SongId); 
     203                                bool rowHighlighted = ((int)((long)currentView[i]["id"]) == HighlightedRow.SongId); 
    206204                if (rowHighlighted) { 
    207205                    currentBrush = HighlightedRowColor; 
     
    219217                while (currentCol != null) 
    220218                { 
    221                     DrawCell((string)currentView[i][currentCol.Value], dc, currentPt, colWidth); 
     219                                        object cellValue = currentView[i][currentCol.Value]; 
     220                                        if(cellValue.GetType() == typeof(string)) 
     221                                                DrawCell((string)currentView[i][currentCol.Value], dc, currentPt, colWidth); 
    222222 
    223223                    currentPt.X += colWidth; 
     
    300300        } 
    301301 
    302         RowRecord HighlightedRow; 
     302        public RowRecord HighlightedRow; 
    303303                 
    304304        Brush fontColor = Brushes.Black; 
     
    323323 
    324324                                                HighlightedRow.LastIndex = rowClicked -1; 
    325                                                 HighlightedRow.SongId = (int)currentView[HighlightedRow.LastIndex]["id"]
     325                                                HighlightedRow.SongId = (int)((long)currentView[HighlightedRow.LastIndex]["id"])
    326326 
    327327                        InvalidateVisual(); 
     
    449449                void MoveHighlight(int amount){ 
    450450                        //First make sure the currently highlighted song is even displayed 
    451                         if((int)currentView[HighlightedRow.LastIndex]["id"] != HighlightedRow.SongId) 
     451                        if((int)((long)currentView[HighlightedRow.LastIndex]["id"]) != HighlightedRow.SongId) 
    452452                                return; 
    453453 
     
    458458 
    459459                        HighlightedRow.LastIndex = newIndex; 
    460                         HighlightedRow.SongId = (int)currentView[newIndex]["id"]
     460                        HighlightedRow.SongId = (int)((long)currentView[newIndex]["id"])
    461461                         
    462462                        if(newIndex < FirstIndex){ 
  • dmp/trunk/client/wpfclient/main_window.xaml

    r166 r172  
    44    xmlns:def="Definition" 
    55 
     6                xmlns:wfi="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration" 
     7    xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms" 
     8                xmlns:vlc="clr-namespace:VLanControl;assembly=VLanControl"  
    69    Title="Rubicon" 
    710    > 
     
    5558        </Button.BitmapEffect> 
    5659      </Button> 
    57       <Button Template="{StaticResource PlayIcon}" Margin="5"
     60      <Button Template="{StaticResource PlayIcon}" Margin="5" Name="PlayButton" Click="PlayButtonOnClick"
    5861        <Button.BitmapEffect> 
    5962          <OuterGlowBitmapEffect GlowColor="#FF000000" GlowSize="2" Opacity="0.9"/> 
     
    6568        </Button.BitmapEffect> 
    6669      </Button> 
     70 
     71                        <WindowsFormsHost Height="1" Width="1"> 
     72                                <vlc:MusicPlayerControl x:Name="VLControl"/> 
     73                        </WindowsFormsHost> 
    6774                </StackPanel> 
    6875                 
  • dmp/trunk/client/wpfclient/main_window.xaml.cs

    r166 r172  
    3838            songViewBorder.Child = songView; 
    3939                        songView.Focusable = true; 
    40             /* 
     40             
    4141            myBridge = new Bridge(); 
    4242 
    4343            myBridge.ServerAdded += serverAdded; 
    4444            myBridge.ServerRemoved += serverRemoved; 
     45                        myBridge.ServerStatusChanged += ServerStatusChanged; 
    4546                        myBridge.SongListChanged += DataTableChanged; 
    4647            myBridge.StartZeroConf(); 
    47             */ 
     48             
    4849            songView.VertScrollBar = vertScroll; 
    4950            songView.HorizScrollBar = horizScroll; 
     
    5657 
    5758            songView.SearchBox = SearchBox; 
     59 
     60                        VLControl.Width = 10; 
     61                        VLControl.Height = 10; 
     62                        VLControl.UseMpegVbrOffset = false; 
     63                        VLControl.Name = "VLControl"; 
     64                        //VLControl.Volume = 100; 
     65 
    5866            /*Canvas serverBtn = CreateNewServerButton("a really long server name alskdjflkj", true); 
    5967            serverStack.Children.Add(serverBtn); 
    6068            serverBtn = CreateNewServerButton("Another server", false); 
    6169            serverStack.Children.Add(serverBtn);*/ 
     70 
     71                        PlayButton.Content = false; 
    6272        } 
    6373 
     
    7080                newServers.Enqueue(new GPair<string, bool>(args.ServerName, args.ServerIsConnected)); 
    7181            } 
    72  
     82                        Console.WriteLine("Adding server "+args.ServerName); 
    7383            serverStack.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal,  
    7484                                        new ServerUpdateDelegate(addServer)); 
     
    8696            } 
    8797             
     98                        if(displayedServers.ContainsKey(server.First)) 
     99                                return; 
     100 
    88101            //StackPanel newButton = CreateServerButton(server.First, server.Second); 
    89102            Canvas newButton = CreateNewServerButton(server.First, server.Second); 
     103 
    90104            displayedServers.Add(server.First, newButton); 
    91105            serverStack.Children.Add(newButton); 
     
    97111                removedServers.Enqueue(args.ServerName); 
    98112            } 
     113 
     114                        Console.WriteLine("Removing server "+args.ServerName); 
    99115            serverStack.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal,  
    100116                                        new ServerUpdateDelegate(removeServer)); 
     
    138154            Button controlButton = new Button(); 
    139155            controlButton.Template = GetButtonTemplate(connected); 
    140                         controlButton.PreviewMouseLeftButtonDown += OnServerAdd
     156                        controlButton.PreviewMouseLeftButtonDown += OnServerClick
    141157                        controlButton.Content = serverName; 
    142158            mainPanel.Children.Add(controlButton); 
     
    171187            Button controlButton = new Button(); 
    172188            controlButton.Template = GetButtonTemplate(connected); 
    173             controlButton.PreviewMouseLeftButtonDown += OnServerAdd
    174             controlButton.Content = serverName
     189            controlButton.PreviewMouseLeftButtonDown += OnServerClick
     190            controlButton.Content = new ServerStatus(serverName, connected)
    175191            controlButton.Margin = new Thickness(170, 0, 0, 0); 
    176192            mainPanel.Children.Add(controlButton); 
     
    193209                } 
    194210                 
    195                 Queue<GPair<string, bool>> statusQueue = new Queue<GPair<string, bool>>(); 
    196                 private void ServerStatusChanged(string serverName, bool connected){ 
     211                Queue<ServerStatus> statusQueue = new Queue<ServerStatus>(); 
     212                private void ServerStatusChanged(object o, ServerStatusEventArgs args){// string serverName, bool connected){ 
    197213                        lock(statusQueue){ 
    198                                 statusQueue.Enqueue(new GPair<string, bool>(serverName, connected)); 
    199                         } 
    200  
     214                                statusQueue.Enqueue(new ServerStatus(args.ServerName, args.ServerIsConnected)); 
     215                        } 
     216                        Console.WriteLine("ServerStatusChanged called"); 
    201217                        serverStack.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal,  
    202218                                        new ServerUpdateDelegate(ChangeServerStatus)); 
     
    205221                //Will change a server button status to connected or disconnected regardless of earlier state 
    206222                void ChangeServerStatus() { 
    207                         GPair<string, bool> server; 
     223                        ServerStatus server; 
    208224                        lock(statusQueue){ 
    209225                                server = statusQueue.Dequeue(); 
    210226                        } 
    211227                         
    212                         Panel mainPanel = displayedServers[server.First]; 
    213                         BitmapImage bitmap = (BitmapImage)((Image)mainPanel.Children[0]).Source; 
    214  
     228                        Canvas serverCanvas = displayedServers[server.ServerName]; 
     229                        //BitmapImage bitmap = (BitmapImage)((Image)mainPanel.Children[0]).Source; 
     230                        BitmapImage bitmap = new BitmapImage(); 
    215231                        bitmap.BeginInit(); 
     232                        bitmap.UriSource = GetServerStatus(server.Connected); 
     233                        bitmap.EndInit(); 
     234 
     235                        Image connectionStatus = (Image)serverCanvas.Children[0]; 
     236                        connectionStatus.Source = (ImageSource)bitmap; 
     237                        /*bitmap.BeginInit(); 
    216238                        bitmap.UriSource = GetServerStatus(server.Second); 
    217239                        bitmap.EndInit(); 
    218  
    219                         Button controlButton = (Button)mainPanel.Children[2]; 
    220                         controlButton.Template = GetButtonTemplate(server.Second); 
     240                        */ 
     241                        Button controlButton = (Button)serverCanvas.Children[2]; 
     242                        controlButton.Template = GetButtonTemplate(server.Connected); 
     243                        controlButton.Content = server; 
    221244                } 
    222245 
     
    240263                } 
    241264 
    242                 Queue<string> serverAddQueue = new Queue<string>(); 
    243                 private void OnServerAdd(object sender, MouseButtonEventArgs args){ 
     265                Queue<ServerStatus> serverAddQueue = new Queue<ServerStatus>(); 
     266                private void OnServerClick(object sender, MouseButtonEventArgs args){ 
    244267                        Button source = (Button)sender; 
    245268                        //(string)source.Content; 
    246  
     269                        ServerStatus status = ((ServerStatus)source.Content); 
    247270                        lock(serverAddQueue){ 
    248                                 serverAddQueue.Enqueue((string)source.Content); 
    249                         } 
    250                         Thread newThread = new Thread(TServerAdd); 
     271                                serverAddQueue.Enqueue(new ServerStatus(status.ServerName, status.Connected)); 
     272                        } 
     273                        Thread newThread = new Thread(TServerClick); 
    251274                        newThread.Start(); 
    252275                } 
    253276 
    254                 void TServerAdd(){ 
    255                         string serverName
     277                void TServerClick(){ 
     278                        ServerStatus status
    256279                         
    257280                        lock(serverAddQueue){ 
    258                                 serverName = serverAddQueue.Dequeue(); 
    259                         } 
    260  
    261                         myBridge.AddServerConnection(serverName); 
     281                                status = serverAddQueue.Dequeue(); 
     282                        } 
     283 
     284                        if(status.Connected) 
     285                                myBridge.RemoveServerConnection(status.ServerName); 
     286                        else 
     287                                myBridge.AddServerConnection(status.ServerName); 
     288                } 
     289 
     290                void PlayButtonOnClick(object sender, RoutedEventArgs args) { 
     291                         
     292                        if(VLControl.IsPlaying){ 
     293                                VLControl.Pause(); 
     294                                PlayButton.Template = (ControlTemplate)this.FindResource("PlayIcon"); 
     295                        } 
     296                        else if(VLControl.IsPaused){ 
     297                                VLControl.UnPause(); 
     298 
     299                                PlayButton.Template = (ControlTemplate)this.FindResource("PauseIcon"); 
     300                        } 
     301                        else { 
     302                                int songId = songView.HighlightedRow.SongId; 
     303                                string songURL = myBridge.getSongURL(songId); 
     304                                 
     305                                VLControl.AddSongToPlaylist(songId, songURL, songURL); 
     306                                VLControl.PlaySong(songId); 
     307 
     308                                PlayButton.Template = (ControlTemplate)this.FindResource("PauseIcon"); 
     309                        } 
     310                } 
     311 
     312                class ServerStatus { 
     313                        public string ServerName; 
     314                        public bool Connected; 
     315 
     316                        public ServerStatus(string serverName, bool connected){ 
     317                                ServerName = serverName; 
     318                                Connected = connected; 
     319                        } 
    262320                } 
    263321 
  • dmp/trunk/client/wpfclient/wpfclient.csproj

    r148 r172  
    3030    <Reference Include="System" /> 
    3131    <Reference Include="System.Data" /> 
     32    <Reference Include="System.Windows.Forms" /> 
    3233    <Reference Include="System.Xml" /> 
    3334    <Reference Include="UIAutomationProvider" /> 
     
    3536    <Reference Include="PresentationCore" /> 
    3637    <Reference Include="PresentationFramework" /> 
     38    <Reference Include="WindowsFormsIntegration" /> 
    3739  </ItemGroup> 
    3840  <ItemGroup> 
     
    5658      <Project>{C7D0CE28-60E1-4FC8-B9E0-DBB9F683E95E}</Project> 
    5759      <Name>daap-sharp</Name> 
     60    </ProjectReference> 
     61    <ProjectReference Include="..\..\vlc.NET\VLanControl.csproj"> 
     62      <Project>{4E5BE39D-D764-494F-80DB-C32854595A08}</Project> 
     63      <Name>VLanControl</Name> 
    5864    </ProjectReference> 
    5965  </ItemGroup>