Sidebar - Made sidebar resizable (to an extend)

Sidebar - Truncate long profile names
Profile editor - Added shift+click on eye-icon in profile tree to focus an element
Profile editor - Fixed layer property prefix/affix vertical alignment
UI - Made shutdown via tray more responsive
UI - Fixed several memory leaks
This commit is contained in:
Robert committed 2021-06-08 18:18:27 +02:00
1 parent bab566a2b9
commit 6087a45a18
26 files changed
+298 -147

No files matched your search

@@ -53,7 +53,6 @@ namespace Artemis.UI.Shared
// Run an update timer at 25 fps
_timer = new Timer(40);
_timer.Elapsed += TimerOnTick;
MouseLeftButtonUp += OnMouseLeftButtonUp;
Loaded += OnLoaded;
@@ -158,7 +157,8 @@ namespace Artemis.UI.Shared
/// </param>
protected virtual void Dispose(bool disposing)
{
if (disposing) _timer.Stop();
if (disposing)
_timer.Dispose();
}
@@ -191,6 +191,7 @@ namespace Artemis.UI.Shared
private void OnUnloaded(object? sender, RoutedEventArgs e)
{
_timer.Stop();
_timer.Elapsed -= TimerOnTick;
if (_oldDevice != null)
{
@@ -222,6 +223,7 @@ namespace Artemis.UI.Shared
private void OnLoaded(object? sender, RoutedEventArgs e)
{
_timer.Start();
_timer.Elapsed += TimerOnTick;
}
private void TimerOnTick(object? sender, EventArgs e)
@@ -11,6 +11,7 @@
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<shared:StreamToBitmapImageConverter x:Key="StreamToBitmapImageConverter" />
<shared:StreamToSvgImageConverter x:Key="StreamToSvgImageConverter" />
</UserControl.Resources>
<ContentControl>
<ContentControl.Style>
@@ -47,10 +48,11 @@
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<svgc:SvgViewbox StreamSource="{Binding ConfigurationIcon.FileIcon, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"
RenderOptions.BitmapScalingMode="HighQuality"
Width="Auto"
Height="Auto" />
<Image
Source="{Binding ConfigurationIcon.FileIcon, Converter={StaticResource StreamToSvgImageConverter}, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"
RenderOptions.BitmapScalingMode="HighQuality"
Width="Auto"
Height="Auto" />
</DataTemplate>
</Setter.Value>
</Setter>
@@ -8,7 +8,7 @@ namespace Artemis.UI.Shared
{
/// <inheritdoc />
/// <summary>
/// Converts <see cref="T:Stream" /> into <see cref="T:BitmapImage" />.
/// Converts bitmap file in the form of a <see cref="T:Stream" /> into <see cref="T:BitmapImage" />.
/// </summary>
[ValueConversion(typeof(Stream), typeof(BitmapImage))]
public class StreamToBitmapImageConverter : IValueConverter
@@ -16,7 +16,7 @@ namespace Artemis.UI.Shared
/// <inheritdoc />
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is not Stream stream)
if (value is not Stream stream)
return null;
stream.Position = 0;
@@ -0,0 +1,48 @@
using System;
using System.Globalization;
using System.IO;
using System.Windows.Data;
using System.Windows.Media.Imaging;
using SharpVectors.Converters;
using SharpVectors.Renderers.Wpf;
namespace Artemis.UI.Shared
{
/// <inheritdoc />
/// <summary>
/// Converts SVG file in the form of a <see cref="T:Stream" /> into <see cref="T:BitmapImage" />.
/// </summary>
[ValueConversion(typeof(Stream), typeof(BitmapImage))]
public class StreamToSvgImageConverter : IValueConverter
{
/// <inheritdoc />
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is not Stream stream)
return null;
stream.Position = 0;
StreamSvgConverter converter = new(new WpfDrawingSettings());
using MemoryStream imageStream = new();
converter.Convert(stream, imageStream);
BitmapImage selectedBitmap = new();
selectedBitmap.BeginInit();
selectedBitmap.StreamSource = imageStream;
selectedBitmap.CacheOption = BitmapCacheOption.OnLoad;
selectedBitmap.EndInit();
selectedBitmap.Freeze();
stream.Position = 0;
return selectedBitmap;
}
/// <inheritdoc />
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return Binding.DoNothing;
}
}
}