Exemplo n.º 1
0
        /*
         * Method for controller to put new chips
         * -----------------------------------------
         * x - x coordinate of new chip
         * y - y coordinate of new chip
         */
        public void PutChip(int x, int y)
        {
            Chip newChip = new Chip(turnHolder.CurrentTurnColor, new Cell(x, y));

            if (!NewChipIsAllowed(newChip))
            {
                return;
            }

            board.AddChip(newChip);

            List<Chip> changedChips = board.GetChangedChips(newChip, turnHolder.CurrentTurnColor);
            countHolder.Increase(turnHolder.CurrentTurnColor, changedChips.Count + 1);
            countHolder.Decrease(turnHolder.OppositeTurnColor, changedChips.Count);

            SetChips?.Invoke(this, new SetChipsEventArgs { NewChip = newChip, ChangedChips = changedChips });

            turnHolder.Switch();

            CountChanged?.Invoke(this, new CountChangedEventArgs
            {
                CountWhite = countHolder.GetPlayerCount(Color.White),
                CountBlack = countHolder.GetPlayerCount(Color.Black),
            });

            FinishTurnAndMoveOn();
        }
Exemplo n.º 2
0
 private void OnCountChanged(long id, decimal oldValue, decimal newValue)
 {
     CountChanged?.Invoke(this, new DecimalValueChangedEventArgs(id,
                                                                 oldValue,
                                                                 newValue,
                                                                 MenuItemName.Basket));
 }
Exemplo n.º 3
0
 /// <summary>
 /// Called when items count changed.
 /// </summary>
 /// <param name="count">The count.</param>
 protected virtual void OnCountChanged(int count)
 {
     CountChanged?.Invoke(this, count);
     if (Current >= count)
     {
         ToAbsolutePosition(count - 1);
     }
 }
Exemplo n.º 4
0
 private void InboxOnCountChanged(object sender, EventArgs e)
 {
     _config.Tracer?.TraceVerbose($"<CountChanged>", $"{this}");
     if (sender is IMailFolder folder)
     {
         CountChanged?.Invoke(this, new FolderEventArgs(folder));
     }
 }
Exemplo n.º 5
0
        private void OnCountChanged(object sender, DecimalValueChangedEventArgs e)
        {
            DecimalValueChangedEventArgs args =
                new DecimalValueChangedEventArgs(e.Id, e.OldValue, e.NewValue, MenuItemName.Orders);

            CountChanged?.Invoke(this, args);
            OrderChanged?.Invoke(sender, e);
        }
Exemplo n.º 6
0
 private void OnCountChanged()
 {
     if (_oldCount == Count)
     {
         return;
     }
     _oldCount = Count;
     CountChanged?.Invoke(this);
 }
        protected void BindBaseCreateElements(Button cancelButton, Button createButton, TextField nameField, IntegerField countField, Toggle maxCountToggle)
        {
            cancelButton.clickable.clicked += OnCancelClicked;
            createButton.clickable.clicked += OnCreateClicked;

            if (GetDefaultName != null)
            {
                m_CurrentName = GetDefaultName();
            }

            m_NameField           = nameField;
            m_NameField.isDelayed = true;
            m_NameField.SetValueWithoutNotify(m_CurrentName);
            m_NameIsCustom = false;
            m_NameField.RegisterValueChangedCallback(evt =>
            {
                if (evt.newValue.Length > 0)
                {
                    m_CurrentName  = evt.newValue;
                    m_NameIsCustom = true;
                }
                else if (GetDefaultName != null)
                {
                    m_CurrentName = GetDefaultName();
                    m_NameField?.SetValueWithoutNotify(m_CurrentName);
                    m_NameIsCustom = false;
                }

                if (NameChanged != null)
                {
                    NameChanged(m_CurrentName);
                }
            });

            maxCountToggle.RegisterValueChangedCallback(evt =>
            {
                m_CountField.value = evt.newValue ? 1 : 0;
                m_CountField.SetEnabled(evt.newValue);
            });

            m_CountField = countField;
            m_CountField.RegisterValueChangedCallback(evt =>
            {
                var newValue = evt.newValue;
                if (newValue < 0)
                {
                    newValue = 0;
                    m_CountField.SetValueWithoutNotify(newValue);
                }

                var maxEnabled = newValue > 0;
                maxCountToggle.SetValueWithoutNotify(maxEnabled);
                m_CountField.SetEnabled(maxEnabled);

                CountChanged?.Invoke(newValue);
            });
        }
 public void Redo()
 {
     if (_redoCommandStack.Count > 0)
     {
         ICommand command = _redoCommandStack.Pop();
         command.Execute();
         _undoCommandStack.Push(command);
         CountChanged?.Invoke();
     }
 }
