Skip to content

Commit

Permalink
Fixed issue with particle gradient editor not updating when a preset …
Browse files Browse the repository at this point in the history
…was applied.
  • Loading branch information
Wibble199 committed Apr 24, 2020
1 parent b6f4c60 commit 1e779b9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Project-Aurora/Project-Aurora/Project-Aurora.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2292,6 +2292,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Settings\Layers\Control_ParticleLayer.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Settings\Layers\Control_RazerLayer.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ public Control_ParticleLayer(SimpleParticleLayerHandler context) {
presetsCombo.ItemsSource = ParticleLayerPresets.Presets.Select(kvp => new { Text = kvp.Key, ApplyFunc = kvp.Value });
}

private void UserControl_Loaded(object sender, RoutedEventArgs e) {
// Create a temporary Media brush from the particle's color stops
private void UserControl_Loaded(object sender, RoutedEventArgs e) => ApplyGradientToEditor();

private void ApplyGradientToEditor() {
// Note that I tried using a binding instead of this but since it'd need a IValueConverter which would have to create a new brush and
// the _values_ on that brush change not the brush itself, the binding was not actually being triggered.
gradientEditor.Brush = handler.Properties._ParticleColorStops.Count == 1
? (Brush)new SolidColorBrush(handler.Properties._ParticleColorStops.First().color.ToMediaColor())
: new LinearGradientBrush(new GradientStopCollection(handler.Properties._ParticleColorStops.Select(t => new GradientStop(t.color.ToMediaColor(), t.offset))));
Expand All @@ -43,6 +46,7 @@ private void ApplyButton_Click(object sender, RoutedEventArgs e) {
if (presetsCombo.SelectedValue is Action<SimpleParticleLayerProperties> apply && MessageBox.Show("Do you wish to apply this preset? Your current configuration will be overwritten.", "Apply Preset", MessageBoxButton.YesNo) == MessageBoxResult.Yes) {
handler.Properties.Default();
apply(handler.Properties);
ApplyGradientToEditor(); // Manually update the gradient editor since this can't be handled by bindings
}
}
}
Expand Down

0 comments on commit 1e779b9

Please sign in to comment.