Example #1
0
 /*
  * searches through all controls for event handlers for the given name
  */
 private IEnumerable <Node> SearchEvents(string name, Node node)
 {
     if (node != null)
     {
         foreach (Node idx in node)
         {
             if (idx.Name == "events")
             {
                 foreach (Node idxInner in idx)
                 {
                     if (!CachedControlEvents.ContainsKey(idxInner.Name))
                     {
                         CachedControlEvents[idxInner.Name] = new Node();
                     }
                     CachedControlEvents[idxInner.Name].Add("", idxInner);
                     if (idxInner.Name == name)
                     {
                         yield return(idxInner);
                     }
                 }
             }
             else
             {
                 foreach (Node idxInner in SearchEvents(name, idx))
                 {
                     yield return(idxInner);
                 }
             }
         }
     }
 }
Example #2
0
        private void magix_forms_change_mml(object sender, ActiveEventArgs e)
        {
            if (e.Params.Contains("inspect"))
            {
                e.Params["inspect"].Value = @"changes the mml of the given [form-id] 
to the value in [mml]";
                return;
            }

            HasSetCachedControlEvents = false;
            CachedControlEvents.Clear();

            if (FormID == Ip(e.Params)["form-id"].Get <string>())
            {
                Node ip = Ip(e.Params);
                Node dp = Dp(e.Params);

                DataSource = new Node();
                Methods.Clear();
                TokenizeMarkup(Expressions.GetExpressionValue <string>(ip["mml"].Get <string>(), dp, ip, false));
                this.Controls.Clear();
                isFirst = true;
                BuildControls();
                ((DynamicPanel)this.Parent).ReRender();
            }
        }
Example #3
0
        private void magix_null_event_handler(object sender, ActiveEventArgs e)
        {
            Node ip = Ip(e.Params);

            if (Methods.ContainsKey(e.Name))
            {
                if (ShouldInspect(ip))
                {
                    AppendInspectFromResource(
                        ip["inspect"],
                        "Magix.forms",
                        "Magix.forms.hyperlisp.inspect.hl",
                        "[magix.forms.web-part-null-event-handler-dox].value");
                    ip.AddRange(Methods[e.Name].Clone());
                    return;
                }

                Node tmp = Methods[e.Name].Clone();

                // cloning the incoming parameters
                if (ip.Count > 0)
                {
                    tmp["$"].AddRange(ip.Clone());
                }

                RaiseActiveEvent(
                    "magix.execute",
                    tmp);

                if (tmp.Contains("$"))
                {
                    ip.Clear();
                    ip.AddRange(tmp["$"]);
                }
            }

            // shortcutting execute keywords for efficiency
            if (DataSource.ContainsValue("controls"))
            {
                if (!HasSetCachedControlEvents)
                {
                    HasSetCachedControlEvents = true;
                    foreach (Node idx in SearchEvents(e.Name, DataSource["controls"].Get <Node>()))
                    {
                        Node tmp = idx.Clone();

                        // cloning the incoming parameters
                        if (ip.Count > 0)
                        {
                            tmp["$"].AddRange(ip.Clone());
                        }

                        RaiseActiveEvent(
                            "magix.execute",
                            tmp);

                        if (tmp.Contains("$"))
                        {
                            ip.Clear();
                            ip.AddRange(tmp["$"]);
                        }
                    }
                }
                else
                {
                    if (CachedControlEvents.ContainsKey(e.Name))
                    {
                        Node cache = CachedControlEvents[e.Name];
                        foreach (Node idx in cache)
                        {
                            Node tmp = idx.Get <Node>().Clone();

                            // cloning the incoming parameters
                            if (ip.Count > 0)
                            {
                                tmp["$"].AddRange(ip.Clone());
                            }

                            RaiseActiveEvent(
                                "magix.execute",
                                tmp);

                            if (tmp.Contains("$"))
                            {
                                ip.Clear();
                                ip.AddRange(tmp["$"]);
                            }
                        }
                    }
                }
            }
        }