コード例 #1
0
        private bool startCountdown( )
        {
            if (isCallCut == true)
            {
                return(false);
            }
            if (sec > 30)
            {
                if (isAcceptedByTeacher == false)
                {
                    _connection.StopAsync();
                    setOnTuitionOFF();
                    setIsActiveOffOrOn();
                    MainThread.BeginInvokeOnMainThread(async() =>
                    {
                        calllbl.Text = "Cancle Calling...";
                    });
                    MainThread.BeginInvokeOnMainThread(async() =>
                    {
                        await Application.Current.MainPage.Navigation.PopModalAsync().ConfigureAwait(false);
                    });
                    return(false);
                }
            }

            searchdontcount++;
            if (searchdontcount == 1)
            {
                calllbl.Text = "Connection with teacher.";
            }
            else if (searchdontcount == 2)
            {
                calllbl.Text = "Connection with Teacher..";
            }
            else if (searchdontcount == 3)
            {
                searchdontcount = 0;
                calllbl.Text    = "Connection with Teacher...";
            }
            sec++;

            return(true);
        }
コード例 #2
0
 private bool EntrenarBayes()
 {
     try
     {
         App.Bayes = new Bayes()
         {
             Centros = new List <Muestra>()
             {
                 new Muestra()
                 {
                     Medidas = new List <double>()
                     {
                         double.Parse(Clase1Centro1.Text.Replace('.', ',')),
                         double.Parse(Clase1Centro2.Text.Replace('.', ',')),
                         double.Parse(Clase1Centro3.Text.Replace('.', ',')),
                         double.Parse(Clase1Centro4.Text.Replace('.', ','))
                     }
                 },
                 new Muestra()
                 {
                     Medidas = new List <double>()
                     {
                         double.Parse(Clase2Centro1.Text.Replace('.', ',')),
                         double.Parse(Clase2Centro2.Text.Replace('.', ',')),
                         double.Parse(Clase2Centro3.Text.Replace('.', ',')),
                         double.Parse(Clase2Centro4.Text.Replace('.', ','))
                     }
                 }
             },
             Datos    = CopiarDatos(App.Data),
             Muestras = App.Muestras
         };
         App.Bayes.Entrenar();
         return(true);
     }
     catch (Exception ex)
     {
         MainThread.BeginInvokeOnMainThread(() =>
                                            DisplayAlert("Error", ex.Message, "OK"));
         return(false);
     }
 }
コード例 #3
0
 private void loadImageProcess()
 {
     try
     {
         if (engine.Data.Images.Count == 0)
         {
             MainThread.BeginInvokeOnMainThread(() =>
             {
                 statusLabel.Text = "Vous n'avez aucune image.";
             });
             return;
         }
         if (position > engine.Data.Images.Count - 1)
         {
             position = 0;
         }
         else if (position < 0)
         {
             position = engine.Data.Images.Count - 1;
         }
         MainThread.BeginInvokeOnMainThread(() =>
         {
             img.Source = ImageSource.FromStream(() =>
             {
                 WebClient client = new WebClient();
                 Stream stream    = client.OpenRead(engine.Data.Images[position].Source);
                 client.Dispose();
                 return(stream);
             });
         });
     } catch
     {
         running = false;
     }
     MainThread.BeginInvokeOnMainThread(() =>
     {
         PreviousButton.IsVisible = true;
         NextButton.IsVisible     = true;
         RemoveButton.IsVisible   = true;
     });
     running = false;
 }
コード例 #4
0
        public RightSlideLayout()
        {
            VM.SlideView = this;

            tintPanel = new StackLayout()
            {
                Opacity         = 0.2,
                BackgroundColor = Color.Black
            };

            Content = new Grid()
            {
                Children =
                {
                    new StackLayout().Assign(out MainContent).Row(0).Column(0),
                    new StackLayout()
                    {
                        Orientation = StackOrientation.Horizontal,
                        Children    =
                        {
                            new StackLayout()
                            {
                                HorizontalOptions = LayoutOptions.StartAndExpand,
                            },
                            new StackLayout()
                            {
                                WidthRequest = RightSlideLayout.PanelWidth,
                            }.Assign(out SlideContent)
                        }
                    }.Assign(out SlideContainer).Row(0).Column(0)
                    //.BindViewTap(async()=>{
                    //    await ClosePanel();
                    //})
                }
            }.Assign(out ContentGrid);

            MainThread.BeginInvokeOnMainThread(async() =>
            {
                SlideContainer.InputTransparent = true;
                await SlideContent.TranslateTo(RightSlideLayout.PanelWidth, 0, 100);
            });
        }
コード例 #5
0
        public PieChart()
        {
            InitializeComponent();


            if (!LiveCharts.IsConfigured)
            {
                LiveCharts.Configure(LiveChartsSkiaSharp.DefaultPlatformBuilder);
            }

            var stylesBuilder = LiveCharts.CurrentSettings.GetStylesBuilder <SkiaSharpDrawingContext>();
            var initializer   = stylesBuilder.GetInitializer();

            if (stylesBuilder.CurrentColors == null || stylesBuilder.CurrentColors.Length == 0)
            {
                throw new Exception("Default colors are not valid");
            }
            initializer.ConstructChart(this);

            InitializeCore();
            SizeChanged                 += OnSizeChanged;
            mouseMoveThrottler           = new ActionThrottler(TimeSpan.FromMilliseconds(10));
            mouseMoveThrottler.Unlocked += MouseMoveThrottlerUnlocked;

            seriesObserver = new CollectionDeepObserver <ISeries>(
                (object sender, NotifyCollectionChangedEventArgs e) =>
            {
                if (core == null)
                {
                    return;
                }
                MainThread.BeginInvokeOnMainThread(core.Update);
            },
                (object sender, PropertyChangedEventArgs e) =>
            {
                if (core == null)
                {
                    return;
                }
                MainThread.BeginInvokeOnMainThread(core.Update);
            });
        }
コード例 #6
0
 void TakeAction(PushDemoAction action) => MainThread.BeginInvokeOnMainThread(()
                                                                              =>
 {
     try
     {
         var Page = (MainPage as NavigationPage).RootPage as MainTabbedPage;
         if (Page != null)       //mainpage là trang tabbedpage
         {
             Page.CurrentPage = Page.Children[1];
         }
         else
         {
             // vẫn ở trang login, login xong vào thẳng trang thông báo
             MainPage = new NavigationPage(new Login(1));
         }
     }
     catch (Exception e)
     {
     }
 });
コード例 #7
0
        private void UpdateDisplayUpload()
        {
            // Ensure to be on Main UI Thread
            if (!MainThread.IsMainThread)
            {
                MainThread.BeginInvokeOnMainThread(() => UpdateDisplayUpload());
                return;
            }

            if (uploadProgress >= 100)
            {
                uploadState       = false;
                Spinner.IsVisible = false;
                Spinner.Progress  = 0;
            }
            else if (uploadProgress > Spinner.Progress)
            {
                Spinner.Progress = uploadProgress;
            }
        }
コード例 #8
0
ファイル: MainActivity.cs プロジェクト: AxelRigal/TpXamarin
        private void Lancement()
        {
            MainThread.BeginInvokeOnMainThread(() =>
            {
                if (accelerometerReader.isStarted == false)
                {
                    accelerometerReader.ToggleAccelerometer();
                }

                if (orientationReader.isStarted == false)
                {
                    orientationReader.ToggleOrientationSensor();
                }

                if (gyroscopeReader.isStarted == false)
                {
                    gyroscopeReader.ToggleGyroscope();
                }
            });
        }
コード例 #9
0
        void RemoveNewsTab(RemoveInterestTabMessage msg)
        {
            // this has been working on Droid - need to test more on iOS
            MainThread.BeginInvokeOnMainThread(() =>
            {
                try
                {
                    var toRemove = newsTab.Items.SingleOrDefault(t => t.Title.Equals(msg.InterestName, StringComparison.OrdinalIgnoreCase));

                    if (toRemove != null)
                    {
                        newsTab.Items.Remove(toRemove);
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex);
                }
            });
        }
コード例 #10
0
        private void UpdatePresenceImageSource(String resource)
        {
            // Ensure to be on Main UI Thread
            if (!MainThread.IsMainThread)
            {
                MainThread.BeginInvokeOnMainThread(() => UpdatePresenceImageSource(resource));
                return;
            }

            if (resource == null)
            {
                ImagePresence.Source      = null;
                FrameForPesence.IsVisible = false;
            }
            else
            {
                ImagePresence.Source      = ImageSource.FromResource(resource, typeof(Helper).Assembly);
                FrameForPesence.IsVisible = true;
            }
        }
コード例 #11
0
        private bool centerMapToPosition(double Latitude, double Longitude, double ScaleKilometers)
        {
            bool result = false;

            try
            {
                MainThread.BeginInvokeOnMainThread(() => {
                    MapOverview.MoveToRegion(MapSpan.FromCenterAndRadius(new Xamarin.Forms.Maps.Position(Latitude, Longitude), Distance.FromKilometers(ScaleKilometers)));
                });
                result = true;
            }
            catch (Exception exception)
            {
                var properties = new Dictionary <string, string> {
                    { "Action", "centerMapToPosition" }
                };
                Crashes.TrackError(exception, properties);
            }
            return(result);
        }
コード例 #12
0
 private async void shareRouteCommandAsync(object obj)
 {
     if ((IsNeedSyncRoute) && (!IsRefreshing))
     {
         await syncRouteAsync(_vroute.Id).ContinueWith(async(result) =>
         {
             if (result.IsCompleted)
             {
                 MainThread.BeginInvokeOnMainThread(async() =>
                 {
                     await startShareRouteDialogAsync(_vroute.RouteId);
                 });
             }
         });
     }
     else
     {
         await startShareRouteDialogAsync(_vroute.RouteId);
     }
 }
コード例 #13
0
        protected override void OnAppearing()
        {
            base.OnAppearing();

            MessagingCenter.Subscribe <NewProfilePageViewModel>(this, MessageNames.NotOldEnough, (vm) =>
            {
                MainThread.BeginInvokeOnMainThread(() =>
                {
                    DisplayAlert("Not old enough", "You're not old enough to use this app in accordance with it's Terms & Conditions", "Ok");
                });
            });

            MessagingCenter.Subscribe <ProfilePageViewModel>(this, MessageNames.NoPickPhotoSupport, (vm) =>
            {
                MainThread.BeginInvokeOnMainThread(() =>
                {
                    DisplayAlert("Can't select photo", "Selecting a photo doesn't appear to be not supported", "Ok");
                });
            });
        }
コード例 #14
0
        public async Task SearchParent(string password, int parentCode)
        {
            string              url      = "https://api.shikkhanobish.com/api/Master/GetParentInfo";
            HttpClient          client   = new HttpClient();
            string              jsonData = JsonConvert.SerializeObject(new { ParentID = parentCode, Password = password });
            StringContent       content  = new StringContent(jsonData, Encoding.UTF8, "application/json");
            HttpResponseMessage response = await client.PostAsync(url, content).ConfigureAwait(true);

            var result = await response.Content.ReadAsStringAsync().ConfigureAwait(true);

            var parent = JsonConvert.DeserializeObject <Parent> (result);

            StaticPageForOnSleep.isParent = true;
            MainThread.BeginInvokeOnMainThread(async( ) =>
            {
                await progress.ProgressTo(1, 300, Easing.SinIn).ConfigureAwait(false);
                loadinglbl.Text = "Logging As " + parent.ParentName + "...";
            });
            MainThread.BeginInvokeOnMainThread(async( ) => { await Application.Current.MainPage.Navigation.PushModalAsync(new ParentsProfile(parent)).ConfigureAwait(false); });
        }
コード例 #15
0
 private async void Next_Debris_Click(object sender, EventArgs e)
 {
     if (selected != "")
     {
         await Task.Run(() =>
         {
             FinalProject_PU.Model.Debris deb = new Model.Debris();
             deb.roadCoverage = selected;
             deb.IssueImage   = JsonConvert.DeserializeObject <string>(Intent.GetStringExtra("objtopass"));
             FinalProject_PU.Control.DataOper.PutData <Debris2>(this, deb);
         });
     }
     else
     {
         MainThread.BeginInvokeOnMainThread(() =>
         {
             Toast.MakeText(this, "Please select any option", ToastLength.Long).Show();
         });
     }
 }
コード例 #16
0
        public void SetReplyMessage(MessageElementModel messageElementModel)
        {
            // Ensure to be on Main UI Thread
            if (!MainThread.IsMainThread)
            {
                MainThread.BeginInvokeOnMainThread(() => SetReplyMessage(messageElementModel));
                return;
            }

            // We can't add attachments
            FrameBeforeButtonAttachment.IsVisible = false;
            ButtonAttachment.IsVisible            = false;

            replyToMessageId = messageElementModel?.Reply?.Id;

            MessageContentReply.SetUsageMode(true);
            MessageContentReply.BindingContext = messageElementModel;

            MessageContentReplyElement.IsVisible = true;
        }
コード例 #17
0
        public static void ShowDefaultDisconnectionInformation(String linkedToAutomationId = null)
        {
            // NECESSARY TO BE ON MAIN THREAD
            if (!MainThread.IsMainThread)
            {
                MainThread.BeginInvokeOnMainThread(() => ShowDefaultDisconnectionInformation(linkedToAutomationId));
                return;
            }

            MultiPlatformApplication.Controls.CtrlContentPage contentPage = GetCurrentContentPage();

            String id = DEFAULT_DISCONNECTION_INFORMATION_AUTOMATION_ID;

            if (contentPage?.PopupExists(id) != true)
            {
                AddBasicDisconnexionInformationUsingDefaultSettings(null, id);
            }

            Show(id, linkedToAutomationId, LayoutAlignment.Center, false, LayoutAlignment.Center, false, new Point(), -1);
        }
コード例 #18
0
        public static async Task ConsiderBeginInvokeTaskOnMainThread
        (
            this Task task,
            bool forceBeginInvoke =
#if FORCE_ALL_BEGIN_INVOKE
            true
#else
            false
#endif
        )
        {
            if (!forceBeginInvoke && MainThread.IsMainThread)
            {
                await task.WithoutChangingContext();
            }
            else
            {
                MainThread.BeginInvokeOnMainThread(() => { task.FireAndFuhgetAboutIt(); });
            }
        }
コード例 #19
0
        private void UpdateLocationName(GpsLocation location)
        {
            Task.Run(async() =>
            {
                var placeInfo = await PlaceNameProvider.AsyncGetPlaceName(location);

                MainThread.BeginInvokeOnMainThread(() =>
                {
                    _editTextName.Text = placeInfo.PlaceName;

                    var countryIndex = (_spinnerCountry.Adapter as CountryAdapter).GetPosition(placeInfo.Country);
                    if (countryIndex >= 0)
                    {
                        _spinnerCountry.SetSelection(countryIndex);
                    }
                }
                                                   );
            }
                     );
        }
コード例 #20
0
        public void StopAlarmForegroundService()
        {
            Log.Info("Main Activity", $"Main Activity StopAlarmForegroundService Started: {DateTime.Now:HH:m:s.fff}");
            //var startServiceIntent = new Intent(this, typeof(ForegroundService));
            var _stopServiceIntent = new Intent(Application.Context, typeof(AlarmForegroundService));

            _stopServiceIntent.SetAction("SuleymaniyeTakvimi.action.STOP_SERVICE");
            MainThread.BeginInvokeOnMainThread(() =>
            {
                if (Build.VERSION.SdkInt >= BuildVersionCodes.O)
                {
                    Application.Context?.StartForegroundService(_stopServiceIntent);
                }
                else
                {
                    Application.Context?.StartService(_stopServiceIntent);
                }
            });
            System.Diagnostics.Debug.WriteLine("Main Activity" + $"Main Activity StopAlarmForegroundService Finished: {DateTime.Now:HH:m:s.fff}");
        }
コード例 #21
0
        private async Task GetPhotos()
        {
            try
            {
                var result = await _nicWritesService.GetSocialPhotosAsync();

                MainThread.BeginInvokeOnMainThread(() =>
                {
                    foreach (var doc in result)
                    {
                        SocialPosts.Add(new SocialPost(doc.url.ToString()));
                    }
                    // Code to run on the main thread
                });
            }
            catch (Exception ex)
            {
                Logger.Debug(ex.Message, ex);
            }
        }
コード例 #22
0
 public async void SendFeedbackClicked(object sender, EventArgs e)
 {
     try
     {
         var message = new EmailMessage("App feedback", "", "*****@*****.**");
         await Email.ComposeAsync(message);
     }
     catch (FeatureNotSupportedException)
     {
         // Email is not supported on this device
         MainThread.BeginInvokeOnMainThread(() =>
         {
             DisplayAlert("Email not supported", "To send feedback, please add an email account", "Ok");
         });
     }
     catch (Exception)
     {
         // Some other exception occurred
     }
 }
コード例 #23
0
        private async void Muestra_OnClicked(object sender, EventArgs e)
        {
            if (Device.RuntimePlatform.Equals(DevicePlatform.Android.ToString()))
            {
                var read = await Permissions.CheckStatusAsync <Permissions.StorageRead>();

                if (read != PermissionStatus.Granted)
                {
                    read = await Permissions.RequestAsync <Permissions.StorageRead>();

                    if (read != PermissionStatus.Granted)
                    {
                        MainThread.BeginInvokeOnMainThread(async() =>
                                                           await DisplayAlert("Error", "No ha concedido los permisos necesarios", "OK"));
                        return;
                    }
                }
            }

            var fileTypes = DependencyService.Get <ISaveDocs>().GetFileTypes();
            var muestra   = await CrossFilePicker.Current.PickFile(fileTypes);

            if (muestra != null)
            {
                _muestra = ReadLines(muestra.GetStream, Encoding.Default).ToArray();

                muestra.Dispose();

                MainThread.BeginInvokeOnMainThread(async() =>
                {
                    await DisplayAlert("Correcto", "Muestra cargada", "OK");
                });

                LeerMuestra();
            }
            else
            {
                MainThread.BeginInvokeOnMainThread(async() => await DisplayAlert("Error",
                                                                                 "Selección de archivo cancelada", "OK"));
            }
        }
コード例 #24
0
        private void AddRoutePoint()
        {
            var p = CsService.Instance.Location.CurrentLocation;

            if (p == null)
            {
                CrossToastPopUp.Current.ShowToastMessage("Requested Location is Null");
                return;
            }

            _vm.CurrentRoutePoints.Add(p);

            MainThread.BeginInvokeOnMainThread(() =>
            {
                // Todo: Need to fix this, will jump connect points if paused (need to force create new line if auto-add is paused)
                if (MyMap.MapElements.Count < 1)
                {
                    var currentRoutePointsCount = _vm.CurrentRoutePoints.Count;
                    if (currentRoutePointsCount < 2)
                    {
                        return;
                    }

                    var r1 = _vm.CurrentRoutePoints[currentRoutePointsCount - 2];
                    var r2 = _vm.CurrentRoutePoints[currentRoutePointsCount - 1];

                    MyMap.MapElements.Add(CreatePolylineFromTwoRoutePoints(r1, r2));
                }
                else
                {
                    var lines = MyMap.MapElements.OfType <Polyline>().ToList();
                    if (lines == null || lines.Count < 1)
                    {
                        return;
                    }

                    var lastLine = lines.Last();
                    lastLine.Geopath.Add(new Position(p.Latitude, p.Longitude));
                }
            });
        }
コード例 #25
0
 private void SetQRCode(bool isFinished, bool asd)
 {
     MainThread.BeginInvokeOnMainThread(async() => {
         try {
             UserDialogs.Instance.ShowLoading();
             string str = await viewModel.LoadQRCode();
             if (rootLayout.Children.Count > 1)
             {
                 rootLayout.Children.RemoveAt(0);
             }
             if (isFinished & rootLayout.Children.Count > 0)
             {
                 rootLayout.Children.Clear();
             }
             StackLayout rootStack = new StackLayout()
             {
                 WidthRequest      = 350,
                 HeightRequest     = 350,
                 VerticalOptions   = LayoutOptions.FillAndExpand,
                 HorizontalOptions = LayoutOptions.FillAndExpand
             };
             GenerateButton.IsVisible = true;
             rootLayout.Children.Insert(0, rootStack);
             if (asd)
             {
                 qrCode = null;
                 qrCode = GenerateQR(str);
                 rootStack.Children.Add(qrCode);
             }
             else
             {
                 Image img = new Image();
                 rootStack.Children.Add(img);
             }
             rootStack.Children.Add(GenerateButton);
             UserDialogs.Instance.HideLoading();
         } catch (Exception e) {
             System.Diagnostics.Debug.WriteLine(e);
         }
     });
 }
コード例 #26
0
 private void EntrenarKmedias_OnClicked(object sender, EventArgs e)
 {
     if (EntrenarKmedias())
     {
         MainThread.BeginInvokeOnMainThread(async() =>
         {
             try
             {
                 await Shell.Current.GoToAsync("algoritmos?activo=3");
             }
             catch (Exception ex)
             {
                 await DisplayAlert("Error", ex.Message, "OK");
             }
         });
     }
     else
     {
         MainThread.BeginInvokeOnMainThread(() => DisplayAlert("Error", "Error al entrenar el algoritmo", "OK"));
     }
 }
コード例 #27
0
        /// <summary>
        ///     Work around damit im Menü immer ein Eintrag auch selektiert ist
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ListViewMenuItems_OnSelectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.OldItems == null ||
                e.NewItems != null ||
                !e.OldItems.Contains(ListViewMenuItems.SelectedItem))
            {
                return;
            }

            if (!ListViewMenuItems.SelectedItems.Contains(ListViewMenuItems.SelectedItem))
            {
                var elem = ViewModel.MainMenu.CmdAllMenuCommands.FirstOrDefault(x => x == ListViewMenuItems.SelectedItem);
                Task.Run(async() =>
                {
                    await Task.Delay(1);
                    MainThread.BeginInvokeOnMainThread(() => ListViewMenuItems.SelectedItems.Add(elem));
                });
            }

            ViewModel.BcNavigation().Navigator.ShowMenu(false);
        }
コード例 #28
0
        //protected override bool OnBackButtonPressed()
        //{
        //    var bindingContext = BindingContext as CoreViewModel;
        //    var result = bindingContext?.OnBackButtonPressed() ?? base.OnBackButtonPressed();
        //    return result;
        //}

        //public void OnSoftBackButtonPressed()
        //{
        //    var bindingContext = BindingContext as CoreViewModel;
        //    bindingContext?.OnSoftBackButtonPressed();
        //}

        //public static readonly BindableProperty NeedOverrideSoftBackButtonProperty =
        //        BindableProperty.Create("NeedOverrideSoftBackButton", typeof(bool), typeof(BasePages), false);

        /// <summary>
        /// Enables the ability of the Pages view model to receive soft back button press events
        /// </summary>
        /// <value><c>true</c> if need override soft back button; otherwise, <c>false</c>.</value>
        //public bool NeedOverrideSoftBackButton
        //{
        //    get { return (bool)GetValue(NeedOverrideSoftBackButtonProperty); }
        //    set { SetValue(NeedOverrideSoftBackButtonProperty, value); }
        //}


#if __IOS__
        //      /// <summary>
        //      /// Override default settings for back button and removes the chevron images leaving just text.
        //      /// </summary>
        //      public static readonly BindableProperty OverrideBackButtonProperty =
        //          BindableProperty.Create("OverrideBackButton", typeof(bool), typeof(BasePages), false);

        //      /// <summary>
        //      /// Override default settings for back button and removes the chevron images leaving just text.
        //      /// </summary>
        //      /// <value><c>true</c> if override back button; otherwise, <c>false</c>.</value>
        //      public bool OverrideBackButton
        //      {
        //          get { return (bool)GetValue(OverrideBackButtonProperty); }
        //          set { SetValue(OverrideBackButtonProperty, value); }
        //      }

        //      /// <summary>
        //      /// The override back text property.
        //      /// </summary>
        //public static readonly BindableProperty OverrideBackTextProperty =
        //          BindableProperty.Create("OverrideBackText", typeof(string), typeof(BasePages), "Back");

        //      /// <summary>
        //      /// Gets or sets the override back text.
        //      /// </summary>
        //      /// <value>The override back text.</value>
        //public string OverrideBackText
        //      {
        //          get { return (string)GetValue(OverrideBackTextProperty); }
        //          set { SetValue(OverrideBackTextProperty, value); }
        //      }
#endif


        public void ScrollToElement(string scrollAutomationId, string elementAutomationId, ScrollToPosition position)
        {
            object scrollObj = null;

            ((ILayoutController)Content).FindViewByAutomationId(scrollAutomationId, ref scrollObj);

            if (scrollObj != null && scrollObj is ScrollView)
            {
                object elementObj = null;
                ((ILayoutController)Content).FindViewByAutomationId(elementAutomationId, ref elementObj);

                if (elementObj != null && elementObj is Element)
                {
                    var element    = (Element)elementObj;
                    var scrollView = (ScrollView)scrollObj;
                    MainThread.BeginInvokeOnMainThread(async() => {
                        await scrollView.ScrollToAsync(element, position, true);
                    });
                }
            }
        }
コード例 #29
0
 public void CallPropertyChanged(PropertyChangedEventHandler Event, object o, string property)
 {
     try
     {
         Event?.Invoke(o, new PropertyChangedEventArgs(property));
     }
     catch (Exception)
     {
         try
         {
             MainThread.BeginInvokeOnMainThread(() =>
             {
                 Event?.Invoke(o, new PropertyChangedEventArgs(property));
             });
         }
         catch (Exception ex)
         {
             Log.Write("Could not CallPropertyChanged", ex, logType: LogType.Error);
         }
     }
 }
コード例 #30
0
        private static void ProgressBarProgressChanged(ProgressBar progressBar, double progress)
        {
            ViewExtensions.CancelAnimations(progressBar);
            var lengthMs = progress == 1 ? 100 : (uint)((progress - progressBar.Progress) * 80000);

            progressBar.ProgressTo((double)progress, lengthMs, Easing.SinOut);

            if (progress >= 1)
            {
                Task.Run(async() => {
                    await Task.Delay((int)lengthMs);
                    MainThread.BeginInvokeOnMainThread(() =>
                                                       progressBar.IsVisible = false);
                });
            }
            else
            {
                MainThread.BeginInvokeOnMainThread(() =>
                                                   progressBar.IsVisible = true);
            }
        }