Exemple #1
0
        private void UpdateForVisualState(VisualState newState, VisualState oldState = null)
        {
            if (newState == NarrowState && oldState == DefaultState && _lastSelectedItem != null)
            {
                // Resize down to the detail item. Don't play a transition.
                Frame.Navigate(typeof(DetailPage), 0, new SuppressNavigationTransitionInfo());
            }
            else if (newState == DefaultState && oldState == NarrowState)
            {
                _lastSelectedItem = null;
            }

            var isNarrow = newState == NarrowState;

            EntranceNavigationTransitionInfo.SetIsTargetElement(MasterListView, isNarrow);

            Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, UpdateTitleBar);
        }
Exemple #2
0
        private void ProcessTreeNodes(TreeNode node, VisualState visualState)
        {
            if (node.IsExpanded || node.Checked)
            {
                visualState.Nodes.Add(new VisualTreeNode()
                {
                    Id       = ((TestNode)node.Tag).Id,
                    Expanded = node.IsExpanded,
                    Checked  = node.Checked
                });
            }


            foreach (TreeNode childNode in node.Nodes)
            {
                ProcessTreeNodes(childNode, visualState);
            }
        }
 public void InitializeComponent()
 {
     if (this._contentLoaded)
     {
         return;
     }
     this._contentLoaded = true;
     Application.LoadComponent(this, new Uri("/VKClient.Common;component/UsersSearchNearbyPage.xaml", UriKind.Relative));
     this.CommonStates         = (VisualStateGroup)base.FindName("CommonStates");
     this.Normal               = (VisualState)base.FindName("Normal");
     this.Disabled             = (VisualState)base.FindName("Disabled");
     this.ucHeader             = (GenericHeaderUC)base.FindName("ucHeader");
     this.progressRing         = (ProgressRing)base.FindName("progressRing");
     this.textBlockDescription = (TextBlock)base.FindName("textBlockDescription");
     this.textBlockDisabled    = (TextBlock)base.FindName("textBlockDisabled");
     this.buttonOpenSettings   = (Button)base.FindName("buttonOpenSettings");
     this.listUsers            = (ExtendedLongListSelector)base.FindName("listUsers");
 }
Exemple #4
0
 /// <summary>
 /// Transitions a control between states by letting each registered
 /// <see cref="VisualStateSwitcher"/> transition to the new state.
 /// </summary>
 /// <param name="control">The control to transition between states.</param>
 /// <param name="stateGroupsRoot">
 /// The root element that contains the <see cref="ExtendedVisualStateManager"/>.
 /// </param>
 /// <param name="stateName">The name of the state to transition to.</param>
 /// <param name="group"> The <see cref="VisualStateGroup"/> that the state belongs to.</param>
 /// <param name="state">The representation of the state to transition to.</param>
 /// <param name="useTransitions">
 /// true to use a <see cref="VisualTransition"/> object to transition between states;
 /// otherwise, false.
 /// </param>
 /// <returns>
 /// <c>true</c> if the control successfully transitioned to the new state;
 /// otherwise, <c>false</c>.
 /// </returns>
 protected override bool GoToStateCore(
     FrameworkElement control,
     FrameworkElement stateGroupsRoot,
     string stateName,
     VisualStateGroup group,
     VisualState state,
     bool useTransitions)
 {
     if (control == null || stateGroupsRoot == null || stateName == null || group == null || state == null)
     {
         return(false);
     }
     if (!ShouldTransitionToState(control, group, state))
     {
         return(true);
     }
     return(TransitionToState(control, stateGroupsRoot, stateName, group, state, useTransitions));
 }
        public void StateNamesMustBeUniqueWithinGroupListWhenAddingGroup()
        {
            IList <VisualStateGroup> vsgs = CreateTestStateGroups();

            // Create and add a second VisualStateGroup
            var secondGroup = new VisualStateGroup {
                Name = "Foo"
            };

            // Create a VisualState with the same name as one in another group in the list
            var duplicate = new VisualState {
                Name = NormalStateName
            };

            secondGroup.States.Add(duplicate);

            Assert.Throws <InvalidOperationException>(() => vsgs.Add(secondGroup));
        }
        internal static bool TryGetState(IList <VisualStateGroup> groups, string stateName, out VisualStateGroup group, out VisualState state)
        {
            for (int groupIndex = 0; groupIndex < groups.Count; ++groupIndex)
            {
                VisualStateGroup g = groups[groupIndex];
                VisualState      s = g.GetState(stateName);
                if (s != null)
                {
                    group = g;
                    state = s;
                    return(true);
                }
            }

            group = null;
            state = null;
            return(false);
        }
Exemple #7
0
        public void When_SingleActiveState_DefaultValue()
        {
            Window.Current.SetWindowSize(new Size(100, 100));

            var sut = new AdaptiveTrigger();             // should always be active

            var state = new VisualState {
                Name = "activeState"
            };

            state.StateTriggers.Add(sut);

            var group = new VisualStateGroup();

            group.States.Add(state);

            group.CurrentState.Should().Be(state);
        }
Exemple #8
0
        public async Task LoadDataAsync(VisualState currentState)
        {
            _currentState = currentState;
            Customers.Clear();

            var service = new CustomerService();
            var data    = await service.GetDataAsync();

            foreach (var item in data)
            {
                Customers.Add(item);
            }
            await LoadSettingsAsync();

            Singleton <ToastNotificationsService> .Instance.ShowToastNotificationSample($"Loaded {Customers.Count} customers");

            Singleton <LiveTileService> .Instance.SampleUpdate($"{Customers.Count} customers in the database");
        }
Exemple #9
0
        public void UpdateForVisualState(VisualState newState, VisualState oldState = null)
        {
            var isNarrow = newState.Name == "NarrowState";

            if (isNarrow && oldState != null && oldState.Name == "DefaultState" && SelectedThread != null)
            {
                NarrowStateCommand.Execute(null);
                // Resize down to the detail item. Don't play a transition.
                //Frame.Navigate(typeof(ConversationView), _lastSelectedItem.number, new SuppressNavigationTransitionInfo());
            }


            /*EntranceNavigationTransitionInfo.SetIsTargetElement(masterFrame, isNarrow);
             * if (detailFrame != null)
             * {
             *  EntranceNavigationTransitionInfo.SetIsTargetElement(detailFrame, !isNarrow);
             * }*/
        }
		/// <summary>
		/// Does the state transition.
		/// </summary>
		/// <param name="state">State.</param>
		/// <param name="instant">If set to <c>true</c> instant.</param>
		protected virtual void DoStateTransition(VisualState state, bool instant)
		{
			// Check if the script is enabled
			if (!this.enabled || !this.gameObject.activeInHierarchy)
				return;
			
			Color color = this.m_NormalColor;
			Sprite newSprite = null;
			string triggername = this.m_NormalTrigger;
			
			// Prepare the transition values
			switch (state)
			{
				case VisualState.Normal:
					color = this.m_NormalColor;
					newSprite = null;
					triggername = this.m_NormalTrigger;
					break;
				case VisualState.Highlighted:
					color = this.m_HighlightedColor;
					newSprite = this.m_HighlightedSprite;
					triggername = this.m_HighlightedTrigger;
					break;
				case VisualState.Selected:
					color = this.m_SelectedColor;
					newSprite = this.m_SelectedSprite;
					triggername = this.m_SelectedTrigger;
					break;
			}
			
			// Do the transition
			switch (this.m_Transition)
			{
				case Transition.ColorTint:
					this.StartColorTween(color * this.m_ColorMultiplier, instant);
					break;
				case Transition.SpriteSwap:
					this.DoSpriteSwap(newSprite);
					break;
				case Transition.Animation:
					this.TriggerAnimation(triggername);
					break;
			}
		}
Exemple #11
0
        protected override void InvokeCore()
        {
            if (VisualState.IsNullOrEmpty())
            {
                return;
            }

#if SILVERLIGHT
            var target = ActualTarget as Control;
#else
            var target = ActualTarget as FrameworkElement;
#endif
            if (target == null)
            {
                return;
            }

            System.Windows.VisualStateManager.GoToState(target, VisualState, UseTransitions);
        }
Exemple #12
0
        public void MultipleOperations_OperateCorrectly()
        {
            var state1 = new FakeOperationState("Fake State 1");
            var state2 = new FakeOperationState("Fake State 2");

            this.notificationsCallback(TestOperationStateTransition.Started, state1);
            this.state.Update();
            this.notificationsCallback(TestOperationStateTransition.Started, state2);
            this.state.Update();
            this.notificationsCallback(TestOperationStateTransition.Finished, state1);
            this.state.Update();

            var visualState = new VisualState(this.scrollView);

            CollectionAssert.AreEqual(
                new[] { state2.StringRepresentation },
                visualState.CurrentOperations);
            Assert.AreEqual(state1.StringRepresentation, visualState.PreviousOperation);
        }
        private void UpdateForVisualState(VisualState newState, VisualState oldState = null)
        {
            if (DetailFrame.CurrentSourcePageType != null)
            {
                ((Setter)NarrowState.Setters[1]).Value = "0";
                ((Setter)NarrowState.Setters[2]).Value = "0";
                ((Setter)NarrowState.Setters[3]).Value = "*";
            }
            else
            {
                ((Setter)NarrowState.Setters[1]).Value = "720";
                ((Setter)NarrowState.Setters[2]).Value = "*";
                ((Setter)NarrowState.Setters[3]).Value = "0";
            }
            var isNarrow = newState == NarrowState;

            if (isNarrow && oldState == DefaultState)
            {
                //NarrowState.Setters.Remove()
                //NarrowState.Setters[0]
                //Frame.Navigate(DetailFrame.SourcePageType, null, new SuppressNavigationTransitionInfo());
                //GridSplitter.Visibility = Visibility.Collapsed;
                //if (DetailFrame.CurrentSourcePageType != null)
                //{
                //    MasterColumn.MinWidth = 0;
                //    MasterColumn.Width = new GridLength(0);
                //    DetailColumn.Width = new GridLength(1, GridUnitType.Star);
                //    //DetailColumn.Width = new GridLength(1, GridUnitType.Star);
                //    //MasterColumn.Width = new GridLength(0, GridUnitType.Star);
                //    //MasterColumn.MinWidth = 0;
                //}
                //else
                //{
                //    DetailColumn.Width = new GridLength(0);
                //    MasterColumn.MaxWidth = 720;
                //    MasterColumn.Width = new GridLength(1, GridUnitType.Star);
                //    //Frame.Navigate(MasterFrame.SourcePageType, null, new SuppressNavigationTransitionInfo());

                //    //DetailColumn.Width = new GridLength(0, GridUnitType.Star);
                //    //MasterColumn.Width = new GridLength(1, GridUnitType.Star);
                //}
            }
        }
Exemple #14
0
        private void MoveCell(int i, int j, int x, int y)
        {
            visualState = VisualState.Transitioning;
            var toMove = Gems[i, j];

            toMove.i = x;
            toMove.j = y;

            Gems[i, j] = null;
            Gems[x, y] = toMove;

            Storyboard sb   = new Storyboard();
            Animation  anim = new TranslationAnimation(sb, toMove.sprite, GameSettings.GemTranslationDuration, GetGemVisualPosition(x, y), false);

            sb.AddAnimation(anim);
            sb.argument = Gems[x, y];
            sb.Start();
            sb.OnCompleted += OnMoveCellCompleted;
        }
Exemple #15
0
        private static void transitionToState(object sender, DependencyPropertyChangedEventArgs args)
        {
            var c = sender as FrameworkElement;

            if (c == null)
            {
                throw new ArgumentException("CurrentState is only supported on the FrameworkElement type");
            }

            _lastState = args.NewValue.ToString();

            _visualState = TryGetVisualState(_lastState, c);
            if (_visualState != null && _visualState.Storyboard != null)
            {
                _visualState.Storyboard.Completed += storyboardCompleted;
            }

            GoToElementState(c, _lastState, false);
        }
Exemple #16
0
        private async void SmallInteractable(VisualState previous)
        {
            leftPanelCache.Visibility          = Visibility.Visible;
            leftSecondaryPanelCache.Visibility = Visibility.Visible;
            rightPanelCache.Visibility         = Visibility.Visible;

            _tracker.MaxPosition = new Vector3(width - 72, 0, 0);
            _tracker.MinPosition = new Vector3(-width, 0, 0);
            content.Margin       = new Thickness(0, 0, 0, 0);
            rightSide.Margin     = new Thickness(0, 0, -72, 0);
            contentVis.StartAnimation("Translation.X", _contentAnimation);
            if (contentVis2 != null)
            {
                contentVis2.StartAnimation("Translation.X", _contentAnimation);
            }

            leftcache1.StartAnimation("Opacity", _leftPanelFadeAnimation);
            Translate(leftpanel1, 0);
            leftpanel1.StartAnimation("Translation.X", leftPanelTranslateAnimation);
            leftcache2.StartAnimation("Opacity", _leftPanelFadeAnimation2);
            Translate(leftpanel2, 0);
            leftpanel2.StartAnimation("Translation.X", _leftPanelTranslateAnimation2);

            if (previous == Mid)
            {
                Translate(contentVis, 0, 72);
                if (contentVis2 != null)
                {
                    Translate(contentVis2, 0, 72);
                }

                await Task.Delay(300);

                contentVis.StartAnimation("Translation.X", _contentAnimation);
                if (contentVis2 != null)
                {
                    contentVis2.StartAnimation("Translation.X", _contentAnimation);
                }
            }

            SetSnapPoints(-width, 0, width - 72);
        }
        /// <summary>
        /// Does the state transition.
        /// </summary>
        /// <param name="state">State.</param>
        /// <param name="instant">If set to <c>true</c> instant.</param>
        protected virtual void DoStateTransition(VisualState state, bool instant)
        {
            // Check if active in the scene
            if (!this.gameObject.activeInHierarchy)
            {
                return;
            }

            // Check if it's interactable
            if (!this.IsInteractable())
            {
                state = VisualState.Normal;
            }

            Color color = this.m_NormalColor;

            // Prepare the transition values
            switch (state)
            {
            case VisualState.Normal:
                color = this.m_NormalColor;
                break;

            case VisualState.Highlighted:
                color = this.m_HighlightedColor;
                break;

            case VisualState.Selected:
                color = this.m_SelectedColor;
                break;

            case VisualState.Pressed:
                color = this.m_PressedColor;
                break;

            case VisualState.Active:
                color = this.m_ActiveColor;
                break;
            }

            this.StartEffectColorTween(color, false);
        }
Exemple #18
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            KeyboardLayoutVisualStateGroup = GetTemplateChild(VisualStateGroupKeyboardLayoutName) as VisualStateGroup;
            QuertyVisualState  = GetTemplateChild(VisualStateQuertyName) as VisualState;
            NumericVisualState = GetTemplateChild(VisualStateNumericName) as VisualState;

            foreach (var partName in TemplatePartNames.Keys)
            {
                var element = GetTemplateChild(partName) as Button;
                if (element != null)
                {
                    element.Command          = KeyStrokeCommand;
                    element.CommandParameter = TemplatePartNames[partName];

                    //element.TouchUp += new EventHandler<TouchEventArgs>(Button_TouchUp);
                    var touchUpEventListener = new WeakEventListener <QuertyKeyboard, object, TouchEventArgs>(this);
                    touchUpEventListener.OnEventAction = (instance, source, eventArgs) =>
                                                         instance.Button_TouchUp(source, eventArgs);
                    touchUpEventListener.OnDetachAction = (weakEventListenerParameter) =>
                                                          element.TouchUp -= weakEventListenerParameter.OnEvent;
                    element.TouchUp += touchUpEventListener.OnEvent;

                    //element.Click += new RoutedEventHandler(Button_Click);
                    var clickEventListener = new WeakEventListener <QuertyKeyboard, object, RoutedEventArgs>(this);
                    clickEventListener.OnEventAction = (instance, source, eventArgs) =>
                                                       instance.Button_Click(source, eventArgs);
                    clickEventListener.OnDetachAction = (weakEventListenerParameter) =>
                                                        element.Click -= weakEventListenerParameter.OnEvent;
                    element.Click += clickEventListener.OnEvent;
                }
#if DEBUG
                else
                {
                    System.Diagnostics.Debug.WriteLine(string.Format("Part not found: {0}", partName));
                }
#endif
                OnShowCapitalize();
                //OnShiftPressed();
            }
        }
        public void ValidatePerformance(int groups, int states)
        {
            IList <VisualStateGroup> vsgs = new VisualStateGroupList();

            var groupList = new List <VisualStateGroup>();

            for (int n = 0; n < groups; n++)
            {
                groupList.Add(new VisualStateGroup {
                    Name = n.ToString()
                });
            }

            var watch = new Stopwatch();

            watch.Start();

            foreach (var group in groupList)
            {
                vsgs.Add(group);
            }

            watch.Stop();

            double iterations = states;
            var    random     = new Random();

            for (int n = 0; n < iterations; n++)
            {
                var state = new VisualState {
                    Name = n.ToString()
                };
                var group = groupList[random.Next(0, groups - 1)];
                watch.Start();
                group.States.Add(state);
                watch.Stop();
            }

            var average = watch.ElapsedMilliseconds / iterations;

            Debug.WriteLine($">>>>> VisualStateManagerTests ValidatePerformance: {watch.ElapsedMilliseconds}ms over {iterations} iterations; average of {average}ms");
        }
