Esempio n. 1
0
 private void displayLog(string str)
 {
     Dispatcher.Invoke(() => {
         LogText.Text += str + '\n';
         LogText.ScrollToEnd();
     });
 }
Esempio n. 2
0
 public LogWindow(string path)
 {
     InitializeComponent();
     this.path = path;
     if (File.Exists(path))
     {
         LogText.Text = File.ReadAllText(path);
     }
     Loaded += (e, o) => LogText.ScrollToEnd();
 }
Esempio n. 3
0
        public MainWindow(MainWindowViewModel viewModel)
        {
            InitializeComponent();
            this.DataContext = viewModel;
            SetConfigurationMenu(viewModel);

            LogText.TextChanged += (sender, e) =>
            {
                LogText.ScrollToEnd();
            };
            KeyDown += (sender, e) =>
            {
                if (Keyboard.Modifiers == ModifierKeys.Control && e.Key == Key.W)
                {
                    this.Close();
                }
            };

            openingWindows.Add(this);
        }
Esempio n. 4
0
        private void appendLog(logging.logItem li)
        {
            //build the string
            Color     c = li.getColor();
            Paragraph p = new Paragraph();

            p.Inlines.Add(li.ToString());

            try
            {
                //TODO - new brush each time is probably shitty for perf.
                p.Foreground = new SolidColorBrush(c);
                LogText.Document.Blocks.Add(p);
                if (chkLockScroll.IsChecked.Value)
                {
                    LogText.ScrollToEnd();
                }
            }
            catch (FormatException) { }
        }
Esempio n. 5
0
 private void LogText_OnTextChanged(object sender, TextChangedEventArgs e)
 {
     LogText.ScrollToEnd();
 }
Esempio n. 6
0
 private void Page_Loaded(object sender, RoutedEventArgs e)
 {
     LogText.ScrollToEnd();
     br.LogRealtimeRefresh = true;
 }
Esempio n. 7
0
        private void NewLogEvent(Level level, string message)
        {
            var color  = Brushes.Gray;
            var weight = FontWeights.Normal;
            var style  = FontStyles.Italic;

            if (level == Level.Error)
            {
                color  = Brushes.Red;
                weight = FontWeights.Bold;
                style  = FontStyles.Normal;
            }
            else if (level == Level.Warn)
            {
                color  = Brushes.Orange;
                weight = FontWeights.Normal;
                style  = FontStyles.Normal;
            }
            else if (level == Level.Info)
            {
                color  = Brushes.Black;
                weight = FontWeights.Normal;
                style  = FontStyles.Normal;
            }

            dynamic logItem = new ExpandoObject();

            logItem.color   = color;
            logItem.weight  = weight;
            logItem.style   = style;
            logItem.message = message.Trim();

            _logList.Add(logItem);
            while (_logList.Count > MaxLogLines)
            {
                _logList.RemoveAt(0);
            }

            LogText.Dispatcher.Invoke(DispatcherPriority.Background, new Action(() =>
            {
                var paragraph = new Paragraph();
                foreach (var log in _logList)
                {
                    paragraph.Inlines.Add(new TextBlock
                    {
                        FontFamily = new FontFamily("Courier New"),
                        Margin     = new Thickness(0),
                        Foreground = log.color,
                        FontWeight = log.weight,
                        FontStyle  = log.style,
                        Text       = log.message
                    });
                    paragraph.Inlines.Add(new LineBreak());
                }

                var document = new FlowDocument(paragraph);

                LogText.Document = document;
                LogText.ScrollToEnd();
            }));
        }