Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Type: ConSecMonitor.MainWindow
- // Assembly: ConSecMonitor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
- // MVID: 3E409366-F669-4BF1-9E17-33E7F*******
- using ConSecMonitor.My;
- using FPH.SpedV.API.Enums;
- using FPH.SpedV.API.Objects.Telemetry;
- using MahApps.Metro.Controls;
- using Microsoft.VisualBasic;
- using Microsoft.VisualBasic.CompilerServices;
- using Newtonsoft.Json;
- using System;
- using System.CodeDom.Compiler;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Diagnostics;
- using System.Linq;
- using System.Net;
- using System.Runtime.CompilerServices;
- using System.Threading;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Markup;
- namespace ConSecMonitor
- {
- /// <summary>MainWindow</summary>
- [DesignerGenerated]
- public class MainWindow : MetroWindow, IComponentConnector
- {
- private WPFOverlay WPFO;
- private bool WPFOinit;
- private string Server;
- private int ServerKey;
- private WebClient client;
- private bool startup;
- private bool _contentLoaded;
- private virtual FPH.SpedV.API.Objects.Telemetry.Telemetry Telemetry
- {
- get
- {
- return this._Telemetry;
- }
- [MethodImpl(MethodImplOptions.Synchronized)] set
- {
- FPH.SpedV.API.Objects.Telemetry.Telemetry.DataRefreshedEventHandler refreshedEventHandler = new FPH.SpedV.API.Objects.Telemetry.Telemetry.DataRefreshedEventHandler(this.Telemetry_DataRefreshed);
- FPH.SpedV.API.Objects.Telemetry.Telemetry telemetry1 = this._Telemetry;
- if (telemetry1 != null)
- telemetry1.DataRefreshed -= refreshedEventHandler;
- this._Telemetry = value;
- FPH.SpedV.API.Objects.Telemetry.Telemetry telemetry2 = this._Telemetry;
- if (telemetry2 == null)
- return;
- telemetry2.DataRefreshed += refreshedEventHandler;
- }
- }
- public MainWindow()
- {
- this.Loaded += new RoutedEventHandler(this.MainWindow_Loaded);
- this.Closing += new CancelEventHandler(this.MainWindow_Closing);
- this.WPFOinit = false;
- this.Server = "https://consec.sped-v.de/rest/";
- this.ServerKey = 0;
- this.client = new WebClient();
- this.startup = true;
- this.InitializeComponent();
- MyWpfExtension.Application.LoadSettings();
- this.TXT_telemetry.Text = MyWpfExtension.Application.Settings.GetValue<string>("TelemetryIP", "127.0.0.1", false, (JsonSerializer) null);
- this.NUD_dpi.Value = new double?((double) MyWpfExtension.Application.Settings.GetValue<int>("overlay.scale", 100, false, (JsonSerializer) null));
- this.NUD_maxWidth.Value = new double?((double) MyWpfExtension.Application.Settings.GetValue<int>("consec.maxwidth", 1920, false, (JsonSerializer) null));
- this.NUD_maxDrivers.Value = new double?((double) MyWpfExtension.Application.Settings.GetValue<int>("consec.maxdrivers", 5, false, (JsonSerializer) null));
- this.TXT_username.Text = MyWpfExtension.Application.Settings.GetValue<string>("consec.username", MyWpfExtension.Computer.Name, false, (JsonSerializer) null);
- this.CMB_position.SelectedIndex = 1;
- this.Telemetry = new FPH.SpedV.API.Objects.Telemetry.Telemetry(MyWpfExtension.Application.Settings.GetValue<string>("TelemetryIP", "127.0.0.1", false, (JsonSerializer) null), 1000);
- this.Title = "ConSec-Monitor 19.1.19.19";
- if (!this.client.DownloadString(this.Server + "version").Contains("19011919"))
- {
- if (Interaction.MsgBox((object) "Update verfügbar! Möchtest du zur Downloadseite gehen?", MsgBoxStyle.YesNo, (object) null) == MsgBoxResult.Yes)
- {
- try
- {
- Process.Start("http://convoy-security.de/filebase/index.php?file/33-consecmonitor/");
- }
- catch (Exception ex)
- {
- ProjectData.SetProjectError(ex);
- ProjectData.ClearProjectError();
- }
- }
- }
- this.startup = false;
- }
- private void CheckForETSATSProcess()
- {
- try
- {
- // ISSUE: variable of a compiler-generated type
- MainWindow._Closure\u0024__11\u002D0 closure110_1;
- // ISSUE: object of a compiler-generated type is created
- // ISSUE: variable of a compiler-generated type
- MainWindow._Closure\u0024__11\u002D0 closure110_2 = new MainWindow._Closure\u0024__11\u002D0(closure110_1);
- // ISSUE: reference to a compiler-generated field
- closure110_2.\u0024VB\u0024Me = this;
- // ISSUE: reference to a compiler-generated field
- closure110_2.\u0024VB\u0024Local_P_ETS = ((IEnumerable<Process>) Process.GetProcessesByName("eurotrucks2")).FirstOrDefault<Process>();
- Process process = ((IEnumerable<Process>) Process.GetProcessesByName("amtrucks")).FirstOrDefault<Process>();
- // ISSUE: reference to a compiler-generated field
- if (closure110_2.\u0024VB\u0024Local_P_ETS == null & process != null)
- {
- // ISSUE: reference to a compiler-generated field
- closure110_2.\u0024VB\u0024Local_P_ETS = process;
- }
- // ISSUE: reference to a compiler-generated field
- if (closure110_2.\u0024VB\u0024Local_P_ETS != null && !this.WPFOinit && this.Telemetry.Connected == TelemetryConnectionState.InGame | this.Telemetry.Connected == TelemetryConnectionState.Paused)
- {
- try
- {
- // ISSUE: reference to a compiler-generated field
- FPH.SpedV.API.Objects.Telemetry.Telemetry.LogEvent("OLAY", "Initialize Connection to " + closure110_2.\u0024VB\u0024Local_P_ETS.ProcessName);
- // ISSUE: reference to a compiler-generated method
- this.Dispatcher.Invoke(new Action(closure110_2._Lambda\u0024__0));
- new Thread((ThreadStart) (() =>
- {
- while (this.WPFOinit)
- {
- this.Dispatcher.Invoke((Action) (() => this.WPFO.Update()));
- Thread.Sleep(30);
- }
- })).Start();
- // ISSUE: reference to a compiler-generated field
- FPH.SpedV.API.Objects.Telemetry.Telemetry.LogEvent("OLAY", "Connection initialized to " + closure110_2.\u0024VB\u0024Local_P_ETS.ProcessName);
- }
- catch (Exception ex)
- {
- ProjectData.SetProjectError(ex);
- Exception exception = ex;
- int num = (int) Interaction.MsgBox((object) (exception.Message + "\r\n" + exception.StackTrace), MsgBoxStyle.OkOnly, (object) null);
- ProjectData.ClearProjectError();
- }
- }
- else
- {
- // ISSUE: reference to a compiler-generated field
- if (closure110_2.\u0024VB\u0024Local_P_ETS != null || !this.WPFOinit)
- return;
- this.WPFOinit = false;
- this.WPFO?.Disable();
- FPH.SpedV.API.Objects.Telemetry.Telemetry.LogEvent("OLAY", "Missed Connection");
- }
- }
- catch (Exception ex)
- {
- ProjectData.SetProjectError(ex);
- ProjectData.ClearProjectError();
- }
- }
- public void CheckThread()
- {
- while (true)
- {
- this.CheckForETSATSProcess();
- Thread.Sleep(10000);
- }
- }
- private void MainWindow_Loaded(object sender, RoutedEventArgs e)
- {
- new Thread(new ThreadStart(this.CheckThread)).Start();
- }
- private void CMD_save_Click(object sender, RoutedEventArgs e)
- {
- MyWpfExtension.Application.Settings.SetValue<string>("TelemetryIP", this.TXT_telemetry.Text, (JsonSerializer) null);
- MyWpfExtension.Application.Settings.SetValue<double?>("overlay.scale", this.NUD_dpi.Value, (JsonSerializer) null);
- MyWpfExtension.Application.Settings.SetValue<string>("consec.username", this.TXT_username.Text, (JsonSerializer) null);
- MyWpfExtension.Application.Settings.SetValue<double?>("consec.maxwidth", this.NUD_maxWidth.Value, (JsonSerializer) null);
- MyWpfExtension.Application.Settings.SetValue<double?>("consec.maxdrivers", this.NUD_maxDrivers.Value, (JsonSerializer) null);
- MyWpfExtension.Application.SaveSettings();
- this.Telemetry = new FPH.SpedV.API.Objects.Telemetry.Telemetry(MyWpfExtension.Application.Settings.GetValue<string>("TelemetryIP", "127.0.0.1", false, (JsonSerializer) null), 1000);
- if ((uint) this.ServerKey <= 0U)
- return;
- string str = this.client.DownloadString(this.Server + "changeName?key=" + Conversions.ToString(this.ServerKey) + "&name=" + WebUtility.UrlEncode(this.TXT_username.Text));
- if (Operators.CompareString(str, "Error occured", false) == 0)
- {
- this.ServerKey = 0;
- this.LBL_disclaimer.Content = (object) ("(c) Freie Programme Hohenstein 2019. Based upon FPH SpedV - " + Conversions.ToString(this.ServerKey));
- int num = (int) Interaction.MsgBox((object) "Fehler bei der Synchronisation mit dem Server.", MsgBoxStyle.Critical, (object) null);
- }
- else
- {
- this.refreshData(str, this.Telemetry.Data, MyWpfExtension.Application.Settings.GetValue<string>("consec.username", MyWpfExtension.Computer.Name, false, (JsonSerializer) null));
- int num = (int) Interaction.MsgBox((object) "Daten gespeichert und synchronisiert.", MsgBoxStyle.Information, (object) null);
- }
- }
- private void Telemetry_DataRefreshed(MainData newData, MainData oldData)
- {
- if (this.ServerKey == 0)
- this.Dispatcher.Invoke((Action) (() =>
- {
- this.ServerKey = Conversions.ToInteger(this.client.DownloadString(this.Server + "login?name=" + WebUtility.UrlEncode(MyWpfExtension.Application.Settings.GetValue<string>("consec.username", MyWpfExtension.Computer.Name, false, (JsonSerializer) null))));
- this.LBL_disclaimer.Content = (object) ("(c) Freie Programme Hohenstein 2019. Based upon FPH SpedV - " + Conversions.ToString(this.ServerKey));
- this.client.DownloadString(this.Server + "setPosition?key=" + Conversions.ToString(this.ServerKey) + "&position=" + Conversions.ToString(this.CMB_position.SelectedIndex));
- }));
- string str = this.client.DownloadString(this.Server + "update?key=" + Conversions.ToString(this.ServerKey) + "&distance=" + Conversions.ToString(newData.navigation.estimatedDistance) + "&velocity=" + WebUtility.UrlEncode(Conversions.ToString(Math.Round(newData.truck.speed, 0)) + " km/h") + "&xcoord=" + Conversions.ToString(newData.truck.placement.x) + "&zcoord=" + Conversions.ToString(newData.truck.placement.z));
- if (Operators.CompareString(str, "Error occured", false) == 0)
- {
- this.ServerKey = 0;
- this.LBL_disclaimer.Content = (object) ("(c) Freie Programme Hohenstein 2019. Based upon FPH SpedV - " + Conversions.ToString(this.ServerKey));
- }
- else
- this.refreshData(str, this.Telemetry.Data, MyWpfExtension.Application.Settings.GetValue<string>("consec.username", MyWpfExtension.Computer.Name, false, (JsonSerializer) null));
- }
- ************************* usw.........
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement