SignaturePadView in Xamarin Forms different on ios and android - c#

I have added the Nuget packages for Xamarin.Controls.SignaturePad.Forms into my xamarin forms solution. I call the GetImageStreamAsync(SignatureImageFormat.Jpg);. When I run it with White background and black stroke color it only works on ios. Android displays a black screen. THen when I try to set the background to black and White stroke color, Android displays correctly and ios displays a white block and doesn't display correctly. Does anyone have any solutions to this? Ideally it would be good to have the same background color and stroke color on either platforms. I can get around it by setting the background color and stroke color depending on OS, but that seems a bit hacky. Here's what works with the android in Xamarin Forms when I call var str = await PadView.GetImageStreamAsync(SignatureImageFormat.Jpg);. Setting a "White" Background doesn't show up in Android. It always shows a black square. Is there something I'm missing? I'm trying the source https://github.com/xamarin/SignaturePad Thanks.
<forms:SignaturePadView x:Name="PadView"
HeightRequest="100"
WidthRequest="140"
BackgroundColor="Black"
SignatureLineColor="White"
PromptText="Sign here"
PromptTextColor="Gray"
ClearText="Clear"
ClearTextColor="{StaticResource Accent}"
StrokeColor="White"
StrokeWidth="4" />

see comment - Rebuilt source and hard coded White into android background color when it creates the image of the signature. It suits what I have to do, so may not work if you want another color, or you may have to hard code your own color in the android and ios version. Didn't delve into the SignaturePad code enough to see what was going on.

Related

SetWindowDisplayAffinity backcolor image/transparent

how to make transparent black square in SetWindowDisplayAffinity?
put a picture or transparent background instead of a black square
I need the window not to be visible at all in the video capture
I found a solution.
const uint WDA_EXCLUDEFROMCAPTURE = 0x00000011;
SetWindowDisplayAffinity (this.Handle, WDA_EXCLUDEFROMCAPTURE);
I also used it. But it works in Windows 10 version 2004 and above. I tried on new versions of Windows and everything worked out, the window was completely invisible in the screen capture.

Android - Notification icon color not affected by setColor

I'm showing a notification in my app. I would like the small icon to be white in the status bar but another color (greenish) in the notification itself, as described in this question.
I'm using a 72x72, pure white, transparent, RGB-gamma-color-space PNG file as the icon:
This is how it appears in the status bar:
But it's still white in the notification itself (even though the app title gets the correct color):
This is the code I use to display the notification:
using AndroidX.Core.App;
var builder = new NotificationCompat.Builder(this, "MY_CHANNEL")
.SetSmallIcon(Resource.Mipmap.ic_notification_alert)
.SetContentTitle("Test1")
.SetContentText("This is a test")
.SetColor(GetColor(Resource.Color.colorPrimary));
NotificationManagerCompat.From(this).Notify(777, builder.Build());
I already tried moving the icon to the drawable folder, the mipmap folder and using the tool mentioned in the aforementioned question. I'm testing on a Samsung Galaxy S7 with Android 8.0.0 installed. What am I missing?
Downscaling the icon to exactly 48x48 pixels suddenly made the correct color appear.
I still don't understand this undocumented behavior.

How to set the transparency level for a color over a fixed background image in C# for iOS?

