/// <summary> /// PositionProperty property changed handler. /// </summary> /// <param name="d">Slide that changed its Position.</param> /// <param name="e">Event arguments.</param> private static void OnPositionPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { Slide source = d as Slide; SlidePosition value = (SlidePosition)e.NewValue; if (value != SlidePosition.Left && value != SlidePosition.Normal && value != SlidePosition.Right) { d.SetValue(e.Property, e.OldValue); return; } source.UpdateVisualState(true, value); }
/// <summary> /// Initializes the position of the slide based on location. /// </summary> /// <param name="slide">The slide instance.</param> /// <param name="isFirst">A property indicating whether the slide is the /// first to be managed.</param> private void InitializePosition(Slide slide, bool isFirst) { SlidePosition c = slide.Position; SlidePosition expected = isFirst ? SlidePosition.Normal : SlidePosition.Right; if (c != expected) { slide.Position = expected; } // CONSIDER: Need to modify all others as well? if (_slides.First != null && _slides.First.Value == slide) { _current = _slides.First; } }
void SetSlidePosition(int slideIndex) { if (slideIndex != tutorialContents.Count - 1 && slideIndex != 0) { slidePosition = SlidePosition.Default; } else if (slideIndex == 0) { slidePosition = SlidePosition.First; } else if (slideIndex == tutorialContents.Count - 1) { slidePosition = SlidePosition.Last; } }
/// <summary> /// Move in a direction. /// </summary> /// <param name="forward">A value indicating whether the direction to /// move is forward or not.</param> private void Move(bool forward) { LinkedListNode <Slide> oldNode = _current; Slide old = oldNode.Value; SlidePosition sp = SlidePosition.Normal; if (forward && oldNode.Next != null) { _current = oldNode.Next; sp = SlidePosition.Left; } else if (!forward && oldNode.Previous != null) { _current = oldNode.Previous; sp = SlidePosition.Right; } if (oldNode != _current) { _current.Value.Position = SlidePosition.Normal; old.Position = sp; } }
/// <summary> /// Updates the visual state. /// </summary> /// <param name="useTransitions">A value indicating whether to use /// visual transitions for the state change.</param> /// <param name="sp">The slide position to use.</param> private void UpdateVisualState(bool useTransitions, SlidePosition sp) { string state; switch (Position) { case SlidePosition.Left: state = StatePositionLeft; break; case SlidePosition.Right: state = StatePositionRight; break; default: state = StatePositionNormal; break; } // Always expand the visual for a state change Visibility = Visibility.Visible; VisualStateManager.GoToState(this, state, false); // useTransitions); }