mirror of
https://github.com/terrymacdonald/DisplayMagician.git
synced 2024-08-30 18:32:20 +00:00
Major improvement for ShortcutForm loading speed
Also fixes the most recent bug highlighted by erbkaiser in #49.
This commit is contained in:
parent
058060ed60
commit
ea38f25e28
@ -26,8 +26,8 @@ using System.Resources;
|
||||
[assembly: Guid("e4ceaf5e-ad01-4695-b179-31168eb74c48")]
|
||||
|
||||
// Version information
|
||||
[assembly: AssemblyVersion("2.1.0.228")]
|
||||
[assembly: AssemblyFileVersion("2.1.0.228")]
|
||||
[assembly: AssemblyVersion("2.1.0.239")]
|
||||
[assembly: AssemblyFileVersion("2.1.0.239")]
|
||||
[assembly: NeutralResourcesLanguageAttribute( "en" )]
|
||||
[assembly: CLSCompliant(true)]
|
||||
|
||||
|
34
DisplayMagician/UIForms/ShortcutForm.Designer.cs
generated
34
DisplayMagician/UIForms/ShortcutForm.Designer.cs
generated
@ -93,6 +93,7 @@ namespace DisplayMagician.UIForms
|
||||
this.rb_standalone = new System.Windows.Forms.RadioButton();
|
||||
this.rb_no_game = new System.Windows.Forms.RadioButton();
|
||||
this.p_game = new System.Windows.Forms.Panel();
|
||||
this.btn_refresh_games_list = new System.Windows.Forms.Button();
|
||||
this.btn_choose_game_icon = new System.Windows.Forms.Button();
|
||||
this.pb_game_icon = new System.Windows.Forms.PictureBox();
|
||||
this.lbl_no_game_libraries = new System.Windows.Forms.Label();
|
||||
@ -132,7 +133,6 @@ namespace DisplayMagician.UIForms
|
||||
this.cb_autosuggest = new System.Windows.Forms.CheckBox();
|
||||
this.btn_hotkey = new System.Windows.Forms.Button();
|
||||
this.lbl_hotkey_assigned = new System.Windows.Forms.Label();
|
||||
this.btn_refresh_games_list = new System.Windows.Forms.Button();
|
||||
this.tabc_shortcut.SuspendLayout();
|
||||
this.tabp_display.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pbLogo)).BeginInit();
|
||||
@ -996,6 +996,22 @@ namespace DisplayMagician.UIForms
|
||||
this.p_game.Size = new System.Drawing.Size(1076, 389);
|
||||
this.p_game.TabIndex = 7;
|
||||
//
|
||||
// btn_refresh_games_list
|
||||
//
|
||||
this.btn_refresh_games_list.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btn_refresh_games_list.FlatAppearance.MouseDownBackColor = System.Drawing.Color.IndianRed;
|
||||
this.btn_refresh_games_list.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Brown;
|
||||
this.btn_refresh_games_list.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.btn_refresh_games_list.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.btn_refresh_games_list.ForeColor = System.Drawing.Color.White;
|
||||
this.btn_refresh_games_list.Location = new System.Drawing.Point(950, 162);
|
||||
this.btn_refresh_games_list.Name = "btn_refresh_games_list";
|
||||
this.btn_refresh_games_list.Size = new System.Drawing.Size(117, 25);
|
||||
this.btn_refresh_games_list.TabIndex = 42;
|
||||
this.btn_refresh_games_list.Text = "Refresh Games List";
|
||||
this.btn_refresh_games_list.UseVisualStyleBackColor = true;
|
||||
this.btn_refresh_games_list.Click += new System.EventHandler(this.btn_refresh_games_list_Click);
|
||||
//
|
||||
// btn_choose_game_icon
|
||||
//
|
||||
this.btn_choose_game_icon.Enabled = false;
|
||||
@ -1491,22 +1507,6 @@ namespace DisplayMagician.UIForms
|
||||
this.lbl_hotkey_assigned.Visible = false;
|
||||
this.lbl_hotkey_assigned.Click += new System.EventHandler(this.lbl_hotkey_assigned_Click);
|
||||
//
|
||||
// btn_refresh_games_list
|
||||
//
|
||||
this.btn_refresh_games_list.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btn_refresh_games_list.FlatAppearance.MouseDownBackColor = System.Drawing.Color.IndianRed;
|
||||
this.btn_refresh_games_list.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Brown;
|
||||
this.btn_refresh_games_list.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.btn_refresh_games_list.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.btn_refresh_games_list.ForeColor = System.Drawing.Color.White;
|
||||
this.btn_refresh_games_list.Location = new System.Drawing.Point(950, 162);
|
||||
this.btn_refresh_games_list.Name = "btn_refresh_games_list";
|
||||
this.btn_refresh_games_list.Size = new System.Drawing.Size(117, 25);
|
||||
this.btn_refresh_games_list.TabIndex = 42;
|
||||
this.btn_refresh_games_list.Text = "Refresh Games List";
|
||||
this.btn_refresh_games_list.UseVisualStyleBackColor = true;
|
||||
this.btn_refresh_games_list.Click += new System.EventHandler(this.btn_refresh_games_list_Click);
|
||||
//
|
||||
// ShortcutForm
|
||||
//
|
||||
this.AcceptButton = this.btn_save;
|
||||
|
@ -61,10 +61,11 @@ namespace DisplayMagician.UIForms
|
||||
//private string _userExeIconPath = "";
|
||||
private List<ShortcutBitmap> _availableImages = new List<ShortcutBitmap>();
|
||||
private ShortcutBitmap _selectedImage = new ShortcutBitmap();
|
||||
private bool _firstShow = true;
|
||||
|
||||
private static readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
|
||||
|
||||
public ShortcutForm(ShortcutItem shortcutToEdit, bool editingExistingShortcut = false)
|
||||
public ShortcutForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
Program.AppSplashScreen = new LoadingForm();
|
||||
@ -82,9 +83,6 @@ namespace DisplayMagician.UIForms
|
||||
_profileAdaptor = new ProfileAdaptor();
|
||||
_gameAdaptor = new GameAdaptor();
|
||||
|
||||
_editingExistingShortcut = editingExistingShortcut;
|
||||
_shortcutToEdit = shortcutToEdit;
|
||||
|
||||
// Style the Saved Profiles list
|
||||
ilv_saved_profiles.MultiSelect = false;
|
||||
ilv_saved_profiles.ThumbnailSize = new Size(100, 100);
|
||||
@ -126,6 +124,7 @@ namespace DisplayMagician.UIForms
|
||||
public ShortcutItem Shortcut
|
||||
{
|
||||
get => _shortcutToEdit;
|
||||
set => _shortcutToEdit = value;
|
||||
}
|
||||
|
||||
public bool EditingExistingShortcut
|
||||
@ -940,22 +939,63 @@ namespace DisplayMagician.UIForms
|
||||
}
|
||||
}
|
||||
|
||||
private void ShortcutForm_Load(object sender, EventArgs e)
|
||||
private void ClearForm()
|
||||
{
|
||||
// Clear the textboxes
|
||||
txt_alternative_executable.Text = "";
|
||||
txt_alternative_game.Text = "";
|
||||
txt_args_executable.Text = "";
|
||||
txt_args_game.Text = "";
|
||||
txt_executable.Text = "";
|
||||
txt_game_name.Text = "Please select a game from the list below...";
|
||||
txt_run_cmd_afterwards.Text = "";
|
||||
txt_run_cmd_afterwards_args.Text = "";
|
||||
txt_shortcut_save_name.Text = "";
|
||||
|
||||
// Set the radio buttons to default
|
||||
rb_no_change_audio.Checked = true;
|
||||
rb_change_audio.Checked = false;
|
||||
rb_keep_audio_volume.Checked = true;
|
||||
rb_set_audio_volume.Checked = false;
|
||||
rb_change_capture.Checked = false;
|
||||
rb_keep_capture_volume.Checked = false;
|
||||
rb_no_change_capture.Checked = true;
|
||||
rb_set_capture_volume.Checked = false;
|
||||
|
||||
// Set the game mode on load
|
||||
rb_launcher.Checked = true;
|
||||
rb_no_game.Checked = false;
|
||||
rb_standalone.Checked = false;
|
||||
|
||||
// Set the checkboxes
|
||||
cb_args_executable.Checked = false;
|
||||
cb_args_game.Checked = false;
|
||||
cb_autosuggest.Checked = true;
|
||||
cb_run_cmd_afterwards.Checked = false;
|
||||
cb_run_cmd_afterwards_args.Checked = false;
|
||||
cb_wait_alternative_game.Checked = false;
|
||||
|
||||
// Wipe the pictureboxes if they're in use
|
||||
if (pb_exe_icon.Image != null)
|
||||
{
|
||||
pb_exe_icon.Image = null;
|
||||
}
|
||||
if (pb_game_icon.Image != null)
|
||||
{
|
||||
pb_game_icon.Image = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadShortcut()
|
||||
{
|
||||
Game shortcutGame = null;
|
||||
|
||||
|
||||
// Parse the game bitmaps now the first time as we need them
|
||||
// We need to add a refresh button to the shortcut page now!
|
||||
if (!GameLibraries.GameLibrary.GamesImagesLoaded)
|
||||
{
|
||||
GameLibraries.GameLibrary.RefreshGameBitmaps();
|
||||
}
|
||||
|
||||
// Load all the profiles to prepare things
|
||||
bool foundChosenProfileInLoadedProfiles = false;
|
||||
ProfileItem chosenProfile = null;
|
||||
|
||||
ClearForm();
|
||||
|
||||
// Prepare the Game process priority combo box
|
||||
cbx_game_priority.DataSource = new ComboItem[] {
|
||||
new ComboItem{ Value = ProcessPriority.High, Text = "High" },
|
||||
@ -982,6 +1022,9 @@ namespace DisplayMagician.UIForms
|
||||
cbx_exe_priority.SelectedIndex = 2; //Normal
|
||||
cbx_exe_priority.Enabled = true;
|
||||
|
||||
// Empty the selected game in case this is a reload
|
||||
txt_alternative_executable.Text = "";
|
||||
|
||||
// Populate all the Audio devices in the audio devices list.
|
||||
// Set the Audio device to the shortcut audio device only if
|
||||
// the Change Audio radiobutton is set
|
||||
@ -1592,7 +1635,7 @@ namespace DisplayMagician.UIForms
|
||||
continue;
|
||||
}
|
||||
|
||||
StartProgramControl startProgramControl = new StartProgramControl(myStartProgram,spOrder);
|
||||
StartProgramControl startProgramControl = new StartProgramControl(myStartProgram, spOrder);
|
||||
startProgramControl.Dock = DockStyle.None;
|
||||
if (spOrder == 1)
|
||||
{
|
||||
@ -1639,8 +1682,26 @@ namespace DisplayMagician.UIForms
|
||||
// Finally enable the save button if it's still valid
|
||||
EnableSaveButtonIfValid();
|
||||
|
||||
}
|
||||
|
||||
private void ShortcutForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_firstShow)
|
||||
{
|
||||
// Parse the game bitmaps now the first time as we need them
|
||||
// We need to add a refresh button to the shortcut page now!
|
||||
if (!GameLibraries.GameLibrary.GamesImagesLoaded)
|
||||
{
|
||||
GameLibraries.GameLibrary.RefreshGameBitmaps();
|
||||
}
|
||||
|
||||
// Close the splash screen
|
||||
CloseTheSplashScreen();
|
||||
_firstShow = false;
|
||||
}
|
||||
// Load the shortcut info
|
||||
LoadShortcut();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -2870,6 +2931,7 @@ namespace DisplayMagician.UIForms
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Exclamation);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Class used to populate combo boxes
|
||||
|
@ -219,7 +219,7 @@
|
||||
this.tsmi_copy,
|
||||
this.tsmi_delete});
|
||||
this.cms_shortcuts.Name = "cms_shortcuts";
|
||||
this.cms_shortcuts.Size = new System.Drawing.Size(216, 136);
|
||||
this.cms_shortcuts.Size = new System.Drawing.Size(216, 114);
|
||||
//
|
||||
// tsmi_edit
|
||||
//
|
||||
|
@ -265,11 +265,15 @@ namespace DisplayMagician.UIForms
|
||||
private void btn_new_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.Cursor = Cursors.WaitCursor;
|
||||
ShortcutItem si = new ShortcutItem();
|
||||
if (_shortcutForm == null)
|
||||
{
|
||||
_shortcutForm = new ShortcutForm(new ShortcutItem(), false);
|
||||
_shortcutForm = new ShortcutForm();
|
||||
}
|
||||
//ShortcutRepository.IsValidRefresh();
|
||||
//ShortcutRepository.IsValidRefresh()
|
||||
// Set the Shortcut to as a new shortcut
|
||||
_shortcutForm.Shortcut = si;
|
||||
_shortcutForm.EditingExistingShortcut = false;
|
||||
_shortcutForm.ShowDialog(this);
|
||||
if (_shortcutForm.DialogResult == DialogResult.OK)
|
||||
{
|
||||
@ -317,7 +321,12 @@ namespace DisplayMagician.UIForms
|
||||
|
||||
this.Cursor = Cursors.WaitCursor;
|
||||
|
||||
_shortcutForm = new ShortcutForm(_selectedShortcut,true);
|
||||
if (_shortcutForm == null)
|
||||
{
|
||||
_shortcutForm = new ShortcutForm();
|
||||
}
|
||||
_shortcutForm.Shortcut = _selectedShortcut;
|
||||
_shortcutForm.EditingExistingShortcut = true;
|
||||
//ilv_saved_shortcuts.SuspendLayout();
|
||||
_shortcutForm.ShowDialog(this);
|
||||
if (_shortcutForm.DialogResult == DialogResult.OK)
|
||||
|
Loading…
Reference in New Issue
Block a user