Skip to content

Commit

Permalink
username in main window
Browse files Browse the repository at this point in the history
  • Loading branch information
kdeoliveira committed Mar 27, 2023
1 parent c498969 commit 8e92767
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 25 deletions.
2 changes: 0 additions & 2 deletions IoT1/MainWindow.xaml
Expand Up @@ -164,8 +164,6 @@
<Grid Grid.Row="0" Grid.Column="1">
<StackPanel Orientation="Horizontal" >
<TextBlock x:Name="redhat_id" Margin="16 16 8 8" FontSize="16" Width="auto"/>


</StackPanel>
</Grid>

Expand Down
23 changes: 2 additions & 21 deletions IoT1/MainWindow.xaml.cs
Expand Up @@ -16,7 +16,7 @@ public partial class MainWindow : Window
private PacketModel packets;
private readonly SqlConnection connection;
private SettingsViewModel settingsViewModel;
public MainWindow(SqlConnection connection)
public MainWindow(SqlConnection connection, string user)
{
InitializeComponent();
settingsViewModel = new SettingsViewModel();
Expand All @@ -25,31 +25,12 @@ public MainWindow(SqlConnection connection)
DataContext = _viewModel;
packets = new PacketModel();
connectCtx = new ConnectViewModel(packets, settingsViewModel.PreviousGRPCIpAddress);
redhat_id.Text = "Redhat Agent #12345";
redhat_id.Text = string.Format("Redhat Agent {0}", user);
connectCtx.PropertyChanged += ConnectCtx_PropertyChanged;
this.connection = connection;

}

/*
// Overloaded constructor to accept the username and then display it at the top of the page
public MainWindow() : this(string.Empty)
{
}
// Overloaded constructor to accept the username
public MainWindow(string username)
{
InitializeComponent();
redhat_id.Text = username;
_viewModel = new NotificationsViewModel();
DataContext = _viewModel;
packets = new PacketModel();
connectCtx = new ConnectViewModel(packets);
}
*/

private void ConnectCtx_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
Expand Down
2 changes: 1 addition & 1 deletion IoT1/View/LoginPage.xaml.cs
Expand Up @@ -57,7 +57,7 @@ private void btnSubmit_Click(object sender, RoutedEventArgs e)
*/
MessageBox.Show("Login Successfull", "Login/Registration", MessageBoxButton.OK);

MainWindow window = new MainWindow(sqlCon);
MainWindow window = new MainWindow(sqlCon, txtUsername.Text);
Application.Current.MainWindow.Close();
window.ShowDialog();
}
Expand Down
2 changes: 1 addition & 1 deletion IoT1/View/RegisterPage.xaml.cs
Expand Up @@ -47,7 +47,7 @@ private void Button_Click(object sender, RoutedEventArgs e)
cmd.ExecuteNonQuery();
conn.Close();
MessageBox.Show("Registration Completed", "Login/Registration", MessageBoxButton.OK);
MainWindow window = new MainWindow(conn);
MainWindow window = new MainWindow(conn, txt_Username.Text);
Application.Current.MainWindow.Close();
window.ShowDialog();
}
Expand Down

0 comments on commit 8e92767

Please sign in to comment.