This repository was archived by the owner on Apr 3, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 67
Master #90
Open
fabricetayou
wants to merge
2
commits into
jamesmontemagno:master
Choose a base branch
from
fabricetayou:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Master #90
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,146 @@ | ||
| using ImageCircle.Forms.Plugin.WPF; | ||
| using System; | ||
| using Xamarin.Forms; | ||
| using ImageCircle.Forms.Plugin.Abstractions; | ||
| using Xamarin.Forms.Platform.WPF; | ||
| using System.Windows.Media; | ||
| using System.Windows.Media.Imaging; | ||
| using System.Windows.Shapes; | ||
| using Color = System.Windows.Media.Color; | ||
| using ImageSource = Xamarin.Forms.ImageSource; | ||
| using System.ComponentModel; | ||
| using System.Diagnostics; | ||
|
|
||
| [assembly: ExportRenderer(typeof(CircleImage), typeof(ImageCircleRenderer))] | ||
| namespace ImageCircle.Forms.Plugin.WPF | ||
| { | ||
| /// <summary> | ||
| /// ImageCircle Implementation | ||
| /// </summary> | ||
| public class ImageCircleRenderer : ViewRenderer<Image, Ellipse> | ||
| { | ||
| #pragma warning disable CS0108 // Member hides inherited member; missing new keyword | ||
| #pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously | ||
| /// <summary> | ||
| /// Used for registration with dependency service | ||
| /// </summary> | ||
| public async static void Init() | ||
| #pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Init is not necessary, I suggest to replace the file with the code above |
||
| #pragma warning restore CS0108 // Member hides inherited member; missing new keyword | ||
| { | ||
| var temp = DateTime.Now; | ||
| } | ||
|
|
||
| private ImageSource file; | ||
|
|
||
| /// <summary> | ||
| /// Register circle | ||
| /// </summary> | ||
| /// <param name="e"></param> | ||
| protected override void OnElementChanged(ElementChangedEventArgs<Image> e) | ||
| { | ||
| base.OnElementChanged(e); | ||
| if (e.OldElement != null || Element == null) | ||
| return; | ||
|
|
||
| var ellipse = new Ellipse(); | ||
| SetNativeControl(ellipse); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// </summary> | ||
| /// <param name="sender"></param> | ||
| /// <param name="e"></param> | ||
| protected override async void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) | ||
| { | ||
| base.OnElementPropertyChanged(sender, e); | ||
|
|
||
| if (Control == null) | ||
| return; | ||
|
|
||
| var min = Math.Min(Element.Width, Element.Height); | ||
| if (min / 2.0f <= 0) | ||
| return; | ||
|
|
||
| try | ||
| { | ||
| Control.Width = min; | ||
| Control.Height = min; | ||
|
|
||
| // Fill background color | ||
| var color = ((CircleImage)Element).FillColor; | ||
| Control.Fill = new SolidColorBrush(Color.FromArgb( | ||
| (byte)(color.A * 255), | ||
| (byte)(color.R * 255), | ||
| (byte)(color.G * 255), | ||
| (byte)(color.B * 255))); | ||
|
|
||
| // Fill stroke | ||
| color = ((CircleImage)Element).BorderColor; | ||
| Control.StrokeThickness = ((CircleImage)Element).BorderThickness; | ||
| Control.Stroke = new SolidColorBrush(Color.FromArgb( | ||
| (byte)(color.A * 255), | ||
| (byte)(color.R * 255), | ||
| (byte)(color.G * 255), | ||
| (byte)(color.B * 255))); | ||
|
|
||
| var force = e.PropertyName == VisualElement.XProperty.PropertyName || | ||
| e.PropertyName == VisualElement.YProperty.PropertyName || | ||
| e.PropertyName == VisualElement.WidthProperty.PropertyName || | ||
| e.PropertyName == VisualElement.HeightProperty.PropertyName || | ||
| e.PropertyName == VisualElement.ScaleProperty.PropertyName || | ||
| e.PropertyName == VisualElement.TranslationXProperty.PropertyName || | ||
| e.PropertyName == VisualElement.TranslationYProperty.PropertyName || | ||
| e.PropertyName == VisualElement.RotationYProperty.PropertyName || | ||
| e.PropertyName == VisualElement.RotationXProperty.PropertyName || | ||
| e.PropertyName == VisualElement.RotationProperty.PropertyName || | ||
| e.PropertyName == CircleImage.BorderThicknessProperty.PropertyName || | ||
| e.PropertyName == CircleImage.BorderColorProperty.PropertyName || | ||
| e.PropertyName == CircleImage.FillColorProperty.PropertyName || | ||
| e.PropertyName == VisualElement.AnchorXProperty.PropertyName || | ||
| e.PropertyName == VisualElement.AnchorYProperty.PropertyName; | ||
|
|
||
| //already set | ||
| if (file == Element.Source && !force) | ||
| return; | ||
|
|
||
| file = Element.Source; | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| BitmapImage bitmapImage = null; | ||
|
|
||
| // Handle file images | ||
| if (file is FileImageSource) throw new NotImplementedException(); | ||
|
|
||
| if (file is UriImageSource) | ||
| { | ||
| bitmapImage = new BitmapImage((Element.Source as UriImageSource).Uri); | ||
| } | ||
| else if (file is StreamImageSource) | ||
| { | ||
| var handler = new StreamImageSourceHandler(); | ||
| var imageSource = await handler.LoadImageAsync(file); | ||
|
|
||
| if (imageSource != null) | ||
| Control.Fill = new ImageBrush | ||
| { | ||
| ImageSource = imageSource, | ||
| Stretch = Stretch.UniformToFill | ||
| }; | ||
| return; | ||
| } | ||
|
|
||
| if (bitmapImage != null) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| Control.Fill = new ImageBrush | ||
| { | ||
| ImageSource = bitmapImage, | ||
| Stretch = Stretch.UniformToFill | ||
| }; | ||
| } | ||
| catch | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. try catch looks uninformative, you can remove it |
||
| { | ||
| Debug.WriteLine("Unable to create circle image, falling back to background color."); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| } | ||
This file contains hidden or 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,18 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <configuration> | ||
| <startup> | ||
| <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /> | ||
| </startup> | ||
| <runtime> | ||
| <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | ||
| <dependentAssembly> | ||
| <assemblyIdentity name="OpenTK" publicKeyToken="bad199fe84eb3df4" culture="neutral" /> | ||
| <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" /> | ||
| </dependentAssembly> | ||
| <dependentAssembly> | ||
| <assemblyIdentity name="OpenTK.GLControl" publicKeyToken="bad199fe84eb3df4" culture="neutral" /> | ||
| <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" /> | ||
| </dependentAssembly> | ||
| </assemblyBinding> | ||
| </runtime> | ||
| </configuration> |
This file contains hidden or 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,9 @@ | ||
| <Application x:Class="TestAppsCircles.WPF.App" | ||
| xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
| xmlns:local="clr-namespace:TestAppsCircles.WPF" | ||
| StartupUri="MainWindow.xaml"> | ||
| <Application.Resources> | ||
|
|
||
| </Application.Resources> | ||
| </Application> |
This file contains hidden or 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,17 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Configuration; | ||
| using System.Data; | ||
| using System.Linq; | ||
| using System.Threading.Tasks; | ||
| using System.Windows; | ||
|
|
||
| namespace TestAppsCircles.WPF | ||
| { | ||
| /// <summary> | ||
| /// Interaction logic for App.xaml | ||
| /// </summary> | ||
| public partial class App : Application | ||
| { | ||
| } | ||
| } |
This file contains hidden or 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,13 @@ | ||
| <forms:FormsApplicationPage x:Class="TestAppsCircles.WPF.MainWindow" | ||
| xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
| xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
| xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
| xmlns:local="clr-namespace:TestAppsCircles.WPF" | ||
| xmlns:forms="clr-namespace:Xamarin.Forms.Platform.WPF;assembly=Xamarin.Forms.Platform.WPF" | ||
| mc:Ignorable="d" | ||
| Title="MainWindow" Height="450" Width="800"> | ||
| <Grid> | ||
|
|
||
| </Grid> | ||
| </forms:FormsApplicationPage> |
This file contains hidden or 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,20 @@ | ||
| using Xamarin.Forms; | ||
| using Xamarin.Forms.Platform.WPF; | ||
| using System.Windows; | ||
|
|
||
| namespace TestAppsCircles.WPF | ||
| { | ||
| /// <summary> | ||
| /// Interaction logic for MainWindow.xaml | ||
| /// </summary> | ||
| public partial class MainWindow : FormsApplicationPage | ||
| { | ||
| public MainWindow() | ||
| { | ||
| InitializeComponent(); | ||
| Forms.Init(); | ||
| ImageCircle.Forms.Plugin.WPF.ImageCircleRenderer.Init(); | ||
| LoadApplication(new TestAppsCircles.App()); | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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,25 @@ | ||
| <configuration> | ||
| <dllmap os="linux" dll="opengl32.dll" target="libGL.so.1"/> | ||
| <dllmap os="linux" dll="glu32.dll" target="libGLU.so.1"/> | ||
| <dllmap os="linux" dll="openal32.dll" target="libopenal.so.1"/> | ||
| <dllmap os="linux" dll="alut.dll" target="libalut.so.0"/> | ||
| <dllmap os="linux" dll="opencl.dll" target="libOpenCL.so"/> | ||
| <dllmap os="linux" dll="libX11" target="libX11.so.6"/> | ||
| <dllmap os="linux" dll="libXi" target="libXi.so.6"/> | ||
| <dllmap os="linux" dll="SDL2.dll" target="libSDL2-2.0.so.0"/> | ||
| <dllmap os="osx" dll="opengl32.dll" target="/System/Library/Frameworks/OpenGL.framework/OpenGL"/> | ||
| <dllmap os="osx" dll="openal32.dll" target="/System/Library/Frameworks/OpenAL.framework/OpenAL" /> | ||
| <dllmap os="osx" dll="alut.dll" target="/System/Library/Frameworks/OpenAL.framework/OpenAL" /> | ||
| <dllmap os="osx" dll="libGLES.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" /> | ||
| <dllmap os="osx" dll="libGLESv1_CM.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" /> | ||
| <dllmap os="osx" dll="libGLESv2.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" /> | ||
| <dllmap os="osx" dll="opencl.dll" target="/System/Library/Frameworks/OpenCL.framework/OpenCL"/> | ||
| <dllmap os="osx" dll="SDL2.dll" target="libSDL2.dylib"/> | ||
| <!-- XQuartz compatibility (X11 on Mac) --> | ||
| <dllmap os="osx" dll="libGL.so.1" target="/usr/X11/lib/libGL.dylib"/> | ||
| <dllmap os="osx" dll="libX11" target="/usr/X11/lib/libX11.dylib"/> | ||
| <dllmap os="osx" dll="libXcursor.so.1" target="/usr/X11/lib/libXcursor.dylib"/> | ||
| <dllmap os="osx" dll="libXi" target="/usr/X11/lib/libXi.dylib"/> | ||
| <dllmap os="osx" dll="libXinerama" target="/usr/X11/lib/libXinerama.dylib"/> | ||
| <dllmap os="osx" dll="libXrandr.so.2" target="/usr/X11/lib/libXrandr.dylib"/> | ||
| </configuration> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have changed a code for this file: