コード例 #1
0
		public ImageLoadingGallery ()
		{
			Padding = new Thickness (20);

			var source = new UriImageSource {
				Uri = new Uri ("http://www.nasa.gov/sites/default/files/styles/1600x1200_autoletterbox/public/images/298773main_EC02-0282-3_full.jpg"),
				CachingEnabled = false
			};

			var image = new Image {
				Source = source,
				WidthRequest = 200,
				HeightRequest = 200,
			};

			var indicator = new ActivityIndicator {Color = new Color (.5),};
			indicator.SetBinding (ActivityIndicator.IsRunningProperty, "IsLoading");
			indicator.BindingContext = image;

			var grid = new Grid();
			grid.RowDefinitions.Add (new RowDefinition());
			grid.RowDefinitions.Add (new RowDefinition());

			grid.Children.Add (image);
			grid.Children.Add (indicator);

			var cancel = new Button { Text = "Cancel" };
			cancel.Clicked += (s, e) => source.Cancel();
			Grid.SetRow (cancel, 1);
			grid.Children.Add (cancel);

			Content = grid;
		}
コード例 #2
0
        public SpeakerPage()
        {
            InitializeComponent();
            viewModel      = App.SimpleIoC.Resolve <SpeakersViewModel> ();
            BindingContext = viewModel;

            if (viewModel.CurrentSpeaker.HeadshotUrl.Length > 0)
            {
                try
                {
                    var photo = new CircleImage
                    {
                        BorderColor       = Color.White,
                        BorderThickness   = 3,
                        HeightRequest     = 75,
                        WidthRequest      = 75,
                        Aspect            = Aspect.AspectFill,
                        HorizontalOptions = LayoutOptions.Center,
                        Source            = UriImageSource.FromUri(new Uri(viewModel.CurrentSpeaker.HeadshotUrl))
                                            //Source = UriImageSource.FromFile("TeamMirMaheed")
                                            //Source = UriImageSource.FromUri (new Uri ("http://upload.wikimedia.org/wikipedia/commons/5/55/Tamarin_portrait.JPG"))
                    };
                    stackCircles.Children.Clear();
                    stackCircles.Children.Add(photo);
                }
                catch (Exception exc)
                {
                }
            }
        }
コード例 #3
0
        public async Task <SKSvg> LoadImageAsync(ImageSource imageSource,
                                                 CancellationToken cancellationToken = new CancellationToken())
        {
            SKSvg          loader = new SKSvg();
            UriImageSource source = imageSource as UriImageSource;
            HttpClient     client = new HttpClient();

            using (client)
            {
                HttpResponseMessage response = await client.GetAsync(source.Uri, cancellationToken)
                                               .ConfigureAwait(false);

                Stream stream = await response.Content.ReadAsStreamAsync()
                                .ConfigureAwait(false);

                using (stream)
                {
                    if (stream != null)
                    {
                        loader.Load(stream);
                    }
                }
            }

            return(loader);
        }
