示例#1
0
        public override void ExitClicked()
        {
            var result = MessageBox.AskYesNoQuestion(Dialog, "Are you sure you want to exit the application?", Core.Application.NameAndVersion);

            if (result == DialogResult.Yes)
            {
                // TODO: Replace Application.Exit() with abstraction
                Application.Exit();
            }
        }
        public void DeleteQueryClick()
        {
            var result = MessageBox.AskYesNoQuestion(Form, "Are you sure?", Core.Application.NameAndVersion);

            if (result == DialogResult.Yes)
            {
                try
                {
                    Model.RemoveQuery(Model.SelectedWorkUnitQuery);
                }
                catch (ArgumentException ex)
                {
                    MessageBox.ShowError(Form, ex.Message, Core.Application.NameAndVersion);
                }
            }
        }
        public void DeleteWorkUnitClick()
        {
            var entry = Model.SelectedWorkUnitRow;

            if (entry == null)
            {
                MessageBox.ShowInformation(Form, "No work unit selected.", Core.Application.NameAndVersion);
            }
            else
            {
                var result = MessageBox.AskYesNoQuestion(Form, "Are you sure?  This operation cannot be undone.", Core.Application.NameAndVersion);
                if (result == DialogResult.Yes)
                {
                    Model.DeleteHistoryEntry(entry);
                }
            }
        }
        private void RefreshProjectData(WorkUnitProteinUpdateScope scope)
        {
            var result = MessageBox.AskYesNoQuestion(Form, "Are you sure?  This operation cannot be undone.", Core.Application.NameAndVersion);

            if (result == DialogResult.No)
            {
                return;
            }

            long id = 0;

            if (scope == WorkUnitProteinUpdateScope.Project)
            {
                id = Model.SelectedWorkUnitRow.ProjectID;
            }
            else if (scope == WorkUnitProteinUpdateScope.Id)
            {
                id = Model.SelectedWorkUnitRow.ID;
            }

            var proteinDataUpdater = new ProteinDataUpdater((IWorkUnitDatabase)Model.Repository, ProteinService);

            try
            {
                using (var dialog = new ProgressDialog((progress, token) => proteinDataUpdater.Execute(progress, scope, id, token), true))
                {
                    dialog.Text = Core.Application.NameAndVersion;
                    dialog.ShowDialog(Form);
                    if (dialog.Exception != null)
                    {
                        Logger.Error(dialog.Exception.Message, dialog.Exception);
                        MessageBox.ShowError(Form, dialog.Exception.Message, Core.Application.NameAndVersion);
                    }
                }

                Model.ResetBindings(true);
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message, ex);
                MessageBox.ShowError(Form, ex.Message, Core.Application.NameAndVersion);
            }
        }