diff --git a/sources/editor/Stride.Core.Assets.Editor.Avalonia/ITemplateDescriptionViewModel.cs b/sources/editor/Stride.Core.Assets.Editor.Avalonia/ITemplateDescriptionViewModel.cs new file mode 100644 index 0000000000..887a5a2a71 --- /dev/null +++ b/sources/editor/Stride.Core.Assets.Editor.Avalonia/ITemplateDescriptionViewModel.cs @@ -0,0 +1,30 @@ +// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp) +// Distributed under the MIT license. See the LICENSE.md file in the project root for more information. +using System; +using System.Collections.Generic; +using Avalonia.Media.Imaging; +using Stride.Core.Assets.Templates; + +namespace Stride.Core.Assets.Editor.Components.TemplateDescriptions.ViewModels +{ + public interface ITemplateDescriptionViewModel + { + string Name { get; } + + string Description { get; } + + string FullDescription { get; } + + string Group { get; } + + Guid Id { get; } + + string DefaultOutputName { get; } + + Bitmap Icon { get; } + + IEnumerable Screenshots { get; } + + TemplateDescription GetTemplate(); + } +} diff --git a/sources/editor/Stride.Core.Assets.Editor.Avalonia/NewOrOpenSessionTemplateCollectionViewModel.cs b/sources/editor/Stride.Core.Assets.Editor.Avalonia/NewOrOpenSessionTemplateCollectionViewModel.cs new file mode 100644 index 0000000000..11ed5cf643 --- /dev/null +++ b/sources/editor/Stride.Core.Assets.Editor.Avalonia/NewOrOpenSessionTemplateCollectionViewModel.cs @@ -0,0 +1,30 @@ +using Stride.Core.Assets.Editor.Services; +using Stride.Core.Presentation.Commands; +using Stride.Core.Presentation.Services; +using Stride.Core.Presentation.ViewModels; + +namespace Stride.Core.Assets.Editor.Avalonia; + +public class NewOrOpenSessionTemplateCollectionViewModel +{ + private readonly IModalDialog dialog; + private readonly IViewModelServiceProvider serviceProvider; + public NewOrOpenSessionTemplateCollectionViewModel(IViewModelServiceProvider serviceProvider) + { + this.serviceProvider = serviceProvider; + BrowseForExistingProjectCommand = new AnonymousTaskCommand(serviceProvider, BrowseForExistingProject); + } + public ICommandBase BrowseForExistingProjectCommand { get; } + public bool AutoReloadSession { get; } + + private async Task BrowseForExistingProject() + { + var filePath = await EditorDialogHelper.BrowseForExistingProject(serviceProvider); + if (filePath != null) + { + //SelectedTemplate = new ExistingProjectViewModel(ServiceProvider, filePath, RemoveExistingProjects); + dialog?.RequestClose(DialogResult.Ok); + } + } + +} diff --git a/sources/editor/Stride.Core.Assets.Editor.Avalonia/ObjectBrowserUserControl.axaml b/sources/editor/Stride.Core.Assets.Editor.Avalonia/ObjectBrowserUserControl.axaml new file mode 100644 index 0000000000..cac55ab99a --- /dev/null +++ b/sources/editor/Stride.Core.Assets.Editor.Avalonia/ObjectBrowserUserControl.axaml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + diff --git a/sources/editor/Stride.Core.Assets.Editor.Avalonia/ObjectBrowserUserControl.axaml.cs b/sources/editor/Stride.Core.Assets.Editor.Avalonia/ObjectBrowserUserControl.axaml.cs new file mode 100644 index 0000000000..ded4cea6e8 --- /dev/null +++ b/sources/editor/Stride.Core.Assets.Editor.Avalonia/ObjectBrowserUserControl.axaml.cs @@ -0,0 +1,123 @@ +// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) +// Distributed under the MIT license. See the LICENSE.md file in the project root for more information. + +using System.Collections; +using Avalonia; +using Avalonia.Controls; +using Avalonia.Controls.Templates; +using Avalonia.Styling; + +namespace Stride.Core.Assets.Editor.Avalonia; + +public partial class ObjectBrowserUserControl : UserControl +{ + public static readonly StyledProperty HierarchyItemsSourceProperty = + AvaloniaProperty.Register(nameof(HierarchyItemsSource)); + + public static readonly StyledProperty SelectedHierarchyItemProperty = + AvaloniaProperty.Register(nameof(SelectedHierarchyItem)); + + public static readonly StyledProperty HierarchyItemTemplateProperty = + AvaloniaProperty.Register(nameof(HierarchyItemTemplate)); + + public static readonly StyledProperty HierarchyItemContainerStyleProperty = + AvaloniaProperty.Register(nameof(HierarchyItemContainerStyle)); + + public static readonly StyledProperty ObjectItemsSourceProperty = + AvaloniaProperty.Register(nameof(ObjectItemsSource)); + + public static readonly StyledProperty SelectedObjectItemProperty = + AvaloniaProperty.Register(nameof(SelectedObjectItem)); + + public static readonly StyledProperty ObjectItemTemplateProperty = + AvaloniaProperty.Register(nameof(ObjectItemTemplate)); + + public static readonly StyledProperty ObjectItemTemplateSelectorProperty = + AvaloniaProperty.Register(nameof(ObjectItemTemplateSelector)); + + public static readonly StyledProperty ObjectItemContainerStyleProperty = + AvaloniaProperty.Register(nameof(ObjectItemContainerStyle)); + + public static readonly StyledProperty ObjectDescriptionTemplateProperty = + AvaloniaProperty.Register(nameof(ObjectDescriptionTemplate)); + + public static readonly StyledProperty ObjectDescriptionTemplateSelectorProperty = + AvaloniaProperty.Register(nameof(ObjectDescriptionTemplateSelector)); + + public ObjectBrowserUserControl() + { + InitializeComponent(); + } + + public IEnumerable HierarchyItemsSource + { + get => GetValue(HierarchyItemsSourceProperty); + set => SetValue(HierarchyItemsSourceProperty, value); + } + + public object SelectedHierarchyItem + { + get => GetValue(SelectedHierarchyItemProperty); + set => SetValue(SelectedHierarchyItemProperty, value); + } + + public IDataTemplate HierarchyItemTemplate + { + get => GetValue(HierarchyItemTemplateProperty); + set => SetValue(HierarchyItemTemplateProperty, value); + } + + public IStyle HierarchyItemContainerStyle + { + get => GetValue(HierarchyItemContainerStyleProperty); + set => SetValue(HierarchyItemContainerStyleProperty, value); + } + + public IEnumerable ObjectItemsSource + { + get => GetValue(ObjectItemsSourceProperty); + set => SetValue(ObjectItemsSourceProperty, value); + } + + public object SelectedObjectItem + { + get => GetValue(SelectedObjectItemProperty); + set => SetValue(SelectedObjectItemProperty, value); + } + + public IDataTemplate ObjectItemTemplate + { + get => GetValue(ObjectItemTemplateProperty); + set => SetValue(ObjectItemTemplateProperty, value); + } + + public IDataTemplate ObjectItemTemplateSelector + { + get => GetValue(ObjectItemTemplateSelectorProperty); + set => SetValue(ObjectItemTemplateSelectorProperty, value); + } + + public IStyle ObjectItemContainerStyle + { + get => GetValue(ObjectItemContainerStyleProperty); + set => SetValue(ObjectItemContainerStyleProperty, value); + } + + public IDataTemplate ObjectDescriptionTemplate + { + get => GetValue(ObjectDescriptionTemplateProperty); + set => SetValue(ObjectDescriptionTemplateProperty, value); + } + + public IDataTemplate ObjectDescriptionTemplateSelector + { + get => GetValue(ObjectDescriptionTemplateSelectorProperty); + set => SetValue(ObjectDescriptionTemplateSelectorProperty, value); + } + + // If you have a scroll viewer in your .axaml file: + private void OnSelectedObjectItemChanged() + { + // ScrollViewer?.ScrollToTop(); // Placeholder: hook up actual ScrollViewer reference + } +} diff --git a/sources/editor/Stride.Core.Assets.Editor.Avalonia/ProjectSelectionWindow.axaml b/sources/editor/Stride.Core.Assets.Editor.Avalonia/ProjectSelectionWindow.axaml new file mode 100644 index 0000000000..7eeb354ed4 --- /dev/null +++ b/sources/editor/Stride.Core.Assets.Editor.Avalonia/ProjectSelectionWindow.axaml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + +