Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all 91519 articles
Browse latest View live

SkiaSharp multi-threaded drawing

$
0
0

Does someone have a code sample of how to do multithreaded SkiaSharp drawing? I'm trying to achieve that in a PCL, but I've not gotten any further.

What I'm trying to do is:
1. await method X in method A
2. in method X start a new Task which returns a SKImage
3. in method X create (and dispose when done) SKSurface
4. draw to the Canvas of created SKSurface
5. return SKSurface.Canvas.Snapshot
6. in method A draw the returned SKImage to the original SKCanvasView's Surface.Canvas
7. dispose the SKImage
8. dispose original SKCanvasView's Surface.Canvas

But at step 6 I get the following exception:

[Mono] Found as 'sk_canvas_draw_image'.
[mono-rt] Stacktrace:
[mono-rt] 
[mono-rt]   at <unknown> <0xffffffff>
[mono-rt]   at (wrapper managed-to-native) SkiaSharp.SkiaApi.sk_canvas_draw_image (intptr,intptr,single,single,intptr) <0x0004f>
[mono-rt]   at SkiaSharp.SKCanvas.DrawImage (SkiaSharp.SKImage,single,single,SkiaSharp.SKPaint) [0x00037] in <8e4c06e066264a27bdda5f7ce87d3a90>:0
[mono-rt]   at MyView/<OnDrawGraph>d__6.MoveNext () [0x00177] in /.../Views/MyView.xaml.cs:72
[mono-rt]   at System.Runtime.CompilerServices.AsyncMethodBuilderCore/MoveNextRunner.InvokeMoveNext (object) [0x00006] in <3fd174ff54b146228c505f23cf75ce71>:0
[mono-rt]   at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool) [0x00073] in <3fd174ff54b146228c505f23cf75ce71>:0
[mono-rt]   at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool) [0x00004] in <3fd174ff54b146228c505f23cf75ce71>:0
[mono-rt]   at System.Runtime.CompilerServices.AsyncMethodBuilderCore/MoveNextRunner.Run () [0x00032] in <3fd174ff54b146228c505f23cf75ce71>:0
[mono-rt]   at System.Threading.Tasks.AwaitTaskContinuation.InvokeAction (object) [0x00006] in <3fd174ff54b146228c505f23cf75ce71>:0
[mono-rt]   at System.Threading.Tasks.AwaitTaskContinuation.RunCallback (System.Threading.ContextCallback,object,System.Threading.Tasks.Task&) [0x00013] in <3fd174ff54b146228c505f23cf75ce71>:0
[mono-rt]   at System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation.Run (System.Threading.Tasks.Task,bool) [0x00021] in <3fd174ff54b146228c505f23cf75ce71>:0
[mono-rt]   at System.Threading.Tasks.Task.FinishContinuations () [0x000b5] in <3fd174ff54b146228c505f23cf75ce71>:0
[mono-rt]   at System.Threading.Tasks.Task.FinishStageThree () [0x0003d] in <3fd174ff54b146228c505f23cf75ce71>:0
[mono-rt]   at System.Threading.Tasks.Task`1<TResult_REF>.TrySetResult (TResult_REF) [0x00050] in <3fd174ff54b146228c505f23cf75ce71>:0
[mono-rt]   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<TResult_REF>.SetResult (TResult_REF) [0x00040] in <3fd174ff54b146228c505f23cf75ce71>:0

The original code:

async void OnDrawGraph(object sender, SKPaintSurfaceEventArgs e)
{
    var canvasWidth = e.Info.Width;
    var canvasHeight = e.Info.Height;

    using (var theCanvas = e.Surface.Canvas)
    {
        theCanvas.Clear(MyArgs.GraphBackgroundColor.ToSKColor());

        using (var axesImage = await DrawAxes(args, theCanvas))
        {
            theCanvas.DrawImage(axesImage, 0, 0);
        }

        theCanvas.Flush();
    }
}

// theCanvas is from old code and is not used anymore (gonna remove it if multithreading works)
async Task<SKImage> DrawAxes(MyArgs args, SKCanvas theCanvas)
        {
    return await Task.Run(() =>
    {
        using (var myCanvas = SKSurface.Create((int)args.GraphWidth, (int)args.GraphHeight, SKImageInfo.PlatformColorType, SKAlphaType.Premul))
        using (SKPaint paint = new SKPaint())
        {
            int numberOfAxes = ...;
            float axisYPosition = ...;

            var axis = new Axis
            {
                Args = args,
                YPosition = axisYPosition,
                HeaderText = "1",
                IsBaseXAxis = (i == 0)
            };

            axis.Draw(paint, myCanvas.Canvas);
        }

        return myCanvas.Snapshot();
    });
}

Any help would be appreciated, as I'm highly stuck :-)


Pop Display Alert/ Message from ViewModel

$
0
0

Guys.

How do i invoke/ call display alert/show message once my program did some logic in ViewModel (MVVM)?

E.g

  1. Login Form --> Enter Login Data ---> Click Login Button---> Bind button command to LoginViewModel

Lets say the program done the login validation..how do i send back the login result to Login Page (assuming if login failed) ?

Create simple chat forum

$
0
0
Hi
I am relatively new to Xamarin.Forms
I would like to know how to go about creating a simple Chat forum/Discussion, amongst consultants. I've looked and only seem to come across broadcast messages.

Guidance on Best SkiaSharp Performance

$
0
0

@mattleibow We are creating a graphic-intensive Xamarin.Forms app that uses Skiasharp to create high resolution images for printing. We use low-level drawing, SVG, local and remote images, text with custom fonts, etc. to compose our final output. All of the work is done in the .Netstandard shared project.

Can you direct us to examples, articles, documentation, anything that can give us guidance for how to do this in the most performant way? Here are a few questions.

  1. Presently we have a class that does all the drawing and returns an SKBitmap as the result. While we can use the class and do the work on a background thread, the SKBitmap cannot be used by the UI thread. Can you point to an example of how to properly (i.e. the correct SkiaSharp syntax and functions) marshal the image from the background thread to an SKBitmap on the UI thread?
  2. Related to that, we stopped using the SKCanvasView for two reasons. First, it does not resize nicely within Xamarin.Forms containers, so creating an image with SkiaSharp and then displaying it in a Xamarin.Forms Image object is best because it automatically resizes, playing nicely with Xamarin.Forms containers. Second, our graphics are apparently complex enough, or we are drawing them wrongly, so drawing them in response to the PaintSurface event on the UI thread caused the app to freeze. We can't even display a simple wait animation. That's why we're trying to do all drawing on a background thread.
  3. Would we benefit from using a GRContext and doing all this drawing on the GPU? Does that free the UI thread so it can display a wait animation? I am new to this realm and can find no example code showing how to create and use a GRContext in the .Netstandard shared project. The SkiaSharpFormsDemo does not do anything with the GPU as far as I can tell.
  4. I have studied the SkiaSharpFormsDemo, and have read through dozens of forum posts and most of the issues on the SkiaSharp GitHub project, trying to glean some tips. You mention often that it is important to reuse SKPaint objects, SKTypeFace objects, etc. Would you recommend making them static members of our drawing class and just changing the values every time they are used? The SkiaSharpFormsDemo seems to create SKPaint objects as needed, or within a using block, but I can't find an example of how to properly reuse them.

Thank you so much for your help and all your hard work!

Swagger integration with xamarin forms

$
0
0

Hello there,

I need to use swagger api codes just like drag and drop in xamarin forms project but every time I use the code generated by swagger I have to do few changes regarding restsharp and stream's writer property not found in restsharp.portable nuget package.

Please help me with the best possible solutions to fix this.

Thanks in Advance.

Images from url not showing on android

$
0
0

Hey,

I am trying to show some images from my wordpress site in my app. Its working great on iOS but not working on android.
Images I am getting from one wordpress site and I cannot figure it out why its not working on android.

Code I am using to get and show images is from xamarin.com site:

var webImage = new Image { Source = ImageSource.FromUri(new Uri("https ://xamarin.com/content/images/pages/forms/example-appDOTpng")) };

If I use this link then picture shows on both platforms but if I use

var webImage = new Image { Source = ImageSource.FromUri(new Uri("https ://www.sportino-ma.com/wp-content/uploads/2015/11/19884496_436596000030267_1630323802236795993_n-e1499849630652-150x150DOTjpg")) };

it would not work. I have searched the web for solutions but without any success.

I hope that someone can help me.. Thanx..

P.S. - I'm trying to set image source with XAML too but with same result. (using binding imgUrl as source). Space in my links are because I cannot post links here

App displays URL images from other URLs than my own

$
0
0

I am unable to make the URL public, but I've pasted the full URL into my browser and can confirm the page is right - the image shows in the browser.

But... when I copy that exact URL into a Xamarin.Forms image, set as:

<Image 
    HorizontalOptions="FillAndExpand"
    VerticalOptions="FillAndExpand"
    Aspect="AspectFit">
    <Image.Source>
        <UriImageSource Uri="https://mydomain.com/images/doesntshow.jpg" 
            CacheValidity="3" 
            CachingEnabled="false"/>
    </Image.Source>
</Image>

The image simply will not show.

If I substitute the URL: "https://upload.wikimedia.org/wikipedia/en/a/a9/Example.jpg" the image shows fine.

NOTE: There is 0 possibility the URL is incorrect or has an error because... I'm not typing it; I'm copying/pasting it and it's showing just fine in the browser, just not the Xamarin.Forms app.

I've not a clue as to what to look for. Does anyone else?

Change google map info window text when it is appearing

$
0
0

my current situation that i want when user click on marker i send a request to get clicked position address and show it in the info window it working for IOS but android has problems


Sample ToDo - Downloaded - How do I execute

$
0
0

I have downloaded the sample ToDo List. There are many members in the folder. What member do I click to execute the sample?

[UWP] Changing image on button causes flicker

$
0
0

I typically change images on a button from one image to another, like enabled image to disabled greyscale image. Both of these images are the same size. When the image changes on Android/iOS, no problem. But when the image changes on UWP, it looks like the entire widget hierarchy is recalculated and redrawn causing a horrible flicker. I can understand this if the images were different sizes, but they aren't. Anybody experience this issue on UWP and have a good workaround?

I can not execute the sample of Hello, Android: Quickstart or Multiscreen

$
0
0

I have downloaded but Hello Android: Quickstart and Multiscreen. When I attempt to execute phoneword.sin I get message ONE OR MORE PROJECTS IN THESOLUTION WERE NOT LOADED CORRECTED. I get the same message from but the Quickstart and the Multiscreen Deep Dive. What must I do to get around this problem?

How to create a camera app in xamarin app

$
0
0

Suggest best ways to create a camera app, and best plugins available for using cama in xamarin forms cross platform app

Opening file from location: AppxManifest.xml failed with error: The system cannot find the path spec

$
0
0

I've created a bare-bones Xamarin app (with shared elements, but they're not doing anything yet). It builds and runs in debug mode just fine on UWP and Android (I don't have a Mac to build it for iOS). But I've had to move it to another drive - a simple copy of the whole project directory to the new location. Now the Android version builds and debugs ok, but the UWP version gives me the error:

DEP0700: Registration of the app failed. [0x80073CF0] error 0x80070003: Opening file from location: AppxManifest.xml failed with error: The system cannot find the path specified.

How can I find out what's missing and tell Visual Studio where to look for it? (The version in the original location still works fine, but I'll need to delete that when I get the version in the new location working.)

Native linking failed error in xamarin for GoogleSign

$
0
0

I am following this tutorial for GoogleSign in my project. https://www.pujolsluis.com/google-client-plugin-for-xamarin/ .Works fine in android. But getting Native linking failed errors while rebuild in ios.

Native linking error: clang: error: no such file or directory: '/Users/cybasetechnologies/Library/Caches/Xamarin/mtbs/builds/login2.iOS/0f92dcc98e9717a0d2643ed70077af70/obj/iPhone/Debug/mtouch-cache/FirebaseInstanceID'
Native linking error: clang: error: no such file or directory: '/Users/cybasetechnologies/Library/Caches/Xamarin/mtbs/builds/login2.iOS/0f92dcc98e9717a0d2643ed70077af70/obj/iPhone/Debug/mtouch-cache/FirebaseNanoPB'
Native linking failed. Please review the build log.
Native linking error: clang: error: no such file or directory: '/Users/cybasetechnologies/Library/Caches/Xamarin/mtbs/builds/login2.iOS/0f92dcc98e9717a0d2643ed70077af70/obj/iPhone/Debug/mtouch-cache/FirebaseCoreDiagnostics'
Native linking error: clang: error: no such file or directory: '/Users/cybasetechnologies/Library/Caches/Xamarin/mtbs/builds/login2.iOS/0f92dcc98e9717a0d2643ed70077af70/obj/iPhone/Debug/mtouch-cache/FirebaseAnalytics'
Native linking error: clang: error: no such file or directory: '/Users/cybasetechnologies/Library/Caches/Xamarin/mtbs/builds/login2.iOS/0f92dcc98e9717a0d2643ed70077af70/obj/iPhone/Debug/mtouch-cache/GoogleSignIn'
Native linking error: clang: error: no such file or directory: '/Users/cybasetechnologies/Library/Caches/Xamarin/mtbs/builds/login2.iOS/0f92dcc98e9717a0d2643ed70077af70/obj/iPhone/Debug/mtouch-cache/FirebaseCore'

Deleted bin and obj folders in both mac and visualstudio; clean and rebuid; still error persists.Please help..

WebView/HybridWebView Context Menu

$
0
0

Is there any way to show the context menu? especially ios.
do you have an idea or sample? can you please share?

Thanks


Using RelativeLayout.BoundsConstraint?

$
0
0

Hi,
Any documentation on how to use RelativeLayout.BoundsConstraint, the official doc doesn't mention anything about it!

The name 'InitializeComponent' does not exist in the current context

$
0
0

This is really strange and inconsistent. Sometimes it runs fine and sometimes I get the following error

'The name 'InitializeComponent' does not exist in the current context'

There is absolutely no change in code and project settings. Just sometimes it runs and sometimes it throws this compilation error. How to resolve this?

how to open image in webview in xamarin forms

$
0
0

i am using xamarin forms i want to display image in webview for android any help ? its urgent

publish app to win store

Picker shows multiple times

$
0
0

if you have multiple pickers on a page like Picker 1, picker 2 ... when you click on picker 1 and select something it works fine, but if you click and select something from second picker the first picker shows by itself. it is happening in XF 3.4.0.1008975 but it is ok in XF version 3.1.0.583944.

Do we have any fixes on its way?

Viewing all 91519 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>