mirror of
https://github.com/terrymacdonald/DisplayMagician.git
synced 2024-08-30 18:32:20 +00:00
Working icon selector
It looks like the work is done on the icon selector. Adds #51, hopefully fixing the last issue in #49 too.
This commit is contained in:
parent
4d9216328d
commit
41a75acb1a
@ -296,7 +296,11 @@ namespace DisplayMagician.GameLibraries
|
||||
// Note: This may be an icon file, or an exe file.
|
||||
// This function tries to get a 256x256 Vista sized bitmap from the file
|
||||
logger.Trace($"Program/LoadGamesInBackground: Attempting to get game bitmaps from {game.Name}.");
|
||||
bmList = ImageUtils.GetMeAllBitmapsFromFile(game.IconPath);
|
||||
bmList.AddRange(ImageUtils.GetMeAllBitmapsFromFile(game.IconPath));
|
||||
if (game.ExePath != game.IconPath)
|
||||
{
|
||||
bmList.AddRange(ImageUtils.GetMeAllBitmapsFromFile(game.ExePath));
|
||||
}
|
||||
logger.Trace($"Program/LoadGamesInBackground: Got game bitmaps from {game.Name}.");
|
||||
|
||||
}
|
||||
@ -308,38 +312,29 @@ namespace DisplayMagician.GameLibraries
|
||||
if (bmList.Count == 0)
|
||||
{
|
||||
ShortcutBitmap bm = new ShortcutBitmap();
|
||||
bm.UUID = Guid.NewGuid().ToString("D");
|
||||
bm.Order = bmList.Count;
|
||||
bm.Source = game.ExePath;
|
||||
if (game.GameLibrary.Equals(SupportedGameLibraryType.Steam))
|
||||
{
|
||||
bm.Name = "Steam";
|
||||
bm.Image = Properties.Resources.Steam;
|
||||
bm = ImageUtils.CreateShortcutBitmap(Properties.Resources.Steam, "Steam Icon", game.ExePath, bmList.Count);
|
||||
}
|
||||
else if (game.GameLibrary.Equals(SupportedGameLibraryType.Uplay))
|
||||
{
|
||||
bm.Name = "Uplay";
|
||||
bm.Image = Properties.Resources.Uplay;
|
||||
bm = ImageUtils.CreateShortcutBitmap(Properties.Resources.Uplay, "Uplay Icon", game.ExePath, bmList.Count);
|
||||
}
|
||||
else if (game.GameLibrary.Equals(SupportedGameLibraryType.Origin))
|
||||
{
|
||||
bm.Name = "Origin";
|
||||
bm.Image = Properties.Resources.Origin;
|
||||
bm = ImageUtils.CreateShortcutBitmap(Properties.Resources.Origin, "Origin Icon", game.ExePath, bmList.Count);
|
||||
}
|
||||
else if (game.GameLibrary.Equals(SupportedGameLibraryType.Epic))
|
||||
{
|
||||
bm.Name = "Epic";
|
||||
bm.Image = Properties.Resources.Epic;
|
||||
bm = ImageUtils.CreateShortcutBitmap(Properties.Resources.Epic, "Epic Icon", game.ExePath, bmList.Count);
|
||||
}
|
||||
else if (game.GameLibrary.Equals(SupportedGameLibraryType.GOG))
|
||||
{
|
||||
bm.Name = "GOG";
|
||||
bm.Image = Properties.Resources.GOG;
|
||||
bm = ImageUtils.CreateShortcutBitmap(Properties.Resources.GOG, "GOG Icon", game.ExePath, bmList.Count);
|
||||
}
|
||||
else
|
||||
{
|
||||
bm.Name = "DisplayMagician";
|
||||
bm.Image = Properties.Resources.DisplayMagician.ToBitmap();
|
||||
bm = ImageUtils.CreateShortcutBitmap(Properties.Resources.DisplayMagician.ToBitmap(), "DisplayMagician Icon", game.ExePath, bmList.Count);
|
||||
}
|
||||
// Add the shortcutbitmap to the list
|
||||
bmList.Add(bm);
|
||||
|
@ -26,8 +26,8 @@ using System.Resources;
|
||||
[assembly: Guid("e4ceaf5e-ad01-4695-b179-31168eb74c48")]
|
||||
|
||||
// Version information
|
||||
[assembly: AssemblyVersion("2.1.0.132")]
|
||||
[assembly: AssemblyFileVersion("2.1.0.132")]
|
||||
[assembly: AssemblyVersion("2.1.0.142")]
|
||||
[assembly: AssemblyFileVersion("2.1.0.142")]
|
||||
[assembly: NeutralResourcesLanguageAttribute( "en" )]
|
||||
[assembly: CLSCompliant(true)]
|
||||
|
||||
|
35
DisplayMagician/UIForms/ChooseIconForm.Designer.cs
generated
35
DisplayMagician/UIForms/ChooseIconForm.Designer.cs
generated
@ -31,36 +31,43 @@ namespace DisplayMagician.UIForms
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ChooseIconForm));
|
||||
this.lv_icons = new System.Windows.Forms.ListView();
|
||||
this.columnHeaderName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.pb_selected_icon = new System.Windows.Forms.PictureBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.btn_add = new System.Windows.Forms.Button();
|
||||
this.btn_select = new System.Windows.Forms.Button();
|
||||
this.btn_back = new System.Windows.Forms.Button();
|
||||
this.columnHeaderName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.columnHeaderSize = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
((System.ComponentModel.ISupportInitialize)(this.pb_selected_icon)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// lv_icons
|
||||
//
|
||||
this.lv_icons.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
||||
this.columnHeaderName});
|
||||
this.lv_icons.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
|
||||
this.columnHeaderName,
|
||||
this.columnHeaderSize});
|
||||
this.lv_icons.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
|
||||
this.lv_icons.HideSelection = false;
|
||||
this.lv_icons.Location = new System.Drawing.Point(26, 40);
|
||||
this.lv_icons.MultiSelect = false;
|
||||
this.lv_icons.Name = "lv_icons";
|
||||
this.lv_icons.ShowGroups = false;
|
||||
this.lv_icons.Size = new System.Drawing.Size(561, 200);
|
||||
this.lv_icons.Size = new System.Drawing.Size(370, 200);
|
||||
this.lv_icons.TabIndex = 0;
|
||||
this.lv_icons.UseCompatibleStateImageBehavior = false;
|
||||
this.lv_icons.View = System.Windows.Forms.View.Details;
|
||||
this.lv_icons.SelectedIndexChanged += new System.EventHandler(this.lv_icons_SelectedIndexChanged);
|
||||
//
|
||||
// columnHeaderName
|
||||
//
|
||||
this.columnHeaderName.Text = "Name";
|
||||
this.columnHeaderName.Width = 270;
|
||||
//
|
||||
// pb_selected_icon
|
||||
//
|
||||
this.pb_selected_icon.BackColor = System.Drawing.Color.DimGray;
|
||||
this.pb_selected_icon.Location = new System.Drawing.Point(593, 40);
|
||||
this.pb_selected_icon.Location = new System.Drawing.Point(402, 40);
|
||||
this.pb_selected_icon.Name = "pb_selected_icon";
|
||||
this.pb_selected_icon.Size = new System.Drawing.Size(200, 200);
|
||||
this.pb_selected_icon.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
|
||||
@ -73,7 +80,7 @@ namespace DisplayMagician.UIForms
|
||||
this.label1.BackColor = System.Drawing.Color.Black;
|
||||
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.label1.ForeColor = System.Drawing.Color.White;
|
||||
this.label1.Location = new System.Drawing.Point(238, 21);
|
||||
this.label1.Location = new System.Drawing.Point(139, 21);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(125, 16);
|
||||
this.label1.TabIndex = 2;
|
||||
@ -86,7 +93,7 @@ namespace DisplayMagician.UIForms
|
||||
this.label2.BackColor = System.Drawing.Color.Black;
|
||||
this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.label2.ForeColor = System.Drawing.Color.White;
|
||||
this.label2.Location = new System.Drawing.Point(652, 21);
|
||||
this.label2.Location = new System.Drawing.Point(457, 21);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(93, 16);
|
||||
this.label2.TabIndex = 3;
|
||||
@ -110,7 +117,7 @@ namespace DisplayMagician.UIForms
|
||||
this.btn_select.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.btn_select.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.btn_select.ForeColor = System.Drawing.Color.White;
|
||||
this.btn_select.Location = new System.Drawing.Point(314, 261);
|
||||
this.btn_select.Location = new System.Drawing.Point(218, 261);
|
||||
this.btn_select.Name = "btn_select";
|
||||
this.btn_select.Size = new System.Drawing.Size(176, 30);
|
||||
this.btn_select.TabIndex = 40;
|
||||
@ -123,7 +130,7 @@ namespace DisplayMagician.UIForms
|
||||
this.btn_back.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.btn_back.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.btn_back.ForeColor = System.Drawing.Color.White;
|
||||
this.btn_back.Location = new System.Drawing.Point(714, 261);
|
||||
this.btn_back.Location = new System.Drawing.Point(525, 261);
|
||||
this.btn_back.Name = "btn_back";
|
||||
this.btn_back.Size = new System.Drawing.Size(79, 30);
|
||||
this.btn_back.TabIndex = 41;
|
||||
@ -131,17 +138,17 @@ namespace DisplayMagician.UIForms
|
||||
this.btn_back.UseVisualStyleBackColor = true;
|
||||
this.btn_back.Click += new System.EventHandler(this.btn_back_Click);
|
||||
//
|
||||
// columnHeaderName
|
||||
// columnHeaderSize
|
||||
//
|
||||
this.columnHeaderName.Text = "Name";
|
||||
this.columnHeaderName.Width = 550;
|
||||
this.columnHeaderSize.Text = "Size";
|
||||
this.columnHeaderSize.Width = 70;
|
||||
//
|
||||
// ChooseIconForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.Color.Black;
|
||||
this.ClientSize = new System.Drawing.Size(819, 319);
|
||||
this.ClientSize = new System.Drawing.Size(629, 319);
|
||||
this.Controls.Add(this.btn_back);
|
||||
this.Controls.Add(this.btn_select);
|
||||
this.Controls.Add(this.btn_add);
|
||||
@ -156,6 +163,7 @@ namespace DisplayMagician.UIForms
|
||||
this.Name = "ChooseIconForm";
|
||||
this.ShowIcon = false;
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Choose shortcut icon";
|
||||
this.TopMost = true;
|
||||
this.Load += new System.EventHandler(this.ChooseIconForm_Load);
|
||||
@ -175,5 +183,6 @@ namespace DisplayMagician.UIForms
|
||||
private System.Windows.Forms.Button btn_select;
|
||||
private System.Windows.Forms.Button btn_back;
|
||||
private System.Windows.Forms.ColumnHeader columnHeaderName;
|
||||
private System.Windows.Forms.ColumnHeader columnHeaderSize;
|
||||
}
|
||||
}
|
@ -46,7 +46,11 @@ namespace DisplayMagician.UIForms
|
||||
int imageCount = 1;
|
||||
foreach (ShortcutBitmap sc in AvailableImages)
|
||||
{
|
||||
ListViewItem lvi = new ListViewItem($"Image {sc.Order} from {sc.Source}");
|
||||
string[] stringsToAdd = new string[] {
|
||||
$"Image {sc.Order} from {sc.Name}",
|
||||
$"{sc.Size.Width} x {sc.Size.Height}"
|
||||
};
|
||||
ListViewItem lvi = new ListViewItem(stringsToAdd);
|
||||
lvi.Name = sc.UUID;
|
||||
if (sc.Equals(SelectedImage))
|
||||
{
|
||||
|
@ -1403,8 +1403,12 @@ namespace DisplayMagician.UIForms
|
||||
// If the game is selected, then grab images from the game
|
||||
if (shortcutGame != null)
|
||||
{
|
||||
_availableImages.AddRange(ImageUtils.GetMeAllBitmapsFromFile(shortcutGame.ExePath));
|
||||
_availableImages.AddRange(ImageUtils.GetMeAllBitmapsFromFile(shortcutGame.IconPath));
|
||||
if (shortcutGame.ExePath != shortcutGame.IconPath)
|
||||
{
|
||||
_availableImages.AddRange(ImageUtils.GetMeAllBitmapsFromFile(shortcutGame.ExePath));
|
||||
}
|
||||
|
||||
}
|
||||
// If the different exe to monitor is set, then grab the icons from there too!
|
||||
if (!String.IsNullOrWhiteSpace(_shortcutToEdit.DifferentGameExeToMonitor) && File.Exists(_shortcutToEdit.DifferentGameExeToMonitor))
|
||||
@ -1621,6 +1625,11 @@ namespace DisplayMagician.UIForms
|
||||
// Empty the bitmaps
|
||||
EmptyTheImages();
|
||||
|
||||
if (!String.IsNullOrWhiteSpace(txt_executable.Text) && File.Exists(txt_executable.Text))
|
||||
{
|
||||
UpdateExeImagesUI();
|
||||
}
|
||||
|
||||
SuggestShortcutName();
|
||||
EnableSaveButtonIfValid();
|
||||
}
|
||||
@ -1971,6 +1980,21 @@ namespace DisplayMagician.UIForms
|
||||
private void btn_exe_to_start_Click(object sender, EventArgs e)
|
||||
{
|
||||
txt_executable.Text = getExeFile();
|
||||
UpdateExeImagesUI();
|
||||
}
|
||||
|
||||
private void UpdateExeImagesUI()
|
||||
{
|
||||
_availableImages = new List<ShortcutBitmap>();
|
||||
_availableImages.AddRange(ImageUtils.GetMeAllBitmapsFromFile(txt_executable.Text));
|
||||
if (rb_wait_alternative_executable.Checked && File.Exists(txt_alternative_executable.Text))
|
||||
{
|
||||
_availableImages.AddRange(ImageUtils.GetMeAllBitmapsFromFile(txt_alternative_executable.Text));
|
||||
}
|
||||
_selectedImage = ImageUtils.GetMeLargestAvailableBitmap(_availableImages);
|
||||
_shortcutToEdit.SelectedImage = _selectedImage;
|
||||
pb_exe_icon.Image = _selectedImage.Image;
|
||||
btn_choose_exe_icon.Enabled = true;
|
||||
}
|
||||
|
||||
private void txt_shortcut_save_name_Click(object sender, EventArgs e)
|
||||
@ -2700,11 +2724,11 @@ namespace DisplayMagician.UIForms
|
||||
|
||||
private void btn_choose_exe_icon_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (rb_standalone.Checked && _shortcutToEdit.AvailableImages.Count > 0)
|
||||
if (rb_standalone.Checked && _availableImages.Count > 0)
|
||||
{
|
||||
ChooseIconForm exeIconForm = new ChooseIconForm();
|
||||
exeIconForm.AvailableImages = _shortcutToEdit.AvailableImages;
|
||||
exeIconForm.SelectedImage = _shortcutToEdit.SelectedImage;
|
||||
exeIconForm.AvailableImages = _availableImages;
|
||||
exeIconForm.SelectedImage = _selectedImage;
|
||||
if (exeIconForm.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
_availableImages = exeIconForm.AvailableImages;
|
||||
@ -2720,8 +2744,8 @@ namespace DisplayMagician.UIForms
|
||||
if (rb_launcher.Checked && _shortcutToEdit.AvailableImages.Count > 0)
|
||||
{
|
||||
ChooseIconForm gameIconForm = new ChooseIconForm();
|
||||
gameIconForm.AvailableImages = _shortcutToEdit.AvailableImages;
|
||||
gameIconForm.SelectedImage = _shortcutToEdit.SelectedImage;
|
||||
gameIconForm.AvailableImages = _availableImages;
|
||||
gameIconForm.SelectedImage = _selectedImage;
|
||||
if (gameIconForm.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
_availableImages = gameIconForm.AvailableImages;
|
||||
|
Loading…
Reference in New Issue
Block a user