Exemple #20
0
        public void OnOvertakeCompleted(object sender, object argument)
        {
            visualState = VisualState.Idle;

            if (argument != null)
            {
                List <Gem> toFades = (List <Gem>)argument;
                if (toFades.Count > 0)
                {
                    if (toFades[0].team == Gem.Team.Blue)
                    {
                        ScoreRed  += toFades.Count;
                        ScoreBlue -= toFades.Count;
                    }
                    else
                    {
                        ScoreRed  -= toFades.Count;
                        ScoreBlue += toFades.Count;
                    }
                }
                foreach (var toFade in toFades)
                {
                    gems.RemoveChild(toFade);
                }
            }
            if (sender is Storyboard)
            {
                ((Storyboard)sender).OnCompleted -= OnOvertakeCompleted;
            }

            if (State == MapState.BlueTurn)
            {
                State = MapState.RedTurn;
            }
            else
            {
                State = MapState.BlueTurn;
            }

            CheckWinState();
            CheckWaitingStatus();
        }
Exemple #21
0
        private static Storyboard GetStoryboardForVisualState(
            FrameworkElement visualStatesHost,
            string stateGroupName,
            string stateName)
        {
            Storyboard storyboard = null;

            var stateGroups             = VisualStateManager.GetVisualStateGroups(visualStatesHost);
            VisualStateGroup stateGroup = null;

            if (!string.IsNullOrEmpty(stateGroupName))
            {
                stateGroup = stateGroups.FirstOrDefault(g => g.Name == stateGroupName);
            }

            VisualState state = null;

            if (stateGroup != null)
            {
                state = stateGroup.States.FirstOrDefault(s => s.Name == stateName);
            }

            if (state == null)
            {
                foreach (var group in stateGroups)
                {
                    state = group.States.FirstOrDefault(s => s.Name == stateName);

                    if (state != null)
                    {
                        break;
                    }
                }
            }

            if (state != null)
            {
                storyboard = state.Storyboard;
            }

            return(storyboard);
        }
        private void FloatingPanel_Loaded(object sender, RoutedEventArgs e)
        {
            _expandedState  = FloatingPanelStateGroup.States[ExpandedPanelStateIndex];
            _collapsedState = FloatingPanelStateGroup.States[CollapsedPanelStateIndex];

            ExpandedHeightKeyFrame.Value  = ExpandedHeight;
            CollapsedHeightKeyFrame.Value = CollapsedHeight;

            ExpandedHeightStoryboard.Completed += (s1, args1) =>
            {
                PanelGrid.Height = ExpandedHeight;
            };

            CollapsedHeightStoryboard.Completed += (s2, args2) =>
            {
                PanelGrid.Height = CollapsedHeight;
            };

            VisualStateManager.GoToState(this, _currentState?.Name ?? _expandedState.Name, false);
        }
        public override void Perform()
        {
            var root = GetTemplateRoot(Target);

            if (root != null)
            {
                var groups = System.Windows.VisualStateManager.GetVisualStateGroups(root) as Collection <VisualStateGroup>;
                if (groups != null && groups.Count > 0)
                {
                    var group = groups[GroupIndex % groups.Count];
                    if (group.States.Count > 0)
                    {
                        VisualState state = group.States[StateIndex % group.States.Count] as VisualState;
                        VisualStateManager.GoToState(Target, state.Name, false);

                        DispatcherHelper.DoEvents(DispatcherPriority.ApplicationIdle);
                    }
                }
            }
        }
Exemple #24
0
        public void When_SingleNoConstraints()
        {
            Window.Current.SetWindowSize(new Size(100, 100));

            var sut = new AdaptiveTrigger {
                MinWindowWidth = 0, MinWindowHeight = 0
            };

            var state = new VisualState {
                Name = "activeState"
            };

            state.StateTriggers.Add(sut);

            var group = new VisualStateGroup();

            group.States.Add(state);

            group.CurrentState.Should().Be(state);
        }
Exemple #25
0
    // Start is called before the first frame update
    private void Start()
    {
        _screenWidth  = Screen.width;
        _screenHeight = Screen.height;
        _rigidBody    = GetComponent <Rigidbody>();
        State         = PlayerState.RAIN;

        if (GetComponent <VisualState>())
        {
            _visualState = GetComponent <VisualState>();
            _visualState.SetMaxHeight(_cloudHeight);
            _visualState.SetCloudTime(CloudTime);
            _visualState.StartVisualStates(State);
        }

        if (Cinemachine != null)
        {
            _transposer = Cinemachine.GetCinemachineComponent <CinemachineTransposer>();
        }
    }
Exemple #26
0
        public void When_SingleActiveState_ExactValue()
        {
            Window.Current.SetWindowSize(new Size(100d, 100d));

            var sut = new AdaptiveTrigger {
                MinWindowHeight = 100d, MinWindowWidth = 100d
            };

            var state = new VisualState {
                Name = "activeState"
            };

            state.StateTriggers.Add(sut);

            var group = new VisualStateGroup();

            group.States.Add(state);

            group.CurrentState.Should().Be(state);
        }
Exemple #27
0
        static VisualStateGroupList CreateTestStateGroups()
        {
            var stateGroups      = new VisualStateGroupList();
            var visualStateGroup = new VisualStateGroup {
                Name = CommonStatesName
            };
            var normalState = new VisualState {
                Name = NormalStateName
            };
            var invalidState = new VisualState {
                Name = InvalidStateName
            };

            visualStateGroup.States.Add(normalState);
            visualStateGroup.States.Add(invalidState);

            stateGroups.Add(visualStateGroup);

            return(stateGroups);
        }
        protected virtual void Awake()
        {
            // Save instance reference
            mInstance = this;

            // Get the rect transform
            this.m_Rect = this.gameObject.GetComponent <RectTransform>();

            // Get the canvas group
            this.m_CanvasGroup = this.gameObject.GetComponent <CanvasGroup>();

            // Make sure the tooltip does not block raycasts
            this.m_CanvasGroup.blocksRaycasts = false;
            this.m_CanvasGroup.interactable   = false;

            // Get the content size fitter
            this.m_SizeFitter = this.gameObject.GetComponent <ContentSizeFitter>();

            // Prepare the content size fitter
            this.m_SizeFitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize;

            // Prepare the vertical layout group
            VerticalLayoutGroup vlg = this.gameObject.GetComponent <VerticalLayoutGroup>();

            vlg.childControlHeight = true;
            vlg.childControlWidth  = true;

            // Make sure we have the always on top component
            UIAlwaysOnTop aot = this.gameObject.GetComponent <UIAlwaysOnTop>();

            if (aot == null)
            {
                aot       = this.gameObject.AddComponent <UIAlwaysOnTop>();
                aot.order = UIAlwaysOnTop.TooltipOrder;
            }

            // Hide
            this.SetAlpha(0f);
            this.m_VisualState = VisualState.Hidden;
            this.InternalOnHide();
        }
        private bool IsTransitionBetterMatch(VisualTransition current, VisualTransition transitionToTest)
        {
            return(GetMatchPriorityNumber(current) < GetMatchPriorityNumber(transitionToTest));

            sbyte GetMatchPriorityNumber(VisualTransition transition)
            {
                const sbyte PerfectMatch           = 3,
                            ToMatch                = 2,
                            FromMatch              = 1,
                            DefaultTransitionMatch = 0,
                            NoMatch                = -1;

                if (transition == null)
                {
                    return(NoMatch);
                }
                VisualState transitionFromState = Group.GetStateByName(transition.From);
                VisualState transitionToState   = Group.GetStateByName(transition.To);

                if (FromState == transitionFromState && ToState == transitionToState)
                {
                    return(PerfectMatch);
                }
                else if (ToState == transitionToState && transitionFromState == null)
                {
                    return(ToMatch);
                }
                else if (FromState == transitionFromState && transitionToState == null)
                {
                    return(FromMatch);
                }
                else if (transition.IsDefault())
                {
                    return(DefaultTransitionMatch);
                }
                else
                {
                    return(NoMatch);
                }
            }
        }
		public void SaveAndRestoreVisualState()
		{
			VisualState state = new VisualState();
			state.ShowCheckBoxes = true;
			state.TopNode = "ABC.Test.dll";
			state.SelectedNode = "NUnit.Tests.MyFixture.MyTest";
			state.SelectedCategories = "A,B,C";
			state.ExcludeCategories = true;

			StringWriter writer = new StringWriter();
			state.Save( writer );

			string output = writer.GetStringBuilder().ToString();

			StringReader reader = new StringReader( output );
			VisualState newState = VisualState.LoadFrom( reader );

			Assert.AreEqual( state.ShowCheckBoxes, newState.ShowCheckBoxes, "ShowCheckBoxes" );
			Assert.AreEqual( state.TopNode, newState.TopNode, "TopNode" );
			Assert.AreEqual( state.SelectedNode, newState.SelectedNode, "SelectedNode" );
			Assert.AreEqual( state.SelectedCategories, newState.SelectedCategories, "SelectedCategories" );
			Assert.AreEqual( state.ExcludeCategories, newState.ExcludeCategories, "ExcludeCategories" );
		}
Exemple #31
0
        public void OnOvertakeCompleted(object sender, object argument)
        {
            visualState = VisualState.Idle;

            if (argument != null)
            {
                List<Gem> toFades = (List<Gem>)argument;
                if (toFades.Count > 0)
                {
                    if (toFades[0].team == Gem.Team.Blue)
                    {
                        ScoreRed += toFades.Count;
                        ScoreBlue -= toFades.Count;
                    }
                    else
                    {
                        ScoreRed -= toFades.Count;
                        ScoreBlue += toFades.Count;
                    }
                }
                foreach (var toFade in toFades)
                {
                    gems.RemoveChild(toFade);
                }
            }
            if (sender is Storyboard)
            {
                ((Storyboard)sender).OnCompleted -= OnOvertakeCompleted;
            }

            if (State == MapState.BlueTurn) State = MapState.RedTurn;
            else State = MapState.BlueTurn;

            CheckWinState();
            CheckWaitingStatus();
        }
Exemple #32
0
        private void MoveCell(int i, int j, int x, int y)
        {
            visualState = VisualState.Transitioning;
            var toMove = Gems[i,j];
            toMove.i = x;
            toMove.j = y;

            Gems[i, j] = null;
            Gems[x, y] = toMove;

            Storyboard sb = new Storyboard();
            Animation anim = new TranslationAnimation(sb, toMove.sprite, GameSettings.GemTranslationDuration, GetGemVisualPosition(x, y), false);
            sb.AddAnimation(anim);
            sb.argument = Gems[x, y];
            sb.Start();
            sb.OnCompleted += OnMoveCellCompleted;
        }
Exemple #33
0
        private void DuplicateCell(int i, int j, int x, int y)
        {
            visualState = VisualState.Transitioning;
            Gems[x, y] = new Gem(Gems[i, j]);

            Gems[x, y].i = x;
            Gems[x, y].j = y;

            this.gems.AddChild(Gems[x, y]);
            if (Gems[x, y].team == Gem.Team.Blue)
            {
                ScoreBlue++;
            }
            else { ScoreRed++; }

            Storyboard sb = new Storyboard();
            Animation anim = new TranslationAnimation(sb, Gems[x, y].sprite, GameSettings.GemTranslationDuration, GetGemVisualPosition(x, y), false);
            sb.AddAnimation(anim);
            sb.argument = Gems[x, y];
            sb.Start();
            sb.OnCompleted += OnMoveCellCompleted;
        }
 internal void RaiseCurrentStateChanged(FrameworkElement element, VisualState oldState, VisualState newState, Control control)
 {
     if (CurrentStateChanged != null)
     {
         CurrentStateChanged(element, new VisualStateChangedEventArgs(oldState, newState, control));
     }
 }
Exemple #35
0
 public void StartSingle()
 {
     ResetMap();
     visualState = VisualState.Idle;
 }
