One way pivot paging - windows-phone-7

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.

Related

Grid based ai path finding with smooth movement

I'm attempting a grid based path finding to my game. The ai would always teleport, so, I've been working on a way to make it smoothly transition to the next tile with no luck. I also don't want the instances to overlap, which means that I have to constantly update the grid with clear and add. I've been at this for a month now with no success. I would greatly appreciate any help. If you have every played Pokemon mystery dungeon, I'm trying to make the movement be just like that.
Store in the object the cell it should eventually arrive at ( target_x and target_y ). Each time you go to a different cell, do a check on all 4 cells from the object in different directions. The checks are whether the cell is the closest to the target, or whether the cell is occupied by someone else. Each time we check for the closest cell to the target, we write the cell we are checking into a variable (closest_cell). If no better candidates are found, then specify (direction) and change (speed) so that we move smoothly to (closest_cell). If all 4 checks fail, stop moving.

Make a view go vertical if other view tries to compress it horizontally with constraints?

Let's say you have a label on the right and another label on the left of a screen. Text on the left one can grow till the end of the screen. Is it possible to make constraints to push the left label down if the right one grows so big it starts to compress the left one?
Ps. without constraints it seems easy, but the question is about constraints
Is it possible to make constraints to push the left label down if the right one grows so big it starts to compress the left one?
Yes, but not by magic. You would need, in code, to detect that this has happened and actually change the constraints entirely in order to rearrange the labels.
A more common solution to this problem is to give the left label a fixed minimum size so that the right one cannot compress it beyond a certain amount. You can even let the right label grow to multiple lines.

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.

How to determine pivot flick is right or left?

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 :)

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