public Menu(SpriteBatch spriteBatch, ContentManager content) : base(spriteBatch) { _panel = new Sprite(spriteBatch) { Texture = content.Load <Texture2D>("UI/yellow_panel") }; AddChild(_panel); _panel.Scale = 3.0f; _playButton = new Sprite(spriteBatch) { Texture = content.Load <Texture2D>("UI/blue_button00") }; AddChild(_playButton); _pressedTexture = content.Load <Texture2D>("UI/green_button00"); var text = new Label(spriteBatch) { Text = "PLAY", Font = Match3TextureManager.GetDefaultFont() }; _playButton.AddChild(text); var pressShape = new ShapeButton(spriteBatch); var halfSize = new Vector2(_playButton.Texture.Width * 0.5f, _playButton.Texture.Height * 0.5f); pressShape.ShapeRect = new RectangleF(-halfSize.X, -halfSize.Y, _playButton.Texture.Width, _playButton.Texture.Height); _playButton.AddChild(pressShape); pressShape.EventReleased += OnReleased; pressShape.EventPressed += OnPressed; }
static void Main() { // Ellipse button ShapeButton ellipseButton = new ShapeButton(); ellipseButton.Location = new Point(10, 10); ellipseButton.Size = new Size(80, 80); ellipseButton.DoPaint = delegate(PaintEventArgs e) { Graphics graphics = e.Graphics; SolidBrush brush1 = new SolidBrush(SystemColors.ButtonFace); graphics.FillRectangle(brush1, 0, 0, ellipseButton.Width, ellipseButton.Height); SolidBrush brush2 = new SolidBrush(Color.Red); graphics.FillEllipse(brush2, 0, 0, ellipseButton.Width, ellipseButton.Height); }; ellipseButton.Click += delegate(object sender, EventArgs e) { MessageBox.Show("Ellipse!"); }; // Triangle button ShapeButton triangleButton = new ShapeButton(); triangleButton.Location = new Point(100, 10); triangleButton.Size = new Size(80, 80); triangleButton.DoPaint = delegate(PaintEventArgs e) { Graphics graphics = e.Graphics; SolidBrush brush1 = new SolidBrush(SystemColors.ButtonFace); graphics.FillRectangle(brush1, 0, 0, triangleButton.Width, triangleButton.Height); SolidBrush brush2 = new SolidBrush(Color.Green); Point[] points = { new Point(triangleButton.Width / 2, 0), new Point(0, triangleButton.Height), new Point(triangleButton.Width, triangleButton.Height) }; graphics.FillPolygon(brush2, points); }; triangleButton.Click += delegate(object sender, EventArgs e) { MessageBox.Show("Triangle!"); }; // Star button (using image) Button starButton = new Button(); starButton.Location = new Point(190, 10); starButton.Size = new Size(80, 80); starButton.Image = new Bitmap("Star.png"); starButton.Click += delegate(object sender, EventArgs e) { MessageBox.Show("Star!"); }; // The form Form form = new Form(); form.Text = "Shape Button Test"; form.ClientSize = new Size(280, 100); form.Controls.Add(ellipseButton); form.Controls.Add(triangleButton); form.Controls.Add(starButton); form.ShowDialog(); }
internal void buildControl() { // 角色列表 roleListTree = new BaseTreeView(); roleListTree.BackColor = Color.Gray; this.Controls.Add(roleListTree); roleListTree.BorderStyle = BorderStyle.None; roleListTree.ItemHeight = 60; roleListTree.Font = new Font("宋体", 10); roleListTree.NodeMouseClick += roleListTree_NodeMouseClick; roleListTree.Invalidate(); // 添加 addRole = new ShapeButton(); this.Controls.Add(addRole); addRole.Text = "添加"; addRole.ForeColor = Color.White; addRole.Font = new Font("宋體", 13, FontStyle.Bold); removeRole = new ShapeButton(); this.Controls.Add(removeRole); removeRole.Text = "刪除"; removeRole.ForeColor = Color.White; removeRole.Font = new Font("宋體", 13, FontStyle.Bold); /////////功能列表 if (basePanel == null) { // 基础配置 basePanel = new Panel(); this.Controls.Add(basePanel); addSubControl(basePanel, "功能列表1"); } if (savePanel == null) { // 存储设置 savePanel = new Panel(); this.Controls.Add(savePanel); addSubControl(savePanel, "功能列表2"); } if (dbPanel == null) { // 数据配置 dbPanel = new Panel(); this.Controls.Add(dbPanel); addSubControl(dbPanel, "功能列表3"); } }
public void SelectSolid() { // GetComponent<Button>().Select(); if (SelectedButton == this) { SelectedButton = null; LevelManager.Current.ReadySolid = null; GetComponent <Image>().sprite = defaultSprite; } else { SelectedButton = this; LevelManager.Current.ReadySolid = solid; LevelManager.Current.DeleteMode = false; GetComponent <Image>().sprite = SelectedSprite; } }
public GameOver(SpriteBatch spriteBatch, ContentManager content, int score) : base(spriteBatch) { _panel = new Sprite(spriteBatch) { Texture = content.Load <Texture2D>("UI/red_panel") }; AddChild(_panel); _panel.Scale = 3.0f; _playButton = new Sprite(spriteBatch) { Texture = content.Load <Texture2D>("UI/yellow_button00") }; AddChild(_playButton); _pressedTexture = content.Load <Texture2D>("UI/red_button00"); var buttonLabel = new Label(spriteBatch) { Text = "OK", Font = Match3TextureManager.GetDefaultFont() }; _playButton.AddChild(buttonLabel); var scoreLabel = new Label(spriteBatch) { Text = $"You SCORE {score}", Font = Match3TextureManager.GetDefaultFont(), Position = new Vector2(0, -400f), Scale = 0.5f }; AddChild(scoreLabel); var pressShape = new ShapeButton(spriteBatch); var halfSize = new Vector2(_playButton.Texture.Width * 0.5f, _playButton.Texture.Height * 0.5f); pressShape.ShapeRect = new Rectangle((int)-halfSize.X, (int)-halfSize.Y, _playButton.Texture.Width, _playButton.Texture.Height); _playButton.AddChild(pressShape); pressShape.EventReleased += OnReleased; pressShape.EventPressed += OnPressed; }
public void buildControl() { // ! exportBtn = new ShapeButton(); exportBtn.Text = "导出"; this.Controls.Add(exportBtn); // searchBox = new SearchBox(); this.Controls.Add(searchBox); // addBtn = new ShapeButton(); addBtn.Text = "增加"; this.Controls.Add(addBtn); // deleBtn = new ShapeButton(); deleBtn.Text = "删除"; this.Controls.Add(deleBtn); // resetPassword = new ShapeButton(); resetPassword.Text = "重置密码"; this.Controls.Add(resetPassword); // customLv = new CXListView(); initListVHeader(customLv); this.Controls.Add(customLv); customLv.FullRowSelect = true; customLv.GridLines = true; // pagePanel = new PageSwitchPanel(); this.Controls.Add(pagePanel); }
public void Initialize(VisualButtonTestControl control) { // Setup initial conditions. shapeButton = control.shapeButton; imageButton = control.imageButton; // Setup sizes. shapeButton.SetSize(119, 119); imageButton.SetSize(119, 119); // Setup the image button. imageButton.Source = GetImage("Button.Default.png"); imageButton.DisabledSource = GetImage("Button.Disabled.png"); imageButton.OverSource = GetImage("Button.Over.png"); imageButton.DownSource = GetImage("Button.Down.png"); // Wire up events. shapeButton.Click += delegate { Output.Write(Colors.Orange, "!! CLICK: ShapeButton"); }; imageButton.Click += delegate { Output.Write(Colors.Orange, "!! CLICK: ImageButton"); }; // Finish up. Offsets__Down_Only(control); }