Ejemplo n.º 1
0
        // with delegate Ajax on click
        public static MenuItem ClientInsertMenuItem(Terrasoft.UI.WebControls.PageSchemaUserControl page, string menuOwnerClientID, int index,
                                                    string name, string caption, ControlImage controlImage, string clickCode, Action <string> onClickHandler)
        {
            var script = string.Empty;

            script += string.Format("if ({0}.getMenu().items.get({1}) &&  {0}.menu.items.get({1}).id == '{2}' ) {{\n", menuOwnerClientID, index, name);
            script += string.Format(" {0}.menu.removeByIndex({1}); }}\n", menuOwnerClientID, index);
            var menuItem = GetMenuItem(page, menuOwnerClientID, name, caption, controlImage, clickCode);

            menuItem.AjaxEvents.Click.Event += delegate(object sender, Terrasoft.UI.WebControls.Controls.AjaxEventArgs e) {
                var clickedMenuItemCode = e.ExtraParameters[0].Value;
                onClickHandler(clickedMenuItemCode);
            };

            /*menuItem.AjaxEvents.MenuItemClick.Event += delegate(object sender, Terrasoft.UI.WebControls.Controls.AjaxEventArgs e) {
             *                                                                              var clickedMenuItemCode = e.ExtraParameters[2].Value;
             *                                                                              onClickHandler(clickedMenuItemCode);
             *                                                                              };
             */
            script += string.Format("window.{0} = {1};\n", menuItem.ClientID, menuItem.GenerateControlScript(true, null));
            script += string.Format("{0}.getMenu().insert({2}, window.{1});\n", menuOwnerClientID, menuItem.ClientID, index);
            var scriptManager = ScriptManager.GetCurrent(page.AspPage);

            scriptManager.AddScript(script);
            return(menuItem);
        }
Ejemplo n.º 2
0
        public static void SetMenuItemVisibility(Terrasoft.UI.WebControls.PageSchemaUserControl page, string menuItemClientID, bool value)
        {
            var script = string.Empty;

            script += string.Format("window.{0}.visible = {1};\n", menuItemClientID, value.ToString().ToLower());
            script += string.Format("window.{0}.actualizeIsVisible();\n", menuItemClientID);
            var scriptManager = ScriptManager.GetCurrent(page.AspPage);

            scriptManager.AddScript(script);
        }
Ejemplo n.º 3
0
        public static void ClientRemoveMenuItemByName(Terrasoft.UI.WebControls.PageSchemaUserControl page, string menuOwnerClientID, string name)
        {
            var script = string.Empty;

            script += string.Format("var targetIndex = {0}.getMenu().items.indexOfKey('{1}'); \n", menuOwnerClientID, name);
            script += "if (targetIndex != -1 ) { \n";
            script += string.Format(" {0}.menu.removeByIndex(targetIndex); }}\n", menuOwnerClientID);
            var scriptManager = ScriptManager.GetCurrent(page.AspPage);

            scriptManager.AddScript(script);
        }
Ejemplo n.º 4
0
        public static void SetComponentMenuItemClickSignal(Terrasoft.UI.WebControls.PageSchemaUserControl page, string CmpClientId, string signalName)
        {
            var script =
                "{0}.getMenu().on('itemClick', function(item, event, itemId, itemIndex) {{ \n" +
                "	var tag = item.tag; \n"+
                "	var pars = new Object(); pars.tag = tag; \n"+
                "	var parStr =  Ext.util.JSON.encodeObject(pars, 3); \n"+
                "	window.Terrasoft.AjaxMethods.ThrowClientEventWithParameters('{1}', '{2}', parStr); \n"+
                "}}, {0}.getMenu()); \n";

            script = string.Format(script, CmpClientId, page.Process.InstanceUId, signalName);
            var scriptManager = ScriptManager.GetCurrent(page.AspPage);

            scriptManager.AddScript(script);
        }
Ejemplo n.º 5
0
        private static Terrasoft.UI.WebControls.Controls.MenuItem GetMenuItem(Terrasoft.UI.WebControls.PageSchemaUserControl page, string menuOwnerClientID,
                                                                              string name, string caption, ControlImage controlImage, string clickCode)
        {
            var menuItem = new Terrasoft.UI.WebControls.Controls.MenuItem();

            menuItem.CreatedByAjax   = true;
            menuItem.EnableViewState = false;
            menuItem.Name            = name;
            menuItem.UId             = Guid.NewGuid();
            menuItem.Tag             = clickCode;
            menuItem.Caption         = caption;
            menuItem.Image           = controlImage;

            return(menuItem);
        }
Ejemplo n.º 6
0
        // with delegate Ajax on click
        public static MenuItem ClientAppendMenuItem(Terrasoft.UI.WebControls.PageSchemaUserControl page, string menuOwnerClientID,
                                                    string name, string caption, ControlImage controlImage, string clickCode, Action <string> onClickHandler)
        {
            var script   = string.Empty;
            var menuItem = GetMenuItem(page, menuOwnerClientID, name, caption, controlImage, clickCode);

            menuItem.AjaxEvents.Click.Event += delegate(object sender, Terrasoft.UI.WebControls.Controls.AjaxEventArgs e) {
                var clickedMenuItemCode = e.ExtraParameters[0].Value;
                onClickHandler(clickedMenuItemCode);
            };
            script += string.Format("window.{0} = {1};\n", menuItem.ClientID, menuItem.GenerateControlScript(true, null));
            script += string.Format("{0}.getMenu().addItem(window.{1});\n", menuOwnerClientID, menuItem.ClientID);
            var scriptManager = ScriptManager.GetCurrent(page.AspPage);

            scriptManager.AddScript(script);
            return(menuItem);
        }
Ejemplo n.º 7
0
        // with specified Signal on click
        public static MenuItem ClientInsertMenuItem(Terrasoft.UI.WebControls.PageSchemaUserControl page, string menuOwnerClientID, int index,
                                                    string name, string caption, ControlImage controlImage, string clickCode, string signalName)
        {
            var script = string.Empty;

            script += string.Format("if ({0}.getMenu().items.get({1}) &&  {0}.menu.items.get({1}).id == '{2}' ) {{\n", menuOwnerClientID, index, name);
            script += string.Format(" {0}.menu.removeByIndex({1}); }}\n", menuOwnerClientID, index);
            var menuItem = GetMenuItem(page, menuOwnerClientID, name, caption, controlImage, clickCode);

            if (!string.IsNullOrEmpty(signalName))
            {
                menuItem.AjaxEvents.Click.SignalName = signalName;
                menuItem.AjaxEvents.Click.AjaxEventTargetControlID = menuOwnerClientID;
            }
            script += string.Format("window.{0} = {1};\n", menuItem.ClientID, menuItem.GenerateControlScript(true, null));
            script += string.Format("{0}.getMenu().insert({2}, window.{1});\n", menuOwnerClientID, menuItem.ClientID, index);
            var scriptManager = ScriptManager.GetCurrent(page.AspPage);

            scriptManager.AddScript(script);
            return(menuItem);
        }
Ejemplo n.º 8
0
 public virtual void RefreshReferences(Terrasoft.UI.WebControls.PageSchemaUserControl page)
 {
     _page          = page;
     UserConnection = page.UserConnection;
 }
Ejemplo n.º 9
0
 public virtual void Prepare(Terrasoft.UI.WebControls.PageSchemaUserControl page)
 {
     _page = page;
 }