コード例 #4
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (targetType != typeof(ImageSource))
            {
                throw new InvalidOperationException("Invalid target type.");
            }

            try
            {
                /*
                 *  Image image = new Image();
                 *  Stream stream = new MemoryStream(byteArray);
                 *  image.Source = ImageSource.FromStream(stream);
                 */
                Uri         uri       = new Uri(value.ToString());
                ImageSource imgSource = UriImageSource.FromUri(uri);
                return(imgSource);
                //return ImageSource.FromUri(new Uri(value.ToString(), UriKind.RelativeOrAbsolute));
                //return GetImageStreamFromURL(value.ToString());
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
コード例 #5
0
        static public ImageSource FromUri(String filename)
        {
            try
            {
                if (filename != "")
                {
                    ImageSource retVal = null;
                    bool        hit    = cache.TryGetValue(filename, out retVal);

                    if (!hit)
                    {
                        retVal = new UriImageSource
                        {
                            CachingEnabled = true,
                            CacheValidity  = new TimeSpan(30, 0, 0, 0),
                            Uri            = new Uri(filename)
                        };
                        cache[filename] = retVal;
                    }
                    return(retVal);
                }
                else
                {
                    return("");
                }
            }
            catch (Exception ex)
            {
                Shared.Services.Logs.Insights.Send("ImageFromUri", ex);
                return("");
            }
        }
コード例 #6
0
        public LoadingPlaceholder()
        {
            Padding = new Thickness(20);
            Title   = "Image Loading Gallery";

            var source = new UriImageSource {
                Uri            = new Uri("http://www.nasa.gov/sites/default/files/styles/1600x1200_autoletterbox/public/images/298773main_EC02-0282-3_full.jpg"),
                CachingEnabled = false
            };

            var image = new Image {
                Source        = source,
                WidthRequest  = 200,
                HeightRequest = 200,
            };

            var indicator = new ActivityIndicator {
                Color = new Color(.5),
            };

            indicator.SetBinding(ActivityIndicator.IsRunningProperty, "IsLoading");
            indicator.BindingContext = image;

            var grid = new Grid();

            grid.RowDefinitions.Add(new RowDefinition());


            grid.Children.Add(image);
            grid.Children.Add(indicator);


            Content = grid;
        }
コード例 #7
0
        private async void Load(CityMapProxy city)
        {
            using (var client = new HttpClient())
            {
                var url      = "http://api.openweathermap.org/data/2.5/weather?id=" + city.Id + "&APPID=8e44fd2ad82d53c04469e467010eb7b3&units=metric&lang=es";
                var jsonText = await client.GetStringAsync(url);

                var data = OpenWeatherMapProxy.FromJson(jsonText);

                Description.Text = data.Weather[0].Description;
                Temperature.Text = data.Main.Temp + "°C";



                //LastUpdate.Text = String.Format("{0:G}", (new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).AddSeconds(data.Dt));
                TemperatureMin.Text = "Min: " + data.Main.TempMin + " °C";
                TemperatureMax.Text = "Max: " + data.Main.TempMax + " °C";
                Temperature.Text    = data.Main.Temp + " °C";
                Pressure.Text       = data.Main.Pressure + " Pascales";
                Humidity.Text       = data.Main.Humidity + " %";


                //Sunrise.Text = String.Format("{0:T}", (new DateTime(1970, 1, 1)).AddSeconds(data.Sys.Sunrise));
                //Sunset.Text = String.Format("{0:T}", (new DateTime(1970, 1, 1)).AddSeconds(data.Sys.Sunset));


                var            iconUrl = "http://openweathermap.org/img/w/" + data.Weather[0].Icon + ".png";
                UriImageSource source  = new UriImageSource();
                source.Uri  = new Uri(iconUrl);
                Logo.Source = source;


                //Logo.Source = ImageSource.FromResource("WeatherApp.Assets.WeatherIcons." + data.Weather[0].Icon + ".png");
            }
        }
コード例 #8
0
        public BaseViewModel()
        {
            if (App.LoginResponse.basicInfo.ImageUrl != null && App.LoginResponse.basicInfo.ImageUrl != "NA" && App.LoginResponse.basicInfo.ImageUrl != "defaultIcon.png")
            {
                //String url = App.LoginResponse.basicInfo.ImageUrl != null ? App.LoginResponse.basicInfo.ImageUrl : "defaultIcon.png";
                //string[] values = url.Split(new string[] { "http" }, StringSplitOptions.None);

                //String finalUrl;

                //if (values.Length > 2)
                //{
                //    String tempUrl = "http" + values[values.Length - 1];

                //    finalUrl = tempUrl.Substring(0, tempUrl.Length - 5);
                //}
                //else
                //{
                //    finalUrl = "http" + values[values.Length - 1];
                //}


                ImageSource = new UriImageSource {
                    CachingEnabled = true, Uri = new System.Uri(App.LoginResponse.basicInfo.ImageUrl)
                };
            }

            //PlaceHolderImageSource = "defaultIcon.png";
        }
コード例 #9
0
ファイル: GlideExtensions.cs プロジェクト: MSiccDev/glidex
        static RequestBuilder HandleUriImageSource(RequestManager request, UriImageSource source)
        {
            var url = source.Uri.OriginalString;

            Forms.Debug("Loading `{0}` as a web URL", url);
            return(request.Load(url));
        }
コード例 #10
0
 protected override void OnAppearing()
 {
     try
     {
         txt_nav_username.Text = Application.Current.Properties["username"].ToString().ToUpper();
         if (Application.Current.Properties["role"].ToString() == "Student")
         {
             try
             {
                 if (Application.Current.Properties["userno"].ToString().Length > 1)
                 {
                     img_nav_photo.Source = UriImageSource.FromUri(new Uri(Libraries.MobileConfig.GetPhotoAddress(Application.Current.Properties["campus"].ToString()) +
                                                                           Application.Current.Properties["userno"] + "_photo.jpg"));
                 }
                 else
                 {
                     img_nav_photo.Source = "no_photo.png";
                 }
             }
             catch (Exception)
             {
                 img_nav_photo.Source = "no_photo.png";
             }
         }
         else
         {
             img_nav_photo.Source = "no_photo.png";
         }
     }
     catch (Exception) { }
     base.OnAppearing();
 }
コード例 #11
0
 public static UriImageSource Uri(this UriImageSource source, Uri uri, bool enabled, TimeSpan timeSpan)
 {
     source.Uri            = uri;
     source.CachingEnabled = enabled;
     source.CacheValidity  = timeSpan;
     return(source);
 }
コード例 #12
0
        private async void TakePicture_Clicked(object sender, EventArgs e)
        {
            if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported)
            {
                await DisplayAlert("No Camera", ":( No camera avaliable.", "OK");

                return;
            }

            var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions
            {
                DefaultCamera      = Plugin.Media.Abstractions.CameraDevice.Front,
                Directory          = "Moodify",
                Name               = $"{DateTime.UtcNow}.jpg",
                CompressionQuality = 92
            });

            if (file == null)
            {
                return;
            }


            var imageSource = new UriImageSource {
                Uri = new Uri("http://lorempixel.com/1920/1080/foods/2/")
            };

            image.Source = imageSource;
            //image.Source = ImageSource.FromStream(() =>
            //{
            //    var stream = file.GetStream();
            //    file.Dispose();
            //    return stream;
            //});
        }
コード例 #13
0
        public Task <Windows.UI.Xaml.Media.ImageSource> LoadImageAsync(ImageSource imagesoure, CancellationToken cancelationToken)
        {
            //BitmapImage bitmapImage = null;
            //UriImageSource uriImageSource = imagesoure as UriImageSource;
            //if (uriImageSource != null && uriImageSource.Uri != null)
            //{
            //    using (Stream stream = await uriImageSource.GetStreamAsync(cancelationToken))
            //    {
            //        if (stream != null && stream.CanRead)
            //        {
            //            IRandomAccessStream inMemoryStream = new InMemoryRandomAccessStream();
            //            using (var inputStream = stream.AsInputStream())
            //            {
            //                await RandomAccessStream.CopyAsync(inputStream, inMemoryStream);
            //            }
            //            inMemoryStream.Seek(0);

            //            bitmapImage = new BitmapImage();
            //            bitmapImage.SetSource(inMemoryStream);
            //        }
            //    }
            //}
            //return bitmapImage;
            Windows.UI.Xaml.Media.ImageSource bitmapImage = null;
            UriImageSource fileImageSource = imagesoure as UriImageSource;

            if (fileImageSource != null)
            {
                bitmapImage = new BitmapImage(fileImageSource.Uri);
            }
            return(Task.FromResult(bitmapImage));
        }
コード例 #14
0
ファイル: HUD.xaml.cs プロジェクト: Captain97r/Assistant
        private async void OnItem_Clicked(object source, EventArgs e)
        {
            try
            {
                Frame frame   = (Frame)source;
                Image content = (Image)frame.Content;

                if (content.Source != null)
                {
                    UriImageSource uri_source = (UriImageSource)content.Source;
                    Uri            uri        = (Uri)uri_source.Uri;

                    foreach (Item item in ImageList.Values)
                    {
                        if (item != null)
                        {
                            if (String.Equals(uri, item.image))
                            {
                                string action = await DisplayActionSheet(item.name, "Отмена", null, "Убрать в рюкзак", "Выбросить нахуй", "Информация");

                                ItemAction(action, item, content.AutomationId, frame);
                                break;
                            }
                        }
                    }
                }
            }
            catch (System.NullReferenceException)
            {
                await DisplayAlert("Ты заебал", "Тут вообще-то пусто", "ОК");
            }
        }
コード例 #15
0
        public static Task <SKImage?> ToSKImageAsync(this ImageSource imageSource, CancellationToken cancellationToken = default)
        {
            if (imageSource == null)
            {
                throw new ArgumentNullException(nameof(imageSource));
            }

            return(imageSource switch
            {
                // 1. first try SkiaSharp sources
                SKImageImageSource iis => FromSkia(iis.Image),
                SKBitmapImageSource bis => FromSkia(SKImage.FromBitmap(bis.Bitmap)),
                SKPixmapImageSource xis => FromSkia(SKImage.FromPixels(xis.Pixmap)),
                SKPictureImageSource pis => FromSkia(SKImage.FromPicture(pis.Picture, pis.Dimensions)),

                // 2. then try Stream sources
                StreamImageSource stream => FromStream(stream.Stream.Invoke(cancellationToken)),
                UriImageSource uri => FromStream(uri.GetStreamAsync(cancellationToken)),

                // 3. finally, use the handlers
                FileImageSource file => FromHandler(PlatformToSKImageAsync(file, cancellationToken)),
                FontImageSource font => FromHandler(PlatformToSKImageAsync(font, cancellationToken)),

                // 4. all is lost
                _ => throw new ArgumentException("Unable to determine the type of image source.", nameof(imageSource))
            });
コード例 #16
0
ファイル: App.cs プロジェクト: echo000/TestProject2
        public static void LoadPageConnected()
        {
            device = Resolver.Resolve <IDevice>();
            Debug.WriteLine(device.HardwareVersion);
            display   = device.Display;
            emptyIcon = new UriImageSource {
                CachingEnabled = false, Uri = new Uri("https://raw.githubusercontent.com/echo000/testProject/master/Empty.png")
            };

            Current.Resources = new ResourceDictionary();

            if (DependencyService.Get <ICredentialsService>().DoCredentialsExist())
            {
                string id       = DependencyService.Get <ICredentialsService>().ProfileId;
                var    region   = regFromString(DependencyService.Get <ICredentialsService>().Region);
                var    x        = int.Parse(id);
                var    summoner = api.GetSummoner(region, x);
                MyTabbedPage = new TabbedPages(summoner, summoner.Region);
                Application.Current.MainPage = MyTabbedPage;
            }
            else
            {
                Application.Current.MainPage = new NavigationPage(new loginXaml());
            }
        }
コード例 #17
0
ファイル: App.cs プロジェクト: stacker16/Xamarin-Ogreniyorum
        public App()
        {
            var content = new ContentPage
            {
                Title   = "XamarinCircleImage",
                Content = new StackLayout
                {
                    VerticalOptions = LayoutOptions.Center,
                    Children        =
                    {
                        new Label {
                            HorizontalTextAlignment = TextAlignment.Center,
                            Text = "Welcome to Xamarin Forms!"
                        },
                        new CircleImage
                        {
                            BorderColor       = Color.Red,
                            BorderThickness   = 5,
                            HeightRequest     = 150,
                            WidthRequest      = 150,
                            Aspect            = Aspect.AspectFill,
                            HorizontalOptions = LayoutOptions.Center,
                            Source            = UriImageSource.FromUri(new Uri("http://www.xamarintr.com/Portals/0/Users/003/03/3/yigit-ozaksut.jpg"))
                        }
                    }
                }
            };

            //MainPage = new NavigationPage(content);
            MainPage = new CircleSample();
        }
コード例 #18
0
        public ActivityIndicatorPage()
        {
            InitializeComponent();
            //Dirty Way
            //var imageSource= (UriImageSource) ImageSource.FromUri(new Uri("http://..."));

            //Cleaner Way
            var imageSource = new UriImageSource {
                Uri = new Uri("hhttp://lorempixel.com/1920/1080/sports/7/")
            };


            //ImageSource Properties

            //CachingEnabled is a Bool
            //Default is automatically enabled
            //Need to set this to false if you want to dynamically change images
            imageSource.CachingEnabled = false;

            //CacheValidity sets how long the cache is valid
            //Default is 24hours
            //This is how to change the time-span
            imageSource.CacheValidity = TimeSpan.FromHours(1);
            //This is 1hr timeSpan

            //Setting imageSource to image.Source object
            image.Source = imageSource;
            image.Source = "http://lorempixel.com/1920/1080/sports/7/";

            //ActivityIndicator.BindingContext = image;
            //ActivityIndicator.SetBinding(ActivityIndicator.IsVisibleProperty, nameof(image.IsLoading));
            //ActivityIndicator.SetBinding(ActivityIndicator.IsRunningProperty, nameof(image.IsLoading));
        }
コード例 #19
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value != null)
            {
                if (value is string && targetType == typeof(ImageSource))
                {
                    var val    = (string)value;
                    var source = (ImageSource)val;
                    if (source == null)
                    {
                        return(null);
                    }

                    if (source is UriImageSource)
                    {
                        UriImageSource imgSource = (UriImageSource)source;
                        imgSource.CachingEnabled = Globals.ImageCachedEnable;
                        imgSource.CacheValidity  = Globals.ImageCachedValidity;
                        return(imgSource);
                    }
                    return(source);
                }
            }

            return(null);
        }
