コード例 #1
0
        public static void InitializeContextHelpButton(Button helpContextButton, string helpContextId, UserConnection userConnection)
        {
            string videoCode    = GetVideoCode(helpContextId, userConnection);
            string formatString = "{0}.on('click', function(el) {{ {1} }}, this)";

            helpContextButton.Hidden       = false;
            helpContextButton.Image.Source = ControlImageSource.ResourceManager;
            helpContextButton.Image.ResourceManagerName = "Terrasoft.WebApp";
            if (HasVideoCode)
            {
                helpContextButton.Image.ResourceItemName = "video_help_btn.png";
                var menu = helpContextButton.Menu as Terrasoft.UI.WebControls.Controls.MenuBaseCollection;
                if (menu != null)
                {
                    var videoMenuItem = new Terrasoft.UI.WebControls.Controls.MenuItem();
                    videoMenuItem.ID      = "VideoHelpMenuItem";
                    videoMenuItem.UId     = Guid.NewGuid();
                    videoMenuItem.Caption = new LocalizableString(userConnection.ResourceStorage, "VideoHelpUtilities",
                                                                  "LocalizableStrings.MenuVideoHelpItemCaption.Value").ToString();
                    videoMenuItem.CaptionColor = Color.FromArgb(0, 2, 77, 156);
                    videoMenuItem.Tag          = "ref";
                    string function = "Terrasoft.HelpContext.showVideoHelp(" + Json.Serialize(videoCode) + ")";
                    menu.Add(videoMenuItem);
                    helpContextButton.AddScript(formatString, videoMenuItem.ClientID, function);
                    var menuItem = new Terrasoft.UI.WebControls.Controls.MenuItem();
                    menuItem.ID      = "HelpMenuItem";
                    menuItem.UId     = Guid.NewGuid();
                    menuItem.Caption = new LocalizableString(userConnection.ResourceStorage, "VideoHelpUtilities",
                                                             "LocalizableStrings.MenuHelpItemCaption.Value").ToString();
                    menuItem.CaptionColor = Color.FromArgb(0, 2, 77, 156);
                    menuItem.Tag          = "ref";
                    function = "Terrasoft.HelpContext.showHelp(" + Json.Serialize((string.IsNullOrEmpty(helpContextId) ?  "null" : helpContextId)) + ",'" + helpContextButton.ClientID + "')";
                    menu.Add(menuItem);
                    helpContextButton.AddScript(formatString, menuItem.ClientID, function);
                }
            }
            else
            {
                helpContextButton.Image.ResourceItemName = "help.png";
                string buttonClientEvent;
                if (!helpContextId.IsNullOrEmpty())
                {
                    string helpUrl = GetHelpUrl(helpContextButton, helpContextId, userConnection);
                    buttonClientEvent = "Terrasoft.HelpContext.showHelp(null, null, '" + helpUrl + @"')";
                }
                else
                {
                    buttonClientEvent = "Terrasoft.HelpContext.showHelp(" + Json.Serialize((string.IsNullOrEmpty(helpContextId) ?  "null" : helpContextId)) + ",'" + helpContextButton.ClientID + "')";
                }
                helpContextButton.AjaxEvents.Click.OnClientEvent = buttonClientEvent;
                SetWebControlHelpProperties(helpContextButton, helpContextId, userConnection);
            }
        }
コード例 #2
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);
        }
コード例 #3
0
        public static void AppendMenuItem <T>(T ownerComponent, string code, string caption, ControlImage image)
            where T : Button
        {
            var menuItem = new Terrasoft.UI.WebControls.Controls.MenuItem();

            menuItem.UId     = Guid.NewGuid();
            menuItem.Name    = ownerComponent + "_" + code;
            menuItem.Caption = caption;
            menuItem.Tag     = code;
            menuItem.Image   = image;
            ownerComponent.Menu.Add(menuItem);
            if (Terrasoft.UI.WebControls.Ext.IsAjaxRequest)
            {
                ownerComponent.Menu.AddCaptionItem(menuItem);
            }
        }
コード例 #4
0
 public void CompleteButtonMenuItems(object /*PageSchemaUserControl*/ page, Terrasoft.UI.WebControls.Controls.Button button,
                                     Dictionary <string, string> itemTagsAndCaptions)
 {
     //if (Terrasoft.UI.WebControls.Ext.IsAjaxRequest) {
     button.Menu.RemoveAll();
     //}
     foreach (var itemTagAndCaption in itemTagsAndCaptions)
     {
         if (itemTagAndCaption.Value == "|")
         {
             if (!Terrasoft.UI.WebControls.Ext.IsAjaxRequest)
             {
                 var menuSeparator = new Terrasoft.UI.WebControls.Controls.MenuSeparator();
                 menuSeparator.Name = itemTagAndCaption.Key;
                 button.Menu.Add(menuSeparator);
             }
             else
             {
                 button.Menu.AddSeparator();
             }
             continue;
         }
         var menuItem = new Terrasoft.UI.WebControls.Controls.MenuItem();
         menuItem.UId     = Guid.NewGuid();
         menuItem.Name    = itemTagAndCaption.Key;
         menuItem.Caption = itemTagAndCaption.Value;
         menuItem.Tag     = itemTagAndCaption.Key;
         menuItem.Image   = new ControlImage {
         };
         button.Menu.Add(menuItem);
         if (Terrasoft.UI.WebControls.Ext.IsAjaxRequest)
         {
             button.Menu.AddCaptionItem(menuItem);
         }
     }
     if (itemTagsAndCaptions.Count > 0)
     {
         var        script          = button.ClientID + ".onContentChanged();";
         MethodInfo addScriptMethod = page.GetType().GetMethod("AddScript");
         addScriptMethod.Invoke(page, new object[] { script });
     }
     return;
 }