Ejemplo n.º 1
0
 void MakeTweet_Loaded(object sender, RoutedEventArgs e)
 {
     VisualStateManager.GoToState(this, "Tweeted", false);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Changes the control's visual state(s).
 /// </summary>
 /// <param name="useTransitions">True if state transitions should be used.</param>
 protected virtual void ChangeVisualState(bool useTransitions)
 {
     VisualStateManager.GoToState(this, IsBusy ? VisualStates.StateBusy : VisualStates.StateIdle, useTransitions);
     VisualStateManager.GoToState(this, IsContentVisible ? VisualStates.StateVisible : VisualStates.StateHidden, useTransitions);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes the DateTimePickerPageBase class; must be called from the subclass's constructor.
        /// </summary>
        /// <param name="primarySelector">Primary selector.</param>
        /// <param name="secondarySelector">Secondary selector.</param>
        /// <param name="tertiarySelector">Tertiary selector.</param>
        protected void InitializeDateTimePickerPage(LoopingSelector primarySelector, LoopingSelector secondarySelector, LoopingSelector tertiarySelector)
        {
            if (null == primarySelector)
            {
                throw new ArgumentNullException("primarySelector");
            }
            if (null == secondarySelector)
            {
                throw new ArgumentNullException("secondarySelector");
            }
            if (null == tertiarySelector)
            {
                throw new ArgumentNullException("tertiarySelector");
            }

            _primarySelectorPart   = primarySelector;
            _secondarySelectorPart = secondarySelector;
            _tertiarySelectorPart  = tertiarySelector;

            // Hook up to interesting events
            _primarySelectorPart.DataSource.SelectionChanged   += OnDataSourceSelectionChanged;
            _secondarySelectorPart.DataSource.SelectionChanged += OnDataSourceSelectionChanged;
            _tertiarySelectorPart.DataSource.SelectionChanged  += OnDataSourceSelectionChanged;
            _primarySelectorPart.IsExpandedChanged             += OnSelectorIsExpandedChanged;
            _secondarySelectorPart.IsExpandedChanged           += OnSelectorIsExpandedChanged;
            _tertiarySelectorPart.IsExpandedChanged            += OnSelectorIsExpandedChanged;

            // Hide all selectors
            _primarySelectorPart.Visibility   = Visibility.Collapsed;
            _secondarySelectorPart.Visibility = Visibility.Collapsed;
            _tertiarySelectorPart.Visibility  = Visibility.Collapsed;

            // Position and reveal the culture-relevant selectors
            int column = 0;

            foreach (LoopingSelector selector in GetSelectorsOrderedByCulturePattern())
            {
                Grid.SetColumn(selector, column);
                selector.Visibility = Visibility.Visible;
                column++;
            }

            // Hook up to storyboard(s)
            FrameworkElement templateRoot = VisualTreeHelper.GetChild(this, 0) as FrameworkElement;

            if (null != templateRoot)
            {
                foreach (VisualStateGroup group in VisualStateManager.GetVisualStateGroups(templateRoot))
                {
                    if (VisibilityGroupName == group.Name)
                    {
                        foreach (VisualState state in group.States)
                        {
                            if ((ClosedVisibilityStateName == state.Name) && (null != state.Storyboard))
                            {
                                _closedStoryboard            = state.Storyboard;
                                _closedStoryboard.Completed += OnClosedStoryboardCompleted;
                            }
                        }
                    }
                }
            }

            // Customize the ApplicationBar Buttons by providing the right text
            if (null != ApplicationBar)
            {
                foreach (object obj in ApplicationBar.Buttons)
                {
                    IApplicationBarIconButton button = obj as IApplicationBarIconButton;
                    if (null != button)
                    {
                        if ("DONE" == button.Text)
                        {
                            button.Text   = ControlResources.DateTimePickerDoneText;
                            button.Click += OnDoneButtonClick;
                        }
                        else if ("CANCEL" == button.Text)
                        {
                            button.Text   = ControlResources.DateTimePickerCancelText;
                            button.Click += OnCancelButtonClick;
                        }
                    }
                }
            }

            // Play the Open state
            VisualStateManager.GoToState(this, OpenVisibilityStateName, true);
        }
 private void Small_GotFocus(object sender, RoutedEventArgs e)
 {
     VisualStateManager.GoToState(this, "FullPin", true);
 }
 private void OnPointerPressed(object sender, PointerRoutedEventArgs e)
 {
     VisualStateManager.GoToState(this, "Pressed", true);
 }
 void OnPageSizeChanged(object sender, SizeChangedEventArgs args)
 {
     VisualStateManager.GoToState(this, ApplicationView.Value.ToString(), true);
 }
Ejemplo n.º 7
0
        public void SetDrawingToolbarPosition(bool onRight)
        {
            var stateName = onRight ? "RightToolbar" : "LeftToolbar";

            VisualStateManager.GoToState(LayoutRoot, stateName);
        }
Ejemplo n.º 8
0
 public void GoToStateExpand()
 {
     VisualStateManager.GoToState(this, "Expand", false);
 }
Ejemplo n.º 9
0
 public void GoToStateCollapse()
 {
     VisualStateManager.GoToState(this, "Collapse", false);
 }
 protected virtual void UpdateVisualStates(bool useTransitions)
 {
     VisualStateManager.GoToState(this,
                                  IsCovered ? CoveredStateName : UncoveredStateName,
                                  useTransitions);
 }
Ejemplo n.º 11
0
        private static void IsOpenPropertyChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
        {
            var dialogHost = (DialogHost)dependencyObject;

            if (dialogHost._popupContentControl != null)
            {
                ValidationAssist.SetSuppress(dialogHost._popupContentControl, !dialogHost.IsOpen);
            }
            VisualStateManager.GoToState(dialogHost, dialogHost.SelectState(), !TransitionAssist.GetDisableTransitions(dialogHost));

            if (dialogHost.IsOpen)
            {
                WatchWindowActivation(dialogHost);
                dialogHost._currentSnackbarMessageQueueUnPauseAction = dialogHost.SnackbarMessageQueue?.Pause();
            }
            else
            {
                dialogHost._attachedDialogClosingEventHandler = null;
                if (dialogHost._currentSnackbarMessageQueueUnPauseAction != null)
                {
                    dialogHost._currentSnackbarMessageQueueUnPauseAction();
                    dialogHost._currentSnackbarMessageQueueUnPauseAction = null;
                }
                dialogHost.CurrentSession.IsEnded = true;
                dialogHost.CurrentSession         = null;
                dialogHost._closeCleanUp();
                //NB: _dialogTaskCompletionSource is only set in the case where the dialog is shown with Show
                //To get into this case you need to display the dialog with Show and then hide it by setting IsOpen to false
                //Setting this here ensures the other
                dialogHost._dialogTaskCompletionSource?.TrySetResult(null);

                // Don't attempt to Invoke if _restoreFocusDialogClose hasn't been assigned yet. Can occur
                // if the MainWindow has started up minimized. Even when Show() has been called, this doesn't
                // seem to have been set.
                dialogHost.Dispatcher.InvokeAsync(() => dialogHost._restoreFocusDialogClose?.Focus(), DispatcherPriority.Input);

                return;
            }

            dialogHost.CurrentSession = new DialogSession(dialogHost);
            var window = Window.GetWindow(dialogHost);

            dialogHost._restoreFocusDialogClose = window != null?FocusManager.GetFocusedElement(window) : null;

            //multiple ways of calling back that the dialog has opened:
            // * routed event
            // * the attached property (which should be applied to the button which opened the dialog
            // * straight forward dependency property
            // * handler provided to the async show method
            var dialogOpenedEventArgs = new DialogOpenedEventArgs(dialogHost.CurrentSession, DialogOpenedEvent);

            dialogHost.OnDialogOpened(dialogOpenedEventArgs);
            dialogHost._attachedDialogOpenedEventHandler?.Invoke(dialogHost, dialogOpenedEventArgs);
            dialogHost.DialogOpenedCallback?.Invoke(dialogHost, dialogOpenedEventArgs);
            dialogHost._asyncShowOpenedEventHandler?.Invoke(dialogHost, dialogOpenedEventArgs);

            dialogHost.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
            {
                CommandManager.InvalidateRequerySuggested();
                UIElement child = dialogHost.FocusPopup();

                if (child != null)
                {
                    //https://github.com/ButchersBoy/MaterialDesignInXamlToolkit/issues/187
                    //totally not happy about this, but on immediate validation we can get some weird looking stuff...give WPF a kick to refresh...
                    Task.Delay(300).ContinueWith(t => child.Dispatcher.BeginInvoke(new Action(() => child.InvalidateVisual())));
                }
            }));
        }
Ejemplo n.º 12
0
 private void FileUploaderControl_Loaded(object sender, RoutedEventArgs e)
 {
     VisualStateManager.GoToState(this, "Empty", false);
 }
Ejemplo n.º 13
0
 void _files_AllFilesFinished(object sender, EventArgs e)
 {
     VisualStateManager.GoToState(this, "Finished", true);
 }
Ejemplo n.º 14
0
 void Current_SizeChanged(object sender, Windows.UI.Core.WindowSizeChangedEventArgs e)
 {
     VisualStateManager.GoToState(this, ApplicationView.Value.ToString(), true);
 }
Ejemplo n.º 15
0
 void ItemHighlight_MouseLeave(object sender, MouseEventArgs e)
 {
     VisualStateManager.GoToState(this, "noneHighlightedMBI", true);
 }
Ejemplo n.º 16
0
 public void GoToStateNumeric()
 {
     VisualStateManager.GoToState(this, "Numeric", false);
 }
Ejemplo n.º 17
0
 private void TargetTextBox_DragLeave(object sender, DragEventArgs e)
 {
     VisualStateManager.GoToState(this, "Outside", true);
 }
Ejemplo n.º 18
0
        /// <summary>
        /// Update the visual state of the control when its template is changed.
        /// </summary>
        protected override void OnApplyTemplate()
        {
            if (_minThumb != null)
            {
                _minThumb.DragCompleted -= Thumb_DragCompleted;
                _minThumb.DragDelta     -= MinThumb_DragDelta;
                _minThumb.DragStarted   -= MinThumb_DragStarted;
                _minThumb.KeyDown       -= MinThumb_KeyDown;
            }

            if (_maxThumb != null)
            {
                _maxThumb.DragCompleted -= Thumb_DragCompleted;
                _maxThumb.DragDelta     -= MaxThumb_DragDelta;
                _maxThumb.DragStarted   -= MaxThumb_DragStarted;
                _maxThumb.KeyDown       -= MaxThumb_KeyDown;
            }

            if (_containerCanvas != null)
            {
                _containerCanvas.SizeChanged     -= ContainerCanvas_SizeChanged;
                _containerCanvas.PointerPressed  -= ContainerCanvas_PointerPressed;
                _containerCanvas.PointerMoved    -= ContainerCanvas_PointerMoved;
                _containerCanvas.PointerReleased -= ContainerCanvas_PointerReleased;
                _containerCanvas.PointerExited   -= ContainerCanvas_PointerExited;
            }

            IsEnabledChanged -= RangeSelector_IsEnabledChanged;

            // Need to make sure the values can be set in XAML and don't overwrite each other
            VerifyValues();
            _valuesAssigned = true;

            _outOfRangeContentContainer = GetTemplateChild("OutOfRangeContentContainer") as Border;
            _activeRectangle            = GetTemplateChild("ActiveRectangle") as Rectangle;
            _minThumb        = GetTemplateChild("MinThumb") as Thumb;
            _maxThumb        = GetTemplateChild("MaxThumb") as Thumb;
            _containerCanvas = GetTemplateChild("ContainerCanvas") as Canvas;
            _controlGrid     = GetTemplateChild("ControlGrid") as Grid;
            _toolTip         = GetTemplateChild("ToolTip") as Grid;
            _toolTipText     = GetTemplateChild("ToolTipText") as TextBlock;

            if (_minThumb != null)
            {
                _minThumb.DragCompleted += Thumb_DragCompleted;
                _minThumb.DragDelta     += MinThumb_DragDelta;
                _minThumb.DragStarted   += MinThumb_DragStarted;
                _minThumb.KeyDown       += MinThumb_KeyDown;
                _minThumb.KeyUp         += Thumb_KeyUp;
            }

            if (_maxThumb != null)
            {
                _maxThumb.DragCompleted += Thumb_DragCompleted;
                _maxThumb.DragDelta     += MaxThumb_DragDelta;
                _maxThumb.DragStarted   += MaxThumb_DragStarted;
                _maxThumb.KeyDown       += MaxThumb_KeyDown;
                _maxThumb.KeyUp         += Thumb_KeyUp;
            }

            if (_containerCanvas != null)
            {
                _containerCanvas.SizeChanged     += ContainerCanvas_SizeChanged;
                _containerCanvas.PointerEntered  += ContainerCanvas_PointerEntered;
                _containerCanvas.PointerPressed  += ContainerCanvas_PointerPressed;
                _containerCanvas.PointerMoved    += ContainerCanvas_PointerMoved;
                _containerCanvas.PointerReleased += ContainerCanvas_PointerReleased;
                _containerCanvas.PointerExited   += ContainerCanvas_PointerExited;
            }

            VisualStateManager.GoToState(this, IsEnabled ? "Normal" : "Disabled", false);

            IsEnabledChanged += RangeSelector_IsEnabledChanged;

            // Measure our min/max text longest value so we can avoid the length of the scrolling reason shifting in size during use.
            var tb = new TextBlock {
                Text = Maximum.ToString()
            };

            tb.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));

            base.OnApplyTemplate();
        }
Ejemplo n.º 19
0
 protected override void UpdateVisualState(bool useTransitions)
 {
     VisualStateManager.GoToState(this, GetCommonStateName(), useTransitions);
     VisualStateManager.GoToState(this, GetCheckStateName(), useTransitions);
 }
Ejemplo n.º 20
0
 private void ContainerCanvas_PointerEntered(object sender, PointerRoutedEventArgs e)
 {
     VisualStateManager.GoToState(this, "PointerOver", false);
 }
 private void Small_Tapped(object sender, TappedRoutedEventArgs e)
 {
     VisualStateManager.GoToState(this, "FullPin", true);
 }
Ejemplo n.º 22
0
 private void GoToState(string name)
 {
     VisualStateManager.GoToState(this, name, false);
 }
 private void OnPointerEntered(object sender, PointerRoutedEventArgs e)
 {
     VisualStateManager.GoToState(this, "PointerOver", true);
     //VisualStateManager.GoToState(this, "FullPin", true);
 }
        private void CategoriesPage_SizeChanged(object sender, EventArgs e)
        {
            string visualState = Width > Height ? "Landscape" : "Portrait";

            VisualStateManager.GoToState(titleLabel, visualState);
        }
 private void OnPointerReleased(object sender, PointerRoutedEventArgs e)
 {
     VisualStateManager.GoToState(this, "Normal", true);
 }
