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

Map´s control swipe up and down doesn´t work

$
0
0

Hi.

There´s a map control in a page and I´m able to swipe left and right and movement it. However, when I try to swipe up and down the scroll view element on the screen is used (specifically when rendered to the Android platform using google map) and I can´t move the map. Has anyone had the same problem? Am I missing something here?


Is it possible to define height and width in percentage in Xamarin forms?

$
0
0

How we can define height and width in percentage in Xamarin forms so that it can support different screens?

Xamarin.Forms vs Flutter

$
0
0

Hi all
Thomas Burkhart has posted an interesting small review to Flutter (a relative new challenger to .forms) including his personal compare between .forms and Flutter.

As the link was included in the “Weekly Xamarin” newsletter and there also already were articles to Flutter published in the visuals studio magazine (links see below), I think, it’s O.K. to publish this thread here...

As I think, this is interesting for many users, I post the link here:
https://www.burkharts.net/apps/blog/flutter-the-new-kid-on-the-block/?utm_campaign=Weekly+Xamarin&utm_medium=email&utm_source=Weekly_Xamarin_150

Further, also Aloïs Deniel (another Xamarin user) has posted detailed information’s to Flutter a longer time ago here:
https://aloisdeniel.github.io/flutter-introduction/

I think, both postings together will give a good overview to Flutter (from the point of view of Xamarin users).

Link #1 to article in visual studio magazine:
https://visualstudiomagazine.com/articles/2017/12/04/flutter-challenges-xamarin.aspx

Link #2 to article in visual studio magazine:
https://visualstudiomagazine.com/articles/2018/03/01/flutter-xamarin.aspx

Link to a further “high level” comparison Xamarin / Flutter and React native:
http://blog.novoda.com/react-native-flutter-xamarin-a-comparison/

@ThomasBurkhart and @AloisDeniel
First, many thanks for your good work! :smile:

@ThomasBurkhart:
I can fully agree with your findings regarding the “Xamarin tool-chain”.
My personal opinion (without testing Flutter):

  • Looks very promising and interesting (especially “It just works”, fast build time, very fast start-up).
  • Negative points for me are: it seems that there is no integration in VS professional (MS will know the reason for), no direct interface to the device functions, future not secured, no direct support for build iOS on a windows machine

I will definitely keep an eye on Flutter and - as soon as my nerves are completely destroyed with Xamain.Forms - give it a try.

Thanks again

Maybe, also other users want to share their opinions here....?

Map in a ListView header - Drag / scroll event propagation issue on Android

$
0
0

Hi everybody,

I'm trying to use a Map (Xamarin.Forms.Maps.Map) into a ListView Header.

The problem on Android: both of the Map and the ListView handle any drag event onto the Map.

If I want to drag vertically (from bottom to top) the Map to move it to the south, the ListView also get the drag event and start to scroll.

On iOS, the Map doesn't propagate the "drag" event to the ListView wich is the behavior I'm expecting.

I was trying to implement a custom MapRenderer to solve this but the OnDragEvent method of my renderer is never called, so I don't know how to stop the progation of the gesture.

Thanks for your help!

Best regards,

Antoine Boulinguez.

Local Images vs Embedded Images

$
0
0

Is it faster/better to use Local Images or Embedded Images?

*** Local Images: Each project (ios, android, uwp) has the images in the resources folder.
*** Embedded Images:
All images are in a Resource folder in the portable project.

I have 580 images in my portable project, and Im startin to see images not always appearing. So trying to find a solution for what could cause an image not to show up eventhough the .Source property for the Image is set.

Xamarin forms and prism and IEventAggregator instance from model class

$
0
0

How do i get access to the IEventAggregator from a class?

using AssetofThings.Events;
using Prism.Events;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Timers;

namespace AssetofThings.Models
{

public class DeviceInfo : INotifyPropertyChanged
{
    IEventAggregator ea;
    public DeviceInfo()
    {
        App.Current.

        ea = Container.Resolve<IEventAggregator>();//******   ERROR..doesnt work
        aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
        DeviceInfo.Current.aTimer.Interval = 5000;
        DeviceInfo.Current.aTimer.Enabled = true;

    }

    private void OnTimedEvent(object sender, ElapsedEventArgs e)
    {

        ea.GetEvent<RequestGeoUpdateEvent>().Publish("RequestGeoUpdateEvent");//*******WANT TO publish an event

    }

    // Singleton
    public static DeviceInfo Current = new DeviceInfo();

   public System.Timers.Timer aTimer = new System.Timers.Timer();


    private int _updateseconds=60;
    public int updateseconds //seconds
    {
        get
        {

            return _updateseconds;
        }
        set
        {
            if (value != updateseconds)
            {
                _updateseconds = value;
                OnPropertyChanged("updateseconds");
            }
        }
    }

    public event PropertyChangedEventHandler PropertyChanged;

    protected virtual void OnPropertyChanged(string propertyName)
    {
        if (PropertyChanged == null)
            return;

        PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
    }
}

}

AutomationProperties Name for ToolbarItem (iOS)

$
0
0

My toolbar item doesn't get read aloud on iOS. It just says "Taste" (button in German) when clicking it.

My code:

var toolbarItemWeiter = new ToolbarItem("Continue", "PATH_TO_MY_IMAGE", SomeAction, ToolbarItemOrder.Primary);
toolbarItemWeiter.Text = "Continue";
ToolbarItems.Add(toolbarItemWeiter);

I even tried this:

AutomationProperties.SetIsInAccessibleTree(toolbarItemWeiter, true);
AutomationProperties.SetName(toolbarItemWeiter, "Continue");

Still nothing. What am I doing wrong?

How to change the Thickness of OUTLINE / BORDER frame ?

$
0
0

Hi,
I want change the Thickness of a Frame border. I my phone the border is VERY small..

My code :

<Grid RowSpacing="0" ColumnSpacing="0">
      <Grid.RowDefinitions>
        <RowDefinition Height="50" />
      </Grid.RowDefinitions>

      <Frame OutlineColor="Red" Grid.Row="0" Grid.Column="0" Margin="20,0,2,0" Padding="0" HeightRequest="36">
        <Label Text="Femme" XAlign="Center" TextColor="#FFFFFF" FontSize="14"/>
      </Frame>

      <Frame OutlineColor="Red" Grid.Row="0" Grid.Column="1" Margin="2,0,20,0" Padding="0">
        <Label Text="21 ANS" XAlign="Center" TextColor="#FFFFFF" FontSize="14"/>
      </Frame>

    </Grid>

Thx :smile:


Older version or newer example - Not sure what I need

$
0
0

I just want to get something that is working. I am using Visual Studio 2017. I'm trying to make an app that lets me enter a list of information and have dictionary [key: value]. I was thinking a ToDo list might be close but the code pattern is completely different. When I make an app I see Xaml and code behind when I download the ToDo app I see a bunch of CS files. So far I have not got these to even run.

MR.Gestures handles ALL touch gestures

$
0
0

With MR.Gestures you can handle the Tapping, Tapped, DoupleTapped, LongPressing, LongPressed, Panning, Panned, Swiped, Pinching, Pinched, Rotating and Rotated gestures on all layouts, cells, views and on the ContentPage.

The code can be as easy as

    var box1 = new MR.Gestures.BoxView { Color = Color.Red };
    box1.LongPressed += (s, e) => { Console.WriteLine("Code: Red LongPressed"); };

Or in XAML

<br /><mr:ContentView xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:mr="clr-namespace:MR.Gestures;assembly=MR.Gestures"
             x:Class="GestureSample.Views.ContentViewXaml"

             Padding="50"

             TappingCommand="{Binding TappingCommand}"
             TappedCommand="{Binding TappedCommand}"
             DoubleTappedCommand="{Binding DoubleTappedCommand}"
             LongPressingCommand="{Binding LongPressingCommand}"
             LongPressedCommand="{Binding LongPressedCommand}"
             PanningCommand="{Binding PanningCommand}"
             PannedCommand="{Binding PannedCommand}"
             SwipedCommand="{Binding SwipedCommand}"
             PinchingCommand="{Binding PinchingCommand}"
             PinchedCommand="{Binding PinchedCommand}"
             RotatingCommand="{Binding RotatingCommand}"
             RotatedCommand="{Binding RotatedCommand}"
             >

MR.Gestures is available via NuGet. More info on http://www.mrgestures.com/.

There is also a sample app available to download from https://github.com/MichaelRumpler/GestureSample. The GestureSample demonstrates how to use all the gestures with all Xamarin.Forms elements.

Open my app from a url and read value from that url

$
0
0

Hi,

I want to open my app when tapping on a url and read the value appended to the url. For example, I need to get string "123" in my code by opening my app with url "myapp://open?code=123".

I add some code to manifest inside application tag :

<activity android:name="com.companyname.appname.MainActivity" android:label="appname">
        <intent-filter>
            <data android:scheme="https" android:host="appname" />
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
        </intent-filter>
    </activity>

I am testing this feature by tapping a demo url from my phone. But always open google chrome when tapping the demo url.
Thanks in advance :)

Bugs? Memory leaks, animation problems and IsVisible

$
0
0

So the title already tells a lot, I started working on a big project in xamarin forms and ran into some issues I can't explain. It think it are bugs, but before reporting them on github I want to be sure I'm not doing stupid things.

I made an example project detailing my problems, you can view the code on:

gitlab.com/TomBruyneelTrisco/xamarintest.git

In it I set the content of a scrollview dynamically by pushing a button. One of the views has a xamarin animation.

Three questions when running the project:

1) None of the views pages is ever released from memory, the destructor is not called and the animation keeps running
2) How do I know if a view is on the screen, IsVisible always returns true
3) The rate parameter in the animation commit function doesn't seem to change anything (evident by removing the debug statement on line 25 in View1.xaml.cs from comment)

To me, all of the points look like bugs. Can somebody clarify what is going wrong in this project?

Thanks

CS0121 With DryIoc when migrating project to .netstandard

$
0
0

Hi,

I needed to migrate a Xamarin.Forms project from PCL to .netstandard. I use the PCL compatibility nuget package to consume PCLs referenced in the project but I am having a problem with DryIoc that I'm not sure why it is happening. I figured maybe someone here has seen this and can help. Basically I'm getting CS0121 errors (call is ambiguous between 'method1' and 'method2' ) One of the errors is below. I replaced part of the path with the ~ but it looks like it is confused with itself.

~/.nuget/packages/dryioc/2.12.7/contentFiles/cs/any/Container.cs(56,56): Error CS0121: The call is ambiguous between the following methods or properties: 'DryIoc.ReflectionTools.GetFieldOrNull(System.Type, string)' and 'DryIoc.ReflectionTools.GetFieldOrNull(System.Type, string)' (CS0121) (Masterflex)

Viewing a presentation in Xamarin.Forms

$
0
0

Hello, Is it possible to play a presentation in Xamarin.Forms (or Xamarin.Android)?

Xamarin.Forms And EmguCV

$
0
0

I could not even do a simple image processing Xamarin.Forms (PCL) with EmguCV. I have errors in the projects in Github (EmguCV). How can I do it? Do you have a tutorial for Xamarin?


Adding pages programmatically to CarouselPage

$
0
0

Hello everybody!

_I realized the crutch! It works, but I would like to know better approaches to this task. _

I have Months that I want to display in CarouselPage. Here are the problems I faced:
1. At the start, display the second page, the first page on the left, and the third page on the right;
2. Assign a unique identifier to each page (in my case it was the date of the first day of each month);
3. Add pages if user swipe left or right;
4. Add ActivityIndicator to the entire CarouselPage (I added it in templates for each page);
5. Translate CarouselPage events into commands, I get an exception if I use Convac.Behaviors or my own EventToCommandBehavior class.

