-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
195 additions
and
500 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
422 changes: 59 additions & 363 deletions
422
src/Shared/HandyControlDemo_Shared/UserControl/Tools/EffectsDemoCtl.xaml
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 0 additions & 61 deletions
61
src/Shared/HandyControl_Shared/Media/Effects/BlendEffect.cs
This file was deleted.
Oops, something went wrong.
116 changes: 116 additions & 0 deletions
116
src/Shared/HandyControl_Shared/Media/Effects/BlendEffectBox.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
using System.Collections.ObjectModel; | ||
using System.Collections.Specialized; | ||
using System.ComponentModel; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Data; | ||
using System.Windows.Markup; | ||
using System.Windows.Media.Effects; | ||
|
||
namespace HandyControl.Media.Effects | ||
{ | ||
[DefaultProperty("Content")] | ||
[ContentProperty("Content")] | ||
public class BlendEffectBox : Control | ||
{ | ||
private readonly ContentPresenter _effectBottomPresenter; | ||
|
||
private readonly ContentPresenter _effectTopPresenter; | ||
|
||
private bool _isInternalAction; | ||
|
||
public BlendEffectBox() | ||
{ | ||
_effectTopPresenter = new ContentPresenter(); | ||
ActualContent = _effectTopPresenter; | ||
|
||
_effectBottomPresenter = new ContentPresenter(); | ||
_effectBottomPresenter.SetBinding(ContentPresenter.ContentProperty, new Binding(ContentProperty.Name) | ||
{ | ||
Source = this | ||
}); | ||
|
||
var effects = new ObservableCollection<Effect>(); | ||
effects.CollectionChanged += OnEffectsChanged; | ||
Effects = effects; | ||
} | ||
|
||
private void OnEffectsChanged(object sender, NotifyCollectionChangedEventArgs e) | ||
{ | ||
if (Effects == null || Effects.Count == 0) | ||
{ | ||
ClearEffect(_effectTopPresenter); | ||
return; | ||
} | ||
|
||
if (_isInternalAction) return; | ||
|
||
_isInternalAction = true; | ||
AddEffect(_effectTopPresenter, Effects.Count); | ||
_isInternalAction = false; | ||
} | ||
|
||
private void ClearEffect(ContentPresenter presenter) | ||
{ | ||
if (presenter == null) return; | ||
|
||
if (ReferenceEquals(_effectBottomPresenter, presenter)) | ||
{ | ||
_effectBottomPresenter.SetCurrentValue(EffectProperty, null); | ||
return; | ||
} | ||
|
||
presenter.SetCurrentValue(EffectProperty, null); | ||
ClearEffect(presenter.Content as ContentPresenter); | ||
} | ||
|
||
private void AddEffect(ContentPresenter presenter, int count) | ||
{ | ||
var newCount = --count; | ||
|
||
if (newCount >= 0) | ||
{ | ||
presenter.Effect = Effects[newCount]; | ||
|
||
var nextCount = --count; | ||
if (nextCount >= 1) | ||
{ | ||
var content = new ContentPresenter(); | ||
presenter.Content = content; | ||
AddEffect(content, newCount); | ||
} | ||
else if (nextCount >= 0) | ||
{ | ||
_effectBottomPresenter.Effect = Effects[0]; | ||
presenter.Content = _effectBottomPresenter; | ||
} | ||
else | ||
{ | ||
presenter.Content = _effectBottomPresenter; | ||
} | ||
} | ||
} | ||
|
||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] | ||
[Bindable(true)] | ||
public Collection<Effect> Effects { get; } | ||
|
||
public static readonly DependencyProperty ContentProperty = DependencyProperty.Register( | ||
"Content", typeof(FrameworkElement), typeof(BlendEffectBox), new PropertyMetadata(default(FrameworkElement))); | ||
|
||
public FrameworkElement Content | ||
{ | ||
get => (FrameworkElement)GetValue(ContentProperty); | ||
set => SetValue(ContentProperty, value); | ||
} | ||
|
||
internal static readonly DependencyProperty ActualContentProperty = DependencyProperty.Register( | ||
"ActualContent", typeof(FrameworkElement), typeof(BlendEffectBox), new PropertyMetadata(default(FrameworkElement))); | ||
|
||
internal FrameworkElement ActualContent | ||
{ | ||
get => (FrameworkElement) GetValue(ActualContentProperty); | ||
set => SetValue(ActualContentProperty, value); | ||
} | ||
} | ||
} |
32 changes: 0 additions & 32 deletions
32
src/Shared/HandyControl_Shared/Media/Effects/BlendEffectMode.cs
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
src/Shared/HandyControl_Shared/Resources/Effects/MultiplyBlendEffect.fx
This file was deleted.
Oops, something went wrong.
Binary file removed
BIN
-420 Bytes
src/Shared/HandyControl_Shared/Resources/Effects/MultiplyBlendEffect.ps
Binary file not shown.
14 changes: 14 additions & 0 deletions
14
src/Shared/HandyControl_Shared/Themes/Styles/BlendEffectBox.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:effects="clr-namespace:HandyControl.Media.Effects"> | ||
|
||
<Style TargetType="effects:BlendEffectBox"> | ||
<Setter Property="Template"> | ||
<Setter.Value> | ||
<ControlTemplate TargetType="effects:BlendEffectBox"> | ||
<ContentPresenter ContentSource="ActualContent"/> | ||
</ControlTemplate> | ||
</Setter.Value> | ||
</Setter> | ||
</Style> | ||
|
||
</ResourceDictionary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters