Started UI separation
This commit is contained in:
		
							
								
								
									
										27
									
								
								Stars Assistant/ViewModels/BuColViewModel.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								Stars Assistant/ViewModels/BuColViewModel.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,27 @@
 | 
				
			|||||||
 | 
					using System.Collections.ObjectModel;
 | 
				
			||||||
 | 
					using System.Reactive.Disposables;
 | 
				
			||||||
 | 
					using System.Reactive.Linq;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					using ReactiveUI;
 | 
				
			||||||
 | 
					using ReactiveUI.SourceGenerators;
 | 
				
			||||||
 | 
					using Splat;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace StarsAssistant.ViewModels;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public partial class BuColViewModel : ViewModelBase, IActivatableViewModel
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public ViewModelActivator Activator { get; } = new ViewModelActivator();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public BuColViewModel()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        this.WhenActivated((CompositeDisposable disposables) => 
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            // /* handle activation */
 | 
				
			||||||
 | 
					            // Disposable
 | 
				
			||||||
 | 
					            //     .Create(() => { /* handle deactivation */ })
 | 
				
			||||||
 | 
					            //     .DisposeWith(disposables);
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public ObservableCollection<PlanetViewModel> Planets { get; } = PlanetViewModel.LoadAll();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -1,4 +1,4 @@
 | 
				
			|||||||
using System.Collections.ObjectModel;
 | 
					
 | 
				
			||||||
using System.Reactive.Disposables;
 | 
					using System.Reactive.Disposables;
 | 
				
			||||||
using System.Reactive.Linq;
 | 
					using System.Reactive.Linq;
 | 
				
			||||||
using ReactiveUI;
 | 
					using ReactiveUI;
 | 
				
			||||||
@@ -28,8 +28,8 @@ public partial class MainWindowViewModel : ViewModelBase, IActivatableViewModel
 | 
				
			|||||||
            //     .Create(() => { /* handle deactivation */ })
 | 
					            //     .Create(() => { /* handle deactivation */ })
 | 
				
			||||||
            //     .DisposeWith(disposables);
 | 
					            //     .DisposeWith(disposables);
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
    }        
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public ObservableCollection<PlanetViewModel> Planets { get; } = PlanetViewModel.LoadAll();
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										23
									
								
								Stars Assistant/Views/BuColView.axaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								Stars Assistant/Views/BuColView.axaml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,23 @@
 | 
				
			|||||||
 | 
					<UserControl xmlns="https://github.com/avaloniaui"
 | 
				
			||||||
 | 
					             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 | 
				
			||||||
 | 
					             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
 | 
				
			||||||
 | 
					             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
 | 
				
			||||||
 | 
					             xmlns:vm="using:StarsAssistant.ViewModels"
 | 
				
			||||||
 | 
					             mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
 | 
				
			||||||
 | 
					             x:Class="StarsAssistant.Views.BuColView"
 | 
				
			||||||
 | 
					             x:DataType="vm:BuColViewModel">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  <DataGrid x:Name="PlanetsGrid"
 | 
				
			||||||
 | 
					    ItemsSource="{Binding Planets}"
 | 
				
			||||||
 | 
					    IsReadOnly="True" 
 | 
				
			||||||
 | 
					    GridLinesVisibility="All"
 | 
				
			||||||
 | 
					    FrozenColumnCount="1"
 | 
				
			||||||
 | 
					    BorderThickness="1" BorderBrush="Gray">
 | 
				
			||||||
 | 
					    <DataGrid.Columns>
 | 
				
			||||||
 | 
					        <DataGridTextColumn Header="Planet" Binding="{Binding Name}" />
 | 
				
			||||||
 | 
					        <DataGridTextColumn Header="Value" Binding="{Binding Value}" />
 | 
				
			||||||
 | 
					    </DataGrid.Columns>
 | 
				
			||||||
 | 
					  </DataGrid>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					</UserControl>
 | 
				
			||||||
							
								
								
									
										25
									
								
								Stars Assistant/Views/BuColView.axaml.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								Stars Assistant/Views/BuColView.axaml.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,25 @@
 | 
				
			|||||||
 | 
					using System.Reactive.Disposables;
 | 
				
			||||||
 | 
					using Avalonia;
 | 
				
			||||||
 | 
					using Avalonia.Controls;
 | 
				
			||||||
 | 
					using Avalonia.Markup.Xaml;
 | 
				
			||||||
 | 
					using Avalonia.ReactiveUI;
 | 
				
			||||||
 | 
					using ReactiveUI;
 | 
				
			||||||
 | 
					using StarsAssistant.ViewModels;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace StarsAssistant.Views;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public partial class BuColView : ReactiveUserControl<BuColViewModel>
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public BuColView()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /*
 | 
				
			||||||
 | 
					        this.WhenActivated(disposables => 
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					        */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        this.ViewModel = new BuColViewModel();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        InitializeComponent();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -1,8 +1,9 @@
 | 
				
			|||||||
<Window xmlns="https://github.com/avaloniaui"
 | 
					<Window xmlns="https://github.com/avaloniaui"
 | 
				
			||||||
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 | 
					        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 | 
				
			||||||
        xmlns:vm="using:StarsAssistant.ViewModels"
 | 
					 | 
				
			||||||
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
 | 
					        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
 | 
				
			||||||
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
 | 
					        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
 | 
				
			||||||
 | 
					        xmlns:vm="using:StarsAssistant.ViewModels"
 | 
				
			||||||
 | 
					        xmlns:views="clr-namespace:StarsAssistant.Views"
 | 
				
			||||||
        mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
 | 
					        mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
 | 
				
			||||||
        x:Class="StarsAssistant.Views.MainWindow"
 | 
					        x:Class="StarsAssistant.Views.MainWindow"
 | 
				
			||||||
        x:DataType="vm:MainWindowViewModel"
 | 
					        x:DataType="vm:MainWindowViewModel"
 | 
				
			||||||
@@ -24,18 +25,8 @@
 | 
				
			|||||||
                <TextBlock x:Name="DbPath" Grid.Row="0" Grid.Column="1" Margin="0 5" Padding="3"/>
 | 
					                <TextBlock x:Name="DbPath" Grid.Row="0" Grid.Column="1" Margin="0 5" Padding="3"/>
 | 
				
			||||||
            </Grid>
 | 
					            </Grid>
 | 
				
			||||||
        </TabItem>
 | 
					        </TabItem>
 | 
				
			||||||
        <TabItem Header="DataGrid">
 | 
					        <TabItem Header="BuCol">
 | 
				
			||||||
            <DataGrid x:Name="PlanetsGrid"
 | 
					            <views:BuColView />
 | 
				
			||||||
                ItemsSource="{Binding Planets}"
 | 
					 | 
				
			||||||
                IsReadOnly="True" 
 | 
					 | 
				
			||||||
                GridLinesVisibility="All"
 | 
					 | 
				
			||||||
                FrozenColumnCount="1"
 | 
					 | 
				
			||||||
                BorderThickness="1" BorderBrush="Gray">
 | 
					 | 
				
			||||||
                <DataGrid.Columns>
 | 
					 | 
				
			||||||
                    <DataGridTextColumn Header="Planet" Binding="{Binding Name}" />
 | 
					 | 
				
			||||||
                    <DataGridTextColumn Header="Value" Binding="{Binding Value}" />
 | 
					 | 
				
			||||||
                </DataGrid.Columns>
 | 
					 | 
				
			||||||
            </DataGrid>
 | 
					 | 
				
			||||||
        </TabItem>
 | 
					        </TabItem>
 | 
				
			||||||
    </TabControl>
 | 
					    </TabControl>
 | 
				
			||||||
</Window>
 | 
					</Window>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user