How to determine pivot flick is right or left? - windows-phone-7

Which event is used to determine if the user flicked the pivot right or left?

The Pivot control uses the angle reported in the FlickEventArgs of the Flick event to determine which way to navigate the items. An angle of 180 degrees means a navigation to the right, an angle of 0 degrees means a navigation to the left.
If you want to detect this in your own code you could use the GestureService from the Silverlight Windows Phone Toolkit as described in this article or you could simply keep track of the SelectedIndex property on the Pivot control to determine which way the user flicked.
I'd be interested to know to what purpose you're going to put this knowledge :)

Related

What does "nearest bottom neighbor" mean in layman terms when using auto layout?

I've noticed the term nearest bottom neighbor used in different contexts when following tutorials on building interfaces in interface builder. Does the nearest bottom neighbor mean, if I come in contact with a view on the way down to the bottom safe area line then that would be the nearest neighbor?
An example tutorial can be found here:
Auto Layout Tutorial
Under the very special circumstance where you use this popover to form constraints from a selected view...
... how does the dialog know what you want to constrain to in a given direction? It doesn’t. So it just makes a rule that if you pick a direction it will constrain this view to the first view whose edge it comes to in that direction. The dialog terms that the “nearest neighbor”.
Thus, for the downward direction, we could call that view this view’s “nearest bottom neighbor”.
(Personally, I think there is so much limitation, confusion, indeterminacy, and inconvenience in that popover, that I never use it to form constraints. I can’t tell you what to do, but perhaps that’s a useful perspective at least. If you go the longer route and draw the constraint by control-dragging from one view to another, you know exactly what you're doing; so that's how I always do it, even if it takes a little more work to configure the constraints after creating them.)

How do you get the view coordinates of a CListCtrl in LVS_REPORT style on Win XP

I'm trying to coordinate the scrolling of a CListCtrl with another control. Contrary to the documentation on Win 7 you can call CListCtrl::GetViewRect or CListCtrl::GetOrigin to get the viewable area coordinates.
e.g. If you're scrolled 10 units across CListCtrl::GetOriginwill return x=10, y=0.
Unfortunately Win XP does follow the SDK documentation which says "... if the control is in report view, the return value is always zero".
I'm sure this must be really simple but whats the best way to get the top left coordinates of a CListCtrl viewable area?
It turns out that GetScrollInfo will do the trick. The nPos value matches the window coordinates (ie the min/max range represents the total size of columns not a fixed 0-100 range).

One way pivot paging

I want to create a photo gallery basically.
I have a list of x items, and a pivot of 3 pages fixed.
(I did this because I don't know in advance will I have 4 items or 1000)
When I'm browsing between the items and I reach the last one, I want to disable further paging to the right, or to the left if I reached the begining.
Is this possible, and how?
Thanks in advance.
You can use my answer here to determine when the user is on the first or last pivot item. Once you reach the the first or last pivot page, you can then disable the hit testing by using IsHitTestVisible=false as described on this page. To ensure that you can still swipe in the opposite direction, you can detect a horizontal swipe to the left to re-enable it and then manually move the pivot using SelectedIndex.
There are various ways of detecting a horizontal swipe such as using the gesture library or calculating it manually. You can get the starting position and the final position of the user's touch and determine if the difference in the X positions is positive (swiped to the right) or negative (swiped to the left) - assuming you're subtracting the initial position from the final one.

Virtualizing horizontally and vertically for large grid

Is it possible to virtualize both horizontally and vertically?
All examples show one or the other.
Imagine a large grid like structure:
n amount of rows
and as many columns as there are hours in one month
At any one point only 4 rows maybe on screen showing only 2 columns (2 hours). Virtualization one way doesn't make sense. This is an up down / left to right scrollable grid.
I ask because I can't for life of me find any examples online? Also I can't find anyone else who has had the same query. Maybe the design in general is wrong or I don't quite know what I'm searching for.
I did think the design maybe wrong i.e. is there a better alternative but I don't think so. This planner-like-grid is required! The only other consideration I had was to dyanmically build pivot pages but this seems messy and won't have the same feel.
Can anyone begin to advise were I might look?
Whether right or wrong, the direction I'm going in is the following. I wanted to post one answer for any one stumbling across the question.
Using a grid, I'm creating a 2 x 2 grid. Top right, bottom left and bottom right will all contain scroll viewers. The scroll viewer in the bottom right when scrolled will dyanmically change the scroll position of the bottom left scroll viewer and top right scroll viewer. Similar scroll top right will dyanmically scroll bottom right, and bottom left will scroll bottom right.
Obviously a lot of scroll viewer bindings but this is one solution which will work in order to give me the planner functionality and layout.
In terms of the virtualization I am dyanmically going to queue controls in order to keep the performance decent, reusing controls where required.

Scrollbars for Infinite Document?

Is there a standard Aqua way to handle a practically infinite document?
For example, imagine a level editor for a tile-based game. The level has no preset size (though it's technically limited by NSInteger's size); tiles can be placed anywhere on the grid. Is there a standard interface for scrolling through such a document?
I can't simply limit the scrolling to areas that already have tiles, because the user needs to be able to add tiles outside that boundary. Arbitrarily creating a level size, even if it's easily changeable by the user, doesn't seem ideal either.
Has anyone seen an application that deals with this problem?
One option is to essentially dynamically expand the area as the user scrolls through it - any time the user scrolls within X units of an edge, add another unit in that direction. Essentially, you'll never be able to scroll "all the way" to an edge, because the closer you get the farther it will expand.
If the user scrolls back away from the edge, contract it to back to no more than X units beyond where there is actually content.
Have you seen what Microsoft Excel does for this problem? It has to represent an unbounded space with scrollbars, as well.
One solution is to define a reasonable space for the original level size, and when the user scrolls to one tile away from its bounds, add another row or column of tiles, and adjust the scrollbar accordingly. This way, the user never reaches the actual bounds.
If the user decides to cut down on the level size, you could also add code that shrinks the "reasonable space" once an unused row consists only of empty tiles. This saves the user from being stuck with a huge level that they scrolled through, with no way to shrink it.
Edit: Same as Dav's answer. :)

Resources