Exemple #1
0
        private async void UpdateExtension()
        {
            SecurityFunctions.CheckForAccess(SecurityGroups.Modify);

            if (!FieldsValid(this))
            {
                return;
            }

            using (var spinner = new WaitSpinner(this, "Updating extension...", 150))
            {
                var ctx = (Extension)this.DataContext;

                try
                {
                    await ctx.UpdateAsync();
                }
                catch (MySql.Data.MySqlClient.MySqlException ex)
                {
                    ExceptionHandler.MySqlException(this, ex);

                    return;
                }

                // Copy new values to the original context to update the main window values.
                this.extensionContext.CopyValues(ctx);
            }

            UserPrompts.PopupMessage(this, "Extension updated.", "Success!");
        }
Exemple #2
0
        private async void InitConnection()
        {
            bool canReach      = false;
            bool cacheVerified = false;

            using (var spinner = new WaitSpinner(this, "Connecting to database...", 2000))
            {
                await Task.Run(() =>
                {
                    canReach = DBFactory.CanReachServer();

                    spinner.StatusText = "Checking cache...";

                    cacheVerified = CacheFunctions.VerifyCache();

                    if (canReach)
                    {
                        spinner.StatusText = "Loading data...";

                        CacheFunctions.RefreshCache();
                    }

                    SecurityFunctions.PopulateUserAccess();
                    SecurityFunctions.PopulateAccessGroups();
                });
            }

            if (!cacheVerified && !canReach)
            {
                await UserPrompts.PopupMessage(this, "Cannot connect to the database and the local cache was not verified.", "Cannot Run");

                Application.Current.Shutdown();
            }
            else if (cacheVerified && !canReach)
            {
                WatchDogInstance.WatchDog.Start(true);
            }
            else
            {
                WatchDogInstance.WatchDog.Start(false);
            }

            // If current user can modify, add edit button column to grid.
            AddEditButton();

            FieldsGrid.IsEnabled = true;
        }
Exemple #3
0
        public LoadingControl()
        {
            var size = new Size(32, 32);

            _waitSpinner = new WaitSpinner
            {
                Dock = DockStyle.Fill,
                Size = size
            };

            SuspendLayout();
            Dock = DockStyle.Fill;
            AutoScaleDimensions = new SizeF(96, 96);
            AutoScaleMode       = AutoScaleMode.Dpi;
            Controls.Add(_waitSpinner);
            Name = nameof(LoadingControl);
            Size = size;
            ResumeLayout(performLayout: false);

            this.AdjustForDpiScaling();
        }
Exemple #4
0
    private static void OnIsWaitingPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
    {
        WaitSpinner waitSpinner = (WaitSpinner)sender;

        waitSpinner.ChangeVisualState(true);
    }