Exemple #36
0
        public override void Update(GameTime gameTime)
        {
            if (Global.thisGame.gameMode == Game1.GameMode.Multiplayer)
            {
                if (Global.thisGame.connectionState != Game1.ConnectionState.Connected)
                    visualState = VisualState.Disabled;
                else visualState = VisualState.Idle;
            }

            if (visualState == VisualState.Disabled) return;
            foreach (Gem gem in gems.Children)
            {
                bool isAssign = false;
                if ((gem.team == Gem.Team.Blue && State == MapState.BlueTurn) || (gem.team == Gem.Team.Red && State == MapState.RedTurn))
                {
                    if (visualState == VisualState.Idle)
                    {
                        isAssign = true;
                    }
                }

                if (isAssign)
                {
                    SelectedStyleZoomInOut.Assign(gem.sprite);
                }
                else
                {
                    SelectedStyleZoomInOut.Unassign(gem.sprite);
                }
            }
            base.Update(gameTime);
        }
        /// <summary>
        /// Evaluates and transitions to the given state.
        /// </summary>
        /// <param name="state">If set to <c>true</c> transition to shown <c>false</c> otherwise.</param>
        /// <param name="instant">If set to <c>true</c> instant.</param>
        private void EvaluateAndTransitionToState(bool state, bool instant)
        {
            // Do the transition
            switch (this.m_Transition)
            {
                case Transition.Fade:
                    this.StartAlphaTween((state ? 1f : 0f), (instant ? 0f : this.m_TransitionDuration));
                    break;
                case Transition.None:
                default:
                    this.SetAlpha(state ? 1f : 0f);
                    this.m_VisualState = (state ? VisualState.Shown : VisualState.Hidden);
                    break;
            }

            // If we are transitioning to hidden state and the transition is none
            // Call the internal on hide to do a cleanup
            if (this.m_Transition == Transition.None && !state)
                this.InternalOnHide();
        }
        /// <summary>
        /// Raises the tween finished event.
        /// </summary>
        protected virtual void OnTweenFinished()
        {
            // Check if the tooltip is not visible meaning it was Fade Out
            if (this.alpha == 0f)
            {
                // Flag as hidden
                this.m_VisualState = VisualState.Hidden;

                // Call the internal on hide
                this.InternalOnHide();
            }
            else
            {
                // Flag as shown
                this.m_VisualState = VisualState.Shown;
            }
        }
		/// <summary>
		/// Does the state transition.
		/// </summary>
		/// <param name="state">State.</param>
		/// <param name="instant">If set to <c>true</c> instant.</param>
		protected virtual void DoStateTransition(VisualState state, bool instant)
		{
			// Check if the script is enabled
			if (!this.enabled || !this.gameObject.activeInHierarchy)
				return;
			
			Color color = this.m_NormalColor;
			Sprite newSprite = null;
			string triggername = this.m_NormalTrigger;
			
			// Prepare the transition values
			switch (state)
			{
				case VisualState.Normal:
					color = this.m_NormalColor;
					newSprite = null;
					triggername = this.m_NormalTrigger;
					break;
				case VisualState.Highlighted:
					color = this.m_HighlightedColor;
					newSprite = this.m_HighlightedSprite;
					triggername = this.m_HighlightedTrigger;
					break;
				case VisualState.Selected:
					color = this.m_SelectedColor;
					newSprite = this.m_SelectedSprite;
					triggername = this.m_SelectedTrigger;
					break;
			}
			
			// Do the transition
			switch (this.m_Transition)
			{
				case Transition.ColorTint:
					this.StartColorTween(color * this.m_ColorMultiplier, instant);
					break;
				case Transition.SpriteSwap:
					this.DoSpriteSwap(newSprite);
					break;
				case Transition.Animation:
					this.TriggerAnimation(triggername);
					break;
			}
		}
Exemple #40
0
        public void OvertakeEnemies(Gem gem)
        {
            visualState = VisualState.Transitioning;
            List<Tile> adjacents = GetAdjacentCell(gem);
            if (adjacents.Count == 0)
            {
                OnOvertakeCompleted(this, null);
                return;
            }

            Storyboard sb = new Storyboard();
            List<Gem> toFades = new List<Gem>();
            foreach (Tile adjacent in adjacents)
            {
                Gem toOvertake = new Gem(gem);
                toOvertake.i = adjacent.i;
                toOvertake.j = adjacent.j;

                gems.AddChild(toOvertake);

                Gem toFade = Gems[adjacent.i, adjacent.j];
                toFades.Add(toFade);

                Gems[toOvertake.i, toOvertake.j] = toOvertake;

                Animation anim = new TranslationAnimation(sb, toOvertake.sprite, GameSettings.GemTranslationDuration, GetGemVisualPosition(toOvertake.i, toOvertake.j), false);
                sb.AddAnimation(anim);

                anim = new ColorAnimation(sb, toFade.sprite, GameSettings.GemTranslationDuration, new Vector4(0,0,0,0), false);
                sb.AddAnimation(anim);
            }

            sb.argument = toFades;
            sb.Start();
            sb.OnCompleted += OnOvertakeCompleted;
        }