Month Carousel Page Xaml:

<?xml version="1.0" encoding="utf-8" ?>
<base:CarouselBasePage
    x:Class="MDOSchedule.UI.Pages.AllJobs.CarouselAllJobsWeekPage"
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:base="clr-namespace:MDOSchedule.UI.Pages.Base;assembly=MDOSchedule"
    xmlns:templates="clr-namespace:MDOSchedule.UI.Templates;assembly=MDOSchedule"
    xmlns:week="clr-namespace:MDOSchedule.UI.Views.Week;assembly=MDOSchedule"

    x:Name="This"
    Title="{Binding CurrentDate, StringFormat='{0:MMMM yyyy}'}"
    BindingContextChanged="CarouselAllJobsWeekPage_OnBindingContextChanged"
    CurrentPageChanged="CarouselAllJobsWeekPage_OnCurrentPageChanged"
    ItemsSource="{Binding Weeks}"
    PagesChanged="CarouselAllJobsWeekPage_OnPagesChanged">

    <CarouselPage.ToolbarItems>
        <ToolbarItem
            Command="{Binding RefreshItemsCommand}"
            Icon="ic_refresh.png"
            Order="Primary" />
    </CarouselPage.ToolbarItems>

    <CarouselPage.ItemTemplate>
        <DataTemplate>
            <ContentPage Title="{Binding DateOfFirstDayOfWeek}">

                <AbsoluteLayout>
                    <week:ScheduleWeekView
                        AbsoluteLayout.LayoutBounds="0,0,1,1"
                        AbsoluteLayout.LayoutFlags="All"
                        ItemTappedCommand="{Binding ItemTappedCommand}"
                        WeekItems="{Binding Days}" />

                    <templates:ActivityIndicatorTemplate BindingContext="{Binding Source={x:Reference This}, Path=BindingContext}" />
                </AbsoluteLayout>
            </ContentPage>
        </DataTemplate>
    </CarouselPage.ItemTemplate>

</base:CarouselBasePage>

Month Carousel Page Xaml.CS:

    public partial class CarouselAllJobsMonthPage : CarouselBasePage
        {
            #region Private Fields

            private CarouselAllJobsMonthViewModel _viewModel;

            private bool _isInitialized;

            #endregion


            #region Init

            public CarouselAllJobsMonthPage()
            {
                InitializeComponent();
            }

            #endregion


            #region Events

            private void CarouselAllJobsMonthPage_OnBindingContextChanged(object sender, EventArgs e)
            {
                _viewModel = BindingContext as CarouselAllJobsMonthViewModel;
            }

            private void CarouselAllJobsMonthPage_OnPagesChanged(object sender, NotifyCollectionChangedEventArgs e)
            {
                if (!_isInitialized
                    && Children.Count > 2)
                {
                    CurrentPage = this.Children[1];
                    _isInitialized = true;
                }
            }

            private void CarouselAllJobsMonthPage_OnCurrentPageChanged(object sender, EventArgs e)
            {
                _viewModel.CurrentPageChangedCommand.Execute(this.CurrentPage);
            }

            #endregion
        }

My Carousel View Model:

public class CarouselAllJobsMonthViewModel : BaseViewModel
    {
        // Fields

        #region Public Fields

        public ObservableCollection<Month> Months
        {
            get => Get<ObservableCollection<Month>>();
            set => Set(value);
        }   

        public DateTime CurrentDate
        {
            get => Get<DateTime>();
            set => Set(value);
        }

        #endregion


        #region Private Fields

        private DateTime _previousDate;
        private int _pagesCount = 3;

        private int _pageIndex = 1;

        #endregion


        // Methods  

        #region Commands

        public ICommand RefreshItemsCommand =>
            new Command(async () => await ShowLoading(RefreshItems));

        public ICommand ItemTappedCommand => 
            new Command<DayInfo>(DayTapped);    

        public ICommand CurrentPageChangedCommand => 
            new Command<ContentPage>(async page => await LoadNextPage(page));


        private async Task RefreshItems()
        {
            Months[_pageIndex].Weeks = GetMonth(CurrentDate).Weeks;

            await Task.Delay(1500);
        }

        private void DayTapped(DayInfo obj)
        {

        }

        private async Task LoadNextPage(ContentPage page)
        {
            if (!DateTime.TryParse(page?.Title,
                                   DateTimeFormatInfo.InvariantInfo,
                                   DateTimeStyles.None,
                                   out DateTime newDate))
                return;

            if (newDate.DateEqualsByDay(CurrentDate))
                return;

            await ShowLoading(async () =>
            {
                // Calculate current position and Time
                _previousDate = this.CurrentDate;
                this.CurrentDate = newDate;

                _pageIndex += newDate < _previousDate ? -1 : 1;

                // Add to the head
                if (newDate.DateEqualsByDay(Months[0].FirstDayOfMonth))
                {
                    Months.Insert(0, GetMonth(CurrentDate.AddMonths(-1)));
                    _pagesCount++;
                    await Task.Delay(1500);
                }
                // Add to the tail      
                else if (newDate.DateEqualsByDay(Months[_pagesCount - 1].FirstDayOfMonth))
                {
                    Months.Add(GetMonth(CurrentDate.AddMonths(1)));
                    _pagesCount++;
                    await Task.Delay(1500);
                }
            });
        }

        #endregion


        #region Init



        #endregion


        #region Override Methods

        public override async Task OnPageAppearing()
        {
            await ShowLoading(async () =>
            {
                Months = new ObservableCollection<Month>
                {
                    GetMonth(DateTime.Now.AddMonths(-1)),
                    GetMonth(DateTime.Now),
                    GetMonth(DateTime.Now.AddMonths(1)),
                };

                CurrentDate = Months[0].FirstDayOfMonth;
            });
        }

        #endregion


        #region Private Methods 


        #endregion


        #region Test

        private Month GetMonth(DateTime monthTime)
        {
            var weeks = new List<Week>();

            DateTime firstDayOfMonth = new DateTime(monthTime.Year, monthTime.Month, 1);

            var lastMondayOfPreviousMonth = firstDayOfMonth;
            while (lastMondayOfPreviousMonth.DayOfWeek != DayOfWeek.Monday)
                lastMondayOfPreviousMonth = lastMondayOfPreviousMonth.AddDays(-1);

            var currentDate = lastMondayOfPreviousMonth;
            for (int i = 0; i < 6; i++)
            {
                var week = new Week { Days = GetDays(currentDate) };
                weeks.Add(week);
                currentDate = currentDate.AddDays(7);
            }

            return new Month
            {
                FirstDayOfMonth = firstDayOfMonth,
                Weeks = weeks,
                ItemTappedCommand = this.ItemTappedCommand
            };
        }

        private readonly Random _random = new Random();

        private List<DayInfo> GetDays(DateTime firstDay)
        {
            var days = new List<DayInfo>();
            for (int i = 0; i < 7; i++)
            {
                var jobs = new List<JobObject>();

                if (i != 2)
                    for (int j = 0; j < 10; j++)
                    {
                        jobs.Add(new JobObject()
                        {
                            Color = (j & _random.Next(3)) == 1 ? "#42f47d" : "#ff6677",
                            JobId = _random.Next(70),
                            Monteurs = new List<MonteurObject>()
                            {
                                new MonteurObject()
                                {
                                    TeamName = "Tax"
                                }
                            }
                        });
                    }
                days.Add(new DayInfo(firstDay.AddDays(i), jobs));
            }

            return days;
        }

        #endregion
    }

OxyPlot Example Line Plot Not Displaying

