Esempio n. 1
0
        public void ReplaceMaster(IBareForm <HTMLElement> newForm)
        {
            var maybeMaster = _adapted.Master;

            _adapted.ReplaceMaster(newForm);
            _callback(this, newForm, maybeMaster);
        }
Esempio n. 2
0
 private PopupInfo(
     IFormCanvas <HTMLElement> canvas, IBareForm <HTMLElement> form, IFormView <HTMLElement> formView)
 {
     Canvas   = canvas;
     Form     = form;
     FormView = formView;
 }
Esempio n. 3
0
        private void RemovePopupImpl(IBareForm <HTMLElement> frm)
        {
            if (_parent != null)
            {
                _parent.RemovePopupImpl(frm);
                return;
            }

            _popups.Remove(frm);
            TryPutFocusOnTopMostForm();
        }
Esempio n. 4
0
        private void AddPopupImpl(IBareForm <HTMLElement> frm)
        {
            if (_parent != null)
            {
                _parent.AddPopupImpl(frm);
                return;
            }

            var x = _popups.AddPopup(frm);

            TryPutFocusOnForm(x);
        }
Esempio n. 5
0
        public void Remove(IBareForm <HTMLElement> frm)
        {
            Logger.Debug(GetType(), "Remove() form={0} _masterFormView={1} isMaster?={2}",
                         frm, _masterFormView, frm.View == _masterFormView);

            if (frm.View == _masterFormView)
            {
                ClearMaster();
                //if there's popup it keeps focus
                return;
            }

            RemovePopupImpl(frm);
        }
Esempio n. 6
0
        public void Remove(IBareForm <HTMLElement> frm)
        {
            var maybeFrm = _popups.FirstOrDefault(x => x.FormView == frm.View);

            if (maybeFrm != null)
            {
                maybeFrm.Canvas.Unrender();
                _popups.Remove(maybeFrm);

                return;
            }

            Logger.Error(GetType(), "Remove() form was not shown. Popups={0} failing!", _popups.PrettyToString());
            throw new Exception(string.Format("form was not shown {0}", frm));
        }
        public static void RenderForm(this IFormCanvas <HTMLElement> self, IBareForm <HTMLElement> form, Action beforeShow)
        {
            Debug($"RenderForm() form into canvas: title={form.Title}, type={form.GetType().FullName}");
            var handlers = form.ExternalEventsHandlers;

            self.UserCancel = handlers.OnUserCancel;
            self.Body       = BuildBody(form.View);
            self.Actions    = form.View.Actions.Select(x => x.Widget);
            beforeShow();

            Handlers.Set(self, handlers);

            self.Show();

            Logger.Debug(typeof(FormCanvasExtensions), "RenderForm() ending");
        }
Esempio n. 8
0
        public void ClearMaster()
        {
            Logger.Debug(GetType(), "ClearMaster() _masterFormView={0} _masterAdaptedView={1}", _masterFormView, _masterAdaptedView);

            if (_masterAdaptedView != null)
            {
                _masterCanvas.Hide();
                _masterAdaptedView = null;
            }

            if (_masterFormView == null)
            {
                return;
            }

            _masterCanvas.Unrender();
            _masterFormView = null;
            _masterForm     = null;
        }
Esempio n. 9
0
        public IFormCanvas <HTMLElement> AddPopup(IBareForm <HTMLElement> newForm)
        {
            Logger.Debug(GetType(), "AddPopup() {0}", newForm);
            var newCanvas = _popupCanvasProvider.Provide();

            newCanvas.RenderForm(
                newForm,
                () => {
                if (_popups.Any(x => x.FormView == newForm.View))
                {
                    Logger.Error(GetType(), "AddPopup() form was already added. popups={0} failing!",
                                 _popups.PrettyToString());
                    throw new Exception(string.Format("form was already added {0}", newForm));
                }

                _popups.Add(PopupInfo.Create(newCanvas, newForm, newForm.View));
            });

            newCanvas.Title = newForm.Title;

            (newForm as IOnShownNeedingForm <HTMLElement>)?.OnShown();
            return(newCanvas);
        }
Esempio n. 10
0
        public void ReplaceMaster(IBareForm <HTMLElement> newForm)
        {
            var isSame = newForm.View == _masterFormView;

            Logger.Debug(GetType(), "ReplaceMaster() with {0}. Same as now?{0}", newForm, isSame);

            ClearMaster();

            _masterCanvas.RenderForm(
                newForm,
                () => {
                _masterFormView = newForm.View;
                _masterForm     = newForm;
            });
            _masterCanvas.Title = newForm.Title;

            //don't steal focus from popup (if any)
            if (MaybeGetTopMostDialog() == null)
            {
                TryPutFocusOnForm(_masterCanvas);
            }

            (newForm as IOnShownNeedingForm <HTMLElement>)?.OnShown();
        }
Esempio n. 11
0
 public static PopupInfo Create(
     IFormCanvas <HTMLElement> canvas, IBareForm <HTMLElement> form, IFormView <HTMLElement> formView) =>
 new PopupInfo(canvas, form, formView);
Esempio n. 12
0
 public void AddPopup(IBareForm <HTMLElement> newForm) => AddPopupImpl(newForm);
Esempio n. 13
0
 public void Remove(IBareForm <HTMLElement> frm)
 {
     _adapted.Remove(frm);
     _callback(this, null, frm);
 }
Esempio n. 14
0
 public void AddPopup(IBareForm <HTMLElement> newForm)
 {
     _adapted.AddPopup(newForm);
     _callback(this, newForm, null);
 }