Exemple #1
0
 public HelpModel(string name, string description, string tooltip, Xamarin.Forms.View v)
 {
     Name        = name;
     Description = description;
     Tooltip     = tooltip;
     View        = v;
 }
Exemple #2
0
        FrameworkElement CreateView(object item)
        {
            Xamarin.Forms.View formsView = null;
            var bindingContext           = item;

            var dt = bindingContext as Xamarin.Forms.DataTemplate;

            // Support for List<DataTemplate> as ItemsSource
            if (dt != null)
            {
                formsView = (Xamarin.Forms.View)dt.CreateContent();
            }
            else
            {
                var selector = Element.ItemTemplate as Xamarin.Forms.DataTemplateSelector;
                if (selector != null)
                {
                    formsView = (Xamarin.Forms.View)selector.SelectTemplate(bindingContext, Element).CreateContent();
                }
                else
                {
                    formsView = (Xamarin.Forms.View)Element.ItemTemplate.CreateContent();
                }

                formsView.BindingContext = bindingContext;
            }

            formsView.Parent = this.Element;

            var element = formsView.ToWindows(new Xamarin.Forms.Rectangle(0, 0, ElementWidth, ElementHeight));

            return(element);
        }
Exemple #3
0
        private static String SAMPLE = dir + "Video_2014_5_7__15_33_44.mpg";//"Video_2014_5_8__9_12_35.mpg";//"Video_2014_5_6__15_55_19.mpg";//


        protected override void OnElementChanged(Xamarin.Forms.Platform.Android.ElementChangedEventArgs<Xamarin.Forms.View> e)
        {
            Android.Util.Log.Debug(this.GetType().Name, "OnElementChanged()");

            Android.Util.Log.Debug("Android API-int: ", Android.OS.Build.VERSION.Sdk);
            Android.Util.Log.Debug("Android API build: ", ""+Android.OS.Build.VERSION.SdkInt);
            Android.Util.Log.Debug("Android API: ", Android.OS.Build.VERSION.Codename);



            //first call into this method, the render was just created?
            if (e.OldElement == null)
            {
                surf = new SurfaceView(Context);

                myV = e.NewElement;//capture our Xamarin View.

                Android.Util.Log.Debug("X =", myV.X.ToString());

                myV.SizeChanged += myV_SizeChanged;
                myV.PropertyChanged += myV_PropertyChanged;

                base.SetNativeControl(surf);

                surf.Holder.AddCallback(this);
            }
        }
Exemple #4
0
        private static String SAMPLE = dir + "Video_2014_5_7__15_33_44.mpg"; //"Video_2014_5_8__9_12_35.mpg";//"Video_2014_5_6__15_55_19.mpg";//


        protected override void OnElementChanged(Xamarin.Forms.Platform.Android.ElementChangedEventArgs <Xamarin.Forms.View> e)
        {
            Android.Util.Log.Debug(this.GetType().Name, "OnElementChanged()");

            Android.Util.Log.Debug("Android API-int: ", Android.OS.Build.VERSION.Sdk);
            Android.Util.Log.Debug("Android API build: ", "" + Android.OS.Build.VERSION.SdkInt);
            Android.Util.Log.Debug("Android API: ", Android.OS.Build.VERSION.Codename);



            //first call into this method, the render was just created?
            if (e.OldElement == null)
            {
                surf = new SurfaceView(Context);

                myV = e.NewElement;//capture our Xamarin View.

                Android.Util.Log.Debug("X =", myV.X.ToString());

                myV.SizeChanged     += myV_SizeChanged;
                myV.PropertyChanged += myV_PropertyChanged;

                base.SetNativeControl(surf);

                surf.Holder.AddCallback(this);
            }
        }
 View CreateViewContainer(Context context, Xamarin.Forms.View formsView)
 => new Xamarin.Forms.Platform.Android.ContainerView(context, formsView)
 {
     MatchWidth       = true,
     LayoutParameters = new ViewGroup.LayoutParams(
         ViewGroup.LayoutParams.MatchParent,
         ViewGroup.LayoutParams.WrapContent)
 };
        internal RequestViewModel(Xamarin.Forms.View element, SelectedViewModel SelectedViewModel, Xamarin.Forms.StackLayout spList, Xamarin.Forms.ControlTemplate ctControlTemplate)
        {
            this._element          = element;
            this.SelectedViewModel = SelectedViewModel;

            this._spList            = spList;
            this._ctControlTemplate = ctControlTemplate;
        }
Exemple #7
0
 public ViewChangedEventArgs(
     View view,
     FView oldNativeView,
     FView newNativeView)
 {
     VirtualView   = view;
     OldNativeView = oldNativeView;
     NewNativeView = newNativeView;
 }
Exemple #8
0
 public AndroidCameraPage()
     : base()
 {
     _imageView = new ImageView(Android.App.Application.Context);
     Xamarin.Forms.View xView = _imageView.ToView();
     //xView.BackgroundColor = Color.Aqua;
     MainLayout.Children.Add(xView);
     base.DisplayImage.IsVisible = false;
 }
Exemple #9
0
        async Task Transfer(Xamarin.Forms.View element)
        {
            var choice = await App.Current.MainPage.DisplayActionSheet("Transfer profile?", "Cancel", null, "Transfer to another device", "Transfer to this device");


            if (choice.Contains("another"))
            {
                if (await DisplayAlert("Transfer profile out", "This will export your credentials that you can re-import on another device. Your credentials will remain on this device. Do you want to proceed?", "Yes, transfer", "Cancel"))
                {
                    var info = await SettingsService.TransferOut();

                    var bounds = element.GetAbsoluteBounds();

                    await Share.RequestAsync(new ShareTextRequest
                    {
                        PresentationSourceBounds = bounds.ToSystemRectangle(),
                        Title = "Island Tracker for ACNH Backup Codes",
                        Text  = info
                    });

                    Analytics.TrackEvent("Transfer", new Dictionary <string, string>
                    {
                        ["type"] = "out"
                    });
                }
            }
            else if (choice.Contains("this device"))
            {
                if (await DisplayAlert("Transfer in profile?", "Warning! This will start a transfer process that will override your existing profile. Ensure that you have exported your existing profile first as you can not go back. When a new account is imported your Pro status will be reset and you will have to retrieve it again. Do you still want to proceed?", "Yes, transfer in", "Cancel"))
                {
                    var info = await App.Current.MainPage.DisplayPromptAsync("Entry transfer code", "Enter your transfer code that you exported to continue.", "OK", "Cancel");

                    if (string.IsNullOrWhiteSpace(info) || info == "Cancel")
                    {
                        return;
                    }

                    Analytics.TrackEvent("Transfer", new Dictionary <string, string>
                    {
                        ["type"] = "in"
                    });

                    if (await SettingsService.TransferIn(info))
                    {
                        await DisplayAlert("Success", "Your profile has been updated. Ensure you update information in the app and sync with the cloud.");

                        SettingsService.IsPro        = false;
                        SettingsService.NeedsProSync = false;
                    }
                    else
                    {
                        await DisplayAlert("Error", "Please contact support with your transfer code for help.");
                    }
                }
            }
        }
Exemple #10
0
        public void RegisterKeyboardFocusLockInputSource(Xamarin.Forms.View view)
        {
            var nativeType   = OnConvertToNativeType(view);
            var resolvedType = ResolveNativeType(nativeType)?.GetGenericArguments().LastOrDefault();

            if (resolvedType != null && !KeyboardFocusLockInputSources.Contains(resolvedType))
            {
                KeyboardFocusLockInputSources.Add(resolvedType);
            }
        }
Exemple #11
0
 public override void OnDestroyView()
 {
     if (View is ViewGroup)
     {
         ((ViewGroup)View).RemoveAllViews();
     }
     DisposeEvent();
     base.OnDestroyView();
     _xfView = null;
 }
Exemple #12
0
 public BaseDialogFragment(Context context, Xamarin.Forms.View view,
                           DialogConfig dialogConfig, IDialogMsg dialogMsg)
 {
     _xfView       = view;
     _mContext     = context;
     _dialogConfig = dialogConfig;
     _iDialogMsg   = dialogMsg;
     if (view is IDialogElement)
     {
         _dialogElement = view as IDialogElement;
     }
 }
Exemple #13
0
 public BaseDialogFragment(Context context, Xamarin.Forms.View view, DialogConfig dialogConfig
                           , DialogMsg dialogMsg)
 {
     if (view == null)
     {
         IsNative = true;
     }
     _xfView       = view;
     _mContext     = context;
     _dialogConfig = dialogConfig;
     _dialogMsg    = dialogMsg;
 }
Exemple #14
0
        public static IVisualElementRenderer GetRenderer(this XView view, Context context)
        {
            /* Create the Native Renderer if not initialized */
            if (Platform.GetRenderer(view) == null || Platform.GetRenderer(view)?.Tracker == null)
            {
                var ctxRenderer = Platform.CreateRendererWithContext(view, context);
                Platform.SetRenderer(view, ctxRenderer);
            }

            /* Render the X.F. View */
            return(Platform.GetRenderer(view));
        }
 public BaseDialogFragment2(Activity activity, Xamarin.Forms.View contentView,
                            DialogConfig dialogConfig, IDialogMsg dialogMsg, IDialogResult dialogResult = null)
 {
     _context      = activity;
     _dialogConfig = dialogConfig;
     _iDialogMsg   = dialogMsg;
     _contentView  = contentView;
     _dialogResult = dialogResult;
     if (contentView is IDialogElement dialogElement)
     {
         _dialogElement = contentView as IDialogElement;
     }
 }
Exemple #16
0
        // Code taken from
        // http://www.michaelridland.com/xamarin/creating-native-view-xamarin-forms-viewpage/
        public static ViewGroup ConvertFormsToNative(Xamarin.Forms.View view, Xamarin.Forms.Rectangle size)
        {
            var renderer  = Platform.CreateRenderer(view);
            var viewGroup = renderer.ViewGroup;

            renderer.Tracker.UpdateLayout();
            var layoutParams = new ViewGroup.LayoutParams((int)size.Width, (int)size.Height);

            viewGroup.LayoutParameters = layoutParams;
            view.Layout(size);
            viewGroup.Layout(0, 0, (int)view.WidthRequest, (int)view.HeightRequest);
            return(viewGroup);
        }
 public ToastDialogUtil(Activity context, Xamarin.Forms.View view, DialogConfig dialogConfig
                        , IDialogMsg dialogMsg, bool isLong, bool isNative)
 {
     _toastView    = view;
     _mContext     = context;
     _dialogConfig = dialogConfig;
     _dialogMsg    = dialogMsg;
     _isLong       = isLong;
     _isNative     = isNative;
     if (_toastView == null)
     {
         _isNative = true;
     }
 }
Exemple #18
0
 private void InvokeTapEvent(Xamarin.Forms.View view, Xamarin.Forms.TapGestureRecognizer tgr, UIView uiView, UITapGestureRecognizer nativeTgr)
 {
     if (tgr.Command != null)
     {
         if (tgr.Command.CanExecute(tgr.CommandParameter))
         {
             tgr.Command.Execute(tgr.CommandParameter);
         }
     }
     else
     {
         InvkokeEvent(tgr, "Tapped", view, EventArgs.Empty);
     }
 }
Exemple #19
0
        public static UIView ConvertFormsToNative(this Xamarin.Forms.View view)
        {
            var renderer = view.GetOrCreateRenderer();
            var size     = new CGRect(view.X, view.Y, view.Width, view.Height);

            renderer.NativeView.Frame            = size;
            renderer.NativeView.AutoresizingMask = UIViewAutoresizing.All;
            renderer.NativeView.ContentMode      = UIViewContentMode.ScaleToFill;
            renderer.Element.Layout(size.ToRectangle());
            var nativeView = renderer.NativeView;

            nativeView.SetNeedsLayout();
            return(nativeView);
        }
Exemple #20
0
        public void CreateWebViewAdditional()
        {
            var helper         = new Ao3TrackHelper(this);
            var messageHandler = new Win81.ScriptMessageHandler(helper);

            webView.ScriptNotify += messageHandler.WebView_ScriptNotify;
            this.helper           = helper;

            contextMenuPlaceholder = new Xamarin.Forms.ContentView();
            Xamarin.Forms.AbsoluteLayout.SetLayoutBounds(contextMenuPlaceholder, new Xamarin.Forms.Rectangle(0, 0, 0, 0));
            Xamarin.Forms.AbsoluteLayout.SetLayoutFlags(contextMenuPlaceholder, Xamarin.Forms.AbsoluteLayoutFlags.PositionProportional);
            MainContent.Children.Insert(0, contextMenuPlaceholder);

            webView.SizeChanged += WebView_SizeChanged;
        }
Exemple #21
0
        public NativeGestureCoordinator(Xamarin.Forms.View targetView)
        {
            NativeRecognizers = new List <BaseNativeGestureRecognizer> ();
            TargetView        = targetView;
            var renderer = TargetView.GetRenderer();

            if (renderer == null)
            {
                TargetView.PropertyChanged += Recognizer_View_PropertyChanged;
            }
            else
            {
                Initialize();
            }
        }
Exemple #22
0
        public static UIView ConvertFormsToNative(Xamarin.Forms.View view, CGRect size)
        {
            var renderer = Platform.CreateRenderer(view);

            renderer.NativeView.Frame = size;

            renderer.NativeView.AutoresizingMask = UIViewAutoresizing.All;
            renderer.NativeView.ContentMode      = UIViewContentMode.ScaleToFill;

            renderer.Element.Layout(size.ToRectangle());

            var nativeView = renderer.NativeView;

            nativeView.SetNeedsLayout();

            return(nativeView);
        }
        public async Task <byte[]> CaptureAsync(Xamarin.Forms.View fView)
        {
            var view = UIApplication.SharedApplication.KeyWindow.RootViewController.View;

            //If You Want to capture WebView It "fView"
            //var view = ConvertFormsToNative(fView, new CGRect(fView.X, fView.Y, fView.Height, fView.Width));
            UIGraphics.BeginImageContext(view.Frame.Size);
            view.DrawViewHierarchy(view.Frame, true);
            var image = UIGraphics.GetImageFromCurrentImageContext();

            UIGraphics.EndImageContext();

            using (var imageData = image.AsPNG())
            {
                var bytes = new byte[imageData.Length];
                System.Runtime.InteropServices.Marshal.Copy(imageData.Bytes, bytes, 0, Convert.ToInt32(imageData.Length));
                return(bytes);
            }
        }
Exemple #24
0
        private View ConvertFormsToNative(Xamarin.Forms.View view, Xamarin.Forms.Rectangle size)
        {
            viewRenderer = Platform.CreateRendererWithContext(view, Context);
            var viewGroup = viewRenderer.View;

            viewRenderer.Tracker.UpdateLayout();

            if (view.HeightRequest > 0)
            {
                size.Height = view.HeightRequest;
            }

            var layoutParams = new ViewGroup.LayoutParams((int)(size.Width * Xamarin.Essentials.DeviceDisplay.MainDisplayInfo.Density), (int)(size.Height * Xamarin.Essentials.DeviceDisplay.MainDisplayInfo.Density));

            viewGroup.LayoutParameters = layoutParams;
            view.Layout(size);
            viewGroup.Layout(0, 0, (int)view.Width, (int)view.Height);
            return(viewGroup);
        }
Exemple #25
0
        public void PopUp(Xamarin.Forms.View view, object v)
        {
            var menu = new PopupMenu(MainActivity.Context, (View)view.GetRenderer())
            {
            };

            menu.Inflate(Resource.Menu.popup_menu);
            menu.MenuItemClick += (s, e) =>
            {
                if (e.Item.ToString() == "Delete")
                {
                    OnCustomDelete(view, e, v);
                }
                else if (e.Item.ToString() == "Edit")
                {
                    OnCustomEdit(view, e, v);
                }
            };
            menu.Show();
        }
        public async Task CaptureAndSaveAsync(Xamarin.Forms.View fView)
        {
            var bytes = await CaptureAsync(fView);

            var    documentsDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
            string date      = DateTime.Now.ToString().Replace("/", "-").Replace(":", "-");
            string localPath = System.IO.Path.Combine(documentsDirectory, "Screnshot-" + date + ".png");

            var chartImage = new UIImage(NSData.FromArray(bytes));

            chartImage.SaveToPhotosAlbum((image, error) =>
            {
                //you can retrieve the saved UI Image as well if needed using
                //var i = image as UIImage;
                if (error != null)
                {
                    Console.WriteLine(error.ToString());
                }
            });
        }
    Task <byte[]> IViewSnapShot.CaptureAsync(Xamarin.Forms.View view)
    {
        var nativeView             = view.GetRenderer().View;
        var wasDrawingCacheEnabled = nativeView.DrawingCacheEnabled;

        nativeView.DrawingCacheEnabled = true;
        nativeView.BuildDrawingCache(false);
        Bitmap bitmap = nativeView.GetDrawingCache(false);

        // TODO: Save bitmap and return filepath
        nativeView.DrawingCacheEnabled = wasDrawingCacheEnabled;

        byte[] bitmapData;
        using (var stream = new MemoryStream())
        {
            bitmap.Compress(Bitmap.CompressFormat.Png, 0, stream);
            bitmapData = stream.ToArray();
        }

        return(Task.FromResult(bitmapData));
    }
