public ConsoleUi(string windowTitle) { var panel = new StackPanel(); _timeText = new Text(_arial14, windowTitle) { TextAlignment = TextAlignment.Right, VerticalAlignment = VerticalAlignment.Top, ForeColor = ColorUtility.ColorFromRGB(255, 255, 0) }; panel.Children.Add(_timeText); var scroll = new ScrollViewer { Height = SystemMetrics.ScreenHeight - _arial14.Height, Width = SystemMetrics.ScreenWidth, ScrollingStyle = ScrollingStyle.Last, Background = null, LineHeight = _small.Height }; panel.Children.Add(scroll); _log = new TextFlow { HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top }; scroll.Child = _log; Background = _solidBlack; Child = panel; }
public ListBox() { _panel = new StackPanel(); _scrollViewer = new ScrollViewer(); _scrollViewer.Child = _panel; this.LogicalChildren.Add(_scrollViewer); }
public Window CreateWindow() { // Create a window object and set its size to the // size of the display. mainWindow = new Window(); mainWindow.Height = SystemMetrics.ScreenHeight; mainWindow.Width = SystemMetrics.ScreenWidth; // Create a scrollviewer ScrollViewer scrollViewer = new ScrollViewer(); scrollViewer.Background = new SolidColorBrush(Colors.Gray); // scroll line by line with 10 pixels per line scrollViewer.ScrollingStyle = ScrollingStyle.LineByLine; scrollViewer.LineWidth = 10; scrollViewer.LineHeight = 10; // Create a canvas and add ellipse shapes Canvas canvas = new Canvas(); for (int x = 0; x <= 20; ++x) { for (int y = 0; y <= 20; ++y) { Ellipse ellipse = new Ellipse(10, 10); ellipse.Stroke = new Pen(Colors.White); canvas.Children.Add(ellipse); Canvas.SetLeft(ellipse, x * 30); Canvas.SetTop(ellipse, y * 30); } } //we need to set the size of a canvas explicitly //because it doesn´t calculate the desired size from its content canvas.Width = 20 * 30 + 10 * 2; canvas.Height = 20 * 30 + 10 * 2; scrollViewer.Child = canvas; // Add the scroll viewer to the window. mainWindow.Child = scrollViewer; // Set the window visibility to visible. mainWindow.Visibility = Visibility.Visible; // Attach the button focus to the scroll viewer // to be able to scroll with the up down right and left buttons Buttons.Focus(scrollViewer); return mainWindow; }
/// <summary> /// Constructs a TextScrollViewer using the specified text, font, and color. /// </summary> /// <param name="text"></param> /// <param name="font"></param> /// <param name="color"></param> public TextScrollViewer(string text, Font font, Color color) { // Create the ScrollViewer object. _viewer = new ScrollViewer(); // Create the ScrollText object using the parameters passed into the // constructor and then set other important member values. ScrollText = new ScrollerText(text, font, color); ScrollText.HorizontalAlignment = HorizontalAlignment.Left; ScrollText.VerticalAlignment = VerticalAlignment.Top; // Set the child of the viewer to be the ScrollText object. this._viewer.Child = ScrollText; // Hard code a line with and height based on the character 'A'. _viewer.LineWidth = font.CharWidth('A'); _viewer.LineHeight = font.Height; // Set the child of our class to be the ScrollViewer object. this.Children.Add(_viewer); }
object ScrollViewer_UpdateWindow(object obj) { scv = new ScrollViewer(); scv.Width = _scvWidth; scv.Height = _scvHeight; scv.Background = new SolidColorBrush(_scvBground); scv.LineHeight = _lineHeight; scv.LineWidth = _lineWidth; scv.HorizontalOffset = _hOffset; scv.VerticalOffset = _vOffset; scv.ScrollingStyle = _style; scv.VerticalAlignment = VerticalAlignment.Center; scv.HorizontalAlignment = HorizontalAlignment.Center; Canvas _canvas = new Canvas(); _canvas.Width = _canWidth; _canvas.Height = _canHeight; _canvas.VerticalAlignment = VerticalAlignment.Top; _canvas.HorizontalAlignment = HorizontalAlignment.Left; //Adding child elt to Canvas _rect = new Rectangle(); _rect.Width = _rectW; _rect.Height = _rectH; _rect.Fill = new SolidColorBrush(_color); _canvas.Children.Add(_rect); Canvas.SetTop(_rect, cTop); Canvas.SetLeft(_rect, cLeft); //Adding the StackPanel to ScrollViewer scv.Child = _canvas; if (_lineDown) { for (int i = 0; i < scrollCount; i++) { scv.LineDown(); } } if (_lineUp) { for (int i = 0; i < scrollCount; i++) { scv.LineUp(); } } if (_lineRight) { for (int i = 0; i < scrollCount; i++) { scv.LineRight(); } } if (_lineLeft) { for (int i = 0; i < scrollCount; i++) { scv.LineLeft(); } } //Adding the ScrollViewer to the Window mainWindow.Child = scv; _getHOffset = scv.HorizontalOffset; _getVOffset = scv.VerticalOffset; _getLineHeight = scv.LineHeight; _getLineWidth = scv.LineWidth; return null; }