protected override void Initialize() { base.Initialize(); this.cpContent = null; this.cpDetails = null; this.pnlContainer = null; this.currentDetailState = ExpandingSurfaceVEPushPinDetailState.Mini; }
void shrinkClock_Completed(object sender, EventArgs e) { currentDetailState = ExpandingSurfaceVEPushPinDetailState.Mini; cpDetails.Visibility = Visibility.Collapsed; SendOnCollapsed(); }
void growClock_Completed(object sender, EventArgs e) { currentDetailState = ExpandingSurfaceVEPushPinDetailState.Full; SendOnExpanded(); }
void ToggleDetailState() { if (cpContent == null) { pendingToggle = true; return; } cpContent.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); Size sizeTitle = cpContent.DesiredSize; Visibility original = cpDetails.Visibility; cpDetails.Visibility = Visibility.Visible; cpDetails.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); Size sizeDetails = cpDetails.DesiredSize; cpDetails.Visibility = original; pnlContainer.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); Size currentSize = pnlContainer.DesiredSize; AnimateUtility.StopAnimation(pnlContainer, Panel.WidthProperty); AnimateUtility.StopAnimation(pnlContainer, Panel.HeightProperty); pnlContainer.Width = currentSize.Width; pnlContainer.Height = currentSize.Height; Size expandedSize = new Size(sizeTitle.Width, sizeTitle.Height + sizeDetails.Height); if (sizeDetails.Width > sizeTitle.Width) { expandedSize.Width = sizeDetails.Width; } if (currentDetailState == ExpandingSurfaceVEPushPinDetailState.Full || currentDetailState == ExpandingSurfaceVEPushPinDetailState.Growing) { // Hide pp details. if (Map != null) { Map.SendToBack(this); } currentDetailState = ExpandingSurfaceVEPushPinDetailState.Shrinking; AnimateUtility.AnimateElementDouble(cpDetails, Panel.OpacityProperty, 0, 0, 1); AnimateUtility.AnimateElementDouble(pnlContainer, Panel.WidthProperty, sizeTitle.Width, 0, 1); AnimationClock shrinkClock = AnimateUtility.AnimateElementDouble(pnlContainer, Panel.HeightProperty, sizeTitle.Height, 0, 1); shrinkClock.CurrentTimeInvalidated += new EventHandler(currentTimeInvalidated); shrinkClock.Completed += new EventHandler(shrinkClock_Completed); SendOnCollapsing(); } else { // Show pp details. if (Map != null) { Map.SendToFront(this); } currentDetailState = ExpandingSurfaceVEPushPinDetailState.Growing; cpDetails.Visibility = Visibility.Visible; AnimateUtility.AnimateElementDouble(cpDetails, Panel.OpacityProperty, 1, 0, 1); AnimateUtility.AnimateElementDouble(pnlContainer, Panel.WidthProperty, expandedSize.Width, 0, 1); AnimationClock growClock = AnimateUtility.AnimateElementDouble(pnlContainer, Panel.HeightProperty, expandedSize.Height, 0, 1); growClock.CurrentTimeInvalidated += new EventHandler(currentTimeInvalidated); growClock.Completed += new EventHandler(growClock_Completed); SendOnExpanding(); } }
public void OpenDetails() { //Fake it out, set to the opposite of what we want then toggle currentDetailState = ExpandingSurfaceVEPushPinDetailState.Shrinking; ToggleDetailState(); }