ElevationAngle

Jul 12, 2011 at 2:59 PM

Hello,

first of all thanks for sharing your knowledge!

We noticed that the ElevationAngle frequently causes Exceptions so we found a better way is to wrap it in an extension method:

    public static class Extensions
    {
        public static bool TrySetElevationAngle(this Camera camera, int angle)
        {
            bool success = false;
            try
            {
                camera.ElevationAngle = angle;
                success = true;
            }
            catch{}
            return success;
        }
    }

And then use the extension method in BindableNUICamera.cs:

        public int ElevationAngle
        {
            get { return nuiCamera.ElevationAngle; }
            set
            {
                if (nuiCamera.ElevationAngle == value)
                    return;

                if (value > ElevationMaximum || value < ElevationMinimum)
                    return;

                if(nuiCamera.TrySetElevationAngle(value))
                    RaisePropertyChanged(() => ElevationAngle);               
            }
        }

Thanks again and keep up the good work.

Angelo

Coordinator
Jul 12, 2011 at 3:48 PM
Excellent!

thanks a lot.
I will publish tour update:)

Envoyé à partir de mon Windows Phone

De : nanus
Envoyé : 12/07/2011 15:59
À : david.catuhe@live.fr
Objet : ElevationAngle [KinectToolkit:264829]

From: nanus

Hello,

first of all thanks for sharing your knowledge!

We noticed that the ElevationAngle frequently causes Exceptions so we found a better way is to wrap it in an extension method:

public static class Extensions
{
public static bool TrySetElevationAngle(this Camera camera, int angle)
{
bool success = false;
try
{
camera.ElevationAngle = angle;
success = true;
}
catch{}
return success;
}
}

And then use the extension method in BindableNUICamera.cs:

public int ElevationAngle
{
get { return nuiCamera.ElevationAngle; }
set
{
if (nuiCamera.ElevationAngle == value)
return;

if (value > ElevationMaximum || value < ElevationMinimum)
return;

if(nuiCamera.TrySetElevationAngle(value))
RaisePropertyChanged(() => ElevationAngle);
}
}

Thanks again and keep up the good work.

Angelo