Пример #1
0
        private SvgIconTarget(string iconName, string iconFile)
        {
            IconName = iconName;
            IconFile = iconFile;


            ResourceFile = (string)ImageEnumEmbeddedResourceConverter.Convert(iconFile, null, null, null);

            ImageSource  = new EmbeddedResourceImageSource(new Uri(ResourceFile));
            ImageSource2 = SvgImageSource.FromSvgResource(ResourceFile);
        }
        public ButtonsViewModel()
        {
            LeftCommand       = new Command(Left);
            RightCommand      = new Command(Right);
            ThrottleCommand   = new Command(Throttle);
            StopCommand       = new Command(Stop);
            SwitchViewCommand = new Command(async() => await Switch());

            //specify resource's path
            LeftImage     = SvgImageSource.FromSvgResource("Images.left.svg");
            RightImage    = SvgImageSource.FromSvgResource("Images.right.svg");
            ThrottleImage = SvgImageSource.FromSvgResource("Images.throttle.svg");
            StopImage     = SvgImageSource.FromSvgResource("Images.stop.svg");

            X = 0;
            Y = 0;
            Z = 0;
        }
Пример #3
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null)
            {
                return(null);
            }

            string imageName = $"Resources.{value.ToString()}";
            int?   size      = null;

            if (parameter != null)
            {
                size = int.Parse(parameter.ToString());
            }
            if (size.HasValue)
            {
                return(SvgImageSource.FromSvgResource(imageName, size.Value, size.Value));
            }
            else
            {
                return(SvgImageSource.FromSvgResource(imageName));
            }
        }