本文整理匯總了C#中Anchor.ToString方法的典型用法代碼示例。如果您正苦於以下問題:C# Anchor.ToString方法的具體用法?C# Anchor.ToString怎麽用?C# Anchor.ToString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Anchor
的用法示例。
在下文中一共展示了Anchor.ToString方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: GetImageProcessorUrl
public static string GetImageProcessorUrl(
this string imageUrl,
int? width = null,
int? height = null,
int? quality = null,
Mode? mode = null,
Anchor? anchor = null,
string imageCropperValue = null,
string imageCropperCropId = null,
string furtherOptions = null,
bool slimmage = false)
{
if (!string.IsNullOrEmpty(imageUrl))
{
var imageResizerUrl = new StringBuilder();
imageResizerUrl.Append(imageUrl);
if (!string.IsNullOrEmpty(imageCropperValue) && imageCropperValue.IsJson())
{
var allTheCrops = imageCropperValue.GetImageCrops();
if (allTheCrops != null && allTheCrops.Any())
{
var crop = imageCropperCropId != null
? allTheCrops.Find(x => x.Id == imageCropperCropId)
: allTheCrops.First();
if (crop != null)
{
imageResizerUrl.Append("?crop=" + crop.CropCoOrds);
}
}
}
else
{
if (mode == null)
{
mode = Mode.Pad;
}
imageResizerUrl.Append("?mode=" + mode.ToString().ToLower());
if (anchor != null)
{
imageResizerUrl.Append("&anchor=" + anchor.ToString().ToLower());
}
}
if (quality != null)
{
imageResizerUrl.Append("&quality=" + quality);
}
if (width != null)
{
imageResizerUrl.Append("&width=" + width);
}
if (height != null)
{
imageResizerUrl.Append("&height=" + height);
}
if (slimmage)
{
if (width == null)
{
imageResizerUrl.Append("&width=300");
}
if (quality == null)
{
imageResizerUrl.Append("&quality=90");
}
imageResizerUrl.Append("&slimmage=true");
}
if (furtherOptions != null)
{
imageResizerUrl.Append(furtherOptions);
}
return imageResizerUrl.ToString();
}
return string.Empty;
}