diff --git a/speedLight/speedLight.BL/Models/Space.cs b/speedLight/speedLight.BL/Models/Space.cs new file mode 100644 index 0000000..fd87b5f --- /dev/null +++ b/speedLight/speedLight.BL/Models/Space.cs @@ -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(); + } +} \ No newline at end of file diff --git a/speedLight/speedLight.BL/speedLight.BL.csproj b/speedLight/speedLight.BL/speedLight.BL.csproj new file mode 100644 index 0000000..eb2460e --- /dev/null +++ b/speedLight/speedLight.BL/speedLight.BL.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + + diff --git a/speedLight/speedLight.UI/App.axaml b/speedLight/speedLight.UI/App.axaml new file mode 100644 index 0000000..95825db --- /dev/null +++ b/speedLight/speedLight.UI/App.axaml @@ -0,0 +1,15 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/speedLight/speedLight.UI/App.axaml.cs b/speedLight/speedLight.UI/App.axaml.cs new file mode 100644 index 0000000..325c305 --- /dev/null +++ b/speedLight/speedLight.UI/App.axaml.cs @@ -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(); + } +} \ No newline at end of file diff --git a/speedLight/speedLight.UI/Assets/avalonia-logo.ico b/speedLight/speedLight.UI/Assets/avalonia-logo.ico new file mode 100644 index 0000000..da8d49f Binary files /dev/null and b/speedLight/speedLight.UI/Assets/avalonia-logo.ico differ diff --git a/speedLight/speedLight.UI/Program.cs b/speedLight/speedLight.UI/Program.cs new file mode 100644 index 0000000..4ee2df2 --- /dev/null +++ b/speedLight/speedLight.UI/Program.cs @@ -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() + .UsePlatformDetect() + .WithInterFont() + .LogToTrace() + .UseReactiveUI(); +} \ No newline at end of file diff --git a/speedLight/speedLight.UI/ViewLocator.cs b/speedLight/speedLight.UI/ViewLocator.cs new file mode 100644 index 0000000..87430d5 --- /dev/null +++ b/speedLight/speedLight.UI/ViewLocator.cs @@ -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; + } +} \ No newline at end of file diff --git a/speedLight/speedLight.UI/ViewModels/MainWindowViewModel.cs b/speedLight/speedLight.UI/ViewModels/MainWindowViewModel.cs new file mode 100644 index 0000000..6ef1ba2 --- /dev/null +++ b/speedLight/speedLight.UI/ViewModels/MainWindowViewModel.cs @@ -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 ImageFromWebsite { get; set; } +} \ No newline at end of file diff --git a/speedLight/speedLight.UI/ViewModels/ViewModelBase.cs b/speedLight/speedLight.UI/ViewModels/ViewModelBase.cs new file mode 100644 index 0000000..3f46fd1 --- /dev/null +++ b/speedLight/speedLight.UI/ViewModels/ViewModelBase.cs @@ -0,0 +1,7 @@ +using ReactiveUI; + +namespace speedLight.UI.ViewModels; + +public class ViewModelBase : ReactiveObject +{ +} \ No newline at end of file diff --git a/speedLight/speedLight.UI/Views/MainWindow.axaml b/speedLight/speedLight.UI/Views/MainWindow.axaml new file mode 100644 index 0000000..13a64d1 --- /dev/null +++ b/speedLight/speedLight.UI/Views/MainWindow.axaml @@ -0,0 +1,40 @@ + + + + + + + + + + Скорость + + Сценарий + + + + \ No newline at end of file diff --git a/speedLight/speedLight.UI/Views/MainWindow.axaml.cs b/speedLight/speedLight.UI/Views/MainWindow.axaml.cs new file mode 100644 index 0000000..5a098ad --- /dev/null +++ b/speedLight/speedLight.UI/Views/MainWindow.axaml.cs @@ -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) + { + + } +} \ No newline at end of file diff --git a/speedLight/speedLight.UI/app.manifest b/speedLight/speedLight.UI/app.manifest new file mode 100644 index 0000000..31900c3 --- /dev/null +++ b/speedLight/speedLight.UI/app.manifest @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + diff --git a/speedLight/speedLight.UI/speedLight.UI.csproj b/speedLight/speedLight.UI/speedLight.UI.csproj new file mode 100644 index 0000000..ae3cb92 --- /dev/null +++ b/speedLight/speedLight.UI/speedLight.UI.csproj @@ -0,0 +1,25 @@ + + + WinExe + net6.0 + enable + true + app.manifest + true + + + + + + + + + + + + + + + + +