mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Editor - Added message when profile failed to load
Editor - Implemented creating elements inside folders
This commit is contained in:
parent
aa8667544f
commit
68cd8287a6
@ -6,31 +6,34 @@
|
||||
x:Class="Artemis.UI.Shared.Services.ExceptionDialogView"
|
||||
Title="{Binding Title}"
|
||||
ExtendClientAreaToDecorationsHint="True"
|
||||
Width="800"
|
||||
Width="800"
|
||||
Height="800"
|
||||
WindowStartupLocation="CenterOwner">
|
||||
<Grid>
|
||||
<TextBlock Margin="10" IsHitTestVisible="False" Text="{Binding Title}" />
|
||||
<Grid Margin="0 32 0 0" ColumnDefinitions="*,Auto" RowDefinitions="*,Auto">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Margin="10" Grid.Row="1" IsHitTestVisible="False" Text="{Binding Title}" />
|
||||
|
||||
<Border Classes="card" Grid.Row="0" Grid.ColumnSpan="2" Margin="10">
|
||||
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Margin="0 5">
|
||||
<Grid RowDefinitions="Auto,Auto,*">
|
||||
<TextBlock Grid.Row="0" Classes="h3">Awww :(</TextBlock>
|
||||
<TextBlock Grid.Row="1">
|
||||
It looks like Artemis ran into an unhandled exception. If this keeps happening feel free to hit us up on Discord.
|
||||
</TextBlock>
|
||||
<StackPanel Grid.Row="2" Margin="20">
|
||||
<TextBlock Classes="h3">Awww :(</TextBlock>
|
||||
<TextBlock>
|
||||
It looks like Artemis ran into an unhandled exception. If this keeps happening feel free to hit us up on Discord.
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
|
||||
<TextBox Grid.Row="2" Text="{Binding Exception, Mode=OneTime}"
|
||||
Margin="0 10"
|
||||
AcceptsReturn="True"
|
||||
IsReadOnly="True"
|
||||
FontFamily="Consolas"
|
||||
FontSize="12"
|
||||
BorderThickness="0" />
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
</Border>
|
||||
<Grid Grid.Row="3" ColumnDefinitions="*,Auto" RowDefinitions="*,Auto">
|
||||
<ScrollViewer Grid.Row="0" Grid.ColumnSpan="2" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Margin="20 0">
|
||||
<TextBox Text="{Binding Exception, Mode=OneTime}"
|
||||
AcceptsReturn="True"
|
||||
IsReadOnly="True"
|
||||
FontFamily="Consolas"
|
||||
FontSize="12"
|
||||
BorderThickness="0" />
|
||||
</ScrollViewer>
|
||||
|
||||
<TextBlock Grid.Row="1" Grid.Column="0" TextWrapping="Wrap" Margin="15" VerticalAlignment="Center">
|
||||
When reporting errors please don't take a screenshot of the error, instead copy the text, thanks!
|
||||
|
||||
@ -31,7 +31,7 @@ namespace Artemis.UI.Shared.Services
|
||||
_notificationService.CreateNotification()
|
||||
.WithMessage("Copied stack trace to clipboard.")
|
||||
.WithSeverity(NotificationSeverity.Success)
|
||||
.WithHorizontalPosition(HorizontalAlignment.Center)
|
||||
.WithHorizontalPosition(HorizontalAlignment.Left)
|
||||
.Show();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,13 +1,17 @@
|
||||
using Artemis.Core.Ninject;
|
||||
using System;
|
||||
using System.Reactive;
|
||||
using Artemis.Core.Ninject;
|
||||
using Artemis.Core;
|
||||
using Artemis.UI.Exceptions;
|
||||
using Artemis.UI.Ninject;
|
||||
using Artemis.UI.Screens.Root;
|
||||
using Artemis.UI.Shared.Ninject;
|
||||
using Artemis.UI.Shared.Services.Interfaces;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
using Ninject;
|
||||
using ReactiveUI;
|
||||
using Splat.Ninject;
|
||||
|
||||
namespace Artemis.UI
|
||||
@ -23,7 +27,7 @@ namespace Artemis.UI
|
||||
throw new ArtemisUIException("UI already bootstrapped");
|
||||
|
||||
Utilities.PrepareFirstLaunch();
|
||||
|
||||
|
||||
_application = application;
|
||||
_kernel = new StandardKernel();
|
||||
_kernel.Settings.InjectNonPublic = true;
|
||||
@ -42,7 +46,7 @@ namespace Artemis.UI
|
||||
if (_application == null || _kernel == null)
|
||||
throw new ArtemisUIException("UI not yet bootstrapped");
|
||||
if (_application.ApplicationLifetime is not IClassicDesktopStyleApplicationLifetime desktop)
|
||||
return;
|
||||
return;
|
||||
|
||||
// Don't shut down when the last window closes, we might still be active in the tray
|
||||
desktop.ShutdownMode = ShutdownMode.OnExplicitShutdown;
|
||||
@ -50,6 +54,13 @@ namespace Artemis.UI
|
||||
RootViewModel rootViewModel = _kernel.Get<RootViewModel>();
|
||||
// Apply the root view model to the data context of the application so that tray icon commands work
|
||||
_application.DataContext = rootViewModel;
|
||||
|
||||
RxApp.DefaultExceptionHandler = Observer.Create<Exception>(DisplayUnhandledException);
|
||||
}
|
||||
|
||||
private static void DisplayUnhandledException(Exception exception)
|
||||
{
|
||||
_kernel?.Get<IWindowService>().ShowExceptionDialog("Exception", exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -21,7 +21,49 @@
|
||||
</TreeView.KeyBindings>
|
||||
<TreeView.ItemTemplate>
|
||||
<TreeDataTemplate ItemsSource="{Binding Children}">
|
||||
<ContentControl Content="{Binding}" />
|
||||
<ContentControl Content="{Binding}">
|
||||
<ContentControl.ContextFlyout>
|
||||
<MenuFlyout>
|
||||
<MenuItem Header="Add new folder" Command="{Binding AddFolder}">
|
||||
<MenuItem.Icon>
|
||||
<avalonia:MaterialIcon Kind="CreateNewFolder" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Add new layer" Command="{Binding AddLayer}">
|
||||
<MenuItem.Icon>
|
||||
<avalonia:MaterialIcon Kind="LayersPlus" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<Separator />
|
||||
<MenuItem Header="Duplicate" Command="{Binding DuplicateElement}" InputGesture="Ctrl+D" IsEnabled="False">
|
||||
<MenuItem.Icon>
|
||||
<avalonia:MaterialIcon Kind="ContentDuplicate" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Copy" Command="{Binding CopyElement}" InputGesture="Ctrl+C" IsEnabled="False">
|
||||
<MenuItem.Icon>
|
||||
<avalonia:MaterialIcon Kind="ContentCopy" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Paste" Command="{Binding PasteElement}" InputGesture="Ctrl+V">
|
||||
<MenuItem.Icon>
|
||||
<avalonia:MaterialIcon Kind="ContentPaste" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<Separator />
|
||||
<MenuItem Header="Rename" Command="{Binding RenameElement}" InputGesture="F2" IsEnabled="False">
|
||||
<MenuItem.Icon>
|
||||
<avalonia:MaterialIcon Kind="RenameBox" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Delete" Command="{Binding DeleteElement}" InputGesture="Delete" IsEnabled="False">
|
||||
<MenuItem.Icon>
|
||||
<avalonia:MaterialIcon Kind="TrashCan" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
</MenuFlyout>
|
||||
</ContentControl.ContextFlyout>
|
||||
</ContentControl>
|
||||
</TreeDataTemplate>
|
||||
</TreeView.ItemTemplate>
|
||||
</TreeView>
|
||||
|
||||
@ -22,12 +22,18 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree
|
||||
{
|
||||
profileEditorService.ProfileConfiguration.WhereNotNull().Subscribe(configuration =>
|
||||
{
|
||||
ProfileElement = configuration.Profile!.GetRootFolder();
|
||||
if (configuration.Profile == null)
|
||||
{
|
||||
windowService.ShowConfirmContentDialog("Failed to load profile", "It appears that this profile is corrupt and cannot be loaded. Please check your logs.", "Confirm", null);
|
||||
return;
|
||||
}
|
||||
|
||||
ProfileElement = configuration.Profile.GetRootFolder();
|
||||
SubscribeToProfileElement(d);
|
||||
CreateTreeItems();
|
||||
}).DisposeWith(d);
|
||||
|
||||
profileEditorService.ProfileElement.WhereNotNull().Subscribe(SelectCurrentProfileElement).DisposeWith(d);
|
||||
profileEditorService.ProfileElement.Subscribe(SelectCurrentProfileElement).DisposeWith(d);
|
||||
});
|
||||
|
||||
this.WhenAnyValue(vm => vm.SelectedChild).Subscribe(model =>
|
||||
@ -43,7 +49,7 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree
|
||||
set => this.RaiseAndSetIfChanged(ref _selectedChild, value);
|
||||
}
|
||||
|
||||
private void SelectCurrentProfileElement(RenderProfileElement element)
|
||||
private void SelectCurrentProfileElement(RenderProfileElement? element)
|
||||
{
|
||||
if (SelectedChild?.ProfileElement == element)
|
||||
return;
|
||||
|
||||
@ -20,13 +20,16 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree
|
||||
{
|
||||
private readonly IProfileEditorVmFactory _profileEditorVmFactory;
|
||||
private readonly IWindowService _windowService;
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private bool _isExpanded;
|
||||
private ProfileElement? _profileElement;
|
||||
private RenderProfileElement? _currentProfileElement;
|
||||
|
||||
protected TreeItemViewModel(TreeItemViewModel? parent, ProfileElement? profileElement, IWindowService windowService, IProfileEditorService profileEditorService,
|
||||
IProfileEditorVmFactory profileEditorVmFactory)
|
||||
{
|
||||
_windowService = windowService;
|
||||
_profileEditorService = profileEditorService;
|
||||
_profileEditorVmFactory = profileEditorVmFactory;
|
||||
|
||||
Parent = parent;
|
||||
@ -50,6 +53,7 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree
|
||||
|
||||
this.WhenActivated(d =>
|
||||
{
|
||||
_profileEditorService.ProfileElement.Subscribe(element => _currentProfileElement = element).DisposeWith(d);
|
||||
SubscribeToProfileElement(d);
|
||||
CreateTreeItems();
|
||||
});
|
||||
@ -105,6 +109,10 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree
|
||||
List<TreeItemViewModel> toRemove = Children.Where(t => t.ProfileElement == profileElement).ToList();
|
||||
foreach (TreeItemViewModel treeItemViewModel in toRemove)
|
||||
Children.Remove(treeItemViewModel);
|
||||
|
||||
// Deselect the current profile element if removed
|
||||
if (_currentProfileElement == profileElement)
|
||||
_profileEditorService.ChangeCurrentProfileElement(null);
|
||||
}
|
||||
|
||||
protected void AddTreeItemIfMissing(ProfileElement profileElement)
|
||||
@ -116,6 +124,10 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree
|
||||
Children.Insert(folder.Parent.Children.IndexOf(folder), _profileEditorVmFactory.FolderTreeItemViewModel(this, folder));
|
||||
else if (profileElement is Layer layer)
|
||||
Children.Insert(layer.Parent.Children.IndexOf(layer), _profileEditorVmFactory.LayerTreeItemViewModel(this, layer));
|
||||
|
||||
// Select the newly added element
|
||||
if (profileElement is RenderProfileElement renderProfileElement)
|
||||
_profileEditorService.ChangeCurrentProfileElement(renderProfileElement);
|
||||
}
|
||||
|
||||
protected void CreateTreeItems()
|
||||
@ -127,10 +139,12 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree
|
||||
return;
|
||||
|
||||
foreach (ProfileElement profileElement in ProfileElement.Children)
|
||||
{
|
||||
if (profileElement is Folder folder)
|
||||
Children.Add(_profileEditorVmFactory.FolderTreeItemViewModel(this, folder));
|
||||
else if (profileElement is Layer layer)
|
||||
Children.Add(_profileEditorVmFactory.LayerTreeItemViewModel(this, layer));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -143,7 +143,16 @@ namespace Artemis.UI.Screens.Sidebar
|
||||
if (!await _windowService.ShowConfirmContentDialog("Delete profile", "Are you sure you want to permanently delete this profile?"))
|
||||
return;
|
||||
|
||||
_profileService.RemoveProfileConfiguration(_profileConfiguration);
|
||||
try
|
||||
{
|
||||
_profileService.RemoveProfileConfiguration(_profileConfiguration);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
throw;
|
||||
}
|
||||
|
||||
Close(true);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user