Example #1
0
        public async Task CloseModal(ModalDialog modalForm, FormBase oldForm)
        {
            DeviceSession ds = this.Device;

            if (ds == null)
            {
                return;
            }

            if (modalForm == null)
            {
                throw new Exception("No modal form");
            }

            ds.FormSwitched = true;

            ds.PreviousForm = ds.ActiveForm;

            ds.ActiveForm = oldForm;
        }
Example #2
0
        public override async Task Action(MessageResult message)
        {
            var call = message.GetData <CallbackData>();

            message.Handled = true;

            if (!message.IsAction)
            {
                return;
            }

            await message.ConfirmAction();

            await message.DeleteMessage();

            var buttons = this.Buttons.Aggregate((a, b) => a.Union(b).ToArray()).ToList();

            if (call == null)
            {
                return;
            }

            ButtonBase button = buttons.FirstOrDefault(a => a.Value == call.Value);

            if (button == null)
            {
                return;
            }

            OnButtonClicked(new ButtonClickedEventArgs(button)
            {
                Tag = this.Tag
            });

            FormBase fb = ButtonForms.ContainsKey(call.Value) ? ButtonForms[call.Value] : null;

            if (fb != null)
            {
                await this.NavigateTo(fb);
            }
        }
Example #3
0
        /// <summary>
        /// Navigates to a new form
        /// </summary>
        /// <param name="newForm"></param>
        /// <returns></returns>
        public virtual async Task NavigateTo(FormBase newForm, params object[] args)
        {
            DeviceSession ds = this.Device;

            if (ds == null)
            {
                return;
            }

            ds.FormSwitched = true;

            ds.PreviousForm = ds.ActiveForm;

            ds.ActiveForm  = newForm;
            newForm.Client = this.Client;
            newForm.Device = ds;

            //Notify prior to close
            foreach (var b in this.Controls)
            {
                if (!b.Enabled)
                {
                    continue;
                }

                await b.Hidden(true);
            }

            this.CloseControls().Wait();

            await this.OnClosed(new EventArgs());

            await newForm.OnInit(new InitEventArgs(args));

            await newForm.OnOpened(new EventArgs());
        }