Erstwhile
Erstwhile

Reputation: 71

ScatterView item orientation and PrimarySurfaceDevice.Tilt

I'm working in Visual C# 2010 Express with WPF to develop an application for a Microsoft Surface table, and cannot for the life of me find the simple solution to this problem.

When using a ScatterView control without setting a custom template for scatterview items, the control throws new ScatterViewItems onto the screen at random orientations and positions. This, I like.

I am developing my program on a vertical screen, on which scatterViewItems are randomly thrown, except they are mostly upright, and never thrown on updide-down. What I am getting at is the control knows the screen is vertical and keeps the items from starting out upside down.

However, when I transfer the program to a device with a horizontal screen, the items are now thrown out randomly and OFTEN upside down from the original app orientation. Again the ScatterView control is reading InteractiveSurface.PrimarySurfaceDevice.Tilt (or something like it) and compensating.

How do I make it stop doing this?

I just want my items to continue to appear in the ScatterView as if the screen was vertical. Can I trick ScatterView into thinking it's vertical still? Can I turn this feature off? I would like to avoid making my own template for ScatterViewItems.

Thanks!

Upvotes: 0

Views: 422

Answers (2)

Erstwhile
Erstwhile

Reputation: 71

Well, if nobody can explain how ScatterView knows the screen tilt angle, and how to change that, then the only solution is to generate your own randomness. For reference, here's what I used to do this:

    ScatterViewItem item = new ScatterViewItem();
    item.Content = image;
    Random rand = new Random();

    item.Orientation = RandOrientation(-20, 20);
    item.Center = RandCenter(50);
    SSScatter.Items.Add(item);

    private Point RandCenter(int pad)
    {   
        int randx = rand.Next(pad, (int)SSScatter.Width-pad);
        int randy = rand.Next(pad, (int)SSScatter.Height-pad);
        return new Point(randx, randy);
    }

    private int RandOrientation(int low, int up)
    {
        int randor = rand.Next(low, up);
        return randor;
    }

I still wish there was a way to trick ScatterView...

Upvotes: 0

Robert Levy
Robert Levy

Reputation: 29083

Set the Orientation property to 0 for each item. The randomness only happens when you haven't explicitly set a value

Upvotes: 0

Related Questions