コード例 #20
0
        private async void OnItemTapped(object ob, EventArgs e)                                                                                 //tap handler
        {
            Frame          frame   = (Frame)ob;
            Image          content = (Image)frame.Content;
            UriImageSource source  = (UriImageSource)content.Source;
            string         id      = source.AutomationId;

            foreach (Item item in items.item)
            {
                if (String.Equals(id, item.id) && (GetItemType(item) == itemType.ammo))
                {
                    string action = await DisplayActionSheet(item.caliber + "x" + item.case_length + " (" + item.features + ")\r\n", "Отмена", null, "\r\nВыбросить", "Информация");

                    ItemTypeDefinitor(action, item, item.id);
                    break;
                }
                else if (String.Equals(id, item.id))
                {
                    string action = await DisplayActionSheet(item.name + "\r\n", "Отмена", null, "Надеть", "Выбросить", "Информация");

                    ItemTypeDefinitor(action, item, item.id);
                    break;
                }
            }
        }
コード例 #21
0
        private async Task <ImageSource> LoadImageFromURL(String sUri, EventHandler <ImageSource> UpdateImageEvent)
        {
            var threadID = m_IThreading.GetCurrentThreadID().ToString();

            System.Diagnostics.Debug.WriteLine(threadID + "LoadImageFromURL");
            var source = new UriImageSource
            {
                Uri            = new Uri(sUri),
                CachingEnabled = false
            };

            //Stream imageStream = new System.IO.MemoryStream();
            var asyncUrlDownload = new AsyncUrlDownload(m_IThreading);
            var stream           = await asyncUrlDownload.DownloadHttpToArray(sUri);

            //var bmpConverter = new LoadImageFormats();
            //processImage.inputImage = bmpConverter.BMPToImage(stream);
            if (stream.Item1)
            {
                ImageProperties imgProp = await GetImageProperties(stream.Item2);

                //System.Diagnostics.Debug.WriteLine(threadID + "LoadImageFromURL - res {0}x{1} depth {2} compression {3} subComp {4} inSize {5} outSize {6}",
                //    imgProp.width, imgProp.height, imgProp.bitDepth, imgProp.compressionType, imgProp.subCompressionType, imgProp.inSize, imgProp.outRealSize);
                processImage.inputImage = new InputImage(imgProp.outBuf.pBuf, (int)(imgProp.width * imgProp.bitDepth / 8.0), imgProp.width, imgProp.height, (int)(imgProp.bitDepth / 8.0));
                CanExecuteProcess       = true;
                UpdateImageEvent(this, source);
            }
            return(source);
        }
