public override void Initialize(ContentManager content, GraphicsDevice graphics) { // TODO: load your content here Height = (int)((Size.Y - 2 + 12) / (float)Font.LineSpacing) * Font.LineSpacing; area.Width = (int)Width; area.Height = (int)Height; backArea = area; pixel = new Texture2D(graphics, 1, 1); pixel.SetData <Color>(new Color[] { Color.White }); #region Init Scrollbars vScrollbar = new Scrollbar("vScrollbar", new Vector2(Position.X + Width - 13, Position.Y + 1), Scrollbar.Type.Vertical, Height - 14); vScrollbar.Owner = Owner; vScrollbar.Initialize(content, graphics); hScrollbar = new Scrollbar("hScrollbar", new Vector2(Position.X + 1, Position.Y + Height - 13), Scrollbar.Type.Horizontal, Width - 14); hScrollbar.Owner = Owner; hScrollbar.Initialize(content, graphics); #endregion spriteBatch = new SpriteBatch(graphics); renderTarget = new RenderTarget2D(graphics, area.Width - 2, area.Height - 2); capturedTexture = new Texture2D(graphics, area.Width - 2, area.Height - 2); base.Initialize(content, graphics); }
private void InitScrollbars(ContentManager content, GraphicsDevice graphics) { if (scrollbar == Scrollbars.Vertical) { vscrollbar = new Scrollbar("vscrollbar", Position + new Vector2(Width - 2, 1), xWinFormsLib.Scrollbar.Type.Vertical, (int)Height - 2); } else if (scrollbar == Scrollbars.Horizontal) { hscrollbar = new Scrollbar("hscrollbar", Position + new Vector2(1, Height - 2), xWinFormsLib.Scrollbar.Type.Horizontal, (int)Width - 2); } else if (scrollbar == Scrollbars.Both) { vscrollbar = new Scrollbar("vscrollbar", Position + new Vector2(Width - 13, 1), xWinFormsLib.Scrollbar.Type.Vertical, (int)Height - 14); hscrollbar = new Scrollbar("hscrollbar", Position + new Vector2(1, Height - 13), xWinFormsLib.Scrollbar.Type.Horizontal, (int)Width - 14); } if (vscrollbar != null) { vscrollbar.Owner = this.Owner; vscrollbar.OnChangeValue = vScrollbar_OnChangeValue; vscrollbar.Initialize(content, graphics); } if (hscrollbar != null) { hscrollbar.Owner = this.Owner; hscrollbar.OnChangeValue = hScrollbar_OnChangeValue; hscrollbar.Initialize(content, graphics); } }
private void InitScrollbars(ContentManager content, GraphicsDevice graphics) { if (vscrollbar != null && !vscrollbar.IsDisposed) { vscrollbar.Dispose(); } if (hscrollbar != null && !hscrollbar.IsDisposed) { hscrollbar.Dispose(); } #region initialize Horizontal scrollbar if (HorizontalScrollbar) { if (items.Count > visibleItems) { hscrollbar = new Scrollbar("hscrollbar", Position + new Vector2(1, Height - 13), Scrollbar.Type.Horizontal, (int)Width - 14); } else { hscrollbar = new Scrollbar("hscrollbar", Position + new Vector2(1, Height - 13), Scrollbar.Type.Horizontal, (int)Width - 2); } hscrollbar.Owner = this.Owner; hscrollbar.Initialize(content, graphics); } #endregion int vScrollbarHeight = 0; if (HorizontalScrollbar && hscrollbar.Visible && hscrollbar.Max > 0) { vScrollbarHeight = (int)Height - 14; } else { vScrollbarHeight = (int)Height - 2; } vscrollbar = new Scrollbar("vscrollbar", Position + new Vector2(Width - 13, 1), Scrollbar.Type.Vertical, vScrollbarHeight); vscrollbar.Owner = this.Owner; vscrollbar.Initialize(content, graphics); //vscrollbar.Visible = false; }
private void InitScrollbars(ContentManager content, GraphicsDevice graphics) { if (vscrollbar != null && !vscrollbar.IsDisposed) vscrollbar.Dispose(); if (hscrollbar != null && !hscrollbar.IsDisposed) hscrollbar.Dispose(); #region initialize Horizontal scrollbar if (HorizontalScrollbar) { if (items.Count > visibleItems) hscrollbar = new Scrollbar("hscrollbar", Position + new Vector2(1, Height - 13), Scrollbar.Type.Horizontal, (int)Width - 14); else hscrollbar = new Scrollbar("hscrollbar", Position + new Vector2(1, Height - 13), Scrollbar.Type.Horizontal, (int)Width - 2); hscrollbar.Owner = this.Owner; hscrollbar.Initialize(content, graphics); } #endregion int vScrollbarHeight = 0; if(HorizontalScrollbar && hscrollbar.Visible && hscrollbar.Max > 0) vScrollbarHeight = (int)Height - 14; else vScrollbarHeight = (int)Height - 2; vscrollbar = new Scrollbar("vscrollbar", Position + new Vector2(Width - 13, 1), Scrollbar.Type.Vertical, vScrollbarHeight); vscrollbar.Owner = this.Owner; vscrollbar.Initialize(content, graphics); //vscrollbar.Visible = false; }
public override void Initialize(ContentManager content, GraphicsDevice graphics) { // TODO: load your content here Height = (int)((Size.Y - 2 + 12) / (float)Font.LineSpacing) * Font.LineSpacing; area.Width = (int)Width; area.Height = (int)Height; backArea = area; pixel = new Texture2D(graphics, 1, 1); pixel.SetData<Color>(new Color[] { Color.White }); #region Init Scrollbars vScrollbar = new Scrollbar("vScrollbar", new Vector2(Position.X + Width - 13, Position.Y + 1), Scrollbar.Type.Vertical, Height - 14); vScrollbar.Owner = Owner; vScrollbar.Initialize(content, graphics); hScrollbar = new Scrollbar("hScrollbar", new Vector2(Position.X + 1, Position.Y + Height - 13), Scrollbar.Type.Horizontal, Width - 14); hScrollbar.Owner = Owner; hScrollbar.Initialize(content, graphics); #endregion spriteBatch = new SpriteBatch(graphics); renderTarget = new RenderTarget2D(graphics, area.Width - 2, area.Height - 2, 1, SurfaceFormat.Color); capturedTexture = new Texture2D(graphics, area.Width - 2, area.Height - 2); base.Initialize(content, graphics); }