$
0
0

I followed the getting started guide as well as used the example code form the GIT repo to try to create a line graph. I put all the initializer calls in the corresponding projects. I cannot get a graph to display specifically on an android device. My XAML and code behind:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:OxyPlotExamples"
             xmlns:oxy="clr-namespace:OxyPlot.Xamarin.Forms;assembly=OxyPlot.Xamarin.Forms"
             x:Class="OxyPlotExamples.MainPage">

    <Grid>

        <Grid.RowDefinitions>

            <RowDefinition />

        </Grid.RowDefinitions>

        <Grid.ColumnDefinitions>

            <ColumnDefinition />

        </Grid.ColumnDefinitions>

        <oxy:PlotView Grid.Row="0" Grid.Column="0" 
                      Model="{Binding Model}" 
                      VerticalOptions="Center" 
                      HorizontalOptions="Center" 
                      WidthRequest="1000"
                      HeightRequest="500"/>

    </Grid>

</ContentPage>
using OxyPlot;
using OxyPlot.Series;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;

namespace OxyPlotExamples
{
    public partial class MainPage : ContentPage
    {
        public PlotModel Model { get; set; }

        public MainPage()
        {
            InitializeComponent();

            Model = new PlotModel
            {
                Title = "Test",
                LegendSymbolLength = 24
            };

            LineSeries s1 = new LineSeries
            {
                Title = "Series 1",
                Color = OxyColors.SkyBlue,
                MarkerType = MarkerType.Circle,
                MarkerSize = 6,
                MarkerStroke = OxyColors.White,
                MarkerFill = OxyColors.SkyBlue,
                MarkerStrokeThickness = 1.5
            };

            s1.Points.Add(new DataPoint(0, 10));
            s1.Points.Add(new DataPoint(10, 40));
            s1.Points.Add(new DataPoint(40, 20));
            s1.Points.Add(new DataPoint(60, 30));

            Model.Series.Add(s1);
        }
    }
}

Is it possible to serialize views?

$
0
0

I'm making an app where the order and properties of the views on a page can be changed. I'm trying to serialize the StackLayout that contains the views.

I've tried 3 different serialization techniques, all of which have failed with the following exceptions:

XmlSerializer:

System.InvalidOperationException: There was an error reflecting type 'AppProject.MyApp'. occurred

Newtonsoft.Json:

Newtonsoft.Json.JsonSerializationException: Self referencing loop detected for property 'ParentView' with type 'Xamarin.Forms.StackLayout'. Path 'Pages[0].stack.Children[0]'.

BinaryFormatter:

System.Runtime.Serialization.SerializationException: Type 'AppProject.MyApp' in Assembly 'AppProject, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.

Can someone please recommend a solution?

Thanks.

Google vision not read codebar only in huawei

$
0
0

Hi,

I need some help,

in my app i use Visio api and works fine in almost all the diveces but i am having this trace

05-22 17:15:39.903 W/DynamiteModule( 2125): Local module descriptor class for com.google.android.gms.vision.dynamite not found.
05-22 17:15:39.912 I/DynamiteModule( 2125): Considering local module com.google.android.gms.vision.dynamite:0 and remote module com.google.android.gms.vision.dynamite:1702
05-22 17:15:39.912 I/DynamiteModule( 2125): Selected remote version of com.google.android.gms.vision.dynamite, version >= 1702

i have this to read barcodes

 [Activity(Label = "Scanner", Theme = "@style/MainTheme")]
    public class Vision_scanner : AppCompatActivity, ISurfaceHolderCallback, IProcessor,Scanner_Vision
    {
        SurfaceView surfaceView;
        TextView txtResult;
        BarcodeDetector barcodeDetector;
        CameraSource cameraSource;
        const int RequestCameraPermisionID = 1001;
        public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Permission[] grantResults)
        {
            switch (requestCode)
            {
                case RequestCameraPermisionID:
                    {
                        if (grantResults[0] == Permission.Granted)
                        {
                            if (ActivityCompat.CheckSelfPermission(ApplicationContext, Manifest.Permission.Camera) != Android.Content.PM.Permission.Granted)
                            {
                                //Request Permision  
                                ActivityCompat.RequestPermissions(this, new string[]
                                {
                                   Manifest.Permission.Camera
                                }, RequestCameraPermisionID);
                                return;
                            }
                            try
                            {
                                cameraSource.Start(surfaceView.Holder);
                            }
                            catch (InvalidOperationException)
                            {
                            }
                        }
                    }
                    break;
            }
        }

        protected override void OnCreate( Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            try
            {
                SetContentView(Resource.Layout.Scanner);
                surfaceView = FindViewById<SurfaceView>(Resource.Id.cameraView);
                txtResult = FindViewById<TextView>(Resource.Id.txtResult);

                barcodeDetector = new BarcodeDetector.Builder(this)
                    .Build();

                cameraSource = new CameraSource
                    .Builder(this, barcodeDetector)
                    .SetRequestedPreviewSize(640, 480)
                    .SetAutoFocusEnabled(true)
                    .Build();

                surfaceView.Holder.AddCallback(this);
                barcodeDetector.SetProcessor(this);

            }
            catch (Exception EX)
            {
                EX.ToString();
            }
        }

        public void SurfaceChanged(ISurfaceHolder holder, [GeneratedEnum] Format format, int width, int height)
        {
        }

        public void SurfaceCreated(ISurfaceHolder holder)
        {
            if (ActivityCompat.CheckSelfPermission(ApplicationContext, Manifest.Permission.Camera) != Android.Content.PM.Permission.Granted)
            {
                //Request Permision  
                ActivityCompat.RequestPermissions(this, new string[]
                {
                    Manifest.Permission.Camera
                }, RequestCameraPermisionID);
                return;
            }
            try
            {
                cameraSource.Start(surfaceView.Holder);
            }
            catch (InvalidOperationException)
            {
            }
        }

        public void SurfaceDestroyed(ISurfaceHolder holder)
        {
            cameraSource.Stop();
        }

        public void ReceiveDetections(Detections detections)
        {
            SparseArray qrcodes = detections.DetectedItems;
            if (qrcodes.Size() != 0)
            {
                txtResult.Post(() =>
                {                    
                    App.variablesGlovales.CodigoBarras = ((Barcode)qrcodes.ValueAt(0)).RawValue;

                    if (App.variablesGlovales.campoCodigo == "Placa")
                    {
                        MessagingCenter.Send<Xamarin.Forms.Application, string>(App.Current, "Placa", ((Barcode)qrcodes.ValueAt(0)).RawValue);
                    }
                    else if(App.variablesGlovales.campoCodigo == "Serie")
                    {
                        MessagingCenter.Send<Xamarin.Forms.Application, string>(App.Current, "Serie", ((Barcode)qrcodes.ValueAt(0)).RawValue);
                    }
                    else if (App.variablesGlovales.campoCodigo == "PlacaAF")
                    {
                        MessagingCenter.Send<Xamarin.Forms.Application, string>(App.Current, "PlacaAF", ((Barcode)qrcodes.ValueAt(0)).RawValue);
                    }
                    else if (App.variablesGlovales.campoCodigo == "SerieAF")
                    {
                        MessagingCenter.Send<Xamarin.Forms.Application, string>(App.Current, "SerieAF", ((Barcode)qrcodes.ValueAt(0)).RawValue);
                    }           

                    Finish();                    
                });
            }
        }

only in huawei devices

please help

thanks

Draw a line between two controls

$
0
0

Hello!

I would like to create a simple structure of organizational chart, and so far, i'm dynamically adding buttons to StackLayout. When i click a button, i create another one and put him in StackPanel.

Now i would like to create a line, connecting clicked button and newly created one.

I would appreciate any help!

Viewing all 91519 articles
Browse latest View live


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