Ticket Q278612
Visible to All Users

Rescale Images programmatically prior to inserting into document

created 14 years ago

Hello DevExpress Support.
I am trying to find a property or method that allows me to determine the margins width for scaling images before inserting them into the document.
Can you advise if this is possible?
Regards
Jason Sullivan

Answers approved by DevExpress Support

created 14 years ago (modified 12 years ago)

Hi Jason,
Thank you for contacting us. I am afraid that the XtraRichEdit does not have an event that fires when an image is inserted in a document. However, to accomplish your task, you can handle the RichEditControl.ContentChanged event with the following code:

C#
private int count = 0; private void Form1_Load(object sender, EventArgs e) { DocumentImageCollection collection = richEditControl1.Document.GetImages(richEditControl1.Document.Range); count = collection.Count; } private void richEditControl1_ContentChanged(object sender, EventArgs e) { DocumentImageCollection collection = richEditControl1.Document.GetImages(richEditControl1.Document.Range); if (collection.Count < count) { count -= 1; } if (count != collection.Count && collection.Count != 0) { DocumentImage documentImage = collection[collection.Count - 1]; SizeF size = documentImage.Size; count = collection.Count; } }
Visual Basic
Private count As Integer = 0 Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Dim collection As DocumentImageCollection = richEditControl1.Document.GetImages(richEditControl1.Document.Range) count = collection.Count End Sub Private Sub richEditControl1_ContentChanged(ByVal sender As Object, ByVal e As EventArgs) Dim collection As DocumentImageCollection = richEditControl1.Document.GetImages(richEditControl1.Document.Range) If collection.Count < count Then count -= 1 End If If count <> collection.Count AndAlso collection.Count <> 0 Then Dim documentImage As DocumentImage = collection(collection.Count - 1) Dim size As SizeF = documentImage.Size count = collection.Count End If End Sub

Please try this solution and let us know the results.
Thanks,
Sergi

    Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

    Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.