Changeset 172
- Timestamp:
- 03/09/07 04:53:32 (2 years ago)
- Files:
-
- dmp/trunk/BadClient/Form1.cs (modified) (1 diff)
- dmp/trunk/client/wpfclient/ControlTemplates.xaml (modified) (1 diff)
- dmp/trunk/client/wpfclient/SongViewer.cs (modified) (8 diffs)
- dmp/trunk/client/wpfclient/main_window.xaml (modified) (3 diffs)
- dmp/trunk/client/wpfclient/main_window.xaml.cs (modified) (10 diffs)
- dmp/trunk/client/wpfclient/wpfclient.csproj (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
dmp/trunk/BadClient/Form1.cs
r164 r172 110 110 { 111 111 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); 114 113 115 114 116 vlcPlayer.PlaySong(songId);115 //vlcPlayer.PlaySong(songId); 117 116 this.button3.Text = "Pause"; 118 117 } dmp/trunk/client/wpfclient/ControlTemplates.xaml
r148 r172 10 10 <Trigger Property="IsPressed" Value="true"> 11 11 <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"/> 12 24 </Trigger> 13 25 </ControlTemplate.Triggers> dmp/trunk/client/wpfclient/SongViewer.cs
r162 r172 53 53 54 54 HighlightedRow.SongId = -1; 55 HighlightedRow.LibId = -1;56 55 HighlightedRow.LastIndex = -1; 57 56 … … 59 58 } 60 59 61 struct RowRecord{60 public struct RowRecord{ 62 61 public int SongId; 63 public int LibId;64 62 public int LastIndex; 65 63 } … … 203 201 Brush currentBrush; 204 202 205 bool rowHighlighted = ((int) currentView[i]["id"]== HighlightedRow.SongId);203 bool rowHighlighted = ((int)((long)currentView[i]["id"]) == HighlightedRow.SongId); 206 204 if (rowHighlighted) { 207 205 currentBrush = HighlightedRowColor; … … 219 217 while (currentCol != null) 220 218 { 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); 222 222 223 223 currentPt.X += colWidth; … … 300 300 } 301 301 302 RowRecord HighlightedRow;302 public RowRecord HighlightedRow; 303 303 304 304 Brush fontColor = Brushes.Black; … … 323 323 324 324 HighlightedRow.LastIndex = rowClicked -1; 325 HighlightedRow.SongId = (int) currentView[HighlightedRow.LastIndex]["id"];325 HighlightedRow.SongId = (int)((long)currentView[HighlightedRow.LastIndex]["id"]); 326 326 327 327 InvalidateVisual(); … … 449 449 void MoveHighlight(int amount){ 450 450 //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) 452 452 return; 453 453 … … 458 458 459 459 HighlightedRow.LastIndex = newIndex; 460 HighlightedRow.SongId = (int) currentView[newIndex]["id"];460 HighlightedRow.SongId = (int)((long)currentView[newIndex]["id"]); 461 461 462 462 if(newIndex < FirstIndex){ dmp/trunk/client/wpfclient/main_window.xaml
r166 r172 4 4 xmlns:def="Definition" 5 5 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" 6 9 Title="Rubicon" 7 10 > … … 55 58 </Button.BitmapEffect> 56 59 </Button> 57 <Button Template="{StaticResource PlayIcon}" Margin="5" >60 <Button Template="{StaticResource PlayIcon}" Margin="5" Name="PlayButton" Click="PlayButtonOnClick"> 58 61 <Button.BitmapEffect> 59 62 <OuterGlowBitmapEffect GlowColor="#FF000000" GlowSize="2" Opacity="0.9"/> … … 65 68 </Button.BitmapEffect> 66 69 </Button> 70 71 <WindowsFormsHost Height="1" Width="1"> 72 <vlc:MusicPlayerControl x:Name="VLControl"/> 73 </WindowsFormsHost> 67 74 </StackPanel> 68 75 dmp/trunk/client/wpfclient/main_window.xaml.cs
r166 r172 38 38 songViewBorder.Child = songView; 39 39 songView.Focusable = true; 40 /*40 41 41 myBridge = new Bridge(); 42 42 43 43 myBridge.ServerAdded += serverAdded; 44 44 myBridge.ServerRemoved += serverRemoved; 45 myBridge.ServerStatusChanged += ServerStatusChanged; 45 46 myBridge.SongListChanged += DataTableChanged; 46 47 myBridge.StartZeroConf(); 47 */48 48 49 songView.VertScrollBar = vertScroll; 49 50 songView.HorizScrollBar = horizScroll; … … 56 57 57 58 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 58 66 /*Canvas serverBtn = CreateNewServerButton("a really long server name alskdjflkj", true); 59 67 serverStack.Children.Add(serverBtn); 60 68 serverBtn = CreateNewServerButton("Another server", false); 61 69 serverStack.Children.Add(serverBtn);*/ 70 71 PlayButton.Content = false; 62 72 } 63 73 … … 70 80 newServers.Enqueue(new GPair<string, bool>(args.ServerName, args.ServerIsConnected)); 71 81 } 72 82 Console.WriteLine("Adding server "+args.ServerName); 73 83 serverStack.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, 74 84 new ServerUpdateDelegate(addServer)); … … 86 96 } 87 97 98 if(displayedServers.ContainsKey(server.First)) 99 return; 100 88 101 //StackPanel newButton = CreateServerButton(server.First, server.Second); 89 102 Canvas newButton = CreateNewServerButton(server.First, server.Second); 103 90 104 displayedServers.Add(server.First, newButton); 91 105 serverStack.Children.Add(newButton); … … 97 111 removedServers.Enqueue(args.ServerName); 98 112 } 113 114 Console.WriteLine("Removing server "+args.ServerName); 99 115 serverStack.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, 100 116 new ServerUpdateDelegate(removeServer)); … … 138 154 Button controlButton = new Button(); 139 155 controlButton.Template = GetButtonTemplate(connected); 140 controlButton.PreviewMouseLeftButtonDown += OnServer Add;156 controlButton.PreviewMouseLeftButtonDown += OnServerClick; 141 157 controlButton.Content = serverName; 142 158 mainPanel.Children.Add(controlButton); … … 171 187 Button controlButton = new Button(); 172 188 controlButton.Template = GetButtonTemplate(connected); 173 controlButton.PreviewMouseLeftButtonDown += OnServer Add;174 controlButton.Content = serverName;189 controlButton.PreviewMouseLeftButtonDown += OnServerClick; 190 controlButton.Content = new ServerStatus(serverName, connected); 175 191 controlButton.Margin = new Thickness(170, 0, 0, 0); 176 192 mainPanel.Children.Add(controlButton); … … 193 209 } 194 210 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){ 197 213 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"); 201 217 serverStack.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, 202 218 new ServerUpdateDelegate(ChangeServerStatus)); … … 205 221 //Will change a server button status to connected or disconnected regardless of earlier state 206 222 void ChangeServerStatus() { 207 GPair<string, bool>server;223 ServerStatus server; 208 224 lock(statusQueue){ 209 225 server = statusQueue.Dequeue(); 210 226 } 211 227 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(); 215 231 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(); 216 238 bitmap.UriSource = GetServerStatus(server.Second); 217 239 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; 221 244 } 222 245 … … 240 263 } 241 264 242 Queue< string> serverAddQueue = new Queue<string>();243 private void OnServer Add(object sender, MouseButtonEventArgs args){265 Queue<ServerStatus> serverAddQueue = new Queue<ServerStatus>(); 266 private void OnServerClick(object sender, MouseButtonEventArgs args){ 244 267 Button source = (Button)sender; 245 268 //(string)source.Content; 246 269 ServerStatus status = ((ServerStatus)source.Content); 247 270 lock(serverAddQueue){ 248 serverAddQueue.Enqueue( (string)source.Content);249 } 250 Thread newThread = new Thread(TServer Add);271 serverAddQueue.Enqueue(new ServerStatus(status.ServerName, status.Connected)); 272 } 273 Thread newThread = new Thread(TServerClick); 251 274 newThread.Start(); 252 275 } 253 276 254 void TServer Add(){255 string serverName;277 void TServerClick(){ 278 ServerStatus status; 256 279 257 280 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 } 262 320 } 263 321 dmp/trunk/client/wpfclient/wpfclient.csproj
r148 r172 30 30 <Reference Include="System" /> 31 31 <Reference Include="System.Data" /> 32 <Reference Include="System.Windows.Forms" /> 32 33 <Reference Include="System.Xml" /> 33 34 <Reference Include="UIAutomationProvider" /> … … 35 36 <Reference Include="PresentationCore" /> 36 37 <Reference Include="PresentationFramework" /> 38 <Reference Include="WindowsFormsIntegration" /> 37 39 </ItemGroup> 38 40 <ItemGroup> … … 56 58 <Project>{C7D0CE28-60E1-4FC8-B9E0-DBB9F683E95E}</Project> 57 59 <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> 58 64 </ProjectReference> 59 65 </ItemGroup>
