Exemple #1
0
        public MainWindow()
        {
            InitializeComponent();

            var t = new WpfRtfLogTarget(txtLog);

            t.DefaultBackgroundColor = Colors.Black;
            t.DefaultForegroundColor = Colors.White;
            Log.AddTarget(t);
            Log.AllowAsynchronousWriting = false;

            Run            = new ControlledRun(true);
            Run.MmCreated += mm => {
                mm.AfterStep += ucTape.UpdateTapeVisualization;
                mm.AfterStep += x => Thread.Sleep(100);

                Dispatcher.Invoke((Action)(() => {
                    txtMachineInfo.Text =
                        mm.Definition.GetShortDefinitionString(null, null) + "\n" +
                        mm.Definition.GetLongDefinitionString(null).Replace("\n", "").Replace("\r", "");
                }));
            };

            tRun = new Thread(() => {
                Run.Run();
            })
            {
                IsBackground = true,
                Name         = "WPF TM Run thread",
            };
            tRun.Start();
        }
Exemple #2
0
		public MainWindow ()
		{
			InitializeComponent ();

			var t = new WpfRtfLogTarget (rtfBox);
			Log.AddTarget (t);
			Log.AllowAsynchronousWriting = false;

			/*
			 * Test basic WriteLine
			 */
			Log.WriteLine ("First line");

			/*
			 * Test combination of Write and empty WriteLine
			 */
			Log.Write ("Second line");
			Log.WriteLine ();
			Log.WriteLine ("Third line");

			/*
			 * Test foreground colors
			 */
			Log.Write ("Foreground: Black,");
			Log.ForegroundColor = ConsoleColor.Red;
			Log.Write ("Red,");
			Log.ForegroundColor = ConsoleColor.Green;
			Log.Write ("Green,");
			Log.ResetColor ();
			Log.Write ("(Reset),");
			Log.ForegroundColor = ConsoleColor.Blue;
			Log.Write ("Blue,");
			Log.ResetColor ();
			Log.Write ("(Reset),");
			Log.WriteLine ();

			/*
			 * Test background colors
			 */
			Log.Write ("Background: White,");
			Log.BackgroundColor = ConsoleColor.Red;
			Log.Write ("Red,");
			Log.BackgroundColor = ConsoleColor.Green;
			Log.Write ("Green,");
			Log.ResetColor ();
			Log.Write ("(Reset),");
			Log.BackgroundColor = ConsoleColor.Blue;
			Log.Write ("Blue,");
			Log.ResetColor ();
			Log.Write ("(Reset),");
			Log.WriteLine ();

			/*
			 * Test fore- and background colors
			 */
			Log.ForegroundColor = ConsoleColor.White;
			Log.BackgroundColor = ConsoleColor.Black;
			Log.WriteLine ("White on black");
			Log.ForegroundColor = ConsoleColor.Cyan;
			Log.BackgroundColor = ConsoleColor.Magenta;
			Log.WriteLine ("Cyan on magenta");
			Log.ResetColor ();

			/*
			 * Done!
			 */
			Log.WriteLine ("Test complete");
		}