public MouseBridgeService() { _screens = ScreenConfigCollection.Load(); ScreenConfigCollection.OnChanged += config => { _screens = config; }; }
protected override void OnLoad(EventArgs e) { _config = ScreenConfigCollection.Load(); ScreenConfigCollection.OnChanged += OnDisplaySettingsChanged; base.OnLoad(e); }
private void InitSystemInfos() { LogInfos($"Config: {Json(ScreenConfigCollection.Load())}"); LogInfos($"Screens: {Json(Screen.AllScreens)}"); LogInfos($"SystemInformation: {Json(StaticProperties(typeof(SystemInformation)))}"); LogInfos($"Environment: {Json(StaticProperties(typeof(Environment)))}"); void LogInfos(string msg) { this.InfosBox.AppendText($"{msg}\r\n"); }
public DiagnosticForm(ServiceThread service) { Service = service; InitializeComponent(); var diagnostic = false; this.BtnStartDiagnostic.Click += delegate { if (!diagnostic) { ConsoleBox.Text = string.Empty; var config = ScreenConfigCollection.Load(); Service.StopService(); Service.StartService(new MouseBridgeDiagnosticService(config, RealtimeLog)); this.BtnStartDiagnostic.Text = "Stop Diagnostic"; diagnostic = true; } else { Service.RestoreOriginalState(); this.BtnStartDiagnostic.Text = "Start Diagnostic"; diagnostic = false; } }; this.BtnCopy.Click += delegate { var sb = new StringBuilder(); // update log infos LogfileBox.Text = string.Empty; InitLogFileInfos(); sb.AppendLine(InfosBox.Text); sb.AppendLine(); sb.AppendLine(); sb.AppendLine(ConsoleBox.Text); sb.AppendLine(); sb.AppendLine(); sb.AppendLine(LogfileBox.Text); Clipboard.SetText(sb.ToString()); MessageBox.Show("Diagnostic data copied to clipboard."); }; this.Closing += delegate { Service.RestoreOriginalState(); }; ConsoleBox.Text = "\r\n INFO: Start Diagnostic to see Realtime output.."; InitSystemInfos(); InitLogFileInfos(); }
public ConfigFrom(ServiceThread service) { this.Icon = App.Icon; Service = service; Screens = ScreenConfigCollection.Load(); Settings = Settings.Load(); Settings.Configured = Screens.Any(_ => _.HasBridges); InitializeComponent(); this.Text += $" v{Assembly.GetEntryAssembly()?.GetName().Version}"; this.ResizeRedraw = true; this.InfoText.Visible = Settings.Configured == false; this.BtnConfigure.Click += (s, e) => { ShowForms(); }; this.BtnDiagnostic.Click += (s, e) => { ShowDiagnosticForm(); }; this.EnableAutoStart.Checked = Settings.AutoStartEnabled; this.EnableAutoStart.CheckedChanged += delegate { if (EnableAutoStart.Checked) { Task.Run(() => new ProjectInstaller().Install()); Settings.AutoStartEnabled = true; } else { Task.Run(() => new ProjectInstaller().Uninstall()); Settings.AutoStartEnabled = false; } }; if (!Settings.Configured && !Settings.AutoStartEnabled) { this.EnableAutoStart.Checked = true; } this.TeleportationActive.Checked = Settings.TeleportationActive; this.TeleportationActive.CheckedChanged += delegate { if (TeleportationActive.Checked) { Service.StartService(); Settings.TeleportationActive = true; } else { Service.StopService(); Settings.TeleportationActive = false; } }; }
public static int ChooseScreenDialog(ScreenConfigCollection screens, int screenIdToexclude) { var resultId = -1; do { var f = new Form { Width = 500, Height = 200, AutoSize = true, AutoSizeMode = AutoSizeMode.GrowOnly, StartPosition = FormStartPosition.CenterScreen, Text = "Choose target screen", Icon = App.Icon }; var container = new FlowLayoutPanel { Location = Point.Empty, Dock = DockStyle.Fill, Padding = new Padding(10), WrapContents = true }; foreach (var screen in screens) { var button = new Button { Text = screen.ScreenNum, Width = 50, Height = 50, Enabled = screen.ScreenId != screenIdToexclude }; button.Click += (sender, e) => { resultId = screen.ScreenId; f.Close(); }; container.Controls.Add(button); } f.Controls.Add(container); f.ShowDialog(); } while (resultId == -1); return(resultId); }
public MouseBridgeDiagnosticService(ScreenConfigCollection screens, Action <string> log) { _screens = screens; ScreenConfigCollection.OnChanged += config => { _screens = config; }; var sw = new Stopwatch(); sw.Start(); _log = msg => { msg = $"{sw.Elapsed,-15:g} {Interlocked.Increment(ref _count),11} [{DirectionArrow(_direction)}] Cursor({_position.X,4}, {_position.Y,4}) {msg}"; if (_count == uint.MaxValue) { _count = 0; } Task.Run(() => log(msg)); };
public MouseBridgeService(ScreenConfigCollection screens) { _screens = screens; }
private void OnDisplaySettingsChanged(ScreenConfigCollection config) { _config = config; this.Invalidate(); }