ArcObjects Mobile SDK, how do you get length/distance of a polyline - mobile

I programmatically select a polyline using an attribute query statement and returning the geometry of it. Then I use that to zoom-in to the area.
I'm needing to the length of the polyline in order to zoom-in to the area based on the length.

After you get the geometry of the polyline:
'
' --- Get the length of the polyline
'
Dim mPolyline As Polyline
Dim mPolylineLength As Double
'
mPolyline = gGeometry
mPolylineLength = mPolyline.GetLength()

Related

How to create little colored shape in a cell that would indicate colors on a chart? SSRS 2012

I have a bar chart with different bar colors. Below in a table I just want to indicate what each color means.
Can I do something like that in SSRS?
Im sure I can create another column on a left and assign each color to a cell. But is any way I can display it the way its on a picture above?
I tried to use indicators for that but I guess it needs conditions.
You can do this with custom code.
Loose steps to follow are:
Create a list to hold the graph
Add the graph
Inside the list and below the graph, add a tablix
The tablix will row group on the same thing as the graph (so you can get a row per coloured item in the graph)
Add a column to the start of the tablix for the colour
Add the following custom code:
Private colourPalette As String() = {"#418CF0", "#FCB441", "#DF3A02", "#056492", "#BFBFBF", "#1A3B69", "#FFE382", "#129CDD", "#CA6B4B", "#005CDB", "#F3D288", "#506381", "#F1B9A8", "#E0830A", "#7893BE"}
Private count As Integer = 0
Private mapping As New System.Collections.Hashtable()
Public Function GetColour(ByVal groupingValue As String) As String
If mapping.ContainsKey(groupingValue) Then
Return mapping(groupingValue)
End If
Dim c As String = colourPalette(count Mod colourPalette.Length)
count = count + 1
mapping.Add(groupingValue, c)
Return c
End Function
For the series fill on the graph, use the follow expression:
Use the same expression for the fill on the initial column in the tablix
You can use any list of codes for colour - this is the list for the default palette in SSRS.
This code ensures the same colour is picked each time the same item is used - so in the image the same colour is returned each time the same Category is returned.
The solution I use is pretty simple.
I use Windows Character Map to find a character I like. For example: ■
Copy that character and add an expression where you want to show the color icon. Your expression text will be
="■"
Then go to the Font tab and Color. Select the color you want from the menu. You can use expression logic in here to change the color dynamically. (You can refer to other answer for details there)

Reseting zoom and pan when updating chart in livecharts

I'm using beto-rodriguez's livecharts for VB.NET/WPF, where I'm setting the source data in the code-behind and showing a plot when the user clicks a button.
I have enabled the zooming feature on my chart using chart.Zoom = ZoomingOptions.X. My issue here if that if I zoom to 150% and pan away from the point (0,0) for example, and I load a new plot on the same control, the zoom is not reset, as the new plot will be zoomed 150% and panned by the same value.
Is there a way to reset the chart zoom and pan every time its .Series value is reset ?
By the way, my x-axis contains dates, therefore, setting the min and max values wouldn't work.
Your answer is right, there you are forcing the range of your axis, but you can also let the chart to try to auto scale setting your axis limits to double.NaN
From the site: https://lvcharts.net/App/examples/v1/wf/Zooming%20and%20panning
cartesianChart1.AxisX[0].MinValue = double.NaN;
cartesianChart1.AxisX[0].MaxValue = double.NaN;
cartesianChart1.AxisY[0].MinValue = double.NaN;
cartesianChart1.AxisY[0].MaxValue = double.NaN;
I found the solution :
xAxis.Labels = labels
' Run these two lines every time the chart is updated
xAxis.MinValue = 0
xAxis.MaxValue = labels.Count - 1
Where xAxis is the name of my Axis control and labels is a list of strings containing the x-axis dates.

Animate a combined geometry along a path

I have WPF/VB application that animates an ellipse geometry along a path using point animation. I used PointAnimationUsingPath and a Storyboard as per this MSDN example and it works great.
I now want to show a number inside the ellipse. To do this I created a combined geometry and set my ellipse as geometry1. I then created a formattedtext(...).buildgeometry for my number and set that as geometry2. Like this:
Dim CarGeo AS New CombinedGeometry()
CarGeo.Geometry1 = New EllipseGeometry(StartPoint, 5, 5)
CarGeo.Geometry2 = New FormattedText(carIndex.ToString, System.Globalization.CultureInfo.GetCultureInfo("en-us"), Windows.FlowDirection.LeftToRight, New Typeface("Veranda"), 7, Brushes.White).BuildGeometry(New Point(StartPoint.X - 4, StartPoint.Y - 4))
The resulting geometry is exactly what I wanted.
The problem is I don't seem to be able to animate this geometry along my path because unlike an ellipse there is no center property in a combined geometry to set the targeted property to on the StoryBoard.
' Create a PointAnimationgUsingPath to move the car along the animation path.
cpAnimation = New PointAnimationUsingPath
cpAnimation.PathGeometry = pgSectorPath(intSector)
cpAnimation.Duration = timDuration
' Set the animation to target the Center property of the EllipseGeometry
Storyboard.SetTargetName(cpAnimation, "CarGeo")
Storyboard.SetTargetProperty(cpAnimation, New PropertyPath(EllipseGeometry.CenterProperty))
Is there I property in a combined geometry that I can use for the animation?
If not can I wrap the geometry in something else that can be animated?
I'm very new to WPF and have wasted way too much time searching for an answer to this. Any help would be greatly appreciated.
Just wrap the CombinedGeometry into a Path object, as in the MS example:
http://msdn.microsoft.com/en-us/library/system.windows.media.combinedgeometry(v=vs.110).aspx

Cropping an arbitrary wpf geometry

The background to my problem is that I have a bunch of geometries (huge amount, think map over a larger area) split across multiple wpf geometry instances (originally they were PathGeometry, but to reduce memory usage I pre-process them and create StreamGeometries during load). Now what I want to do is to generate tiles from these geometries.
Basically I would like to take a larger geometry object and "cut out" a rectangle of it (my tile) so I get several smaller geometries. Something like the image below:
Notice that I want the result to be a new geometry, not a rendering. I know I can achieve the visual result by applying a clip to a UIElement or by pushing a clip to a drawingvisual.
I've tried using Geometry.Combine with one of the arguments being the clip rectangle, but I can't get it to do what I want (I typically only get the clip rect back, or an empty geometry, depending on which combine mode I use).
Alternatively, if this cannot be done using WPF, is there any other (third party is ok) general purporse geometry API for .NET that can do these kind of operations? Or maybe this can be implemented using other parts of the WPF geometry API?
Code shows the bottom right rectangle like in your "smaller tiles" visualisation:
var geometry = MyOriginalPath.Data.Clone();
var bounds = geometry.Bounds;
var rectangleGeometry = new RectangleGeometry(bounds);
var halfWidth = bounds.Width * 0.5;
var halfHeight = bounds.Height * 0.5;
var bottomQuarter = new RectangleGeometry(
new Rect(bounds.X + halfWidth, bounds.Y + halfHeight,
halfWidth, halfHeight));
var combinedGeometry = new CombinedGeometry(GeometryCombineMode.Exclude,
rectangleGeometry, bottomQuarter);
combinedGeometry = new CombinedGeometry(GeometryCombineMode.Exclude,
geometry, combinedGeometry);
MyBottomQuarterPath.Data = combinedGeometry;
Regards Dave

Is there a restriction to cursor sizes in VB.net

My application makes use of a custom cursor loaded from a predefined file (.cur) during runtime. I know windows uses a standard 32x32 pixels cursor or a 48x48 pixel cursor for high DPI devices.
The cursor I want to use in my application however is much larger. A small cursor is displayed correctly when I use Mouse.SetCursor(_CustomCursor). When a larger cursor is chosen, I don't see any cursor. It would seem that the cursor loads correctly but cannot be displayed.
Note: Currently a static .cur cursor is acceptable.
Is there a way to display larger cursors in my application and if there is a limit on the size, what is it?
Is there a restriction to cursor sizes?
Yes, it's a system restriction. Not just for VB.NET...
To get the max size of the Cursor you can use, you should query the SystemParameters.CursorHeight and SystemParameters.CursorWidth properties.
As stated by MSDN these properties are mapped to the SM_CYCURSOR andSM_CXCURSOR properties respectivly.
As you can read in MSDN
SM_CXCURSOR
13
The width of a cursor, in pixels. The system cannot create cursors of other sizes.
and
SM_CYCURSOR
14
The height of a cursor, in pixels. The system cannot create cursors of other sizes.
So I managed to find a work around to the problem on the size restriction.
As mentioned on Cursor from BitMap one can create a cursor of arbitrary size from a bitmap.
The code to achieve this is as follows:
Dim bm As New Bitmap(60, 60) 'Or from a bitmap file
Dim g As Graphics = Graphics.FromImage(bm)
g.FillRectangle(Brushes.Blue, 0, 0, 60, 60) 'For a simple blue rectangle cursor
Dim ptrCur As IntPtr = bm.GetHicon
Dim CustomCursor As Cursor
CustomCursor = New Cursor(ptrCur)
Me.Cursor = CustomCursor 'Set the application cursor to be custom
The hotspot is automatically set to the centre of the bitmap. Here is a preview of the results:
This code works well on a Windows forms application. With a WPF application an 'invalid extension for cursor' exception is thrown. Will be looking into resolving it (any suggestions welcome).
EDIT: In WPF a restriction of 96 pixels is applied to any dimension of the cursor, anything bigger will not display.

Resources