mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-12 21:38:38 +00:00
Fix auto connecting nodes
This commit is contained in:
parent
73933ee324
commit
88558efcb1
@ -45,7 +45,7 @@ public class DeviceVisualizer : Control
|
||||
/// <inheritdoc />
|
||||
public override void Render(DrawingContext drawingContext)
|
||||
{
|
||||
if (Device == null || _deviceBounds.Width == 0 || _deviceBounds.Height == 0)
|
||||
if (Device == null || _deviceBounds.Width == 0 || _deviceBounds.Height == 0 || _loading)
|
||||
return;
|
||||
|
||||
// Determine the scale required to fit the desired size of the control
|
||||
@ -208,6 +208,8 @@ public class DeviceVisualizer : Control
|
||||
public static readonly StyledProperty<ObservableCollection<ArtemisLed>?> HighlightedLedsProperty =
|
||||
AvaloniaProperty.Register<DeviceVisualizer, ObservableCollection<ArtemisLed>?>(nameof(HighlightedLeds));
|
||||
|
||||
private bool _loading;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a list of LEDs to highlight
|
||||
/// </summary>
|
||||
@ -273,6 +275,7 @@ public class DeviceVisualizer : Control
|
||||
return;
|
||||
|
||||
_deviceBounds = MeasureDevice();
|
||||
_loading = true;
|
||||
|
||||
Device.RgbDevice.PropertyChanged += DevicePropertyChanged;
|
||||
Device.DeviceUpdated += DeviceUpdated;
|
||||
@ -288,15 +291,15 @@ public class DeviceVisualizer : Control
|
||||
ArtemisDevice? device = Device;
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
{
|
||||
if (device.Layout?.Image == null || !File.Exists(device.Layout.Image.LocalPath))
|
||||
{
|
||||
_deviceImage?.Dispose();
|
||||
_deviceImage = null;
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (device.Layout?.Image == null || !File.Exists(device.Layout.Image.LocalPath))
|
||||
{
|
||||
_deviceImage?.Dispose();
|
||||
_deviceImage = null;
|
||||
return;
|
||||
}
|
||||
|
||||
// Create a bitmap that'll be used to render the device and LED images just once
|
||||
// Render 4 times the actual size of the device to make sure things look sharp when zoomed in
|
||||
RenderTargetBitmap renderTargetBitmap = new(new PixelSize((int) device.RgbDevice.ActualSize.Width * 2, (int) device.RgbDevice.ActualSize.Height * 2));
|
||||
@ -314,12 +317,16 @@ public class DeviceVisualizer : Control
|
||||
_deviceImage?.Dispose();
|
||||
_deviceImage = renderTargetBitmap;
|
||||
|
||||
Dispatcher.UIThread.Post(InvalidateMeasure);
|
||||
InvalidateMeasure();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
finally
|
||||
{
|
||||
_loading = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -156,7 +156,21 @@
|
||||
<TextBlock Grid.Row="0" Classes="h5 no-margin">Release notes</TextBlock>
|
||||
<Separator Grid.Row="1" Classes="card-separator" />
|
||||
|
||||
<avalonia:MarkdownScrollViewer Grid.Row="2" Markdown="{CompiledBinding Changelog}" MarkdownStyleName="FluentAvalonia"/>
|
||||
<avalonia:MarkdownScrollViewer Grid.Row="2" Markdown="{CompiledBinding Changelog}" MarkdownStyleName="FluentAvalonia">
|
||||
<avalonia:MarkdownScrollViewer.Styles>
|
||||
<Style Selector="ctxt|CHyperlink">
|
||||
<Setter Property="Foreground" Value="{DynamicResource SystemAccentColorLight3}" />
|
||||
</Style>
|
||||
<Style Selector="ctxt|CHyperlink:pointerover">
|
||||
<Setter Property="Foreground" Value="{DynamicResource SystemAccentColorLight1}" />
|
||||
</Style>
|
||||
<Style Selector="Grid.List">
|
||||
<Style.Setters>
|
||||
<Setter Property="Margin" Value="20,0,0,0"/>
|
||||
</Style.Setters>
|
||||
</Style>
|
||||
</avalonia:MarkdownScrollViewer.Styles>
|
||||
</avalonia:MarkdownScrollViewer>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
@ -50,7 +50,6 @@ public class NodePickerViewModel : ActivatableViewModelBase
|
||||
this.WhenActivated(d =>
|
||||
{
|
||||
SearchText = null;
|
||||
TargetPin = null;
|
||||
|
||||
nodeSourceList.Edit(list =>
|
||||
{
|
||||
@ -59,7 +58,11 @@ public class NodePickerViewModel : ActivatableViewModelBase
|
||||
});
|
||||
|
||||
IsVisible = true;
|
||||
Disposable.Create(() => IsVisible = false).DisposeWith(d);
|
||||
Disposable.Create(() =>
|
||||
{
|
||||
IsVisible = false;
|
||||
TargetPin = null;
|
||||
}).DisposeWith(d);
|
||||
});
|
||||
}
|
||||
|
||||
@ -102,6 +105,7 @@ public class NodePickerViewModel : ActivatableViewModelBase
|
||||
node.Y = Math.Round(Position.Y / 10d, 0, MidpointRounding.AwayFromZero) * 10d;
|
||||
|
||||
if (TargetPin != null)
|
||||
{
|
||||
using (_nodeEditorService.CreateCommandScope(_nodeScript, "Create node for pin"))
|
||||
{
|
||||
_nodeEditorService.ExecuteCommand(_nodeScript, new AddNode(_nodeScript, node));
|
||||
@ -114,6 +118,7 @@ public class NodePickerViewModel : ActivatableViewModelBase
|
||||
if (source != null)
|
||||
_nodeEditorService.ExecuteCommand(_nodeScript, new ConnectPins(source, TargetPin));
|
||||
}
|
||||
}
|
||||
else
|
||||
_nodeEditorService.ExecuteCommand(_nodeScript, new AddNode(_nodeScript, node));
|
||||
}
|
||||
|
||||
@ -44,12 +44,10 @@
|
||||
</Border>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
<DataTemplate DataType="core:Numeric">
|
||||
<TextBlock Text="{Binding}" FontFamily="Consolas"/>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate DataType="system:Object">
|
||||
<TextBlock Text="{Binding Converter={StaticResource JsonConverter}}" FontFamily="Consolas"/>
|
||||
<Border Classes="card-condensed" Margin="0,5,5,5 ">
|
||||
<TextBlock Text="{Binding Converter={StaticResource JsonConverter}}" FontFamily="Consolas"/>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</ContentControl.DataTemplates>
|
||||
</ContentControl>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user