Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using umbraco.cms.businesslogic.datatype;
- using System.Collections;
- namespace Kyber.Entities
- {
- public class CropFormats
- {
- private List<CropFormat> _lCropFormats = new List<CropFormat>();
- public CropFormats()
- {
- Guid _g = new Guid("7a2d436c-34c2-410f-898f-4a23b3d79f54"); // Guid of the imgage cropper datatype
- DataTypeDefinition _dtdImageCropper = DataTypeDefinition.GetByDataTypeId(_g);
- SortedList _sortedList = PreValues.GetPreValues(_dtdImageCropper.Id);
- if (_sortedList != null && _sortedList.Count > 0)
- {
- PreValue _preValue = (PreValue)_sortedList[0];
- this.ParseImageCropperPreValueString(_preValue.Value.ToString());
- }
- }
- public List<CropFormat> AvailableCropFormats
- {
- get
- {
- return this._lCropFormats;
- }
- }
- private void ParseImageCropperPreValueString(String _sImageCropperPrevalue)
- {
- // Example string umbracoFile,1,1|Hovedbilde,660,286,1,CM;Oversiktsbilde,170,135,1,CM;test,200,200,1,LT
- String[] _aSplitByPipe = _sImageCropperPrevalue.Split('|');
- if (_aSplitByPipe.Length > 1) // two lines
- {
- if (!String.IsNullOrEmpty(_aSplitByPipe[1]))
- {
- String[] _aCropTypes = _aSplitByPipe[1].Split(';');
- foreach (String _sCropType in _aCropTypes)
- {
- String[] _aCropTypeProperties = _sCropType.Split(',');
- String _sCropName = _aCropTypeProperties[0];
- String _sWidth = _aCropTypeProperties[1];
- String _sHeight = _aCropTypeProperties[2];
- String _sBKeepAspectRatio = _aCropTypeProperties[3];
- String _sDefaultPosition = _aCropTypeProperties[4];
- _lCropFormats.Add(new CropFormat(_sCropName, _sWidth, _sHeight, _sBKeepAspectRatio, _sDefaultPosition));
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement