WebControl ActionControlStyle.SetUpControl(WebControl control, string defaultText) { control.CssClass = control.CssClass.ConcatenateWithSpace( ActionComponentCssElementCreator.AllStylesClass.ClassName + " " + ActionComponentCssElementCreator.TextStyleClass.ClassName); return(control.AddControlsReturnThis(ActionComponentIcon.GetIconAndTextComponents(icon, Text.Any() ? Text : defaultText).GetControls())); }
private ActionComponentSetup getFavoriteAction() { var text = "{0} Article ({1})".FormatWith( AppTools.User == null || FavoritesTableRetrieval.GetRowMatchingPk(AppTools.User.UserId, ArticleId, returnNullIfNoMatch: true) == null ? "Favorite" : "Unfavorite", FavoritesTableRetrieval.GetRows(new FavoritesTableEqualityConditions.ArticleId(ArticleId)).Count()); var icon = new ActionComponentIcon(new FontAwesomeIcon("fa-heart")); return(AppTools.User == null ? (ActionComponentSetup) new HyperlinkSetup(User.GetInfo(), text, icon: icon) : new ButtonSetup( text, behavior: new PostBackBehavior( postBack: FavoritesTableRetrieval.GetRowMatchingPk(AppTools.User.UserId, ArticleId, returnNullIfNoMatch: true) == null ? PostBack.CreateFull( id: "favorite", modificationMethod: () => FavoritesModification.InsertRow(AppTools.User.UserId, ArticleId)) : PostBack.CreateFull( id: "unfavorite", modificationMethod: () => FavoritesModification.DeleteRows( new FavoritesTableEqualityConditions.UserId(AppTools.User.UserId), new FavoritesTableEqualityConditions.ArticleId(ArticleId)))), icon: icon)); }
WebControl ActionControlStyle.SetUpControl(WebControl control, string defaultText) { var cssElement = ActionComponentCssElementCreator.NormalButtonStyleClass.ClassName; if (buttonSize == ButtonSize.ShrinkWrap) { cssElement = ActionComponentCssElementCreator.ShrinkWrapButtonStyleClass.ClassName; } else if (buttonSize == ButtonSize.Large) { cssElement = ActionComponentCssElementCreator.LargeButtonStyleClass.ClassName; } control.CssClass = control.CssClass.ConcatenateWithSpace(ActionComponentCssElementCreator.AllStylesClass.ClassName + " " + cssElement); return(control.AddControlsReturnThis(ActionComponentIcon.GetIconAndTextComponents(icon, text.Any() ? text : defaultText).GetControls())); }
internal static ActionComponentSetup GetFollowAction(int userId) { var text = "{0} {1} ({2})".FormatWith( AppTools.User == null || FollowsTableRetrieval.GetRowMatchingPk(AppTools.User.UserId, userId, returnNullIfNoMatch: true) == null ? "Follow" : "Unfollow", UsersTableRetrieval.GetRowMatchingId(userId).Username, FollowsTableRetrieval.GetRows(new FollowsTableEqualityConditions.FolloweeId(userId)).Count()); var icon = new ActionComponentIcon(new FontAwesomeIcon("fa-plus")); return(AppTools.User == null ? (ActionComponentSetup) new HyperlinkSetup(User.GetInfo(), text, icon: icon) : new ButtonSetup( text, behavior: new PostBackBehavior( postBack: FollowsTableRetrieval.GetRowMatchingPk(AppTools.User.UserId, userId, returnNullIfNoMatch: true) == null ? PostBack.CreateFull(id: "follow", modificationMethod: () => FollowsModification.InsertRow(AppTools.User.UserId, userId)) : PostBack.CreateFull( id: "unfollow", modificationMethod: () => FollowsModification.DeleteRows( new FollowsTableEqualityConditions.FollowerId(AppTools.User.UserId), new FollowsTableEqualityConditions.FolloweeId(userId)))), icon: icon)); }
/// <summary> /// Creates a button action control style. /// </summary> /// <param name="text">Do not pass null.</param> /// <param name="buttonSize"></param> /// <param name="icon">The icon.</param> public ButtonActionControlStyle(string text, ButtonSize buttonSize = ButtonSize.Normal, ActionComponentIcon icon = null) { this.buttonSize = buttonSize; this.icon = icon; this.text = text; }
/// <summary> /// Creates a text action control style. /// </summary> /// <param name="text">Do not pass null.</param> /// <param name="icon">The icon.</param> public TextActionControlStyle(string text, ActionComponentIcon icon = null) { this.icon = icon; Text = text; }