protected void WriteLineToLogBox(string text, bool setTitle = false, Brush color = null)
        {
            if (setTitle)
            {
                ProgressText.Text = text;
            }
            Paragraph p = new Paragraph();

            if (setTitle)
            {
                p.Foreground = Brushes.Blue;
                p.FontSize  += 4;
            }
            else
            {
                if (color == null)
                {
                    p.Foreground = Brushes.Black;
                }
                else
                {
                    p.Foreground = color;
                }
            }
            p.Margin = new Thickness(0);

            p.Inlines.Add(text);
            LogBox.Document.Blocks.Add(p);
            LogBox.ScrollToEnd();
        }
        void Discovery_Connect(DiscoveryCompleteEventArgs e)
        {
            //var reference = e.Reference;

            //foreach (var warning in reference.Warnings) logger.Warn(warning);
            //foreach (var error in reference.Errors) logger.Error(error);

            //if (reference.HasErrors)
            //    logger.Write("Cannot create a connection.");
            //else
            //{
            logger.Write("Click \"Next\" to continue.");

            //    var reset = string.IsNullOrEmpty(Model.BindingName) ||
            //        !reference.Bindings.Any(b => b.Name == Model.BindingName);
            //    if (reset)
            //    {
            //        Model.BindingName = reference.Bindings.Count > 0
            //            ? reference.Bindings[0].Name : "";
            //    }

            //    BindingBox.ItemsSource = reference.Bindings.Select(b => b.Name);
            //    BindingBox.SelectedItem = Model.BindingName;
            //}

            RestartButton.IsEnabled  = true;
            Progress.IsIndeterminate = false;
            LogBox.ScrollToEnd();

            //if (!reference.HasErrors && !reference.HasWarnings)
            //{
            //SetVisiblePage(2);
            FinishButton.IsEnabled = true;
            //}
        }
Example #3
0
 private void Window_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyboardDevice.Modifiers == ModifierKeys.Control && e.Key == Key.R)
     {
         if (LogBox.Visibility == Visibility.Hidden)
         {
             LogBox.Text       = logTitle + log;
             logBoxIsEnable    = true;
             LogBox.Visibility = Visibility.Visible;
             LogBox.ScrollToEnd();
             Storyboard S = Resources["ShowLogBox"] as Storyboard;
             S.Begin();
         }
         else
         {
             logBoxIsEnable = false;
             Storyboard S = Resources["HideLogBox"] as Storyboard;
             S.Completed += delegate { LogBox.Visibility = Visibility.Hidden; LogBox.Text = ""; };
             S.Begin();
         }
     }
     if (e.Key == Key.Escape)
     {
         this.Close();
     }
 }
Example #4
0
 private void OnIsVisibleChanged(object sender, DependencyPropertyChangedEventArgs args)
 {
     if (this.Visibility == Visibility.Visible)
     {
         GoogleLatency.Resume();
         ChatServerLatency.Resume();
         GameServerLatency.Resume();
         ApiServerLatency.Resume();
         Dispatcher.BeginInvoke(
             new Action(
                 () =>
         {
             LogBox.Document.Blocks.Clear();
             foreach (var l in LatestLogLines)
             {
                 LogBox.Document.Blocks.Add(new Paragraph(new Run(l)));
             }
             if (AutoScroll)
             {
                 LogBox.ScrollToEnd();
             }
         }));
     }
     else
     {
         GoogleLatency.Pause();
         ChatServerLatency.Pause();
         GameServerLatency.Pause();
         ApiServerLatency.Pause();
     }
 }
Example #5
0
        public void Log(string message)
        {
            //LogBox.AppendText("\n[" + DateTime.Now.ToString("HH:mm") + "]" + message);
            LogBox.AppendText("\n" + message);
            LogBox.ScrollToEnd();

            //WriteTextSafe(message);
        }
Example #6
0
 void LogMessage(string message)
 {
     Dispatcher.Invoke(new Action(() =>
     {
         LogBox.AppendText(message + "\n");
         LogBox.ScrollToEnd();
     }));
 }
Example #7
0
 private void AppendLog(string text)
 {
     Console.WriteLine(text);
     Dispatcher.Invoke(() =>
     {
         LogBox.AppendText(text + "\n");
         LogBox.ScrollToEnd();
     });
 }
Example #8
0
        public void WriteLine
        (
            string format, params object[] args
        )
        {
            string text = string.Format(format, args) + Environment.NewLine;

            LogBox.AppendText(text);
            LogBox.ScrollToEnd();
        }
 public void AppendLog(string log)
 {
     Dispatcher.Invoke(new Action(() =>
     {
         if (AutoScrollChk.IsChecked == true)
         {
             LogBox.ScrollToEnd();
         }
         LogBox.AppendText(log + "\r\n");
     }));
 }
Example #10
0
        private void LoadUpdateSystem()
        {
            Timer netTimer;

            netTimer          = new Timer(1000 / 60);
            netTimer.Elapsed += (s, q) =>
            {
                if (clientUser == null)
                {
                    return;
                }
                Dispatcher.BeginInvoke(new Action(() =>
                {
                    SendMessage(Player1.Margin);
                }));
                try
                {
                    //////////////////////////////////////////////////////////////////////////
                    List <BallMessage> messages = remoteProxy.GetNewMessages(clientUser);
                    if (messages != null)
                    {
                        foreach (var message in messages)
                        {
                            Dispatcher.BeginInvoke(new Action(() =>
                            {
                                if (!IsGameStarted)
                                {
                                    StartGame(message);
                                    IsGameStarted = true;
                                }
                                if (!String.IsNullOrEmpty(message.Message))
                                {
                                    LogBox.AppendText(message.Date.ToString() + " : " + message.Message + "\n");
                                    LogBox.ScrollToEnd();
                                }

                                var mar                = Player2.Margin;
                                mar.Left               = message.Margine.Left;
                                Player2.Margin         = mar;
                                Ball.Margin            = message.BallMargine;
                                GameSpeedLabel.Content = message.GameSpeed;
                            }));
                        }
                    }
                    NetworkError = false;
                }
                catch (Exception e)
                {
                    e.DebugDesc().Log("ChackNet");
                    NetworkError = true;
                }
            };
            netTimer.Start();
        }
Example #11
0
 private void Prompt(string text)
 {
     this.Dispatcher.Invoke(new Action(() =>
     {
         if (LogBox.Text.Length > 200)
         {
             LogBox.Text = LogBox.Text.Remove(0, 100);
         }
         LogBox.Text += text;
         LogBox.ScrollToEnd();
     }));
 }
        public void Log(string text, bool skipEmpty = true)
        {
            if (skipEmpty && string.IsNullOrEmpty(text))
            {
                return;
            }

            _currentLog?.WriteLine(text);

            Application.Current.Dispatcher.Invoke(() =>
            {
                LogBox.AppendText(text + Environment.NewLine);
                LogBox.ScrollToEnd();
            });
        }
Example #13
0
 private void P_Mixed_OutputReceived(string message)
 {
     log += "\r\n[Mixed] " + message;
     if (logBoxIsEnable)
     {
         Dispatcher.Invoke(new Action(() =>
         {
             if (LogBox.Visibility == Visibility.Visible)
             {
                 LogBox.AppendText("\r\n[Mixed] " + message);
                 LogBox.ScrollToEnd();
             }
         }));
     }
 }
 private async void TelegramLogWorker()
 {
     while (!_windowClosing)
     {
         if (_logQueue.Count > 0)
         {
             var t = _logQueue.Dequeue();
             LogBox.AppendParagraph(t, Colors.Aquamarine);
             if (LogBox.Document.Blocks.Count > 200)
             {
                 var toRemove = LogBox.Document.Blocks.ElementAt(0);
                 LogBox.Document.Blocks.Remove(toRemove);
             }
             LogBox.ScrollToEnd();
         }
         await Task.Delay(10);
     }
 }
Example #15
0
 // Print log to window
 public void printlog(string log, bool clear = false)
 {
     if (!clear)
     {
         Dispatcher.BeginInvoke(new Action(() =>
         {
             LogBox.Text += (log + "\n");
             LogBox.ScrollToEnd();
         }));
     }
     else
     {
         Dispatcher.BeginInvoke(new Action(() =>
         {
             LogBox.Text = (log + "\n");
             LogBox.ScrollToEnd();
         }));
     }
 }
Example #16
0
        private void Discovery_Connect(DiscoveryCompleteEventArgs e)
        {
            var reference = e.Reference;

            foreach (var warning in reference.Warnings)
            {
                _logger.Warn(warning);
            }
            foreach (var error in reference.Errors)
            {
                _logger.Error(error);
            }

            if (reference.HasErrors)
            {
                _logger.Write("Cannot create a connection.");
            }
            else
            {
                _logger.Write("Click \"Next\" to continue.");
                SelectButton.IsEnabled = true;

                var reset = string.IsNullOrEmpty(Model.BindingName) ||
                            !reference.Bindings.Any(b => b.Name == Model.BindingName);
                if (reset)
                {
                    Model.BindingName = reference.Bindings.Count > 0
                                                ? reference.Bindings[0].Name : "";
                }

                BindingBox.ItemsSource  = reference.Bindings.Select(b => b.Name);
                BindingBox.SelectedItem = Model.BindingName;
            }

            RestartButton.IsEnabled  = true;
            Progress.IsIndeterminate = false;
            LogBox.ScrollToEnd();

            if (!reference.HasErrors && !reference.HasWarnings)
            {
                SetVisiblePage(2);
            }
        }
