Telerik Forums
UI for WPF Forum
11 answers
196 views

I have a RadObservableCollection which is populated with 2560 DataPoint Objects every 800ms.  Each DataPoint object has a Time and Value property (DateTime and Double).

I only want to store 10 seconds worth of data, so every time I add a value, I check whether the collection contains 10 seconds of data or not already.  If it does, I remove the first item in the collection.

1.foreach (RawDataPoint rdp in ldp)
2.{
3.    _Real.Add(new DataPoint(rdp.Time, rdp.Value));
4.    if((rdp.Time.Add(-dataTimeSpan) > _Real[0].Time))
5.    {
6.        _Real.RemoveAt(0); // This is an Order(n) operation.
7.    }
8.}

Unfortunately the RemoveAt(0) function on RadObservableCollection is an O(n) operation and this is causing my application to slowdown as my collection grows to it's "full" capacity, which is many thousands of entries.  Because my data is coming in so fast, I need everything to happen in less than 1 second.

I've created an ObservableQueue<T> class which implements INotifyCollectionChanged and has a ConcurrentQueue as the underlying data type, whose TryDequeue operation is O(1).  Like the following:

 

public class ObservableQueue<T> : INotifyCollectionChanged, IEnumerable<T>
   {
       public event NotifyCollectionChangedEventHandler CollectionChanged;
       private readonly ConcurrentQueue<T> queue = new ConcurrentQueue<T>();
 
       public void Enqueue(T item)
       {
           queue.Enqueue(item);
           if (CollectionChanged != null)
               CollectionChanged(this,
                   new NotifyCollectionChangedEventArgs(
                       NotifyCollectionChangedAction.Add, item, queue.Count - 1));
       }
 
       public T Dequeue()
       {
           T result;
           bool dequeued = (queue.TryDequeue(out result));
           if (CollectionChanged != null && dequeued)
           {
               CollectionChanged(this,
                   new NotifyCollectionChangedEventArgs(
                       NotifyCollectionChangedAction.Remove, result, 0));
           }
           return result;
       }
 
       public T First()
       {
           T item;
           queue.TryPeek(out item);
           return item;
       }
 
       public IEnumerator<T> GetEnumerator()
       {
           return queue.GetEnumerator();
       }
 
       IEnumerator IEnumerable.GetEnumerator()
       {
           return GetEnumerator();
       }
   }

My new implementation of the code to update the collection is as follows:

public void Add(List<RawDataPoint> ldp)
{
    foreach (RawDataPoint dp in ldp)
    {
        _Real.Enqueue(new DataPoint(dp.Time, dp.Value));
        if ((dp.Time.Add(-dataTimeSpan) > _Real.First().Time))
        {
                _Real.Dequeue();  // this is an Order(1) operation.
        }
    }
}

However I can't get the solution to work.  Either it locks up my UI or I get a "Collection was modified during enumeration" exception.

Is there any way to better implement a limited size collection where I can remove the first value in O(1) time?

Peshito
Telerik team
 answered on 07 Dec 2015
1 answer
156 views

Hi,

 

I'm trying to use the RadRichTextBow to perform some printings but after lots of tries, the richtextbowx is still always blank....

I even try to create a new project with only a span with no success....

 

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfApplication1"
        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
        mc:Ignorable="d"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <telerik:RadRichTextBox x:Name="test">
            <telerik:RadDocument>
                <telerik:Section>
                    <telerik:Paragraph>
                        <telerik:Span Text="Span declared in XAML" />
                    </telerik:Paragraph>
                </telerik:Section>
            </telerik:RadDocument>
        </telerik:RadRichTextBox>
    </Grid>
</Window>

Am I doing something really wrong ? Maybe a missing reference...

Lilian
Top achievements
Rank 1
 answered on 07 Dec 2015
2 answers
42 views

Good afternoon,

As the title says, I am looking for a way to add a new pane without navigation to it / having it selected.

I've searched around google and even in the forums and documentation but I haven't found an example or answer (maybe I'm searching for the wrong terms).

Any help will be appreciated.

 

Thanks in advance,

Diogo

Diogo
Top achievements
Rank 1
 answered on 07 Dec 2015
9 answers
205 views
Hello there,

out of curiosity, is it planned to support .doc (binary 200-2003 / pre .docx) files anytime soon? Additionally, is there a list of .docx file format features that are not supported yet (or not planned at all)?

All the best,
-Jörg B.
Boby
Telerik team
 answered on 07 Dec 2015
1 answer
115 views

What is the little > on top left of the grid?

If I add group it is always at the top of the 1st group.

Can we hide it? Its confusing as if this is the current row and not the one selected.

 

Stefan Nenchev
Telerik team
 answered on 07 Dec 2015
3 answers
226 views

Our centralized logging system detected the following exception in one of our customers machines. It's not systematic or frequent: it just randomly happens on that machine: 

System.Printing.PrintQueueException: PrintTicket provider failed to merge and validate PrintTicket. Win32 error: The data is invalid.
at MS.Internal.Printing.Configuration.PTProvider.MergeAndValidatePrintTicket(MemoryStream basePrintTicket, MemoryStream deltaPrintTicket, PrintTicketScope scope, ConflictStatus& conflictStatus)
at System.Printing.PrintTicketManager.MergeAndValidatePrintTicket(PrintTicket basePrintTicket, PrintTicket deltaPrintTicket, PrintTicketScope scope)
at System.Printing.PrintQueue.MergeAndValidatePrintTicket(PrintTicket basePrintTicket, PrintTicket deltaPrintTicket)
at Telerik.Windows.Controls.Diagrams.Extensions.PrintSettingsViewModel.MergeAndValidatePrintTicket(PrintTicket originalTicket, PrintTicket modificationTicket)
at Telerik.Windows.Controls.Diagrams.Extensions.RadDiagramPrintPreview.DoPrint(String title)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.Controls.Primitives.ButtonBase.OnClick()
at System.Windows.Controls.Button.OnClick()
at Telerik.Windows.Controls.RadButton.OnClick()
at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
at System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler).

 

And here is the code causing the issue:

var printPreviewWindow = new Telerik.Windows.Controls.RadWindow();
var printPreview = new RadDiagramPrintPreview { Diagram = selectedDiagram.diagram };
printPreviewWindow.Content = printPreview;
printPreviewWindow.ResizeMode = ResizeMode.NoResize;
printPreviewWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner;
printPreviewWindow.Width = 800;
printPreviewWindow.Height = 600;
printPreviewWindow.Owner = _owner;
printPreviewWindow.ShowDialog();

 

They are on a quite old version of our product using Telerik 2014.3.1021.40 (.NET 4.0 and Microsoft Windows NT 6.2.9200.0 64 bit).

Our latest version includes Telerik 2015.3.930.40: as far as you guys know, the new version solves that issue?

 

Thank you,

Regards,

 

Manuel

 

Petar Mladenov
Telerik team
 answered on 07 Dec 2015
1 answer
135 views

Hi @all,

Im new to Telerik and currenty trying to implement some Telerik Controls (Trial) to an existing Solution.

Two Projects in the solution are WPF Control Libraries.

After installing Telerik for WPF and changing the standard Windows controls to Telerik controls, everything worked as expected.

For Deployment we need to place our references to a different FilePath (Not the Telerik Installation Path).

But after copying the dll-Files to this path and re-reference them from the new path into the solution, no Telerik-Controls are visible

on the UI anymore. The remaining Standard-Windows-Controls (which we have not switches to Telerik yet) are still visible.

Are there best practices to reference the Telerik-Binaries without installing the Telerik-Setup for WPF Controls?

Any suggestions on this?

Thanks in advance

Andreas Geier

Nasko
Telerik team
 answered on 07 Dec 2015
1 answer
1.0K+ views

Hello,

 We are using  RichTextBox control for Mail merge functionality to implement in our system. Our requirement is to complete the mail merge and print the entire document.

