コード例 #1
0
        private async void SwitchButton_OnTapped(object sender, EventArgs e)
        {
            try
            {
                Xamarin.Forms.Image           img = (Xamarin.Forms.Image)sender;
                Xamarin.Forms.FileImageSource objFileImageSource = (Xamarin.Forms.FileImageSource)img.Source;
                MovementListTbl obj = (MovementListTbl)objFileImageSource.BindingContext;

                string strFileName = objFileImageSource.File;
                if (strFileName == "off_btn.png")
                {
                    obj.MoveIcon = "on_btn.png";
                    img.Source   = "on_btn.png";
                    obj.Selected = true;
                }
                else
                {
                    obj.MoveIcon = "off_btn.png";
                    img.Source   = "off_btn.png";
                    obj.Selected = false;
                }

                await App.mvDatabase.SaveItemAsync1(obj);
            }
            catch (Exception ex)
            {
                StaticMethods.ShowToast(ex.Message);
            }
        }
コード例 #2
0
        private async void TakePictureAsync(Xamarin.Forms.Image photoImage)
        {
            System.IO.Stream imageStream = null;
            var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions
            {
                Directory          = "Test",
                Name               = "test.jpg",
                SaveToAlbum        = true,
                CompressionQuality = 75,
                CustomPhotoSize    = 100,
                PhotoSize          = PhotoSize.Large,
                MaxWidthHeight     = 2000,
                DefaultCamera      = CameraDevice.Front
            });

            if (file == null)
            {
                return;
            }

            await DisplayAlert("File Location", file.Path, "OK");

            imageStream = file.GetStream();
            BinaryReader br = new BinaryReader(imageStream);

            imageByte = br.ReadBytes((int)imageStream.Length);

            photoImage.Source = ImageSource.FromStream(() =>
            {
                var stream = file.GetStream();
                file.Dispose();
                return(stream);
            });
        }
コード例 #3
0
        public async void Media(Xamarin.Forms.Image Image1)
        {
            await CrossMedia.Current.Initialize();

            if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported)
            {
                await Dialog.AlertAsync("No Camera", ":( No camera available.", "OK");

                return;
            }

            var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions
            {
                Directory = "Sample",
                Name      = "icon.png"
            });

            if (file == null)
            {
                return;
            }

            await Dialog.AlertAsync("File Location", file.Path, "OK");

            Image1.Source = ImageSource.FromStream(() =>
            {
                var stream = file.GetStream();
                file.Dispose();
                return(stream);
            });
        }
コード例 #4
0
 protected override void OnDetachingFrom(SampleView bindable)
 {
     dataGrid   = null;
     pdfImage   = null;
     excelImage = null;
     base.OnDetachingFrom(bindable);
 }
コード例 #5
0
 /// <summary>
 /// You can override this method while View was detached from window
 /// </summary>
 /// <param name="bindAble">SampleView type of bindAble parameter</param>
 protected override void OnDetachingFrom(SampleView bindAble)
 {
     this.dataGrid   = null;
     this.pdfImage   = null;
     this.excelImage = null;
     base.OnDetachingFrom(bindAble);
 }
コード例 #6
0
ファイル: Tools.cs プロジェクト: firstArachne0116/Iroai
        public static Xamarin.Forms.Image bytesToImage(byte[] data)
        {
            var image = new Xamarin.Forms.Image();

            image.Source = ImageSource.FromStream(() => new MemoryStream(data));
            return(image);
        }
コード例 #7
0
        /// <summary>
        /// Return a stack layout with the Player information inside
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public StackLayout CreateItemDisplayBox(ItemModel data)
        {
            if (data == null)
            {
                data = new ItemModel();
            }

            // Hookup the image
            var PlayerImage = new Image
            {
                Style  = (Style)Application.Current.Resources["ImageBattleSmallStyle"],
                Source = data.ImageURI
            };

            // Put the Image Button and Text inside a layout
            var PlayerStack = new StackLayout
            {
                Style             = (Style)Application.Current.Resources["ScoreItemInfoBox"],
                HorizontalOptions = LayoutOptions.Center,
                Padding           = 0,
                Spacing           = 0,
                Children          =
                {
                    PlayerImage,
                },
            };

            return(PlayerStack);
        }
コード例 #8
0
        public FastVehicleViewModel(Map _map, Xamarin.Forms.Image imagen, Label distanceLabel, Xamarin.Forms.Image imagen2, Label distanceLabel2, Xamarin.Forms.Image imagen3, Label distanceLabel3)
        {
            try
            {
                string rnd = new Random().Next(int.MinValue, int.MaxValue).ToString();

                this._map          = _map;
                this.imagen        = imagen;
                this.distanceLabel = distanceLabel;

                this.imagen2        = imagen2;
                this.distanceLabel2 = distanceLabel2;

                this.imagen3        = imagen3;
                this.distanceLabel3 = distanceLabel3;

                //centrar el mapa en españa - madrid
                this._map.MoveToRegion(new MapSpan(new Position(40.4893538, -3.6827461), 0.05, 0.05));

                CenterMap();
            }
            catch (Exception ex)
            {
                Debug.WriteLine("FastVehicleViewModel: " + ex.Message);
            }
        }
コード例 #9
0
        public static void SetImageProperties(this Xamarin.Forms.Image imageview, Image image, RenderContext context)
        {
            switch (image.Size)
            {
            case ImageSize.Auto:
            case ImageSize.Stretch:
                imageview.VerticalOptions   = LayoutOptions.FillAndExpand;
                imageview.HorizontalOptions = LayoutOptions.FillAndExpand;
                break;

            case ImageSize.Small:
                imageview.WidthRequest  = context.Config.ImageSizes.Small;
                imageview.HeightRequest = context.Config.ImageSizes.Small;
                break;

            case ImageSize.Medium:
                imageview.WidthRequest  = context.Config.ImageSizes.Medium;
                imageview.HeightRequest = context.Config.ImageSizes.Medium;
                break;

            case ImageSize.Large:
                imageview.WidthRequest  = context.Config.ImageSizes.Large;
                imageview.HeightRequest = context.Config.ImageSizes.Large;
                break;
            }
        }
        async Task CreateTintEffectBrushAsync(Uri uri)
        {
            Xamarin.Forms.Image element = this.Element as Xamarin.Forms.Image;

            if (Control == null || Element == null || element.Width < 0 || element.Height < 0)
            {
                return;
            }

            SetupCompositor();

            spriteVisual      = compositor.CreateSpriteVisual();
            spriteVisual.Size = new Vector2((float)element.Width, (float)element.Height);

            imageSurface = await generator.CreateImageSurfaceAsync(uri, new Windows.Foundation.Size(element.Width, element.Height), ImageSurfaceOptions.DefaultOptimized);

            CompositionSurfaceBrush surfaceBrush = compositor.CreateSurfaceBrush(imageSurface.Surface);

            CompositionBrush targetBrush = surfaceBrush;

            if (this.TintColor == Color.Transparent)
            {
                // Don't apply tint effect
                effectBrush = null;
            }
            else
            {
                // Set target brush to tint effect brush

                Windows.UI.Color nativeColor = GetNativeColor(this.TintColor);

                IGraphicsEffect graphicsEffect = new CompositeEffect
                {
                    Mode    = CanvasComposite.DestinationIn,
                    Sources =
                    {
                        new ColorSourceEffect
                        {
                            Name  = "colorSource",
                            Color = nativeColor
                        },
                        new CompositionEffectSourceParameter("mask")
                    }
                };

                CompositionEffectFactory effectFactory = compositor.CreateEffectFactory(graphicsEffect,
                                                                                        new[] { "colorSource.Color" });

                effectBrush = effectFactory.CreateBrush();
                effectBrush.SetSourceParameter("mask", surfaceBrush);

                SetTint(nativeColor);

                targetBrush = effectBrush;
            }

            spriteVisual.Brush = targetBrush;
            ElementCompositionPreview.SetElementChildVisual(Control, spriteVisual);
        }
コード例 #11
0
        public override IView ConvertTo(FigmaNode currentNode, ProcessedNode parent, FigmaRendererService rendererService)
        {
            var imageView      = new Xamarin.Forms.Image();
            var figmaImageView = new FigmaSharp.Views.Forms.ImageView(imageView);

            imageView.Configure((RectangleVector)currentNode);
            return(figmaImageView);
        }
コード例 #12
0
        public static bool HasDefaultAspectAndLayoutOptions(this Xamarin.Forms.Image image)
        {
            var hasDefaultAspect           = image.Aspect == (Aspect)Xamarin.Forms.Image.AspectProperty.DefaultValue;
            var hasDefaultHorizontalLayout = image.HorizontalOptions.IsEqualTo((LayoutOptions)Xamarin.Forms.Image.HorizontalOptionsProperty.DefaultValue);
            var hasDefaultVerticalLayout   = image.VerticalOptions.IsEqualTo((LayoutOptions)Xamarin.Forms.Image.VerticalOptionsProperty.DefaultValue);

            return(hasDefaultAspect && hasDefaultHorizontalLayout && hasDefaultVerticalLayout);
        }
コード例 #13
0
 public static void SetSource(this Xamarin.Forms.Image image, string url, RenderContext context)
 {
     if (string.IsNullOrWhiteSpace(url))
     {
         return;
     }
     image.SetSource(new Uri(url));
 }
コード例 #14
0
 /// <summary>
 /// Adding Image at a position
 /// </summary>
 /// <param name="row"></param>
 /// <param name="column"></param>
 private void AddImage(int row, int column, string imageURI)
 {
     Xamarin.Forms.Image Img = new Xamarin.Forms.Image();
     Img.Source = imageURI;
     Grid.SetRow(Img, row);
     Grid.SetColumn(Img, column);
     BattleGrid.Children.Add(Img);
 }
コード例 #15
0
        /// <summary>
        /// Initialize an image button layout
        /// Add LongTapGesture recognizer for displaying pressed color and invoke click event.
        /// </summary>
        public ImageButton() : base()
        {
            var image = new Image()
            {
                Source = Source,
            };

            image.BindingContext = this;
            image.SetBinding(Image.SourceProperty, new Binding("Source"));
            image.SetBinding(Image.MinimumWidthRequestProperty, new Binding("MinWidth"));
            image.SetBinding(Image.MinimumHeightRequestProperty, new Binding("MinHeight"));

            var gestureRecognizer = new LongTapGestureRecognizer();

            //When tap event is invoked. add pressed color to image.
            gestureRecognizer.TapStarted += (s, e) =>
            {
                //change forground blend color of image
                ImageAttributes.SetBlendColor(image, Color.FromRgb(213, 228, 240));
            };

            //If tap is released. set default color to image.
            gestureRecognizer.TapCanceled += (s, e) =>
            {
                //revert forground blend color of image
                ImageAttributes.SetBlendColor(image, Color.Default);
                SendClicked();
            };

            //If tap is completed. set default color to image.
            gestureRecognizer.TapCompleted += (s, e) =>
            {
                //revert forground blend color of image
                ImageAttributes.SetBlendColor(image, Color.Default);
                SendClicked();
            };

            GestureRecognizers.Add(gestureRecognizer);

            Children.Add(
                image,
                Constraint.RelativeToParent((parent) =>
            {
                return(0);
            }),
                Constraint.RelativeToParent((parent) =>
            {
                return(0);
            }),
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Width);
            }),
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Height);
            }));
        }
コード例 #16
0
        View CreateContent(ImageCell cell)
        {
            XForm.Label text = new XForm.Label
            {
                HorizontalTextAlignment = TextAlignment.Start,
                VerticalTextAlignment   = TextAlignment.Start,
                HorizontalOptions       = LayoutOptions.FillAndExpand,
                VerticalOptions         = LayoutOptions.FillAndExpand,
                FontAttributes          = FontAttributes.Bold,
            };
            XForm.Label detailLabel = new XForm.Label
            {
                HorizontalTextAlignment = TextAlignment.Start,
                VerticalTextAlignment   = TextAlignment.Start,
                HorizontalOptions       = LayoutOptions.FillAndExpand,
                VerticalOptions         = LayoutOptions.FillAndExpand,
            };
            detailLabel.FontSize = Device.GetNamedSize(NamedSize.Micro, detailLabel);

            text.SetBinding(XForm.Label.TextProperty, new Binding("Text", source: cell));
            text.SetBinding(XForm.Label.TextColorProperty, new Binding("TextColor", source: cell));

            detailLabel.SetBinding(XForm.Label.TextProperty, new Binding("Detail", source: cell));
            detailLabel.SetBinding(XForm.Label.TextColorProperty, new Binding("DetailColor", source: cell));

            XForm.Image image = new XForm.Image
            {
                HeightRequest     = Element.ItemHeight,
                WidthRequest      = Element.ItemWidth,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                Aspect            = Aspect.Fill
            };
            image.SetBinding(XForm.Image.SourceProperty, new Binding("ImageSource", source: cell));

            var view = new AbsoluteLayout();

            view.Children.Add(image, new XForm.Rectangle(0, 0, 1, 1), AbsoluteLayoutFlags.All);
            view.Children.Add(new StackLayout
            {
                VerticalOptions   = LayoutOptions.EndAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Children          =
                {
                    new StackLayout {
                        VerticalOptions   = LayoutOptions.EndAndExpand,
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        Padding           = 15,
                        Spacing           = 0,
                        BackgroundColor   = XForm.Color.FromHex("#2b7c87"),
                        Children          = { text, detailLabel }
                    }
                }
            }, new XForm.Rectangle(0, 0, 1, 1), AbsoluteLayoutFlags.All);

            cell.SetBinding(GridView.BindingContextProperty, new Binding("BindingContext", source: view));
            return(view);
        }
コード例 #17
0
 public Xamarin.Forms.Image ShowImage(string filepath)
 {
     Xamarin.Forms.Image img = (new Xamarin.Forms.Image());                                      //Create a new Image
     byte[] imageByteArray   = File.ReadAllBytes(filepath);                                      //Make a byte array based on file specified
     imageByteArray = ImageResizer.cropPicture(imageByteArray);                                  //Crop the image to a square
     imageByteArray = ImageResizer.ResizeImage(imageByteArray, 256, 256);                        //Resize the image to 256x256
     img.Source     = ImageSource.FromStream(() => new MemoryStream(imageByteArray));            //Set and return the image
     return(img);
 }
コード例 #18
0
        /// <summary>
        /// CustomImageCell constructor to build UI controls
        /// <param name="title">The title label in this view cell</param>
        /// <param name="imageSource">The image source for the icon image in this view cell</param>
        /// <param name="page">The containing page for the table cell</param>
        /// <seealso cref="ContentPage">
        /// </summary>
        public CustomImageCell(String title, String imageSource, ContentPage page)
        {
            /// create new Relative layout for custom cell.
            listItemLayout = new RelativeLayout
            {
                HeightRequest = 120,
            };

            /// create new Image for left icon.
            menuImage = new Image
            {
                Source        = imageSource,
                WidthRequest  = 50,
                HeightRequest = 50,
            };

            /// create new Label for settings menu text.
            menuLabel = new Label
            {
                FontSize = 21,
                Text     = title,
            };

            FontFormat.SetFontWeight(menuLabel, FontWeight.Light);

            ///set x,y coordinates for aligning menu label
            listItemLayout.Children.Add(menuLabel,
                                        Constraint.RelativeToParent((parent) => (parent.X + 32 + 50 + 32)),
                                        Constraint.RelativeToParent((parent) => (.5 * parent.Height - 30)));

            ///set x,y coordinates for aligning menu icon
            listItemLayout.Children.Add(menuImage,
                                        Constraint.RelativeToParent((parent) => (parent.X + 32)),
                                        Constraint.RelativeToParent((parent) => (.5 * parent.Height - 25)));

            View = listItemLayout;

            /// add tap gesture
            this.Tapped += (s, e) =>
            {
                if (Command == null)
                {
                    // This command is used for push new page in async mode,
                    // the parameter title is title of the new page.
                    Command = new Command(async() =>
                    {
                        await page.Navigation.PushAsync(new SecondPage(title));
                    });
                }

                if (Command != null)
                {
                    Command.Execute(null);
                }
            };
        }
コード例 #19
0
 private static Action <IShadow, ImageSource> GetSetAction(IShadow <Xamarin.Forms.Element> shadow)
 {
     return(shadow.Item switch
     {
         Xamarin.Forms.Button _ => ImageSourceMappers.Button,
         Xamarin.Forms.Image _ => ImageSourceMappers.Image,
         Xamarin.Forms.ToolbarItem _ => ImageSourceMappers.ToolbarItem,
         Xamarin.Forms.ImageButton _ => ImageSourceMappers.ImageButton,
         Xamarin.Forms.ImageCell _ => ImageSourceMappers.ImageCell,
         _ => throw new ArgumentException()
     });
コード例 #20
0
        void DownloadSound(object sender, EventArgs args)
        {
            Image senderButton = sender as Image;

            if (senderButton == null)
            {
                return;
            }
            String fileName = ((ApiRecord)senderButton.BindingContext).Filename.ToString();

            DependencyService.Get <IFileSaver>().SaveFile("https://sounds.soundofgothic.pl/assets/gsounds/" + fileName.ToUpper() + ".WAV");
        }
コード例 #21
0
        private async Task <Xamarin.Forms.Image> GetImageStreamFromURL(String imageUrl)
        {
            HttpClient client = new HttpClient();

            client.MaxResponseContentBufferSize = 256000;
            //client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
            Stream stream = await client.GetStreamAsync(imageUrl);

            Xamarin.Forms.Image img = new Xamarin.Forms.Image();
            img.Source = ImageSource.FromStream(() => stream);

            return(img);
        }
コード例 #22
0
        public static void SaveImageToDisk(Xamarin.Forms.Image profile_pic)
        {
            var uri       = profile_pic.Source.GetValue(UriImageSource.UriProperty);
            var uriString = uri.ToString();

            IFileSystem fileSystem     = FileSystem.Current;
            IFolder     rootFolder     = fileSystem.LocalStorage;
            IFile       profilePicture = (PCLStorage.IFile)rootFolder.CreateFileAsync("profile_picture.png", CreationCollisionOption.ReplaceExisting);
            string      pic_path       = profilePicture.Path;

            //File.WriteAllBytes(pic_path, image_data);
            File.WriteAllText(pic_path, uriString);
        }
コード例 #23
0
ファイル: Button.cs プロジェクト: jetalabard/Xamarin_CV
        public void Init(string uri, string title, string source, string LinkTitle, bool isUrl)
        {
            CornerRadius = 10;
            Opacity      = 30;
            BorderColor  = Color.FromHex("#1B3147");
            Padding      = 0;

            StackLayout stack = new MR.Gestures.StackLayout {
                HorizontalOptions = LayoutOptions.FillAndExpand, Orientation = StackOrientation.Horizontal, Spacing = 10, Padding = new Thickness(10, 10, 10, 10), BackgroundColor = Color.Accent, VerticalOptions = LayoutOptions.FillAndExpand
            };

            Down   += (s, e) => stack.BackgroundColor = Color.FromHex("#1B3147");
            Up     += (s, e) => stack.BackgroundColor = Color.Accent;
            Tapped += (s, e) => {
                if (LinkTitle.Contains(".apk"))
                {
                    DependencyService.Get <IDownloaderManager>().Download(uri);
                }
                else if (isUrl)
                {
                    Device.BeginInvokeOnMainThread(async() =>
                    {
                        await DependencyService.Get <IAppHandler>().LaunchApp(uri);
                    });
                }
                else
                {
                    DependencyService.Get <IDownloaderManager>().Download(uri);
                }
            };

            var image = new Image
            {
                Source            = source,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                Aspect            = Aspect.AspectFill
            };

            stack.Children.Add(image);
            stack.Children.Add(new Label
            {
                FontSize          = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
                TextColor         = Color.White,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                Text = title
            });
            Content = stack;
        }
コード例 #24
0
        private void com(object sender, EventArgs e)
        {
            Xamarin.Forms.Label hj = new Xamarin.Forms.Label();
            hj.Text = ed.Text; Xamarin.Forms.Label hjj = new Xamarin.Forms.Label()
            {
                FontSize = 15, TextColor = Color.DarkBlue
            };
            hjj.Text = login.strl;
            StackLayout stk = new StackLayout();

            stk.Children.Add(hjj); stk.Children.Add(hj);
            Xamarin.Forms.Image ll = new Xamarin.Forms.Image()
            {
                Source = "pro.png", WidthRequest = 50
            };
            g.Children.Add(ll, 0, rowcount); g.Children.Add(stk, 1, rowcount); rowcount++;
        }
コード例 #25
0
        Xamarin.Forms.Image one()
        {
            con.Close(); con.Open();
            string       gh  = "SELECT * FROM product_table WHERE bar_code='" + Class1.code + "'";
            MySqlCommand cmd = new MySqlCommand(gh, con);

            reader = cmd.ExecuteReader();
            reader.Read();
            byte[] imm  = (byte[])reader["image"];
            var    img1 = new Xamarin.Forms.Image()
            {
                HorizontalOptions = LayoutOptions.Fill, Aspect = Aspect.AspectFill
            };

            img1.Source = ImageSource.FromStream(() => new MemoryStream(imm));

            return(img1);
        }
コード例 #26
0
        /// <summary>
        /// Return a stack layout for the Characters
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public StackLayout CreateCharacterDisplayBox(PlayerInfoModel data)
        {
            if (data == null)
            {
                data = new PlayerInfoModel();
            }

            // Hookup the image
            var PlayerImage = new Image
            {
                Style  = (Style)Application.Current.Resources["ImageBattleMediumStyle"],
                Source = data.ImageURI
            };

            // Add the Level
            var PlayerLevelLabel = new Label
            {
                Text                    = "Level : " + data.Level,
                Style                   = (Style)Application.Current.Resources["ValueStyleMicro"],
                HorizontalOptions       = LayoutOptions.Center,
                HorizontalTextAlignment = TextAlignment.Center,
                Padding                 = 0,
                LineBreakMode           = LineBreakMode.TailTruncation,
                CharacterSpacing        = 1,
                LineHeight              = 1,
                MaxLines                = 1,
            };

            // Put the Image Button and Text inside a layout
            var PlayerStack = new StackLayout
            {
                Style             = (Style)Application.Current.Resources["ScoreCharacterInfoBox"],
                HorizontalOptions = LayoutOptions.Center,
                Padding           = 0,
                Spacing           = 0,
                Children          =
                {
                    PlayerImage,
                    PlayerLevelLabel,
                },
            };

            return(PlayerStack);
        }
コード例 #27
0
        /// <summary>
        /// You can override this method to subscribe to AssociatedObject events and initialize properties.
        /// </summary>
        /// <param name="bindAble">SampleView type parameter as bindAble</param>
        protected override void OnAttachedTo(SampleView bindAble)
        {
            var assembly = Assembly.GetAssembly(Application.Current.GetType());

            this.dataGrid   = bindAble.FindByName <Syncfusion.SfDataGrid.XForms.SfDataGrid>("dataGrid");
            this.excelImage = bindAble.FindByName <Xamarin.Forms.Image>("excelImage");
            this.pdfImage   = bindAble.FindByName <Xamarin.Forms.Image>("pdfImage");
            this.excelImage.GestureRecognizers.Add(new TapGestureRecognizer()
            {
                Command = new Command(this.ExportToExcel)
            });
            this.pdfImage.GestureRecognizers.Add(new TapGestureRecognizer()
            {
                Command = new Command(this.ExportToPdf)
            });

            this.pdfExport   = bindAble.FindByName <StackLayout>("PdfStack");
            this.excelExport = bindAble.FindByName <StackLayout>("ExcelStack");
            this.excelExport.GestureRecognizers.Add(new TapGestureRecognizer()
            {
                Command = new Command(this.ExportToExcel)
            });
            this.pdfExport.GestureRecognizers.Add(new TapGestureRecognizer()
            {
                Command = new Command(this.ExportToPdf)
            });
#if COMMONSB
            this.pdfImage.Source   = ImageSource.FromResource("SampleBrowser.Icons.DataGrid.PdfExport.png", assembly);
            this.excelImage.Source = ImageSource.FromResource("SampleBrowser.Icons.DataGrid.ExcelExport.png", assembly);
#else
            this.pdfImage.Source   = ImageSource.FromResource("SampleBrowser.SfDataGrid.Icons.DataGrid.PdfExport.png", assembly);
            this.excelImage.Source = ImageSource.FromResource("SampleBrowser.SfDataGrid.Icons.DataGrid.ExcelExport.png", assembly);
#endif
            this.excelImage.Margin    = new Thickness(0, 0, 10, 0);
            this.exportToPdf          = bindAble.FindByName <Label>("exportToPdf");
            this.exportToPdf.Focused += this.ExportToPdf_Clicked;
            //// exportToPdf.Clicked += ExportToPdf_Clicked;

            this.exportToExcel          = bindAble.FindByName <Label>("exportToExcel");
            this.exportToExcel.Focused += this.ExportToExcel_Clicked;
            //// exportToExcel.Clicked += ExportToExcel_Clicked;

            base.OnAttachedTo(bindAble);
        }
コード例 #28
0
        private async void backgrounding()
        {
            Task <Xamarin.Forms.Image> task1 = new Task <Xamarin.Forms.Image>(one);

            task1.Start();
            Xamarin.Forms.Image cmg = await task1;
            img.Source         = cmg.Source;
            label0.Text       += reader["name"].ToString();
            label1.Text       += reader["price"].ToString();
            label2.Text       += reader["description"].ToString();
            details.Text       = reader["details"].ToString();
            specification.Text = reader["specification"].ToString();
            con.Close();
            Task <Grid> tt = new Task <Grid>(two);

            tt.Start();
            Grid sd = await tt;

            commentgrid.Children.Add(sd);
        }
コード例 #29
0
        public static Xamarin.Forms.Image GetImageFromDisk()
        {
            var filepath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "profile_pic.jpg");

            Xamarin.Forms.Image profile_pic = new Xamarin.Forms.Image {
                Source = "profile_missing.jpg"
            };

            /*
             * var profile_pic = new Image { Source = "profile_missing.jpg" };
             * if (File.Exists(filepath))
             * {
             *      profile_pic = new Image { Source = ImageSource.FromFile(filepath) };
             * }
             */
            if (File.Exists(filepath))
            {
                profile_pic = DependencyService.Get <ICameraSystem>().ShowImage(filepath);
            }
            return(profile_pic);
        }
コード例 #30
0
        public static void SetHorizontalAlignment(this UI.Image image, HorizontalAlignment alignment)
        {
            switch (alignment)
            {
            case HorizontalAlignment.Left:
                image.HorizontalOptions = LayoutOptions.Start;
                break;

            case HorizontalAlignment.Center:
                image.HorizontalOptions = LayoutOptions.Center;
                break;

            case HorizontalAlignment.Right:
                image.HorizontalOptions = LayoutOptions.End;
                break;

            default:
                image.HorizontalOptions = LayoutOptions.FillAndExpand;     //images fill available width
                break;
            }
        }
コード例 #31
0
ファイル: LoginView.cs プロジェクト: getsaurabh02/M2EMobile
        public LoginView()
        {
            BindingContext = Model;
            BackgroundColor = Color.FromRgb(173, 216, 230);

            var logo = new Image
            {
                Source = ImageSource.FromResource("M2EMobile.Resources.Images.cautom_logo.png"),
                HeightRequest = 33,
                WidthRequest = 186
            };
                        
            
            var usernameEntry = new Entry { Placeholder = "Username",TextColor = Color.Gray};
            usernameEntry.SetBinding(Entry.TextProperty, "Username");

            var passwordEntry = new Entry { IsPassword = true, Placeholder = "Password", TextColor = Color.Gray };
            passwordEntry.SetBinding(Entry.TextProperty, "Password");

            var loginButton = new Button { Text = "Login" };
            loginButton.Clicked += OnLoginClicked;

            var helpButton = new Button { Text = "Help" };
            helpButton.Clicked += OnHelpClicked;

            var facebookLoginButton = new Button {Text = "Facebook"};
            facebookLoginButton.Clicked += facebookLoginButton_Clicked;

            var grid = new Grid()
            {
                HorizontalOptions = LayoutOptions.CenterAndExpand
            };

            if (Device.OS == TargetPlatform.iOS)
            {
                grid.Children.Add(loginButton, 0, 0);
                grid.Children.Add(helpButton, 1, 0);

                Content = new StackLayout()
                {
                    VerticalOptions = LayoutOptions.StartAndExpand,
                    Padding = new Thickness(30),
                    Children = { logo, usernameEntry, passwordEntry, grid }
                };

                BackgroundImage = "login_box";

            }
            else
            {
                grid.Children.Add(logo, 0, 0);
                grid.Children.Add(helpButton, 1, 0);

                Content = new StackLayout()
                {
                    VerticalOptions = LayoutOptions.Center,
                    Padding = new Thickness(30),
                    Children = { grid, usernameEntry, passwordEntry, loginButton, facebookLoginButton },
                };
            }

        }
コード例 #32
0
ファイル: LoginPage.cs プロジェクト: Aranjedeath/SpecimenCode
        public LoginPage()
        {
            ViewModel = new BaseViewModel{};
            BindingContext = ViewModel;
            DeviceDetail.UserKey = "";
			_database = new TokenDatabase();
            
            var layout = new StackLayout { Padding = 10};
           _message = new Label
            {
                Text = "",
                FontSize = Device.GetNamedSize(NamedSize.Default, typeof(Label)),
                VerticalOptions = LayoutOptions.Center,
                XAlign = TextAlignment.Center,
                YAlign = TextAlignment.Center,
                TextColor = Color.Red
            };
            
            var imgLogoImage = new Image {Source = "ecs.png"};
            layout.Children.Add(imgLogoImage);
            
			var spacer = new Label
			{
				Text = "",
				FontSize = 15,
				XAlign = TextAlignment.Center,
				YAlign = TextAlignment.Center,

			};


            var version = new Label
            {
                Text = "Version (0.0.0.2)",
				FontFamily = "HelveticaNeue-Medium",
                FontSize = 15,
				FontAttributes = FontAttributes.Bold,
                VerticalOptions = LayoutOptions.Center,
                XAlign = TextAlignment.Center,
                YAlign = TextAlignment.Center,
                
            };
			layout.Children.Add (spacer);
            layout.Children.Add(version);

            _username = new Entry { Placeholder = "Username"};
            layout.Children.Add(_username);
            
            _password = new Entry { Placeholder = "Password", IsPassword = true };
            layout.Children.Add(_password);

            loginButton = new Button { Text = "Sign In" };
            loginButton.Clicked += async (sender, args) => await ValidateUser(_username.Text, _password.Text);
            layout.Children.Add(loginButton);
            layout.Children.Add(_message);

            
            // here's your activity indicator, it's bound to the IsBusy property of the BaseViewModel
            // those bindings are on both the visibility property as well as the IsRunning property
            var activityIndicator = new ActivityIndicator
            {
                Color = Color.Black
            };
            activityIndicator.SetBinding(ActivityIndicator.IsVisibleProperty, "IsBusy");
            activityIndicator.SetBinding(ActivityIndicator.IsRunningProperty, "IsBusy");
            layout.Children.Add(activityIndicator);

            var placeHolder = new Label
            {
                Text = "This software is proprietary and confidential to ECS and by using this software you agree that no part of the document that you would view may be disclosed in any manner to a third party without the prior written consent.",
                FontSize = Device.GetNamedSize(NamedSize.Default, typeof (Label)),
                VerticalOptions = LayoutOptions.Center,
                TextColor = Color.Black
            };
            layout.Children.Add(placeHolder);
            
            Content = new ScrollView()
            {
                Padding = 10,
                VerticalOptions = LayoutOptions.Start,
                Content = layout
                
            };
           

        }
コード例 #33
0
        private void SubscribeToResizeMessages()
        {
            MessagingCenter.Subscribe<IResizeImage, ImageAndThumbnailLocation>(this, "otherPartyDamageWantsResizedPics", (theResizer, pictureString) =>
            {

                imagesAndthumbs.Add(pictureString);

                Image Image = new Image();
                //add image tap to dropdown Modal and pass full size image (maybe)
                Image.GestureRecognizers.Add(new TapGestureRecognizer
                {
                    NumberOfTapsRequired = 1,
                    Command = new Command(x =>
                    {
                        var thePhotoSelected =
                            allPhotos.Where(img => img.Filename == pictureString.ImageLocation).FirstOrDefault();
                        Navigation.PushModalAsync(new ImageModal(pictureString.ImageLocation, _callingPageIdentification, thePhotoSelected));
                    })
                });

                Image.Source = ImageSource.FromFile(pictureString.ThumbnailLocation);
                OtherPartyAccidentPhotoStackLayout.Children.Add(Image);

            });
        }
コード例 #34
0
        public async Task<Stream> PclStorageStreamAsync(string url)
        {
            try
            {
                IFile imageFile = await FileSystem.Current.GetFileFromPathAsync(url);

                var photoStream = imageFile.OpenAsync(FileAccess.Read).Result;
                var webImage = new Image { Aspect = Aspect.AspectFit };
                webImage.Source = ImageSource.FromUri(new Uri(url));
                return photoStream;

            }
            catch (Exception)
            {
                return null;
            }
        }