public IVisualElementRenderer Convert(Xamarin.Forms.View source, Xamarin.Forms.VisualElement valid) { IVisualElementRenderer render = source.GetOrCreateRenderer(); var properties = typeof(VisualElement).GetRuntimeProperties(); foreach (var item in properties) { if (item.Name == "IsPlatformEnabled") { item.SetValue(source, true); } } properties = typeof(Element).GetRuntimeProperties(); foreach (var item in properties) { if (item.Name == "Platform") { object value = item.GetValue(valid); item.SetValue(source, value); } } return(render); }
public void SetElement(VisualElement element) { var oldElement = this.Element; if (oldElement != null) { this.HookPropertyChanged(oldElement); } if (oldElement == null) { this.Element = element; this.UnhookPropertyChanged(this.Element); this.Tracker = new VisualElementTracker(this); if (this.Control == null) { this.Control = this.CreateFloatingActionButton(); this.Control.Clickable = true; this.Control.SetOnClickListener(new OnClickListener(x => this.FloatingButton.ExecuteCommand())); this.UpdateColorState(); this.UpdateIcon(); } this.AddView(this.Control); } this.OnElementChanged(new VisualElementChangedEventArgs(oldElement, this.Element)); }
protected override void OnElementChanged(VisualElement oldElement, VisualElement newElement) { base.OnElementChanged(oldElement, newElement); if (oldElement != null) { oldElement.PropertyChanged -= this.HandleMasterDetailPagePropertyChanged; oldElement.PropertyChanging -= this.HandleMasterDetailPagePropertyChanging; } if (newElement != null) { newElement.PropertyChanged += this.HandleMasterDetailPagePropertyChanged; newElement.PropertyChanging += this.HandleMasterDetailPagePropertyChanging; } if (oldElement == null && newElement != null) { this.SetFitsSystemWindows(true); var activity = (Activity)this.Context; this.actionBarDrawerToggle = new CustomActionBarDrawerToggle(this, activity, this) { DrawerIndicatorEnabled = true }; this.ActionBar.SetDisplayHomeAsUpEnabled(true); this.ActionBar.SetHomeButtonEnabled(true); this.actionBarDrawerToggle.SyncState(); this.BindNavigationEventHandlers(); } }
/// <summary> /// Constructor. /// </summary> /// <param name="element">The element that caused the layout operation.</param> /// <param name="other">The list of other elements that were affected by the operation.</param> /// <param name="direction">The direction that the layout should be performed in.</param> /// <param name="value">The value that the elements will be affected by in the layout direction.</param> internal LayoutOperation(VisualElement element, IEnumerable<VisualElement> other, LayoutDirection direction, double value) { RootElement = element; Elements = new [] { element }.Union(other).ToList(); Direction = direction; Value = value; }
protected override void OnModelChanged (VisualElement oldModel, VisualElement newModel) { base.OnModelChanged (oldModel, newModel); // this is a ViewGroup - so should be able to load an AXML file and FindView<> var activity = this.Context as Activity; var auth = new OAuth2Authenticator ( clientId: App.Instance.OAuthSettings.ClientId, // your OAuth2 client id scope: App.Instance.OAuthSettings.Scope, // The scopes for the particular API you're accessing. The format for this will vary by API. authorizeUrl: new Uri (App.Instance.OAuthSettings.AuthorizeUrl), // the auth URL for the service redirectUrl: new Uri (App.Instance.OAuthSettings.RedirectUrl)); // the redirect URL for the service auth.Completed += (sender, eventArgs) => { if (eventArgs.IsAuthenticated) { App.Instance.SuccessfulLoginAction.Invoke(); // Use eventArgs.Account to do wonderful things App.Instance.SaveToken(eventArgs.Account.Properties["access_token"]); } else { // The user cancelled } }; activity.StartActivity (auth.GetUI(activity)); }
/// <summary> /// Setup our SwipeRefreshLayout and register for property changed notifications. /// </summary> /// <param name="element">Element.</param> public void SetElement(VisualElement element) { var oldElement = Element; //unregister old and re-register new if (oldElement != null) oldElement.PropertyChanged -= HandlePropertyChanged; Element = element; if (Element != null) { UpdateContent(); Element.PropertyChanged += HandlePropertyChanged; } if (!init) { init = true; //sizes to match the forms view //updates properties, handles visual element properties Tracker = new VisualElementTracker(this); SetOnRefreshListener(this); } UpdateColors(); UpdateIsRefreshing(); UpdateIsSwipeToRefreshEnabled(); if (ElementChanged != null) ElementChanged(this, new VisualElementChangedEventArgs(oldElement, this.Element)); }
private void SetNativeView(Xamarin.Forms.VisualElement view) { var renderer = Xamarin.Forms.Platform.Android.Platform.CreateRendererWithContext(view, this); renderer.Element.Layout(new Rectangle(0, 0, ContentManager.screenWidth, ContentManager.screenHeight)); SetContentView(renderer.View); }
public VisualElementHandler(NativeComponentRenderer renderer, XF.VisualElement visualElementControl) : base(renderer, visualElementControl) { VisualElementControl = visualElementControl ?? throw new ArgumentNullException(nameof(visualElementControl)); VisualElementControl.Focused += (s, e) => { if (FocusedEventHandlerId != default) { renderer.Dispatcher.InvokeAsync(() => renderer.DispatchEventAsync(FocusedEventHandlerId, null, e)); } }; VisualElementControl.SizeChanged += (s, e) => { if (SizeChangedEventHandlerId != default) { renderer.Dispatcher.InvokeAsync(() => renderer.DispatchEventAsync(SizeChangedEventHandlerId, null, e)); } }; VisualElementControl.Unfocused += (s, e) => { if (UnfocusedEventHandlerId != default) { renderer.Dispatcher.InvokeAsync(() => renderer.DispatchEventAsync(UnfocusedEventHandlerId, null, e)); } }; }
async protected override void Invoke(VisualElement visual) { visual.AnchorX = Anchor.X; visual.AnchorY = Anchor.Y; await Task.Delay(Delay); await visual.ScaleTo(Scale, (uint)Length, Easing); }
public void SetElement(VisualElement element) { var oldElement = this.Element; if (oldElement != null) oldElement.PropertyChanged -= HandlePropertyChanged; this.Element = element; if (this.Element != null) { //UpdateContent (); this.Element.PropertyChanged += HandlePropertyChanged; } this.ViewGroup.RemoveAllViews (); //sizes to match the forms view //updates properties, handles visual element properties this.Tracker = new VisualElementTracker (this); this.Packager = new VisualElementPackager (this); this.Packager.Load (); this.UseCompatPadding = true; this.SetContentPadding ((int)TheView.Padding.Left, (int)TheView.Padding.Top, (int)TheView.Padding.Right, (int)TheView.Padding.Bottom); this.Radius = TheView.CornderRadius; this.SetCardBackgroundColor(TheView.BackgroundColor.ToAndroid ()); if (this.ElementChanged != null) { this.ElementChanged(this, new VisualElementChangedEventArgs(oldElement, this.Element)); } }
public void SetElement(VisualElement element) { var oldElement = this.Element; if (oldElement != null) oldElement.PropertyChanged -= HandlePropertyChanged; this.Element = element; if (this.Element != null) { this.Element.PropertyChanged += HandlePropertyChanged; } ViewGroup.RemoveAllViews(); Tracker = new VisualElementTracker(this); Packager = new VisualElementPackager(this); Packager.Load(); UseCompatPadding = true; SetContentPadding((int)TheView.Padding.Left, (int)TheView.Padding.Top, (int)TheView.Padding.Right, (int)TheView.Padding.Bottom); Radius = TheView.CornerRadius; SetCardBackgroundColor(TheView.BackgroundColor.ToAndroid()); if (ElementChanged != null) ElementChanged(this, new VisualElementChangedEventArgs(oldElement, this.Element)); }
public void SetElement(VisualElement element) { var oldElement = this.Element; if (oldElement != null) { oldElement.PropertyChanged -= this.HandlePropertyChanged; } this.Element = element; if (this.Element != null) { this.Element.PropertyChanged += this.HandlePropertyChanged; } this.RemoveAllSubviews(); this.Tracker = new VisualElementTracker(this); this.Packager = new VisualElementPackager(this); this.Packager.Load(); this.SetContentPadding((int)TheView.Padding.Left, (int)TheView.Padding.Top, (int)TheView.Padding.Right, (int)TheView.Padding.Bottom); this.SetCardBackgroundColor(this.TheView.BackgroundColor.ToUIColor()); if (ElementChanged != null) { this.ElementChanged(this, new VisualElementChangedEventArgs(oldElement, this.Element)); } }
protected override void OnModelChanged(VisualElement oldModel, VisualElement newModel) { base.OnModelChanged(oldModel, newModel); // this is a ViewGroup - so should be able to load an AXML file and FindView<> var activity = this.Context as Activity; var auth = new OAuth2Authenticator( clientId: "574134802616730", // your OAuth2 client id scope: "email,user_about_me", // the scopes for the particular API you're accessing, delimited by "+" symbols authorizeUrl: new Uri("https://m.facebook.com/dialog/oauth/"), // the auth URL for the service redirectUrl: new Uri("https://www.cautom.com/SocialAuth/FBLogin/")); // the redirect URL for the service auth.Completed += (sender, eventArgs) => { if (eventArgs.IsAuthenticated) { //App.SuccessfulLoginAction.Invoke(); // Use eventArgs.Account to do wonderful things //App.SaveToken(eventArgs.Account.Properties["access_token"]); string accessToken = eventArgs.Account.Properties["access_token"]; new FacebookLoginWebView().fetchUserInfoFromAccessToken(accessToken); } else { // The user cancelled } }; activity.StartActivity(auth.GetUI(activity)); }
public static Size GetControlSize(Xamarin.Forms.VisualElement control) { var size = control.GetSizeRequest(double.PositiveInfinity, double.PositiveInfinity); //var size2 = control.Measure(double.PositiveInfinity, double.PositiveInfinity); return(size.Request); }
protected override void OnModelChanged (VisualElement oldModel, VisualElement newModel) { base.OnModelChanged (oldModel, newModel); var tableView = Control as global::Android.Widget.ListView; tableView.DividerHeight = 0; tableView.SetBackgroundColor (new global::Android.Graphics.Color(0x2C, 0x3E, 0x50)); }
public FocusEventArgs(VisualElement visualElement, bool isFocused) { if (visualElement == null) throw new ArgumentNullException("visualElement"); VisualElement = visualElement; IsFocused = isFocused; }
public static void AdaptForBinding(VisualElement element, IMvxBindingContextOwner contextOwner) { var mvxPage = element as IMvxContentPage; if (mvxPage != null) { contextOwner.BindingContext = new MvxBindingContext(); contextOwner.BindingContext.DataContext = mvxPage.ViewModel; } }
public static void ElementPressed(Xamarin.Forms.VisualElement visualElement, IButton ButtonElementManager) { if (visualElement.IsEnabled == true) { ButtonElementManager.SetIsPressed(true); ButtonElementManager.PropagateUpPressed(); } }
static Task<bool> ColorAnimation(VisualElement element, string name, Func<double, Color> transform, Action<Color> callback, uint length, Easing easing) { easing = easing ?? Easing.Linear; var taskCompletionSource = new TaskCompletionSource<bool>(); element.Animate<Color>(name, transform, callback, 16, length, easing, (v, c) => taskCompletionSource.SetResult(c)); return taskCompletionSource.Task; }
public static void ElementClicked(Xamarin.Forms.VisualElement visualElement, IButton ButtonElementManager) { if (visualElement.IsEnabled == true) { ButtonElementManager.Command?.Execute(ButtonElementManager.CommandParameter); ButtonElementManager.PropagateUpClicked(); } }
protected override void OnElementChanged(VisualElement oldElement, VisualElement newElement) { base.OnElementChanged(oldElement, newElement); var fld = typeof(MasterDetailPageRenderer).GetField("detailLayout", BindingFlags.NonPublic | BindingFlags.Instance); var fldValue = fld.GetValue(this); var p = fld.FieldType.GetProperty("TopPadding", BindingFlags.Public | BindingFlags.Instance); p.SetValue(fldValue, 0); }
protected override void OnElementChanged(VisualElement oldElement, VisualElement newElement) { base.OnElementChanged(oldElement, newElement); //if not do this, in Android 5.1.1, well have a whrite space between navigation bar and tab bar. var fld = typeof(MasterDetailPageRenderer).GetField("detailLayout", BindingFlags.NonPublic | BindingFlags.Instance); var fldValue = fld.GetValue(this); var p = fld.FieldType.GetProperty("TopPadding", BindingFlags.Public | BindingFlags.Instance); p.SetValue(fldValue, 0); }
public static void AddTouchDownHandler(Xamarin.Forms.VisualElement xamarinVisual, EventHandler <TouchEventArgs> handler) { IRadTouchManager touchManager = DependencyService.Get <IRadTouchManager>(); if (touchManager != null) { touchManager.AddTouchDownHandler(xamarinVisual, handler); } }
/// <summary> /// Gets the services page. /// </summary> /// <param name="mainPage">The main page.</param> /// <returns>Content Page.</returns> private static ContentPage GetServicesPage(VisualElement mainPage) { var services = new ContentPage { Title = "Services" }; var lstServices = new ListView { ItemsSource = new List<string>() { "TextToSpeech", "DeviceExtended", "PhoneService", "GeoLocator", "Camera", "Accelerometer", "Display", "Cache", "Sound" } }; lstServices.ItemSelected += async (sender, e) => { switch (e.SelectedItem.ToString().ToLower()) { case "texttospeech": await mainPage.Navigation.PushAsync(new TextToSpeechPage()); break; case "deviceextended": await mainPage.Navigation.PushAsync(new ExtendedDeviceInfoPage(Resolver.Resolve<IDevice>())); break; case "phoneservice": await mainPage.Navigation.PushAsync(new PhoneServicePage()); break; case "geolocator": await mainPage.Navigation.PushAsync(ViewFactory.CreatePage<GeolocatorViewModel>()); break; case "camera": await mainPage.Navigation.PushAsync(ViewFactory.CreatePage<CameraViewModel>()); break; case "accelerometer": await mainPage.Navigation.PushAsync(new AcceleratorSensorPage()); break; case "display": await mainPage.Navigation.PushAsync(new AbsoluteLayoutWithDisplayInfoPage(Resolver.Resolve<IDisplay>())); break; case "cache": await mainPage.Navigation.PushAsync(ViewFactory.CreatePage<CacheServiceViewModel>()); break; case "sound": await mainPage.Navigation.PushAsync(ViewFactory.CreatePage<SoundServiceViewModel>()); break; default: break; } }; services.Content = lstServices; return services; }
protected override void OnModelChanged(VisualElement oldModel, VisualElement newModel) { base.OnModelChanged (oldModel, newModel); // this is a ViewGroup - so should be able to load an AXML file and FindView<> var activity = this.Context as Activity; var thirdActivity = new Intent (activity, typeof (MyThirdActivity)); activity.StartActivity (thirdActivity); }
/// <summary> /// Gets the or create renderer. /// </summary> /// <returns>The or create renderer.</returns> /// <param name="source">Source.</param> public static IVisualElementRenderer GetOrCreateRenderer(VisualElement source) { var renderer = RendererHelper.GetRenderer (source); if (renderer == null) { renderer = RendererFactory.GetRenderer (source); RendererHelper.SetRenderer (source, renderer); renderer = RendererHelper.GetRenderer (source); } return renderer; }
private void ApplyColors(VisualElement control) { var background = GetBackgroundColor(control).ToAndroid(); Control.Background.SetColorFilter(background, PorterDuff.Mode.Src); var foreground = GetForegroundColor(control).ToAndroid(); Control.SetTextColor(foreground); }
void setVisible(bool visible, Action funk, VisualElement frame) { if (visible) { frame.IsVisible = false; } else { //funk(); } }
public static UIViewController GetViewControler(Xamarin.Forms.VisualElement visualElement) { var renderer = Platform.GetRenderer(visualElement); if (renderer == null) { renderer = Platform.CreateRenderer(visualElement); Platform.SetRenderer(visualElement, renderer); } return(renderer.ViewController); }
private void HideView(Xamarin.Forms.VisualElement view) { if (view.Parent is Xamarin.Forms.VisualElement) { view.IsVisible = false; var parent = (Xamarin.Forms.VisualElement)view.Parent; if (parent != null) { HideView(parent); } } }
private void ShowView(Xamarin.Forms.VisualElement view) { if (view.Parent is Xamarin.Forms.VisualElement) { view.IsVisible = true; var parent = (Xamarin.Forms.VisualElement)view.Parent; if (parent != null) { ShowView(parent); } } }
/// <summary> /// Gets the controls page. /// </summary> /// <param name="mainPage">The main page.</param> /// <returns>Content Page.</returns> private static ContentPage GetControlsPage(VisualElement mainPage) { var controls = new ContentPage { Title = "Controls" }; var lstControls = new ListView { ItemsSource = new List<string>() { "Calendar", "Autocomplete", "Buttons", "Labels", "Cells", "HybridWebView", "WebImage", "DynamicListView" } }; lstControls.ItemSelected += async (sender, e) => { switch (e.SelectedItem.ToString().ToLower()) { case "calendar": await mainPage.Navigation.PushAsync(new CalendarPage()); break; case "autocomplete": await mainPage.Navigation.PushAsync(new AutoCompletePage()); break; case "buttons": await mainPage.Navigation.PushAsync(new ButtonPage()); break; case "labels": await mainPage.Navigation.PushAsync(new ExtendedLabelPage()); break; case "cells": await mainPage.Navigation.PushAsync(new ExtendedCellPage()); break; case "hybridwebview": await mainPage.Navigation.PushAsync(new CanvasWebHybrid()); break; case "webimage": await mainPage.Navigation.PushAsync(new WebImagePage()); break; case "dynamiclistview": await mainPage.Navigation.PushAsync(new Xamarin.Forms.Labs.Sample.Pages.Controls.DynamicList.DynamicListView()); break; default: break; } }; controls.Content = lstControls; return controls; }
public static void CancelAnimations(VisualElement view) { if (view == null) throw new ArgumentNullException("view"); view.AbortAnimation("LayoutTo"); view.AbortAnimation("TranslateTo"); view.AbortAnimation("RotateTo"); view.AbortAnimation("RotateYTo"); view.AbortAnimation("RotateXTo"); view.AbortAnimation("ScaleTo"); view.AbortAnimation("FadeTo"); view.AbortAnimation("SizeTo"); }
public INavigationAware AsNavigationAware(VisualElement element) { if (element == null || element.BindingContext == null) { return null; } var navigationAware = element.BindingContext as INavigationAware; if (navigationAware == null) { navigationAware = element as INavigationAware; } return navigationAware; }
protected override void OnModelSet (VisualElement model) { _view = (CalendarView)model; base.OnModelSet (model); var calendarView = new CalendarMonthView(DateTime.Now, true); calendarView.OnDateSelected += (date) => { _view.NotifyDateSelected(date); }; base.SetNativeControl (calendarView); }
public void SetParent(object parentElement) { if (parentElement is null) { throw new ArgumentNullException(nameof(parentElement)); } if (!(parentElement is XF.VisualElement parentVisualElement)) { throw new ArgumentNullException(nameof(parentElement), $"Expected parent to be of type '{typeof(XF.VisualElement).FullName}' but it is of type '{parentElement.GetType().FullName}'."); } _parentVisualElement = parentVisualElement; UpdateParentStyleSheetIfPossible(); }
private void StartSpinner(VisualElement ve) { double currentRotation = 0; ve.RotateTo(currentRotation, 1, Easing.Linear); Device.StartTimer(TimeSpan.FromMilliseconds(1000), () => { currentRotation += 360; ve.RotateTo(currentRotation, 1000, Easing.Linear); return true; }); }
protected override void OnModelSet(Xamarin.Forms.VisualElement model) { base.OnModelSet(model); var page = model as MySecondPage; var view = NativeView; var viewController = ViewController; var label = new UILabel(new RectangleF(0, 40, 320, 40)); label.Text = "2 " + page.Heading; view.Add(label); }
private void SetCurrentElement(VisualElement element) { StackLayout layout = element as StackLayout; this.Orientation = layout.Orientation == StackOrientation.Horizontal ? Orientation.Horizontal : Orientation.Vertical; element.ChildAdded += element_ChildAdded; foreach (Element logicalElement in element.LogicalChildren) { element_ChildAdded(null, new ElementEventArgs(logicalElement)); } }
public IVisualElementRenderer Convert(Xamarin.Forms.View source, Xamarin.Forms.VisualElement valid) { IVisualElementRenderer render = (IVisualElementRenderer)source.GetValue(RendererProperty); if (render == null) { render = Platform.CreateRenderer(source); source.SetValue(RendererProperty, render); var p = PlatformProperty.GetValue(valid); PlatformProperty.SetValue(source, p); IsPlatformEnabledProperty.SetValue(source, true); } return(render); }
protected override void OnModelChanged(VisualElement oldModel, VisualElement newModel) { base.OnModelChanged (oldModel, newModel); var page = newModel as MySecondPage; // this is a ViewGroup - so should be able to load an AXML file and FindView<> var activity = this.Context as Activity; var o = activity.LayoutInflater.Inflate(Resource.Layout.Main, this, false); view = o; var label = view.FindViewById<TextView> (Resource.Id.textView1); label.Text = page.Heading; AddView(view); }
public void SendTouched(Xamarin.Forms.VisualElement visualElement, TouchEventArgs args) { Debug.WriteLine($"State {args.TouchState} on {visualElement.GetHashCode()} with {args.TouchPoints.Count} Fingers"); VisualStateManager.GoToState(visualElement, args.TouchState.ToString()); Touched?.Invoke(visualElement, args); if (!(visualElement is View view)) { return; } foreach (var gesture in view.GestureRecognizers.Where(x => x.Is <TouchGestureRecognizer>())) { var touchGesture = gesture as TouchGestureRecognizer; touchGesture?.SendTouched(view, args); } }
public void SetElement(Xamarin.Forms.VisualElement element) { var oldElement = Element; Element = element; Element.SizeChanged += PageOnSizeChanged; _masterController = new ChildViewController(); _detailController = new ChildViewController(); Presented = ((MasterDetailPage)Element).IsPresented; OnElementChanged(new VisualElementChangedEventArgs(oldElement, element)); //EffectUtilities.RegisterEffectControlProvider(this, oldElement, element); //if (element != null) // element.SendViewInitialized(NativeView); }
private void ShowDialogAnimation(Xamarin.Forms.VisualElement dialog, Xamarin.Forms.VisualElement bg) { dialog.TranslationY = bg.Height; bg.IsVisible = true; dialog.IsVisible = true; ////ANIMATIONS var showBgAnimation = OpacityAnimation(bg, 0, 0.5); var showDialogAnimation = TransLateYAnimation(dialog, bg.Height, 0); ////EXECUTE ANIMATIONS this.Animate("showBg", showBgAnimation, 16, 200, Easing.Linear, (d, f) => { }); this.Animate("showMenu", showDialogAnimation, 16, 200, Easing.Linear, (d, f) => { OnDialogShow(new EventArgs()); }); OnDialogShowing(new EventArgs()); }
protected override void OnModelChanged (VisualElement oldModel, VisualElement newModel) { _view = (CalendarView)newModel; base.OnModelChanged (oldModel, newModel); LayoutInflater inflatorservice = (LayoutInflater) Context.GetSystemService(Android.Content.Context.LayoutInflaterService); var containerView = (LinearLayout)inflatorservice.Inflate (Resource.Layout.calendar_picker, null, false); _pickerView = containerView.FindViewById<CalendarPickerView>(Resource.Id.calendar_view); _pickerView.Init (new DateTime (2014, 6, 1), new DateTime (2014, 6, 30)) .InMode (CalendarPickerView.SelectionMode.Single); _pickerView.OnDateSelected += (s, e) => { _view.NotifyDateSelected(e.SelectedDate); }; SetNativeControl (containerView); }
private static ContentPage GetControlsPage2(VisualElement mainPage) { var controls = new ContentPage { Title = "2", Content = new StackLayout { Children = { new Label { XAlign = TextAlignment.Center, Text = "Second Page" } } } }; return controls; }
protected override void OnModelChanged(VisualElement oldModel, VisualElement newModel) { base.OnModelChanged(oldModel, newModel); var targetButton = (Android.Widget.Button)Control; var model = newModel as Toolkit.Controls.ImageButton; if (model != null && !string.IsNullOrEmpty(model.Image)) { var packageName = Context.PackageName; var resId = Resources.GetIdentifier(model.Image, "drawable", packageName); if (resId > 0) { var scaledDrawable = GetScaleDrawableFromResourceId(resId, GetWidth(model.ImageWidthRequest), GetHeight(model.ImageHeightRequest)); Drawable left = null; Drawable right = null; Drawable top = null; Drawable bottom = null; switch (model.Orientation) { case (ImageOrientation.ImageToLeft): left = scaledDrawable; break; case (ImageOrientation.ImageToRight): right = scaledDrawable; break; case (ImageOrientation.ImageOnTop): top = scaledDrawable; break; case (ImageOrientation.ImageOnBottom): bottom = scaledDrawable; break; } targetButton.SetCompoundDrawables(left, top, right, bottom); } } }
private async void HideDialogAnimation(Xamarin.Forms.VisualElement dialog, Xamarin.Forms.VisualElement bg) { //ANIMATIONS var hideBgAnimation = OpacityAnimation(bg, 0.5, 0); var showDialogAnimation = TransLateYAnimation(dialog, 0, bg.Height); ////EXECUTE ANIMATIONS this.Animate("hideBg", hideBgAnimation, 16, 200, Easing.Linear, (d, f) => { }); this.Animate("hideMenu", showDialogAnimation, 16, 200, Easing.Linear, (d, f) => { bg.IsVisible = false; dialog.IsVisible = false; dialog.TranslationY = PopUpBgLayout.Height; OnDialogClosing(new EventArgs()); }); await Navigation.PopAllPopupAsync(true); OnDialogClosing(new EventArgs()); }
protected override void OnElementChanged(VisualElement oldElement, VisualElement newElement) { //base.OnElementChanged(oldElement, newElement); //if (newElement == null) //{ // return; //} //if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop) //{ // var drawer = GetChildAt(1); // var detail = GetChildAt(0); // var padding = detail.GetType().GetRuntimeProperty("TopPadding"); // int value = (int)padding.GetValue(detail); // padding.SetValue(drawer, value); //} }
protected override void OnModelSet(Xamarin.Forms.VisualElement model) { base.OnModelSet(model); var page = model as MyThirdPage; var hostViewController = ViewController; var viewController = new UIViewController(); var label = new UILabel(new RectangleF(0, 40, 320, 40)); label.Text = "3 " + page.Heading; viewController.View.Add(label); hostViewController.AddChildViewController(viewController); hostViewController.View.Add(viewController.View); viewController.DidMoveToParentViewController(hostViewController); }
public void SetElement(VisualElement element) { var oldElement = Element; Element = element; UpdateTitle(); OnElementChanged(new VisualElementChangedEventArgs(oldElement, element)); if (Element != null && !string.IsNullOrEmpty(Element.AutomationId)) { SetAutomationId(Element.AutomationId); } if (element != null) { var sendViewInitialized = typeof(Xamarin.Forms.Forms).GetMethod("SendViewInitialized", BindingFlags.Static | BindingFlags.NonPublic); sendViewInitialized?.Invoke(element, new object[] { element, NativeView }); } EffectUtilities.RegisterEffectControlProvider(this, oldElement, element); }
public IVisualElementRenderer Convert(Xamarin.Forms.View source, Xamarin.Forms.VisualElement valid) { IVisualElementRenderer render = (IVisualElementRenderer)source.GetValue(RendererProperty); if (render == null) { render = RendererFactory.GetRenderer(source); source.SetValue(RendererProperty, render); if (valid != null) { var p = PlatformProperty.GetValue(valid); if (p != null) { //PlatformProperty.SetValue(source, p); //IsPlatformEnabledProperty.SetValue(source, true); } } } return(render); }
private async void RotateTheView(VisualElement element, TouchState touchState) { switch (touchState) { case TouchState.Pressed: _isPressed = true; break; case TouchState.Released: _isPressed = false; break; default: return; } while (_isPressed) { await element.RotateTo(360, 500, Easing.Linear); await element.RotateTo(0, 0); // reset to initial position } }
public void SetElement(VisualElement element) { ScrollView oldElement = _view; _view = (ScrollView)element; if (oldElement != null) { oldElement.PropertyChanged -= HandlePropertyChanged; _view.ScrollToRequested -= OnScrollToRequested; } if (element != null) { OnElementChanged(new VisualElementChangedEventArgs(oldElement, element)); if (_container == null) { Tracker = new VisualElementTracker(this); _container = new ScrollViewContainer(_view, Context); } _view.PropertyChanged += HandlePropertyChanged; _view.ScrollToRequested += OnScrollToRequested; LoadContent(); UpdateBackgroundColor(); UpdateOrientation(); UpdateIsEnabled(); //element.SendViewInitialized(this); if (!string.IsNullOrEmpty(element.AutomationId)) { ContentDescription = element.AutomationId; } } Xamarin.Forms.Internals.EffectUtilities.RegisterEffectControlProvider(this, oldElement, element); }
public IVisualElementRenderer Convert(Xamarin.Forms.View source, Xamarin.Forms.VisualElement valid) { //only wp allow us to get renderer directly IVisualElementRenderer render = source.GetRenderer(); if (render == null) { render = RendererFactory.GetRenderer(source); source.SetRenderer(render); if (valid != null) { var p = PlatformProperty.GetValue(valid); if (p != null) { PlatformProperty.SetValue(source, p); IsPlatformEnabledProperty.SetValue(source, true); } } } return(render); }
protected override void Dispose(bool disposing) { if (disposing && !_disposed) { Element.PropertyChanged -= OnHandlePropertyChanged; Platform.SetRenderer(Element, null); if (_appeared) { Page.SendDisappearing(); } _appeared = false; if (_events != null) { _events.Dispose(); _events = null; } if (_packager != null) { _packager.Dispose(); _packager = null; } if (_tracker != null) { _tracker.Dispose(); _tracker = null; } Element = null; _disposed = true; } base.Dispose(disposing); }
public RendererContainer(Xamarin.Forms.VisualElement element) { TranslatesAutoresizingMaskIntoConstraints = false; AccessibilityIdentifier = "SignKeys.Effects.Platform.iOS.RendererContainer"; BackgroundColor = UIColor.Clear; Renderer = (UIView)Xamarin.Forms.Platform.iOS.Platform.CreateRenderer(element); Renderer.TranslatesAutoresizingMaskIntoConstraints = false; AddSubview(Renderer); bottomSpace = new UIView() { TranslatesAutoresizingMaskIntoConstraints = false }; AddSubview(bottomSpace); var views = new NSDictionary <NSString, NSObject>(new NSString[] { (NSString)"renderer", (NSString)"space" }, new NSObject[] { Renderer, bottomSpace }); AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|-0-[renderer]-0-|", NSLayoutFormatOptions.AlignAllTop, null, views)); AddConstraints(NSLayoutConstraint.FromVisualFormat($"V:|-0-[renderer({element.HeightRequest})]-0-[space]-0-|", NSLayoutFormatOptions.AlignAllLeading | NSLayoutFormatOptions.AlignAllTrailing, null, views)); }
public virtual Xamarin.Forms.Point LocationOfTouch(int touchIndex, Xamarin.Forms.VisualElement view) { return(GetLocationInAncestorView(FirstTouchPoint, view)); }
protected Xamarin.Forms.Point GetLocationInAncestorView(Xamarin.Forms.Point location, Xamarin.Forms.VisualElement view) { int[] nativeViewLocation = new int[2]; NativeView.GetLocationOnScreen(nativeViewLocation); var nativeViewLocationOnScreen = new Xamarin.Forms.Point(nativeViewLocation [0], nativeViewLocation [1]); var offsetLocation = new Xamarin.Forms.Point(location.X + nativeViewLocationOnScreen.X, location.Y + nativeViewLocationOnScreen.Y); var targetViewRenderer = view.GetRenderer(); var targetView = targetViewRenderer.ViewGroup; int[] targetViewLocation = new int[2]; targetView.GetLocationOnScreen(targetViewLocation); var nativeViewScreenLocation = new Xamarin.Forms.Point(targetViewLocation [0], targetViewLocation [1]); var returnPoint = offsetLocation; returnPoint.X -= nativeViewScreenLocation.X; returnPoint.Y -= nativeViewScreenLocation.Y; // Console.WriteLine ("offsetLocation {0} nativeViewLocationOnScreen {1} returnPoint", offsetLocation, nativeViewLocationOnScreen); // Console.WriteLine ("location {0} parentViewLoc {1} returnPoint {2}", location, nativeViewScreenLocation, returnPoint); return(returnPoint); }
private static Color GetForegroundColor(VisualElement control) { return(control.IsEnabled ? Color.FromRgb(254, 254, 254) : Color.FromRgb(140, 123, 219)); }