public SystemMenuManager(Form target, bool movePresent, MenuItemState closeState) { this.target = target; this.closeState = closeState; this.target.Load += new EventHandler(target_Load); this.target.Resize += new EventHandler(target_Resize); this.target.KeyDown += new KeyEventHandler(target_KeyDown); this.menuHandle = GetSystemMenu(target.Handle, false); if (!movePresent) { // Remove the Move menu item. DeleteMenu(this.menuHandle, SC_MOVE, MF_BYCOMMAND); } if (closeState == MenuItemState.Removed) { // Remove the Close menu item. DeleteMenu(this.menuHandle, SC_CLOSE, MF_BYCOMMAND); } else { this.RefreshCloseItem(); } if (closeState != MenuItemState.Enabled) { // Set the Keypreview to True so that the Alt+F4 key combination can be detected. target.KeyPreview = true; } }
/// <summary> /// 执行对应的事件 /// </summary> public void Operate() { State = MenuItemState.Pressed; if (OperateEvent != null) { OperateEvent(this, null); } }
public MenuItem(string name, double price, uint quantity, string ingredients, string allergens, MenuItemState menuItemState) { Name = name; Price = price; Quantity = quantity; Ingredients = ingredients; Allergens = allergens; MenuItemState = menuItemState; }
public CreateMenuItemCmd(Menu menu, string name, double price, uint quantity, string ingredients, string allergens, MenuItemState menuItemState) { Menu = menu; Name = name; Price = price; Quantity = quantity; Ingredients = ingredients; Allergens = allergens; MenuItemState = menuItemState; }
private void stateChanged(MenuItemState newState) { if (newState == MenuItemState.Selected) { background.Expand(); } else { background.Contract(); } }
/// <summary> /// 刷新自己 /// </summary> /// <param name="gameTime">游戏现在的时间</param> public virtual void Update(GameTime gameTime) { if (IsSelected) { this.State = MenuItemState.Selected; } else { this.State = MenuItemState.Normal; } }
public void least_method_with_data() { MenuItemState.Least(MenuItemState.Available).ShouldEqual(MenuItemState.Available); MenuItemState.Least(MenuItemState.Hidden).ShouldEqual(MenuItemState.Hidden); MenuItemState.Least(MenuItemState.Disabled).ShouldEqual(MenuItemState.Disabled); MenuItemState.Least(MenuItemState.Hidden, MenuItemState.Available).ShouldEqual(MenuItemState.Hidden); MenuItemState.Least(MenuItemState.Hidden, MenuItemState.Available, MenuItemState.Disabled).ShouldEqual(MenuItemState.Hidden); MenuItemState.Least(MenuItemState.Disabled, MenuItemState.Available).ShouldEqual(MenuItemState.Disabled); MenuItemState.Least(MenuItemState.Hidden, MenuItemState.Disabled).ShouldEqual(MenuItemState.Hidden); }
private void switchState(MenuItemState state) { _state = state; _timeline = -1; switch (_state) { case MenuItemState.FadeIn: _inactiveAlpha = 0; _activeAlpha = 0; break; } }
private void itemStateChanged(DrawableMenuItem item, MenuItemState state) { if (state != MenuItemState.Selected) { return; } if (item != selectedItem && selectedItem != null) { selectedItem.State = MenuItemState.NotSelected; } selectedItem = item; }
void ChangeState(MenuItemState p_state) { if (!IsEnabled) { VisualStateManager.GoToState(this, "Disabled", true); } else if (IsSubmenuOpen) { VisualStateManager.GoToState(this, "Pressed", true); } else { VisualStateManager.GoToState(this, p_state.ToString(), true); } }
/// <summary> /// 生成一个MenuItem实例 /// </summary> /// <param name="patternto">图像需要的基本Texture2D实例</param> /// <param name="eventto">所对应的事件</param> /// <param name="positionto">MenuItem的位置。在Menu中为Menu左上角坐标的相对位置。</param> /// <param name="Sizeto">MenuItem的大小。</param> /// <param name="IntroDuctto">该MenuItem的文字介绍,可根据自己喜好填写,可用于显示详细信息。</param> public MenuItem(Texture2D patternto, EventHandler eventto, Vector2 positionto, Vector2 Sizeto, string IntroDuctto) { basicPattern = patternto; Position = positionto; Size = Sizeto; IsAvaliable = true; IsSelected = false; State = MenuItemState.Normal; neighbourItem = new MenuItem[5]; //下面这条应该移动到更合适的地方 DefaultOperateEvent = new EventHandler(nullEvent); if (eventto != null) { OperateEvent = new EventHandler(eventto); } else { OperateEvent = new EventHandler(DefaultOperateEvent); } intro = IntroDuctto; }
public SystemMenuManager(Form target, MenuItemState closeState) : this(target, true, closeState) { }
public void FadeOut() { _state = MenuItemState.FadeOut; }
/// <summary> /// Sets the <see cref="Menu.DrawableMenuItem"/> <see cref="Menu.DrawableMenuItem.State"/> at the specified index to a specified state. /// </summary> /// <param name="index">The index of the <see cref="Menu.DrawableMenuItem"/> to set the state of.</param> /// <param name="state">The state to be set.</param> public void SetSelectedState(int index, MenuItemState state) { var item = GetMenuItems()[index]; item.GetType().GetProperty("State")?.SetValue(item, state); }
public static IO <CreateMenuItemResult.ICreateMenuItemResult> CreateMenuItem(Menu menu, string name, double price, uint quantity, string ingredients, string allergens, MenuItemState menuItemState) => NewIO <CreateMenuItemCmd, CreateMenuItemResult.ICreateMenuItemResult>(new CreateMenuItemCmd(menu, name, price, quantity, ingredients, allergens, menuItemState));
internal void DrawApplicationMenuItem(Context cr, Rectangle bodyAllocation, MenuItemState state, double roundSize, double lineWidth, double arrowSize, double arrowPadding, bool drawSeparator, ApplicationMenuItem widget) { double lineWidth05 = lineWidth / 2; double lineWidth15 = lineWidth05 * 3; double separatorX = bodyAllocation.X + bodyAllocation.Width - 2 * lineWidth - arrowSize - 2 * arrowPadding; cr.LineWidth = lineWidth; if(state != MenuItemState.Default) { LinearGradient bodyPattern, innerBorderPattern; Color borderColor; bodyPattern = new LinearGradient (bodyAllocation.X, bodyAllocation.Y, bodyAllocation.X, bodyAllocation.Y + bodyAllocation.Height); bodyPattern.AddColorStopRgb (0.0, new Color (1, 0.996, 0.890)); bodyPattern.AddColorStopRgb (0.37, new Color (1, 0.906, 0.592)); bodyPattern.AddColorStopRgb (0.43, new Color (1, 0.843, 0.314)); bodyPattern.AddColorStopRgb (1.0, new Color (1, 0.906, 0.588)); innerBorderPattern = new LinearGradient (bodyAllocation.X, bodyAllocation.Y, bodyAllocation.X + bodyAllocation.Width, bodyAllocation.Y + bodyAllocation.Height); innerBorderPattern.AddColorStop (0.0, new Color (1, 1, 0.969, 1)); innerBorderPattern.AddColorStop (1.0, new Color (1, 1, 0.969, 0)); borderColor = new Color (0.824, 0.753, 0.553); double x0 = bodyAllocation.X + lineWidth05, y0 = bodyAllocation.Y + lineWidth05; double x1 = bodyAllocation.X + bodyAllocation.Width - lineWidth05, y1 = bodyAllocation.Y + bodyAllocation.Height - lineWidth05; cr.MoveTo (x0 + roundSize, y0); cr.Arc (x1 - roundSize, y0 + roundSize, roundSize, 1.5*Math.PI, 0); cr.Arc (x1 - roundSize, y1 - roundSize, roundSize, 0, 0.5*Math.PI); cr.Arc (x0 + roundSize, y1 - roundSize, roundSize, 0.5*Math.PI, Math.PI); cr.Arc (x0 + roundSize, y0 + roundSize, roundSize, Math.PI, 1.5*Math.PI); cr.Pattern = bodyPattern; cr.Fill (); bodyPattern.Destroy (); if(state == MenuItemState.HilightAction) { cr.Color = new Color (1, 1, 1, 0.7); cr.MoveTo (x0 + roundSize, y0); cr.LineTo (separatorX, y0); cr.LineTo (separatorX, y1); cr.Arc (x0 + roundSize, y1 - roundSize, roundSize, 0.5*Math.PI, Math.PI); cr.Arc (x0 + roundSize, y0 + roundSize, roundSize, Math.PI, 1.5*Math.PI); cr.Fill (); } else if(state == MenuItemState.HilightMenu) { cr.Color = new Color (1, 1, 1, 0.7); cr.MoveTo (separatorX, y0); cr.Arc (x1 - roundSize, y0 + roundSize, roundSize, 1.5*Math.PI, 0); cr.Arc (x1 - roundSize, y1 - roundSize, roundSize, 0, 0.5*Math.PI); cr.LineTo (separatorX, y1); cr.LineTo (separatorX, y0); cr.Fill (); } x0 = bodyAllocation.X + lineWidth15; y0 = bodyAllocation.Y + lineWidth15; x1 = bodyAllocation.X + bodyAllocation.Width - lineWidth15; y1 = bodyAllocation.Y + bodyAllocation.Height - lineWidth15; double roundSizeMinusLineWidth = roundSize - lineWidth; x0 -= lineWidth; cr.MoveTo (x0 + roundSizeMinusLineWidth, y0); cr.Arc (x1 - roundSizeMinusLineWidth, y0 + roundSizeMinusLineWidth, roundSizeMinusLineWidth, 1.5*Math.PI, 0); cr.Arc (x1 - roundSizeMinusLineWidth, y1 - roundSizeMinusLineWidth, roundSizeMinusLineWidth, 0, 0.5*Math.PI); cr.Arc (x0 + roundSizeMinusLineWidth, y1 - roundSizeMinusLineWidth, roundSizeMinusLineWidth, 0.5*Math.PI, Math.PI); cr.Arc (x0 + roundSizeMinusLineWidth, y0 + roundSizeMinusLineWidth, roundSizeMinusLineWidth, Math.PI, 1.5*Math.PI); x0 += lineWidth; cr.Pattern = innerBorderPattern; cr.Stroke (); innerBorderPattern.Destroy (); x0 = bodyAllocation.X + lineWidth05; y0 = bodyAllocation.Y + lineWidth05; x1 = bodyAllocation.X + bodyAllocation.Width - lineWidth05; y1 = bodyAllocation.Y + bodyAllocation.Height - lineWidth05; cr.MoveTo (x0 + roundSize, y0); cr.Arc (x1 - roundSize, y0 + roundSize, roundSize, 1.5*Math.PI, 0); cr.Arc (x1 - roundSize, y1 - roundSize, roundSize, 0, 0.5*Math.PI); cr.Arc (x0 + roundSize, y1 - roundSize, roundSize, 0.5*Math.PI, Math.PI); cr.Color = borderColor; cr.Stroke (); } if(arrowSize > 0) { double x, y; x = separatorX; y = bodyAllocation.Y + (bodyAllocation.Height - arrowSize) / 2.0; if(drawSeparator) { double top = bodyAllocation.Y + 2 * lineWidth, bottom = bodyAllocation.Y + bodyAllocation.Height - 2 * lineWidth; cr.MoveTo (x - lineWidth / 2, top); cr.LineTo (x - lineWidth / 2, bottom); cr.Color = new Color (0, 0, 0, 0.1); cr.Stroke (); cr.MoveTo (x + lineWidth / 2, top); cr.LineTo (x + lineWidth / 2, bottom); cr.Color = new Color (1, 1, 1, 0.6); cr.Stroke (); } x += arrowSize / 4.0 + lineWidth / 2.0; cr.MoveTo (x, y); cr.LineTo (x, y + arrowSize); cr.LineTo (x + arrowSize / 2.0, y + arrowSize / 2.0); cr.LineTo (x, y); cr.Color = new Color (0, 0, 0); cr.Fill (); } }
public void least_method_empty_is_available() { MenuItemState.Least().ShouldEqual(MenuItemState.Available); }