public void Complete(TResult result) { //HRESULT hr = S_OK; //IFCEXPECT(m_isInitialized); //AssertInvariants(); //if (m_flyoutState == FlyoutState::Open) //{ // // If the flyout is not already closed or closing, then we're being called // // because the user accepted a selection, and the flyout will be closed shortly // // by PickerFlyoutBase::OnConfirmedImpl // m_flyoutState = FlyoutState::Closing; //} if (m_flyoutState == FlyoutState.Open) { m_flyoutState = FlyoutState.Closing; } //if (m_spCurrentOperation) //{ if (m_spCurrentOperation != null) { // wrl::ComPtr<wf::IAsyncInfo> spAsyncInfo; // wf::AsyncStatus asyncStatus = wf::AsyncStatus::Started; // // If an operation is deferred, then it is not associated with the current // // open/close cycle of this flyout, and we should not complete it unless it // // has been cancelled. // IFC(m_spCurrentOperation.As(&spAsyncInfo)); // IFC(spAsyncInfo->get_Status(&asyncStatus)); var asyncStatus = m_spCurrentOperation.Status; if (!m_isShowAtForCurrentOperationDeferred || asyncStatus == AsyncStatus.Canceled) { AssertCompleteOperationPreconditions(); // // nulls out m_spCurrentOperation. This is important in the case of rentrancy; // // the consumer's CompleteOperation handler may trigger another call to Start, // // in which case we want Start to be able to return a deferred operation // // rather than failing. // wrl::ComPtr<xaml_controls::IPickerFlyoutAsyncOperation<TResult>> spCurrentOperation; // spCurrentOperation.Swap(m_spCurrentOperation); m_isShowAtForCurrentOperationDeferred = false; m_tpTargetForDeferredShowAt = null; m_spCurrentOperation.CompleteOperation(result); m_spCurrentOperation = null; // IFC(spCurrentOperation->CompleteOperation(result)); } //} //Cleanup: //RRETURN(hr); } AssertInvariants(); }
private void Flyout_Loaded(object sender, RoutedEventArgs e) { if (FlyoutState == FlyoutState.None) { this.FlyoutState = FlyoutState.Closed; } ShowSubMenuHandler(); }
private void ShowSubMenuHandler() { string StoryboardName; if (FlyoutState == FlyoutState.Closed) { TextItemPanel.Width = 0; AnimationHelper.StartShowMenuAnimation(SubItemPanel, StackPanel.MarginProperty, new Thickness(0), new Thickness(-255, 0, 0, 0), .5, (s, e) => { FlyoutState = FlyoutState.Opened; IsOpen = true; //MouseOverButton.Visibility = Visibility.Collapsed; }); //StoryboardName = "sbShowLeftMenu"; //FlyoutState = FlyoutState.Opened; //Storyboard sb = Resources[StoryboardName] as Storyboard; //if(sb.IsFrozen) // sb.Freeze(); //sb.Completed += (s, e) => //{ //}; //sb.Begin(SubItemPanel); } else { AnimationHelper.StartHideMenuAnimation(SubItemPanel, StackPanel.MarginProperty, new Thickness(-256, 0, 0, 0), new Thickness(0), .5, (s, e) => { FlyoutState = FlyoutState.Closed; this.Padding = new Thickness(0); IsOpen = false; TextItemPanel.Width = 15; }); //StoryboardName = "sbHideLeftMenu"; // FlyoutState = FlyoutState.Closed; //Storyboard sb = Resources[StoryboardName] as Storyboard; //if (sb.IsFrozen) // sb.Freeze(); //sb.Completed += (s, e) => //{ // IsOpen = false; // MouseOverButton.Visibility = Visibility.Visible; //}; //sb.Begin(SubItemPanel); } }
private void OnClosed(object sender, EventArgs eventArgs) { AssertInvariants(); AsyncStatus asyncStatus = AsyncStatus.Canceled; m_flyoutState = FlyoutState.Closing; // We loop here because it is possible for the consumer's completion handler to cause a // new deferred operation to begin. If that operation is synchronously canceled for some // reason, we will need to complete the new operation immediately, since there will not // be another Closed event. And as are firing another completion handler, the situation // repeats itself. while (m_spCurrentOperation != null && asyncStatus == AsyncStatus.Canceled) { asyncStatus = m_spCurrentOperation.Status; // IFC(m_spCurrentOperation.As(&spAsyncInfo)); //IFC(spAsyncInfo->get_Status(&asyncStatus)); if (!m_isShowAtForCurrentOperationDeferred || asyncStatus == AsyncStatus.Canceled) { // Two cases: // 1. There is a non-deferred operation associated with the closing flyout. Since // the operation was not completed earlier, the closing of the flying triggers // completion of the operation. // 2. There is a deferred operation, but it has already been cancelled. We can // complete the canceled operation immediately rather than showing the flyout again. Complete(m_cancellationValueCallback()); } if (m_isShowAtForCurrentOperationDeferred) { //m_spCurrentOperation.As(&spAsyncInfo); //IFC(spAsyncInfo->get_Status(&asyncStatus)); asyncStatus = m_spCurrentOperation.Status; if (asyncStatus != AsyncStatus.Canceled) { // Consumer attempted to start an operation while the flyout was closing. // Show the flyout again, and clear the deferral info. We need to do this // asynchronously because FlyoutBase will not accept another ShowAt until // the flyout is fully closed, which happens after the Closed event. BeginAttemptStartDeferredOperation(); } } } if (m_flyoutState == FlyoutState.Closing) { m_flyoutState = FlyoutState.Closed; } }
private void SetState(FlyoutState state) { if (_changingState || _designMode) { return; } _changingState = true; // Transform the target state based on our state. switch (state) { case FlyoutState.Opening: if (!Animate || DegradeVisualPerformance()) { state = FlyoutState.Showing; } break; case FlyoutState.Closing: if (!Animate || DegradeVisualPerformance()) { state = FlyoutState.Closed; } break; } try { _timer.Stop(); var currentState = _state; _state = state; SetStateCore(currentState); OnStateChanged(new FlyoutStateChangedEventArgs(currentState, _state)); } finally { _changingState = false; } }
public FlyoutStateChangedEventArgs(FlyoutState previousState, FlyoutState state) { PreviousState = previousState; State = state; }
private void OnOpening(object sender, EventArgs eventArgs) { m_flyoutState = FlyoutState.Open; }
private void SetStateCore(FlyoutState currentState) { switch (_state) { case FlyoutState.Closed: Visible = false; break; case FlyoutState.Closing: Opacity = OpaqueOpacity; Visible = true; _timer.Interval = FadeDuration / AnimateSteps; _timer.Start(); break; case FlyoutState.Opening: Opacity = 0; Visible = true; _timer.Interval = FadeDuration / AnimateSteps; _timer.Start(); break; case FlyoutState.Pending: Visible = false; _timer.Interval = PendingDuration; _timer.Start(); break; case FlyoutState.Showing: Opacity = OpaqueOpacity; Visible = true; if (ShowDuration.HasValue) { // Don't wait the full duration when we're continuing // from a wait. _timer.Interval = currentState == FlyoutState.Waiting ? ShowDuration.Value / 2 : ShowDuration.Value; _timer.Start(); } break; case FlyoutState.Waiting: Opacity = OpaqueOpacity; Visible = true; _timer.Interval = WaitingDuration; _timer.Start(); break; default: throw new NotSupportedException("Unknown state"); } }
private void SetState(FlyoutState state) { if (_changingState || _designMode) return; _changingState = true; // Transform the target state based on our state. switch (state) { case FlyoutState.Opening: if (!Animate || DegradeVisualPerformance()) state = FlyoutState.Showing; break; case FlyoutState.Closing: if (!Animate || DegradeVisualPerformance()) state = FlyoutState.Closed; break; } try { _timer.Stop(); var currentState = _state; _state = state; SetStateCore(currentState); OnStateChanged(new FlyoutStateChangedEventArgs(currentState, _state)); } finally { _changingState = false; } }