Advertisement
eduardogr

Untitled

Jun 27th, 2020
603
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 6.11 KB | None | 0 0
  1. User Class
  2.  
  3.   public class User {
  4.  
  5.         [PrimaryKey, AutoIncrement]
  6.         public int Id { get; set; }
  7.  
  8.         public string Name { get; set; }
  9.  
  10.         public string Email { get; set; }
  11.  
  12.         public string Address { get; set; }
  13.  
  14.         public override string ToString() {
  15.             return $"{Name}";
  16.         }
  17.         public User() { }
  18.     }
  19. }
  20.  MainWindowsVM
  21.  
  22.         public List<User> Users { get; set; }
  23.         public ICommand OpenDialogCommand { get; set; }
  24.         public ICommand CloseCommand { get; set; }
  25.         public ICommand MinimizeCommand { get; set; }
  26.         public ICommand MaximizeCommand { get; set; }
  27.  
  28.         public MainWindowViewModel() {
  29.  
  30.             Users = new List<User>();
  31.             OpenDialogCommand = new OpenDialogCommand(this);
  32.             CloseCommand = new CloseCommand(this);
  33.             MinimizeCommand = new MinimizeCommand(this);
  34.             MaximizeCommand = new MaximizeCommand(this);
  35.  
  36.         }
  37.  
  38.         internal void OpenDialog() {
  39.  
  40.             var dialog = new InputDialog();
  41.             dialog.ShowDialog();
  42.  
  43.             Users = Operation.Read();
  44.  
  45.         }
  46.  
  47.         internal void Close(object obj) {
  48.             Window win = obj as Window;
  49.  
  50.             win.Close();
  51.         }
  52.         internal void Maximize(object obj) {
  53.             Window win = obj as Window;
  54.  
  55.             x++;
  56.  
  57.             win.WindowState = WindowState.Maximized;
  58.  
  59.             if (x % 2 == 0) {
  60.  
  61.                 win.WindowState = WindowState.Normal;
  62.             }
  63.         }
  64.         internal void Minimize(object obj) {
  65.             Window win = obj as Window;
  66.  
  67.             win.WindowState = WindowState.Minimized;
  68.         }
  69.     }
  70.  
  71. InputDialogMV
  72.  
  73.    public User User { get; set; }
  74.         public CloseDialogCommand CloseDialogCommand { get; set; }
  75.         public SaveCommand SaveCommand { get; set; }
  76.  
  77.         public InputViewModel() {
  78.             SaveCommand = new SaveCommand(this);
  79.             CloseDialogCommand = new CloseDialogCommand(this);
  80.             User = new User();
  81.         }
  82.  
  83.  
  84.         internal void CloseDialog(Window window) {
  85.             window.Close();
  86.             Operation.Read();
  87.         }
  88.  
  89.         internal void Save(Window window) {
  90.             Operation.Insert(User);
  91.             window.Close();
  92.         }
  93.  
  94. main XAML
  95.  
  96.  
  97.     <Window.Resources>
  98.         <vm:MainWindowViewModel x:Key="vm" />
  99.     </Window.Resources>
  100.  
  101.     <Grid DataContext="{StaticResource vm}">
  102.         <Grid.RowDefinitions>
  103.             <RowDefinition Height="auto" />
  104.             <RowDefinition Height="auto" />
  105.             <RowDefinition Height="*" />
  106.         </Grid.RowDefinitions>
  107.  
  108.         <Border x:Name="WindowCommandBar"
  109.                 Background="Transparent"
  110.                 MouseDown="WindowCommandBar_MouseDown">
  111.             <Grid>
  112.                 <materialDesign:ColorZone Mode="PrimaryDark">
  113.                     <StackPanel HorizontalAlignment="Right">
  114.                         <Button materialDesign:ShadowAssist.ShadowDepth="Depth4"
  115.                                 Width="30"
  116.                                 Height="30"
  117.                                 Padding="0"
  118.                                 Command="{Binding CloseCommand}"
  119.                                 CommandParameter="{Binding ElementName=Main}">
  120.                             <materialDesign:PackIcon Kind="WindowClose" />
  121.                         </Button>
  122.                     </StackPanel>
  123.                 </materialDesign:ColorZone>
  124.             </Grid>
  125.         </Border>
  126.         <StackPanel Margin="10"
  127.                     Orientation="Horizontal"
  128.                     Grid.Row="1">
  129.             <Button materialDesign:ShadowAssist.ShadowDepth="Depth4"
  130.                     Width="30"
  131.                     Height="30"
  132.                     Padding="0"
  133.                     Command="{Binding OpenDialogCommand}">
  134.                 <materialDesign:PackIcon Kind="UserAdd" />
  135.             </Button>
  136.             <Button materialDesign:ShadowAssist.ShadowDepth="Depth4"
  137.                     Margin="20,0,0,0"
  138.                     Height="30"
  139.                     Width="100"
  140.                     Padding="0"
  141.                     Content="Send Invoice"
  142.                    
  143.                  >
  144.             </Button>
  145.         </StackPanel>
  146.         <Grid Margin="0,50,0,0" Grid.Row="2">
  147.             <Grid.ColumnDefinitions>
  148.                 <ColumnDefinition Width="auto" />
  149.                 <ColumnDefinition Width="*" />
  150.             </Grid.ColumnDefinitions>
  151.             <ListView ItemsSource="{Binding Users}">
  152.             </ListView>
  153.             <Grid Grid.Column="2">
  154.                 <Grid.RowDefinitions>
  155.                     <RowDefinition Height="auto" />
  156.                     <RowDefinition Height="auto" />
  157.                     <RowDefinition Height="auto" />
  158.                 </Grid.RowDefinitions>
  159.                 <StackPanel Margin="10"
  160.                             Grid.Column="1"
  161.                             Orientation="Horizontal">
  162.                     <materialDesign:PackIcon Kind="UserBox"
  163.                                              VerticalAlignment="Center" />
  164.                     <TextBlock Text="Name"
  165.                                VerticalAlignment="Center" />
  166.                 </StackPanel>
  167.                 <StackPanel Margin="10"
  168.                             Grid.Column="1"
  169.                             Grid.Row="1"
  170.                             Orientation="Horizontal">
  171.                     <materialDesign:PackIcon Kind="Email"
  172.                                              VerticalAlignment="Center" />
  173.                     <TextBlock Text="Email"
  174.                                VerticalAlignment="Center" />
  175.                 </StackPanel>
  176.                 <StackPanel Margin="10"
  177.                             Grid.Column="1"
  178.                             Grid.Row="2"
  179.                             Orientation="Horizontal">
  180.                     <materialDesign:PackIcon Kind="Home"
  181.                                              VerticalAlignment="Center" />
  182.                     <TextBlock Text="Adress"
  183.                                VerticalAlignment="Center" />
  184.  
  185.                 </StackPanel>
  186.             </Grid>
  187.  
  188.         </Grid>
  189.     </Grid>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement