private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            RemoveLog();
            Utility.Utility.LogSystemInformation();

            settings = Preferences.Load();

            SetupControls();

            _systemWatcher.ForegroundChanged      += SystemWatcherSystemChanged;
            _keyboardWatcher.KeyboardInputChanged += _keyboardWatcher_KeyboardInputChanged;
            _mouseWatcher.CursorPositionChanged   += MouseWatcherOnCursorPositionChanged;
            _processWatcher.ProcessStarted        += ProcessWatcherOnProcessStarted;
            _processWatcher.ProcessFinished       += ProcessWatcherOnProcessFinished;

            _systemWatcher.Hook();
            _keyboardWatcher.HookKeyboard();
            _processWatcher.Hook();

            FindRa3Process();

            tmr.Tick    += Tmr_Tick;
            tmr.Interval = new TimeSpan(0, 0, 0, 10);

            Logger.Info("OK.. application launch");

            // tmr.Start();
        }
Esempio n. 2
0
        public static SettingEntries Load()
        {
            SettingEntries settings = new SettingEntries();

            if (!File.Exists(Constants.SettingsFile))
            {
                return(settings);
            }

            XmlSerializer serial = new XmlSerializer(settings.GetType());

            settings = (SettingEntries)serial.Deserialize(new StreamReader(Constants.SettingsFile));

            return(settings);
        }
Esempio n. 3
0
        public static bool Write(SettingEntries settings)
        {
            bool result = false;

            try
            {
                XmlSerializer serial = new XmlSerializer(settings.GetType());
                serial.Serialize(new StreamWriter(Constants.SettingsFile), settings);

                result = true;
            }
            catch (IOException)
            {
                // TODO log or whatever
            }
            catch (Exception)
            {
                // TODO: Same
            }

            return(result);
        }
Esempio n. 4
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            settings = Preferences.Load();
            settings.SetContext(this);
            SetupControls();

            if (_foregroundWatcher.HookForeground())
            {
                Log("ForegroundWatcher started. Waiting for RA3 game window...");
            }
            else
            {
                Log("ForegroundWatcher failed.");
            }

            _foregroundWatcher.ForegroundChanged  += ForegroundWatcher_ForegroundChanged;
            _keyboardWatcher.KeyboardInputChanged += _keyboardWatcher_KeyboardInputChanged;

            listConnectionsTmr          = new DispatcherTimer();
            listConnectionsTmr.Tick    += ListConnectionsTmr_Tick;
            listConnectionsTmr.Interval = new TimeSpan(0, 0, 0, 1);
        }