.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Getting the distance of 2 UIElements

Posted By:      Posted Date: September 15, 2010    Points: 0   Category :WPF
Hi, I have references to 2 UIElements, i would like to get the horizontal and vertical distance(in pixels) of these 2 UIelements with reference to their Top Left corner. What is the most effective way of doing this? Thanks

View Complete Post

More Related Resource Links

Calculate distance, bearing and more between Latitude/Longitude points

This page presents a variety of calculations for latitude/longitude points, with the formulæ and code fragments for implementing them.

All these formulæ are for calculations on the basis of a spherical earth (ignoring ellipsoidal effects) - which is accurate enough* for most purposes. [In fact, the earth is very slightly ellipsoidal; using a spherical model gives errors typically up to 0.3% - see notes for further details].

How to calculate the distance between two points on the Earth

We offer many Global Database Products that you can use with the below formulas to calculate distances and many other uses. Not sure how to use distance calculations or global databases within your company? See our Global Database Examples for more information on how to use our data within your industry. Be sure to Download a Free Sample of one of our many Global Database Products.

Saving Canvas and other UIElements as embedded resource

Hi All, I am trying to save a canvas and its content as an embedded resource to another assembly but in doing so I got a Non-Serializable exception. Is there a better way of doing this? Here is the code I used in embedding the Canvas: // create an assembly AssemblyName assemblyName = new AssemblyName(System.IO.Path.GetFileNameWithoutExtension(filename)); AssemblyBuilder assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.RunAndSave); ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule(assemblyName.Name, assemblyName.Name + ".dll"); // create a class TypeBuilder typeBuilder = moduleBuilder.DefineType("ModuleName", TypeAttributes.Public, typeof(EmbeddedBAML)); // Create a default constructor ConstructorBuilder constuctorDefault = typeBuilder.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, Type.EmptyTypes); ILGenerator ilGenerator = constuctorDefault.GetILGenerator(); ilGenerator.Emit(OpCodes.Ldarg_0); ilGenerator.Emit(OpCodes.Call, typeof(EmbeddedBAML).GetConstructor(Type.EmptyTypes)); ilGenerator.Emit(OpCodes.Ret); typeBuilder.CreateType(); IResourceWriter resourceWriter = assemblyBuilder.DefineResource(assemblyName.Name + ".canvas", "Contains the Canvas object",assemblyName.Name + ".canvas", ResourceAttributes.Pu

Find Mile Distance From 2 zipcodes (I have the Latitude and Longitude for both)

Could someone please show me how the query would look? I have 2 zip codes with their Latitude and Longitude.  I want in miles how far away is A from B.

Functioning of K-Means (Scaling of values; Distance between discrete data)

Hello everyone,

at the moment I try to figure out how the implementation of k-means in SSAS works, especially how the disctance between 2 datapoints (with continuous and discrete variables) is measured.
I figured out, that in case of only coninuous variables the square of the eucledian distance is used.
Furthermore I figured out that the distance between only discrete variables is described as 1 - the probability of that value in a cluster.

My questions are:

-How does the algorithm work with continuous AND disrete variables? Is the distance calculated by sum the eucledian distance (e.g. 13,2) and the probability of a discrete value in a cluster (e.g. 0,4)?

-Is it necessary to scale the continuous variables to a lower range, maybe -1 to 1? How does SSAS handle this job

Unfortunately there are no sufficient documentations...



Stored Procedure to Retrieve Zipcodes within a specified Zipcode and distance


Hi All,

Does anyone have a Stored Procedure that works perfectly to retrieve all zipcodes within a specified zipcode and distance radius - a zipcode and radius is passed and the Store Procedure result shows all zipcodes that falls within that range.


Thanks in advance



Calculate GPS Distance with SQL?

CREATE TABLE [dbo].[Logs](

    [logDate] [datetime] NOT NULL,
    [logType] [int] NOT NULL,
    [logCacher] [varchar](128) NOT NULL,
    [cacheId] [int) NOT NULL,

CREATE TABLE [dbo].[Caches](

    [cacheId] [int] NOT NULL,
    [cacheName] [varchar](128) NOT NULL,
    [latitude] [float] NOT NULL,
    [longitude] [float] NOT NULL,

Some sample data:

INSERT INTO Caches VALUES ( 1, 'cache1', 38.1, -9.1 )
INSERT INTO Caches VALUES ( 2, 'cache2', 38.2, -9.2 )
INSERT INTO Caches VALUES ( 3, 'cache3', 38.3, -9.3 )
INSERT INTO Caches VALUES ( 4, 'cache4', 38.4, -9.4 )
INSERT INTO Caches VALUES ( 5, 'cache5', 38.5, -9.5 )

INSERT INTO Logs VALUES ( '21/11/2007 00:00', 1, 'geocacher1', 1 )
INSERT INTO Logs VALUES ( '21/11/2007 10:00', 1, 'geocacher1', 2 )
INSERT INTO Logs VALUES ( '22/11/2007 00:00', 1, 'geocacher1', 3 )
INSERT INTO Logs VALUES ( '22/11/2007 10:00', 1, 'geocacher1', 4 )
INSERT INTO Logs VALUES ( '23/11/2007 00:00', 1, 'geocacher1', 5 )

INSERT INTO Logs VALUES ( '23/11/2007 00:00', 1, 'geocacher2', 1 )

How do I add functionality to get distance between cities/zip codes into my asp.net website?


Im looking for the functionality seen in most commercial websites like google maps to get approximate distance between cities and zip codes. Im guessing these sites are using huge databases with all this information already in them. It would be interesting to learn how to create this functionality myself but Im sure that would require a great deal of time. So Im looking for a package where someone has already done the work(an API) that would allow me to enter two different zip codes or maybe two different city,state combinations and take actions from there.

Thanks for your help.

Snap lines minimum distance from control



I need to place controls on Canvas panel and I need to space them 15px between each other. Is there a way to change minimum distance on snap lines from 6 to 15px? I know that I can use other panels which will do this job but it needs to be on canvas.


How to adjust distance between lines in FlowLayoutControl


In designer:

I put two group boxes into a FlowLayoutPanel and set first group box as 'FlowBreak'.

I found the distance is to long between to controls after I set FlowBreak property.

How can I solve it.


How to adjust distance between lines in FlowLayoutControl


In designer:

I put two group boxes into a FlowLayoutPanel and set first group box as 'FlowBreak'.

I found the distance is to long between to controls after I set FlowBreak property.

How can I solve it.


issue in calculating Distance by latitude and longtitude



I am just stuck in the strange calculation.

i am trying to find distance by latitude and longtitude by using this formula mentioned in this site.


every thing is Ok there when i do it by calculator but when i started doing it by programmatically there is a diiference in result.

here is my part of code

lat = Convert.ToDouble( (s3[a]));
                longt =Convert.ToDouble( (s4[a]));
                Avg_lat = pc._Latitude - lat;
                Avg_longt = pc._Longitude - longt;
                a_hold =( Math.Sin(Avg_lat / 2) * Math.Sin(Avg_lat / 2) )+ (Math.Cos(pc._Latitude) * Math.Cos(lat)) * (Math.Sin(Avg_longt / 2) * Math.Sin(Avg_longt / 2));
                c_hold = 2 * Math.Atan2(Math.Sqrt(a_hold), Math.Sqrt(1 - a_hold));

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend