Exemple #1
0
        private void Release()
        {
            if (_totalSlide < 0 && Math.Abs(_totalSlide) > Width * _slideRatio && _currentIndex < _items.Count - 1)
            {
                _indicators[_currentIndex].Unselect();
                _currentIndex++;
                _indicators[_currentIndex].Select();

                OnNext?.Invoke(_items[_currentIndex]);
            }
            else
            if (_totalSlide > 0 && _totalSlide > Width * _slideRatio && _currentIndex > 0)
            {
                _indicators[_currentIndex].Unselect();
                _currentIndex--;
                _indicators[_currentIndex].Select();

                OnNext?.Invoke(_items[_currentIndex]);
            }

            _lastPanX = null;

            var itemToSlideTo      = _items[_currentIndex];
            var itemToSlideToRealX = itemToSlideTo.X - _itemsContainer.X;
            var targetX            = -itemToSlideToRealX + _initialX;

            this.Animate("slide", p => _itemsContainer.X = (float)p, _itemsContainer.X, targetX, 4, (byte)_slideMs, Easing.CubicOut);
            _totalSlide = 0;
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            bool isParseable   = int.TryParse(textBoxQNumber.Text, out int value);
            bool isWithinRange = isParseable && value < _availableQuestionsCount && value > 0;

            isValid = isWithinRange;

            if (isValid)
            {
                _settings = new Settings(int.Parse(textBoxQNumber.Text));

                (sender as Button).IsEnabled = false;
                OnNext?.Invoke();
            }
            else
            {
                if (!isParseable)
                {
                    Logger.Error("Not parseable");
                }
                else if (!isWithinRange)
                {
                    Logger.Error("Not within range");
                }

                textBoxQNumber.Background = new SolidColorBrush(Color.FromRgb(255, 172, 172));
            }
        }
Exemple #3
0
        /**
         * onNext()
         * promise下一个处理
         * 同一个promise中 step1 -> step2
         * 下一个promise 跳转到上级 promise
         */
        public void onNext(RpcAsyncContext ctx, RpcPromise from = null)
        {
            if (true)
            {
                if (from != null && from._lastPoint != null)
                {
                    int index = _sucesslist.IndexOf(from._lastPoint);
                    _sucesslist.RemoveRange(0, index + 1);
                }

                if (_sucesslist.Count == 0)
                {
                    onFinally(ctx);
                    return;
                }
                OnNext next = null;
                next = _sucesslist[0];
                _sucesslist.RemoveAt(0);
                _currentNext = next;
                if (next != null)
                {
                    next(ctx);
                }
            }
        }
Exemple #4
0
        public void ToReactivePropertySlimAsSynchronizedEnsureClearEventHandler()
        {
            var source    = new PointModel();
            var rp        = source.ToReactivePropertySlimAsSynchronized(x => x.Point);
            var scheduler = new TestScheduler();
            var observer  = scheduler.CreateObserver <(int x, int y)>();

            rp.Subscribe(observer); // OnNext((0, 0))

            source.Handlers.Count.Is(1);
            observer.Messages.Is(OnNext(0, (0, 0)));

            rp.Dispose();
            source.Handlers.Any().IsFalse();
            source.Point = (10, 10);
            observer.Messages.Is(OnNext(0, (0, 0)), OnCompleted <(int, int)>(0));
        }
Exemple #5
0
 /**
  * then()
  * if both succ and error are null , start chain.
  *
  */
 public RpcPromise then(OnNext succ)
 {
     if (true)
     {
         _sucesslist.Add(succ);
     }
     return(this);
 }
Exemple #6
0
        public void join(RpcPromise promise)
        {
            promise._nextPromise = this; //
            OnNext last = null;

            if (_sucesslist.Count != 0)
            {
                last = _sucesslist[_sucesslist.Count - 1];
            }
            promise._lastPoint = last;
        }
Exemple #7
0
 private async void InvokeNext()
 {
     if (OnNext.HasDelegate)
     {
         await OnNext.InvokeAsync(this);
     }
     else
     {
         InvokePage(ActivePage + 1);
     }
 }
Exemple #8
0
 private void onFinally(RpcAsyncContext ctx)
 {
     _currentNext = _finally;
     if (_finally != null)
     {
         _finally(ctx);
     }
     if (_nextPromise != null)
     {
         _nextPromise.onNext(ctx, this);
     }
 }
        private void FileChanged(object sender, FileSystemEventArgs e)
        {
#if FILTER_GIT_FILES
            if (e.FullPath.StartsWith(_gitdir, StringComparison.CurrentCultureIgnoreCase))
            {
                Debug.WriteLine($"Skipping file: {e.FullPath}");
                return;
            }
#endif

            Debug.WriteLine($"Processing file: {e.FullPath}");
            OnNext?.Invoke(e.FullPath);
        }
Exemple #10
0
        public void next()
        {
            var window     = Windows.UI.Core.CoreWindow.GetForCurrentThread();
            var dispatcher = window.Dispatcher;

            Task.Run(async() =>
            {
                await dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                                          new DispatchedHandler(() =>
                {
                    OnNext?.Invoke(this, new EventArgs());
                }));
            });
        }
Exemple #11
0
        private IEnumerator TypeSentence(ChatNode node)
        {
            OnNext?.Invoke(node);

            NameField.text     = node.ActorName;
            DialogueField.text = "";

            foreach (char letter in node.Text.ToCharArray())
            {
                DialogueField.text += letter;
                yield return(null);
            }

            if (node.HasChoices)
            {
                WaitingForChoices = true;
                // Load choices available
                Debug.Log("Choices available: " + node.Choices.Count);

                // TODO: You'll have to somehow pass things with the nodes here. Perhaps make
                // a small class to pass, or, some sort of event listener?
                // Or however many you need...
                node.Choices.ForEach(choice =>
                {
                    GameObject ButtonObj = Instantiate(ChoiceButtonPrefab, ButtonContainer.transform.position, Quaternion.identity, ButtonContainer.transform);

                    ButtonObj.transform.Find("Text").GetComponent <Text>()
                    .text = choice.Text;

                    ButtonObj.GetComponent <Button>()
                    .onClick.AddListener(() =>
                    {
                        WaitingForChoices = false;
                        Next(choice.To);
                    });
                });
            }
            else if (NextButtonPrefab != null)
            {
                GameObject ButtonObj = Instantiate(NextButtonPrefab, ButtonContainer.transform.position, Quaternion.identity, ButtonContainer.transform);

                ButtonObj.transform.Find("Text").GetComponent <Text>()
                .text = "Next";

                ButtonObj.GetComponent <Button>()
                .onClick.AddListener(() => Next());
            }
        }
        private async Task ListeningAsync(CancellationToken token)
        {
            var listening = true;

            token.Register(() => listening = false);

            while (listening)
            {
                var sqlDataReader = await Task.Run(async() => await sqlCommand.ExecuteReaderAsync(), token);

                foreach (var item in await ReadFromQueueAsync(sqlDataReader))
                {
                    OnNext?.Invoke(this, new ListeningEventArgs <T>(item));
                }
            }
        }
        private void ButtonAccept_Click(object sender, RoutedEventArgs e)
        {
            List <int>    answerIds = new List <int>();
            StringBuilder builder   = new StringBuilder();

            answerStringSet.ToList().ForEach(x => {
                builder.Append($"{x} ");
                answerIds.Add(_question.Data.Answers
                              .Where(a => a.String == x)
                              .Select(a => a.Id)
                              .FirstOrDefault());
            });
            _question.AnswerIds.AddRange(answerIds);

            Logger.Info($"QuestionPage: Accepted: answers: {builder.ToString()} (count: {_question.AnswerIds.Count}).");

            (sender as Button).IsEnabled = false;
            OnNext?.Invoke();
        }
Exemple #14
0
        /**
         *  at here  , new promise be created as Error processing fork.
         *  you can promise.wait util the error-routine return.
         */
        public RpcPromise error(OnNext error)
        {
            RpcPromise promise = new RpcPromise();

            if (true)
            {
                OnNext succ = null;

                if (_sucesslist.Count != 0)
                {
                    succ = _sucesslist[_sucesslist.Count - 1]; // select last OnNext
                }

                KeyValuePair <RpcPromise, OnNext> kv = new KeyValuePair <RpcPromise, OnNext>(promise, succ);
                _errorlist.Add(kv);
                promise._nextPromise = this;
                promise.then(error);
            }
            return(promise);
        }
Exemple #15
0
        public void onError(RpcAsyncContext ctx)
        {
            if (_errorlist.Count == 0)
            {
                onFinally(ctx);
                return;
            }
            // pick out one fork-promise
            KeyValuePair <RpcPromise, OnNext> kv = _errorlist[0];
            OnNext     succ = kv.Value;
            RpcPromise next = kv.Key;

            _errorlist.RemoveAt(0);
            // scan list and remove all nodes which's depth of node is less than promise.
            int index = _sucesslist.IndexOf(succ);

            _sucesslist.RemoveRange(0, index + 1);

            if (next != null)
            {
                ctx.promise = next;
                next.onNext(ctx);
            }
        }
Exemple #16
0
 public bool Equals(OnNext <T> other)
 {
     return(EqualityComparer <T> .Default.Equals(Element, other.Element));
 }
 public void Add(OnNext onNext)
 {
     OnNextEvent += onNext;
 }
 public void Remove(OnNext onNext)
 {
     OnNextEvent -= onNext;
 }
Exemple #19
0
 public RpcPromise final(OnNext next)
 {
     _finally = next;
     return(this);
 }
Exemple #20
0
 public RpcPromise final(OnNext next )
 {
     _finally = next;
     return this;
 }
Exemple #21
0
        /**
         * onNext()
         * promise下一个处理
         * 同一个promise中 step1 -> step2
         * 下一个promise 跳转到上级 promise
         */
        public void onNext(RpcAsyncContext ctx,RpcPromise from = null)
        {
            if (true) {
                if (from != null && from._lastPoint != null)
                {
                    int index = _sucesslist.IndexOf(from._lastPoint);
                    _sucesslist.RemoveRange(0,index+1);
                }

                if (_sucesslist.Count == 0) {
                    onFinally(ctx);
                    return;
                }
                OnNext next = null;
                next = _sucesslist[0];
                _sucesslist.RemoveAt(0);
                _currentNext = next;
                if ( next != null) {
                    next( ctx );
                }
            }
        }
Exemple #22
0
 private void AllClipsFragment_Click(object sender, EventArgs e)
 {
     OnNext?.Invoke();
 }
 public virtual void Next() => OnNext?.Invoke(null);
Exemple #24
0
 /**
  * then()
  * if both succ and error are null , start chain.
  *
  */
 public RpcPromise then(OnNext succ)
 {
     if(true){
        _sucesslist.Add(succ);
     }
     return this;
 }
 private void PressNext()
 {
     OnNext?.Invoke();
 }
Exemple #26
0
 private void onFinally(RpcAsyncContext ctx)
 {
     _currentNext = _finally;
     if (_finally != null) {
         _finally(ctx);
     }
     if (_nextPromise != null) {
         _nextPromise.onNext(ctx,this);
     }
 }
 protected bool Equals(OnNext other)
 {
     return(Element is IEnumerable
         ? ((IEnumerable)Element).Cast <object>().SequenceEqual(((IEnumerable)other.Element).Cast <object>())
         : Equals(Element, other.Element));
 }
Exemple #28
0
        /**
         *  at here  , new promise be created as Error processing fork.
         *  you can promise.wait util the error-routine return.
         */
        public RpcPromise error(OnNext error )
        {
            RpcPromise promise = new RpcPromise();
            if(true) {
                OnNext succ = null;

                if (_sucesslist.Count != 0) {
                    succ = _sucesslist[_sucesslist.Count - 1]; // select last OnNext
                }

                KeyValuePair<RpcPromise,OnNext> kv = new KeyValuePair<RpcPromise, OnNext>(promise,succ);
                _errorlist.Add( kv );
                promise._nextPromise = this;
                promise.then(error);
            }
            return promise;
        }
Exemple #29
0
        public void Next(string nodeId = null, string findIn = null)
        {
            if (WaitingForChoices || !IsActive)
            {
                return;
            }

            if (ExitScheduled)
            {
                OnChatComplete();
                return;
            }

            ClearButtons();

            if (findIn != null)
            {
                var switchTo = conversations.Find(x => x.Id == findIn);
                dialogueIterator = new DialogueIterator(switchTo.Nodes);

                Debug.Log("Switched to conversation: " + findIn);
            }

            DialogueNode node = dialogueIterator.GoToNext(nodeId);

            if (node == null)
            {
                Debug.LogError("Chat quit unexpectedly. Couldn't find a node to display.");
                OnChatComplete();
                return;
            }

            Log(node.Text);
            DialogueField.text = node.Text;

            ExitScheduled = node.IsLast;

            /* Connection parsing */
            if (node.HasConnection)
            {
                dialogueIterator.PushNext(node.To);
            }

            /* Route parsing */
            if (node.HasRoute)
            {
                bool outcome = false;

                /* Note: Route actions make no sense when queued, so don't bother. Also
                 * not a huge fan of doing this to detect an item existing, but for
                 * now it's all we've got. I'll figure a way to get this working
                 * via a delegate instead at some point. */
                switch (node.Route.RouteBool.method)
                {
                case DialogueConsts.CHECK_FOR_ITEM:
                    outcome = GameObject
                              .FindGameObjectWithTag(GlobalConsts.CONTEXT_TAG)
                              .GetComponent <PlayerInventory>()
                              .HasItem(node.Route.RouteBool.value);
                    break;
                }

                string outcomeId = outcome ? node.Route.PositiveId : node.Route.NegativeId;

                dialogueIterator.PushNext(outcomeId);
            }

            /* Action parsing & events */
            if (node.HasActions)
            {
                List <DialogueAction> postActions = node.Actions
                                                    .Where(x => x.waitForFinish)
                                                    .ToList();

                PostActionQueue.AddRange(postActions);

                List <DialogueAction> immediateActions = node.Actions
                                                         .Where(x => !x.waitForFinish)
                                                         .ToList();

                TriggerActions(immediateActions);
            }

            OnNext?.Invoke(node);

            /* Begin output of text */
            StopAllCoroutines();
            StartCoroutine(TypeSentence(node));
        }
Exemple #30
0
 protected override void RefreshCommands()
 {
     OnNext.RaiseCanExecuteChanged();
     OnError.RaiseCanExecuteChanged();
     OnCompleted.RaiseCanExecuteChanged();
 }
Exemple #31
0
 void OnSetNew(Objective obj)
 {
     MDebug.Log("Objective new " + obj.Config.Title + " " + obj.Config.Condition.name);
     obj.SetActive();
     OnNext.AttemptCall(obj);
 }
 protected bool Equals(OnNext other)
 {
     return(Equals(Source, other.Source) && Equals(Element, other.Element));
 }
 private void GitLockDeleted(object sender, FileSystemEventArgs e)
 {
     Debug.WriteLine("Git lock deleted");
     _workingDirectoryWatcher.EnableRaisingEvents = true;
     OnNext?.Invoke(e.FullPath);
 }