Click here to Skip to main content
15,898,222 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Global Styles Pin
#realJSOP22-Jul-09 2:21
professional#realJSOP22-Jul-09 2:21 
GeneralRe: Global Styles Pin
Pete O'Hanlon22-Jul-09 2:23
mvePete O'Hanlon22-Jul-09 2:23 
GeneralRe: Global Styles Pin
#realJSOP22-Jul-09 2:41
professional#realJSOP22-Jul-09 2:41 
GeneralRe: Global Styles Pin
Pete O'Hanlon22-Jul-09 3:43
mvePete O'Hanlon22-Jul-09 3:43 
QuestionSilverlight : Dynamic plugins? Pin
User 527145421-Jul-09 3:48
User 527145421-Jul-09 3:48 
AnswerRe: Silverlight : Dynamic plugins? Pin
Ray Cassick21-Jul-09 18:06
Ray Cassick21-Jul-09 18:06 
AnswerRe: Silverlight : Dynamic plugins? Pin
Michael Sync23-Jul-09 6:43
Michael Sync23-Jul-09 6:43 
Question3 Tangent Ciricles? Pin
jward21-Jul-09 0:55
jward21-Jul-09 0:55 
I'm having a problem positioning elements and not sure where I'm going wrong. The elements are basically ellipsegeometry paths, since all of the elements are have the same radius.x and radius.y I've added a property Radius that I set when I add them.

This code should position them without an overlap and it works fine as long as the elements have the same radius

Public Sub Group2Elements(ByVal Conductor1 As Conductor, ByVal Conductor2 As Conductor, ByVal Angle As Double)
        Dim DeltaX As Double = System.Math.Cos(Radians(Angle)) * (Conductor1.Radius + Conductor2.Radius)
        Dim DeltaY As Double = System.Math.Sin(Radians(Angle)) * (Conductor1.Radius + Conductor2.Radius)
        Dim Cond2Center As Point = New Point(Conductor2.GetValue(Canvas.LeftProperty) + Conductor2.Radius, Conductor2.GetValue(Canvas.TopProperty) + Conductor2.Radius)
        Conductor1.SetValue(Canvas.LeftProperty, (Cond2Center.X + DeltaX) - Conductor1.Radius)
        Conductor1.SetValue(Canvas.TopProperty, (Cond2Center.Y + DeltaY) - Conductor1.Radius)
    End Sub


and the function to convert Degrees to Radians is as follows

Private Function Radians(ByVal Deg As Double) As Double
            Radians = Deg * System.Math.PI / 180
        End Function


The other problem I'm having is positioning 1 element next to 2 other elements, once again if the elements have the same radius it seems to work.


Public Sub Group3Elements(ByVal Conductor1 As Conductor, ByVal Conductor2 As Conductor, ByVal Conductor3 As Conductor, ByVal Side As Integer)
            Dim DeltaX As Double
            Dim DeltaY As Double
            Dim Angle As Double
            Dim aLength, bLength, cLength As Double
            Dim aAngle, bAngle, cAngle As Double
            aLength = Conductor3.Radius + Conductor1.Radius
            bLength = Conductor2.Radius + Conductor1.Radius
            cLength = Conductor2.Radius + Conductor3.Radius
           aAngle = Degrees(System.Math.Acos((bLength ^ 2 + cLength ^ 2 - aLength ^ 2) / (2 * bLength * cLength)))
           bAngle = Degrees(System.Math.Acos((aLength ^ 2 + cLength ^ 2 - bLength ^ 2) / (2 * aLength * cLength)))
           cAngle = Degrees(System.Math.Acos((aLength ^ 2 + bLength ^ 2 - cLength ^ 2) / (2 * aLength * bLength)))
           If Side = 0 Then
               Angle = AngleBetween(Conductor2, Conductor3) - aAngle
           Else
               Angle = AngleBetween(Conductor2, Conductor3) + aAngle
           End If
           DeltaX = System.Math.Cos(Radians(Angle)) * (Conductor2.Radius + Conductor1.Radius)
           DeltaY = System.Math.Sin(Radians(Angle)) * (Conductor2.Radius + Conductor1.Radius)
           Dim Cond2Center As Point = New Point(Conductor2.GetValue(Canvas.LeftProperty) + Conductor2.Radius, Conductor2.GetValue(Canvas.TopProperty) + Conductor2.Radius)
           Conductor1.SetValue(Canvas.LeftProperty, (Cond2Center.X + DeltaX) - Conductor1.Radius)
           Conductor1.SetValue(Canvas.TopProperty, (Cond2Center.Y + DeltaY) - Conductor1.Radius)
       End Sub


and the AngleBeteween code is as follows

Public Function AngleBetween(ByVal Conductor1 As Conductor, ByVal Conductor2 As Conductor) As Double
        Dim Angle As Double
        Dim Cond1Center As Point = New Point(Conductor1.GetValue(Canvas.LeftProperty) + Conductor1.Radius, Conductor1.GetValue(Canvas.TopProperty) + Conductor1.Radius)
        Dim Cond2Center As Point = New Point(Conductor2.GetValue(Canvas.LeftProperty) + Conductor2.Radius, Conductor2.GetValue(Canvas.TopProperty) + Conductor2.Radius)
        Angle = Degrees(System.Math.Asin((Cond2Center.Y - Cond1Center.Y) / (Conductor2.Radius + Conductor1.Radius)))
        If Cond2Center.X < Cond1Center.X Then Angle = 180 - Angle
        AngleBetween = Angle
    End Function


and finally the the function to convert Degrees to Radians is

Private Function Degrees(ByVal rad As Double) As Double
            Degrees = rad * 180 / System.Math.PI
        End Function


Again both Group2Elements & Group3Elements work if the elements all have the same radius if they don't there's no telling where they will end up.


Any help would be appreciated

Thanks
AnswerRe: 3 Tangent Ciricles? Pin
Michael Sync23-Jul-09 19:43
Michael Sync23-Jul-09 19:43 
QuestionWPF: Windows 7 Taskbar Integration throwing COM Exception Pin
Kunal Chowdhury «IN»21-Jul-09 0:26
professionalKunal Chowdhury «IN»21-Jul-09 0:26 
AnswerRe: WPF: Windows 7 Taskbar Integration throwing COM Exception Pin
#realJSOP21-Jul-09 3:48
professional#realJSOP21-Jul-09 3:48 
GeneralRe: WPF: Windows 7 Taskbar Integration throwing COM Exception Pin
Kunal Chowdhury «IN»21-Jul-09 18:35
professionalKunal Chowdhury «IN»21-Jul-09 18:35 
GeneralRe: WPF: Windows 7 Taskbar Integration throwing COM Exception Pin
Keeron24-Jul-09 7:56
Keeron24-Jul-09 7:56 
GeneralRe: WPF: Windows 7 Taskbar Integration throwing COM Exception Pin
Kunal Chowdhury «IN»26-Jul-09 19:15
professionalKunal Chowdhury «IN»26-Jul-09 19:15 
QuestionNeed help with positioning 3D models in a viewport Pin
Etienne_12320-Jul-09 23:23
Etienne_12320-Jul-09 23:23 
AnswerRe: Need help with positioning 3D models in a viewport Pin
Pete O'Hanlon20-Jul-09 23:28
mvePete O'Hanlon20-Jul-09 23:28 
QuestionDropdown button with "search" Textbox using C# Pin
Krishna Aditya20-Jul-09 21:31
Krishna Aditya20-Jul-09 21:31 
AnswerRe: Dropdown button with "search" Textbox using C# Pin
Pete O'Hanlon20-Jul-09 23:08
mvePete O'Hanlon20-Jul-09 23:08 
AnswerRe: Dropdown button with "search" Textbox using C# Pin
Krishna Aditya20-Jul-09 23:39
Krishna Aditya20-Jul-09 23:39 
QuestionTreeview Expansion in MVVM Pin
VickyC#20-Jul-09 21:19
VickyC#20-Jul-09 21:19 
AnswerRe: Treeview Expansion in MVVM Pin
Michael Sync23-Jul-09 19:51
Michael Sync23-Jul-09 19:51 
GeneralRe: Treeview Expansion in MVVM Pin
VickyC#16-Aug-09 13:07
VickyC#16-Aug-09 13:07 
QuestionXamlParseException at startup under debug Pin
Gary Wheeler20-Jul-09 9:27
Gary Wheeler20-Jul-09 9:27 
AnswerRe: XamlParseException at startup under debug Pin
Mark Salsbery21-Jul-09 7:40
Mark Salsbery21-Jul-09 7:40 
GeneralRe: XamlParseException at startup under debug Pin
Gary Wheeler21-Jul-09 7:57
Gary Wheeler21-Jul-09 7:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.