private void InternalSetText(object text, float textScale, bool large) { DynamicSpriteFont val = large ? FontAssets.DeathText.get_Value() : FontAssets.MouseText.get_Value(); _text = text; _isLarge = large; _textScale = textScale; _lastTextReference = _text.ToString(); if (IsWrapped) { _visibleText = val.CreateWrappedText(_lastTextReference, GetInnerDimensions().Width / _textScale); } else { _visibleText = _lastTextReference; } Vector2 vector = val.MeasureString(_visibleText); Vector2 vector2 = _textSize = ((!IsWrapped) ? (new Vector2(vector.X, large ? 32f : 16f) * textScale) : (new Vector2(vector.X, vector.Y + WrappedTextBottomPadding) * textScale)); MinWidth.Set(vector2.X + PaddingLeft + PaddingRight, 0f); MinHeight.Set(vector2.Y + PaddingTop + PaddingBottom, 0f); if (this.OnInternalTextChange != null) { this.OnInternalTextChange(); } }
protected override void OnInitialized() { _defaultMinWidth = $"{MinWidth.ToString().Replace(",", ".")}px"; _defaultMaxWidth = $"{MaxWidth.ToString().Replace(",", ".")}px"; CreateLocalCss(); base.OnInitialized(); }
public override void OnInitialize() { MediaCache.LoadTexture(Image, out string key); Texture2D temp = MediaCache.GetTexture(key); MinWidth.Set(temp.Width, 0f); MinHeight.Set(temp.Height, 0f); Image = key; }
public virtual void SetText(T text, float textScale) { Vector2 textSize = new Vector2(FontAssets.MouseText.get_Value().MeasureString(text.ToString()).X, 16f) * textScale; _text = text; _textScale = textScale; _textSize = textSize; MinWidth.Set(textSize.X + PaddingLeft + PaddingRight, 0f); MinHeight.Set(textSize.Y + PaddingTop + PaddingBottom, 0f); }
private void InternalSetText(object text, float textScale, bool large) { Vector2 textSize = new Vector2((large ? Main.fontDeathText : Main.fontMouseText).MeasureString(text.ToString()).X, large ? 32f : 16f) * textScale; _textScale = textScale; _textSize = textSize; _isLarge = large; MinWidth.Set(textSize.X + PaddingLeft + PaddingRight, 0f); MinHeight.Set(textSize.Y + PaddingTop + PaddingBottom, 0f); }
/// <summary> /// Returns a hash code for this instance. /// </summary> /// <returns> /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. /// </returns> public override int GetHashCode() { unchecked { var hashCode = Width.GetHashCode(); hashCode = (hashCode * 397) ^ Height.GetHashCode(); hashCode = (hashCode * 397) ^ MinWidth.GetHashCode(); hashCode = (hashCode * 397) ^ MinHeight.GetHashCode(); return(hashCode); } }
public virtual void SetText(T text, float textScale, bool large) { Vector2 textSize = new Vector2((large ? FontAssets.DeathText.Value : FontAssets.MouseText.Value).MeasureString(text.ToString()).X, large ? 32f : 16f) * textScale; _text = text; _textScale = textScale; _textSize = textSize; _isLarge = large; MinWidth.Set(textSize.X + PaddingLeft + PaddingRight, 0f); MinHeight.Set(textSize.Y + PaddingTop + PaddingBottom, 0f); }
public void SetText(string text, float textScale, bool large) { Vector2 vector2 = new Vector2((large ? Main.fontDeathText : Main.fontMouseText).MeasureString(text).X, large ? 32f : 16f) * textScale; _text = text; _textScale = textScale; _textSize = vector2; _isLarge = large; MinWidth.Set(vector2.X + PaddingLeft + PaddingRight, 0.0f); MinHeight.Set(vector2.Y + PaddingTop + PaddingBottom, 0.0f); }
private AttributeSet?GetContentAttributeSet() { return(AttributeSet.Create(builder => builder .AddClassAttribute(x => x .Add("dropdown-content") .Add("right-to-left", !_alignContentLeftToRight) .AddElevation(4)) .AddStyleAttribute(x => x .AddProperty("min-width", MinWidth.ToString(), MinWidth.Value > 0) .AddProperty("max-width", MaxWidth.ToString(), MaxWidth.Value > 0)))); }
private void InternalSetText(object text, float scale, bool large) { Vector2 size = (large ? Main.Xiq12 : Main.Xiq12).MeasureString(text.ToString()) * scale; size.Y = (large ? 28f : 16f) * scale; Text = text; TextScale = scale; TextSize = size; IsLarge = large; MinWidth.Set(size.X + PaddingLeft + PaddingRight, 0f); MinHeight.Set(size.Y + PaddingTop + PaddingBottom, 0f); }
public virtual void SetText(T text, float scale, bool large) { Vector2 size = (large ? Main.Xiq12 : Main.Xiq12).MeasureString(text.ToString()) * scale; size.Y = (large ? 28f : 16f) * scale; this.text = text; TextScale = scale; TextSize = size; IsLarge = large; MinWidth.Set(size.X + PaddingLeft + PaddingRight, 0f); MinHeight.Set(size.Y + PaddingTop + PaddingBottom, 0f); }
public void SetText(string text, float textScale, bool large) { SpriteFont spriteFont = large ? Main.fontDeathText : Main.fontMouseText; Vector2 textSize = new Vector2(spriteFont.MeasureString(text).X, large ? 32f : 16f) * textScale; _text = text; _textScale = textScale; _textSize = textSize; _isLarge = large; MinWidth.Set(textSize.X + PaddingLeft + PaddingRight, 0f); MinHeight.Set(textSize.Y + PaddingTop + PaddingBottom, 0f); }
/// <summary> /// Returns the object's hash code. /// </summary> /// <returns>Hash code.</returns> public override int GetHashCode() { // See http://stackoverflow.com/questions/263400/what-is-the-best-algorithm-for-an-overridden-system-object-gethashcode unchecked { int hash = 17; hash = hash * 23 + PadChar.GetHashCode(); hash = hash * 23 + Alignment.GetHashCode(); hash = hash * 23 + MinWidth.GetHashCode(); hash = hash * 23 + MaxWidth.GetHashCode(); return(hash); } }
public void Render(IOutputStream outputStream) { if (MinWidth != null) { outputStream.Write(HTMLElements.m_space); outputStream.Write(HTMLElements.m_styleMinWidth); outputStream.Write(HTMLElements.m_space); MinWidth.Render(outputStream); outputStream.Write(HTMLElements.m_semiColon); } if (MinHeight != null) { outputStream.Write(HTMLElements.m_space); outputStream.Write(HTMLElements.m_styleMinHeight); outputStream.Write(HTMLElements.m_space); MinHeight.Render(outputStream); outputStream.Write(HTMLElements.m_semiColon); } if (MaxHeight != null) { outputStream.Write(HTMLElements.m_space); outputStream.Write(HTMLElements.m_styleMaxHeight); outputStream.Write(HTMLElements.m_space); MaxHeight.Render(outputStream); outputStream.Write(HTMLElements.m_semiColon); } if (MaxWidth != null) { outputStream.Write(HTMLElements.m_space); outputStream.Write(HTMLElements.m_styleMaxWidth); outputStream.Write(HTMLElements.m_space); MaxWidth.Render(outputStream); outputStream.Write(HTMLElements.m_semiColon); } if (Width != null) { outputStream.Write(HTMLElements.m_space); outputStream.Write(HTMLElements.m_styleWidth); outputStream.Write(HTMLElements.m_space); Width.Render(outputStream); outputStream.Write(HTMLElements.m_semiColon); } if (Height != null) { outputStream.Write(HTMLElements.m_space); outputStream.Write(HTMLElements.m_styleHeight); outputStream.Write(HTMLElements.m_space); Height.Render(outputStream); outputStream.Write(HTMLElements.m_semiColon); } }
public UIButtonChoice(GUIBase parent, Texture2D[] _butons, LocalizedText[] mouseText) { if (_butons.Length != mouseText.Length || _butons.Length == 0) { throw new ArgumentException(); } buttons = _butons; mouseOverTexts = mouseText; parentGui = parent; int width = BUTTON_SIZE * _butons.Length + BUTTON_PADDING * (_butons.Length - 1); Width.Set(width, 0f); MinWidth.Set(width, 0f); Height.Set(BUTTON_SIZE, 0f); MinHeight.Set(BUTTON_SIZE, 0f); }
public override void ResizeThis(Rectangle parentRectangle) { //scale all relative values to parent rectangle Margin.Resize(parentRectangle.Size); FlexWidth.Resize(parentRectangle.Width); FlexHeight.Resize(parentRectangle.Height); MaxWidth.Resize(parentRectangle.Width); MinWidth.Resize(parentRectangle.Width); MaxHeight.Resize(parentRectangle.Height); MinHeight.Resize(parentRectangle.Height); //clamp size to min and max Width = MathHelper.Clamp(FlexWidth.Absolute / SEGMENT_WIDTH, MinWidth.Absolute, MaxWidth.Absolute) * SEGMENT_WIDTH; Height = MathHelper.Clamp(FlexHeight.Absolute, MinHeight.Absolute, MaxHeight.Absolute); //if control is square, conform both width and height to the larger of the two if (IsSquare) { Width = Height = Math.Min(Width, Height); } X = HorizontalAlign switch { HorizontalAlign.Center => (parentRectangle.X + (parentRectangle.Width / 2) - (Width / 2)), HorizontalAlign.Left => parentRectangle.Left + Margin.Left, _ => parentRectangle.Right - Width - Margin.Right }; Y = VerticalAlign switch { VerticalAlign.Center => (parentRectangle.Top + parentRectangle.Height / 2 - Height / 2), VerticalAlign.Top => parentRectangle.Top + Margin.Top, _ => parentRectangle.Bottom - Height - Margin.Bottom }; Padding.Resize(Size); //calculate internal rectangle ContentRectangle = new Rectangle(X + Margin.Left + Padding.Left, Y + Margin.Top + Padding.Top, Width - Padding.Horizontal, Height - Padding.Vertical); }
protected override void WriteDataXML(XElement ele, ElderScrollsPlugin master) { XElement subEle; ele.TryPathTo("Width/Min", true, out subEle); subEle.Value = MinWidth.ToString("G15"); ele.TryPathTo("Width/Max", true, out subEle); subEle.Value = MaxWidth.ToString("G15"); ele.TryPathTo("Height/Min", true, out subEle); subEle.Value = MinHeight.ToString("G15"); ele.TryPathTo("Height/Max", true, out subEle); subEle.Value = MaxHeight.ToString("G15"); ele.TryPathTo("Depth", true, out subEle); subEle.Value = Depth.ToString("G15"); ele.TryPathTo("Shininess", true, out subEle); subEle.Value = Shininess.ToString("G15"); ele.TryPathTo("Parallax/Scale", true, out subEle); subEle.Value = ParallaxScale.ToString("G15"); ele.TryPathTo("Parallax/Passes", true, out subEle); subEle.Value = ParallaxPasses.ToString(); ele.TryPathTo("Flags", true, out subEle); subEle.Value = DecalFlags.ToString(); WriteUnusedXML(ele, master); ele.TryPathTo("Color", true, out subEle); Color.WriteXML(subEle, master); }
private async void LoadImage() { if (_currentTask != null) { _currentTask.Cancel(); } TaskParameter imageLoader = null; var ffSource = await FFImageSourceBinding.GetImageSourceBinding(Source); if (ffSource == null) { if (internalImage != null) { await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { internalImage.Source = null; }); } } else if (ffSource.ImageSource == FFImageLoading.Work.ImageSource.Url) { imageLoader = ImageService.LoadUrl(ffSource.Path, TimeSpan.FromDays(CacheDuration)); } else if (ffSource.ImageSource == FFImageLoading.Work.ImageSource.CompiledResource) { imageLoader = ImageService.LoadCompiledResource(ffSource.Path); } else if (ffSource.ImageSource == FFImageLoading.Work.ImageSource.ApplicationBundle) { imageLoader = ImageService.LoadFileFromApplicationBundle(ffSource.Path); } else if (ffSource.ImageSource == FFImageLoading.Work.ImageSource.Filepath) { imageLoader = ImageService.LoadFile(ffSource.Path); } if (imageLoader != null) { // LoadingPlaceholder if (LoadingPlaceholder != null) { var placeholderSource = await FFImageSourceBinding.GetImageSourceBinding(LoadingPlaceholder); if (placeholderSource != null) { imageLoader.LoadingPlaceholder(placeholderSource.Path, placeholderSource.ImageSource); } } // ErrorPlaceholder if (ErrorPlaceholder != null) { var placeholderSource = await FFImageSourceBinding.GetImageSourceBinding(ErrorPlaceholder); if (placeholderSource != null) { imageLoader.ErrorPlaceholder(placeholderSource.Path, placeholderSource.ImageSource); } } // Downsample if (DownsampleToViewSize && (Width > 0 || Height > 0)) { if (Height > Width) { imageLoader.DownSample(height: Height.PointsToPixels()); } else { imageLoader.DownSample(width: Width.PointsToPixels()); } } else if (DownsampleToViewSize && (MinWidth > 0 || MinHeight > 0)) { if (MinHeight > MinWidth) { imageLoader.DownSample(height: MinHeight.PointsToPixels()); } else { imageLoader.DownSample(width: MinWidth.PointsToPixels()); } } else if ((int)DownsampleHeight != 0 || (int)DownsampleWidth != 0) { if (DownsampleHeight > DownsampleWidth) { imageLoader.DownSample(height: DownsampleUseDipUnits ? DownsampleHeight.PointsToPixels() : (int)DownsampleHeight); } else { imageLoader.DownSample(width: DownsampleUseDipUnits ? DownsampleWidth.PointsToPixels() : (int)DownsampleWidth); } } // Downsample mode imageLoader.DownSampleMode(DownsampleMode); // RetryCount if (RetryCount > 0) { imageLoader.Retry(RetryCount, RetryDelay); } // FadeAnimation imageLoader.FadeAnimation(FadeAnimationEnabled); // TransformPlaceholders imageLoader.TransformPlaceholders(TransformPlaceholders); // Transformations if (Transformations != null && Transformations.Count != 0) { imageLoader.Transform(Transformations); } _currentTask = imageLoader.Into(internalImage); } }
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { var hasColon = Title?.Trim() != "~"; var td = new StringBuilder($"<td>{Title + (hasColon ? ":" : "")}</td><td{(ColSpan.HasValue ? $" colspan='{ColSpan}'" : "")}>"); if (ContentTag != null) { var innerOutput = CreateTagHelperOutput(); if (Field.IsNotNullOrWhiteSpace()) { innerOutput.Attributes.Add("name", Field.ToCamelCase()); } var css = ""; if (Height.IsNotNullOrWhiteSpace()) { css += $"height: {Height};"; } if (Width.IsNotNullOrWhiteSpace()) { css += $"width: {Width};"; } if (MinWidth.IsNotNullOrWhiteSpace()) { css += $"min-width: {MinWidth};"; } if (ColSpan > 1 && Width.IsNullOrWhiteSpace()) { css += "width: 100%;"; } if (css != "") { innerOutput.Attributes.Add("style", css); } var innerTagContent = await RenderInnerTagHelper(ContentTag, context, innerOutput); td.Append(innerTagContent); } else { var content = await output.GetChildContentAsync(); td.Append(content.GetContent()); if (Field.IsNotNullOrWhiteSpace()) { var doc = ParseHtml(ChildContent); var contentElement = doc.Body.FirstElementChild; contentElement.SetAttribute("name", Field.ToCamelCase()); ChildContent = contentElement.OuterHtml; } td.Append(ChildContent); } if (Sort.HasValue) { output.Attributes.Add(EasyuiConsts.Item_Sort, Sort); } if (ReplaceField.IsNotNullOrWhiteSpace()) { output.Attributes.Add(EasyuiConsts.Item_Replace, ReplaceField); } td.Append("</td>"); output.Content.AppendHtml(td.ToString()); await base.ProcessAsync(context, output); }
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { var hasColon = Title?.Trim() != "~"; //var td = new StringBuilder($"<td>{Title + (hasColon ? ":" : "")}</td><td{(ColSpan.HasValue ? $" colspan='{ColSpan}'" : "")}>"); var md = ColMd > 12 ? 12 : ColMd; var colspan = ColSpan > 0 ? $" {LayuiConsts.Colspan}='{ColSpan}' " : ""; var sort = Sort.HasValue ? $" {LayuiConsts.Item_Sort}='{Sort}' " : ""; var title = Title.IsNotNullOrWhiteSpace() ? $"<label class='layui-form-label'>{Title}</label>" : ""; var replace = ReplaceField.IsNotNullOrWhiteSpace() ? $" {LayuiConsts.Item_Replace}='{ReplaceField}' " : ""; if (ColSpan > 0) { md = md * ColSpan.Value; } var div = new StringBuilder($"<div class='layui-form-item layui-col-md{md}'{colspan}{sort}{replace}>{title}<div class='layui-input-block'>"); if (ContentTag != null) { var innerOutput = CreateTagHelperOutput(); if (Field.IsNotNullOrWhiteSpace()) { innerOutput.Attributes.Add("name", Field.ToCamelCase()); } var css = ""; if (Height.IsNotNullOrWhiteSpace()) { css += $"height: {Height};"; } if (Width.IsNotNullOrWhiteSpace()) { css += $"width: {Width};"; } if (MinWidth.IsNotNullOrWhiteSpace()) { css += $"min-width: {MinWidth};"; } if (ColSpan > 1) { css += "width: 100%;"; } if (css != "") { innerOutput.Attributes.Add("style", css); } var innerTagContent = await RenderInnerTagHelper(ContentTag, context, innerOutput); div.Append(innerTagContent); } else { var content = await output.GetChildContentAsync(); div.Append(content.GetContent()); div.Append(ChildContent); } if (Sort.HasValue) { output.Attributes.Add(LayuiConsts.Item_Sort, Sort); } if (ReplaceField.IsNotNullOrWhiteSpace()) { output.Attributes.Add(LayuiConsts.Item_Replace, ReplaceField); } div.Append(" </div> </div>"); output.Content.AppendHtml(div.ToString()); await base.ProcessAsync(context, output); }
public bool Equals(ContentTypeProperty input) { if (input == null) { return(false); } return (( Name == input.Name || (Name != null && Name.Equals(input.Name)) ) && ( RootPropertyName == input.RootPropertyName || (RootPropertyName != null && RootPropertyName.Equals(input.RootPropertyName)) ) && ( ReadableName == input.ReadableName || (ReadableName != null && ReadableName.Equals(input.ReadableName)) ) && ( Value == input.Value || (Value != null && Value.Equals(input.Value)) ) && ( PropertyDescription == input.PropertyDescription || (PropertyDescription != null && PropertyDescription.Equals(input.PropertyDescription)) ) && ( Localizable == input.Localizable || (Localizable != null && Localizable.Equals(input.Localizable)) ) && ( Fallback == input.Fallback || (Fallback != null && Fallback.Equals(input.Fallback)) ) && ( Enabled == input.Enabled || (Enabled != null && Enabled.Equals(input.Enabled)) ) && ( Order == input.Order || (Order.Equals(input.Order)) ) && ( Visible == input.Visible || (Visible != null && Visible.Equals(input.Visible)) ) && ( IsTitle == input.IsTitle || (IsTitle != null && IsTitle.Equals(input.IsTitle)) ) && ( Required == input.Required || (Required != null && Required.Equals(input.Required)) ) && ( MaxLength == input.MaxLength || (MaxLength.Equals(input.MaxLength)) ) && ( MaxByteLength == input.MaxByteLength || (MaxByteLength.Equals(input.MaxByteLength)) ) && ( MaxFileSize == input.MaxFileSize || (MaxFileSize.Equals(input.MaxFileSize)) ) && ( Regexp == input.Regexp || (Regexp != null && Regexp.Equals(input.Regexp)) ) && ( ValidateAs == input.ValidateAs || (ValidateAs != null && ValidateAs.Equals(input.ValidateAs)) ) && ( RssAttribute == input.RssAttribute || (RssAttribute != null && RssAttribute.Equals(input.RssAttribute)) ) && ( VisibleDependency == input.VisibleDependency || (VisibleDependency != null && VisibleDependency.Equals(input.VisibleDependency)) ) && ( VisibleOn == input.VisibleOn || (VisibleOn != null && VisibleOn.Equals(input.VisibleOn)) ) && ( Datatype == input.Datatype || (Datatype != null && Datatype.Equals(input.Datatype)) ) && ( Attributes == input.Attributes || (Attributes != null && Attributes.SequenceEqual(input.Attributes)) ) && ( ChildProperties == input.ChildProperties || (ChildProperties != null && ChildProperties.SequenceEqual(input.ChildProperties)) ) && ( ContentTypeAllowed == input.ContentTypeAllowed || (ContentTypeAllowed != null && ContentTypeAllowed.Equals(input.ContentTypeAllowed)) ) && ( BindToProperty == input.BindToProperty || (BindToProperty != null && BindToProperty.Equals(input.BindToProperty)) ) && ( BoundRegex == input.BoundRegex || (BoundRegex != null && BoundRegex.Equals(input.BoundRegex)) ) && ( RepresentationSelection == input.RepresentationSelection || (RepresentationSelection != null && RepresentationSelection.SequenceEqual(input.RepresentationSelection)) ) && ( DefaultValues == input.DefaultValues || (DefaultValues != null && DefaultValues.SequenceEqual(input.DefaultValues)) ) && ( IsExternalAllowed == input.IsExternalAllowed || (IsExternalAllowed != null && IsExternalAllowed.Equals(input.IsExternalAllowed)) ) && ( PropertySection == input.PropertySection || (PropertySection != null && PropertySection.Equals(input.PropertySection)) ) && ( Weight == input.Weight || (Weight.Equals(input.Weight)) ) && ( Entitytype == input.Entitytype || (Entitytype != null && Entitytype.Equals(input.Entitytype)) ) && ( IsCombo == input.IsCombo || (IsCombo != null && IsCombo.Equals(input.IsCombo)) ) && ( SuppressProperty == input.SuppressProperty || (SuppressProperty != null && SuppressProperty.Equals(input.SuppressProperty)) ) && ( LegalContentTypes == input.LegalContentTypes || (LegalContentTypes != null && LegalContentTypes.SequenceEqual(input.LegalContentTypes)) ) && ( RepresentationValidationString == input.RepresentationValidationString || (RepresentationValidationString != null && RepresentationValidationString.Equals(input.RepresentationValidationString)) ) && ( MinWidth == input.MinWidth || (MinWidth.Equals(input.MinWidth)) ) && ( MaxWidth == input.MaxWidth || (MaxWidth.Equals(input.MaxWidth)) ) && ( MinHeight == input.MinHeight || (MinHeight.Equals(input.MinHeight)) ) && ( MaxHeight == input.MaxHeight || (MaxHeight.Equals(input.MaxHeight)) ) && ( IsVideo == input.IsVideo || (IsVideo != null && IsVideo.Equals(input.IsVideo)) ) && ( IsImage == input.IsImage || (IsImage != null && IsImage.Equals(input.IsImage)) )); }
/// <summary> /// Equalses the specified other. /// </summary> /// <param name="other">The other.</param> /// <returns></returns> public bool Equals(ExtendedSize other) { return(Width.Equals(other.Width) && Height.Equals(other.Height) && MinWidth.Equals(other.MinWidth) && MinHeight.Equals(other.MinHeight)); }
/// <summary> /// Create url query string. /// </summary> /// <returns>query string</returns> public override string ToString() { var sb = new StringBuilder(); if (!String.IsNullOrEmpty(Query)) { sb.Append($"&q={HttpTools.UriEncode(Query)}"); } if (Language != null) { sb.Append($"&lang={Language.ToString().ToLower()}"); } if (!String.IsNullOrEmpty(Id)) { sb.Append($"&id={Id}"); } if (Category != null) { sb.Append($"&category={Category.ToString().ToLower()}"); } if (MinWidth != null && MinWidth != 0) { sb.Append($"&min_width={MinWidth.ToString().ToLower()}"); } if (MinHeight != null && MinHeight != 0) { sb.Append($"&min_height={MinHeight.ToString().ToLower()}"); } if (IsEditorsChoice != null) { sb.Append($"&editors_choice={IsEditorsChoice.ToString().ToLower()}"); } if (IsSafeSearch != null) { sb.Append($"&safesearch={IsSafeSearch.ToString().ToLower()}"); } if (Order != null) { sb.Append($"&order={Order.ToString().ToLower()}"); } if (Page != null) { sb.Append($"&page={Page}"); } if (PerPage != null) { sb.Append($"&per_page={PerPage}"); } return(sb.ToString()); }
private async void LoadImage() { if (_currentTask != null) { _currentTask.Cancel(); } TaskParameter imageLoader = null; var ffSource = await FFImageSourceBinding.GetImageSourceBinding(Source); if (ffSource == null) { if (internalImage != null) { await MainThreadDispatcher.Instance.PostAsync(() => { internalImage.Source = null; }); } } else if (ffSource.ImageSource == FFImageLoading.Work.ImageSource.Url) { imageLoader = ImageService.LoadUrl(ffSource.Path, TimeSpan.FromDays(CacheDuration)); } else if (ffSource.ImageSource == FFImageLoading.Work.ImageSource.CompiledResource) { imageLoader = ImageService.LoadCompiledResource(ffSource.Path); } else if (ffSource.ImageSource == FFImageLoading.Work.ImageSource.ApplicationBundle) { imageLoader = ImageService.LoadFileFromApplicationBundle(ffSource.Path); } else if (ffSource.ImageSource == FFImageLoading.Work.ImageSource.Filepath) { imageLoader = ImageService.LoadFile(ffSource.Path); } if (imageLoader != null) { // CustomKeyFactory if (CacheKeyFactory != null) { var dataContext = DataContext; imageLoader.CacheKey(CacheKeyFactory.GetKey(Source, dataContext)); } // LoadingPlaceholder if (LoadingPlaceholder != null) { var placeholderSource = await FFImageSourceBinding.GetImageSourceBinding(LoadingPlaceholder); if (placeholderSource != null) { imageLoader.LoadingPlaceholder(placeholderSource.Path, placeholderSource.ImageSource); } } // ErrorPlaceholder if (ErrorPlaceholder != null) { var placeholderSource = await FFImageSourceBinding.GetImageSourceBinding(ErrorPlaceholder); if (placeholderSource != null) { imageLoader.ErrorPlaceholder(placeholderSource.Path, placeholderSource.ImageSource); } } // Downsample if (DownsampleToViewSize && (Width > 0 || Height > 0)) { if (Height > Width) { imageLoader.DownSample(height: Height.PointsToPixels()); } else { imageLoader.DownSample(width: Width.PointsToPixels()); } } else if (DownsampleToViewSize && (MinWidth > 0 || MinHeight > 0)) { if (MinHeight > MinWidth) { imageLoader.DownSample(height: MinHeight.PointsToPixels()); } else { imageLoader.DownSample(width: MinWidth.PointsToPixels()); } } else if ((int)DownsampleHeight != 0 || (int)DownsampleWidth != 0) { if (DownsampleHeight > DownsampleWidth) { imageLoader.DownSample(height: DownsampleUseDipUnits ? DownsampleHeight.PointsToPixels() : (int)DownsampleHeight); } else { imageLoader.DownSample(width: DownsampleUseDipUnits ? DownsampleWidth.PointsToPixels() : (int)DownsampleWidth); } } // Downsample mode imageLoader.DownSampleMode(DownsampleMode); // RetryCount if (RetryCount > 0) { imageLoader.Retry(RetryCount, RetryDelay); } // FadeAnimation imageLoader.FadeAnimation(FadeAnimationEnabled); // TransformPlaceholders imageLoader.TransformPlaceholders(TransformPlaceholders); // Transformations if (Transformations != null && Transformations.Count != 0) { imageLoader.Transform(Transformations); } imageLoader.Finish((work) => OnFinish(new Args.FinishEventArgs(work))); imageLoader.Success((imageSize, loadingResult) => OnSuccess(new Args.SuccessEventArgs(imageSize, loadingResult))); imageLoader.Error((exception) => OnError(new Args.ErrorEventArgs(exception))); _currentTask = imageLoader.Into(internalImage); } }