Example #1
0
        void HandleTeamTagging(LMTeamVM team, string taggedPlayer)
        {
            // limitation to the number of temporal contexts that can be created
            int position = taggedPlayer.Length;

            if (position == 3)
            {
                HandleTaggedPlayer(team, taggedPlayer);
            }

            KeyTemporalContext tempContext = new KeyTemporalContext {
            };

            for (int i = 0; i < 10; i++)
            {
                string     newTaggedPlayer = taggedPlayer + i;
                VKeyAction action          = new VKeyAction(new KeyConfig {
                    Name = taggedPlayer,
                    Key  = App.Current.Keyboard.ParseName(i.ToString())
                }, () => HandleTeamTagging(team, newTaggedPlayer));
                tempContext.AddAction(action);
            }
            tempContext.Duration          = Constants.TEMP_TAGGING_DURATION;
            tempContext.ExpiredTimeAction = () => HandleTaggedPlayer(team, taggedPlayer);

            App.Current.KeyContextManager.AddContext(tempContext);
        }
Example #2
0
        void HandleSubCategoriesTagging(AnalysisEventButtonVM buttonVM, TagVM subcategoryTagged = null)
        {
            if (subcategoryTagged != null)
            {
                buttonVM.SelectedTags.Add(subcategoryTagged);
            }

            KeyTemporalContext tempContext = new KeyTemporalContext {
            };

            foreach (var subcategory in buttonVM.Tags)
            {
                KeyAction action = new KeyAction(new KeyConfig {
                    Name = subcategory.Value,
                    Key  = subcategory.HotKey.Model
                }, () => HandleSubCategoriesTagging(buttonVM, subcategory));
                tempContext.AddAction(action);
            }

            var analysisEventButton = (buttonVM.Model as AnalysisEventButton);

            if (analysisEventButton != null && analysisEventButton.TagMode == TagMode.Free)
            {
                tempContext.ExpiredTimeAction = buttonVM.ToggleIsCategoryClicked;
            }
            else
            {
                tempContext.Duration          = Constants.TEMP_TAGGING_DURATION;
                tempContext.ExpiredTimeAction = buttonVM.Click;
            }

            App.Current.KeyContextManager.AddContext(tempContext);
        }
Example #3
0
        public void NewKeyContexts_TempContextAdded_RemoveAfterTimeExpires()
        {
            // Arrange
            AutoResetEvent     resetEvent = new AutoResetEvent(false);
            KeyTemporalContext tmpContext = new KeyTemporalContext();

            tmpContext.AddAction(play);
            tmpContext.Duration          = 100;
            tmpContext.ExpiredTimeAction = () => resetEvent.Set();

            KeyContext context = new KeyContext();

            context.AddAction(forward);

            mockToolkit.Setup(x => x.Invoke(It.IsAny <EventHandler> ())).Callback(() => Task.Factory.StartNew(() => tmpContext.ExpiredTimeAction()));

            // Act
            App.Current.KeyContextManager.NewKeyContexts(new List <KeyContext> {
                tmpContext, context
            });
            Assert.AreEqual(2, App.Current.KeyContextManager.CurrentKeyContexts.Count);

            // Assert
            resetEvent.WaitOne();
            Assert.AreEqual(1, App.Current.KeyContextManager.CurrentKeyContexts.Count);

            resetEvent.Dispose();
        }