Exemplo n.º 1
0
        /// <summary>
        /// Update the value
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public async Task <ExecutionResult <T> > UpdateAsync(T value)
        {
            var connectMessage = Connect();

            if (connectMessage != "OK")
            {
                throw new ConnectionException(connectMessage);
            }

            BeforeUpdate?.Invoke(value);

            var stop = new Stopwatch();

            stop.Start();

            if (_diagnosticSource.IsEnabled($"{typeof(T).Name}_Update"))
            {
                _diagnosticSource.Write($"{typeof(T).Name}_Update", value);
            }

            _logger.LogTrace("Try to update item");
            T result = await TryUpdate(value);

            stop.Stop();
            _logger.LogTrace($"End Update in {stop.Elapsed}");

            AfterUpdate?.Invoke(value);

            return(new ExecutionResult <T>(result != null, result));
        }
Exemplo n.º 2
0
        protected async Task Update()
        {
            IsBusy = true;
            ResetCancellationToken();
            var token = updateTokenSource.Token;

            try
            {
                BeforeUpdate?.Invoke(this, EventArgs.Empty);
                await OnUpdate(token);

                AfterUpdate?.Invoke(this, EventArgs.Empty);
            }
            catch (OperationCanceledException)
            {
                // log that the operation was cancelled here. this will have to be handled in each
                // viewmodel differently but the main log should go here
                await OnUpdateCancelled();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                throw;
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Performs update step for all entities and components
        /// </summary>
        /// <param name="gameTime"></param>
        public void Update(GameTime gameTime)
        {
            ProcessEntitiesForAdding();
            ProcessComponentForAdding();

            BeforeUpdate?.Invoke();

            foreach (Entity entity in _entities)
            {
                if (!entity.Processable)
                {
                    continue;
                }

                // ReSharper disable once ForCanBeConvertedToForeach
                for (var i = 0; i < entity.Components.Count; i++)
                {
                    var entityComponent = entity.Components[i];

                    if (entityComponent.Processable)
                    {
                        entityComponent.Update(gameTime);
                    }
                }
            }

            AfterUpdate?.Invoke();

            ProcessEntitiesForRemoving();
            ProcessComponentsForRemoving();
        }
Exemplo n.º 4
0
        public void Update(IWidget widget)
        {
            UserInterfaceRenderer?.UpdateAnimation(this, widget);

            BeforeUpdate?.Invoke(widget);

            widget.Update(this);
        }
Exemplo n.º 5
0
 protected virtual async Task <bool> OnBeforeUpdate(GridUpdateComponent <T> component)
 {
     if (BeforeUpdate != null)
     {
         return(await BeforeUpdate.Invoke(component, _item));
     }
     return(true);
 }
Exemplo n.º 6
0
        public async Task UpdateAsync(T entity)
        {
            var entityEntry = _context.Entry(entity);

            BeforeUpdate?.Invoke(ref entityEntry);
            UpdateWithoutChangeCreatedDate(in entityEntry);
            await _context.SaveChangesAsync();
        }
Exemplo n.º 7
0
        public virtual void Update(TModel model)
        {
            var eArgs = new RepositoryEventArgs <TModel>();

            eArgs.Model = model;

            BeforeUpdate?.Invoke(eArgs);

            dbSet.Attach(model);
            context.Entry(model).State = EntityState.Modified;
        }
Exemplo n.º 8
0
        public void OnLoop(FrameTime frameTime)
        {
            CurrentTimestamp = frameTime.TotalSeconds;

            BeforeAll?.Invoke(frameTime);

            BeforeUpdate?.Invoke(frameTime);
            Update?.Invoke(frameTime);
            AfterUpdate?.Invoke(frameTime);

            BeforeRender?.Invoke(frameTime);
            Render?.Invoke(frameTime);
            AfterRender?.Invoke(frameTime);

            AfterAll?.Invoke(frameTime);
        }
Exemplo n.º 9
0
        internal void update(bool parentUpdated)
        {
            if (HasControlsToSolve) //Control solve
            {
                if (BeforeUpdate != null)
                {
                    BeforeUpdate.Invoke(this);
                }

                //Seed needupdate, will be true if there are external controls or the parent was updated
                bool needUpdate = externalControls.Count > 0 || parentUpdated;

                foreach (var control in controls)
                {
                    //See if any controls moved
                    needUpdate           |= control.MovedThisTick;
                    control.MovedThisTick = false;
                    control.syncPosition();
                }

                //Something requires us to update
                if (needUpdate)
                {
                    ikSolver.Solve(solveControls);
                    parentUpdated   = true;
                    updatedThisTick = true;
                }
            }
            else if (AutosolveOnParentUpdate && parentUpdated) //Solve bones if parent updated and no controls
            {
                if (BeforeUpdate != null)
                {
                    BeforeUpdate.Invoke(this);
                }

                ikSolver.Solve(solveBones);

                updatedThisTick = true;
            }

            foreach (var child in childSolvers)
            {
                child.update(parentUpdated);
            }
        }
Exemplo n.º 10
0
 internal bool OnBeforeUpdate(object sender, IDbEntity dbEntity)
 {
     return(BeforeUpdate?.Invoke(sender, dbEntity) ?? true);
 }
 protected override void OnBeforeUpdate(T entity)
 {
     BeforeUpdate?.Invoke(entity);
     _validator?.ValidateAndThrowOnUpdate(entity);
 }
 protected virtual void OnBeforeUpdate(T entity)
 {
     BeforeUpdate?.Invoke(entity);
 }
Exemplo n.º 13
0
        /// <summary>
        /// Create the DropDown list.
        /// </summary>
        /// <param name="size">List size (refers to the whole size of the list + the header when dropdown list is opened).</param>
        /// <param name="anchor">Position anchor.</param>
        /// <param name="offset">Offset from anchor position.</param>
        /// <param name="skin">Panel skin to use for this DropDown list and header.</param>
        public DropDown(Vector2 size, Anchor anchor = Anchor.Auto, Vector2?offset = null, PanelSkin skin = PanelSkin.ListBackground) :
            base(size, anchor, offset)
        {
            // default padding of self is 0
            Padding = Vector2.Zero;

            // to get collision right when list is opened
            UseActualSizeForCollision = true;

            // create the panel and paragraph used to show currently selected value (what's shown when drop-down is closed)
            _selectedTextPanel     = new Panel(new Vector2(0, SelectedPanelHeight), skin, Anchor.TopLeft);
            _selectedTextParagraph = UserInterface.DefaultParagraph(string.Empty, Anchor.CenterLeft);
            _selectedTextParagraph.UseActualSizeForCollision = false;
            _selectedTextParagraph.UpdateStyle(SelectList.DefaultParagraphStyle);
            _selectedTextParagraph.UpdateStyle(DefaultParagraphStyle);
            _selectedTextParagraph.UpdateStyle(DefaultSelectedParagraphStyle);
            _selectedTextPanel.AddChild(_selectedTextParagraph, true);

            // create the arrow down icon
            _arrowDownImage = new Image(Resources.ArrowDown, new Vector2(ArrowSize, ArrowSize), ImageDrawMode.Stretch, Anchor.CenterRight, new Vector2(-10, 0));
            _selectedTextPanel.AddChild(_arrowDownImage, true);

            // create the list component
            _selectList = new SelectList(size, Anchor.TopCenter, Vector2.Zero, skin);

            // update list offset and space before
            _selectList.SetOffset(new Vector2(0, SelectedPanelHeight));
            _selectList.SpaceBefore = Vector2.Zero;

            // add the header and select list as children
            AddChild(_selectedTextPanel);
            AddChild(_selectList);

            // add callback on list value change
            _selectList.OnValueChange = (Entity entity) =>
            {
                // hide list
                ListVisible = false;

                // set selected text
                _selectedTextParagraph.Text = (SelectedValue ?? DefaultText);
            };

            // hide the list by default
            _selectList.Visible = false;

            // setup the callback to show / hide the list when clicking the dropbox
            _selectedTextPanel.OnClick = (Entity self) =>
            {
                // change visibility
                ListVisible = !ListVisible;
            };

            // set starting text
            _selectedTextParagraph.Text = (SelectedValue ?? DefaultText);

            // update styles
            _selectList.UpdateStyle(DefaultStyle);

            // make the list events trigger the dropdown events
            _selectList.OnListChange       += (Entity entity) => { OnListChange?.Invoke(this); };
            _selectList.OnMouseDown        += (Entity entity) => { OnMouseDown?.Invoke(this); };
            _selectList.OnMouseReleased    += (Entity entity) => { OnMouseReleased?.Invoke(this); };
            _selectList.WhileMouseDown     += (Entity entity) => { WhileMouseDown?.Invoke(this); };
            _selectList.WhileMouseHover    += (Entity entity) => { WhileMouseHover?.Invoke(this); };
            _selectList.OnClick            += (Entity entity) => { OnClick?.Invoke(this); };
            _selectList.OnValueChange      += (Entity entity) => { OnValueChange?.Invoke(this); };
            _selectList.OnMouseEnter       += (Entity entity) => { OnMouseEnter?.Invoke(this); };
            _selectList.OnMouseLeave       += (Entity entity) => { OnMouseLeave?.Invoke(this); };
            _selectList.OnMouseWheelScroll += (Entity entity) => { OnMouseWheelScroll?.Invoke(this); };
            _selectList.OnStartDrag        += (Entity entity) => { OnStartDrag?.Invoke(this); };
            _selectList.OnStopDrag         += (Entity entity) => { OnStopDrag?.Invoke(this); };
            _selectList.WhileDragging      += (Entity entity) => { WhileDragging?.Invoke(this); };
            _selectList.BeforeDraw         += (Entity entity) => { BeforeDraw?.Invoke(this); };
            _selectList.AfterDraw          += (Entity entity) => { AfterDraw?.Invoke(this); };
            _selectList.BeforeUpdate       += (Entity entity) => { BeforeUpdate?.Invoke(this); };
            _selectList.AfterUpdate        += (Entity entity) => { AfterUpdate?.Invoke(this); };

            // make the selected value panel trigger the dropdown events
            _selectedTextPanel.OnMouseDown        += (Entity entity) => { OnMouseDown?.Invoke(this); };
            _selectedTextPanel.OnMouseReleased    += (Entity entity) => { OnMouseReleased?.Invoke(this); };
            _selectedTextPanel.WhileMouseDown     += (Entity entity) => { WhileMouseDown?.Invoke(this); };
            _selectedTextPanel.WhileMouseHover    += (Entity entity) => { WhileMouseHover?.Invoke(this); };
            _selectedTextPanel.OnClick            += (Entity entity) => { OnClick?.Invoke(this); };
            _selectedTextPanel.OnValueChange      += (Entity entity) => { OnValueChange?.Invoke(this); };
            _selectedTextPanel.OnMouseEnter       += (Entity entity) => { OnMouseEnter?.Invoke(this); };
            _selectedTextPanel.OnMouseLeave       += (Entity entity) => { OnMouseLeave?.Invoke(this); };
            _selectedTextPanel.OnMouseWheelScroll += (Entity entity) => { OnMouseWheelScroll?.Invoke(this); };
            _selectedTextPanel.OnStartDrag        += (Entity entity) => { OnStartDrag?.Invoke(this); };
            _selectedTextPanel.OnStopDrag         += (Entity entity) => { OnStopDrag?.Invoke(this); };
            _selectedTextPanel.WhileDragging      += (Entity entity) => { WhileDragging?.Invoke(this); };
            _selectedTextPanel.BeforeDraw         += (Entity entity) => { BeforeDraw?.Invoke(this); };
            _selectedTextPanel.AfterDraw          += (Entity entity) => { AfterDraw?.Invoke(this); };
            _selectedTextPanel.BeforeUpdate       += (Entity entity) => { BeforeUpdate?.Invoke(this); };
            _selectedTextPanel.AfterUpdate        += (Entity entity) => { AfterUpdate?.Invoke(this); };
        }
Exemplo n.º 14
0
 internal void _DoUpdate()
 {
     BeforeUpdate?.Invoke();
     UnityUpdate();
     AfterUpdate?.Invoke();
 }