public StatisticGraph(Control parent, SpriteFont font, Statistic statistic, TimeSpan accessInterval) : base(parent) { if (statistic == null) throw new ArgumentNullException("statistic"); if (accessInterval == TimeSpan.Zero) accessInterval = TimeSpan.FromMilliseconds(16); Strata = new ControlStrata() { Layer = Layer.Overlay }; _tracker = new StatisticTracker(statistic, accessInterval); _graph = new Graph(Device, (int)(15f / (float)accessInterval.TotalSeconds)); //(byte)MathHelper.Clamp(15f / (float)accessInterval.TotalSeconds, 15, 15 * 60)); _label = new Label(this, font) { Text = statistic.Name, Justification = Justification.Centre }; _label.SetPoint(Points.TopLeft, 2, 2); _label.SetPoint(Points.TopRight, -2, 2); _value = new Label(this, font) { Text = "0", Justification = Justification.Centre }; _value.SetPoint(Points.BottomLeft, 2, -2); _value.SetPoint(Points.BottomRight, -2, -2); _texture = new Texture2D(Device, 1, 1); _texture.SetData<Color>(new Color[] { new Color(0, 0, 0, 0.8f) }); SetSize(200, 120); }
public StatisticGraph(Control parent, SpriteFont font, Statistic statistic, TimeSpan accessInterval) : base(parent) { if (statistic == null) { throw new ArgumentNullException("statistic"); } if (accessInterval == TimeSpan.Zero) { accessInterval = TimeSpan.FromMilliseconds(16); } Strata = new ControlStrata() { Layer = Layer.Overlay }; tracker = new StatisticTracker(statistic, accessInterval); graph = new Graph(Device, (int)(15f / (float)accessInterval.TotalSeconds)); //(byte)MathHelper.Clamp(15f / (float)accessInterval.TotalSeconds, 15, 15 * 60)); label = new Label(this, font); label.Text = statistic.Name; label.Justification = Justification.Centre; label.SetPoint(Points.TopLeft, 2, 2); label.SetPoint(Points.TopRight, -2, 2); value = new Label(this, font); value.Text = "0"; value.Justification = Justification.Centre; value.SetPoint(Points.BottomLeft, 2, -2); value.SetPoint(Points.BottomRight, -2, -2); texture = new Texture2D(Device, 1, 1); texture.SetData <Color>(new Color[] { new Color(0, 0, 0, 0.8f) }); SetSize(200, 120); }
private void Initialise() { children = new List<Control>(); childrenReadOnly = new ReadOnlyCollection<Control>(children); focusedBy = new List<ActorFocus>(); focusedByReadOnly = new ReadOnlyCollection<ActorFocus>(focusedBy); Gestures = new GestureGroup(UserInterface); isVisible = true; LikesHavingFocus = true; FocusPriority = 100; if (Parent != null) { Parent.strataOffsetCount++; Strata = new ControlStrata() { Layer = Layer.Parent, Offset = Parent.Strata.Offset + Parent.strataOffsetCount }; Parent.AddChild(this); } else { Strata = new ControlStrata() { Layer = Layer.Medium, Offset = 0 }; } }
/// <summary> /// Initializes a new instance of the <see cref="CommandConsole"/> class. /// </summary> /// <param name="parent">The parent.</param> /// <param name="assemblies">The assemblies containing commands and options to add to this <see cref="CommandConsole"/> instance.</param> public CommandConsole(Game game, SpriteFont font, Control parent, params Assembly[] assemblies) : base(parent) { engine = new CommandEngine(assemblies); PresentationParameters pp = game.GraphicsDevice.PresentationParameters; SetSize(0, pp.BackBufferHeight / 3); SetPoint(Points.Top, 0, 5); SetPoint(Points.Left, 5, 0); SetPoint(Points.Right, -5, 0); Strata = new ControlStrata() { Layer = Layer.Overlay, Offset = 100 }; FocusPriority = int.MaxValue; LikesHavingFocus = false; IsVisible = false; RespectSafeArea = true; ToggleKey = Keys.Oem8; //var font = Content.Load<SpriteFont>(game, "Consolas"); //skin = Content.Load<Skin>(game, "Console"); //skin.BackgroundColour = new Color(1f, 1f, 1f, 0.8f); background = new Texture2D(game.GraphicsDevice, 1, 1); background.SetData(new Color[] { Color.Black }); textBox = new TextBox(this, game, font, "Command Console", "Enter you command"); textBox.SetPoint(Points.Bottom, 0, -3); textBox.SetPoint(Points.Left, 3, 0); textBox.SetPoint(Points.Right, -3, 0); textBox.FocusPriority = 1; textBox.FocusedChanged += c => { if (c.IsFocused) { textBox.BeginTyping(PlayerIndex.One); } }; textBox.IgnoredCharacters.Add('`'); log = new TextLog(this, font, (int)(3 * Area.Height / (float)font.LineSpacing)); log.SetPoint(Points.TopLeft, 3, 3); log.SetPoint(Points.TopRight, -3, 3); log.SetPoint(Points.Bottom, 0, 0, textBox, Points.Top); log.WriteLine("Hello world"); tabCompletion = new Label(this, font); tabCompletion.SetSize(300, 0); tabCompletion.SetPoint(Points.TopLeft, 3, 6, this, Points.BottomLeft); infoBox = new Label(this, font); infoBox.SetPoint(Points.TopRight, -3, 6, this, Points.BottomRight); AreaChanged += delegate(Frame c) { infoBox.SetSize(Math.Max(0, c.Area.Width - 311), 0); }; commandStack = new CommandStack(textBox, Gestures); #if WINDOWS ConsoleTraceListener cts = new ConsoleTraceListener(this); Listener = cts; Trace.Listeners.Add(cts); Engine.AddCommand(cts.RegexFilter, "AddFilter", "Console.Trace.AddFilter"); Engine.AddCommand(cts.RegexFilter, "ListFilters", "Console.Trace.ListFilters"); Engine.AddCommand(cts.RegexFilter, "RemoveAt", "Console.Trace.RemoveFilter"); #endif BindGestures(); Gestures.BlockedDevices.Add(typeof(KeyboardDevice)); }
/// <summary> /// Initializes a new instance of the <see cref="CommandConsole"/> class. /// </summary> /// <param name="font"></param> /// <param name="parent">The parent.</param> /// <param name="assemblies">The assemblies containing commands and options to add to this <see cref="CommandConsole"/> instance.</param> /// <param name="game"></param> public CommandConsole(Game game, SpriteFont font, Control parent, params Assembly[] assemblies) : base(parent) { _engine = new CommandEngine(assemblies); _writer = new ConsoleWriter(this); PresentationParameters pp = game.GraphicsDevice.PresentationParameters; SetSize(0, pp.BackBufferHeight / 3); SetPoint(Points.Top, 0, 5); SetPoint(Points.Left, 5, 0); SetPoint(Points.Right, -5, 0); Strata = new ControlStrata() { Layer = Layer.Overlay, Offset = 100 }; FocusPriority = int.MaxValue; LikesHavingFocus = false; IsVisible = false; RespectSafeArea = true; ToggleKey = Keys.Oem8; //var font = Content.Load<SpriteFont>(game, "Consolas"); //skin = Content.Load<Skin>(game, "Console"); //skin.BackgroundColour = new Color(1f, 1f, 1f, 0.8f); _background = new Texture2D(game.GraphicsDevice, 1, 1); _background.SetData(new Color[] { Color.Black }); _textBox = new TextBox(this, game, font, "Command Console", "Enter your command"); _textBox.SetPoint(Points.Bottom, 0, -3); _textBox.SetPoint(Points.Left, 3, 0); _textBox.SetPoint(Points.Right, -3, 0); _textBox.FocusPriority = 1; _textBox.FocusedChanged += c => { if (c.IsFocused) _textBox.BeginTyping(PlayerIndex.One); }; _textBox.IgnoredCharacters.Add('`'); _log = new TextLog(this, font, (int)(3 * Area.Height / (float)font.LineSpacing)); _log.SetPoint(Points.TopLeft, 3, 3); _log.SetPoint(Points.TopRight, -3, 3); _log.SetPoint(Points.Bottom, 0, 0, _textBox, Points.Top); _log.WriteLine("Hello world"); _tabCompletion = new Label(this, font); _tabCompletion.SetSize(300, 0); _tabCompletion.SetPoint(Points.TopLeft, 3, 6, this, Points.BottomLeft); _infoBox = new Label(this, font); _infoBox.SetPoint(Points.TopRight, -3, 6, this, Points.BottomRight); AreaChanged += c => _infoBox.SetSize(Math.Max(0, c.Area.Width - 311), 0); _commandStack = new CommandStack(_textBox, Gestures); BindGestures(); Gestures.BlockedDevices.Add(typeof(KeyboardDevice)); }