internal static MenuItem GetMenuItem(String name, Bitmap bitmap) { MenuItem menuItem = new MenuItem(name); menuItem.SetStyle(StyleFactory.GetMenuItemStyle()); menuItem.SetTextMargin(new Indents(25, 0, 0, 0)); // Optionally: set an event on click menuItem.EventMouseClick += (sender, args) => { PopUpMessage popUpInfo = new PopUpMessage("You choosed a function:\n" + menuItem.GetText()); popUpInfo.SetStyle(StyleFactory.GetBluePopUpStyle()); popUpInfo.SetTimeOut(2000); popUpInfo.Show(menuItem.GetHandler()); }; // Optionally: add an image into MenuItem ImageItem img = new ImageItem(bitmap, false); img.SetSizePolicy(SizePolicy.Fixed, SizePolicy.Fixed); img.SetSize(20, 20); img.SetAlignment(ItemAlignment.Left, ItemAlignment.VCenter); img.KeepAspectRatio(true); menuItem.AddItem(img); // Optionally: add a button into MenuItem ButtonCore infoBtn = new ButtonCore("?"); infoBtn.SetBackground(40, 40, 40); infoBtn.SetWidth(20); infoBtn.SetSizePolicy(SizePolicy.Fixed, SizePolicy.Expand); infoBtn.SetFontStyle(FontStyle.Bold); infoBtn.SetForeground(210, 210, 210); infoBtn.SetAlignment(ItemAlignment.VCenter, ItemAlignment.Right); infoBtn.SetMargin(0, 0, 10, 0); infoBtn.SetBorderRadius(3); infoBtn.AddItemState(ItemStateType.Hovered, new ItemState(Color.FromArgb(0, 140, 210))); infoBtn.SetPassEvents(false, InputEventType.MousePress, InputEventType.MouseRelease, InputEventType.MouseDoubleClick); infoBtn.IsFocusable = false; // prevent focus this button infoBtn.EventMouseClick += (sender, args) => { PopUpMessage popUpInfo = new PopUpMessage("This is decorated MenuItem:\n" + menuItem.GetText()); popUpInfo.SetStyle(StyleFactory.GetDarkPopUpStyle()); popUpInfo.SetTimeOut(2000); popUpInfo.Show(infoBtn.GetHandler()); }; menuItem.AddItem(infoBtn); return(menuItem); }
public override void InitElements() { ImageItem _race = new ImageItem(DefaultsService.GetDefaultImage( EmbeddedImage.User, EmbeddedImageSize.Size32x32), false); _race.KeepAspectRatio(true); _race.SetWidthPolicy(SizePolicy.Fixed); _race.SetWidth(20); _race.SetAlignment(ItemAlignment.Left, ItemAlignment.VCenter); switch (_characterInfo.Race) { case CharacterRace.Human: _race.SetColorOverlay(Color.FromArgb(0, 162, 232)); break; case CharacterRace.Elf: _race.SetColorOverlay(Color.FromArgb(35, 201, 109)); break; case CharacterRace.Dwarf: _race.SetColorOverlay(Color.FromArgb(255, 127, 39)); break; } _name.SetMargin(30, 0, 30, 0); ButtonCore infoBtn = new ButtonCore("?"); infoBtn.SetBackground(Color.FromArgb(255, 40, 40, 40)); infoBtn.SetWidth(20); infoBtn.SetSizePolicy(SizePolicy.Fixed, SizePolicy.Expand); infoBtn.SetFontStyle(FontStyle.Bold); infoBtn.SetForeground(210, 210, 210); infoBtn.SetAlignment(ItemAlignment.VCenter, ItemAlignment.Right); infoBtn.SetMargin(0, 0, 20, 0); infoBtn.AddItemState(ItemStateType.Hovered, new ItemState(Color.FromArgb(0, 140, 210))); infoBtn.SetPassEvents(false); infoBtn.EventMouseHover += (sender, args) => { SetMouseHover(true); }; infoBtn.EventMouseClick += (sender, args) => { ImageItem race = new ImageItem(DefaultsService.GetDefaultImage(EmbeddedImage.User, EmbeddedImageSize.Size32x32), false); race.SetSizePolicy(SizePolicy.Fixed, SizePolicy.Fixed); race.SetSize(32, 32); race.SetAlignment(ItemAlignment.Left, ItemAlignment.Top); race.SetColorOverlay(_race.GetColorOverlay()); PopUpMessage popUpInfo = new PopUpMessage( _characterInfo.Name + "\n" + "Age: " + _characterInfo.Age + "\n" + "Sex: " + _characterInfo.Sex + "\n" + "Race: " + _characterInfo.Race + "\n" + "Class: " + _characterInfo.Class ); popUpInfo.SetTimeOut(3000); popUpInfo.SetHeight(200); popUpInfo.Show(GetHandler()); popUpInfo.AddItem(race); }; //close ButtonCore removeBtn = new ButtonCore(); removeBtn.SetBackground(Color.FromArgb(255, 40, 40, 40)); removeBtn.SetSizePolicy(SizePolicy.Fixed, SizePolicy.Fixed); removeBtn.SetSize(10, 10); removeBtn.SetAlignment(ItemAlignment.VCenter, ItemAlignment.Right); removeBtn.SetCustomFigure(new CustomFigure(false, GraphicsMathService.GetCross(10, 10, 2, 45))); removeBtn.AddItemState(ItemStateType.Hovered, new ItemState(Color.FromArgb(200, 95, 97))); //close event removeBtn.EventMouseClick += (sender, args) => { RemoveSelf(); }; //adding AddItems(_race, _name, infoBtn, removeBtn); }
public override void InitElements() { _palette.SetPassEvents(false); _palette.SetItemName("Palette"); _palette.SetAlignment(ItemAlignment.Right | ItemAlignment.Top); _palette.SetMargin(0, 40, 0, 0); _palette.SetSize(16, 15); _palette.SetBackground(255, 128, 128); _palette.SetBorderRadius(new CornerRadius(3)); CustomShape arrow = new CustomShape(); arrow.SetTriangles(GraphicsMathService.GetTriangle(angle: 180)); arrow.SetBackground(50, 50, 50); arrow.SetSize(14, 6); arrow.SetMargin(0, 1, 0, 0); arrow.SetSizePolicy(SizePolicy.Fixed, SizePolicy.Fixed); arrow.SetAlignment(ItemAlignment.HCenter | ItemAlignment.VCenter); _lock.SetAlignment(ItemAlignment.Left | ItemAlignment.Top); _lock.SetSize(16, 16); _lock.SetBorderRadius(new CornerRadius(8)); _lock.EventToggle += (sender, args) => { IsLocked = !IsLocked; _text.SetEditable(!_text.IsEditable()); _btn_close.SetDisabled(!_btn_close.IsDisabled()); }; VerticalScrollBar vs = _text.VScrollBar; vs.Slider.Handler.RemoveAllItemStates(); vs.SetArrowsVisible(false); vs.SetBackground(Color.Transparent); vs.SetPadding(0, 2, 0, 2); vs.Slider.Track.SetBackground(Color.Transparent); vs.Slider.Handler.SetBorderRadius(new CornerRadius(3)); vs.Slider.Handler.SetBackground(80, 80, 80, 255); vs.Slider.Handler.SetMargin(new Indents(5, 0, 5, 0)); _text.SetBorderRadius(new CornerRadius(3)); _text.SetHScrollBarPolicy(VisibilityPolicy.Never); _text.SetHeight(25); _text.SetAlignment(ItemAlignment.Left | ItemAlignment.Bottom); _text.SetBackground(151, 203, 255); _text.SetMargin(0, 60, 0, 0); _note.SetForeground(180, 180, 180); _note.SetHeight(25); _note.SetAlignment(ItemAlignment.Left | ItemAlignment.Top); _note.SetTextAlignment(ItemAlignment.VCenter | ItemAlignment.Left); _note.SetSizePolicy(SizePolicy.Expand, SizePolicy.Fixed); _note.SetText("Add a Note:"); _note.SetMargin(0, 30, 0, 0); _btn_close = new ButtonCore(); _btn_close.SetBackground(Color.FromArgb(255, 100, 100, 100)); _btn_close.SetItemName("Close_" + GetItemName()); _btn_close.SetSize(10, 10); _btn_close.SetMargin(0, 0, 0, 0); _btn_close.SetSizePolicy(SizePolicy.Fixed, SizePolicy.Fixed); _btn_close.SetAlignment(ItemAlignment.Top | ItemAlignment.Right); _btn_close.AddItemState(ItemStateType.Hovered, new ItemState() { Background = Color.FromArgb(125, 255, 255, 255) }); _btn_close.SetCustomFigure(new Figure(false, GraphicsMathService.GetCross(10, 10, 3, 45))); _btn_close.EventMouseClick += (sender, args) => { Dispose(); }; AddItems(_lock, _note, _text, _palette, _btn_close); _palette.AddItem(arrow); _palette_menu = new ContextMenu(GetHandler()); _palette_menu.SetBorderRadius(5); _palette_menu.SetBorderThickness(1); _palette_menu.SetBorderFill(32, 32, 32); _palette_menu.SetBackground(60, 60, 60); _palette_menu.SetWidth(100); _palette_menu.ItemList.SetSelectionVisible(false); _palette_menu.ActiveButton = MouseButton.ButtonLeft; MenuItem red = InfinityItemsBox.GetMenuItem("Red"); red.EventMouseClick += (sender, args) => { _text.SetBackground(255, 196, 196); }; MenuItem green = InfinityItemsBox.GetMenuItem("Green"); green.EventMouseClick += (sender, args) => { _text.SetBackground(138, 255, 180); }; MenuItem blue = InfinityItemsBox.GetMenuItem("Blue"); blue.EventMouseClick += (sender, args) => { _text.SetBackground(151, 203, 255); }; MenuItem yellow = InfinityItemsBox.GetMenuItem("Yellow"); yellow.EventMouseClick += (sender, args) => { _text.SetBackground(234, 232, 162); }; _palette_menu.AddItems(red, green, blue, yellow); //mouse click to show palette _palette.EventMouseClick += (_, x) => _palette_menu.Show(_, x); }