Example #1
0
        public void SetEditor(IEditorControl editor)
        {
            try
            {
                _editor           = editor;
                tsbSearch.Visible = editor.SupportSearch;
                tscbKeyValue.Items.Clear();
                object[] skeys = editor.SearchKeys;
                if (skeys != null)
                {
                    tscbKeyValue.Items.AddRange(skeys);
                }

                dOpen.Filter = editor.OpenFileFilter;
                dSave.Filter = editor.SaveFileFilter;
                UpdateFileTitle();
                UpdateSearchBarVisibility();
                editor.DirtyChanged = _ => { UpdateFileTitle(); };
                if (_editor is Control c)
                {
                    c.Enabled = true;
                }

                EditorChanged?.Invoke(editor);
            }
            catch (Exception e)
            {
                MessageBox.Show("Error encountered when setting up editor '{0}'.\n\nException: {1}\nMessage: {2}".F(_editor.GetType().Name, e.GetType(), e.Message), "Dune 2000 Editor", MessageBoxButtons.OK);
                _editor = null;
            }
        }
        public async Task <TResult> UpdateAsyncAsync <TData, TResult>(string rowKey, string partitionKey,
                                                                      UpdateDelegate <TData, Task <TResult> > onUpdate,
                                                                      Func <Task <TResult> > onNotFound = default(Func <Task <TResult> >),
                                                                      RetryDelegateAsync <Task <TResult> > onTimeoutAsync = default(RetryDelegateAsync <Task <TResult> >))
            where TData : class, ITableEntity
        {
            return(await await FindByIdAsync(rowKey, partitionKey,
                                             async (TData currentStorage) =>
            {
                var resultGlobal = default(TResult);
                var useResultGlobal = false;
                var resultLocal = await onUpdate.Invoke(currentStorage,
                                                        async(documentToSave) =>
                {
                    useResultGlobal = await await UpdateIfNotModifiedAsync(documentToSave,
                                                                           () => false.ToTask(),
                                                                           async() =>
                    {
                        if (onTimeoutAsync.IsDefaultOrNull())
                        {
                            onTimeoutAsync = GetRetryDelegateContentionAsync <Task <TResult> >();
                        }

                        resultGlobal = await await onTimeoutAsync(
                            async() => await UpdateAsyncAsync(rowKey, partitionKey, onUpdate, onNotFound, onTimeoutAsync),
                            (numberOfRetries) => { throw new Exception("Failed to gain atomic access to document after " + numberOfRetries + " attempts"); });
                        return true;
                    },
                                                                           onTimeout: GetRetryDelegate());
                });
                return useResultGlobal ? resultGlobal : resultLocal;
            },
                                             onNotFound,
Example #3
0
 public void Update()
 {
     if (updateDelegate != null && updateDelegate.GetInvocationList().Length > 0)
     {
         updateDelegate.Invoke();
     }
 }
Example #4
0
        public virtual void Update(GameTime theTime)
        {
            if (FormAddindList.Count > 0)
            {
                foreach (SivForm sv in FormAddindList)
                {
                    this.Form_list.Add(sv);
                }
                FormAddindList.Clear();
                Form_list = Form_list.OrderBy(sv => sv.Priority).ToList();
            }
            if (FormDeletingList.Count > 0)
            {
                foreach (SivForm sv in FormDeletingList)
                {
                    this.Form_list.Remove(sv);
                }
                FormDeletingList.Clear();
            }

            foreach (SivForm sv in Form_list)
            {
                if (sv.Visible)
                {
                    sv.Update(theTime);
                }
            }
            if (FormsUpdate != null)
            {
                FormsUpdate.Invoke(theTime);
            }
        }
Example #5
0
            private bool Tick()
            {
                long currentTicks = _stopwatch.Elapsed.Ticks;

                _accumulatedTime += TimeSpan.FromTicks(currentTicks - _previousTicks);
                _previousTicks    = currentTicks;

                if (_accumulatedTime < _targetRate)
                {
                    int sleepTime = (int)(_targetRate - _accumulatedTime).TotalMilliseconds;
                    Thread.Sleep(sleepTime);
                    return(!_exitNextFrame);
                }

                if (_accumulatedTime > _maxElapsed)
                {
                    _accumulatedTime = _maxElapsed;
                }

                _time.ElapsedGameTime = _accumulatedTime;
                _time.TotalGameTime  += _accumulatedTime;
                _accumulatedTime      = TimeSpan.Zero;

                _delegate?.Invoke(_time);
                return(!_exitNextFrame);
            }
Example #6
0
 public void Invoke(float delta)
 {
     if (!IsRemove)
     {
         Handler.Invoke(delta);
     }
 }
Example #7
0
        public void StartRendering()
        {
            _isActive = true;

            Task.Run(() =>
            {
                while (_isActive)
                {
                    FpsHelper.BeginOfFrame();

                    Rendering();
                    _updateAction?.Invoke(this);

                    if (!Settings.StaticLight)
                    {
                        _lightPos = Vector3.Transform(Vector3.Zero,
                                                      Matrix4x4.CreateTranslation(_scene.LightPos) * ViewModel);
                        _lightPosArray = new[] { _lightPos.X, _lightPos.Y, _lightPos.Z };
                    }
                    else
                    {
                        _lightPos = Vector3.Transform(Vector3.Zero,
                                                      Matrix4x4.CreateTranslation(_scene.LightPos) *
                                                      Matrix4x4.CreateTranslation(ViewModel.Translation));
                        _lightPosArray = new[] { _lightPos.X, _lightPos.Y, _lightPos.Z };
                    }

                    FpsHelper.EndOfFrame();
                }
            });
        }
Example #8
0
 private void Update()
 {
     if (screenDims.x != Screen.width || screenDims.y != Screen.height)
     {
         Setup();
     }
     onUpdate?.Invoke();
 }
Example #9
0
        internal async Task Invoke(Update update, UserContext <TUser> userContext, IUserRepository <TUser> repository)
        {
            if (update.GetUser() is not {
            } user)
            {
                await _next.Invoke(update);

                return;
            }

            if (userContext.User == null)
            {
                var dbUser = await repository.GetUser(user.Id) ?? await repository.CreateUser(user);

                userContext.User = dbUser;
            }

            await _next.Invoke(update);
        }
 static void Update(SceneView sceneView)
 {
     if (updateMethod != null)
     {
         updateMethod.Invoke(sceneView);
     }
     if (updateMethodSecondary != null)
     {
         updateMethodSecondary.Invoke(sceneView);
     }
 }
Example #11
0
        private void PaletteView_Click(object sender, System.EventArgs e)
        {
            if (Palette == null)
            {
                return;
            }

            int2 cell  = PointToClient(Cursor.Position).ToInt2() * Dimensions / Size.ToInt2();
            int  index = cell.x + cell.y * Dimensions.x;

            CellClicked?.Invoke(new PixelInfo <Color>(cell, Palette.Get(index)));
        }
Example #12
0
        public Task Invoke(Update update)
        {
            var info = update.GetInfoFromUpdate();

            _logger.Information("{UpdateType} {MessageType} | {From}: {Contents}",
                                info.UpdateType,
                                info.MessageType,
                                info.From,
                                info.Contents);

            return(_next.Invoke(update));
        }
Example #13
0
 private void Select(object sender, EventArgs e)
 {
     if (sender is ToolStripButton tsb)
     {
         IEditorControl editor = _editors[tsb];
         if (tsb != null && tsb != _current)
         {
             UpdateEditor(editor);
             EditorChanged?.Invoke(editor);
         }
     }
 }
Example #14
0
        private void ResourcePreview_Click(object sender, System.EventArgs e)
        {
            Image image = Preview;
            float zoom  = _zoom;

            if (image != null || zoom < 0)
            {
                float w = image.Width * zoom;
                float h = image.Height * zoom;
                if (FitToScreen)                 // full zoom
                {
                    float scaleX = Width / image.Width;
                    float scaleY = Height / image.Height;
                    float scale  = scaleX.Min(scaleY);

                    w    = image.Width * scale;
                    h    = image.Height * scale;
                    zoom = scale;
                }

                int imgwidth  = (int)w;
                int imgheight = (int)h;
                int offsetX   = (Width - imgwidth - (int)(_offset.x * zoom)) / 2;
                int offsetY   = (Height - imgheight - (int)(_offset.y * zoom)) / 2;

                float2 mloc  = (PointToClient(Cursor.Position).ToFloat2() - new float2(offsetX, offsetY)) / zoom;
                int2   imloc = new int2((int)mloc.x, (int)mloc.y);

                if (imloc.x == imloc.x.Clamp(0, image.Width) && imloc.y == imloc.y.Clamp(0, image.Height))
                {
                    PixelClicked?.Invoke(imloc);
                }
                else
                {
                    PixelClicked?.Invoke(new int2(-1, -1));
                }
            }
        }
Example #15
0
 private void TmFade_Tick(object sender, EventArgs e)
 {
     if (IsDisposed)
     {
         return;
     }
     Invalidate(); // force repaint
     _fadeSteps--;
     if (_fadeSteps <= 0 || _fadeTotalSteps <= 0 || _currFade == null || _tgtFade == null)
     {
         tmFade.Enabled = false;
         Visible        = false;
         FadeFinished?.Invoke();
     }
 }
        public void HandleWsMessage(string subscriptionId, JObject message)
        {
            // subscription already init otherwise subscription does not exist
            UpdateDelegate handler = null;

            lock (_subscriptionLock)
            {
                if (!_subscriptionHandlers.TryGetValue(subscriptionId, out handler))
                {
                    _pendingSubscriptionUpdates.TryAdd(subscriptionId, message);
                }
            }

            handler?.Invoke(message);
        }
Example #17
0
 private void DoFade()
 {
     while (!IsDisposed)
     {
         this.Invoke(new Action(Invalidate)); // force repaint
         _fadeSteps--;
         if (_fadeSteps <= 0 || _fadeTotalSteps <= 0 || _fader == null)
         {
             UnlockInput();
             break;
         }
         Thread.Sleep(66);
     }
     this.Invoke(new Action(() => FadeCycleCompleted?.Invoke()));
     _taskFader = null;
 }
Example #18
0
 private void OnFrameChanged(object o, EventArgs e)
 {
     if (IsDisposed)
     {
         return;
     }
     _animFramesRemaining--;
     if (_animFramesRemaining < 0)
     {
         if (_animate == AnimateType.ONCE)
         {
             _animCyclesRemaining--;
         }
         TaskHandler.StartNew(new TaskSet(() => AnimationCycleCompleted?.Invoke()));
     }
     Invalidate();
 }
Example #19
0
 public bool Closing(ucEditorController controller, UpdateDelegate <IEditorControl> switchFunc)
 {
     foreach (ToolStripButton tsb in _editors.GetKeys())
     {
         IEditorControl editor = _editors[tsb];
         if (editor != null)
         {
             if (editor.Dirty)
             {
                 controller.SetEditor(editor);
                 switchFunc?.Invoke(editor);
                 if (!controller.Unload())
                 {
                     return(false);
                 }
             }
         }
     }
     return(true);
 }
Example #20
0
        protected override void OnUpdate(float timeStep)
        {
            base.OnUpdate(timeStep);

            float deltaTime = Time.SystemTime - tempTime;

            if (deltaTime > 500)
            {
                loadingSpinner.Start();
            }

            loadingSpinner.UpdateSpinner(timeStep);

            if (dirty)
            {
                loadingSpinner.Stop();
                tempTime = Time.SystemTime;
                dirty    = false;
                OnUpdateHandler?.Invoke();
            }
        }
Example #21
0
        private void GetOrCreateFromTextPageCache(out Image result)
        {
            float factor = _scale.x.Clamp(MIN_SCALE, _scale.y);

            StringFormat textFormat = new StringFormat
            {
                Alignment     = Alignment,
                LineAlignment = LineAlignment,
                Trimming      = StringTrimming.EllipsisWord,
                FormatFlags   = StringFormatFlags.LineLimit
            };

            SizeF textBounds = new SizeF
            {
                Width  = ClientRectangle.Width - (TextMargin.Left - TextMargin.Right) * _scale.x,
                Height = ClientRectangle.Height - (TextMargin.Top - TextMargin.Bottom) * _scale.y
            };

            PointF scaledShadowOffset = new PointF
            {
                X = _shadowOffset.X * factor,
                Y = _shadowOffset.Y * factor
            };

            TextFormatInfo info = new TextFormatInfo(_textFont, textFormat, textBounds, _textColor, _shadowColor, scaledShadowOffset);

            if (!_textCache.Contains(info))
            {
                _textCache.Add(info, GenerateTextImages(Text, info));
            }

            result        = SelectPage(_textCache[info], TextPage, out int page, out int pageCount);
            _textPage     = page;
            TextPageCount = pageCount;

            TextCacheUpdated?.Invoke();
        }
        private void cbHouse3_SelectedIndexChanged(object sender, EventArgs e)
        {
            int index = cbHouse3.SelectedIndex.Max(0);

            RegionAnim_House3Changed?.Invoke((House)index);
        }
Example #23
0
 public Task Invoke(Update update, PossibleCommands possibleCommands)
 {
     possibleCommands.Commands.AddRange(commands);
     return(_next.Invoke(update));
 }
Example #24
0
 private void OpenKeyHelp()
 {
     AudioEngine.Click();
     Clicked_KeyHelp?.Invoke();
 }
Example #25
0
 public void Update(float delta)
 {
     _ticks?.Invoke(delta);
 }
 private void tbTheme_TextChanged(object sender, EventArgs e)
 {
     ThemeChanged?.Invoke(tbTheme.Text);
 }
Example #27
0
 protected override bool Update() => UpdateDelegate?.Invoke() ?? false;
        private void cbEnemyHouse_SelectedIndexChanged(object sender, EventArgs e)
        {
            int index = cbEnemyHouse.SelectedIndex.Max(0);

            EnemyHouseChanged?.Invoke((House)index);
        }
 private void SpBack_Click(object sender, EventArgs e)
 {
     AudioEngine.Click(); Clicked_Back?.Invoke();
 }
 private void SpStart_Click(object sender, EventArgs e)
 {
     AudioEngine.Click(); Clicked_Start?.Invoke();
 }