private void FormMain_Load(object sender, EventArgs e) { formCommands = new FormCommands(); formCommands.Show(); this.WriteConsole("F10: globale Start/Stop"); string game = Properties.Settings.Default.game; string server = Properties.Settings.Default.server; string room = Properties.Settings.Default.room; string user = Properties.Settings.Default.user; string password = Properties.Settings.Default.password; string nickserv = Properties.Settings.Default.nickserv; wait = Properties.Settings.Default.keyWait; textBoxGame.Text = game; textBoxServer.Text = server; textBoxRoom.Text = room; textBoxUser.Text = user; textBoxPassword.Text = password; textBoxNickserv.Text = nickserv; numericUpDownKeyWait.Value = wait; interceptKeys = new InterceptKeys(this); interceptKeys.Start(); ReloadKeybinds(); }
public Form1() { InitializeComponent(); label2.Text = "Return Takeoff\n" + " Space Motors OFF (be careful - drone falls out off the sky!!!)\n" + " I Fly forward\n" + " , Fly backward\n" + " J Fly leftward\n" + " L Fly rightward\n" + " K Hover\n" + " W Fly 5cm higher\n" + " S Fly 5cm lower\n" + " A Rotate 5 degrees anticlockwise\n" + " D Rotate 5 degrees clockwise\n" + "\n" + "Note: All keypresses on this PC are captured, even if this window is not active!!!\n"; lblState.Text = string.Format("Start 'fly' on the drone then press Space to connect..."); label1.Text = string.Format(""); lblPos.Text = string.Format(""); log = new UdpLogger(7778, string.Format("{0:yyyyMMddHHmmss}_navlog.csv", DateTime.Now)); timer1.Interval = 250; timer1.Enabled = true; InterceptKeys.Start(KeyDownCallback); }
// private List<string> words = commaWords.Split(','); public FindImageInScreenShot() { this.InitializeComponent(); this.screenShotsManager = new ScreenShotsManager(); InterceptKeys.OnKeyDown += this.InterceptKeys_OnKeyDown; InterceptKeys.Start(); InterceptMouse.OnMouseLeftButtonDown += this.InterceptMouse_OnMouseLeftButtonDown; InterceptMouse.Start(); }
protected override void OnStartup(System.Windows.StartupEventArgs e) { DispatcherUnhandledException += Application_DispatcherUnhandledException; // Call the OnStartup event on our base class base.OnStartup(e); var v = this.GetType().Assembly.GetName().Version; string preproduction = " ?"; if (v.Build == 0) { preproduction = ""; } else if (v.Build % 2 != 0) { preproduction = " αlpha" + (v.Build + 1) / 2 + " (rev." + v.Revision + ")"; } else if (v.Build % 2 == 0) { preproduction = " βeta" + v.Build / 2 + " (rev." + v.Revision + ")"; } this.Properties["Version"] = string.Format("v{0}.{1}{2}", v.Major, v.Minor, preproduction); this.Properties["VersionShort"] = string.Format("v{0}.{1}", v.Major, v.Minor); Exit += new ExitEventHandler(App_Exit); Thread preloader = new Thread(PreloadAssemblies); preloader.IsBackground = true; preloader.Priority = ThreadPriority.BelowNormal; preloader.Start(); this.Resources = Application.LoadComponent(new Uri("App.xaml", UriKind.RelativeOrAbsolute)) as ResourceDictionary; var w = new Window1(); ServiceLocator.RegisterService <IMainView>(w); var dlgsrv = new AppDialogService(); ServiceLocator.RegisterService <IDialogService>(dlgsrv); ServiceLocator.RegisterService <IMainWindow>(w); var vm = new Main { Themes = new ObservableCollection <ThemeInfo>(StyleLoader.GetAllStyles()) }; w.DataContext = vm; ServiceLocator.RegisterOverrideService <IKeyboardHandler>((IKeyboardHandler)vm); ServiceLocator.RegisterOverrideService <IActionExecutor>((IActionExecutor)vm); this.Resources.BeginInit(); var sl = new StyleLoader(Resources); var startTheme = new ThemeInfo { Path = "default" }; startTheme = sl.LoadStyle(startTheme); StyleLoader.CurrentStyleFolder = startTheme.Path; vm.CurrentTheme = vm.Themes.FirstOrDefault(t => t.Path == startTheme.Path); //this.Resources.MergedDictionaries.Add(Application.LoadComponent(new Uri("/Themes/default/style.xaml", UriKind.RelativeOrAbsolute)) as ResourceDictionary); this.Resources.EndInit(); sl.PerformInit = true; var b = new System.Windows.Controls.Button(); ServiceLocator.RegisterService <IStyleLoader>(sl); ServiceLocator.RegisterService <IFramePictureProvider>(w); ServiceLocator.RegisterService <IInputTeller>(w); ServiceLocator.RegisterService <IPlateProcessor>(vm); ServiceLocator.RegisterService <ISettings>(vm); //sl.LoadStyle("default"); string[] args = Environment.GetCommandLineArgs(); if (args.Length > 1) { (MainWindow as Window1).StartupFile = args[1]; } InterceptKeys.Start((MainWindow as Window1)); w.Show(); }
void Timer() { string periodLabel = ""; int periodTime = 0; bool isWorkPeriod = true, wasPaused = false, wasRestarted = false; DateTime currentTime, periodEndTime; while (Command != QUIT) { currentTime = DateTime.Now; if (wasPaused) { // do not reset label or time, use saved periodTime wasPaused = false; periodEndTime = currentTime.AddMilliseconds(periodTime); Console.WriteLine("[{0}] Resumed: {1} | End: {2} ({3})", periodLabel, currentTime.ToString("h:mm:ss tt"), periodEndTime.ToString("h:mm:ss tt"), (periodEndTime - currentTime).ToString(@"mm\:ss")); } else if (wasRestarted) { // do not reset label or time, use existing or modified periodTime wasRestarted = false; periodEndTime = currentTime.AddMilliseconds(periodTime); Console.WriteLine("[{0}] Restarted: {1} | End: {2} ({3})", periodLabel, currentTime.ToString("h:mm:ss tt"), periodEndTime.ToString("h:mm:ss tt"), (periodEndTime - currentTime).ToString(@"mm\:ss")); } else // normal flow { if (isWorkPeriod) { periodLabel = "WORK"; periodTime = WORKTIME; } else { periodLabel = "REST"; periodTime = RESTTIME; } periodEndTime = currentTime.AddMilliseconds(periodTime); Console.WriteLine("[{0}] Start: {1} | End: {2} ({3})", periodLabel, currentTime.ToString("h:mm:ss tt"), periodEndTime.ToString("h:mm:ss tt"), (periodEndTime - currentTime).ToString(@"mm\:ss")); } // block thread for periodTime if (TimerBlocker.WaitOne(periodTime)) // if signalled { // manually signalled, reset signal for next timerblock TimerBlocker.Reset(); // handle commands if (Command == PAUSE) { TimeSpan remainingPeriod = periodEndTime - DateTime.Now; periodTime = (int)remainingPeriod.TotalMilliseconds; Console.Write("Period paused, press enter to resume "); WaitForReadLineInput(); wasPaused = true; } else if (Command == NEXT) { isWorkPeriod = !isWorkPeriod; } else if (Command.Contains(RESTART)) { wasRestarted = true; // checking if "MM:SS" setting option present MatchCollection numsInCommand = new Regex(@"\d+").Matches(Command); if (numsInCommand.Count >= 2) { int minsTemp = Int32.Parse(numsInCommand[0].Value); int secsTemp = Int32.Parse(numsInCommand[1].Value); // converting to milliseconds minsTemp *= 60000; secsTemp *= 1000; periodTime = minsTemp + secsTemp; } else { // else restart with normal period time periodTime = isWorkPeriod ? WORKTIME : RESTTIME; } } // else Command == "quit" -> do nothing, while condition will handle it } else // if not signalled (timeout) { isWorkPeriod = !isWorkPeriod; PeriodEndSound.Play(); Thread notifyThread = new Thread(IntervalNotify); notifyThread.Start(); Console.WriteLine("Period end, press Insert to resume"); // blocks until Insert is pressed InterceptKeys.Start(KeyPressCallback); // end notifyThread NotifyBlocker.Set(); // play a confirmation NotificationSound.Play(); } } }
public KeyboardService() { InterceptKeys.Start(); }