I would like to have these 2 things in my iOS game:
(A) One background image of a car as the background image of the game. This background image has the RED color. (I already know how to do this part A).
(B) Next, I want to draw a GREEN rectangle on the TOP of that background image of the car. But, I need to set some level of transparency for that GREEN rectangle so that the GREEN rectangle is 50% clear (or transparent) in order for viewers to be able to see the part of the car behind that GREEN rectangle. This transparency is what I don't know how to implement yet.
Would you please show me how to write the code for part (B) in C# for iOS ?
(I am using C# with Xamarin to write code, and unfortunately, I can't understand Objective-C or Swift.)
Thank you very much.
It is simple, you add UIView over the image, set its background color to green and set its Alpha to some value between 0 and 1.

Black StatusBar with black font in Windows 10 mobile app

I have a Windows 10 UWP app running on mobile. When I run the app in an emulator, everything works fine. When I run it on a device (Lumia 550), the StatusBar is black with black font and the status indicators are not visible.
Is this some kind of bug?
I know I can force the StatusBar to have white background and black color, but the requirement for the app is to stick with the theme (black StatusBar in dark theme, white in Light theme).
If I create a new empty Windows 10 app and run it on a device, the problem is the same, it is not specific to my app.
Edit
Here's a more proper answer:
In Windows 10 Mobile the statusbar inherits it's background color from the topmost page. The foreground color is inherited from RequestedTheme.
This means that if you set the background color of your page to black and your RequestedTheme to Light (which gives a white foreground color), the text will be black on black.
Original post
Have you read this?: https://stenobot.wordpress.com/2015/07/08/uwp-app-development-styling-the-mobile-status-bar/
It might help you.
I have struggled with this a bit.
A strange thing is that when I start my app, the theme (Application.RequestedTheme) is always Light, ignoring the setting on the phone. Even when I try to set it to Dark in the constructor, it immediately reverts to Light. This could explain the black foreground color.
I also experience the inconsistency between simulator and device. To take care of that, I (as suggested in other answer) set the background color of the page (not the root Grid):
<Page
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
... >
</Page>
With this, the status bar at least appear readable.
If you got the black font on the black background with your Light theme project, simple add this line into OnLaunched method in App.xaml.cs:
rootFrame.Background = new SolidColorBrush(Colors.White);
Just add RequestedTheme="Dark"in App.xaml
In your reference Manager add Windows Mobile extensions for the UWP
Then in App.XAML.cs on
protected override void OnLaunched(LaunchActivatedEventArgs e)
add
if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
{
var statusBar = Windows.UI.ViewManagement.StatusBar.GetForCurrentView();
statusBar.BackgroundColor = Windows.UI.Colors.Green;
statusBar.BackgroundOpacity = 1;
statusBar.ForegroundColor = Colors.White;
}
If you want to change Title bar on PC version of UWP app, then you could use this
if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.ApplicationView"))
{
var titleBar = ApplicationView.GetForCurrentView().TitleBar;
if (titleBar != null)
{
titleBar.ButtonBackgroundColor = Colors.DarkBlue;
titleBar.ButtonForegroundColor = Colors.White;
titleBar.BackgroundColor = Colors.Blue;
titleBar.ForegroundColor = Colors.White;
}
}

Can't get gradient transparent border to display correctly

I am having trouble getting my Form background image to display correctly with a gradient transparency. That is, the edge of the image (or anywhere for that matter) has a fading or non-255 Alpha value. The result is that everywhere the Alpha is NOT 255 (or 0 - I can't remember) I see my background color. Here is a screen shot:
What I have in this setup is a 24bit bmp file with a green background that I'm trying to key out via the Form.TransparencyKey property:
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
Color key = ((Bitmap)this.BackgroundImage).GetPixel(0, 0);
this.TransparencyKey = key;
}
I have also tried setting the Form's BackColor property to the same key value but that did not make a difference.
I also tried saving my image as a png with transparency and keying out the entire form background but that didn't work either.
I know this is possible somehow, I've seen applications like Photoshop use this for a decade. I'm on WinXP Pro if that matters.
Anyone have experience with this and have an idea what step I'm missing or doing incorrectly?
The WinForms implementation of Form only permits a solid colour to be used as the transparency key. It's not possible to have varying levels of transparency.
Most apps with splash screens like yours take a screenshot of the desktop (within the bounds that their splash screen will occupy) and then composite their splash screen on top of this screenshot. They then display the resulting bitmap to the user, giving the impression of an alpha gradient.
I've had my share of failure time with exactly that.
I found that WinForms is simple weak at handling this.
Here is some solutions that you might find useful:
http://www.c-sharpcorner.com/UploadFile/scottlysle/XparentFormsCS10282007212944PM/XparentFormsCS.aspx
Link
http://www.vcskicks.com/splash-screen.php

Categories