protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            this.Text = string.Format("{0} (v{1}). By {2}", GameSpecificConstants.ClientWindowTitle, GameSpecificConstants.CameraVersion, GameSpecificConstants.CameraCredits);
            FillAboutTab();

            // First setup the controls
            _settingsEditor.Setup();
            _keyBindingsEditor.Setup();

            // then load the values from the ini file (if any) so the controls are already there.
            AppStateSingleton.Instance().LoadFromIni();
            AppStateSingleton.Instance().LoadRecentProcessList();
            MessageHandlerSingleton.Instance().ConnectedToNamedPipeFunc     = () => HandleConnectedToPipe();
            MessageHandlerSingleton.Instance().ClientConnectionReceivedFunc = () => HandleConnectionReceived();
            _generalTabControl.UpdateSelectedRenderAPI();

            // Disable all tabs, except general, log and about.
            _hotsamplingTab.Enabled = false;
            _settingsTab.Enabled    = false;
            _keyBindingsTab.Enabled = false;

            var notificationWindow = new NotificationWindow();

            MessageHandlerSingleton.Instance().NotificationLogFunc = s => notificationWindow.AddNotification(s);
            notificationWindow.Show(this);
        }
Exemplo n.º 2
0
        private void MainWindow_OnLoaded(object sender, RoutedEventArgs e)
        {
            _sbHyperlink.NavigateUri = new Uri(ConstantsEnums.IGCSRootURL);
            _notificationNotifier    = new Notifier(cfg =>
            {
                cfg.PositionProvider   = new PrimaryScreenPositionProvider(corner: Corner.TopLeft, offsetX: 10, offsetY: 10);
                cfg.LifetimeSupervisor = new TimeAndCountBasedLifetimeSupervisor(notificationLifetime: TimeSpan.FromSeconds(3),
                                                                                 maximumNotificationCount: MaximumNotificationCount.FromCount(6));
                cfg.Dispatcher             = Application.Current.Dispatcher;
                cfg.DisplayOptions.TopMost = true;
            });
            this.Title = string.Format("{0} (v{1}). By {2}", GameSpecificConstants.ClientWindowTitle, GameSpecificConstants.CameraVersion, GameSpecificConstants.CameraCredits);

            // First setup the controls
            _configurationEditor.Setup();
            _keyBindingsEditor.Setup();

            // then load the values from the ini file (if any) so the controls are already there.
            AppStateSingleton.Instance().LoadFromIni();
            AppStateSingleton.Instance().LoadRecentProcessList();
            MessageHandlerSingleton.Instance().ConnectedToNamedPipeFunc     = () => HandleConnectedToPipe();
            MessageHandlerSingleton.Instance().ClientConnectionReceivedFunc = () => HandleConnectionReceived();

            // Disable all tabs, except general, log and about.
            _hotSamplingTab.IsEnabled   = false;
            _configurationTab.IsEnabled = false;
            _keybindingsTab.IsEnabled   = false;

            MessageHandlerSingleton.Instance().NotificationLogFunc = s => DisplayNotification(s);
        }
Exemplo n.º 3
0
        private void PerformHotSampling()
        {
            if (_newWidthBox.Value < 100 || _newHeightBox.Value < 100)
            {
                return;
            }
            if ((Win32Wrapper.IsIconic(_gameWindowHwnd) || Win32Wrapper.IsZoomed(_gameWindowHwnd)))
            {
                Win32Wrapper.ShowWindow(_gameWindowHwnd, Win32Wrapper.SW_SHOWNOACTIVATE);
            }

            int newHorizontalResolution = (int)_newWidthBox.Value;
            int newVerticalResolution   = (int)_newHeightBox.Value;
            // always set the window at (0,0), if width is >= screen width.
            var  screenBounds = Screen.FromHandle(_gameWindowHwnd).Bounds;
            uint uFlags       = Win32Wrapper.SWP_NOZORDER | Win32Wrapper.SWP_NOACTIVATE | Win32Wrapper.SWP_NOOWNERZORDER | Win32Wrapper.SWP_NOSENDCHANGING;

            if (newHorizontalResolution < screenBounds.Width)
            {
                // let the window be where it is.
                uFlags |= Win32Wrapper.SWP_NOMOVE;
            }

            Win32Wrapper.SetWindowPos(_gameWindowHwnd, 0, 0, 0, newHorizontalResolution, newVerticalResolution, uFlags);
            if (GameSpecificConstants.HotsamplingRequiresEXITSIZEMOVE)
            {
                // A warning of unreachable code will be raised here, that's ok. this code is only used when the constant is true
                Win32Wrapper.SendMessage(_gameWindowHwnd, Win32Wrapper.WM_EXITSIZEMOVE, 0, 0);
            }

            LogHandlerSingleton.Instance().LogLine("Switching resolution on window with hwnd 0x{0} to resolution {1}x{2}", "Hotsampler", _gameWindowHwnd.ToString("x"),
                                                   newHorizontalResolution, newVerticalResolution);

            // remove / add borders
            uint nStyle = (uint)Win32Wrapper.GetWindowLong(_gameWindowHwnd, Win32Wrapper.GWL_STYLE);

            nStyle = (nStyle | (Win32Wrapper.WS_THICKFRAME + Win32Wrapper.WS_DLGFRAME + Win32Wrapper.WS_BORDER + Win32Wrapper.WS_MAXIMIZEBOX + Win32Wrapper.WS_MINIMIZEBOX));
            if (_useWindowBordersCheckBox.IsChecked == false)
            {
                nStyle ^= (Win32Wrapper.WS_THICKFRAME + Win32Wrapper.WS_DLGFRAME + Win32Wrapper.WS_BORDER + Win32Wrapper.WS_MAXIMIZEBOX + Win32Wrapper.WS_MINIMIZEBOX);
            }
            Win32Wrapper.SetWindowLong(_gameWindowHwnd, Win32Wrapper.GWL_STYLE, nStyle);
            uFlags = Win32Wrapper.SWP_NOSIZE | Win32Wrapper.SWP_NOMOVE | Win32Wrapper.SWP_NOZORDER | Win32Wrapper.SWP_NOACTIVATE | Win32Wrapper.SWP_NOOWNERZORDER | Win32Wrapper.SWP_NOSENDCHANGING | Win32Wrapper.SWP_FRAMECHANGED;
            Win32Wrapper.SetWindowPos(_gameWindowHwnd, 0, 0, 0, 0, 0, uFlags);

            // Send the resize viewport message to the dll so it can resize the viewport based on the new resolution. The game itself won't resize the viewport on its own.
            MessageHandlerSingleton.Instance().SendResizeViewportAction(newHorizontalResolution, newVerticalResolution);

            AddResolutionToRecentlyUsedList(newHorizontalResolution, newVerticalResolution);

            if (_switchAfterResizingCheckBox.IsChecked == true)
            {
                // focus the attached application's window
                Win32Wrapper.SetForegroundWindow(_gameWindowHwnd);
            }
        }
        private void HandleDllInjected()
        {
            // enable all tabs
            _hotsamplingTab.Enabled = true;
            _settingsTab.Enabled    = true;
            _keyBindingsTab.Enabled = true;
            // show the resolutions on the hotsampling tab
            _hotsamplingControl.BindData();

            // Send preferred rendering API.
            AppStateSingleton.Instance().PreferredRenderApiKind = _generalTabControl.SelectedRenderAPI;
            MessageHandlerSingleton.Instance().SendDXGIHookActionForPreferredRenderAPI(_generalTabControl.SelectedRenderAPI);
        }
Exemplo n.º 5
0
 private void _rehookXInputButton_OnClick(object sender, RoutedEventArgs e)
 {
     MessageHandlerSingleton.Instance().SendRehookXInputAction();
 }
 private void _displayNotificationsCheckBox_CheckedChanged(object sender, RoutedEventArgs e)
 {
     MessageHandlerSingleton.Instance().DisplayNotifications = _displayNotificationsCheckBox.IsChecked ?? false;
 }