Good afternoon,
From time to time I've been experiencing Out of Memory Exception with RadRichText box library version 2013.1.222.40.
My exception is usually thrown when I right click to open the document Context Menu.
I would like to point out that I do add custom items to the document Context Menu depending if the user right clicks in a section with Custom Annotations.
e.g.
My application has also been designed to host multiple instance RadRichTextBox in RadDocking Panes (see the attached image). The docking panes are created and closed on a regular basis throughout the lifetime of the applications runtime.
Another point to add is that my RadDocuments contain a lot of Custom Annotations (unfortunately I cannot upload an example to this forum due to the filters for you to see).
To iterate my previous points, the Out of Memory Exception thus far only seems to occur once my application has been running for some time and only seems to occur when opening the Context Menu between custom annotations.
Is the Out of Memory Exception a known issue with library version 2013.1.222.40?
And can you offer any advice on what may be causing it and how to prevent the exception?
Many thanks,
Rob
From time to time I've been experiencing Out of Memory Exception with RadRichText box library version 2013.1.222.40.
My exception is usually thrown when I right click to open the document Context Menu.
I would like to point out that I do add custom items to the document Context Menu depending if the user right clicks in a section with Custom Annotations.
e.g.
private
void
ContextMenuSubscribe()
{
this
.radRichTextBox.ContextMenu =
new
Telerik.Windows.Controls.RichTextBoxUI.ContextMenu();
ContextMenu contextMenu = (ContextMenu)
this
.radRichTextBox.ContextMenu;
contextMenu.Showing +=
this
.ContextMenu_Showing;
}
private
void
ContextMenu_Showing(
object
sender, ContextMenuEventArgs e)
{
#region Discontinue Product Menu Item
// First check the context - if last selected annotation is product and user permissions
if
(Properties.Settings.Default.SystemUserPermissions.ProductsCanDiscontinue ==
true
&& !(
this
.radRichTextBox.Document.Selection.IsEmpty)
&& RadDocumentExtensions.GetLastSelectedAnnotationMarker(
this
.radRichTextBox.Document)
is
SemanticRangeStart)
{
//Get the selected annotations
List<SemanticRangeStart> products = RadDocumentExtensions.GetSelectedAnnotationsRangeStarts<SemanticRangeStart>(
this
.radRichTextBox.Document);
//Check Product Count is greater than 0
if
(products !=
null
&& products.Count > 0)
{
//Add menu item to data context
RadMenuItem discontinueProductMenuItem =
new
RadMenuItem()
{
Header =
"Discontinue Product"
,
Icon =
new
System.Windows.Controls.Image() { Source =
new
BitmapImage(
new
Uri(
"Icons/Spec-Editor-Menu/block.png"
, UriKind.Relative)) },
Tag = products[products.Count - 1]
//Get last product item in selection
};
discontinueProductMenuItem.Click +=
this
.DiscontinueProductMenuItem_Click;
ContextMenuGroup customContextMenuGroup =
new
ContextMenuGroup();
customContextMenuGroup.Add(discontinueProductMenuItem);
e.ContextMenuGroupCollection.Add(customContextMenuGroup);
}
}
#endregion
#region Product Pricing Menu Item
// First check the context - if selected annotation is end product and user permissions
if
(Properties.Settings.Default.SystemUserPermissions.OrderCanEdit ==
true
&& !(
this
.radRichTextBox.Document.Selection.IsEmpty) &&
RadDocumentExtensions.GetLastSelectedAnnotationMarker(
this
.radRichTextBox.Document)
is
SemanticRangeStart)
{
//Get the selected annotations
List<SemanticRangeStart> products = RadDocumentExtensions.GetSelectedAnnotationsRangeStarts<SemanticRangeStart>(
this
.radRichTextBox.Document);
//Checked the last selected item is an end item
//if (products.Count >= 0 && products[products.Count - 1].Product.HasChild == false)
//{
//Add menu item to data context
RadMenuItem addPriceMenuItem =
new
RadMenuItem()
{
Header =
"Set Price"
,
Icon =
new
System.Windows.Controls.Image() { Source =
new
BitmapImage(
new
Uri(
"Icons/Spec-Editor-Menu/sterling_pound_currency_50.png"
, UriKind.Relative)) },
Tag = products[products.Count - 1]
};
addPriceMenuItem.Click +=
this
.SetPriceMenuItem_Click;
ContextMenuGroup customContextMenuGroup =
new
ContextMenuGroup();
customContextMenuGroup.Add(addPriceMenuItem);
e.ContextMenuGroupCollection.Add(customContextMenuGroup);
//}
}
#endregion
#region Add New Item To Database Menu Item
//Check Conditions
if
(Properties.Settings.Default.SystemUserPermissions.ProductsCanAdd ==
true
&&
this
.radRichTextBox.Document.Selection.IsEmpty && RadDocumentAutoComplete.IsPositionBetweenDefinedAnnotations(
this
.radRichTextBox.Document.CaretPosition) ==
false
)
{
//Check if text exists at caret position
string
text = RadDocumentExtensions.GetSpanBoxText(
this
.radRichTextBox.Document.CaretPosition);
if
(!String.IsNullOrWhiteSpace(text))
{
text.Trim();
//Create New Menu Item
RadMenuItem addNewItemToDatabase =
new
RadMenuItem()
{
Header =
"Add New Item"
,
Icon =
new
System.Windows.Controls.Image() { Source =
new
BitmapImage(
new
Uri(
"Icons/Spec-Editor-Menu/Database-Add-48.png"
, UriKind.Relative)) }
};
addNewItemToDatabase.Click +=
this
.AddNewItemToDatabaseMenuItem_Click;
ContextMenuGroup customContextMenuGroup =
new
ContextMenuGroup();
customContextMenuGroup.Add(addNewItemToDatabase);
e.ContextMenuGroupCollection.Add(customContextMenuGroup);
}
}
#endregion
}
My application has also been designed to host multiple instance RadRichTextBox in RadDocking Panes (see the attached image). The docking panes are created and closed on a regular basis throughout the lifetime of the applications runtime.
Another point to add is that my RadDocuments contain a lot of Custom Annotations (unfortunately I cannot upload an example to this forum due to the filters for you to see).
To iterate my previous points, the Out of Memory Exception thus far only seems to occur once my application has been running for some time and only seems to occur when opening the Context Menu between custom annotations.
Is the Out of Memory Exception a known issue with library version 2013.1.222.40?
And can you offer any advice on what may be causing it and how to prevent the exception?
Many thanks,
Rob