Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Console.SetCursorPosition(x, y);
- tb.Clear();
- string s = "";
- for (int i = 0; i < mh; i++)
- {
- for (int j = 0; j < mw; j++)
- {
- s += MatrixArray[i, j];
- }
- s += "n";
- tb.Text += s;
- }
- public static void MatrixStep(int width, int height, int[] y, int[] l)
- {
- int x;
- thistime = !thistime;
- for (x = 0; x < width; ++x)
- {
- if (x % 11 == 10)
- {
- if (!thistime)
- continue;
- Console.ForegroundColor = ConsoleColor.White;
- }
- else
- {
- Console.ForegroundColor = ConsoleColor.DarkGreen;
- Console.SetCursorPosition(x, inBoxY(y[x] - 2 - (l[x] / 40 * 2), height));
- Console.Write(R);
- Console.ForegroundColor = ConsoleColor.Green;
- }
- Console.SetCursorPosition(x, y[x]);
- Console.Write(R);
- y[x] = inBoxY(y[x] + 1, height);
- Console.SetCursorPosition(x, inBoxY(y[x] - l[x], height));
- Console.Write(' '); // Основной фоновый символ в потоке
- }
- private void PrintMatrix(int x, int y, char r)
- {
- this.Dispatcher.Invoke((Action)(() =>
- {
- AddText(x, y, r);
- foreach (object myCanvasChild in cConsole.Children)
- {
- var tb = myCanvasChild as TextBlock;
- if (tb == null) return;
- var top = (double)tb.GetValue(Canvas.TopProperty);
- Canvas.SetTop(tb, top);
- }
- }));
- }
- private void AddText(int x, int y, char r)
- {
- Rectangle rct = new Rectangle();
- rct.Fill = Brushes.Black;
- rct.Height = 19;
- rct.Width = 17;
- Canvas.SetTop(rct, 21 * x + 4);
- Canvas.SetLeft(rct, 18 * y);
- cConsole.Children.Add(rct);
- var txt = new TextBlock
- {
- Text = r.ToString(),
- Foreground = tc,
- FontSize = 18,
- FontWeight = FontWeights.Bold,
- FontFamily = new FontFamily("Courier New")
- };
- Canvas.SetTop(txt, 21 * x + 5);
- Canvas.SetLeft(txt, 18 * y + 3);
- cConsole.Children.Add(txt);
- }
- using System;
- using System.Threading;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Media;
- namespace matrix
- {
- /// <summary>
- /// Interaction logic for MainWindow.xaml
- /// </summary>
- public partial class MainWindow : Window
- {
- private readonly Random rnd = new Random();
- public MainWindow()
- {
- InitializeComponent();
- Task.Factory.StartNew(()=>
- {
- while (true)
- {
- Application.Current.Dispatcher.Invoke(()=>
- {
- AddText();
- foreach (object myCanvasChild in MyCanvas.Children)
- {
- var tb = myCanvasChild as TextBlock;
- if (tb == null) return;
- var top = (double) tb.GetValue(Canvas.TopProperty);
- Canvas.SetTop(tb, top + 50);
- }
- });
- Thread.Sleep(TimeSpan.FromMilliseconds(300));
- }
- });
- }
- private void AddText()
- {
- var txt = new TextBlock
- {
- Text = $"some message value ={rnd.Next()}",
- Foreground = new SolidColorBrush(Colors.Green)
- };
- Canvas.SetTop(txt, 0);
- MyCanvas.Children.Add(txt);
- }
- }
- }
- <Window x:Class="matrix.MainWindow"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- mc:Ignorable="d"
- Title="MainWindow" Height="350" Width="525">
- <Canvas Name="MyCanvas">
- </Canvas>
Add Comment
Please, Sign In to add comment