/// <summary>
        /// Private helper to fire <see cref="UpdateRequested"/>.
        /// </summary>
        private Task FireUpdateRequested()
        {
            RequestUpdateDescriptorEventArgs args = new RequestUpdateDescriptorEventArgs(this);

            UpdateRequested?.Invoke(this, args);
            return(args.DeferAsync());
        }
Beispiel #2
0
 /// <summary>
 /// Archive current selected medical exams.
 /// </summary>
 private void ArchiveMedicalExam()
 {
     if (GetSelectedRowsCount() > 0)
     {
         if (MessageBox.Show(
                 $"¿Está seguro que desea archivar {(GetSelectedRowsCount() > 1 ? $"los {GetSelectedRowsCount()}" : "el")} examen{(GetSelectedRowsCount() > 1 ? "es" : "")} seleccionado{(GetSelectedRowsCount() > 1 ? "s" : "")}?",
                 $"Archivar examen{(GetSelectedRowsCount() > 1 ? "es" : "")} médico{(GetSelectedRowsCount() > 1 ? "s" : "")}",
                 MessageBoxButtons.OKCancel,
                 MessageBoxIcon.Warning) == DialogResult.OK)
         {
             int total = GetSelectedRowsCount(), errors = 0;
             for (var i = 0; i < GetSelectedRowsCount(); i++)
             {
                 if (!IoCContainer.Container.Get <IDriversDataProvider>().ArchiveMedicalExamAsync(Driver, (dgvMedicalExamActive.Rows[i].Tag as MedicalExam)).Result)
                 {
                     errors++;
                 }
             }
             _ = errors > 0
                 ? MessageBox.Show($"Han ocurrido errores archivando {(total > 1 ? "los" : "el")} examen{(total > 1 ? "es" : "")}. Contacte al desarrollador para obtener soporte acerca de este error.",
                                   $"Error archivando examen{(total > 1 ? "es" : "")}",
                                   MessageBoxButtons.OK,
                                   MessageBoxIcon.Error)
                 : MessageBox.Show($"Se han archivado satisfactoriamente {total} examen{(total > 1 ? "es" : "")} médico{(total > 1 ? "s" : "")}.",
                                   "Examenes archivados", MessageBoxButtons.OK, MessageBoxIcon.Information);
             UpdateMedicalExamsTab(Driver);
             UpdateRequested?.Invoke(this, new EventArgs());
         }
     }
 }
Beispiel #3
0
        /// <summary>
        /// Open the new medical exam form.
        /// </summary>
        private void NewMedicalExam()
        {
            var frm = new FrmNewMedicalExam();

            frm.NewMedicalExamAdded += me =>
            {
                if (IoCContainer.Container.Get <IDriversDataProvider>().AddNewMedicalExamAsync(Driver, me).GetAwaiter().GetResult())
                {
                    UpdateMedicalExamsTab(Driver);
                    UpdateRequested?.Invoke(this, new EventArgs());
                    return(true);
                }
                else
                {
                    return(false);
                }
            };
            _ = frm.ShowDialog();
        }
Beispiel #4
0
        /// <summary>
        /// Opens new requalification form.
        /// </summary>
        private void RequalificationRenewal()
        {
            var frm = new FrmNewRequalification();

            frm.NewRequalificaitonAdded += r =>
            {
                if (IoCContainer.Container.Get <IDriversDataProvider>().RenewalRequalificationAsync(Driver, r).Result)
                {
                    UpdateRequalificationTab(Driver);
                    UpdateRequested?.Invoke(this, new EventArgs());
                    return(true);
                }
                else
                {
                    return(false);
                }
            };
            _ = frm.ShowDialog();
        }
Beispiel #5
0
        /// <summary>
        /// Open the new driver's license form.
        /// </summary>
        private void DriverLicenseRenewal()
        {
            var frm = Driver.ActiveDriverLicense != null ? new FrmNewLicense(Driver.ActiveDriverLicense) : new FrmNewLicense();

            frm.NewLicenseForRenewal += l =>
            {
                if (IoCContainer.Container.Get <IDriversDataProvider>().RenewalLicenseAsync(Driver, l).Result)
                {
                    UpdateLicenseTab(Driver);
                    UpdateRequested?.Invoke(this, new EventArgs());
                    return(true);
                }
                else
                {
                    return(false);
                }
            };
            _ = frm.ShowDialog();
        }
        private void XamlCodeRenderer_KeyDown(Monaco.CodeEditor sender, Monaco.Helpers.WebKeyEventArgs args)
        {
            // Handle Shortcuts.
            // Ctrl+Enter or F5 Update // TODO: Do we need this in the app handler too? (Thinking no)
            if ((args.KeyCode == 13 && args.CtrlKey) ||
                args.KeyCode == 116)
            {
                UpdateRequested?.Invoke(this, EventArgs.Empty);

                // Eat key stroke
                args.Handled = true;
            }

            // Ignore as a change to the document if we handle it as a shortcut above or it's a special char.
            if (!args.Handled && Array.IndexOf(NonCharacterCodes, args.KeyCode) == -1)
            {
                // TODO: Mark Dirty here if we want to prevent overwrites.

                // Setup Time for Auto-Compile
                this._autoCompileTimer?.Cancel(); // Stop Old Timer

                // Create Compile Timer
                this._autoCompileTimer = ThreadPoolTimer.CreateTimer(
                    e =>
                {
                    UpdateRequested?.Invoke(this, EventArgs.Empty);

                    if (TimeSampleEditedFirst == DateTime.MinValue)
                    {
                        TimeSampleEditedFirst = DateTime.Now;
                    }

                    TimeSampleEditedLast = DateTime.Now;
                }, TimeSpan.FromSeconds(0.5));
            }
        }
Beispiel #7
0
 public void UpdateItem()
 {
     UpdateRequested?.Invoke(this, new UpdateRequestedEventArgs(item));
 }
 public void NotifyUpdateRequested(Rat sender, Rat other)
 {
     UpdateRequested?.Invoke(sender, other);
 }
 /// <summary>
 /// Updates the specified context.
 /// </summary>
 /// <param name="context">The context.</param>
 public virtual void Update(RenderContext2D context)
 {
     UpdateRequested?.Invoke(this, new UpdateEventArgs(context));
     IsRenderable = CanRender(context);
 }