This code...

    if (depth == 1)
    {
        Canvas.SetTop(g1, 163);
    }
    else if (depth == 2)
    {
        Canvas.SetTop(g1, 108);
    }
    else if (depth == 3)
    {
        Canvas.SetTop(g1, 81);
    }
    else if (depth == 4)
    {
        Canvas.SetTop(g1, 65);
    }
    else if (depth == 5)
    {
        Canvas.SetTop(g1, 54);
    }
    else if (depth == 6)
    {
        Canvas.SetTop(g1, 46);
    }

Could be better implemented using an array...

    int[] values = new [] { 0, 163, 108, 81, 65, 54, 46  }

Or Dictionary...

    var values = new Dictionary<int,int>() { { 1, 163 }, { 2, 108 }, { 3, 81 }, { 4, 65 }, { 5, 54 }, { 6, 46} };

This way you could simple say

    Canvas.SetTop(g1, values[depth])