public InlineLink Match(String word, Brush lBrush, IStatusUpdate oStatusUpdate) { string word1 = word; Match tweetdeckiskillingme = Regex.Match(word, BrokenTweetdeckHttpUrlRgxPattern); if (tweetdeckiskillingme.Success) word1 = "http://" + tweetdeckiskillingme.Groups["tweetdecksucks"].Value; // pop http:// onto the front of the bastardised tweetdeck shorturl mechanism Match mpa = Regex.Match(word1, HttpUrlRgxPattern); if (mpa.Success) { string nmatched = mpa.Groups["urlscheme"].Value + mpa.Groups["domainpath"].Value; Uri ilurl; if (!Uri.TryCreate(nmatched, UriKind.Absolute, out ilurl)) return null; Uri ciurl; if ( !Uri.TryCreate( "http://" + _textProcessorEngine.ShortenVisualInlineUrl(mpa.Groups["domainpath"].Value) + "/favicon.ico", UriKind.Absolute, out ciurl)) return null; var image = new CachedImage { Url = ciurl, MaxHeight = 10, MaxWidth = 10, Margin = new Thickness(0, 0, 2, 0) }; var il = new InlineLink { Url = ilurl, Text = _textProcessorEngine.ShortenVisualInlineUrl(nmatched) + Ellipsis, Foreground = lBrush, ToolTip = "Browse to: " + nmatched, Tag = false, Image = image, HoverColour = _textProcessorEngine.BrHover, NormalColour = _textProcessorEngine.BrNormal, }; il.MouseLeftButtonDown += _textProcessorEngine.LinkClick; AddImagePreviewIcon(oStatusUpdate, il, nmatched); AddAdditionalSmartText(il, nmatched); CheckAndConvertToLongUrl(oStatusUpdate, il, nmatched); return il; } return null; }
private void SetContent() { var imageSource = ImageSource.FromFile(_imageFile); var closeImage = new CachedImage { DownsampleToViewSize = true, CacheType = CacheType.All, Source = "close_cross.png" }; closeImage.GestureRecognizers.Add(new TapGestureRecognizer() { Command = new Command(Close) }); if (Uri.IsWellFormedUriString(_imageFile, UriKind.Absolute)) { imageSource = ImageSource.FromUri(new Uri(_imageFile)); } var cachedImage = new CachedImage { Source = imageSource, CacheType = CacheType.All, }; var layout = new AbsoluteLayout { Margin = 20, }; AbsoluteLayout.SetLayoutBounds(cachedImage, new Rectangle(0, 0, 1, 1)); AbsoluteLayout.SetLayoutFlags(cachedImage, AbsoluteLayoutFlags.All); AbsoluteLayout.SetLayoutBounds(closeImage, new Rectangle(1, 0, .1, .05)); AbsoluteLayout.SetLayoutFlags(closeImage, AbsoluteLayoutFlags.All); layout.Children.Add(cachedImage); layout.Children.Add(closeImage); Content = layout; }
public ToggleButton() { Image = new CachedImage() { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, FadeAnimationEnabled = false, }; State = false; Padding = 0; GestureRecognizers.Clear(); GestureRecognizers.Add(new TapGestureRecognizer()); (GestureRecognizers.First() as TapGestureRecognizer).Tapped += tap; HeightRequest = 36d; WidthRequest = 36d; IconSize = 25d; Content = Image; }
private async void ImageLoadingSizeChanged(CachedImage element, bool isLoading) { if (element == null || _isDisposed) { return; } await ImageService.Instance.Config.MainThreadDispatcher.PostAsync(() => { if (element == null || _isDisposed) { return; } ((IVisualElementController)element).NativeSizeChanged(); if (!isLoading) { element.SetIsLoading(isLoading); } }); }
private async Task AddImage(string filepath) { string imagePath = await Task <string> .Factory.StartNew(() => FileManager.GetCompressedImage(filepath, 150, 150)); Device.BeginInvokeOnMainThread(async() => { CachedImage image = new CachedImage { Source = await Task <ImageSource> .Factory.StartNew(() => ImageSource.FromFile(imagePath)), HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, HeightRequest = 120, WidthRequest = 120, Aspect = Aspect.Fill, AutomationId = filepath, IsOpaque = true, BackgroundColor = Color.Gray }; image.DownsampleToViewSize = true; image.CacheDuration = new TimeSpan(5, 0, 0, 0); var tapGestureRecognizer = new TapGestureRecognizer(); tapGestureRecognizer.NumberOfTapsRequired = 2; tapGestureRecognizer.Tapped += OnTapGestureRecognizerFolderTapped; image.GestureRecognizers.Add(tapGestureRecognizer); Grid.SetColumn(image, colPosition); Grid.SetRow(image, rowPosition); image.Opacity = 0; flexLayout.Children.Add(image); image.Opacity = 1; colPosition++; if (colPosition == 3) { colPosition = 0; rowPosition++; } }); }
private async Task ImageHoldingOrRightTapped(object sender, Func <UIElement, Point> getPosition) { if (sender != null) { if (!await FileUtils.HaveAyaPositionFile()) { await ViewModel.DownloadAyahPositionFile(); } var cachedImage = sender as CachedImage; if (cachedImage == null) { return; } QuranAyah ayah = await CachedImage.GetAyahFromGesture(getPosition(cachedImage.Image), ViewModel.CurrentPageNumber, radSlideView.ActualWidth); ShowContextMenu(ayah, null, getPosition(ThisPage)); } }
public VaultListHeaderViewCell(VaultListLoginsPage page) { var image = new CachedImage { Source = "folder.png", WidthRequest = 18, HeightRequest = 18 }; var label = new Label { FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), Style = (Style)Application.Current.Resources["text-muted"], VerticalTextAlignment = TextAlignment.Center }; label.SetBinding(Label.TextProperty, nameof(VaultListPageModel.Folder.Name)); var grid = new Grid { ColumnSpacing = 10, Padding = new Thickness(16, 8, 0, 8) }; grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(18, GridUnitType.Absolute) }); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); grid.Children.Add(image, 0, 0); grid.Children.Add(label, 1, 0); View = grid; BackgroundColor = Color.FromHex("efeff4"); }
private void ItemNewsView_TabLike(object sender, EventArgs e) { var stack = sender as StackLayout; var parent = (ContentInfo)stack?.BindingContext; Label like = stack.Children[1] as Label; CachedImage img = stack.Children[0] as CachedImage; if (parent.LikeContent.LikeColor.Equals("#5D6A76")) { if (model != null) { model.SendLike(true, parent); } } else { if (model != null) { model.SendLike(false, parent); } } }
public ListExampleCell() { var image = new CachedImage() { WidthRequest = 200, HeightRequest = 200, DownsampleHeight = 200, DownsampleUseDipUnits = true, TransparencyEnabled = false, Aspect = Aspect.AspectFill, CacheDuration = TimeSpan.FromDays(30), RetryCount = 3, RetryDelay = 500, LoadingPlaceholder = "loading.png", }; image.SetBinding <ListExampleItem>(CachedImage.SourceProperty, v => v.ImageUrl); var fileName = new Label() { LineBreakMode = LineBreakMode.CharacterWrap, YAlign = TextAlignment.Center, XAlign = TextAlignment.Center, }; fileName.SetBinding <ListExampleItem>(Label.TextProperty, v => v.FileName); var root = new AbsoluteLayout() { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, Padding = 5, }; root.Children.Add(image, new Rectangle(0f, 0f, 200f, 200f)); root.Children.Add(fileName, new Rectangle(200f, 0f, 150f, 200f)); View = root; }
private async void TapGestureRecognizer_OnTapped(object sender, EventArgs e) { StackLayout stackLayout = ((StackLayout)sender); StackLayout x = ((StackLayout)(stackLayout.Parent.Parent.Parent));; Label likecount = (Label)((StackLayout)x.Children[2]).Children[1]; Label likecountreal = (Label)((StackLayout)x.Children[2]).Children[2]; Label test = ((Label)stackLayout.Children[0]); CachedImage cachedImage = ((CachedImage)stackLayout.Children[1]); Label label = ((Label)stackLayout.Children[2]); if (test.Text.Equals("false")) { label.TextColor = Color.FromHex("3578e5"); likecount.Text = "You and " + likecountreal.Text + " others"; cachedImage.Source = ImageSource.FromFile("bluelikeicon"); await label.ScaleTo(1.5, 150, Easing.CubicOut); await cachedImage.ScaleTo(1.5, 150, Easing.CubicOut); test.Text = "true"; label.ScaleTo(1, 150, Easing.CubicIn); cachedImage.ScaleTo(1, 150, Easing.CubicIn); } else { await label.ScaleTo(1.5, 50, Easing.CubicOut); await cachedImage.ScaleTo(1.5, 50, Easing.CubicOut); likecount.Text = likecountreal.Text; label.TextColor = Color.Black; cachedImage.Source = ImageSource.FromFile("likeicon"); test.Text = "false"; label.ScaleTo(1, 150, Easing.CubicIn); cachedImage.ScaleTo(1, 150, Easing.CubicIn); } }
public SettingsPageViewCell() { var settingsIcon = new CachedImage { HeightRequest = _settingsIcon, VerticalOptions = LayoutOptions.CenterAndExpand }; settingsIcon.SetBinding(CachedImage.SourceProperty, "Icon", converter: new StringToImageSourceConverter()); var settingsTitle = new Label { Margin = _settingsTitleMargin, VerticalOptions = LayoutOptions.CenterAndExpand, TextColor = Color.FromHex(Theme.Current.SettingsTitleColor), Style = AppStyles.GetLabelStyle() }; settingsTitle.SetBinding(Label.TextProperty, "Title"); var forwardIcon = new CachedImage { HeightRequest = _forwardIcon, HorizontalOptions = LayoutOptions.EndAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand, Source = ImageSource.FromFile(Theme.Current.BaseArrowForwardIcon) }; View = new StackLayout { Padding = _padding, Orientation = StackOrientation.Horizontal, BackgroundColor = Color.FromHex(Theme.Current.BaseBlockColor), Children = { settingsIcon, settingsTitle, forwardIcon } }; }
public LearningPageViewCell() { BackgroundColor = Color.FromHex(Theme.Current.AppBackgroundColor); Padding = _padding; var image = new CachedImage { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, Aspect = Aspect.AspectFill }; image.SetBinding(CachedImage.SourceProperty, "Image", converter: new StringToImageSourceConverter()); var title = new Label { TextColor = Color.FromHex(Theme.Current.LearningCardTextColor), FontAttributes = FontAttributes.Bold, Margin = _titleMargin, Style = AppStyles.GetLabelStyle(bold: true) }; title.SetBinding(Label.TextProperty, "Title"); Children.Add(new Frame { HasShadow = false, Margin = _framePadding, Padding = _framePadding, IsClippedToBounds = true, CornerRadius = _cornerRadius, BackgroundColor = Color.FromHex(Theme.Current.BaseBlockColor), Content = new Grid { Children = { image, title } } }); }
private void CarViewReInit() { var tap = new TapGestureRecognizer(); tap.Command = new Command((obj) => { if (viewModel.IsBusy == false && viewModel.Items.Count != 0) { viewModel.ImageTapCommand.Execute(carView?.Position); } }); carView.GestureRecognizers.Add(tap); if (Device.RuntimePlatform == Device.Android) { carView.ItemTemplate = new DataTemplate(() => { var grid = new Grid(); var img = new CachedImage() { Aspect = Aspect.AspectFill }; img.SetBinding(ClassIdProperty, new Binding("StyleId")); img.SetBinding(CachedImage.SourceProperty, new Binding("Image")); var label = new Label() { Margin = new Thickness(10, 10, 10, 15), VerticalTextAlignment = TextAlignment.End, HorizontalOptions = LayoutOptions.Start, TextColor = Color.White }; label.SetBinding(Label.TextProperty, new Binding("Text")); grid.Children.Add(img); grid.Children.Add(label); grid.GestureRecognizers.Add(tap); return(grid); }); } }
CachedImage createSettingsIcon() { var settingsIcon = new CachedImage { HorizontalOptions = LayoutOptions.EndAndExpand, VerticalOptions = LayoutOptions.StartAndExpand, Margin = Device.RuntimePlatform == Device.iOS ? _iosSettingsMargin : _androidSettingsMargin, Source = ImageSource.FromFile(Theme.Current.MainSettingsIcon), HeightRequest = _settingsIconSize, WidthRequest = _settingsIconSize, Transformations = new List <FFImageLoading.Work.ITransformation> { new TintTransformation { EnableSolidColor = true, HexColor = Theme.Current.LoginButtonBackgroundColor } } }; var tapGestureRecognizer = new TapGestureRecognizer(); tapGestureRecognizer.SetBinding(TapGestureRecognizer.CommandProperty, "SettingsCommand"); settingsIcon.GestureRecognizers.Add(tapGestureRecognizer); return(settingsIcon); }
public void ChangeBeard(object sender, EventArgs e) { CachedImage image = (CachedImage)sender; if (ProfilePictureBeard.Source == image.Source) { ProfilePictureBeard.Source = ""; var PP = (ProfilePage)App.Mainpage.Children[2]; PP.updateAvatar(ProfilePictureHair.Source, ProfilePictureBody.Source, ActualFace, ProfilePictureExpr.Source, ProfilePictureBeard.Source); Avatar[4] = ""; } else { ProfilePictureBeard.Source = image.Source; var PP = (ProfilePage)App.Mainpage.Children[2]; PP.updateAvatar(ProfilePictureHair.Source, ProfilePictureBody.Source, ActualFace, ProfilePictureExpr.Source, ProfilePictureBeard.Source); Avatar[4] = image.ClassId; } App.LoggedinUser.Avatar = JsonConvert.SerializeObject(Avatar); App.database.UpdateAvatarItems(App.LoggedinUser); }
public GridImagesView() { InitializeComponent(); for (int i = 0; i < 100; i++) { _grid.RowDefinitions.Add(new RowDefinition { Height = 50 }); for (int j = 0; j < 4; j++) { var image = new CachedImage { Aspect = Aspect.AspectFill, Source = Images.RandomSource(), }; Grid.SetRow(image, i); Grid.SetColumn(image, j); _grid.Children.Add(image); } } }
/// <summary> /// Loads the template for the carousel in portrait layout. /// </summary> /// <returns>The view used as the template.</returns> private View LoadPortraitTemplate() { // main content StackLayout layout = new StackLayout() { Orientation = StackOrientation.Vertical, Padding = new Thickness(0, 80) }; layout.SetBinding(StackLayout.BackgroundColorProperty, "BackgroundColor"); CachedImage image = new CachedImage() { VerticalOptions = LayoutOptions.CenterAndExpand, Aspect = Aspect.AspectFit, HorizontalOptions = LayoutOptions.FillAndExpand }; image.SetBinding(CachedImage.SourceProperty, "Image"); StackLayout innerStack = new StackLayout() { Orientation = StackOrientation.Vertical, HorizontalOptions = LayoutOptions.CenterAndExpand }; Label headline = new Label() { TextColor = Color.White, VerticalOptions = LayoutOptions.CenterAndExpand, FontSize = 18, FontAttributes = FontAttributes.Bold, HorizontalTextAlignment = TextAlignment.Center }; headline.SetBinding(Label.TextProperty, "Headline"); Label text = new Label() { TextColor = Color.White, VerticalOptions = LayoutOptions.CenterAndExpand, FontSize = 12, HorizontalTextAlignment = TextAlignment.Center }; text.SetBinding(Label.TextProperty, "Text"); innerStack.Children.Add(headline); innerStack.Children.Add(text); layout.Children.Add(image); layout.Children.Add(innerStack); return(layout); }
async void LoadBitmapCollection() { int imageDimension = Device.RuntimePlatform == Device.iOS || Device.RuntimePlatform == Device.Android ? 120 : 60; List <ImageModel> images = await DependencyService.Get <IPicturePicker>().GetImageStreamAsync(); try { Device.BeginInvokeOnMainThread(() => { if (images != null) { for (int i = 0; i < 200; i++) { CachedImage cachedImage = new CachedImage { Source = ImageSource.FromFile(images[i].Path), WidthRequest = imageDimension, HeightRequest = imageDimension, Aspect = Aspect.AspectFill, DownsampleToViewSize = true, //LoadingPlaceholder = "xiaobin.jpg" }; flexLayout.Children.Add(cachedImage); } } }); } catch (Exception ex) { flexLayout.Children.Add(new Label { Text = "Cannot access list of bitmap files" }); } activityIndicator.IsRunning = false; activityIndicator.IsVisible = false; }
protected override void InitializeCell() { var screenWidth = Device.Info.ScaledScreenSize.Width; _image = new CachedImage { HorizontalOptions = LayoutOptions.Center, Aspect = Aspect.AspectFill, WidthRequest = screenWidth / 2 - 40, HeightRequest = screenWidth / 2 - 40 }; _name = new Label { HorizontalOptions = LayoutOptions.Center, FontSize = 20, TextColor = Color.Black }; _price = new Label { HorizontalOptions = LayoutOptions.Center, FontSize = 14, TextColor = Color.Black }; View = new StackLayout { BackgroundColor = Color.White, Padding = 20, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Children = { _image, _name, _price } }; }
public void ChangeBody(object sender, EventArgs e) { var properties = App.Current.Properties; if (CatOpen == "Ct2" || CatOpen == "Ct4") { if (properties.ContainsKey("avatarbodyBig")) { properties["avatarbodyBig"] = false; BBT = false; } } else { if (properties.ContainsKey("avatarbodyBig")) { properties["avatarbodyBig"] = true; BBT = true; } } LastApl = CatOpen; CachedImage image = (CachedImage)sender; Avatar[2] = image.ClassId; App.LoggedinUser.Avatar = JsonConvert.SerializeObject(Avatar); App.database.UpdateAvatarItems(App.LoggedinUser); ProfilePictureBody.Source = image.Source; var PP = (ProfilePage)App.Mainpage.Children[2]; PP.updateAvatar(ProfilePictureHair.Source, ProfilePictureBody.Source, ActualFace, ProfilePictureExpr.Source, ProfilePictureBeard.Source); UpdateAvatar(); }
public Pixbuf TryGetImageResized(YamsterHttpRequest request, Size resizeDimensions, out Exception loadError) { CachedImageKey key = new CachedImageKey(request.Url, resizeDimensions); CachedImage cachedImage = null; Task <byte[]> requestTask; if (!imagesByUrl.TryGetValue(key, out cachedImage)) { // Check hack to prevent the cache from growing too large if (imagesByUrl.Count > MaxCacheItems) { imagesByUrl.Clear(); } requestTask = this.asyncRestCaller.ProcessRawRequestAsync(request); cachedImage = new CachedImage(requestTask, request.Url, resizeDimensions); imagesByUrl.Add(key, cachedImage); } else { requestTask = cachedImage.RequestTask; } if (requestTask != null) { if (requestTask.IsCanceled || requestTask.IsCompleted || requestTask.IsFaulted) { FinishLoadingImage(cachedImage); } } loadError = cachedImage.LoadError; return(cachedImage.Pixbuf); }
async Task <WrapperSimpleTypesDTO> AsignarImagenBanner(Stream streamBanner) { WrapperSimpleTypesDTO wrapper = new WrapperSimpleTypesDTO(); if (streamBanner != null) { int codigoArchivo = SourceModel.Persona.CodigoArchivoImagenBanner.HasValue ? SourceModel.Persona.CodigoArchivoImagenBanner.Value : 0; if (IsNotConnected) { return(null); } wrapper = await _archivoServices.AsignarImagenBannerPersona(SourceModel.Persona.Consecutivo, codigoArchivo, streamBanner); if (wrapper != null && wrapper.Exitoso) { await CachedImage.InvalidateCache(SourceModel.Persona.UrlImagenBanner, CacheType.All, true); SourceModel.Persona.CodigoArchivoImagenBanner = Convert.ToInt32(wrapper.ConsecutivoArchivoCreado); } } return(wrapper); }
public TimelineTail(AccountGroup group) { InitializeComponent(); this.group = group; HeaderView.Icon.Source = "ic_timeline_green_300_48dp"; HeaderView.HeaderLabel.Text = "타임라인 @" + group.AccountForRead.User.ScreenName; WriterView = new StatusWriterView(group); WriterView.IsVisible = false; RootView.Children.Insert(1, WriterView); WriteIcon = HeaderView.AddIcon("ic_create_black_48dp"); WriteIcon.GestureRecognizers.Add(new TapGestureRecognizer() { Command = new Command(() => { WriterView.IsVisible = !WriterView.IsVisible; }) }); TimelineListView.Fetchable = new AccountFetch.Timeline(App.Tail, group); HeaderView.RefreshAction += new Action(async() => { try { await TimelineListView.Refresh(); } catch (Exception e) { Util.HandleException(e); } HeaderView.InRefresh = false; }); }
private void Files_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { if (files.Count == 0) { ImageList.Children.Clear(); return; } if (e.NewItems.Count == 0) { return; } var file = e.NewItems[0] as MediaFile; var image = new Image { WidthRequest = 300, HeightRequest = 300, Aspect = Aspect.AspectFit }; image.Source = ImageSource.FromFile(file.Path); /*image.Source = ImageSource.FromStream(() => * { * var stream = file.GetStream(); * return stream; * });*/ ImageList.Children.Add(image); var image2 = new CachedImage { WidthRequest = 300, HeightRequest = 300, Aspect = Aspect.AspectFit }; //using FFImageLoading.Forms; paketi CachedImage için gerekli image2.Source = ImageSource.FromFile(file.Path); ImageList.Children.Add(image2); }
private async void onImageClicked(ImageSource source) { var modalPage = new ContentPage(); ScrollView view = new ScrollView(); StackLayout layout = new StackLayout(); CachedImage image = new CachedImage(); PinchZoom pinchImage = new PinchZoom(); image.Source = source; image.Margin = new Thickness(0, 130, 0, 130); image.DownsampleToViewSize = false; image.VerticalOptions = LayoutOptions.Center; image.HorizontalOptions = LayoutOptions.Center; view.VerticalOptions = LayoutOptions.CenterAndExpand; layout.VerticalOptions = LayoutOptions.CenterAndExpand; pinchImage.Content = image; //pinchImage.IsClippedToBounds = true; layout.Children.Add(pinchImage); view.Content = layout; modalPage.Content = view; await navigation.PushModalAsync(modalPage); }
/// <summary> /// Gets a value indicating whether the image is new or updated in an asynchronous manner. /// </summary> /// <returns> /// The asynchronous <see cref="Task"/> returning the value. /// </returns> public override async Task <bool> IsNewOrUpdatedAsync() { string cachedFileName = await this.CreateCachedFileNameAsync(); // Collision rate of about 1 in 10000 for the folder structure. // That gives us massive scope to store millions of files. string pathFromKey = string.Join("\\", cachedFileName.ToCharArray().Take(6)); this.CachedPath = Path.Combine(cloudCachedBlobContainer.Uri.ToString(), pathFromKey, cachedFileName).Replace(@"\", "/"); // Do we insert the cache container? This seems to break some setups. bool useCachedContainerInUrl = this.Settings.ContainsKey("UseCachedContainerInUrl") && this.Settings["UseCachedContainerInUrl"].ToLower() != "false"; if (useCachedContainerInUrl) { this.cachedRewritePath = Path.Combine(this.cachedCdnRoot, cloudCachedBlobContainer.Name, pathFromKey, cachedFileName) .Replace(@"\", "/"); } else { this.cachedRewritePath = Path.Combine(this.cachedCdnRoot, pathFromKey, cachedFileName) .Replace(@"\", "/"); } bool isUpdated = false; CachedImage cachedImage = CacheIndexer.Get(this.CachedPath); if (new Uri(this.CachedPath).IsFile) { FileInfo fileInfo = new FileInfo(this.CachedPath); if (fileInfo.Exists) { // Pull the latest info. fileInfo.Refresh(); cachedImage = new CachedImage { Key = Path.GetFileNameWithoutExtension(this.CachedPath), Path = this.CachedPath, CreationTimeUtc = fileInfo.CreationTimeUtc }; CacheIndexer.Add(cachedImage); } } if (cachedImage == null) { string blobPath = this.CachedPath.Substring(cloudCachedBlobContainer.Uri.ToString().Length + 1); CloudBlockBlob blockBlob = cloudCachedBlobContainer.GetBlockBlobReference(blobPath); if (await blockBlob.ExistsAsync()) { // Pull the latest info. await blockBlob.FetchAttributesAsync(); if (blockBlob.Properties.LastModified.HasValue) { cachedImage = new CachedImage { Key = Path.GetFileNameWithoutExtension(this.CachedPath), Path = this.CachedPath, CreationTimeUtc = blockBlob.Properties.LastModified.Value.UtcDateTime }; CacheIndexer.Add(cachedImage); } } } if (cachedImage == null) { // Nothing in the cache so we should return true. isUpdated = true; } else { // Check to see if the cached image is set to expire. if (this.IsExpired(cachedImage.CreationTimeUtc)) { CacheIndexer.Remove(this.CachedPath); isUpdated = true; } } return(isUpdated); }
public PlaceholdersPage() { Title = "Placeholders Demo"; var cachedImage = new CachedImage() { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, WidthRequest = 200, HeightRequest = 200, DownsampleToViewSize = true, CacheDuration = TimeSpan.FromDays(30), RetryCount = 0, TransparencyEnabled = false, }; cachedImage.SetBinding <PlaceholdersPageModel>(CachedImage.LoadingPlaceholderProperty, v => v.LoadingImagePath); cachedImage.SetBinding <PlaceholdersPageModel>(CachedImage.ErrorPlaceholderProperty, v => v.ErrorImagePath); cachedImage.SetBinding <PlaceholdersPageModel>(CachedImage.SourceProperty, v => v.ImagePath); var button1 = new Button() { HorizontalOptions = LayoutOptions.FillAndExpand, Text = "Local Loading Placeholder Example", }; button1.SetBinding <PlaceholdersPageModel>(Button.CommandProperty, v => v.LocalLoadingCommand); var button2 = new Button() { HorizontalOptions = LayoutOptions.FillAndExpand, Text = "Remote Loading Placeholder Example", }; button2.SetBinding <PlaceholdersPageModel>(Button.CommandProperty, v => v.RemoteLoadingCommand); var button3 = new Button() { HorizontalOptions = LayoutOptions.FillAndExpand, Text = "Local Error Placeholder Example", }; button3.SetBinding <PlaceholdersPageModel>(Button.CommandProperty, v => v.LocalErrorCommand); var button4 = new Button() { HorizontalOptions = LayoutOptions.FillAndExpand, Text = "Remote Error Placeholder Example", }; button4.SetBinding <PlaceholdersPageModel>(Button.CommandProperty, v => v.RemoteErrorCommand); var imagePath = new Label() { HorizontalOptions = LayoutOptions.FillAndExpand, FontSize = 9, }; imagePath.SetBinding <PlaceholdersPageModel>(Label.TextProperty, v => v.ImagePath); Content = new ScrollView() { Content = new StackLayout { Children = { imagePath, cachedImage, button1, button2, button3, button4, } } }; }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value == null) { return(null); } string[] Images = (string[])value; var grid = new Grid() { ColumnSpacing = 2, RowSpacing = 2, }; var Photos = Images.Select(x => new Photo() { Title = "", URL = Configuration.ApiConfig.CloudStorageApiCDN + "/" + Folder + "/" + x }).ToList(); if (Images != null) { int end = 1; if (Images.Length == 1) { end = 1; grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }); grid.RowDefinitions.Add(new RowDefinition() { Height = 200 }); } else if (Images.Length == 2) { end = 2; grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }); grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }); grid.RowDefinitions.Add(new RowDefinition() { Height = 150 }); } else if (Images.Length >= 3) { end = 3; grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }); grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }); //grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }); grid.RowDefinitions.Add(new RowDefinition() { Height = 100 }); grid.RowDefinitions.Add(new RowDefinition() { Height = 100 }); } for (int i = 0; i < end; i++) { string imageSource = Configuration.ApiConfig.CloudStorageApiCDN + "/" + Folder + "/" + Images[i]; var img = new CachedImage() { Aspect = Aspect.AspectFill, HeightRequest = 100, Source = imageSource, DownsampleHeight = 100, DownsampleToViewSize = true }; var tap = new TapGestureRecognizer() { NumberOfTapsRequired = 1, CommandParameter = i }; tap.Tapped += (o, e) => { int index = (int)((o as CachedImage).GestureRecognizers[0] as TapGestureRecognizer).CommandParameter; new PhotoBrowser { Photos = Photos, EnableGrid = true, StartIndex = index, }.Show(); }; img.GestureRecognizers.Add(tap); Grid.SetRow(img, 0); Grid.SetColumn(img, i); grid.Children.Add(img); } if (grid.RowDefinitions.Count == 2) { Grid.SetRowSpan(grid.Children[0], 2); Grid.SetColumn(grid.Children[1], 1); Grid.SetRow(grid.Children[1], 0); Grid.SetColumn(grid.Children[2], 1); Grid.SetRow(grid.Children[2], 1); } } return(grid); }
internal static ImageSourceBinding GetImageSourceBinding(ImageSource source, CachedImage element) { if (source == null) { return(null); } var uriImageSource = source as UriImageSource; if (uriImageSource != null) { var uri = uriImageSource.Uri?.OriginalString; if (string.IsNullOrWhiteSpace(uri)) { return(null); } return(new ImageSourceBinding(FFImageLoading.Work.ImageSource.Url, uri)); } var fileImageSource = source as FileImageSource; if (fileImageSource != null) { if (string.IsNullOrWhiteSpace(fileImageSource.File)) { return(null); } if (!string.IsNullOrWhiteSpace(System.IO.Path.GetDirectoryName(fileImageSource.File)) && File.Exists(fileImageSource.File)) { return(new ImageSourceBinding(FFImageLoading.Work.ImageSource.Filepath, fileImageSource.File)); } return(new ImageSourceBinding(FFImageLoading.Work.ImageSource.CompiledResource, fileImageSource.File)); } var streamImageSource = source as StreamImageSource; if (streamImageSource != null) { return(new ImageSourceBinding(streamImageSource.Stream)); } var vectorSource = source as IVectorImageSource; if (vectorSource != null) { if (element.Height > 0d) { vectorSource.UseDipUnits = true; vectorSource.VectorHeight = (int)element.Height; } else if (element.Width > 0d) { vectorSource.UseDipUnits = true; vectorSource.VectorWidth = (int)element.Width; } else if (element.HeightRequest > 0d) { vectorSource.UseDipUnits = true; vectorSource.VectorHeight = (int)element.HeightRequest; } else if (element.WidthRequest > 0d) { vectorSource.UseDipUnits = true; vectorSource.VectorWidth = (int)element.WidthRequest; } else if (element.MinimumHeightRequest > 0d) { vectorSource.UseDipUnits = true; vectorSource.VectorHeight = (int)element.MinimumHeightRequest; } else if (element.MinimumWidthRequest > 0d) { vectorSource.UseDipUnits = true; vectorSource.VectorWidth = (int)element.MinimumWidthRequest; } return(GetImageSourceBinding(vectorSource.ImageSource, element)); } throw new NotImplementedException("ImageSource type not supported"); }
public MenuList() { var masterPageItems = new List <MasterPageItem>(); masterPageItems.Add(new MasterPageItem { Title = AppResources.home, IconSource = "home.png", TargetType = typeof(HomePage), }); masterPageItems.Add(new MasterPageItem { Title = AppResources.profile, IconSource = "profile.png", TargetType = typeof(SellerProfilePage), }); masterPageItems.Add(new MasterPageItem { Title = AppResources.shop, IconSource = "add_on.png", TargetType = typeof(EditShopPage), }); masterPageItems.Add(new MasterPageItem { Title = AppResources.orders, IconSource = "products.png", TargetType = typeof(SellerOrderPage), }); masterPageItems.Add(new MasterPageItem { Title = AppResources.logout, IconSource = "logout.png", TargetType = typeof(LoginPage), }); listView = new ListView { ItemsSource = masterPageItems, ItemTemplate = new DataTemplate(typeof(CustomCell)), VerticalOptions = LayoutOptions.FillAndExpand, SeparatorVisibility = SeparatorVisibility.None, HasUnevenRows = true, BackgroundColor = Color.Transparent, }; Padding = new Thickness(0, 40, 0, 0); Icon = "hamburger.png"; Title = "Personal Organiser"; BackgroundImage = "drawer_bg.png"; BackgroundColor = Color.Transparent; LoggedInUser objUser = App.Database.GetLoggedInUser(); string name = ""; string email = ""; string image = ""; if (objUser != null) { name = objUser.fname + " " + objUser.lname; email = objUser.email; image = string.IsNullOrEmpty(objUser.image) ? "user_placeholder2.png" : objUser.image; } CachedImage img = new CachedImage() { Source = image, HorizontalOptions = LayoutOptions.Center, HeightRequest = 100, WidthRequest = 100, Aspect = Aspect.AspectFit, LoadingPlaceholder = "user_placeholder2.png", Transformations = new List <ITransformation>() { new FFImageLoading.Transformations.CircleTransformation() { BorderSize = 5, BorderHexColor = "#FE1F78" } }, }; Label namelbl = new Label() { Text = name, FontFamily = "CALIBRI", StyleId = "CALIBRI", TextColor = Color.FromHex("#FE1F78"), FontSize = 20, HorizontalTextAlignment = TextAlignment.Center }; Image lineimg = new Image() { Source = "line.png", }; StackLayout _imglinelayout = new StackLayout() { Orientation = StackOrientation.Vertical, BackgroundColor = Color.Transparent, Padding = new Thickness(0, 25, 0, 25), Children = { lineimg } }; StackLayout _layout = new StackLayout() { Orientation = StackOrientation.Vertical, VerticalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.Transparent, Spacing = 0, Children = { img, namelbl, listView } }; Content = new StackLayout { VerticalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.Transparent, Children = { _layout } }; }
/// <summary> /// Merger that based on the classification and the range sets the icon and text /// </summary> /// <param name="classification">The classification int</param> /// <param name="range">The data range for which the images are selected</param> /// <returns>A Tuple of a information string and a icon</returns> private Tuple <string, CachedImage> Merger(int classification, DataRange range) { CachedImage image = new CachedImage(); string text = ""; //Pick a list of images based on the current sensor parameter and classification switch (range.SensorType) { case ("temp"): if (Constants.TEMP_ICONS.ContainsKey(classification)) { image = Constants.TEMP_ICONS[classification]?.GetImage(); switch (classification) { case 1: text = AppResources.issue_temp_ice; break; case 2: text = AppResources.issue_temp_cold; break; case 4: text = AppResources.issue_temp_sweat; break; case 5: text = AppResources.issue_temp_fire; break; default: break; } } break; case ("humid"): if (Constants.HUM_ICONS.ContainsKey(classification)) { image = Constants.HUM_ICONS[classification]?.GetImage(); switch (classification) { case 1: if (tempClass == 5) { text = AppResources.issue_hum_dry_temp_high; } else if (tempClass == 1) { text = AppResources.issue_hum_dry_temp_low; } else { text = AppResources.issue_hum_dry; } break; case 5: if (tempClass == 5) { text = AppResources.issue_hum_wet_temp_high; } else if (tempClass == 1) { text = AppResources.issue_hum_wet_temp_low; } else { text = AppResources.issue_hum_wet; } break; default: break; } } break; case ("co2"): if (Constants.CO2_ICONS.ContainsKey(classification)) { image = Constants.CO2_ICONS[classification]?.GetImage(); switch (classification) { case 2: case 3: case 4: text = AppResources.issue_co2_soft; break; case 5: text = AppResources.issue_co2_severe; break; default: break; } } break; case ("uv"): if (Constants.UV_ICONS.ContainsKey(classification)) { image = Constants.UV_ICONS[classification]?.GetImage(); switch (classification) { case 2: case 3: text = AppResources.issue_uv_what; break; case 4: case 5: text = AppResources.issue_uv_what; break; default: break; } } break; case ("light"): if (Constants.LIGHT_ICONS.ContainsKey(classification)) { image = Constants.LIGHT_ICONS[classification]?.GetImage(); switch (classification) { case 1: text = AppResources.issue_light_dark; break; case 5: text = AppResources.issue_light_bright; break; default: break; } } break; case ("noise"): if (Constants.NOISE_ICONS.ContainsKey(classification)) { image = Constants.NOISE_ICONS[classification]?.GetImage(); switch (classification) { case 2: case 3: case 4: text = AppResources.issue_noise; break; case 5: text = AppResources.issue_noise; break; default: break; } } break; case ("voc"): if (Constants.VOC_ICONS.ContainsKey(classification)) { image = Constants.VOC_ICONS[classification]?.GetImage(); switch (classification) { case 2: case 3: text = AppResources.issue_voc; break; case 4: case 5: text = AppResources.issue_voc; break; default: break; } } break; default: break; } Tuple <string, CachedImage> pair = new Tuple <string, CachedImage>(text, image); return(pair); }
public CropTransformationPage() { Title = "CropTransformation Demo"; ViewModel = new CropTransformationViewModel (); ViewModel.ImagePath = GetRandomImageUrl (); var cachedImage = new CachedImage() { WidthRequest = 300f, HeightRequest = 300f, DownsampleToViewSize = true, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, CacheDuration = TimeSpan.FromDays(30), FadeAnimationEnabled = false, Source = GetRandomImageUrl() }; cachedImage.SetBinding<CropTransformationViewModel>(CachedImage.TransformationsProperty, v => v.Transformations); cachedImage.SetBinding<CropTransformationViewModel>(CachedImage.LoadingPlaceholderProperty, v => v.LoadingImagePath); cachedImage.SetBinding<CropTransformationViewModel>(CachedImage.ErrorPlaceholderProperty, v => v.ErrorImagePath); cachedImage.SetBinding<CropTransformationViewModel>(CachedImage.SourceProperty, v => v.ImagePath); var imagePath = new Label() { HorizontalOptions = LayoutOptions.FillAndExpand, XAlign = TextAlignment.Center, FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Label)) }; imagePath.SetBinding<TransformationExampleViewModel>(Label.TextProperty, v => v.ImagePath); var cropAddXButton = new Button() { HorizontalOptions = LayoutOptions.FillAndExpand, Text = "X+", Command = new Command((o) => ViewModel.AddCurrentXOffsetCommad.Execute (o)), }; var cropSubXButton = new Button() { HorizontalOptions = LayoutOptions.FillAndExpand, Text = "X-", Command = new Command((o)=> ViewModel.SubCurrentXOffsetCommad.Execute(o)), }; var cropAddYButton = new Button() { HorizontalOptions = LayoutOptions.FillAndExpand, Text = "Y+", Command = new Command((o)=> ViewModel.AddCurrentYOffsetCommad.Execute(o)), }; var cropSubYButton = new Button() { HorizontalOptions = LayoutOptions.FillAndExpand, Text = "Y-", Command = new Command((o)=> ViewModel.SubCurrentYOffsetCommad.Execute(o)), }; var cropAddZoomButton = new Button() { HorizontalOptions = LayoutOptions.FillAndExpand, Text = "+", Command = new Command((o)=> ViewModel.AddCurrentZoomFactorCommad.Execute(o)), }; var cropSubZoomButton = new Button() { HorizontalOptions = LayoutOptions.FillAndExpand, Text = "-", Command = new Command((o)=> ViewModel.SubCurrentZoomFactorCommad.Execute(o)), }; var buttonsLayout1 = new StackLayout() { Orientation = StackOrientation.Horizontal, Children = { cropAddXButton, cropSubXButton, cropAddYButton, cropSubYButton, } }; var buttonsLayout2 = new StackLayout() { Orientation = StackOrientation.Horizontal, Children = { cropAddZoomButton, cropSubZoomButton } }; Content = new ScrollView() { Content = new StackLayout { Children = { imagePath, cachedImage, buttonsLayout1, buttonsLayout2, } } }; }
private async void CheckAndConvertToLongUrl(IStatusUpdate oStatusUpdate, InlineLink il, string nmatched) { if (!_textProcessorEngine.ApplicationSettings.AutoExpandUrls || !_textProcessorEngine.UrlExpanders.IsShortUrl(nmatched)) return; //TODO: cleanup the multiple passes, manual vs. web service longurl checker string tmatched = nmatched; //await CheckAndConvertToManualLongUrl(nmatched); // returns nmatched the same if its not a manual url lengthener //tmatched = await _textProcessorEngine.UrlExpanders.ExpandUrl(tmatched); //if (tmatched == null) return; if (_textProcessorEngine.UrlExpanders.IsShortUrl(tmatched)) // go one more round to unshortent the url; useful when t.co shortens an existing shortened link tmatched = await _textProcessorEngine.UrlExpanders.ExpandUrl(tmatched); if (tmatched == null) tmatched = nmatched; //tmatched = await CheckAndConvertToManualLongUrl(nmatched); // and go around again il.Text = _textProcessorEngine.ShortenVisualInlineUrl(tmatched); Uri url; if (!Uri.TryCreate("http://" + il.Text + "/favicon.ico", UriKind.Absolute, out url)) return; var iimage = new CachedImage { Url = url, MaxHeight = _textProcessorEngine.FsDefault, MaxWidth = _textProcessorEngine.FsDefault, Margin = new Thickness(0, 0, 2, 0) }; il.Text = il.Text + Ellipsis; il.Image = iimage; AddAdditionalSmartText(il, tmatched); AddImagePreviewIcon(oStatusUpdate, il, tmatched); }