public MainWindow() { InitializeComponent(); list = new List <TrackViewUserControl>(); Windows.mainWindow = this; homePage = new HomePage(); Width = SystemParameters.PrimaryScreenWidth * 0.8; Height = SystemParameters.PrimaryScreenHeight * 0.8; MaxHeight = SystemParameters.MaximizedPrimaryScreenHeight; var a = new WindowStateUserControl(this); a.WindowState_Label.Opacity = 0.7; grid.Children.Add(a); mediaPlayer = new MediaPlayer(); frame.Navigate(homePage); Profile_Button.Content = repository.GetUsername(); var tuple = new Repository().GetUsersToFollow(); for (int i = 0, j = 1; i < tuple.Item1.Length; i++, j++) { var followUserControl = new FollowUserControl(tuple.Item1[i], tuple.Item2[i]); Grid.SetRow(followUserControl, j); Users_Grid.Children.Add(followUserControl); } }
public SearchResultPage(string search) { InitializeComponent(); #region string connectionString = @"Data Source=JAMES-SPLEEN;Initial Catalog=WoozyTune;Integrated Security=True"; using (var connection = new SqlConnection(connectionString)) { connection.Open(); string select = $"SELECT * FROM Tracks WHERE [Title] LIKE '%{search}%'"; var command = new SqlCommand(select, connection); var reader = command.ExecuteReader(); int i = 1; while (reader.Read()) { grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); var trackViewUserControl = new TrackViewUserControl((int)reader.GetValue(0), reader.GetString(5), reader.GetString(6)); Grid.SetRow(trackViewUserControl, i++); grid.Children.Add(trackViewUserControl); } } using (var connection = new SqlConnection(connectionString)) { connection.Open(); string select = $"SELECT * FROM Tracks WHERE [Artist] LIKE '%{search}%'"; var command = new SqlCommand(select, connection); var reader = command.ExecuteReader(); int i = 1; while (reader.Read()) { grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); var trackViewUserControl = new TrackViewUserControl((int)reader.GetValue(0), reader.GetString(5), reader.GetString(6)); Grid.SetRow(trackViewUserControl, i++); grid.Children.Add(trackViewUserControl); } } using (var connection = new SqlConnection(connectionString)) { connection.Open(); string select = $"SELECT [UserId], [Username] FROM [UsersData] WHERE [Username] LIKE '%{search}%'"; var command = new SqlCommand(select, connection); var reader = command.ExecuteReader(); int i = 1; while (reader.Read()) { grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); var trackViewUserControl = new FollowUserControl((int)reader.GetValue(0), reader.GetString(1)); Grid.SetRow(trackViewUserControl, i++); grid.Children.Add(trackViewUserControl); } } #endregion }