示例#1
0
        /// <summary>
        /// </summary>
        /// <param name = "e">The <see cref = "System.EventArgs" /> instance containing the event data.</param>
        private void DataEditorControl_OnSave(EventArgs e)
        {
            var prevalueEditor = (ImageResizerPrevalueEditor)PrevalueEditor;
            var imageUrl       = ImageResizerHelper.ResizeImage(ImageResizerHelper.GetOriginalUrl(ImageResizerHelper.CurrentNodeId, prevalueEditor), prevalueEditor.MaxHeight, prevalueEditor.MaxHeight);

            _imageResizerDataEditor.ImageUrl = imageUrl;

            base.Data.Value = _imageResizerDataEditor.ImageUrl;
        }
示例#2
0
        /// <summary>
        /// Handles the PreRender event of the _colorPickerDataEditor control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void ImageResizerDataEditorPreRender(object sender, EventArgs e)
        {
            var prevalueEditor = (ImageResizerPrevalueEditor)PrevalueEditor;

            _imageResizerDataEditor.PropertyAlias = prevalueEditor.PropertyAlias;
            _imageResizerDataEditor.ImageUrl      = base.Data.Value.ToString();

            var propertyOk = ImageResizerHelper.GetOriginalUrl(ImageResizerHelper.CurrentNodeId, prevalueEditor) != string.Empty;

            _imageResizerDataEditor.Toggle(propertyOk);
        }
示例#3
0
 /// <summary>
 /// Toggles the specified property ok.
 /// </summary>
 /// <param name="propertyOk">if set to <c>true</c> [property ok].</param>
 internal void Toggle(bool propertyOk)
 {
     if (propertyOk)
     {
         _imageResizerImage.Visible = true;
         _imageResizerLabel.Text    = string.Format("<p>{0}</p>", ImageResizerHelper.GetSizeString(ImageUrl));
     }
     else
     {
         _imageResizerImage.Visible = false;
         _imageResizerLabel.Text    = "<strong>No image to resize</strong>";
     }
 }
        /// <summary>
        /// Processes the properties.
        /// Will resize images when ImageResizer property is found
        /// </summary>
        /// <param name="node">The node.</param>
        private static void ProcessProperties(Content node)
        {
            var nodeId     = node.Id;
            var properties = node.GenericProperties;

            foreach (var property in properties)
            {
                // Check if this is an ImageResizer property
                if (property.PropertyType.DataTypeDefinition.DataType.Id != ImageResizerHelper.DataTypeId)
                {
                    continue;
                }

                // Resize the image
                var prevalueEditor = (ImageResizerPrevalueEditor)property.PropertyType.DataTypeDefinition.DataType.PrevalueEditor;

                ImageResizerHelper.ResizeImage(ImageResizerHelper.GetOriginalUrl(nodeId, prevalueEditor), prevalueEditor.MaxHeight, prevalueEditor.MaxHeight);
            }
        }