Exemple #28
0
        FrameworkElement CreateView(object item)
        {
            Xamarin.Forms.View formsView = null;
            var bindingContext           = item;

            var selector = Element.ItemTemplate as Xamarin.Forms.DataTemplateSelector;

            if (selector != null)
            {
                formsView = (Xamarin.Forms.View)selector.SelectTemplate(bindingContext, Element).CreateContent();
            }
            else
            {
                formsView = (Xamarin.Forms.View)Element.ItemTemplate.CreateContent();
            }

            formsView.BindingContext = bindingContext;

            var element = FormsViewToNativeUWP.ConvertFormsToNative(formsView, new Xamarin.Forms.Rectangle(0, 0, ElementWidth, ElementHeight));

            return(element);
        }
        public static UIView ConvertFormsToNative(Xamarin.Forms.View view, CGRect size)
        {
            //var vRenderer = RendererFactory.GetRenderer (view);

            if (Platform.GetRenderer(view) == null)
            {
                Platform.SetRenderer(view, Platform.CreateRenderer(view));
            }
            var vRenderer = Platform.GetRenderer(view);

            vRenderer.NativeView.Frame = size;

            vRenderer.NativeView.AutoresizingMask = UIViewAutoresizing.All;
            vRenderer.NativeView.ContentMode      = UIViewContentMode.ScaleToFill;

            vRenderer.Element.Layout(size.ToRectangle());

            var nativeView = vRenderer.NativeView;

            nativeView.SetNeedsLayout();

            return(nativeView);
        }
Exemple #30
0
        public async Task <int> LaunchMenu(List <string> menuItems, Xamarin.Forms.View parent)
        {
            if (menuItems == null || menuItems.Count == 0)
            {
                return(-1);
            }

            var menu = new Windows.UI.Popups.PopupMenu();

            Windows.Foundation.Point point = new Windows.Foundation.Point(0, 0);

            if (parent != null)
            {
                // have to turn it into the UWP visual control and extract the screen coordinates
                var visualElement = parent.GetOrCreateRenderer()?.ContainerElement;
                if (visualElement != null)
                {
                    GeneralTransform transform = visualElement.TransformToVisual(null);
                    point = transform.TransformPoint(new Windows.Foundation.Point());
                }
            }

            for (var i = 0; i < menuItems.Count; i++)
            {
                var item = menuItems[i];
                menu.Commands.Add(new Windows.UI.Popups.UICommand(item));
            }

            var response = await menu.ShowAsync(point);

            if (response == null || string.IsNullOrEmpty(response.Label))
            {
                return(-1);
            }

            return(menuItems.IndexOf(response.Label));
        }
        //
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            global::Xamarin.Forms.Forms.SetFlags("Shell_Experimental", "Visual_Experimental", "CollectionView_Experimental", "FastRenderers_Experimental");
            global::Xamarin.Forms.Forms.Init();

            CustomTextEditorDelegate neutralTextEditor =
                () => {
                XMGui.NeutralTextEditView editor = new XMGui.NeutralTextEditView();
                Xamarin.Forms.View        view   = editor.AsView();
                view.HorizontalOptions = Xamarin.Forms.LayoutOptions.FillAndExpand;
                view.VerticalOptions   = Xamarin.Forms.LayoutOptions.FillAndExpand;
                return(editor);
                //return new GUI_Xamarin.NeutralTextEditView {
                //    HorizontalOptions = Xamarin.Forms.LayoutOptions.FillAndExpand,
                //    VerticalOptions = Xamarin.Forms.LayoutOptions.FillAndExpand,
                //};
            };


            CustomTextEditorDelegate customTextEditor =
                () => {
                return(new CustomTextEditView {
                    HorizontalOptions = Xamarin.Forms.LayoutOptions.FillAndExpand,
                    VerticalOptions = Xamarin.Forms.LayoutOptions.FillAndExpand,
                });
            };

            // How to add a LaunchScreen - SplashScreen
            // https://docs.microsoft.com/en-us/xamarin/ios/app-fundamentals/images-icons/launch-screens?tabs=windows#migrating-to-launch-screen-storyboards

            UINavigationBar.Appearance.TintColor = UIColor.White; // affect the color of the bitmaps in the top toolbar
            Gui.platform = Kaemika.Platform.iOS;
            LoadApplication(new App(customTextEditor));           // or neutralTextEditor

            return(base.FinishedLaunching(app, options));
        }