When the print is completed, we would like to know that the printing job is completed successfully for all pages to perform some insert/update operations in the database. We are using the following code to check the printing job is success, but we are not getting the PrintJobInfoCollection results.

 RadDocument _MergedDocument = this.radRichTextBox.MailMerge();
                if (_MergedDocument != null)
                {
                    this.radRichTextBox.Document = _MergedDocument;

                    PrintSettings _PrintSettings = new PrintSettings()
                    {
                        DocumentName = "My document",
                        PrintMode = PrintMode.Native,
                        PrintScaling = PrintScaling.None                        
                    };

                    PrintDialog _PrintDialog = new PrintDialog();
                    _PrintDialog.PageRangeSelection = PageRangeSelection.AllPages;
                    _PrintDialog.UserPageRangeEnabled = true;
                    Nullable<Boolean> print = _PrintDialog.ShowDialog();
                    if (print == true)
                    {                        
                        this.radRichTextBox.Print(_PrintDialog, _PrintSettings);                        
                        PrintJobInfoCollection jobs = _PrintDialog.PrintQueue.GetPrintJobInfoCollection();
                        foreach (PrintSystemJobInfo theJob in jobs)
                        {
                            if (((theJob.JobStatus & PrintJobStatus.Completed) == PrintJobStatus.Completed) || ((theJob.JobStatus & PrintJobStatus.Printed) == PrintJobStatus.Printed))
                            {
                                MessageBox.Show("completed");
                            }
                        }
                    }                    
                }

 

Thanks

 

 

Tanya
Telerik team
 answered on 04 Dec 2015
1 answer
143 views

I use BingMapProvider with IsTileCachingEnabled set to true, and I notice memory leak because of the cache even though I call the Dispose() function for the provider class.

Currently I have a workaround by deriving a CustomBingMapProvider from BingMapProvider to expose the MapSources to public. When disposing, I set all the CacheStorage of the MapSources to null. This workaround works for me.

 Do you have any idea or any solution to dispose the cache properly?

Petar Mladenov
Telerik team
 answered on 04 Dec 2015
1 answer
97 views

Hello,

When we create a mail merge file and click on preview results, the formatting of the document becomes improper as shown in 'MailMerge2'.

 As you can see in 'MailMerge1', we are able to see the proper formatting when we click Show Field Names. 

 However Ms Word Mail merge feature works properly in the same scenario.

Thanks
Todor
Telerik team
 answered on 04 Dec 2015
Narrow your results
Selected tags
Tags
GridView
General Discussions
Chart
RichTextBox
Docking
ScheduleView
ChartView
TreeView
Diagram
Map
ComboBox
TreeListView
Window
RibbonView and RibbonWindow
PropertyGrid
DragAndDrop
TabControl
TileView
Carousel
DataForm
PDFViewer
MaskedInput (Numeric, DateTime, Text, Currency)
AutoCompleteBox
DatePicker
Buttons
ListBox
GanttView
PivotGrid
Spreadsheet
Gauges
NumericUpDown
PanelBar
DateTimePicker
DataFilter
Menu
ContextMenu
TimeLine
Calendar
Installer and Visual Studio Extensions
ImageEditor
BusyIndicator
Slider
Expander
TileList
PersistenceFramework
DataPager
Styling
TimeBar
OutlookBar
TransitionControl
Book
FileDialogs
ToolBar
ColorPicker
TimePicker
SyntaxEditor
MultiColumnComboBox
VirtualGrid
Wizard
ExpressionEditor
NavigationView (Hamburger Menu)
DesktopAlert
WatermarkTextBox
BarCode
SpellChecker
DataServiceDataSource
EntityFrameworkDataSource
RadialMenu
ChartView3D
Data Virtualization
BreadCrumb
ProgressBar
Sparkline
LayoutControl
TabbedWindow
ToolTip
CloudUpload
ColorEditor
TreeMap and PivotMap
EntityFrameworkCoreDataSource (.Net Core)
HeatMap
Chat (Conversational UI)
VirtualizingWrapPanel
Calculator
NotifyIcon
TaskBoard
TimeSpanPicker
BulletGraph
WebCam
CardView
DataBar
Licensing
FilePathPicker
PasswordBox
Rating
SplashScreen
Accessibility
Callout
CollectionNavigator
Localization
AutoSuggestBox
HighlightTextBlock
Security
TouchManager
StepProgressBar
VirtualKeyboard
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
+? more
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?