13 changed files with 273 additions and 0 deletions
@ -0,0 +1,21 @@ |
|||
namespace speedLight.BL.Models; |
|||
|
|||
public class Space |
|||
{ |
|||
public Mechanic Mechanic { get; set; } |
|||
public Picture Picture { get; set; } |
|||
public Ball Ball { get; set; } |
|||
|
|||
public Space(Mechanic mechanic, Picture picture) |
|||
{ |
|||
Mechanic = mechanic; |
|||
Picture = picture; |
|||
Ball = new Ball(); |
|||
} |
|||
|
|||
|
|||
public void Move() |
|||
{ |
|||
Ball.Move(); |
|||
} |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net6.0</TargetFramework> |
|||
<ImplicitUsings>enable</ImplicitUsings> |
|||
<Nullable>enable</Nullable> |
|||
</PropertyGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,15 @@ |
|||
<Application xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
x:Class="speedLight.UI.App" |
|||
xmlns:local="using:speedLight.UI" |
|||
RequestedThemeVariant="Default"> |
|||
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. --> |
|||
|
|||
<Application.DataTemplates> |
|||
<local:ViewLocator/> |
|||
</Application.DataTemplates> |
|||
|
|||
<Application.Styles> |
|||
<FluentTheme /> |
|||
</Application.Styles> |
|||
</Application> |
|||
@ -0,0 +1,28 @@ |
|||
using Avalonia; |
|||
using Avalonia.Controls.ApplicationLifetimes; |
|||
using Avalonia.Markup.Xaml; |
|||
using speedLight.UI.ViewModels; |
|||
using speedLight.UI.Views; |
|||
|
|||
namespace speedLight.UI; |
|||
|
|||
public partial class App : Application |
|||
{ |
|||
public override void Initialize() |
|||
{ |
|||
AvaloniaXamlLoader.Load(this); |
|||
} |
|||
|
|||
public override void OnFrameworkInitializationCompleted() |
|||
{ |
|||
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) |
|||
{ |
|||
desktop.MainWindow = new MainWindow |
|||
{ |
|||
DataContext = new MainWindowViewModel(), |
|||
}; |
|||
} |
|||
|
|||
base.OnFrameworkInitializationCompleted(); |
|||
} |
|||
} |
|||
|
After Width: | Height: | Size: 172 KiB |
@ -0,0 +1,23 @@ |
|||
using Avalonia; |
|||
using Avalonia.ReactiveUI; |
|||
using System; |
|||
|
|||
namespace speedLight.UI; |
|||
|
|||
class Program |
|||
{ |
|||
// Initialization code. Don't use any Avalonia, third-party APIs or any
|
|||
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
|
|||
// yet and stuff might break.
|
|||
[STAThread] |
|||
public static void Main(string[] args) => BuildAvaloniaApp() |
|||
.StartWithClassicDesktopLifetime(args); |
|||
|
|||
// Avalonia configuration, don't remove; also used by visual designer.
|
|||
public static AppBuilder BuildAvaloniaApp() |
|||
=> AppBuilder.Configure<App>() |
|||
.UsePlatformDetect() |
|||
.WithInterFont() |
|||
.LogToTrace() |
|||
.UseReactiveUI(); |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
using System; |
|||
using Avalonia.Controls; |
|||
using Avalonia.Controls.Templates; |
|||
using speedLight.UI.ViewModels; |
|||
|
|||
namespace speedLight.UI; |
|||
|
|||
public class ViewLocator : IDataTemplate |
|||
{ |
|||
public Control Build(object data) |
|||
{ |
|||
var name = data.GetType().FullName!.Replace("ViewModel", "View"); |
|||
var type = Type.GetType(name); |
|||
|
|||
if (type != null) |
|||
{ |
|||
return (Control) Activator.CreateInstance(type)!; |
|||
} |
|||
|
|||
return new TextBlock {Text = "Not Found: " + name}; |
|||
} |
|||
|
|||
public bool Match(object data) |
|||
{ |
|||
return data is ViewModelBase; |
|||
} |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Avalonia.Media.Imaging; |
|||
using speedLight.UI.Helpers; |
|||
using speedLight.UI.Models; |
|||
|
|||
namespace speedLight.UI.ViewModels; |
|||
|
|||
public class MainWindowViewModel : ViewModelBase |
|||
{ |
|||
public PictureList Pictures = new PictureList(); |
|||
|
|||
public string ImageSource => ""; |
|||
public Task<Bitmap?> ImageFromWebsite { get; set; } |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
using ReactiveUI; |
|||
|
|||
namespace speedLight.UI.ViewModels; |
|||
|
|||
public class ViewModelBase : ReactiveObject |
|||
{ |
|||
} |
|||
@ -0,0 +1,40 @@ |
|||
<Window xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
xmlns:vm="using:speedLight.UI.ViewModels" |
|||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
|||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" |
|||
x:Class="speedLight.UI.Views.MainWindow" |
|||
x:DataType="vm:MainWindowViewModel" |
|||
Icon="/Assets/avalonia-logo.ico" |
|||
Title="speedLight.UI" |
|||
DataContextChanged="StyledElement_OnDataContextChanged" |
|||
> |
|||
|
|||
<Design.DataContext> |
|||
<!-- This only sets the DataContext for the previewer in an IDE, |
|||
to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) --> |
|||
<vm:MainWindowViewModel /> |
|||
</Design.DataContext> |
|||
|
|||
<WrapPanel HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> |
|||
<Image |
|||
MaxHeight="300" |
|||
MaxWidth="300" |
|||
Name="imgMain" |
|||
Source="{Binding ImageFromWebsite }" |
|||
HorizontalAlignment="Center" |
|||
VerticalAlignment="Center" /> |
|||
<TextBlock>Скорость</TextBlock> |
|||
<ComboBox |
|||
Width="200" |
|||
Name="cmbSpeed" |
|||
SelectionChanged="CmbSpeed_OnSelectionChanged"></ComboBox> |
|||
<TextBlock>Сценарий</TextBlock> |
|||
<ComboBox |
|||
Width="200" |
|||
Name="cmbList" |
|||
SelectionChanged="CmbList_OnSelectionChanged"></ComboBox> |
|||
</WrapPanel> |
|||
|
|||
</Window> |
|||
@ -0,0 +1,45 @@ |
|||
using System; |
|||
using Avalonia.Controls; |
|||
using speedLight.UI.Helpers; |
|||
using speedLight.UI.Models; |
|||
using speedLight.UI.ViewModels; |
|||
|
|||
namespace speedLight.UI.Views; |
|||
|
|||
public partial class MainWindow : Window |
|||
{ |
|||
public MainWindow() |
|||
{ |
|||
InitializeComponent(); |
|||
} |
|||
|
|||
private void h_FillCmbList() |
|||
{ |
|||
foreach (Picture picture in ((MainWindowViewModel) DataContext).Pictures.Items) |
|||
{ |
|||
cmbList.Items.Add(picture); |
|||
} |
|||
cmbSpeed.Items.Add("") |
|||
} |
|||
|
|||
private void CmbList_OnSelectionChanged(object? sender, SelectionChangedEventArgs e) |
|||
{ |
|||
Picture? obj = (Picture)(cmbList.SelectedValue); |
|||
if (obj == null) return; |
|||
((MainWindowViewModel)DataContext).ImageFromWebsite = ImageHelper.LoadFromWeb(new Uri(obj.Url)); |
|||
} |
|||
|
|||
private void CmbList_OnDropDownOpened(object? sender, EventArgs e) |
|||
{ |
|||
} |
|||
|
|||
private void StyledElement_OnDataContextChanged(object? sender, EventArgs e) |
|||
{ |
|||
if (cmbList.Items.Count == 0) h_FillCmbList(); |
|||
} |
|||
|
|||
private void CmbSpeed_OnSelectionChanged(object? sender, SelectionChangedEventArgs e) |
|||
{ |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1"> |
|||
<!-- This manifest is used on Windows only. |
|||
Don't remove it as it might cause problems with window transparency and embeded controls. |
|||
For more details visit https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests --> |
|||
<assemblyIdentity version="1.0.0.0" name="speedLight.UI.Desktop"/> |
|||
|
|||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> |
|||
<application> |
|||
<!-- A list of the Windows versions that this application has been tested on |
|||
and is designed to work with. Uncomment the appropriate elements |
|||
and Windows will automatically select the most compatible environment. --> |
|||
|
|||
<!-- Windows 10 --> |
|||
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" /> |
|||
</application> |
|||
</compatibility> |
|||
</assembly> |
|||
@ -0,0 +1,25 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
<PropertyGroup> |
|||
<OutputType>WinExe</OutputType> |
|||
<TargetFramework>net6.0</TargetFramework> |
|||
<Nullable>enable</Nullable> |
|||
<BuiltInComInteropSupport>true</BuiltInComInteropSupport> |
|||
<ApplicationManifest>app.manifest</ApplicationManifest> |
|||
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<AvaloniaResource Include="Assets\**"/> |
|||
</ItemGroup> |
|||
|
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Avalonia" Version="11.0.2"/> |
|||
<PackageReference Include="Avalonia.Desktop" Version="11.0.2"/> |
|||
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.2"/> |
|||
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.0.2"/> |
|||
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.--> |
|||
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.2"/> |
|||
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.2"/> |
|||
</ItemGroup> |
|||
</Project> |
|||
Loading…
Reference in new issue