Пример #1
0
        private async void _executeScriptButton_Click(object sender, EventArgs e)
        {
            try {
                using (LoadingCircle.EnterAnimationScope(this, disableControls: true)) {
                    await Task.Run(() => DAC.ExecuteBatch(Script));
                }
                this.DialogResult = DialogResult.OK;

                Close();
            } catch (Exception error) {
                ExceptionDialog.Show("Error", error);
            } finally {
            }
        }
Пример #2
0
        public static IDisposable EnterAnimationScope(Control containerControl, float relativeSize = 0.5f, StylePresets style = StylePresets.MacOSX, bool disableControls = false, params Control[] exclusionControls)
        {
            if (containerControl == null)
            {
                throw new ArgumentNullException("containerControl");
            }

            if (relativeSize < 0.01f || relativeSize > 1f)
            {
                throw new ArgumentOutOfRangeException("relativeSize", relativeSize, "Must be within (0.01, 1.0)");
            }

            var loadingCircle = new LoadingCircle();

            loadingCircle.StylePreset = style;
            Action startAction = () => {
                containerControl.Controls.Add(loadingCircle);
                loadingCircle.BringToFront();
                var sideLength = (int)(Math.Min(containerControl.Width, containerControl.Height) * relativeSize) - 1;
                loadingCircle.Size              = new Size(sideLength, sideLength);
                loadingCircle.Location          = new Point((containerControl.Width - loadingCircle.Width) / 2, (containerControl.Height - loadingCircle.Height) / 2);
                loadingCircle.InnerCircleRadius = sideLength / 5;
                loadingCircle.OuterCircleRadius = sideLength / 3;
                loadingCircle.SpokeThickness    = loadingCircle.InnerCircleRadius / 3;
            };

            Action finishAction = () => {
                containerControl.Controls.Remove(loadingCircle);
            };

            return(new ActionScope(() => {
                startAction();
                loadingCircle.StartAnimating(disableControls ? containerControl : null, exclusionControls);
            }, () => {
                loadingCircle.StopAnimating();
                finishAction();
            }));
        }
Пример #3
0
        public async Task RefreshGrid()
        {
            if (DesignMode)
            {
                return;
            }

            if (_updating)
            {
                return;
            }

            if (await _refreshThrottle.IsCallerFirstInStampede())
            {
                using (LoadingCircle.EnterAnimationScope(this._gridContainerPanel, 1.0f, LoadingCircle.StylePresets.MacOSX)) {
                    _grid.Enabled = false;
                    while (await BindInternal())
                    {
                        ;
                    }
                    _grid.Enabled = true;
                }
            }
        }