Ejemplo n.º 26
0
 private void OnIsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e)
 {
     VisualStateManager.GoToState(this, this.IsEnabled ? "Normal" : "Disabled", true);
 }
Ejemplo n.º 27
0
 private void rect_Tapped(object sender, TappedRoutedEventArgs e)
 {
     VisualStateManager.GoToState(this, HiddenState.Name, true);
 }
Ejemplo n.º 28
0
        /// <summary>
        /// Called when the template is applied to the control.
        /// </summary>
        protected override void OnApplyTemplate()
        {
            if (this.contentContainer != null)
            {
                this.contentContainer.PointerPressed -= this.ContentContainer_OnPointerPressed;
                this.contentContainer.PointerMoved -= this.ContentContainer_OnPointerMoved;
                this.contentContainer.PointerReleased -= this.ContentContainer_OnPointerReleased;
                this.contentContainer.PointerExited -= this.ContentContainer_OnPointerExited;
            }

            if (this.minThumb != null)
            {
                this.minThumb.DragCompleted -= this.Thumb_OnDragCompleted;
                this.minThumb.DragDelta -= this.MinThumb_OnDragDelta;
                this.minThumb.DragStarted -= this.MinThumb_OnDragStarted;
            }

            if (this.maxThumb != null)
            {
                this.maxThumb.DragCompleted -= this.Thumb_OnDragCompleted;
                this.maxThumb.DragDelta -= this.MaxThumb_OnDragDelta;
                this.maxThumb.DragStarted -= this.MaxThumb_OnDragStarted;
            }

            if (this.containerCanvas != null)
            {
                this.containerCanvas.SizeChanged -= this.ContainerCanvas_OnSizeChanged;
            }

            this.IsEnabledChanged -= this.OnIsEnabledChanged;

            this.SetDefaultValues();
            this.areValuesAssigned = true;

            this.contentContainer = this.GetTemplateChild("ContentContainer") as Border;
            this.activeRectangle = this.GetTemplateChild("ActiveRectangle") as Rectangle;
            this.minThumb = this.GetTemplateChild("MinThumb") as Thumb;
            this.maxThumb = this.GetTemplateChild("MaxThumb") as Thumb;
            this.containerCanvas = this.GetTemplateChild("ContainerCanvas") as Canvas;

            if (this.contentContainer != null)
            {
                this.contentContainer.PointerPressed += this.ContentContainer_OnPointerPressed;
                this.contentContainer.PointerMoved += this.ContentContainer_OnPointerMoved;
                this.contentContainer.PointerReleased += this.ContentContainer_OnPointerReleased;
                this.contentContainer.PointerExited += this.ContentContainer_OnPointerExited;
            }

            if (this.minThumb != null)
            {
                this.minThumb.DragCompleted += this.Thumb_OnDragCompleted;
                this.minThumb.DragDelta += this.MinThumb_OnDragDelta;
                this.minThumb.DragStarted += this.MinThumb_OnDragStarted;
            }

            if (this.maxThumb != null)
            {
                this.maxThumb.DragCompleted += this.Thumb_OnDragCompleted;
                this.maxThumb.DragDelta += this.MaxThumb_OnDragDelta;
                this.maxThumb.DragStarted += this.MaxThumb_OnDragStarted;
            }

            if (this.containerCanvas != null)
            {
                this.containerCanvas.SizeChanged += this.ContainerCanvas_OnSizeChanged;
            }

            VisualStateManager.GoToState(this, this.IsEnabled ? "Normal" : "Disabled", false);

            this.IsEnabledChanged += this.OnIsEnabledChanged;

            base.OnApplyTemplate();
        }
Ejemplo n.º 29
0
 protected override void OnMouseLeave(MouseEventArgs e)
 {
     VisualStateManager.GoToState(this, "MouseNotOver", false);
     base.OnMouseLeave(e);
 }
Ejemplo n.º 30
0
 public void StartMessage(string text)
 {
     TweetText = text;
     VisualStateManager.GoToState(this, "Normal", true);
 }