Example #17
0
 // Print log to window
 public void PrintLog(string log, bool clear = false, bool checkError = true)
 {
     if (checkError)
     {
         PrintErrorInfo();
     }
     if (!clear)
     {
         Dispatcher.BeginInvoke(new Action(() =>
         {
             LogBox.Text += (log + "\n");
             LogBox.ScrollToEnd();
         }));
     }
     else
     {
         Dispatcher.BeginInvoke(new Action(() =>
         {
             LogBox.Text = (log + "\n");
             LogBox.ScrollToEnd();
         }));
     }
 }
Example #18
0
        public MainWindow()
        {
            if (File.Exists(ConfigFile))
            {
                _config = Helpers.Deserialize <Config>(ConfigFile);
            }

            for (var i = 0; i < 6; ++i)
            {
                _sensors.Add(new Sensor(i, _config));
            }

            InitializeComponent();
            Title += " version " + Helpers.GetVersion();

            TheCanvas.Sensors = _sensors;
            RefreshCameras();

            Logger.LogAdded += log => {
                LogBox.AppendText(log);
                LogBox.AppendText(Environment.NewLine);
                LogBox.ScrollToEnd();
            };
        }
Example #19
0
 private void Log(string msg)
 {
     LogBox.AppendText($"{DateTime.Now:HH:mm:ss.fff}: {msg}\n");
     LogBox.ScrollToEnd();
 }
Example #20
0
        internal void AddLogEvent(LoggingEvent eve)
        {
            try
            {
                switch (eve.Level.Name)
                {
                case "DEBUG":
                    totalDebug++;
                    break;

                case "WARN":
                    totalWarn++;
                    break;

                case "INFO":
                    totalInfo++;
                    break;

                case "ERROR":
                    totalError++;
                    break;

                case "FATAL":
                    totalFatal++;
                    break;
                }
                EventCounts = String.Format(
                    "DEBUG: {0}    INFO: {1}    WARN: {2}    ERROR:{3}    FATAL:{4}",
                    totalDebug,
                    totalInfo,
                    totalWarn,
                    totalError,
                    totalFatal);
                LatestLogLines.Add(eve.RenderedMessage);
                while (LatestLogLines.Count > 300)
                {
                    LatestLogLines.RemoveAt(0);
                }
                if (this.Visibility == Visibility.Visible)
                {
                    Dispatcher.BeginInvoke(
                        new Action(
                            () =>
                    {
                        LogBox.Document.Blocks.Add(new Paragraph(new Run(eve.RenderedMessage)));
                        while (LogBox.Document.Blocks.Count > 300)
                        {
                            LogBox.Document.Blocks.Remove(LogBox.Document.Blocks.FirstBlock);
                        }
                        if (AutoScroll)
                        {
                            LogBox.ScrollToEnd();
                        }
                    }));
                }
            }
            catch
            {
                // This comes from the logger, if we log here we could enter a recursive nightmare that we may never wake from. Imagine the horror of a thousand crying IO events, bleeding, tormented. The smell is enough to drive a made insane. Well we're on the subject I should mention that I never was a big fan of the first Freddy Kruger film. Wasn't really one of my favorites. Anyways, I suppose this comment is carrying on a little, so I'll wrap it up. Thanks for listening and stuff. Oh, and don't forget to break your while loops and dispose your objects, or the Garbage Man will come to get you!
            }
        }
Example #21
0
 public void AppendLog(string text)
 {
     DC.WriteLine("[MWDBG LOG] " + text);
     LogBox.AppendText(String.Format("{0}[{1:H:mm:ss}] {2}", "\r\n", DateTime.Now, text));
     LogBox.ScrollToEnd();
 }
Example #22
0
 private void OnTextChanged(object sender, TextChangedEventArgs e)
 {
     LogBox.ScrollToEnd();
 }
Example #23
0
        public InstallApkWindow(
            [NotNull] IInstallApkViewModel viewModel
            )
        {
            _viewModel = viewModel;

            InitializeComponent();
            DataContext = viewModel;

            ITaskBarManager taskBarManager = new TaskBarManager(TaskbarItemInfo = new TaskbarItemInfo());
            IVisualProgress visualProgress = StatusProgress.GetVisualProgress();

            viewModel.TaskBarManager.Value = taskBarManager;
            viewModel.VisualProgress.Value = visualProgress;

            visualProgress.SetLabelText(MainResources.AllDone);

            // property changes notification
            viewModel.LogText.PropertyChanged += (sender, args) => LogBox.Dispatcher.Invoke(() => LogBox.ScrollToEnd());
        }
Example #24
0
 public LogViewer(IApplication app) : this()
 {
     LogBox.Text = app.Log.ToString();
     LogBox.ScrollToEnd();
 }
Example #25
0
        public MainPage(Window w)
        {
            InitSettingBrowser();
            InitializeComponent();
            Directory.CreateDirectory(TempFolder);

            RequestObject.DataRecived += (o, args) =>
            {
                if (args.IsError == RecivedDataType.Error)
                {
                    Manager.Log(args.Data, LogMessageType.Error);
                }
                else
                {
                    payloads[args.Id].TaskSource.SetResult(JArray.Parse(args.Data));
                    ForgeOfEmpires.Manager.ParseStringData(args.Data);
                }
            };

            LoadConfig();

            LoadOtherResourcesHtml();

            InitBrowser();

            w.Closed += (sender, args) =>
            {
                Manager.SaveCache();
                SaveConfig();
                Config.Save();
                Cef.Shutdown();
                Environment.Exit(0);
                if (File.Exists(Path.Combine(TempFolder, "OtherResources.html")))
                {
                    File.Delete(Path.Combine(TempFolder, "OtherResources.html"));
                }
            };

            var random = new Random();

            Requests.PayloadSendRequest += async(requests, args) =>
            {
                var delay = random.Next(50, 400);
                Manager.Log($"Request delay: {delay}ms", LogMessageType.Request);
                await Task.Delay(delay);

                SendRequest(args.Payload);
            };

            Manager.LogMessageSend += (manager, args) =>
            {
                Dispatcher.Invoke(() =>
                {
                    if ((ShowLogMessageType & args.Type) == args.Type)
                    {
                        LogBox.AppendText(args.Message + "\n");
                        LogBox.ScrollToEnd();
                    }
                });
                //var tr = new TextRange(LogBox.Document.ContentEnd, LogBox.Document.ContentEnd) {Text = args.Message};
                //tr.ApplyPropertyValue(TextElement.­ForegroundProperty, Brushes.Red);
            };

            Manager.Log("Logging...");

            if (UserName.Text.Length == 0 || Password.Password.Length == 0)
            {
                Manager.Log("Login failed. User name or password is empty. Fill in login data and click on Relogin");
            }

            ForgeOfEmpires.Manager.LogoutEvent += (manager, args) =>
            {
                if (IsReloginRunning)
                {
                    return;
                }
                IsReloginRunning = true;
                Relogin();
            };

            ForgeOfEmpires.Manager.ResourcesUpdate += (manager, args) =>
            {
                try
                {
                    foreach (var value in args.Values)
                    {
                        switch (value.Item1)
                        {
                        //case "tavern_silver": TavernSilver.Dispatcher.Invoke(() => TavernSilver.Text = value.Item2.ToString(CultureInfo.CurrentUICulture)); break;
                        //case "premium": DiamondBox.Dispatcher.Invoke(() => DiamondBox.Text = value.Item2.ToString(CultureInfo.CurrentUICulture)); break;
                        //case "money": MoneyBox.Dispatcher.Invoke(() => MoneyBox.Text = value.Item2.ToString(CultureInfo.CurrentUICulture)); break;
                        //case "supplies": SupplyBox.Dispatcher.Invoke(() => SupplyBox.Text = value.Item2.ToString(CultureInfo.CurrentUICulture)); break;
                        //case "strategy_points": ForgePointsBox.Dispatcher.Invoke(() => ForgePointsBox.Text = value.Item2.ToString(CultureInfo.CurrentUICulture)); break;
                        //case "medals": Medals.Dispatcher.Invoke(() => Medals.Text = value.Item2.ToString(CultureInfo.CurrentUICulture)); break;
                        default:
                            otherBrowser.ExecuteScriptAsync("updateItem", value.Item1, value.Item2);
                            break;
                        }
                    }
                }
                catch (Exception e)
                {
                    Manager.Log("Resource update Exception: " + e.ToString(), LogMessageType.Exception);
                }
            };
        }