Ejemplo n.º 1
0
        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");
        }
Ejemplo n.º 2
0
        private void ShowTooltipOn(HTMLElement tooltipOn, TooltipMode mode, bool forceFullCycle = false)
        {
            var content = GetTooltipsOfElementOrNull(tooltipOn, mode);

            Logger.Debug(GetType(), "ShowTooltipOn starting forceFullCycle={0} mode={1}", forceFullCycle, mode);

            if (content == null)
            {
                Logger.Debug(GetType(), "tooltip show ignored as it would be empty");
                return;
            }

            var contAndTt = GetOrCreateTooltipOn(tooltipOn, content, mode);

            var cont = contAndTt.Item1;
            var tt   = contAndTt.Item2;

            Logger.Debug(GetType(), "ShowTooltipOn gotOrCreated id={0}", tt.Id);

            //tooltipOn.ParentElement.Style.Position = Position.Relative;
            tooltipOn.Style.Position = Position.Relative;

            if (!tooltipOn.HasAttribute(Magics.AttrDataMayBeTooltipContainer))
            {
                if (tooltipOn.ParentElement != null)
                {
                    tooltipOn.ParentElement.InsertAfter(cont, tooltipOn);
                }
            }
            else
            {
                tooltipOn.AppendChild(cont);
            }

            var ops = new List <TooltipOper>();

            _pendingTooltipOps[tt] = ops;
            _tooltips.Set(tt, Tuple.Create(tt, mode));

            if (forceFullCycle)
            {
                tt.ClassList.Remove(Magics.CssClassActive);
                tt.ClassList.Remove(Magics.CssClassInactive);
                tt.ClassList.Add(Magics.CssClassDisabled);
            }

            switch (GetTooltipState(tt))
            {
            case TooltipState.EnabledShown: break;     //already in the right state

            case TooltipState.Disabled:
                ops.AddRange(
                    Immediate(Magics.CssClassDisabled, Magics.CssClassInactive),
                    Lasting(Magics.CssClassInactive, Magics.CssClassActive, Magics.TooltipFadeInMs));
                break;

            case TooltipState.EnabledHidden:     //interrupted showning or hiding
                ops.Add(Lasting(Magics.CssClassInactive, Magics.CssClassActive, Magics.TooltipFadeInMs));
                break;

            default: throw new ArgumentException("ShowTooltipOn unknown state");
            }

            //autohide?
            if (mode == TooltipMode.PeekIntoErrors)
            {
                ops.AddRange(
                    Lasting(Magics.CssClassActive, Magics.CssClassInactive, Magics.TooltipFadeOutMs),
                    Immediate(Magics.CssClassInactive, Magics.CssClassDisabled));
            }

            Logger.Debug(GetType(), "ShowTooltipOn scheduled {0} opers", ops.Count);

            ScheduleNextOperation(tt);
        }
Ejemplo n.º 3
0
 public void AddMouseClickListener(Element target, Action <MouseEvent> action)
 {
     target.MarkAsMouseEventRecipient(true);
     _mouseClickListeners.Set(target, action);
 }