コード例 #1
0
ファイル: MouseBridgeService.cs プロジェクト: rowa/MouseTrap
 public MouseBridgeService()
 {
     _screens = ScreenConfigCollection.Load();
     ScreenConfigCollection.OnChanged += config => {
         _screens = config;
     };
 }
コード例 #2
0
ファイル: ScreensView.cs プロジェクト: rowa/MouseTrap
        protected override void OnLoad(EventArgs e)
        {
            _config = ScreenConfigCollection.Load();
            ScreenConfigCollection.OnChanged += OnDisplaySettingsChanged;

            base.OnLoad(e);
        }
コード例 #3
0
ファイル: DiagnosticForm.cs プロジェクト: rowa/MouseTrap
        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");
            }
コード例 #4
0
ファイル: DiagnosticForm.cs プロジェクト: rowa/MouseTrap
        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();
        }
コード例 #5
0
        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;
                }
            };
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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));
            };
コード例 #8
0
ファイル: MouseBridgeService.cs プロジェクト: rowa/MouseTrap
 public MouseBridgeService(ScreenConfigCollection screens)
 {
     _screens = screens;
 }
コード例 #9
0
ファイル: ScreensView.cs プロジェクト: rowa/MouseTrap
 private void OnDisplaySettingsChanged(ScreenConfigCollection config)
 {
     _config = config;
     this.Invalidate();
 }