Sfoglia il codice sorgente

Restructure and rename stuff

Jonatan Gezelius 1 anno fa
parent
commit
ddff5e8428

+ 0 - 0
Awesomness-Core/Awesomeness-core.csproj → Awesomness.Core/Awesomeness.Core.csproj


+ 21 - 0
Awesomness.Core/CatalogOfPeople.cs

@@ -0,0 +1,21 @@
+namespace Awesomeness.Core;
+
+public class CatalogOfPeople
+{
+	private readonly List<Person> people;
+
+    public CatalogOfPeople()
+    {
+        people = [];
+    }
+
+    public void AddPerson(Person p)
+    {
+        people.Add(p);
+    }
+
+    public List<Person> GetCatalog()
+    {
+        return people;
+    }
+}

+ 1 - 1
Awesomness-Core/Person.cs → Awesomness.Core/Person.cs

@@ -1,4 +1,4 @@
-namespace Awsomeness.Core;
+namespace Awesomeness.Core;
 
 public class Person
 {

+ 0 - 0
Awesomness-GUI/App.xaml → Awesomness.GUI/App.xaml


+ 0 - 0
Awesomness-GUI/App.xaml.cs → Awesomness.GUI/App.xaml.cs


+ 0 - 0
Awesomness-GUI/AssemblyInfo.cs → Awesomness.GUI/AssemblyInfo.cs


+ 1 - 1
Awesomness-GUI/Awsomeness-GUI.csproj → Awesomness.GUI/Awsomeness.GUI.csproj

@@ -14,7 +14,7 @@
   </ItemGroup>
 
   <ItemGroup>
-    <ProjectReference Include="..\Awesomness-Core\Awesomeness-core.csproj" />
+    <ProjectReference Include="..\Awesomness.Core\Awesomeness.Core.csproj" />
   </ItemGroup>
 
 </Project>

+ 19 - 5
Awesomness-GUI/ViewModels/MainViewModel.cs → Awesomness.GUI/ViewModels/MainViewModel.cs

@@ -1,8 +1,9 @@
-using Awsomeness.Core;
+using Awesomeness.Core;
 using CommunityToolkit.Mvvm.ComponentModel;
 using CommunityToolkit.Mvvm.Input;
 using System;
 using System.Collections.Generic;
+using System.Collections.ObjectModel;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
@@ -11,10 +12,18 @@ namespace Awesomeness.GUI.ViewModels;
 
 partial class MainViewModel : ObservableObject
 {
-    private Person _person;
+    private Person scratchPerson;
+    private Person selectedPerson;
+    private CatalogOfPeople catalog;
+    public ObservableCollection<string> AvailableNames;
     public MainViewModel()
     {
-        _person = new Person();
+        scratchPerson = new Person();
+        catalog = new CatalogOfPeople();
+        AvailableNames = new ObservableCollection<string>();
+
+        AvailableNames.Add("Bullshit");
+        AvailableNames.Add("Another Crap");
     }
 
     [ObservableProperty]
@@ -35,12 +44,17 @@ partial class MainViewModel : ObservableObject
     [RelayCommand]
     private void SetName()
     {
-        _person.FirstName = FirstName;
+        scratchPerson.FirstName = FirstName;
     }
 
     [RelayCommand]
     private void GetName()
     {
-        FirstName = _person.FirstName;
+        FirstName = scratchPerson.FirstName;
+    }
+    [RelayCommand]
+    private void AddNameToCatalog()
+    {
+        AvailableNames.Add("Kastöga");
     }
 }

+ 15 - 2
Awesomness-GUI/Views/MainView.xaml → Awesomness.GUI/Views/MainView.xaml

@@ -10,8 +10,9 @@
         Title="MainWindow" Height="450" Width="800">
     <Grid>
         <Grid.ColumnDefinitions>
-            <ColumnDefinition Width="100" />
-            <ColumnDefinition Width="100" />
+            <ColumnDefinition Width="auto" />
+            <ColumnDefinition Width="auto" />
+            <ColumnDefinition Width="auto" />
             <ColumnDefinition Width="auto" />
         </Grid.ColumnDefinitions>
         <Grid.RowDefinitions>
@@ -22,8 +23,20 @@
         <Button Grid.Column="0" Grid.Row="0" Content="Clear" Command="{Binding ResetNameCommand}"/>
         <Label Grid.Column="0" Grid.Row="1" Content="{Binding FirstName}" />
         <TextBox Grid.Column="0" Grid.Row="2" Text="{Binding FirstName, UpdateSourceTrigger=PropertyChanged}"  />
+        
         <Button Grid.Column="1" Grid.Row="2" Content="Set model" Command="{Binding SetNameCommand}"/>
+        
         <Button Grid.Column="2" Grid.Row="2" Content="Get from model" Command="{Binding GetNameCommand}"/>
 
+        <Button Grid.Column="3" Grid.Row="0" Content="Add to list" Command="{Binding AddNameToCatalogCommand}"/>
+        
+        <ListView Grid.Column="3" Grid.Row="1" Width="200" Height="auto" ItemsSource="{Binding AvailableNames}">
+            <ListView.View>
+                <GridView>
+                    <GridViewColumn Header="Name" />
+                </GridView>
+            </ListView.View>
+        </ListView>
+
     </Grid>
 </Window>

+ 1 - 1
Awesomness-GUI/Views/MainView.xaml.cs → Awesomness.GUI/Views/MainView.xaml.cs

@@ -8,7 +8,7 @@ using System.Windows.Media;
 using System.Windows.Media.Imaging;
 using System.Windows.Navigation;
 using System.Windows.Shapes;
-using Awsomeness.Core;
+using Awesomeness.Core;
 using Awesomeness.GUI.ViewModels;
 
 namespace Awesomeness.GUI.Views;

+ 2 - 2
JonatansWPFochMVVMtester.sln

@@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
 # Visual Studio Version 17
 VisualStudioVersion = 17.9.34728.123
 MinimumVisualStudioVersion = 10.0.40219.1
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Awesomeness-core", "Awesomness-Core\Awesomeness-core.csproj", "{5FFCB7B2-FC31-42DD-BC82-AE8D363D55DF}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Awesomeness.Core", "Awesomness.Core\Awesomeness.Core.csproj", "{5FFCB7B2-FC31-42DD-BC82-AE8D363D55DF}"
 EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Awsomeness-GUI", "Awesomness-GUI\Awsomeness-GUI.csproj", "{558A90A9-1980-4C00-8CD7-3B6E18614CCD}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Awsomeness.GUI", "Awesomness.GUI\Awsomeness.GUI.csproj", "{558A90A9-1980-4C00-8CD7-3B6E18614CCD}"
 EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution