예제 #1
0
		public void TestConstructors ()
		{
			var filesource = new FileImageSource { File = "File.png" };
			Assert.AreEqual ("File.png", filesource.File);

			Func<CancellationToken, Task<Stream>> stream = token => new Task<Stream> (() => new FileStream ("Foo", System.IO.FileMode.Open), token);
			var streamsource = new StreamImageSource { Stream = stream };
			Assert.AreEqual (stream, streamsource.Stream);
		}
예제 #2
0
			public RoundedButton(int radius)
			{
				base.BorderRadius = radius;
				base.WidthRequest = 2 * radius;
				base.HeightRequest = 2 * radius;
				HorizontalOptions = LayoutOptions.Center;
				VerticalOptions = LayoutOptions.Center;
				BackgroundColor = Color.Aqua;
				BorderColor = Color.White;
				TextColor = Color.Purple;
				Text = "YAY";
				Image = new FileImageSource { File = "crimson.jpg" };
			}
예제 #3
0
        public ChartsPage()
        {
            ActivityIndicator indicator = new ActivityIndicator()
            {
                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.Center,
                IsRunning         = true,
                IsVisible         = true
            };

            indicator.SetBinding(ActivityIndicator.IsRunningProperty, "IsBusy");
            indicator.SetBinding(ActivityIndicator.IsVisibleProperty, "IsBusy");

            Task.WhenAll(Takingcareofbussiness());

            Title = "ChartPage";
            Icon  = new FileImageSource {
                File = "robot.png"
            };
            NavigationPage.SetBackButtonTitle(this, "go back");

            chart = new SfChart();

            //Initializing Primary Axis
            CategoryAxis primaryAxis = new CategoryAxis
            {
                Title = new ChartAxisTitle()
                {
                    Text = "Date"
                }
            };

            //Initializing Secondary Axis
            NumericalAxis secondaryAxis = new NumericalAxis
            {
                Title = new ChartAxisTitle()
                {
                    Text = "Transaction"
                }
            };

            //defining each of the axis used for the graphical representations.
            chart.PrimaryAxis   = primaryAxis;
            chart.SecondaryAxis = secondaryAxis;

            chart.Title = new ChartTitle()
            {
                Text = "Transaction Chart"
            };
        }
예제 #4
0
        public JobListPage()
        {
            Title = "Jobs";
            Icon  = new FileImageSource {
                File = "sales.png"
            };

            var view = new JobListView();

            view.ItemSelected += ItemSelected;
            view.RowHeight     = 80;
            view.ItemsSource   = GetJobs();
            Content            = view;
        }
예제 #5
0
        public async Task <IImage> GetImage(FileImageSource file, CancellationToken token)
        {
            var handler = new FileImageSourceHandler();
            var bitmap  = await handler.LoadImageAsync(file, Forms.Context, token);

            if (bitmap == null)
            {
                return(null);
            }

            var image = new BitmapImage(bitmap, _scale);

            return(image);
        }
예제 #6
0
        public GuiaPage(string puertaId)
        {
            InitializeComponent();

            AudioList listaAudios = new AudioList();

            Puerta = puertaId;

            switch (puertaId)
            {
            case "Puerta1":
                Title = "Guía - Puerta 1";
                AudiosListView.ItemsSource = listaAudios.List(1);
                Ruta.Source = "Ruta1.png";
                break;

            case "Puerta2":
                Title = "Guía - Puerta 2";
                AudiosListView.ItemsSource = listaAudios.List(2);
                Ruta.Source = "Ruta2.png";
                break;

            case "Puerta3":
                Title = "Guía - Puerta 3";
                AudiosListView.ItemsSource = listaAudios.List(3);
                Ruta.Source = "Ruta3.png";
                break;

            case "Puerta4":
                Title = "Guía - Puerta 4";
                AudiosListView.ItemsSource = listaAudios.List(4);
                Ruta.Source = "Ruta4.png";
                break;

            case "Puerta5":
                Title = "Guía - Puerta 5";
                AudiosListView.ItemsSource = listaAudios.List(5);
                Ruta.Source = "Ruta5.png";
                break;
            }

            pauseImage = new FileImageSource {
                File = "icono_pausa.png"
            };
            playImage = new FileImageSource {
                File = "icono_play.png"
            };

            SetTimer();
        }
예제 #7
0
        public async Task <IImage> GetImage(FileImageSource file, CancellationToken token)
        {
            var handler     = new FileImageSourceHandler();
            var nativeImage = await handler.LoadImageAsync(file, token);

            if (nativeImage == null)
            {
                return(null);
            }

            var image = new CGImageImage(nativeImage.CGImage, _scale);

            return(image);
        }
예제 #8
0
        /// <summary>
        /// Helper method to serialize <see cref="ImageSource" /> objects.
        /// </summary>
        public static string ImageSourceToString(ImageSource imageSource)
        {
            if (imageSource is null)
            {
                throw new ArgumentNullException(nameof(imageSource));
            }

            return(imageSource switch
            {
                FileImageSource fileImageSource => string.Format(CultureInfo.InvariantCulture, "{0}:{1}", FileImageSourcePrefix, fileImageSource.File),
                FontImageSource fontImageSource => SerializeFontImageSource(fontImageSource),
                UriImageSource uriImageSource => string.Format(CultureInfo.InvariantCulture, "{0}:{1}", UriImageSourcePrefix, uriImageSource.Uri.ToString()),
                _ => throw new NotSupportedException($"Unsupported ImageSource type: {imageSource.GetType().FullName}."),
            });
예제 #9
0
        public RefreshButton()
        {
            string folder = "";

#if __UWP__
            folder = "Assets/";
#endif
            Source = new FileImageSource {
                File = folder + "icon_refresh.png"
            };
            ImagePadding    = 5;
            BackgroundColor = Colors.CartoNavyTransparentDark;
            CornerRadius    = 5;
        }
예제 #10
0
        /// <inheritdoc />
        protected override void SetTabIcon(TabLayout.Tab tab, FileImageSource icon)
        {
            var iconize = Iconize.FindIconForKey(icon.File);

            if (!(iconize is null))
            {
                var drawable = new IconDrawable(Context, icon).SizeDp(20);
                DrawableCompat.SetTintList(drawable, GetItemIconTintColorState());
                tab.SetIcon(drawable);
                return;
            }

            base.SetTabIcon(tab, icon);
        }
예제 #11
0
        public ForecastView()
        {
            InitializeComponent();
            if (Device.RuntimePlatform == Device.iOS)
            {
                Icon = new FileImageSource {
                    File = "tab2.png"
                }
            }
            ;

            ListViewWeather.ItemTapped += (sender, args) => ListViewWeather.SelectedItem = null;
        }
    }
예제 #12
0
     public MainPageMaster()
     {
         InitializeComponent();
         if (Device.RuntimePlatform == Device.iOS)
         {
             Icon = new FileImageSource()
             {
                 File = "ic_menu_white_2.png"
             }
         }
         ;
         ListView = MenuItemsListView;
     }
 }
        public WeatherView()
        {
            InitializeComponent();

            SetupEvents();

            if (Device.OS == TargetPlatform.iOS)
            {
                Icon = new FileImageSource {
                    File = "tab1.png"
                }
            }
            ;
        }
예제 #14
0
        protected virtual void UpdateMenuItemIcon(Context context, IMenuItem menuItem, ToolbarItem toolBarItem)
        {
            FileImageSource icon = toolBarItem.Icon;

            if (!string.IsNullOrEmpty(icon))
            {
                Drawable iconDrawable = context.GetFormsDrawable(icon);
                if (iconDrawable != null)
                {
                    menuItem.SetIcon(iconDrawable);
                    iconDrawable.Dispose();
                }
            }
        }
예제 #15
0
        void ImageClicked(object s, EventArgs e)
        {
            Image           image       = s as Image;
            FileImageSource imageSource = (FileImageSource)image.Source;


            foreach (RemoteController rc in App.dataRepository.remoteControllers)
            {
                if ((FileImageSource)"RemoteControllers/" + rc.ImageName + "/" + rc.ImageName == imageSource)
                {
                    Navigation.PushAsync(new RemoteControllerSelectedPage(rc));
                }
            }
        }
예제 #16
0
        public PrescriptionView()
        {
            InitializeComponent();
            if (Device.RuntimePlatform != Device.UWP)
            {
                Icon = new FileImageSource {
                    File = "prescription.png"
                }
            }
            ;

            MyListView.ItemTapped += (sender, args) => MyListView.SelectedItem = null;
        }
    }
예제 #17
0
        private void SliderAchivedGoals_OnValueChanged(object sender, ValueChangedEventArgs e)
        {
            LabelAchivedGoals.Text = FormatHelpers.FormatSliderValue(e.NewValue, StepValue);

            FileImageSource objFileImageSource = (FileImageSource)ImageAchivedGoals.Source;

            string currentFile = objFileImageSource.File;
            string smiley      = SmileyHelper.GetSmileyImage(e.NewValue);

            if (currentFile != smiley)
            {
                ImageAchivedGoals.Source = smiley;
            }
        }
예제 #18
0
        public object ProvideValue(IServiceProvider serviceProvider)
        {
            if (Source == null)
            {
                return(null);
            }
            // Do your translation lookup here, using whatever method you require
            var imageSource = new FileImageSource()
            {
                File = "WorkoutPlaner.Images." + Source
            };

            return(imageSource);
        }
예제 #19
0
 private static Stream GetStreamFromFileImageSource(ImageSource imageSource)
 {
     lock (locker)
     {
         FileImageSource fileImageSource = (FileImageSource)imageSource;
         using (var file = File.Open(fileImageSource.File, FileMode.Open, FileAccess.Read, FileShare.Read))
         {
             MemoryStream memStream = new MemoryStream();
             memStream.SetLength(file.Length);
             file.Read(memStream.GetBuffer(), 0, (int)file.Length);
             return(memStream);
         }
     }
 }
예제 #20
0
        public void TestFileImageSourcePropertiesChangedTriggerResize()
        {
            var source = new FileImageSource();
            var image  = new Image {
                Source = source
            };
            bool fired = false;

            image.MeasureInvalidated += (sender, e) => fired = true;
            Assert.Null(source.File);
            source.File = "foo.png";
            Assert.NotNull(source.File);
            Assert.True(fired);
        }
예제 #21
0
        public PlatformBitmapsPage()
        {
            FileImageSource imgSrc = new FileImageSource();

            switch (Device.RuntimePlatform)
            {
            case Device.iOS:
                imgSrc.File = "Icon-Small-40.png";
                break;

            case Device.Android:
                imgSrc.File = "icon.png";
                break;

            case Device.WinRT:
            case Device.WinPhone:
            case Device.UWP:
                imgSrc.File = "Assets/StoreLogo.png";
                break;
            }

            Image image = new Image
            {
                Source            = imgSrc,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.CenterAndExpand
            };

            Label label = new Label
            {
                FontSize          = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.CenterAndExpand
            };

            image.SizeChanged += (sender, args) =>
            {
                label.Text = String.Format("Rendered size = {0} x {1}",
                                           image.Width, image.Height);
            };

            Content = new StackLayout
            {
                Children =
                {
                    image,
                    label
                }
            };
        }
예제 #22
0
        // 从相册检测。
        private void detect(string filePath)
        {
            FileImageSource fileImageSource = new FileImageSource();

            fileImageSource.setFilePath(filePath);
            detectManager.setImageSource(fileImageSource);
            detectManager.setUseDetect(true);
            //            detectManager.setOnFaceDetectListener(new FaceDetectManager.OnFaceDetectListener()
            //            {


            //            public void onDetectFace(int status, FaceInfo[] faces, ImageFrame frame)
            //            {
            //                if (faces != null && status != FaceTracker.ErrCode.NO_FACE_DETECTED.ordinal()
            //                        && status != FaceTracker.ErrCode.UNKNOW_TYPE.ordinal())
            //                {
            //                    final Bitmap cropBitmap = FaceCropper.getFace(frame.getArgb(), faces[0], frame.getWidth());
            //                    handler.post(new Runnable()
            //                    {


            //                        public void run()
            //                    {
            //                        avatarIv.setImageBitmap(cropBitmap);
            //                    }
            //                });

            //            // File file = File.createTempFile(UUID.randomUUID().toString() + "", ".jpg");
            //            File faceDir = FileUitls.getFaceDirectory();
            //            if (faceDir != null)
            //            {
            //                String imageName = UUID.randomUUID().toString();
            //                File file = new File(faceDir, imageName);
            //                // 压缩人脸图片至300 * 300,减少网络传输时间
            //                ImageUtils.resize(cropBitmap, file, 300, 300);
            //                RegActivity.this.faceImagePath = file.getAbsolutePath();
            //                submitButton.setVisibility(View.VISIBLE);
            //            }
            //            else
            //            {
            //                toast("注册人脸目录未找到");
            //            }
            //        } else {
            //                    toast("未检测到人脸,可能原因:人脸太小(必须大于最小检测人脸minFaceSize),或者人脸角度太大,人脸不是朝上");
            //    }
            //}
            //        });
            detectManager.start();
        }
        public TodoItemCell()
        {
            var label = new Label {
                YAlign            = TextAlignment.Center,
                HorizontalOptions = LayoutOptions.StartAndExpand,
                Font = Constants.Font
            };

            label.SetBinding(Label.TextProperty, "Name");
            if (Device.OS != TargetPlatform.iOS)               // WinPhone & Android
            {
                label.TextColor = Color.Black;
            }

            var tick = new Image {
                Source            = FileImageSource.FromFile("check1.png"),
                HorizontalOptions = LayoutOptions.EndAndExpand
            };

            tick.SetBinding(Image.IsVisibleProperty, "Done");

            var layout = new StackLayout {
                Padding           = new Thickness(10, 0, 10, 0),
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.StartAndExpand,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                Children          = { label, tick },
            };

            var lineLayout = new StackLayout {
                Orientation       = StackOrientation.Vertical,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                Children          =
                {
                    layout,
                    new BoxView {
                        HeightRequest   = 1,
                        WidthRequest    = 600,
                        VerticalOptions = LayoutOptions.End,
                        Color           = Constants.Brown,
                        Opacity         = 0.5
                    }
                },
                BackgroundColor = Color.FromRgb(255, 244, 165)
            };

            View = lineLayout;
        }
예제 #24
0
        public void PrioridadeSelectAction(object sender, EventArgs args)
        {
            var Stacks = SLPrioridades.Children;

            foreach (var Linha in Stacks)
            {
                Label LblPrioridade = ((StackLayout)Linha).Children[1] as Label;
                LblPrioridade.TextColor = Color.Gray;
            }
            ((Label)((StackLayout)sender).Children[1]).TextColor = Color.Black;
            FileImageSource Source     = ((Image)((StackLayout)sender).Children[0]).Source as FileImageSource;
            String          Prioridade = Source.File.ToString().Replace("Resources/p", "").Replace(".png", "");

            this.Prioridade = byte.Parse(Prioridade);
        }
예제 #25
0
        public void TestConstructors()
        {
            var filesource = new FileImageSource {
                File = "File.png"
            };

            Assert.AreEqual("File.png", filesource.File);

            Func <CancellationToken, Task <Stream> > stream = token => new Task <Stream>(() => new FileStream("Foo", System.IO.FileMode.Open), token);
            var streamsource = new StreamImageSource {
                Stream = stream
            };

            Assert.AreEqual(stream, streamsource.Stream);
        }
예제 #26
0
        private void TapGestureRecognizer_Tapped(object sender, System.EventArgs e)
        {
            var stacks = slPrioridades.Children;

            foreach (var item in stacks)
            {
                Label label = ((StackLayout)item).Children[1] as Label;
                label.TextColor = Color.Gray;
            }
            ((Label)((StackLayout)sender).Children[1]).TextColor = Color.Black;
            FileImageSource img = ((Image)((StackLayout)sender).Children[0]).Source as FileImageSource;
            string          s   = img.File.ToString().Replace(".png", "").Replace("p", "").Replace("Resources/", "");

            p = byte.Parse(s);
        }
예제 #27
0
		public void TestBindingContextPropagationOnImageCell ()
		{
			var context = new object ();
			var cell = new ImageCell ();
			cell.BindingContext = context;
			var source = new FileImageSource ();
			cell.ImageSource = source;
			Assert.AreSame (context, source.BindingContext);

			cell = new ImageCell ();
			source = new FileImageSource ();
			cell.ImageSource = source;
			cell.BindingContext = context;
			Assert.AreSame (context, source.BindingContext);
		}
예제 #28
0
        static public FormsCAKeyFrameAnimation CreateAnimationFromFileImageSource(FileImageSource imageSource)
        {
            FormsCAKeyFrameAnimation animation = null;
            string file = imageSource?.File;

            if (!string.IsNullOrEmpty(file))
            {
                using (var parsedImageSource = CGImageSource.FromUrl(NSUrl.CreateFileUrl(file, null)))
                {
                    animation = ImageAnimationHelper.CreateAnimationFromCGImageSource(parsedImageSource);
                }
            }

            return(animation);
        }
예제 #29
0
        private static void ImagePropertyChanged(BindableObject bindable, object oldValue, object newValue)
        {
            if (bindable == null || string.IsNullOrEmpty((string)newValue))
            {
                return;
            }

            var button = ((ButtonBadge)bindable).button;
            var c      = new FileImageSource
            {
                File = (string)newValue
            };

            button.Image = c;
        }
        private void TapGestureRecognizer_Tapped(object sender, EventArgs e)
        {
            var Stacks = slPrioridades.Children;

            foreach (var Linha in Stacks)
            {
                Label lblPrioridade = ((StackLayout)Linha).Children[1] as Label;
                lblPrioridade.TextColor = Color.Gray;
            }

            ((Label)((StackLayout)sender).Children[1]).TextColor = Color.Black;
            FileImageSource Source = ((Image)((StackLayout)sender).Children[0]).Source as FileImageSource;

            Prioridade = Byte.Parse(Source.File.ToString().Substring(1, 1));
        }
예제 #31
0
        public void SetImage(String fileName)
        {
            Xamarin.Forms.Device.BeginInvokeOnMainThread(
                () =>
            {
                var imageSource          = new FileImageSource();
                imageSource.File         = fileName;
                this.DisplayImage.Source = imageSource;
#if __MACOS__
                NSImage image = new NSImage(fileName);
                this.DisplayImage.WidthRequest  = image.Size.Width;
                this.DisplayImage.HeightRequest = image.Size.Height;
#endif
            });
        }
        public WeatherView()
        {
            InitializeComponent();

            if (Device.OS == TargetPlatform.iOS)
            {
                Icon = new FileImageSource {
                    File = "tab1.png"
                }
            }
            ;

            // Background.Source = ImageSource.FromResource("MyWeather.cloud.jpg");
        }
    }
예제 #33
0
        internal static Drawable GetFormsDrawable(this Resources resource, FileImageSource fileImageSource)
        {
            var      file     = fileImageSource.File;
            Drawable drawable = resource.GetDrawable(fileImageSource);

            if (drawable == null)
            {
                var bitmap = GetBitmap(resource, file) ?? BitmapFactory.DecodeFile(file);
                if (bitmap != null)
                {
                    drawable = new BitmapDrawable(resource, bitmap);
                }
            }
            return(drawable);
        }
예제 #34
0
		public void TestFileImageSourcePropertiesChangedTriggerResize ()
		{
			var source = new FileImageSource ();
			var image = new Image { Source = source };
			bool fired = false;
			image.MeasureInvalidated += (sender, e) => fired = true;
			Assert.Null (source.File);
			source.File = "foo.png";
			Assert.NotNull (source.File);
			Assert.True (fired);
		}