public MainPage() { InitializeComponent(); IMicroIocContainer container = (IMicroIocContainer)Application.Current.Resources["Container"]; this.DataContext = container.TryResolve<MainPageViewModel>(); IEventAggregator eventAggregator = container.Resolve<IEventAggregator>(); baseEvent = eventAggregator.GetEvent<BaseEvent>(); _visualStates = new VisualStates(this); _feContainer = this.Container as FrameworkElement; this.Loaded += MainPage_Loaded; }
internal void ApplyState() { // Common States if (this.IsMouseOver) { VisualStates.GoToState(this, true, VisualStates.StateMouseOver, VisualStates.StateNormal); } else { VisualStates.GoToState(this, true, VisualStates.StateNormal); } // Sort States this.CurrentSortingState = null; if (this.OwningGrid != null && this.OwningGrid.DataConnection != null && this.OwningGrid.DataConnection.AllowSort) { SortDescription?sort = this.OwningColumn.GetSortDescription(); if (sort.HasValue) { this.CurrentSortingState = sort.Value.Direction; if (this.CurrentSortingState == ListSortDirection.Ascending) { VisualStates.GoToState(this, true, VisualStates.StateSortAscending, VisualStates.StateUnsorted); } if (this.CurrentSortingState == ListSortDirection.Descending) { VisualStates.GoToState(this, true, VisualStates.StateSortDescending, VisualStates.StateUnsorted); } } else { VisualStates.GoToState(this, true, VisualStates.StateUnsorted); } } }
/// <summary> /// Updates the state of the visual. /// </summary> /// <param name="useTransitions">If set to <c>true</c> use transitions.</param> /// <remarks>The header will follow the parent accordionitem states.</remarks> internal virtual void UpdateVisualState(bool useTransitions) { // the visualstate of the header is completely dependent on the parent state. if (ParentAccordionItem == null) { return; } if (ParentAccordionItem.IsSelected) { VisualStates.GoToState(this, useTransitions, VisualStates.StateExpanded); } else { VisualStates.GoToState(this, useTransitions, VisualStates.StateCollapsed); } switch (ParentAccordionItem.ExpandDirection) { // no animations on an expanddirection change. case ExpandDirection.Down: VisualStates.GoToState(this, false, VisualStates.StateExpandDown); break; case ExpandDirection.Up: VisualStates.GoToState(this, false, VisualStates.StateExpandUp); break; case ExpandDirection.Left: VisualStates.GoToState(this, false, VisualStates.StateExpandLeft); break; default: VisualStates.GoToState(this, false, VisualStates.StateExpandRight); break; } }
/// <summary> /// TransitionProperty property changed handler. /// </summary> /// <param name="d">TransitioningContentControl that changed its Transition.</param> /// <param name="e">Event arguments.</param> private static void OnTransitionPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { TransitioningContentControl source = (TransitioningContentControl)d; string oldTransition = e.NewValue as string; string newTransition = e.NewValue as string; if (source.IsTransitioning) { source.AbortTransition(); } // find new transition Storyboard newStoryboard = source.GetStoryboard(newTransition); // unable to find the transition. if (newStoryboard == null) { // could be during initialization of xaml that presentationgroups was not yet defined if (VisualStates.TryGetVisualStateGroup(source, PresentationGroup) == null) { // will delay check source.CurrentTransition = null; } else { // revert to old value source.SetValue(TransitionProperty, oldTransition); throw new ArgumentException( string.Format(CultureInfo.CurrentCulture, Properties.Resources.TransitioningContentControl_TransitionNotFound, newTransition)); } } else { source.CurrentTransition = newStoryboard; } }
/// <summary> /// Change to the correct visual state for the textbox. /// </summary> /// <param name="useTransitions"> /// true to use transitions when updating the visual state, false to /// snap directly to the new visual state. /// </param> private void ChangeVisualState(bool useTransitions) { // Update the CommonStates group if (!IsEnabled) { VisualStates.GoToState(this, useTransitions, VisualStates.StateDisabled, VisualStates.StateNormal); } else if (isHovered) { VisualStates.GoToState(this, useTransitions, VisualStates.StateMouseOver, VisualStates.StateNormal); } else { VisualStates.GoToState(this, useTransitions, VisualStates.StateNormal); } // Update the FocusStates group if (IsFocused && IsEnabled) { VisualStates.GoToState(this, useTransitions, VisualStates.StateFocused, VisualStates.StateUnfocused); } else { VisualStates.GoToState(this, useTransitions, VisualStates.StateUnfocused); } // Update the WatermarkStates group if (this.Watermark != null && string.IsNullOrEmpty(this.Text)) { VisualStates.GoToState(this, useTransitions, VisualStates.StateWatermarked, VisualStates.StateUnwatermarked); } else { VisualStates.GoToState(this, useTransitions, VisualStates.StateUnwatermarked); } }
/// <summary> /// Updates the hover states of the rating items. /// </summary> private void UpdateHoverStates() { if (HoveredRatingItem != null && IsEnabled) { IList <RatingItem> ratingItems = GetRatingItems().ToList(); int indexOfItem = ratingItems.IndexOf(HoveredRatingItem); double total = ratingItems.Count(); double filled = indexOfItem + 1; this.DisplayValue = filled / total; for (int cnt = 0; cnt < ratingItems.Count; cnt++) { RatingItem ratingItem = ratingItems[cnt]; if (cnt <= indexOfItem && this.SelectionMode == RatingSelectionMode.Continuous) { VisualStates.GoToState(ratingItem, true, VisualStates.StatePointerOver); } else { IUpdateVisualState updateVisualState = (IUpdateVisualState)ratingItem; updateVisualState.UpdateVisualState(true); } } } else { this.DisplayValue = this.Value; foreach (IUpdateVisualState updateVisualState in GetRatingItems().OfType <IUpdateVisualState>()) { updateVisualState.UpdateVisualState(true); } } }
// Token: 0x06005F52 RID: 24402 RVA: 0x001AB934 File Offset: 0x001A9B34 internal override void ChangeVisualState(bool useTransitions) { if (!base.IsEnabled) { VisualStates.GoToState(this, useTransitions, new string[] { "Disabled", "Normal" }); } else if (base.IsMouseOver) { VisualStates.GoToState(this, useTransitions, new string[] { "MouseOver", "Normal" }); } else { VisualStateManager.GoToState(this, "Normal", useTransitions); } if (base.IsKeyboardFocused) { VisualStates.GoToState(this, useTransitions, new string[] { "Focused", "Unfocused" }); } else { VisualStateManager.GoToState(this, "Unfocused", useTransitions); } base.ChangeVisualState(useTransitions); }
internal void ApplyOwnerStatus(bool animate) { if (this._rootElement != null && this.Owner != null && this.Owner.Visibility == Visibility.Visible) { byte idealStateMappingIndex = 0; if (this.OwningRow != null) { if (this.OwningRow.IsValid) { VisualStates.GoToState(this, true, VisualStates.StateRowValid); } else { VisualStates.GoToState(this, true, VisualStates.StateRowInvalid, VisualStates.StateRowValid); } if (this.OwningGrid != null) { if (this.OwningGrid.CurrentSlot == this.OwningRow.Slot) { idealStateMappingIndex += 16; } if (this.OwningGrid.ContainsFocus) { idealStateMappingIndex += 1; } } if (this.OwningRow.IsSelected || this.OwningRow.IsEditing) { idealStateMappingIndex += 8; } if (this.OwningRow.IsEditing) { idealStateMappingIndex += 4; } if (this.OwningRow.IsMouseOver) { idealStateMappingIndex += 2; } } else if (this.OwningRowGroupHeader != null && this.OwningGrid != null && this.OwningGrid.CurrentSlot == this.OwningRowGroupHeader.RowGroupInfo.Slot) { idealStateMappingIndex += 16; } byte stateCode = _idealStateMapping[idealStateMappingIndex]; Debug.Assert(stateCode != DATAGRIDROWHEADER_stateNullCode); string storyboardName; while (stateCode != DATAGRIDROWHEADER_stateNullCode) { storyboardName = _stateNames[stateCode]; if (VisualStateManager.GoToState(this, storyboardName, animate) || VisualStateManager.GoToState(this, _legacyStateNames[stateCode], animate)) { break; } else { // The state wasn't implemented so fall back to the next one stateCode = _fallbackStateMapping[stateCode]; } } } }
internal void ApplyCellState(bool animate) { if (this.OwningGrid == null || this.OwningColumn == null || this.OwningRow == null || this.OwningRow.Visibility == Visibility.Collapsed || this.OwningRow.Slot == -1) { return; } // CommonStates if (this.IsPointerOver) { VisualStates.GoToState(this, animate, VisualStates.StatePointerOver, VisualStates.StateNormal); } else { VisualStates.GoToState(this, animate, VisualStates.StateNormal); } // SelectionStates if (this.OwningRow.IsSelected) { VisualStates.GoToState(this, animate, VisualStates.StateSelected, VisualStates.StateUnselected); } else { VisualStates.GoToState(this, animate, VisualStates.StateUnselected); } // CurrentStates if (this.IsCurrent && !this.OwningGrid.ColumnHeaderHasFocus) { if (this.OwningGrid.ContainsFocus) { VisualStates.GoToState(this, animate, VisualStates.StateCurrentWithFocus, VisualStates.StateCurrent, VisualStates.StateRegular); } else { VisualStates.GoToState(this, animate, VisualStates.StateCurrent, VisualStates.StateRegular); } } else { VisualStates.GoToState(this, animate, VisualStates.StateRegular); } // Interaction states if (this.IsEdited) { VisualStates.GoToState(this, animate, VisualStates.StateEditing, VisualStates.StateDisplay); } else { VisualStates.GoToState(this, animate, VisualStates.StateDisplay); } // Validation states if (this.IsValid) { VisualStates.GoToState(this, animate, VisualStates.StateValid); } else { VisualStates.GoToState(this, animate, VisualStates.StateInvalid, VisualStates.StateValid); } }
/// <summary> /// Change to the correct visual state for the button. /// </summary> /// <param name="useTransitions"> /// True to use transitions when updating the visual state, false to /// snap directly to the new visual state. /// </param> internal void ChangeVisualState(bool useTransitions) { if (_ignoringMouseOverState) { if (IsPressed) { VisualStates.GoToState(this, useTransitions, VisualStates.StatePressed); } if (IsEnabled) { VisualStates.GoToState(this, useTransitions, VisualStates.StateNormal); } else { VisualStates.GoToState(this, useTransitions, VisualStates.StateDisabled); } } // Update the SelectionStates group if (IsSelected) { VisualStates.GoToState(this, useTransitions, VisualStates.StateSelected, VisualStates.StateUnselected); } else { VisualStates.GoToState(this, useTransitions, VisualStates.StateUnselected); } // Update the ActiveStates group if (IsInactive) { VisualStates.GoToState(this, useTransitions, VisualStates.StateInactive); } else { VisualStates.GoToState(this, useTransitions, VisualStates.StateActive, VisualStates.StateInactive); } // Update the DayStates group if (IsToday) { VisualStates.GoToState(this, useTransitions, StateToday, StateRegularDay); } else { VisualStates.GoToState(this, useTransitions, StateRegularDay); } // Update the BlackoutDayStates group if (IsBlackout) { VisualStates.GoToState(this, useTransitions, StateBlackoutDay, StateNormalDay); } else { VisualStates.GoToState(this, useTransitions, StateNormalDay); } // Update the CalendarButtonFocusStates group (IsCurrent means the // button is the focused element on the GlobalCalendar control). if (IsCurrent && IsEnabled) { VisualStates.GoToState(this, useTransitions, VisualStates.StateCalendarButtonFocused, VisualStates.StateCalendarButtonUnfocused); } else { VisualStates.GoToState(this, useTransitions, VisualStates.StateCalendarButtonUnfocused); } }
/// <summary> /// Change to the correct visual state for the button. /// </summary> /// <param name="useTransitions"> /// true to use transitions when updating the visual state, false to /// snap directly to the new visual state. /// </param> internal void ChangeVisualState(bool useTransitions) { if (this.IsEnabled) { VisualStates.GoToState(this, useTransitions, VisualStates.StateNormal); } else { VisualStates.GoToState(this, useTransitions, VisualStates.StateDisabled); } // Update the SelectionStates group if (IsSelected || IsHighlighted) { VisualStates.GoToState(this, useTransitions, VisualStates.StateSelected, VisualStates.StateUnselected); } else { VisualStates.GoToState(this, useTransitions, VisualStates.StateUnselected); } // Update the ActiveStates group if (!IsInactive) { VisualStates.GoToState(this, useTransitions, VisualStates.StateActive, VisualStates.StateInactive); } else { VisualStates.GoToState(this, useTransitions, VisualStates.StateInactive); } // Update the DayStates group if (IsToday && this.Owner != null && this.Owner.IsTodayHighlighted) { VisualStates.GoToState(this, useTransitions, StateToday, StateRegularDay); } else { VisualStates.GoToState(this, useTransitions, StateRegularDay); } // Update the BlackoutDayStates group if (IsBlackedOut) { VisualStates.GoToState(this, useTransitions, StateBlackoutDay, StateNormalDay); } else { VisualStates.GoToState(this, useTransitions, StateNormalDay); } // Update the FocusStates group if (IsKeyboardFocused) { VisualStates.GoToState(this, useTransitions, VisualStates.StateCalendarButtonFocused, VisualStates.StateCalendarButtonUnfocused); } else { VisualStateManager.GoToState(this, VisualStates.StateCalendarButtonUnfocused, useTransitions); } }
/// <summary> /// Change to the correct visual state for the button. /// </summary> /// <param name="useTransitions"> /// true to use transitions when updating the visual state, false to /// snap directly to the new visual state. /// </param> internal void ChangeVisualState(bool useTransitions) { if (_isMouseOverOverride) { if (this.IsPressed) { VisualStates.GoToState(this, useTransitions, VisualStates.StatePressed); } if (this.IsEnabled) { VisualStates.GoToState(this, useTransitions, VisualStates.StateNormal); } else { VisualStates.GoToState(this, useTransitions, VisualStates.StateDisabled); } } // Update the SelectionStates group if (_isSelected) { VisualStates.GoToState(this, useTransitions, VisualStates.StateSelected, VisualStates.StateUnselected); } else { VisualStates.GoToState(this, useTransitions, VisualStates.StateUnselected); } // Update the ActiveStates group if (IsInactive) { VisualStates.GoToState(this, useTransitions, VisualStates.StateInactive); } else { VisualStates.GoToState(this, useTransitions, VisualStates.StateActive, VisualStates.StateInactive); } // Update the DayStates group if (IsToday) { VisualStates.GoToState(this, useTransitions, StateToday, StateRegularDay); } else { VisualStates.GoToState(this, useTransitions, StateRegularDay); } // Update the BlackoutDayStates group if (IsDisabled) { VisualStates.GoToState(this, useTransitions, StateBlackoutDay, StateNormalDay); } else { VisualStates.GoToState(this, useTransitions, StateNormalDay); } // Update the FocusStates group //IsCurrent implies the focused element on Calendar control if (IsCurrent && IsEnabled) { VisualStates.GoToState(this, useTransitions, VisualStates.StateCalendarButtonFocused, VisualStates.StateCalendarButtonUnfocused); } else { VisualStates.GoToState(this, useTransitions, VisualStates.StateCalendarButtonUnfocused); } }
public override void OnStartDrag() { base.OnStartDrag(); tempVisualState = whereIsThisCard.VisualState; whereIsThisCard.VisualState = VisualStates.Dragging; }
private VisualStates visualState = VisualStates.Default;///< Keeps the up-to-date visual layout. /** * @brief Configures the visual layout as requested. * @param state Visual state of type VisualStates and is possible to combine different flags. */ private void SetVisuals(VisualStates state) { // Data update. if ((state & VisualStates.DataUpdate) == VisualStates.DataUpdate) { // Bind dataTable to dataGrid. dataGrid.DataSource = dataTable; // Set column properties, if columns are created. if (dataGrid.Columns.Count == 2) { if (dataGrid.Columns[0].MinimumWidth != 128) { dataGrid.Columns[0].MinimumWidth = 128; } if (dataGrid.Columns[0].FillWeight != 1) { dataGrid.Columns[0].FillWeight = 1; } if (dataGrid.Columns[1].FillWeight != 10000) { dataGrid.Columns[1].FillWeight = 10000; } // Scroll to the bottom of the view. if (dataGrid.Rows.Count > 0) { dataGrid.FirstDisplayedScrollingRowIndex = dataGrid.Rows.Count - 1; } } // Clear DataUpdate state bit. state -= VisualStates.DataUpdate; } // SerialEnabled. if ((state & VisualStates.SerialEnabled) == VisualStates.SerialEnabled) { // Disable controls to prevent change. comboPorts.Enabled = false; textBaud.Enabled = false; buttonNewProject.Enabled = false; buttonNewSingleFileProject.Enabled = false; buttonSave.Enabled = false; // Enable receiption timer. timerSerialCommListener.Enabled = true; // Change button name. buttonPortOpenClose.Text = "&Port Close"; } else { // Enable controls. comboPorts.Enabled = true; textBaud.Enabled = true; buttonNewProject.Enabled = true; buttonNewSingleFileProject.Enabled = true; buttonSave.Enabled = true; // Disable receiption timer. timerSerialCommListener.Enabled = false; // Change button name. buttonPortOpenClose.Text = "&Port Open"; } // ProjectOpen. if ((state & VisualStates.ProjectOpen) == VisualStates.ProjectOpen) { // Show opened projecst name/description. labelProjectName.Text = projectName; } else { // Hide opened projecst name/description. labelProjectName.Text = ""; } // Filter clear button (label) is only visible when filter text is entered. labelClearFilter.Visible = (textFilter.Text != ""); // Save last state. visualState = state; }