Hello,
Currently I am looking into using the Telerik Diagram library for a new application. Users have to be able to load a background image and then draw (and modify) areas of interest on top of this map (using the standard shapes). On top of that a the 'track / path' of a person has to be drawn / plotted (see the attached image). This drawing / plotting has to be 'live / animated' (e.g. the position of the person changes and this has to be visualized in real-time). Do you have any hints / tips on how to achieve this? What I would like is to have some kind of drawing canvas which has the same size as the 'background image shape' but anything drawn here should be displayed 'over' the other placed shapes. This canvas should also respond to zooming in/out of the diagram.
Kind regards,
Douwe

For now, RadRichTextBox does not support dragging or pasting files. So I override the dragevent.
public class UserFile { public string name; public string absoluteAddress; public string image; } public class DragableRichTextBox : RadRichTextBox { public static readonly DependencyProperty UserFilesProperty; static int dirCount; static DragableRichTextBox() { FrameworkPropertyMetadata metadata = new FrameworkPropertyMetadata(new List<UserFile>(), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault); UserFilesProperty = DependencyProperty.Register("UserFiles", typeof(List<UserFile>), typeof(RadRichTextBox), metadata); dirCount = 0; } public List<UserFile> UserFiles { get { userFiles.Clear(); XamlFormatProvider provider = new XamlFormatProvider(); XmlDocument xmlDocument = new XmlDocument(); string data = provider.Export(this.Document); xmlDocument.LoadXml(data); scanFileAndAddIamge(xmlDocument.FirstChild); SetValue(UserFilesProperty, userFiles); return (List<UserFile>)GetValue(UserFilesProperty); } set { SetValue(UserFilesProperty, value); } } List<UserFile> userFiles; public string SaveDirectory; public DragableRichTextBox() { this.AllowDrop = true; this.AddHandler(RichTextBox.DropEvent, new DragEventHandler(dropIn), true); this.AddHandler(RichTextBox.DragOverEvent, new DragEventHandler(dropOver), true); userFiles = new List<UserFile>(); string basePath = @"C:\123\temp"; checkPath(basePath); for (int i = dirCount; i < 1000; ++i) { if (checkPath(basePath + @"\" + i)) { SaveDirectory = basePath + @"\" + i; dirCount = i; break; } } } bool checkPath(string path) { if (!Directory.Exists(path)) { Directory.CreateDirectory(path); return true; } else if(dirCount == 0) { Directory.Delete(path, true); } return false; } private void dropIn(object obj, DragEventArgs de) { if (de.Data.GetDataPresent(DataFormats.FileDrop)) { string[] files = (string[])de.Data.GetData(DataFormats.FileDrop); foreach (string file in files) { UserFile f = new UserFile(); System.Windows.Controls.Image image = new System.Windows.Controls.Image(); image.Source = GetIcon(file); image.Height = image.Source.Height; image.Width = image.Source.Width; PngBitmapEncoder pictureEncoder = new PngBitmapEncoder(); pictureEncoder.Frames.Add(BitmapFrame.Create((BitmapSource)image.Source)); FileStream fs = new FileStream(String.Format(SaveDirectory + "/{0}.png", userFiles.Count), FileMode.OpenOrCreate, FileAccess.Write); pictureEncoder.Save(fs); fs.Close(); string path = String.Format(SaveDirectory + "/{0}.png", userFiles.Count); f.image = path; Uri uri = new Uri(path); BitmapImage image1 = new BitmapImage(uri); image.Source = image1; StackPanel stk = new StackPanel(); stk.Children.Add(image); Telerik.Windows.Controls.Label l = new Telerik.Windows.Controls.Label(); for (int i = file.Length - 1; i >= 0; --i) { if (file[i] == '\\') { l.Content = file.Remove(0, i + 1); break; } } Telerik.Windows.Controls.Label l1 = new Telerik.Windows.Controls.Label(); l1.Content = file; l1.Visibility = Visibility.Collapsed; stk.Children.Add(l); stk.Children.Add(l1); f.name = l.Content.ToString(); f.absoluteAddress = l1.Content.ToString(); userFiles.Add(f); Section section = new Section(); Paragraph paragraph = new Paragraph(); InlineUIContainer container = new InlineUIContainer(); container.UiElement = stk; container.Height = 25 + image.Height; double x = l.Content.ToString().Length; container.Width = x * 6.5 > image.Width ? x * 6.5 : image.Width; paragraph.Inlines.Add(container); section.Blocks.Add(paragraph); this.Document.Sections.Add(section); RecreateUI(); container.Width = stk.ActualWidth; } } RecreateUI(); } private void dropOver(object obj, DragEventArgs de) { if (de.Data.GetDataPresent(DataFormats.FileDrop)) { de.Effects = DragDropEffects.Copy; } else if (de.Data.GetDataPresent(DataFormats.Text) | de.Data.GetDataPresent(DataFormats.Bitmap) | de.Data.GetDataPresent(DataFormats.CommaSeparatedValue) | de.Data.GetDataPresent(DataFormats.Dib) | de.Data.GetDataPresent(DataFormats.Dif) | de.Data.GetDataPresent(DataFormats.EnhancedMetafile) | de.Data.GetDataPresent(DataFormats.FileDrop)) { de.Effects = DragDropEffects.Scroll; } else { de.Effects = DragDropEffects.None; } } private ImageSource GetIcon(string fileName) { Icon icon = System.Drawing.Icon.ExtractAssociatedIcon(fileName); return System.Windows.Interop.Imaging.CreateBitmapSourceFromHIcon( icon.Handle, new Int32Rect(0, 0, icon.Width, icon.Height), BitmapSizeOptions.FromEmptyOptions()); } private void RecreateUI() { if (this.ActiveEditorPresenter != null) { this.ActiveEditorPresenter.RecreateUI(); this.UpdateEditorLayout(); } } private void scanFileAndAddIamge(XmlNode node) { if (node.ChildNodes.Count == 0) return; foreach (XmlNode xn in node.ChildNodes) { if (xn.Name == "av:StackPanel") { UserFile f = new UserFile(); foreach (XmlNode xn1 in xn.ChildNodes) { if (xn1.Name == "Label") { foreach (XmlAttribute attribute in xn1.Attributes) { if (attribute.Name == "Visibility" && attribute.Value == "Collapsed") { f.absoluteAddress = xn1.InnerText; } } if (xn1.Attributes.Count == 0) f.name = xn1.InnerText; } if (xn1.Name == "av:Image") { foreach (XmlAttribute attribute in xn1.Attributes) { if (attribute.Name == "Source") { for (int i = attribute.Value.Length - 1; i >= 0; --i) { if (attribute.Value[i] == '/') { attribute.Value = attribute.Value.Remove(0, i); break; } } attribute.Value = SaveDirectory + "/" + attribute.Value; f.image = attribute.Value; int kk = 11; kk++; kk++; } } } } userFiles.Add(f); } else { scanFileAndAddIamge(xn); } } } }I can drag files now, but the files alway insert in the end of the RadDoucument. I don't know how to get the paragragh or section that my mosue point.
Please help me.
I have a RadTreeView that I am expanding by applying a style.
<Style TargetType="{x:Type telerik:RadTreeViewItem}"> <EventSetter Event="Selected" Handler="TreeViewItem_Selected" /> <Setter Property="IsExpanded" Value="True"></Setter> </Style>
I am trying to display checkboxes next to items that meet a certain condition. To do this I am trying to hide the checkboxes on those elements that do not meet the condition.
I am hooking into the loaded event of my RadTreeView and trying to iterate down through the items, get the item container and hide the checkbox if necessary.
The problem I am having is that ContainerFromItemRecursive is returning null for any item that is not at the root level.
Here's my code.
private void FrameworkElement_OnLoaded(object sender, RoutedEventArgs e) { RadTreeView rtv = sender as RadTreeView; foreach (IMeasurementTreeBase item in rtv.Items) { SetCheckBoxVisibilityRecursive(item, rtv); } } } public void SetCheckBoxVisibilityRecursive(IMeasurementTreeBase item, RadTreeView rtv) { if (!item.HasMeasurements()) { RadTreeViewItem treeItem = rtv.ContainerFromItemRecursive(item); if (treeItem != null) { var children = treeItem.ChildrenOfType<CheckBox>().ToList(); children[0].Visibility = Visibility.Collapsed; } foreach (IMeasurementTreeBase subItem in item.Children) { SetCheckBoxVisibilityRecursive(subItem, rtv); } } }
Thanks
Hi,
I'm trying to remove indenting when grouping items in a GridView.I have it basically working by setting a style for GridViewIndentCell with Visibility Collapsed, however after doing this there is some space "left over" on the right of each grid view row. Could you please let me know how to get rid of it and have the row expand all the way to the right?
Thanks,
Adrian
<pivot:LocalDataSourceProvider x:Key="dataProvider"> <pivot:LocalDataSourceProvider.RowGroupDescriptions> <pivot:PropertyGroupDescription PropertyName="Type" /> <pivot:PropertyGroupDescription PropertyName="Type2" /> </pivot:LocalDataSourceProvider.RowGroupDescriptions> <pivot:LocalDataSourceProvider.AggregateDescriptions> <pivot:PropertyAggregateDescription PropertyName="Description" /> <pivot:PropertyAggregateDescription PropertyName="InitialDate" /> <pivot:PropertyAggregateDescription PropertyName="Price" /> <pivot:PropertyAggregateDescription PropertyName="Units" /> </pivot:LocalDataSourceProvider.AggregateDescriptions></pivot:LocalDataSourceProvider>Hi,
I have used PastingCellClipboardContent event on a wpf radgridview in order to convert the value pasted to a value in a combobox as described in: http://docs.telerik.com/devtools/wpf/controls/radgridview/clipboard/pasting.html
My grid has definition:
ClipboardCopyMode="Cells"
ClipboardPasteMode="Cells"​
However, when copying a cell, then adding a new row and then trying to paste the content, this event does not fire (and produces very odd behaviour in the grid, but that's besides the point).
Any ideas?
Thanks.
Hi,
When I added Telerik to my application, I used .Net framework 4.5 and platform target x86. I used a RadCarousel and it worked perfect. Later I had to switch to .Net 4.0 framework and change the Telerik version to v.2014.3.1021.40. But now I have a problem. I reduced the code to a minimum for a test purposes:
<Window x:Class="myBRH.AddPhotosWnd" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" Title="AddPhotosWnd" Height="300" Width="1024"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="10*"/> <ColumnDefinition Width="135*"/> <ColumnDefinition Width="855*"/> <ColumnDefinition Width="16*"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="2*"/> <RowDefinition Height="10*"/> <RowDefinition Height="3*"/> <RowDefinition Height="36*"/> <RowDefinition Height="3*"/> </Grid.RowDefinitions> <Button Grid.Column="1" Grid.Row="1" Click="Button_Click"/> <telerik:RadCarousel x:Name="rc" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="3" HorizontalScrollBarVisibility="Hidden"/> </Grid></Window>
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows;using System.Windows.Controls;using System.Windows.Data;using System.Windows.Documents;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Imaging;using System.Windows.Shapes;namespace myBRH{ /// <summary> /// Interaction logic for AddPhotosWnd.xaml /// </summary> public partial class AddPhotosWnd : Window { public AddPhotosWnd() { InitializeComponent(); } private void Button_Click(object sender, RoutedEventArgs e) { string str = "sdfsd"; rc.Items.Add(str); rc.BringDataItemIntoView(rc.Items[0]); } }}The problem:
When second item is added to the RadCarousel.Items, System.InvalidOperationException is thrown with the message: "Collection was modified; enumeration operation may not execute."
Exception is not thrown if I comment out the rc.BringDataItemIntoView(rc.Items[0]); method call.
Hello,
I am facing a problem related to dragging an appointment of recurrence series. I have created a recurring appointment which is weekly but when i drag it to some other date as in attached picture and it won't allow me to do that. Thanks!
The Click Event of any minimized icon does not render the correct screen if any icon is collapsed between minimized icons.
Kindly find the ​attached sample project.
If you run the project, it will show you 5 icon ​as minimized icon. and when you click any minimized icon it will work fine. But you Collapsed the last RadOutlookBarItem and run the project then it will show you 4 icon ​as minimized icon.and if you click any it will not render/open the correct one. it is always opening the first one.This is issue is occurring on Telrik Version14.
In my project, i am dynamically ,showing and hide the outlookbar according to configuration but Click Event of any minimized icon does not render the correct screen if any icon is collapsed between minimized icons.
Kindly explain, why it is not working properly as it suppose to be. and what is the possible solution.
following is the code for sample project
<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"
xmlns:telerikInput="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input"
xmlns:telerikNavigation="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"
MaxHeight="400"
Title="Window1">
<Grid>
<!--************* OUTLOOK BAR *************-->
<telerikNavigation:RadOutlookBar x:Name="outlookBar" Width="250" HorizontalAlignment="Left" Margin="0,100,0,0">
<!--****** MAIL ******-->
<telerikNavigation:RadOutlookBarItem Header="Mail" FontWeight="Bold"
Icon="Images/mailBig.png" SmallIcon="Images/mailSmall.png" Tag="Mail">
<telerikNavigation:RadTreeView IsLineEnabled="True" x:Name="foldersTreeView">
<telerikNavigation:RadTreeViewItem Header="Personal Folders"
DefaultImageSrc="Images/1PersonalFolders.png" IsExpanded="True">
<telerikNavigation:RadTreeViewItem Header="Deleted Items"
DefaultImageSrc="Images/2DeletedItems.png" />
<telerikNavigation:RadTreeViewItem Header="Drafts"
DefaultImageSrc="Images/3Drafts.png" />
<telerikNavigation:RadTreeViewItem x:Name="MessagesTreeView"
Header="Inbox(3)" DefaultImageSrc="Images/4Inbox.png"
IsExpanded="True">
<telerikNavigation:RadTreeViewItem.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Source="Images/letter.png" />
<TextBlock Text="{Binding From}" Margin="9 0 0 0" />
</StackPanel>
</DataTemplate>
</telerikNavigation:RadTreeViewItem.ItemTemplate>
</telerikNavigation:RadTreeViewItem>
<telerikNavigation:RadTreeViewItem Header="Junk E-mails"
DefaultImageSrc="Images/junk.png" />
<telerikNavigation:RadTreeViewItem Header="Outbox"
DefaultImageSrc="Images/outbox.png" />
<telerikNavigation:RadTreeViewItem Header="Sent Items"
DefaultImageSrc="Images/sent.png" />
</telerikNavigation:RadTreeViewItem>
</telerikNavigation:RadTreeView>
</telerikNavigation:RadOutlookBarItem>
<!--********** CALENDAR **********-->
<telerikNavigation:RadOutlookBarItem Header="Calendar" FontWeight="Bold"
Icon="Images/calendarBig.png" SmallIcon="Images/calendarSmall.png">
<telerikInput:RadCalendar VerticalAlignment="Top" Margin="3" />
</telerikNavigation:RadOutlookBarItem>
<!--********** CONTACTS **********-->
<telerikNavigation:RadOutlookBarItem Header="Contacts" FontWeight="Bold"
Icon="Images/contactsBig.png" SmallIcon="Images/contactsSmall.png"
Tag="Contacts">
<ListBox x:Name="ContactsListBox" BorderBrush="{x:Null}" BorderThickness="0">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="14 0 14 0">
<Image Source="Images/contact.png" />
<TextBlock Text="{Binding FirstName}" Margin="10 0 0 0"
VerticalAlignment="Center" />
<TextBlock Text="{Binding LastName}" Margin="2 0 0 0"
VerticalAlignment="Center" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</telerikNavigation:RadOutlookBarItem>
<!--******* TASKS *******-->
<telerikNavigation:RadOutlookBarItem Header="Tasks" FontWeight="Bold"
Icon="Images/tasksBig.png" SmallIcon="Images/tasksSmall.png">
<StackPanel VerticalAlignment="Top" HorizontalAlignment="Left" Margin="15 5">
<RadioButton Content="To-Do List" IsChecked="True" Margin="0 5 0 5" />
<RadioButton Content="Simple List" Margin="0 5 0 5" />
<RadioButton Content="Detailed List" Margin="0 5 0 5" />
<RadioButton Content="Active Tasks" Margin="0 5 0 5" />
<RadioButton Content="Next Seven Days" Margin="0 5 0 5" />
<RadioButton Content="Overdue Tasks" Margin="0 5 0 5" />
</StackPanel>
</telerikNavigation:RadOutlookBarItem>
<!--******* NOTES *******-->
<telerikNavigation:RadOutlookBarItem Header="Notes" FontWeight="Bold"
Icon="Images/notesBig.png" SmallIcon="Images/notesSmall.png">
<StackPanel VerticalAlignment="Top" HorizontalAlignment="Left" Margin="15 5">
<RadioButton Content="Icons" IsChecked="True" Margin="0 5 0 5" />
<RadioButton Content="Notes List" Margin="0 5 0 5" />
<RadioButton Content="Last Seven Days" Margin="0 5 0 5" />
<RadioButton Content="By Category" Margin="0 5 0 5" />
<RadioButton Content="Outlook Data Files" Margin="0 5 0 5" />
<RadioButton Content="Overdue Tasks" Margin="0 5 0 5" />
</StackPanel>
</telerikNavigation:RadOutlookBarItem>
<!--************* FOLDER LIST *************-->
<telerikNavigation:RadOutlookBarItem Header="Folder List" FontWeight="Bold"
Icon="Images/foldersBig.png" SmallIcon="Images/foldersSmall.png">
<telerikNavigation:RadTreeView IsLineEnabled="True">
<telerikNavigation:RadTreeViewItem Header="Personal Folders"
DefaultImageSrc="Images/1PersonalFolders.png" IsExpanded="True">
<telerikNavigation:RadTreeViewItem Header="Deleted Items"
DefaultImageSrc="Images/2DeletedItems.png" />
<telerikNavigation:RadTreeViewItem Header="Drafts"
DefaultImageSrc="Images/3Drafts.png" />
<telerikNavigation:RadTreeViewItem Header="Inbox"
DefaultImageSrc="Images/4Inbox.png" />
<telerikNavigation:RadTreeViewItem Header="Junk E-mails"
DefaultImageSrc="Images/junk.png" />
<telerikNavigation:RadTreeViewItem Header="Outbox"
DefaultImageSrc="Images/outbox.png" />
<telerikNavigation:RadTreeViewItem Header="Sent Items"
DefaultImageSrc="Images/sent.png" />
</telerikNavigation:RadTreeViewItem>
</telerikNavigation:RadTreeView>
</telerikNavigation:RadOutlookBarItem>
<!--*********** SHORTCUTS ***********-->
<telerikNavigation:RadOutlookBarItem Header="Shortcuts" FontWeight="Bold"
Icon="Images/shortcutsBig.png" SmallIcon="Images/shortcutsSmall.png">
<StackPanel VerticalAlignment="Top" HorizontalAlignment="Left" Margin="15 5">
<Button Content="Add New Group" />
<Button Content="Add New Shortcut" />
</StackPanel>
</telerikNavigation:RadOutlookBarItem>
<telerikNavigation:RadOutlookBarItem Header="Events" FontWeight="Bold"
Icon="Images/shortcutsBig.png" SmallIcon="Images/notesSmall.png">
<StackPanel VerticalAlignment="Top" HorizontalAlignment="Left" Margin="15 5">
<Button Content="Add New Events" />
</StackPanel>
</telerikNavigation:RadOutlookBarItem>
<telerikNavigation:RadOutlookBarItem Header="Reminder" FontWeight="Bold"
Icon="Images/shortcutsBig.png" SmallIcon="Images/shortcutsSmall.png" Visibility="Collapsed">
<StackPanel VerticalAlignment="Top" HorizontalAlignment="Left" Margin="15 5">
<Button Content="Add New Reminder" />
</StackPanel>
</telerikNavigation:RadOutlookBarItem>
</telerikNavigation:RadOutlookBar>
</Grid>
</Window>
Thanks
Regards
Mudasser
