Skip to content

Commit

Permalink
Merge pull request #13 from TheEightBot/feature/image-processing
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelstonis authored Dec 4, 2024
2 parents 6166515 + ee5e377 commit 0483886
Show file tree
Hide file tree
Showing 21 changed files with 1,696 additions and 125 deletions.
6 changes: 3 additions & 3 deletions AuroraControls.TestApp/AuroraControls.TestApp.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0;net8.0-android;net8.0-ios;net8.0-maccatalyst</TargetFrameworks>
<TargetFrameworks>net8.0-android;net8.0-ios;net8.0-maccatalyst</TargetFrameworks>
<OutputType>Exe</OutputType>
<RootNamespace>AuroraControls.TestApp</RootNamespace>
<UseMaui>true</UseMaui>
Expand Down Expand Up @@ -52,7 +52,7 @@
<PackageReference Include="ReactiveUI.Fody" Version="19.5.41" />
<PackageReference Include="CommunityToolkit.Maui.Markup" Version="4.1.0" />
<PackageReference Include="CommunityToolkit.Maui" Version="9.0.3" />
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.90" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.90" />
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.90" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.90" />
</ItemGroup>
</Project>
25 changes: 25 additions & 0 deletions AuroraControls.TestApp/ImageProcessing.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:effects="clr-namespace:AuroraControls.Effects;assembly=AuroraControls"
x:Class="AuroraControls.TestApp.ImageProcessing">
<ContentPage.Content>
<StackLayout HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand">
<Button Text="Change Effects"
Clicked="Handle_Clicked" />
<Label Text="Blur Amount" />
<Slider Minimum="0"
Maximum="10"
ValueChanged="Handle_ValueChanged" />
<Image x:Name="image"
Source="https://api.floodmagazine.com/wp-content/uploads/2016/07/Steve_Brule-2016-Marc_Lemoine-2.png"
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand">
<Image.Effects>
<effects:ImageProcessingEffect x:Name="ImageProcessingEffect" />
</Image.Effects>
</Image>
</StackLayout>
</ContentPage.Content>
</ContentPage>
61 changes: 61 additions & 0 deletions AuroraControls.TestApp/ImageProcessing.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AuroraControls.TestApp;

public partial class ImageProcessing : ContentPage
{
private List<AuroraControls.ImageProcessing.ImageProcessingBase> _imageProcessing = new();

private int _index = 0;

private AuroraControls.ImageProcessing.Blur _blur;
private AuroraControls.ImageProcessing.Circular _circular;
private AuroraControls.ImageProcessing.Grayscale _grayscale;
private AuroraControls.ImageProcessing.Invert _invert;
private AuroraControls.ImageProcessing.Scale _scale;
private AuroraControls.ImageProcessing.Sepia _sepia;

private Random _rngesus = new Random(Guid.NewGuid().GetHashCode());

public ImageProcessing()
{
InitializeComponent();

_blur = new AuroraControls.ImageProcessing.Blur { };
_circular = new AuroraControls.ImageProcessing.Circular();
_grayscale = new AuroraControls.ImageProcessing.Grayscale();
_invert = new AuroraControls.ImageProcessing.Invert();
_scale = new AuroraControls.ImageProcessing.Scale();
_sepia = new AuroraControls.ImageProcessing.Sepia();

this._imageProcessing.AddRange([_blur, _circular, _grayscale, _invert, _scale, _sepia]);
}

private void Handle_ValueChanged(object sender, ValueChangedEventArgs e)
{
_blur.BlurAmount = e.NewValue;
}

private void Handle_Clicked(object sender, System.EventArgs e)
{
if (_index > _imageProcessing.Count - 1)
{
_index = 0;
}

var processingEffect = this._imageProcessing.ElementAt(_index);

if (ImageProcessingEffect.ImageProcessingEffects.Contains(processingEffect))
{
ImageProcessingEffect.ImageProcessingEffects.Remove(processingEffect);
}

ImageProcessingEffect.ImageProcessingEffects.Add(processingEffect);

_index++;
}
}
164 changes: 52 additions & 112 deletions AuroraControls.TestApp/MainPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public TestMvvmToolkitViewModel MvvmToolkitViewModel

private CupertinoTextToggleSwitch _cupertinoToggleSwitch;

private Button _viewImageProcessingButton;

public MainPage(ILogger<TestRxViewModel> logger)
{
var val = 123;
Expand All @@ -70,81 +72,52 @@ public MainPage(ILogger<TestRxViewModel> logger)
Spacing = 16,
Children =
{
new Label
{
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.Center,
Text = "Welcome to .NET MAUI!",
},
new Button { Text = "View Image Processing", }
.Assign(out _viewImageProcessingButton),
new Grid
{
ColumnDefinitions = Columns.Define(Auto, Star, Auto),
RowDefinitions = Rows.Define(Auto),
Children =
{
new CupertinoTextToggleSwitch()
{
EnabledText = "Enabled",
DisabledText = "Disabled",
TrackDisabledColor = Color.FromRgba("#ef361a"),
TrackEnabledColor = Color.FromRgba("#4694f2"),
DisabledFontColor = Colors.White,
EnabledFontColor = Colors.White,
}
{
EnabledText = "Enabled",
DisabledText = "Disabled",
TrackDisabledColor = Color.FromRgba("#ef361a"),
TrackEnabledColor = Color.FromRgba("#4694f2"),
DisabledFontColor = Colors.White,
EnabledFontColor = Colors.White,
}
.Bind(CupertinoTextToggleSwitch.IsToggledProperty, nameof(TestRxViewModel.IsToggled), mode: BindingMode.TwoWay)
.TapGesture(() => _cupertinoToggleSwitch.EnabledText += "A")
.Row(0).Column(2)
.Assign(out _cupertinoToggleSwitch),
},
},
new Button
{
BackgroundColor = Colors.Fuchsia,
}
new Button { BackgroundColor = Colors.Fuchsia, }
.SetSvgIcon("splatoon.svg", colorOverride: Colors.White),
new SegmentedControl
{
FontFamily = "Clathing",
SegmentControlStyle = SegmentedControlStyle.Cupertino,
ForegroundTextColor = Colors.CadetBlue,
BackgroundTextColor = Colors.DarkSlateGray,
Segments =
{
new Segment
{
ForegroundColor = Colors.Lime,
Text = "Test 1",
},
new Segment
{
EmbeddedImageName = "splatoon.svg",
ForegroundColor = Colors.Fuchsia,
Text = "Test 2",
},
},
Segments = { new Segment { ForegroundColor = Colors.Lime, Text = "Test 1", }, new Segment { EmbeddedImageName = "splatoon.svg", ForegroundColor = Colors.Fuchsia, Text = "Test 2", }, },
},
new StyledInputLayout
{
Opacity = .25d,
BackgroundColor = Colors.Fuchsia,
ActiveColor = Colors.Red,
InactiveColor = Colors.Green,
PlaceholderColor = Colors.Purple,
BorderStyle = ContainerBorderStyle.RoundedRectanglePlaceholderThrough,
Content =
new Entry
{
Placeholder = "My Placeholder With Rounded Rectangle Placeholder Through",
Text = "This is My Entry",
},
}
{
Opacity = .25d,
BackgroundColor = Colors.Fuchsia,
ActiveColor = Colors.Red,
InactiveColor = Colors.Green,
PlaceholderColor = Colors.Purple,
BorderStyle = ContainerBorderStyle.RoundedRectanglePlaceholderThrough,
Content =
new Entry { Placeholder = "My Placeholder With Rounded Rectangle Placeholder Through", Text = "This is My Entry", },
}
.Assign(out _opacitySil),
new Slider
{
Value = .5d,
Minimum = 0d,
Maximum = 1d,
}
new Slider { Value = .5d, Minimum = 0d, Maximum = 1d, }
.Bind(nameof(IView.Opacity), source: _opacitySil),
new StyledInputLayout
{
Expand All @@ -153,10 +126,7 @@ public MainPage(ILogger<TestRxViewModel> logger)
InactiveColor = Colors.Green,
BorderStyle = ContainerBorderStyle.RoundedUnderline,
Content =
new NumericEntry
{
Placeholder = "This must be a numeric value...",
},
new NumericEntry { Placeholder = "This must be a numeric value...", },
},
new StyledInputLayout
{
Expand All @@ -165,10 +135,7 @@ public MainPage(ILogger<TestRxViewModel> logger)
InactiveColor = Colors.Green,
BorderStyle = ContainerBorderStyle.RoundedUnderline,
Content =
new NumericEntry
{
Placeholder = "This must be a numeric value...",
}
new NumericEntry { Placeholder = "This must be a numeric value...", }
.Assign(out _rxNumericEntry),
},
new StyledInputLayout
Expand All @@ -179,11 +146,7 @@ public MainPage(ILogger<TestRxViewModel> logger)
BorderStyle = ContainerBorderStyle.RoundedUnderline,
InternalMargin = new Thickness(16, 8),
Content =
new NumericEntry
{
Placeholder = "This must be an int value...",
ValueType = NumericEntryValueType.Int,
}
new NumericEntry { Placeholder = "This must be an int value...", ValueType = NumericEntryValueType.Int, }
.Assign(out _rxNumericIntEntry),
},
new StyledInputLayout
Expand All @@ -195,13 +158,7 @@ public MainPage(ILogger<TestRxViewModel> logger)
new Picker
{
ItemsSource =
new[]
{
"Item 1",
"Item 2",
"Item 3",
"Item 4",
},
new[] { "Item 1", "Item 2", "Item 3", "Item 4", },
},
},
new StyledInputLayout
Expand All @@ -210,41 +167,24 @@ public MainPage(ILogger<TestRxViewModel> logger)
BackgroundColor = Colors.Chartreuse,
BorderStyle = ContainerBorderStyle.RoundedRectangle,
Content =
new DatePicker
{
},
new DatePicker { },
},
new StyledInputLayout
{
Placeholder = "My Editor",
BackgroundColor = Colors.Chartreuse,
BorderStyle = ContainerBorderStyle.Rectangle,
Content =
new Editor
{
Placeholder = "Test Entry",
AutoSize = EditorAutoSizeOption.TextChanges,
},
new Editor { Placeholder = "Test Entry", AutoSize = EditorAutoSizeOption.TextChanges, },
},
new LinearGauge
{
StartingPercent = 10.1d,
EndingPercent = 40.4d,
ProgressBackgroundColor = Colors.Fuchsia,
ProgressColor = Colors.Chartreuse,
},
new CircularFillGauge
{
ProgressPercentage = 46.1d,
ProgressBackgroundColor = Colors.Fuchsia,
ProgressColor = Colors.Chartreuse,
StartingPercent = 10.1d, EndingPercent = 40.4d, ProgressBackgroundColor = Colors.Fuchsia, ProgressColor = Colors.Chartreuse,
},
new CircularFillGauge { ProgressPercentage = 46.1d, ProgressBackgroundColor = Colors.Fuchsia, ProgressColor = Colors.Chartreuse, },
new CircularGauge
{
StartingDegree = 10.1d,
EndingDegree = 90.0d,
ProgressBackgroundColor = Colors.Fuchsia,
ProgressColor = Colors.Chartreuse,
StartingDegree = 10.1d, EndingDegree = 90.0d, ProgressBackgroundColor = Colors.Fuchsia, ProgressColor = Colors.Chartreuse,
},
(_rainbowRing = new Loading.RainbowRing
{
Expand Down Expand Up @@ -371,24 +311,16 @@ public MainPage(ILogger<TestRxViewModel> logger)
},
},
}),
new Tile
{
EmbeddedImageName = "triforce.svg",
ButtonBackgroundColor = Colors.Fuchsia,
},
new SvgImageView
{
EmbeddedImageName = "splatoon.svg",
OverlayColor = Colors.Chartreuse,
},
new Tile { EmbeddedImageName = "triforce.svg", ButtonBackgroundColor = Colors.Fuchsia, },
new SvgImageView { EmbeddedImageName = "splatoon.svg", OverlayColor = Colors.Chartreuse, },
new GradientPillButton
{
Text = "Gradient Pill Button",
ButtonBackgroundStartColor = Colors.Fuchsia,
ButtonBackgroundEndColor = Colors.Chartreuse,
FontColor = Colors.DarkRed,
FontFamily = "Clathing",
}
{
Text = "Gradient Pill Button",
ButtonBackgroundStartColor = Colors.Fuchsia,
ButtonBackgroundEndColor = Colors.Chartreuse,
FontColor = Colors.DarkRed,
FontFamily = "Clathing",
}
.Assign(out _pillButton),
new Image()
.SetSvgIcon("splatoon.svg", 66, Colors.Red),
Expand All @@ -397,7 +329,15 @@ public MainPage(ILogger<TestRxViewModel> logger)
},
};

this.Bind(ViewModel, vm => vm.NullableDoubleValue, ui => ui._rxNumericEntry.Text);
this._viewImageProcessingButton.Clicked +=
async (sender, args) => await this.Navigation.PushAsync(new ImageProcessing());

this.Bind(
ViewModel,
vm => vm.NullableDoubleValue,
ui => ui._rxNumericEntry.Text,
x => x?.ToString("N2") ?? string.Empty,
x => double.TryParse(x, out var parsed) ? parsed : null);
this.Bind(ViewModel, vm => vm.NullableIntValue, ui => ui._rxNumericIntEntry.Text);

Observable
Expand Down
Loading

0 comments on commit 0483886

Please sign in to comment.