void MainTabControl_SelectedIndexChanged(object sender, EventArgs e) { if (MainTabControl.SelectedTab == HelpTabPage && !HelpInit) { // Move this here so interface will load one second faster. HelpInit = true; var stream = EngineHelper.GetResource("Documents.Help.htm"); var sr = new StreamReader(stream); NameValueCollection list = new NameValueCollection(); list.Add("font-name-default", "'Microsoft Sans Serif'"); list.Add("font-size-default", "16"); HelpRichTextBox.Rtf = Html2Rtf.Converter.Html2Rtf(sr.ReadToEnd(), list); HelpRichTextBox.SelectAll(); HelpRichTextBox.SelectionIndent = 8; HelpRichTextBox.SelectionRightIndent = 8; HelpRichTextBox.DeselectAll(); } else if (MainTabControl.SelectedTab == ControllerSettingsTabPage) { if (OptionsPanel.InternetCheckBox.Checked && OptionsPanel.InternetAutoloadCheckBox.Checked) { SettingsDatabasePanel.RefreshGrid(true); } } UpdateHelpHeader(); }
/// <summary> /// Access this only inside Timer_Click! /// </summary> bool RefreshCurrentInstances(bool forceReload = false) { // If you encounter "LoaderLock was detected" Exception when debugging then: // Make sure that you have reference to Microsoft.Directx.dll. bool instancesChanged = false; DeviceInstance[] devices = null; //var types = DeviceType.Driving | DeviceType.Flight | DeviceType.Gamepad | DeviceType.Joystick | DeviceType.FirstPerson; if (forceRecountDevices || forceReload) { devices = GetDevices(); // Sore device instances and their order here. deviceInstancesNew = string.Join(",", devices.Select(x => x == null ? "" : x.InstanceGuid.ToString())); forceRecountDevices = false; } //Populate All devices if (deviceInstancesNew != deviceInstancesOld) { deviceInstancesOld = deviceInstancesNew; if (devices == null) { devices = GetDevices(); } var instances = devices; // Dispose from previous list of devices. for (int i = 0; i < 4; i++) { if (diDevices[i] != null) { // Dispose current device. diDevices[i].Unacquire(); diDevices[i].Dispose(); } } // Create new list of devices. for (int i = 0; i < 4; i++) { diDevices[i] = instances[i] == null ? null : new Joystick(Manager, instances[i].InstanceGuid); } SettingsDatabasePanel.BindDevices(instances); SettingsDatabasePanel.BindFiles(); for (int i = 0; i < 4; i++) { // Backup old instance. diInstancesOld[i] = diInstances[i]; // Assign new instance. diInstances[i] = instances[i]; } instancesChanged = true; } // Return true if instances changed. return(instancesChanged); }
/// <summary> /// Access this only insite Timer_Click! /// </summary> bool RefreshCurrentInstances() { // If you encounter "LoaderLock was detected" Exception when debugging then: // Make sure that you have reference to Microsoft.Directx.dll. bool instancesChanged = false; IList <DeviceInstance> devices = null; //var types = DeviceType.Driving | DeviceType.Flight | DeviceType.Gamepad | DeviceType.Joystick | DeviceType.FirstPerson; if (forceRecountDevices) { devices = Manager.GetDevices(DeviceClass.GameControl, DeviceEnumerationFlags.AllDevices); deviceCount = devices.Count; forceRecountDevices = false; } //Populate All devices if (deviceCount != _diCount) { _diCount = deviceCount; if (devices == null) { devices = Manager.GetDevices(DeviceClass.GameControl, DeviceEnumerationFlags.AllDevices); } var instances = devices; // Dispose from previous list of devices. for (int i = 0; i < diDevices.Count; i++) { // Dispose current device. diDevices[i].Unacquire(); diDevices[i].Dispose(); } diDevices.Clear(); // Create new list of devices. for (int i = 0; i < instances.Count; i++) { var ig = instances[i].InstanceGuid; var device = new Joystick(Manager, ig); //device.SetCooperativeLevel(this, CooperativeLevel.Background | CooperativeLevel.NonExclusive); //device.Acquire(); diDevices.Add(device); } SettingsDatabasePanel.BindDevices(instances); SettingsDatabasePanel.BindFiles(); // Assign new list of instances. diInstancesOld.Clear(); diInstancesOld.AddRange(diInstances.ToArray()); diInstances.Clear(); diInstances.AddRange(instances.ToArray()); instancesChanged = true; } // Return true if instances changed. return(instancesChanged); }
void UpdateForm2() { // Set status labels. StatusIsAdminLabel.Text = WinAPI.IsVista ? string.Format("Elevated: {0}", WinAPI.IsElevated()) : ""; StatusIniLabel.Text = SettingManager.IniFileName; CheckEncoding(SettingManager.TmpFileName); CheckEncoding(SettingManager.IniFileName); // Show status values. MainStatusStrip.Visible = true; // Load PAD controls. ControlPads = new PadControl[4]; for (int i = 0; i < ControlPads.Length; i++) { ControlPads[i] = new Controls.PadControl(i); ControlPads[i].Name = string.Format("ControlPad{0}", i + 1); ControlPads[i].Dock = DockStyle.Fill; ControlPages[i].Controls.Add(ControlPads[i]); ControlPads[i].InitPadControl(); } // Initialize pre-sets. Execute only after name of cIniFile is set. SettingsDatabasePanel.InitPresets(); // Allow events after PAD control are loaded. MainTabControl.SelectedIndexChanged += new System.EventHandler(this.MainTabControl_SelectedIndexChanged); // Load about control. ControlAbout = new AboutControl(); ControlAbout.Dock = DockStyle.Fill; AboutTabPage.Controls.Add(ControlAbout); // Update settings map. UpdateSettingsMap(); ReloadXinputSettings(); //// start capture events. if (WinAPI.IsVista && WinAPI.IsElevated() && WinAPI.IsInAdministratorRole) { this.Text += " (Administrator)"; } }
void LoadForm() { formLoaded = true; detector = new DeviceDetector(false); detector.DeviceChanged += new DeviceDetector.DeviceDetectorEventHandler(detector_DeviceChanged); BusyLoadingCircle.Visible = false; BusyLoadingCircle.Top = HeaderPictureBox.Top; BusyLoadingCircle.Left = HeaderPictureBox.Left; defaultBody = HelpBodyLabel.Text; //if (DesignMode) return; // init default OptionsPanel.InitOptions(); // Set status. StatusSaveLabel.Visible = false; StatusEventsLabel.Visible = false; // Load Tab pages. ControlPages = new TabPage[4]; ControlPages[0] = Pad1TabPage; ControlPages[1] = Pad2TabPage; ControlPages[2] = Pad3TabPage; ControlPages[3] = Pad4TabPage; //BuletImageList.Images.Add("bullet_square_glass_blue.png", new Bitmap(Helper.GetResource("Images.bullet_square_glass_blue.png"))); //BuletImageList.Images.Add("bullet_square_glass_green.png", new Bitmap(Helper.GetResource("Images.bullet_square_glass_green.png"))); //BuletImageList.Images.Add("bullet_square_glass_grey.png", new Bitmap(Helper.GetResource("Images.bullet_square_glass_grey.png"))); //BuletImageList.Images.Add("bullet_square_glass_red.png", new Bitmap(Helper.GetResource("Images.bullet_square_glass_red.png"))); //BuletImageList.Images.Add("bullet_square_glass_yellow.png", new Bitmap(Helper.GetResource("Images.bullet_square_glass_yellow.png"))); foreach (var item in ControlPages) { item.ImageKey = "bullet_square_glass_grey.png"; } // Hide status values. StatusDllLabel.Text = ""; MainStatusStrip.Visible = false; // Check if ini and dll is on disk. if (!CheckFiles(true)) { return; } CheckEncoding(SettingManager.TmpFileName); CheckEncoding(SettingManager.IniFileName); // Show status values. MainStatusStrip.Visible = true; // Load PAD controls. ControlPads = new Controls.PadControl[4]; for (int i = 0; i < ControlPads.Length; i++) { ControlPads[i] = new Controls.PadControl(i); ControlPads[i].Name = string.Format("ControlPad{0}", i + 1); ControlPads[i].Dock = DockStyle.Fill; ControlPages[i].Controls.Add(ControlPads[i]); ControlPads[i].InitPadControl(); } // Init presets. Execute only after name of cIniFile is set. SettingsDatabasePanel.InitPresets(); // Allow events after PAD control are loaded. MainTabControl.SelectedIndexChanged += new System.EventHandler(this.MainTabControl_SelectedIndexChanged); // Load about control. ControlAbout = new Controls.AboutControl(); ControlAbout.Dock = DockStyle.Fill; AboutTabPage.Controls.Add(ControlAbout); // Update settings map. UpdateSettingsMap(); ReloadXinputSettings(); ////InitDirectInputTab(); //// Timer will execute ReloadXInputLibrary(); ////XInput.ReLoadLibrary(cXinput3File); ////XInput.ReLoadLibrary(cXinput3File); //// start capture events. if (WinAPI.IsVista && WinAPI.IsElevated() && WinAPI.IsInAdministratorRole) { this.Text += " (Administrator)"; } ////ReloadXInputLibrary(); }