コード例 #1
0
        private void imagePickerAlign_SelectedIndexChanged(object sender, EventArgs e)
        {
            AlignmentComboItem selectedAlignment = imagePickerAlign.SelectedItem as AlignmentComboItem;

            if (selectedAlignment != null)
            {
                Alignment = (ImgAlignment)selectedAlignment.ItemValue;
            }
        }
コード例 #2
0
 public AlignmentComboItem(string text, ImgAlignment alignment, Image borderImage) : base(text, alignment)
 {
     image = borderImage;
 }
コード例 #3
0
 public AlignmentComboItem(string text, ImgAlignment alignment, Image borderImage) : base(text, alignment)
 {
     image = borderImage;
 }
コード例 #4
0
 private void imagePickerAlign_SelectedIndexChanged(object sender, EventArgs e)
 {
     AlignmentComboItem selectedAlignment = imagePickerAlign.SelectedItem as AlignmentComboItem;
     if (selectedAlignment != null)
         Alignment = (ImgAlignment)selectedAlignment.ItemValue;
 }
コード例 #5
0
        // Set the alignment of the image
        internal void SetImageHtmlFromAlignment(ImgAlignment value)
        {
            bool needToSelectImage = false;

            switch (value)
            {
            case ImgAlignment.NONE:
                // If we removed the centering node, we need to reselect the image since the selection
                // is invalidated/changed as a result of removing the node.
                needToSelectImage = RemoveCenteringNode();

                _element.removeAttribute("align", 0);
                _element.style.display    = "inline";
                _element.style.styleFloat = null;

                if (_element.style.marginLeft != null && _element.style.marginLeft.ToString() == "auto")
                {
                    _element.style.marginLeft = 0;
                }
                if (_element.style.marginRight != null && _element.style.marginRight.ToString() == "auto")
                {
                    _element.style.marginRight = 0;
                }

                break;

            case ImgAlignment.LEFT:
            case ImgAlignment.RIGHT:
                // If we removed the centering node, we need to reselect the image since the selection
                // is invalidated/changed as a result of removing the node.
                needToSelectImage = RemoveCenteringNode();

                _element.style.display    = "inline";
                _element.style.styleFloat = value.ToString().ToLower(CultureInfo.InvariantCulture);
                if (_element.style.marginLeft != null && _element.style.marginLeft.ToString() == "auto")
                {
                    _element.style.marginLeft = 0;
                }
                if (_element.style.marginRight != null && _element.style.marginRight.ToString() == "auto")
                {
                    _element.style.marginRight = 0;
                }
                // For all other types of alignment we just set the align property on the image
                _element.setAttribute("align", value.ToString().ToLower(CultureInfo.InvariantCulture), 0);

                break;

            case ImgAlignment.CENTER:
                _element.removeAttribute("align", 0);
                _element.style.styleFloat = null;

                if (GlobalEditorOptions.SupportsFeature(ContentEditorFeature.CenterImageWithParagraph))
                {
                    IHTMLElement element = FindCenteringNode();
                    if (element == null)
                    {
                        // There is no existing centering node, we need to create a new one.
                        // Creating the new centering node invalidates/changes the existing selection
                        // so we need to reselect the image.
                        needToSelectImage = true;
                        element           = CreateNodeForCentering();
                    }
                    if (element != null)
                    {
                        element.setAttribute("align", "center", 0);
                    }
                }
                else
                {
                    _element.style.display     = "block";
                    _element.style.styleFloat  = "none";
                    _element.style.marginLeft  = "auto";
                    _element.style.marginRight = "auto";
                }
                break;

            default:
                Trace.Fail("Unknown image alignment: " + value.ToString());
                break;
            }

            if (needToSelectImage)
            {
                // If we need to reselect the image, do it after we have set the right
                // alignment in the element above so that when the selection change event
                // refreshes the ribbon commands using the html doc, it sees the new values.
                SelectImage();
            }
        }
コード例 #6
0
        // Set the alignment of the image
        internal void SetImageHtmlFromAlignment(ImgAlignment value)
        {
            bool needToSelectImage = false;
            switch (value)
            {
                case ImgAlignment.NONE:
                    // If we removed the centering node, we need to reselect the image since the selection
                    // is invalidated/changed as a result of removing the node.
                    needToSelectImage = RemoveCenteringNode();

                    _element.removeAttribute("align", 0);
                    _element.style.display = "inline";
                    _element.style.styleFloat = null;

                    if (_element.style.marginLeft != null && _element.style.marginLeft.ToString() == "auto")
                        _element.style.marginLeft = 0;
                    if (_element.style.marginRight != null && _element.style.marginRight.ToString() == "auto")
                        _element.style.marginRight = 0;

                    break;
                case ImgAlignment.LEFT:
                case ImgAlignment.RIGHT:
                    // If we removed the centering node, we need to reselect the image since the selection
                    // is invalidated/changed as a result of removing the node.
                    needToSelectImage = RemoveCenteringNode();

                    _element.style.display = "inline";
                    _element.style.styleFloat = value.ToString().ToLower(CultureInfo.InvariantCulture);
                    if (_element.style.marginLeft != null && _element.style.marginLeft.ToString() == "auto")
                        _element.style.marginLeft = 0;
                    if (_element.style.marginRight != null && _element.style.marginRight.ToString() == "auto")
                        _element.style.marginRight = 0;
                    // For all other types of alignment we just set the align property on the image
                    _element.setAttribute("align", value.ToString().ToLower(CultureInfo.InvariantCulture), 0);

                    break;
                case ImgAlignment.CENTER:
                    _element.removeAttribute("align", 0);
                    _element.style.styleFloat = null;

                    if (GlobalEditorOptions.SupportsFeature(ContentEditorFeature.CenterImageWithParagraph))
                    {
                        IHTMLElement element = FindCenteringNode();
                        if (element == null)
                        {
                            // There is no existing centering node, we need to create a new one.
                            // Creating the new centering node invalidates/changes the existing selection
                            // so we need to reselect the image.
                            needToSelectImage = true;
                            element = CreateNodeForCentering();
                        }
                        if (element != null)
                        {
                            element.setAttribute("align", "center", 0);
                        }
                    }
                    else
                    {
                        _element.style.display = "block";
                        _element.style.styleFloat = "none";
                        _element.style.marginLeft = "auto";
                        _element.style.marginRight = "auto";
                    }
                    break;
                default:
                    Trace.Fail("Unknown image alignment: " + value.ToString());
                    break;
            }

            if (needToSelectImage)
            {
                // If we need to reselect the image, do it after we have set the right
                // alignment in the element above so that when the selection change event
                // refreshes the ribbon commands using the html doc, it sees the new values.
                SelectImage();
            }
        }