コード例 #22
0
        public void GetProfile()
        {
            GetProfileRequest obj = new GetProfileRequest();

            obj.EmailId = Email;
            obj.UserId  = UserId;
            UserDialogs.Instance.ShowLoading("Requesting..");
            userManager.getProfile(obj, () =>
            {
                var userProfileResponse = userManager.ProfileResponse;

                if (userProfileResponse.StatusCode == 202)
                {
                    var udata    = userProfileResponse.UserData;
                    Address1     = udata.Address1;
                    Address2     = udata.Address2;
                    Address3     = udata.Address3;
                    State        = udata.State;
                    City         = udata.City;
                    Country      = udata.Country;
                    Email        = udata.EmailId;
                    FirstName    = udata.FirstName;
                    Hobbies      = udata.Hobbies;
                    LastName     = udata.LastName;
                    UserName     = udata.UserName;
                    MobileNumber = udata.MobileNumber;
                    Password     = udata.Password;
                    PhoneNumber  = udata.PhoneNumber;
                    Postcode     = udata.Postcode;
                    Picture      = udata.PhotoURL;
                    DateOfBirth  = udata.DateOfBirth;
                    Gender       = udata.Gender;
                    AboutMe      = udata.AboutMe;
                    ImageBase64  = "";
                    if (!string.IsNullOrEmpty(udata.PhotoURL))
                    {
                        PictureSource = new UriImageSource
                        {
                            Uri            = new Uri(udata.PhotoURL),
                            CachingEnabled = true,
                        };
                        // ImageBase64 = await GetImageAsBase64Url(udata.PhotoURL);
                    }
                    Xamarin.Forms.Device.BeginInvokeOnMainThread(async() =>
                    {
                        UserDialogs.Instance.HideLoading();
                        await((MasterDetailPage)App.Current.MainPage).Detail.Navigation.PushAsync(new ProfileSetting());
                    });
                }
            },
                                   (requestFailedReason) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() =>
                {
                    //  UserDialogs.Instance.Alert(requestFailedReason.Message, null, "OK");
                    UserDialogs.Instance.HideLoading();
                });
            });
        }
コード例 #23
0
        public TraineeProfileViewModel()
        {
            //Models.LoginResponse.SyncLoginResponse syncLoginResponse = App.DatabaseManager.SyncLoginResponse("Trainee");

            TraineeName     = App.LoginResponse.basicInfo.Name;
            TraineeGoals    = App.LoginResponse.basicInfo.SportsInterest;
            TraineeInterest = App.LoginResponse.basicInfo.SportsInterest;

            if (App.LoginResponse.basicInfo.ImageUrl != null && App.LoginResponse.basicInfo.ImageUrl != "NA" && App.LoginResponse.basicInfo.ImageUrl != "defaultIcon.png")
            {
                String url = App.LoginResponse.basicInfo.ImageUrl != null ? App.LoginResponse.basicInfo.ImageUrl : "defaultIcon.png";

                ImageSource = new UriImageSource {
                    CachingEnabled = true, Uri = new System.Uri(url)
                };
            }


            if (App.LoginResponse.basicInfo.InstaGramImages != null && App.LoginResponse.basicInfo.InstaGramImages != "")
            {
                string   s        = App.LoginResponse.basicInfo.InstaGramImages;
                string[] imageurl = s.Split(',').Select(sValue => sValue.Trim()).ToArray();

                if (imageurl.Count() > 0)
                {
                    GalleryVisible = true;
                    InstaVisible   = false;

                    var list = new List <string>();
                    foreach (var item in imageurl)
                    {
                        list.Add(item);
                    }
                    Gallery = new ObservableCollection <string>(list);
                }
            }
            else
            {
                if (App.InstagramMedia != null && App.InstagramMedia.data != null)
                {
                    GalleryVisible = true;
                    InstaVisible   = false;

                    var list = new List <string>();
                    foreach (var item in App.InstagramMedia.data)
                    {
                        var media = item.images.standard_resolution.url;
                        list.Add(media);
                    }
                    Gallery = new ObservableCollection <string>(list);
                }

                else
                {
                    GalleryVisible = false;
                    InstaVisible   = true;
                }
            }
        }
コード例 #24
0
        private async void GetData(int id)
        {
            Declaration = await APIService.Instance.GetDeclarationAsync(id);

            ImageSource = new UriImageSource {
                CachingEnabled = false, Uri = APIService.Instance.GetImageUri(Declaration.ReceiptID)
            };
        }
コード例 #25
0
        private void RetrieveScreenShot(object sender, EventArgs e)
        {
            var src = new UriImageSource();

            src.Uri = new Uri(URL.Text + (URL.Text.EndsWith("/") ? "" : "/") + Username.Text + ".png");
            //Debug.WriteLine(src.Uri.AbsolutePath);
            Image.Source = src;
        }
コード例 #26
0
 public CurrentGamePlayers(string name, string rank, int id, UriImageSource icon, RiotSharp.Region region)
 {
     this.Name   = name;
     this.Rank   = rank;
     this.ID     = id;
     this.Icon   = icon;
     this.Region = region;
 }
コード例 #27
0
        public void NullUriDoesNotCrash()
        {
            var loader = new UriImageSource();

            Assert.DoesNotThrow(() => {
                loader.Uri = null;
            });
        }
コード例 #28
0
 public RankedChampions(string kda, string winrate, double winratedecimal, string creepScore, UriImageSource imagePath, int totalsessionsplayed)
 {
     KDA                 = kda;
     WinRate             = winrate;
     WinRateDecimal      = winratedecimal;
     CreepScore          = creepScore;
     Icon                = imagePath;
     TotalSessionsPlayed = totalsessionsplayed;
 }
コード例 #29
0
		public void LoadImageFromStream ()
		{
			var loader = new UriImageSource { 
				Uri = new Uri ("http://foo.com/Images/crimson.jpg"),
			};
			Stream s0 = loader.GetStreamAsync ().Result;

			Assert.AreEqual (79109, s0.Length);
		}
コード例 #30
0
        public MainPage()
        {
            InitializeComponent();
            var imageSource = new UriImageSource {
                Uri = new Uri("http://lorempixel.com/1920/1080/city/1/")
            };

            imageSource.CachingEnabled = false;
        }
コード例 #31
0
        public UriImageSource GetImageSource(string url)
        {
            UriImageSource uri = new UriImageSource()
            {
                Uri = new Uri(url)
            };

            return(uri);
        }