Exemplo n.º 9
0
        public void Save()
        {
            BinaryFormatter bf = new BinaryFormatter();

            using (FileStream fs = new FileStream(fileName, FileMode.Create, FileAccess.Write))
            {
                bf.Serialize(fs, advertisements);
            }
            CountChanged?.Invoke(this, new EventArgs());
        }
Exemplo n.º 10
0
 // тестовый набор записей. В вашей программе записи должны читаться из файла
 public void GetTestData()
 {
     for (int i = 0; i < 105; i++)
     {
         humans.Add(new Human {
             FName = $"Test name {i}", LName = $"Test lastname {i}"
         });
     }
     CountChanged?.Invoke(this, new EventArgs());
 }
Exemplo n.º 11
0
 private void Increment(object source, ElapsedEventArgs e)
 {
     Debug.WriteLine("Interval: " + Timer.Interval);
     Debug.WriteLine("Count: " + Count);
     Count++;
     if (Count == 8)
     {
         CountChanged?.Invoke(this, null);
         RemoveListener();
         Count = 1;
     }
 }
Exemplo n.º 12
0
    public void IncrementClicked()
    {
        _killCount++;
        UpdateCount();

        Instantiate(_clickParticlesPrefab);

        _audioSource.pitch = _baseAudioPitch + UnityEngine.Random.Range(-_audioPitchVariance, _audioPitchVariance);
        _audioSource.PlayOneShot(_shotgunClip);

        LeaderboardRepo.Instance.UpdateScore(_killCount);
        CountChanged?.Invoke(_killCount);
    }
        public void OpenProvider(LinesProvider linesProvider)
        {
            _linesProvider = linesProvider;
            // Handles when the number of columns we need to display the data changes
            _linesProvider.MaxColumnsChanged += (s, e) => ColumnCount = e.MaxColumns;
            ColumnCount = 0;
            var fileLines = new VirtualizingCollectionDynamicAsync <BigFileLine>(_linesProvider, 100 /*page size*/, 60000 /*timeout*/, 1000 /* loadCountInterval*/);

            FileLines = fileLines;
            fileLines.CountChanged += (s, e) =>
            {
                CountChanged?.Invoke(this, e);
                RaisePropertyChanged("RowCount");
            };
        }
    void Update()
    {
        if (_commandBuffer.Count > 0)
        {
            ICommand command = _commandBuffer.Dequeue();
            command.Execute();

            if (command.IsUndoable())
            {
                _undoCommandStack.Push(command);
                _redoCommandStack.Clear();
            }
            else
            {
                ResetHistory();
            }
            CountChanged?.Invoke();
        }
    }
Exemplo n.º 15
0
        void setupRx(IEnumerable <T> initialContents = null, double resetChangeThreshold = 0.3, IScheduler scheduler = null)
        {
            scheduler = scheduler ?? RxApp.MainThreadScheduler;

            _inner = _inner ?? new List <T>();

            _changing = new Subject <NotifyCollectionChangedEventArgs>();
            _changing.Where(_ => this.areChangeNotificationsEnabled()).Subscribe(raiseCollectionChanging);

            _changed = new Subject <NotifyCollectionChangedEventArgs>();
            _changed.Where(_ => this.areChangeNotificationsEnabled()).Subscribe(raiseCollectionChanged);

            ResetChangeThreshold = resetChangeThreshold;

            _beforeItemsAdded   = new Lazy <Subject <T> >(() => new Subject <T>());
            _itemsAdded         = new Lazy <Subject <T> >(() => new Subject <T>());
            _beforeItemsRemoved = new Lazy <Subject <T> >(() => new Subject <T>());
            _itemsRemoved       = new Lazy <Subject <T> >(() => new Subject <T>());
            _itemChanging       = new Lazy <ISubject <IReactivePropertyChangedEventArgs <T> > >(() => new ScheduledSubject <IReactivePropertyChangedEventArgs <T> >(scheduler));
            _itemChanged        = new Lazy <ISubject <IReactivePropertyChangedEventArgs <T> > >(() => new ScheduledSubject <IReactivePropertyChangedEventArgs <T> >(scheduler));
            _beforeItemsMoved   = new Lazy <Subject <IMoveInfo <T> > >(() => new Subject <IMoveInfo <T> >());
            _itemsMoved         = new Lazy <Subject <IMoveInfo <T> > >(() => new Subject <IMoveInfo <T> >());

            // NB: We have to do this instead of initializing _inner so that
            // Collection<T>'s accounting is correct
            foreach (var item in initialContents ?? Enumerable.Empty <T>())
            {
                Add(item);
            }

            // NB: ObservableCollection has a Secret Handshake with WPF where
            // they fire an INPC notification with the token "Item[]". Emulate
            // it here
            CountChanging.Where(_ => this.areChangeNotificationsEnabled()).Subscribe(_ => this.RaisePropertyChanging("Count"));

            CountChanged.Where(_ => this.areChangeNotificationsEnabled()).Subscribe(_ => this.RaisePropertyChanged("Count"));

            IsEmptyChanged.Where(_ => this.areChangeNotificationsEnabled()).Subscribe(_ => this.RaisePropertyChanged("IsEmpty"));

            Changing.Where(_ => this.areChangeNotificationsEnabled()).Subscribe(_ => this.RaisePropertyChanging("Item[]"));

            Changed.Where(_ => this.areChangeNotificationsEnabled()).Subscribe(_ => this.RaisePropertyChanged("Item[]"));
        }
Exemplo n.º 16
0
        void setupRx(IEnumerable <T> initialContents = null, double resetChangeThreshold = 0.3)
        {
            _inner = _inner ?? new List <T>();

            _changing = new Subject <NotifyCollectionChangedEventArgs>();
            _changing.Where(_ => _suppressionRefCount == 0).Subscribe(raiseCollectionChanging);

            _changed = new Subject <NotifyCollectionChangedEventArgs>();
            _changed.Where(_ => _suppressionRefCount == 0).Subscribe(raiseCollectionChanged);

            ResetChangeThreshold = resetChangeThreshold;

            _beforeItemsAdded   = new Lazy <Subject <T> >(() => new Subject <T>());
            _itemsAdded         = new Lazy <Subject <T> >(() => new Subject <T>());
            _beforeItemsRemoved = new Lazy <Subject <T> >(() => new Subject <T>());
            _itemsRemoved       = new Lazy <Subject <T> >(() => new Subject <T>());
            _itemChanging       = new Lazy <Subject <IObservedChange <T, object> > >(() => new Subject <IObservedChange <T, object> >());
            _itemChanged        = new Lazy <Subject <IObservedChange <T, object> > >(() => new Subject <IObservedChange <T, object> >());
            _beforeItemsMoved   = new Lazy <Subject <IMoveInfo <T> > >(() => new Subject <IMoveInfo <T> >());
            _itemsMoved         = new Lazy <Subject <IMoveInfo <T> > >(() => new Subject <IMoveInfo <T> >());

            // NB: We have to do this instead of initializing _inner so that
            // Collection<T>'s accounting is correct
            foreach (var item in initialContents ?? Enumerable.Empty <T>())
            {
                Add(item);
            }

            // NB: ObservableCollection has a Secret Handshake with WPF where
            // they fire an INPC notification with the token "Item[]". Emulate
            // it here
            CountChanging.Where(_ => _suppressionRefCount == 0).Select(x => new PropertyChangingEventArgs("Count")).Subscribe(this.raisePropertyChanging);

            CountChanged.Where(_ => _suppressionRefCount == 0).Select(x => new PropertyChangedEventArgs("Count")).Subscribe(this.raisePropertyChanged);

            IsEmptyChanged.Where(_ => _suppressionRefCount == 0).Select(x => new PropertyChangedEventArgs("IsEmpty")).Subscribe(this.raisePropertyChanged);

            Changing.Where(_ => _suppressionRefCount == 0).Select(x => new PropertyChangingEventArgs("Item[]")).Subscribe(this.raisePropertyChanging);

            Changed.Where(_ => _suppressionRefCount == 0).Select(x => new PropertyChangedEventArgs("Item[]")).Subscribe(this.raisePropertyChanged);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Add object to global list
        /// </summary>
        /// <param name="proxy">com wrapper instance</param>
        internal void AddObjectToList(ICOMObject proxy)
        {
            try
            {
                lock (_thisLock)
                {
                    Add(proxy);

                    if (null != Added)
                    {
                        IEnumerable <ICOMObject> ownerPath = GetOwnerPath(proxy);
                        Added?.Invoke(Parent, ownerPath, proxy);
                    }
                }
                CountChanged?.Invoke(Parent, Count);
            }
            catch (Exception throwedException)
            {
                Parent.Console.WriteException(throwedException);
            }
        }
Exemplo n.º 18
0
        /*
         * Method for controller to start new game 
         */
        public void NewGame()
        {
            playerHasPassed[Color.White] = false;
            playerHasPassed[Color.Black] = false;

            turnHolder.Reset();
            
            NewGameStarted?.Invoke(this, new EventArgs());

            SetStartBoardPosition();

            countHolder.Reset();

            CountChanged?.Invoke(this, new CountChangedEventArgs
            {
                CountWhite = countHolder.GetPlayerCount(Color.White),
                CountBlack = countHolder.GetPlayerCount(Color.Black),
            });

            FinishTurnAndMoveOn();
        }
Exemplo n.º 19
0
 /// <summary>
 /// Remove object from global list
 /// </summary>
 /// <param name="proxy">com wrapper instance</param>
 /// <param name="ownerPath">optional owner path</param>
 internal void RemoveObjectFromList(ICOMObject proxy, IEnumerable <ICOMObject> ownerPath)
 {
     try
     {
         bool removed = false;
         lock (_thisLock)
         {
             removed = Remove(proxy);
             if (removed)
             {
                 Removed?.Invoke(Parent, ownerPath, proxy);
             }
         }
         if (removed)
         {
             CountChanged?.Invoke(Parent, Count);
         }
     }
     catch (Exception throwedException)
     {
         Parent.Console.WriteException(throwedException);
     }
 }
 private void OnCountChanged(PropertyChangedEventArgs arg)
 {
     OnPropertyChanged(arg);
     CountChanged?.Invoke(this, arg);
 }
Exemplo n.º 21
0
        public new void Add(T item)
        {
            base.Add(item);

            CountChanged?.Invoke(this, new Ext_list <T> .ListEventArgs(this.Count));
        }
Exemplo n.º 22
0
        public new void Clear()
        {
            base.Clear();

            CountChanged?.Invoke(this, new Ext_list <T> .ListEventArgs(this.Count));
        }
Exemplo n.º 23
0
        public new void AddRange(IEnumerable <T> collection)
        {
            base.AddRange(collection);

            CountChanged?.Invoke(this, new Ext_list <T> .ListEventArgs(this.Count));
        }
Exemplo n.º 24
0
 protected virtual void OnCountChanged(int count)
 {
     CountChanged?.Invoke(count);
 }
Exemplo n.º 25
0
        public Models.Tag ProcessTag(Models.Tag tag)
        {
            switch (tag.Server)
            {
            case "CoDeSys.OPC.DA":
                if (_FestoTags.Count < 37 && !_FestoTags.Any(x => x.Name == tag.Name))
                {
                    if (!string.IsNullOrEmpty(tag.Name))
                    {
                        _FestoTags.Add(tag);
                    }
                    return(null);
                }
                else if (!_initialized)
                {
                    _FestoTags.Where(x => x.Name.StartsWith("PLC1.Application.GVL.HMI_bShowAuto_")).ToList().ForEach(x =>
                    {
                        if (bool.Parse(x.Value))
                        {
                            int.TryParse(x.Name.Replace("PLC1.Application.GVL.HMI_bShowAuto_", ""), out var auto);
                            UpdateSteps(auto == 1 ? 8 : auto == 2 ? 16 : 32);
                        }
                    });

                    _initialized = true;
                }
                var t = _FestoTags.FirstOrDefault(x => x.Handle == tag.Handle);
                if (t != null)
                {
                    t.Value = tag.Value;
                }
                break;

            case "GaugeToolsXL OPC Server":
                double.TryParse(tag.Value, out _gaugeLastVal);
                CountChanged?.Invoke(_gaugeLastVal);
                return(null);

            default:
                break;
            }

            switch (tag.Name)
            {
            case "PLC1.Application.GVL.Record1.lrTarget":
                var ipos    = _FestoTags.FirstOrDefault(x => x.Value == tag.Value);
                var miniPos = _FestoTags.Where(x => x.Name.StartsWith("PLC1.Application.GVL_1.HMI_iPos") && x.Value != "0").Min(x => int.Parse(x.Value)).ToString();
                var maxiPos = _FestoTags.Where(x => x.Name.StartsWith("PLC1.Application.GVL_1.HMI_iPos") && x.Value != "0").Max(x => int.Parse(x.Value)).ToString();
                if (ipos.Value == maxiPos)
                {
                    LapCompleted?.Invoke(true);
                }
                if (ipos.Value == miniPos)
                {
                    LapCompleted?.Invoke(false);
                }
                TagValidated?.Invoke(new Models.Tag
                {
                    Handle = int.Parse(tag.Value),
                    Name   = ipos.Name,
                    Value  = _gaugeLastVal.ToString()
                });
                break;

            case "PLC1.Application.GVL.HMI_bShowAuto_1":
            case "PLC1.Application.GVL.HMI_bShowAuto_2":
            case "PLC1.Application.GVL.HMI_bShowAuto_3":
                if (bool.Parse(tag.Value))
                {
                    int.TryParse(tag.Name.Replace("PLC1.Application.GVL.HMI_bShowAuto_", ""), out var auto);
                    UpdateSteps(auto == 1 ? 8 : auto == 2 ? 16 : 32);
                }
                break;

            case "PLC1.Application.GVL_1.HMI_rDelay":
                DelayUpdated?.Invoke(tag);
                break;

            default:
                break;
            }

            if (!_FestoTags.Any(x => x.Name == "PLC1.Application.PLC_PRG.bHOME_OK" && bool.Parse(x.Value)))
            {
                return(null);
            }

            return(null);
        }
Exemplo n.º 26
0
 public virtual void OnCountChange()
 {
     CountChanged?.Invoke();
 }
Exemplo n.º 27
0
 private void OnCountChanged(object sender, DecimalValueChangedEventArgs e)
 {
     CountChanged?.Invoke(this, e);
 }
Exemplo n.º 28
0
 protected virtual void OnCountChanged(int previousCount)
 {
     CountChanged?.Invoke(previousCount, Count);
 }
Exemplo n.º 29
0
 public void SetCurrentData(List <Advertisement> advertisements)
 {
     filter = advertisements;
     CountChanged?.Invoke(this, null);
 }
Exemplo n.º 30
0
 private void OnCountChanged(decimal oldValue, decimal newValue)
 {
     CountChanged?.Invoke(this, new DecimalValueChangedEventArgs(Id, oldValue, newValue, MenuItemName.PriceList));
 }