Changeset 166

Show
Ignore:
Timestamp:
03/09/07 01:54:54 (2 years ago)
Author:
timtsu2
Message:

Added the CreateNewServerButton? which adds the server programatically

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • dmp/trunk/client/wpfclient/main_window.xaml

    r162 r166  
    7474          <SolidColorBrush Color="GhostWhite" Opacity="0.6"/> 
    7575        </StackPanel.Background> 
    76         <Canvas Height="24"> 
     76        <!--<Canvas Height="24"> 
    7777          <Image Source="pack://application:,,/resources/Server_red.png"/> 
    7878          <TextBlock x:Name="ServerIndicator" Width="150" Margin="20,3,0,0" TextTrimming="CharacterEllipsis"  
     
    8080                     Text="My Server name is really long blah blah blah"/> 
    8181          <Button Template="{StaticResource ServerAdd}" Margin="170,0,0,0"/> 
    82         </Canvas> 
     82        </Canvas>--> 
    8383        <!--StackPanel Orientation="Horizontal"> 
    8484          <Image Source="pack://application:,,/resources/Server_red.png" Height="20" Width="20"/> 
  • dmp/trunk/client/wpfclient/main_window.xaml.cs

    r162 r166  
    5656 
    5757            songView.SearchBox = SearchBox; 
     58            /*Canvas serverBtn = CreateNewServerButton("a really long server name alskdjflkj", true); 
     59            serverStack.Children.Add(serverBtn); 
     60            serverBtn = CreateNewServerButton("Another server", false); 
     61            serverStack.Children.Add(serverBtn);*/ 
    5862        } 
    5963 
     
    7074                                        new ServerUpdateDelegate(addServer)); 
    7175        } 
    72  
    73         Dictionary<string, StackPanel> displayedServers = new Dictionary<string, StackPanel>(); 
     76        // changed to handle canvas instead of StackPanel 
     77        Dictionary<string, Canvas> displayedServers = new Dictionary<string, Canvas>(); 
    7478 
    7579        //Adds a server listing on the left sidepanel 
     
    8286            } 
    8387             
    84             StackPanel newButton = CreateServerButton(server.First, server.Second); 
     88            //StackPanel newButton = CreateServerButton(server.First, server.Second); 
     89            Canvas newButton = CreateNewServerButton(server.First, server.Second); 
    8590            displayedServers.Add(server.First, newButton); 
    8691            serverStack.Children.Add(newButton); 
     
    121126 
    122127            TextBlock serverText = new TextBlock(new Run(serverName)); 
    123             serverText.FontSize = 14; 
    124             serverText.Margin = new Thickness(2) ; 
     128            serverText.Width = 150; 
     129            serverText.TextTrimming = TextTrimming.CharacterEllipsis; 
     130            // Bind the tooltip text to the name of the server. 
     131            /*ToolTip tt = new ToolTip(); 
     132            Binding textBinding = new Binding("Text"); 
     133            textBinding.Source = serverText; 
     134            tt.SetBinding(tt.Content, textBinding); 
     135            serverText.ToolTip = tt;*/ 
    125136            mainPanel.Children.Add(serverText); 
    126137 
     
    134145        } 
    135146 
     147        // Server Button using canvas 
     148        private Canvas CreateNewServerButton(string serverName, bool connected) 
     149        { 
     150            Canvas mainPanel = new Canvas(); 
     151            mainPanel.Height = 24; 
     152 
     153            BitmapImage bitmap = new BitmapImage(); 
     154            bitmap.BeginInit(); 
     155            bitmap.UriSource = GetServerStatus(connected); 
     156            bitmap.EndInit(); 
     157 
     158            Image connectionStatus = new Image(); 
     159            connectionStatus.Source = bitmap; 
     160            mainPanel.Children.Add(connectionStatus); 
     161 
     162            TextBlock serverText = new TextBlock(new Run(serverName)); 
     163            serverText.Width = 150; 
     164            serverText.Margin = new Thickness(20, 3, 0, 0); 
     165            serverText.TextTrimming = TextTrimming.CharacterEllipsis; 
     166            ToolTip tt = new ToolTip(); 
     167            tt.Content = serverName; 
     168            serverText.ToolTip = tt; 
     169            mainPanel.Children.Add(serverText); 
     170 
     171            Button controlButton = new Button(); 
     172            controlButton.Template = GetButtonTemplate(connected); 
     173            controlButton.PreviewMouseLeftButtonDown += OnServerAdd; 
     174            controlButton.Content = serverName; 
     175            controlButton.Margin = new Thickness(170, 0, 0, 0); 
     176            mainPanel.Children.Add(controlButton); 
     177 
     178            return mainPanel; 
     179        } 
     180 
    136181        private Uri GetServerStatus(bool connected){ 
    137182            if(connected) 
     
    165210                        } 
    166211                         
    167                         StackPanel mainPanel = displayedServers[server.First]; 
     212                        Panel mainPanel = displayedServers[server.First]; 
    168213                        BitmapImage bitmap = (BitmapImage)((Image)mainPanel.Children[0]).Source; 
    169214