Telerik Forums
UI for WPF Forum
10 answers
593 views

I have been trying to write a TiledMapSource that reads from the mbtiles format https://github.com/mapbox/mbtiles-spec/blob/master/1.1/spec.md

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace RadMapMbtilesDemo
{
    using System.Data.SQLite;
    using System.Diagnostics;
    using System.IO;
    using System.Security.AccessControl;
    using System.Windows.Media.Imaging;
 
    using Telerik.Windows.Controls.Map;
 
    public class MbTileSource : TiledMapSource
    {
        private readonly string mbtilefilepath;
 
        /// <summary>
        /// Initializes a new instance of the MyMapSource class.
        /// </summary>
        public MbTileSource(string mbtilefilepath, int minZoom, int maxZoom)
              : base(minZoom, maxZoom, 256, 256)
        {
            this.mbtilefilepath = mbtilefilepath;
        }
 
        /// <summary>
        /// Initialize provider.
        /// </summary>
        public override void Initialize()
        {
            // Raise provider initialized event.
            this.RaiseIntializeCompleted();
        }
        /// <summary>
        /// Gets the image URI.
        /// </summary>
        /// <param name="tileLevel">Tile level.</param>
        /// <param name="tilePositionX">Tile X.</param>
        /// <param name="tilePositionY">Tile Y.</param>
        /// <returns>URI of image.</returns>
        protected override Uri GetTile(int tileLevel, int tilePositionX, int tilePositionY)
        {
            return null;
        }
        protected override Stream GetCachedTile(int tileLevel, int tilePositionX, int tilePositionY)
        {
            var zoomLevel = this.ConvertTileToZoomLevel(tileLevel);
             
            try
            {
                using (var conn = new SQLiteConnection(String.Format("Data Source={0};Version=3;", this.mbtilefilepath)))
                {
                    conn.Open();
                    var sqlquery = String.Format("SELECT tile_data FROM tiles WHERE tile_column = {0} and tile_row = {1} and zoom_level = {2};", tilePositionX, tilePositionY, zoomLevel);
                    Debug.WriteLine(sqlquery);
                    using (var cmd = new SQLiteCommand() { Connection = conn, CommandText = sqlquery })
                    {
                        var reader = cmd.ExecuteReader();
                        if (reader.Read())
                        {
                            var bytes = reader["tile_data"] as byte[];
                            if (bytes != null)
                            {
                                return new MemoryStream(bytes);
                            }
                        }
                    }
                }
            }
            catch
            {
                return null;
            }
 
            return null;
        }
 
         
    }
}

This works and reads the files from the mbtiles (sqlite underneath the mbtiles spec) but the map is requesting the wrong tiles and I cannot see why. My understanding is:

1) Radmap is requesting tiles in a TMS format

2) MbTiles are stored in a TMS format

So the XYZ values passed into GetCachedTile(int tileLevel, int tilePositionX, int tilePositionY) should be the same I use in my sqlite query. Things I have checked:

1) I wondered if my mbtiles files was actually using OSMs style XYZ and tried the code to flip the Y value, this still gives incorrect tile values

2) I checked my mbtile file with https://viswaug.wordpress.com/2011/06/28/mbtilesviewer/ and it works fine

 So I can only assume that Radmap and mbtiles are using a different format or different projection hence the issues lining the two up. Can anyone help?

brian
Top achievements
Rank 1
 answered on 04 Mar 2016
4 answers
510 views

Hi,

I am going to use a RadCartesianChart to show a point series with  DataTimeContinuousAxis as my Horizontal axis and Linear Vertical axis. My requirement is that I want to show only those DateTime axis labels where I have some data point. Also instead of showing it as DateTime I want to bind to some other string.Except those other axis labels should be hidden (where no data point is present). How do I Achieve this? 

Thanks,

Shilpa

Shilpa
Top achievements
Rank 1
 answered on 04 Mar 2016
1 answer
174 views

Hi Telerik,

We are using the RadPdfViewer for our WPF application and it has a strange behavior. The page borders change on zoomlevel, by default (100%)  the right and bottom border are missing in our application. By zooming in and out it changes the border and it becomes slightly visible.

I added three screenshots with different zoomlevels.

Kind regards,

Ben

Deyan
Telerik team
 answered on 03 Mar 2016
2 answers
192 views

Hello,

I am working on an application where I am using RadRichTextBox to show some document in the application. Document is binded in the form of xml to this control.

<telerik:RadRichTextBox  x:Name="txtMsgBody" Grid.Row="1" Grid.Column="0" DataContext="{Binding STATIONARYXML}"  MinHeight="620" MaxWidth="1200"   VerticalAlignment="Top" ScrollViewer.HorizontalScrollBarVisibility="Hidden" SelectiveScrollingGrid.SelectiveScrollingOrientation="None" ScrollViewer.VerticalScrollBarVisibility="Visible"/>

This document is a word like document maximum of 1.5 to 2 pages. It contains some paragraphs, table and 1-2 small images of 2-3 KB in size. I am facing performance issue in the loading of this document. Document is of approx 20KB (when converted into MS word and saved on HD) and on 2GB RAM machine & 512 KB transfer rate it takes 11 seconds to open the document among which 3.5 to 4 seconds are on service side while rest it takes to load that document in control. I have already switched off the non required features like spell checker or image editor etc and also using only XamlFormatProvider in my TypeCatalog. I need to bring this transaction under 7 seconds. Your help is required in this case.

Thanks.

Tanya
Telerik team
 answered on 03 Mar 2016
3 answers
280 views

Hi,

I am trying to define a mask for a meskedinput control as all capital and required letters so normally I would be using something like ">LLL" as the mask.

You mention in your documentation that ">" should be escaped in XAML so I have set the mask property as "&gt;LLL" 

<telerik:RadMaskedTextInput Name="rmb_SMS_CODE"
                HorizontalAlignment="Center"
                Margin="0,10,0,20"               
                AcceptsReturn="True"
                Mask= "&gt;LLL">
            </telerik:RadMaskedTextInput>

But this does not work, it does not even work if I define the mask in code as this.mymaskcontrol.mask = ">LLL". The control ignores the capitalisation.

Can you please provide me with some assistance on what I am doing wrong?

Thank you,

Dinko | Tech Support Engineer
Telerik team
 answered on 03 Mar 2016
1 answer
210 views

I have a question regarding a GridViewMaskedInputColumn with a MaskType = MaskType.Numeric with a short width, so I'll place this question under this forum.

 

When I focus on the cell the caret seems to be placed at the beginning of the content, and (a) happens (see attached file). I wanted to achieve something like (b).

 

I inherited GridViewMaskedInputColumn and if I do:

 

public class SomeGridViewMaskedInputColumn : GridViewMaskedInputColumn
    {
        public override FrameworkElement CreateCellEditElement(GridViewCell cell, object dataItem)
        {
            var elem = (RadMaskedNumericInput)base.CreateCellEditElement(cell, dataItem);
            elem.GotFocus += Elem_GotFocus;

            // I tried SetCaretToEndOfTextOnFocus(elem, true); but it doesnt work for some reason
            return elem;
        }

        private void Elem_GotFocus(object sender, RoutedEventArgs e)
        {
            var control = ((RadMaskedNumericInput)sender);
            control.SelectionStart = control.Text.IndexOf(",");
        }
    }

 

(c) happens. In fact, (b) looks only achievable if i set SelectionStart to control.Text.Length and then press left 2 times (in this case, because i have 2 decimal places). Is there a better way of doing this?

 

 

Dinko | Tech Support Engineer
Telerik team
 answered on 03 Mar 2016
3 answers
195 views

I need to draw an image at the position on the map, and it must move as the position moves.  I also needto draw a different image on some static locations.  This data comes from a collection of locations.

I have coded this as such(below)... but it does not run.  I get the error: "Items collection must be empty before using ItemsSource."

When i remove the waypoints, the current position works, and when i remove the current position, the waypoints works.  I assume there is something very simple i am missing or not organizing correctly.

<telerik:InformationLayer ItemsSource="{Binding Path=Waypoints}" ItemTemplate="{StaticResource Rectangle}">
    <telerik:MapPinPoint telerik:MapLayer.Location="{Binding CurrentPosition}" ImageSource="icon.png" />
</telerik:InformationLayer>

Petar Mladenov
Telerik team
 answered on 03 Mar 2016
5 answers
149 views
How to add adorner (like settings pane) to RadDiagramShape? I'd like my RadDiagramShape to have a mini-toolbar with buttons over the shape visible if shape is selected.
Petar Mladenov
Telerik team
 answered on 03 Mar 2016
1 answer
238 views

I have searched and found several articles about support for a Material Design theme in Kendo UI and other products, but I have not found any discussion about one for WPF.  Is there a Material theme available for the WPF Telerik controls that I have missed somewhere?

Thanks

pmont

Yana
Telerik team
 answered on 03 Mar 2016
2 answers
185 views

I have a RadCartesianChart with several line series, ShowTrackInfo is true, and I have a custom header set up exactly like is done here: http://docs.telerik.com/devtools/wpf/controls/radchartview/features/behaviors/trackball#trackinfoupdated .

It works great but I don't want to show the "Value: xxx Category: yyy" text fields any more. I just want to display my header in the trackinfo tooltip. How can I do this?

Sam
Top achievements
Rank 2
 answered on 02 Mar 2016
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?