コード例 #32
0
		public void SecondCallLoadFromCache ()
		{
			var loader = new UriImageSource { 
				Uri = new Uri ("http://foo.com/Images/crimson.jpg"),
			};
			Assert.AreEqual (0, networkcalls);

			using (var s0 = loader.GetStreamAsync ().Result) {
				Assert.AreEqual (79109, s0.Length);
				Assert.AreEqual (1, networkcalls);
			}
				
			using (var s1 = loader.GetStreamAsync ().Result) {
				Assert.AreEqual (79109, s1.Length);
				Assert.AreEqual (1, networkcalls);
			}
		}
コード例 #33
0
ファイル: ImageTests.cs プロジェクト: Costo/Xamarin.Forms
		public void TestImageSourceToNullCancelsLoading ()
		{
			var image = new Image ();
			var mockImageRenderer = new MockImageRenderer (image);
			var loader = new UriImageSource { Uri = new Uri ("http://www.public-domain-image.com/free-images/miscellaneous/big-high-border-fence.jpg") };
			image.Source = loader;
			Assert.IsTrue (image.IsLoading);
			image.Source = null;
			Assert.IsFalse (image.IsLoading);
			Assert.IsTrue (cancelled);
		}
コード例 #34
0
		public void DoNotKeepFailedRetrieveInCache ()
		{
			var loader = new UriImageSource { 
				Uri = new Uri ("http://foo.com/missing.png"),
			};
			Assert.AreEqual (0, networkcalls);

			var s0 = loader.GetStreamAsync ().Result;
			Assert.IsNull (s0);
			Assert.AreEqual (1, networkcalls);

			var s1 = loader.GetStreamAsync ().Result;
			Assert.IsNull (s1);
			Assert.AreEqual (2, networkcalls);
		}
コード例 #35
0
		public void NullUriDoesNotCrash ()
		{
			var loader = new UriImageSource ();
			Assert.DoesNotThrow (() => {
				loader.Uri = null;
			});
		}
コード例 #36
0
		public void ConcurrentCallsOnSameUriAreQueued ()
		{
			var loader = new UriImageSource { 
				Uri = new Uri ("http://foo.com/Images/crimson.jpg"),
			};
			Assert.AreEqual (0, networkcalls);

			var t0 = loader.GetStreamAsync ();
			var t1 = loader.GetStreamAsync ();

			//var s0 = t0.Result;
			using (var s1 = t1.Result) {
				Assert.AreEqual (1, networkcalls);
				Assert.AreEqual (79109, s1.Length);
			}
		}
コード例 #37
-2
        public AuthenticDocModel(SignalProcess _process, IThreadingCrossPlatform _IThreading, IDevice _currentDevice, IMediaPicker _mediaPicker, IImageSupport _imageSupport, IFileSupport _fileSupport, string[] _testURls)
        {
            m_IThreading    = _IThreading;
            m_IFileSupport  = _fileSupport;
            m_IImageSupport = _imageSupport;
            m_testURls      = _testURls;

            SetupMedia(_currentDevice, _mediaPicker);

            buttonCameraName = "Camera";

            //urlEntryText = directory;
            TakePictureFromCameraCommand = new RelayCommand(TakePictureFromCameraRelay, param => this.canExecute);
            LoadImageFromFileCommand     = new RelayCommand(LoadImageFromFileCommandRelay, param => this.canExecute);
            LoadImageFromURLCommand      = new RelayCommand(LoadImageFromURLCommandRelay, param => this.canExecute);
            TestButtonCommand            = new RelayCommand(TestButtonCommandRelay, param => this.canExecute);
            ProcessCommand = new RelayCommand(ProcessCommandRelay, param => this.CanExecuteProcess);
            URLEntryPickerChangedCommand = new RelayCommand(urlEntryPickerChangedCommandRelay, param => this.canExecute);
            updateImageEvent            += new EventHandler <ImageSource>((o, s) => { imageSource = s; });
            imageSource = new UriImageSource
            {
                Uri            = new Uri("https://grandprix20.files.wordpress.com/2012/11/317757_423537204379996_1874288384_n-1.png"),
                CachingEnabled = false
            };
            processImage = new ProcessingImage(_process);
        }