public Menu( [NotNull] string name, [NotNull] IEnumerable <IMenuGroup> groups, string text, string image, string description, MenuItemDisplayStyle displayStyle, int orderIndex) : base(text, image, description, displayStyle, orderIndex) { if (name == null) { throw new ArgumentNullException("name"); } if (!MenuNamesValidator.IsValidMenuName(name)) { throw new ArgumentException(@"Аргумент имеет некорректный формат.", "name"); } if (groups == null) { throw new ArgumentNullException("groups"); } _name = name; _groups = groups.ToArray().AsReadOnly(); }
private static ToolStripItemDisplayStyle GetDisplayStyle( MenuItemDisplayStyle displayStyle, bool image, TargetMenuType menuType) { switch (displayStyle) { case MenuItemDisplayStyle.Default: return(menuType == TargetMenuType.Toolbar ? image ? ToolStripItemDisplayStyle.Image : ToolStripItemDisplayStyle.Text : ToolStripItemDisplayStyle.ImageAndText); case MenuItemDisplayStyle.Text: return(ToolStripItemDisplayStyle.Text); case MenuItemDisplayStyle.Image: return(ToolStripItemDisplayStyle.Image); case MenuItemDisplayStyle.TextAndImage: return(ToolStripItemDisplayStyle.ImageAndText); } throw new ApplicationException(); }
protected MenuItemWithTextAndImage( string text, string image, string description, MenuItemDisplayStyle displayStyle, int orderIndex) : base(orderIndex) { _text = text; _image = image; _description = description; _displayStyle = displayStyle; }
public MenuCheckCommand( [NotNull] string checkStateName, [NotNull] string checkCommandName, [NotNull] IDictionary <string, object> checkCommandParameters, [NotNull] string uncheckCommandName, [NotNull] IDictionary <string, object> uncheckCommandParameters, string text, string image, string description, MenuItemDisplayStyle displayStyle, int orderIndex) : base(text, image, description, displayStyle, orderIndex) { if (string.IsNullOrEmpty(checkStateName)) { throw new ArgumentException( "Аргумент не должен быть null или пустой строкой.", "checkStateName"); } if (checkCommandName == null) { throw new ArgumentNullException("checkCommandName"); } if (checkCommandParameters == null) { throw new ArgumentNullException("checkCommandParameters"); } if (uncheckCommandName == null) { throw new ArgumentNullException("uncheckCommandName"); } if (uncheckCommandParameters == null) { throw new ArgumentNullException("uncheckCommandParameters"); } _checkStateName = checkStateName; _checkCommandName = checkCommandName; _checkCommandParameters = new Dictionary <string, object>( checkCommandParameters, StringComparer.OrdinalIgnoreCase).AsReadOnly(); _uncheckCommandName = uncheckCommandName; _uncheckCommandParameters = new Dictionary <string, object>( uncheckCommandParameters, StringComparer.OrdinalIgnoreCase).AsReadOnly(); }
public MenuCommand( [NotNull] string commandName, [NotNull] IDictionary <string, object> parameters, string text, string image, string description, MenuItemDisplayStyle displayStyle, int orderIndex) : base(text, image, description, displayStyle, orderIndex) { if (commandName == null) { throw new ArgumentNullException("commandName"); } if (parameters == null) { throw new ArgumentNullException("parameters"); } _commandName = commandName; _parameters = new Dictionary <string, object>( parameters, StringComparer.OrdinalIgnoreCase).AsReadOnly(); }