[WIP] Progressing ShortcutLibrary loading

Still having issues with the shortcutAdaptor for the
Imagelistviewitem loading. Even though it's based
on the same code as the profileAdaptor it's not
reading the Shortcut bitmap properly. Too tired to
figure out why at the moment, so will be trying again
tomorrow. I expect its something to do with the
different Bitmap format for the two options. May
need to revise that to compare image data.
This commit is contained in:
temacdonald 2020-05-19 21:41:26 +12:00
parent 9dab00bdb4
commit 19a2f1543e
12 changed files with 54308 additions and 385 deletions

View File

@ -163,8 +163,15 @@ namespace HeliosPlus.Shared
}
public static List<Profile> AllSavedProfiles
{
get => _allSavedProfiles;
{
get
{
if (_allSavedProfiles.Count == 0)
{
Profile.LoadAllProfiles();
}
return _allSavedProfiles;
}
}
public static Profile CurrentProfile

View File

@ -31,7 +31,7 @@ namespace HeliosPlus {
{
internal static string AppDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "HeliosPlus");
internal static string ShortcutIconCachePath;
//internal static string ShortcutIconCachePath;
internal static Profile GetProfile(string profileName)
@ -122,7 +122,7 @@ namespace HeliosPlus {
Console.WriteLine(@"Copyright © Terry MacDonald 2020-{DateTime.Today.Year}");
Console.WriteLine(@"Based on Helios Display Management - Copyright © Soroush Falahati 2017-2020");
// Figure out where the shortcut's will go
/*// Figure out where the shortcut's will go
ShortcutIconCachePath = Path.Combine(AppDataPath, @"ShortcutIconCache");
// Create the Shortcut Icon Cache if it doesn't exist so that it's avilable for all the program
@ -147,7 +147,7 @@ namespace HeliosPlus {
catch
{
}
}
}*/
var app = new CommandLineApplication();
@ -257,10 +257,10 @@ namespace HeliosPlus {
Application.Run(new UIForms.MainForm());
}
catch (Exception e)
catch (Exception ex)
{
MessageBox.Show(
string.Format(Language.Operation_Failed, e.Message),
ex.Message,
Language.Fatal_Error,
MessageBoxButtons.OK,
MessageBoxIcon.Error);

View File

@ -36,6 +36,9 @@ namespace HeliosPlus
private static List<Shortcut> _allSavedShortcuts = new List<Shortcut>();
private MultiIcon _shortcutIcon, _originalIcon = null;
private Bitmap _shortcutBitmap, _originalBitmap = null;
private Profile _profileToUse = null;
private string _profileName = "";
private bool _isPossible = false;
public Shortcut()
{
@ -57,10 +60,13 @@ namespace HeliosPlus
get
{
if (ProfileToUse is Profile)
return ProfileToUse.Name;
else
return null;
}
_profileName = ProfileToUse.Name;
return _profileName;
}
set
{
_profileName = value;
}
}
public ShortcutPermanence Permanence { get; set; } = ShortcutPermanence.Temporary;
@ -93,7 +99,8 @@ namespace HeliosPlus
public string OriginalIconPath { get; set; } = "";
[JsonConverter(typeof(CustomBitmapConverter))]
//[JsonConverter(typeof(CustomBitmapConverter))]
[JsonIgnore]
public Bitmap OriginalBitmap
{
get
@ -119,7 +126,8 @@ namespace HeliosPlus
}
}
[JsonConverter(typeof(CustomBitmapConverter))]
//[JsonConverter(typeof(CustomBitmapConverter))]
[JsonIgnore]
public Bitmap ShortcutBitmap
{
get
@ -128,6 +136,10 @@ namespace HeliosPlus
return _shortcutBitmap;
else
{
if (ProfileToUse == null)
return null;
if (OriginalBitmap == null)
return null;
@ -160,14 +172,27 @@ namespace HeliosPlus
[JsonIgnore]
public static List<Shortcut> AllSavedShortcuts
{
get => _allSavedShortcuts;
get
{
if (_allSavedShortcuts.Count == 0)
{
Shortcut.LoadAllShortcuts();
}
return _allSavedShortcuts;
}
}
[JsonIgnore]
public bool IsPossible
{
get;
set;
get
{
return _isPossible;
}
set
{
_isPossible = value;
}
}
public static Bitmap ExtractVistaIcon(Icon icoIcon)
@ -207,6 +232,19 @@ namespace HeliosPlus
{
if (_shortcutIcon == null)
{
if (!Directory.Exists(SavedShortcutsPath))
{
try
{
Directory.CreateDirectory(SavedShortcutsPath);
}
catch (Exception ex)
{
Console.WriteLine("Unable to create Shortcut folder " + SavedShortcutsPath + ": " + ex.Message);
}
}
// Only add the rest of the options if the permanence is temporary
if (Permanence == ShortcutPermanence.Temporary)
{
@ -214,7 +252,7 @@ namespace HeliosPlus
if (Category == ShortcutCategory.Application)
{
// Work out the name of the shortcut we'll save.
SavedShortcutIconCacheFilename = Path.Combine(Program.ShortcutIconCachePath, String.Concat(@"executable-", Program.GetValidFilename(Name).ToLower(CultureInfo.InvariantCulture), "-", Path.GetFileNameWithoutExtension(ExecutableNameAndPath), @".ico"));
SavedShortcutIconCacheFilename = Path.Combine(SavedShortcutsPath, String.Concat(@"executable-", Program.GetValidFilename(Name).ToLower(CultureInfo.InvariantCulture), "-", Path.GetFileNameWithoutExtension(ExecutableNameAndPath), @".ico"));
}
// Only add the rest of the options if the temporary switch radio button is set
@ -226,13 +264,13 @@ namespace HeliosPlus
if (GameLibrary == SupportedGameLibrary.Steam)
{
// Work out the name of the shortcut we'll save.
SavedShortcutIconCacheFilename = Path.Combine(Program.ShortcutIconCachePath, String.Concat(@"steam-", Program.GetValidFilename(Name).ToLower(CultureInfo.InvariantCulture), "-", GameAppId.ToString(), @".ico"));
SavedShortcutIconCacheFilename = Path.Combine(SavedShortcutsPath, String.Concat(@"steam-", Program.GetValidFilename(Name).ToLower(CultureInfo.InvariantCulture), "-", GameAppId.ToString(), @".ico"));
}
else if (GameLibrary == SupportedGameLibrary.Uplay)
{
// Work out the name of the shortcut we'll save.
SavedShortcutIconCacheFilename = Path.Combine(Program.ShortcutIconCachePath, String.Concat(@"uplay-", Program.GetValidFilename(Name).ToLower(CultureInfo.InvariantCulture), "-", GameAppId.ToString(), @".ico"));
SavedShortcutIconCacheFilename = Path.Combine(SavedShortcutsPath, String.Concat(@"uplay-", Program.GetValidFilename(Name).ToLower(CultureInfo.InvariantCulture), "-", GameAppId.ToString(), @".ico"));
}
}
@ -242,7 +280,7 @@ namespace HeliosPlus
else
{
// Work out the name of the shortcut we'll save.
SavedShortcutIconCacheFilename = Path.Combine(Program.ShortcutIconCachePath, String.Concat(@"permanent-", Program.GetValidFilename(Name).ToLower(CultureInfo.InvariantCulture), @".ico"));
SavedShortcutIconCacheFilename = Path.Combine(SavedShortcutsPath, String.Concat(@"permanent-", Program.GetValidFilename(Name).ToLower(CultureInfo.InvariantCulture), @".ico"));
}
try
@ -287,17 +325,19 @@ namespace HeliosPlus
}
// Lookup all the Profile Names in the Saved Profiles
List<Profile> allProfiles = Profile.AllSavedProfiles;
foreach (Shortcut updatedShortcut in shortcuts)
{
IEnumerable<Profile> matchingProfile = (from profile in allProfiles where profile.Name == updatedShortcut.ProfileName select profile);
if (matchingProfile.Count() > 0)
foreach (Profile profile in Profile.AllSavedProfiles)
{
updatedShortcut.ProfileToUse = matchingProfile.First();
updatedShortcut.IsPossible = true;
if (profile.Name.Equals(updatedShortcut.ProfileName))
{
// And assign the matching Profile if we find it.
updatedShortcut.ProfileToUse = profile;
updatedShortcut.IsPossible = true;
break;
}
}
else
updatedShortcut.IsPossible = false;
}
_allSavedShortcuts = shortcuts;
@ -476,6 +516,14 @@ namespace HeliosPlus
return shortcutFileName != null && File.Exists(shortcutFileName);
}
public static bool NameAlreadyExists(string shortcutName)
{
if (AllSavedShortcuts.Exists(item => item.Name.Equals(shortcutName)))
return true;
else
return false;
}
}
#region JsonConverterBitmap

View File

@ -114,13 +114,13 @@ namespace HeliosPlus.UIForms
this.dv_profile.BackColor = System.Drawing.Color.DimGray;
this.dv_profile.Font = new System.Drawing.Font("Consolas", 50F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.dv_profile.ForeColor = System.Drawing.Color.MidnightBlue;
this.dv_profile.Location = new System.Drawing.Point(0, 1);
this.dv_profile.Location = new System.Drawing.Point(0, 63);
this.dv_profile.Margin = new System.Windows.Forms.Padding(18);
this.dv_profile.Name = "dv_profile";
this.dv_profile.PaddingX = 100;
this.dv_profile.PaddingY = 100;
this.dv_profile.Profile = null;
this.dv_profile.Size = new System.Drawing.Size(974, 579);
this.dv_profile.Size = new System.Drawing.Size(976, 517);
this.dv_profile.TabIndex = 4;
//
// menu_profiles
@ -222,7 +222,7 @@ namespace HeliosPlus.UIForms
this.lbl_profile_shown.BackColor = System.Drawing.Color.DimGray;
this.lbl_profile_shown.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbl_profile_shown.ForeColor = System.Drawing.Color.White;
this.lbl_profile_shown.Location = new System.Drawing.Point(21, 16);
this.lbl_profile_shown.Location = new System.Drawing.Point(18, 73);
this.lbl_profile_shown.Name = "lbl_profile_shown";
this.lbl_profile_shown.Size = new System.Drawing.Size(205, 29);
this.lbl_profile_shown.TabIndex = 19;
@ -256,7 +256,7 @@ namespace HeliosPlus.UIForms
this.ilv_saved_profiles.Name = "ilv_saved_profiles";
this.ilv_saved_profiles.PersistentCacheDirectory = "";
this.ilv_saved_profiles.PersistentCacheSize = ((long)(100));
this.ilv_saved_profiles.Size = new System.Drawing.Size(974, 128);
this.ilv_saved_profiles.Size = new System.Drawing.Size(976, 128);
this.ilv_saved_profiles.TabIndex = 21;
this.ilv_saved_profiles.UseWIC = true;
this.ilv_saved_profiles.View = Manina.Windows.Forms.View.HorizontalStrip;
@ -268,7 +268,7 @@ namespace HeliosPlus.UIForms
this.lbl_profile_shown_subtitle.BackColor = System.Drawing.Color.DimGray;
this.lbl_profile_shown_subtitle.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbl_profile_shown_subtitle.ForeColor = System.Drawing.Color.White;
this.lbl_profile_shown_subtitle.Location = new System.Drawing.Point(21, 45);
this.lbl_profile_shown_subtitle.Location = new System.Drawing.Point(18, 102);
this.lbl_profile_shown_subtitle.Name = "lbl_profile_shown_subtitle";
this.lbl_profile_shown_subtitle.Size = new System.Drawing.Size(132, 20);
this.lbl_profile_shown_subtitle.TabIndex = 22;
@ -291,6 +291,7 @@ namespace HeliosPlus.UIForms
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.Black;
this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
this.CancelButton = this.btn_back;
this.ClientSize = new System.Drawing.Size(976, 812);
this.Controls.Add(this.label1);

File diff suppressed because it is too large Load Diff

View File

@ -158,18 +158,18 @@ namespace HeliosPlus.UIForms
// Get file info
if (profileToUse.ProfileBitmap is Bitmap)
{
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.FileName, string.Empty, profileToUse.Name));
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.DateCreated, string.Empty, ""));
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.DateAccessed, string.Empty, ""));
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.DateModified, string.Empty, ""));
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.FileSize, string.Empty, ""));
DateTime now = DateTime.Now;
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.DateCreated, string.Empty, now));
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.DateAccessed, string.Empty, now));
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.DateModified, string.Empty, now));
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.FileSize, string.Empty, (long)0));
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.FilePath, string.Empty, ""));
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.FolderName, string.Empty, ""));
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.Dimensions, string.Empty, new Size(profileToUse.ProfileBitmap.Width, profileToUse.ProfileBitmap.Height)));
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.Resolution, string.Empty, new SizeF((float)profileToUse.ProfileBitmap.Width, (float)profileToUse.ProfileBitmap.Height)));
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.ImageDescription, string.Empty, profileToUse.Name));
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.EquipmentModel, string.Empty, ""));
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.DateTaken, string.Empty, ""));
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.DateTaken, string.Empty, now));
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.Artist, string.Empty, ""));
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.Copyright, string.Empty, ""));
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.ExposureTime, string.Empty, (float)0));

View File

@ -46,22 +46,22 @@ namespace HeliosPlus.UIForms
Shortcut shortcutToUse = null;
foreach (Shortcut shortcutToTest in Shortcut.AllSavedShortcuts)
foreach (Shortcut profileToTest in Shortcut.AllSavedShortcuts)
{
if (shortcutToTest.Name == shortcutName)
if (profileToTest.Name == shortcutName)
{
shortcutToUse = shortcutToTest;
shortcutToUse = profileToTest;
}
}
if (shortcutToUse == null)
{
Image.GetThumbnailImageAbort myCallback = new Image.GetThumbnailImageAbort(() => { return false; });
return shortcutToUse.ShortcutBitmap.GetThumbnailImage(size.Width, size.Height, myCallback, IntPtr.Zero);
}
else
return null;
}
Image.GetThumbnailImageAbort myCallback = new Image.GetThumbnailImageAbort(() => { return false; });
return shortcutToUse.ShortcutBitmap.GetThumbnailImage(size.Width, size.Height, myCallback, IntPtr.Zero);
}
catch {
// If we have a problem with converting the submitted key to a profile
@ -112,7 +112,14 @@ namespace HeliosPlus.UIForms
try
{
//Shortcut shortcut = (Shortcut)key;
//return shortcut.SavedShortcutIconCacheFilename;
string shortcutName = (string)key;
/* Shortcut shortcut = (from item in Shortcut.AllSavedShortcuts where item.Name == shortcutName select item).First();
if (shortcut is Shortcut)
return shortcut.SavedShortcutIconCacheFilename;
else
return null;*/
return shortcutName;
}
catch
@ -137,12 +144,13 @@ namespace HeliosPlus.UIForms
try
{
string shortcutName = (string)key;
Shortcut shortcut = (Shortcut)key;
Shortcut shortcutToUse = null;
foreach (Shortcut shortcutToTest in Shortcut.AllSavedShortcuts)
{
if (shortcutToTest.Name == shortcutName)
if (shortcutToTest.Name == shortcut.Name)
{
shortcutToUse = shortcutToTest;
}
@ -152,18 +160,18 @@ namespace HeliosPlus.UIForms
// Get file info
if (shortcutToUse.ShortcutBitmap is Bitmap)
{
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.FileName, string.Empty, shortcutToUse.Name));
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.DateCreated, string.Empty, ""));
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.DateAccessed, string.Empty, ""));
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.DateModified, string.Empty, ""));
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.FileSize, string.Empty, ""));
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.FilePath, string.Empty, ""));
DateTime now = DateTime.Now;
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.DateCreated, string.Empty, now));
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.DateAccessed, string.Empty, now));
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.DateModified, string.Empty, now));
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.FileSize, string.Empty, (long)0));
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.FilePath, string.Empty, shortcutToUse.SavedShortcutIconCacheFilename));
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.FolderName, string.Empty, ""));
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.Dimensions, string.Empty, new Size(shortcutToUse.ShortcutBitmap.Width, shortcutToUse.ShortcutBitmap.Height)));
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.Resolution, string.Empty, new SizeF((float)shortcutToUse.ShortcutBitmap.Width, (float)shortcutToUse.ShortcutBitmap.Height)));
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.ImageDescription, string.Empty, shortcutToUse.Name));
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.EquipmentModel, string.Empty, ""));
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.DateTaken, string.Empty, ""));
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.DateTaken, string.Empty, now));
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.Artist, string.Empty, ""));
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.Copyright, string.Empty, ""));
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.ExposureTime, string.Empty, (float)0));

View File

@ -41,6 +41,8 @@ namespace HeliosPlus.UIForms
public ShortcutForm(Shortcut shortcutToEdit) : this()
{
_shortcutToEdit = shortcutToEdit;
txt_shortcut_save_name.Text = _shortcutToEdit.Name;
}
public string ProcessNameToMonitor
@ -231,8 +233,10 @@ namespace HeliosPlus.UIForms
// Store all of the information in the Shortcut object based on what's been selected in this form
// Validate the fields are filled as they should be!
// Check the name is valid
if (String.IsNullOrWhiteSpace(txt_shortcut_save_name.Text) && Program.IsValidFilename(txt_shortcut_save_name.Text))
// Check the name is valid to save
if (String.IsNullOrWhiteSpace(txt_shortcut_save_name.Text))
{
MessageBox.Show(
@"You need to specify a name for this Shortcut before it can be saved.",
@ -242,6 +246,16 @@ namespace HeliosPlus.UIForms
return;
}
// Please use a plain name that can be
if (Shortcut.NameAlreadyExists(txt_shortcut_save_name.Text))
{
MessageBox.Show(
@"A shortcut has already been created with this name. Please close this window and select that shortcut from the shortcut library window instead of creating a new one.",
@"Please rename this Shortcut.",
MessageBoxButtons.OK,
MessageBoxIcon.Exclamation);
return;
}
// Check the profile is set and that it's still valid
if (!(_profileToUse is Profile))
@ -389,10 +403,17 @@ namespace HeliosPlus.UIForms
// (as we need the OriginalIconPath to run the SaveShortcutIconToCache method)
if (rb_launcher.Checked)
_shortcutToEdit.Category = ShortcutCategory.Game;
if (txt_game_launcher.Text == SupportedGameLibrary.Steam.ToString())
{
_shortcutToEdit.OriginalIconPath = (from steamGame in SteamGame.AllGames where steamGame.GameId == _shortcutToEdit.GameAppId select steamGame.GameIconPath).First();
_shortcutToEdit.GameLibrary = SupportedGameLibrary.Steam;
}
else if (txt_game_launcher.Text == SupportedGameLibrary.Uplay.ToString())
{
_shortcutToEdit.OriginalIconPath = (from uplayGame in UplayGame.AllGames where uplayGame.GameId == _shortcutToEdit.GameAppId select uplayGame.GameIconPath).First();
_shortcutToEdit.GameLibrary = SupportedGameLibrary.Uplay;
}
else if (rb_standalone.Checked)
_shortcutToEdit.Category = ShortcutCategory.Application;
@ -404,6 +425,9 @@ namespace HeliosPlus.UIForms
if (_isNewShortcut)
Shortcut.AllSavedShortcuts.Add(_shortcutToEdit);
// Save all shortcuts just to be sure
Shortcut.SaveAllShortcuts();
// Save everything is golden and close the form.
DialogResult = DialogResult.OK;
this.Close();

File diff suppressed because it is too large Load Diff

View File

@ -37,6 +37,7 @@
this.btn_new = new System.Windows.Forms.Button();
this.btn_save = new System.Windows.Forms.Button();
this.dialog_save = new System.Windows.Forms.SaveFileDialog();
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// ilv_saved_shortcuts
@ -49,14 +50,16 @@
this.ilv_saved_shortcuts.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.ilv_saved_shortcuts.Location = new System.Drawing.Point(0, 0);
this.ilv_saved_shortcuts.Location = new System.Drawing.Point(0, 98);
this.ilv_saved_shortcuts.MultiSelect = false;
this.ilv_saved_shortcuts.Name = "ilv_saved_shortcuts";
this.ilv_saved_shortcuts.PersistentCacheDirectory = "";
this.ilv_saved_shortcuts.PersistentCacheSize = ((long)(100));
this.ilv_saved_shortcuts.Size = new System.Drawing.Size(1122, 743);
this.ilv_saved_shortcuts.Size = new System.Drawing.Size(1123, 645);
this.ilv_saved_shortcuts.TabIndex = 22;
this.ilv_saved_shortcuts.UseWIC = true;
this.ilv_saved_shortcuts.ItemClick += new Manina.Windows.Forms.ItemClickEventHandler(this.ilv_saved_shortcuts_ItemClick);
this.ilv_saved_shortcuts.ItemDoubleClick += new Manina.Windows.Forms.ItemDoubleClickEventHandler(this.ilv_saved_shortcuts_ItemDoubleClick);
//
// btn_delete
//
@ -72,7 +75,6 @@
this.btn_delete.TabIndex = 26;
this.btn_delete.Text = "&Delete";
this.btn_delete.UseVisualStyleBackColor = true;
this.btn_delete.Visible = false;
//
// btn_back
//
@ -105,7 +107,6 @@
this.btn_run.TabIndex = 25;
this.btn_run.Text = "&Run";
this.btn_run.UseVisualStyleBackColor = false;
this.btn_run.Visible = false;
//
// btn_edit
//
@ -122,7 +123,7 @@
this.btn_edit.TabIndex = 28;
this.btn_edit.Text = "&Edit";
this.btn_edit.UseVisualStyleBackColor = false;
this.btn_edit.Visible = false;
this.btn_edit.Click += new System.EventHandler(this.btn_edit_Click);
//
// btn_new
//
@ -156,7 +157,6 @@
this.btn_save.TabIndex = 30;
this.btn_save.Text = "&Save to Desktop";
this.btn_save.UseVisualStyleBackColor = false;
this.btn_save.Visible = false;
//
// dialog_save
//
@ -165,12 +165,25 @@
this.dialog_save.Filter = global::HeliosPlus.Resources.Language.Shortcuts_Filter;
this.dialog_save.RestoreDirectory = true;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label1.ForeColor = System.Drawing.Color.White;
this.label1.Location = new System.Drawing.Point(405, 25);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(251, 29);
this.label1.TabIndex = 31;
this.label1.Text = "Game Shortcut Library";
//
// ShortcutLibraryForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.Black;
this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
this.ClientSize = new System.Drawing.Size(1123, 839);
this.Controls.Add(this.label1);
this.Controls.Add(this.btn_save);
this.Controls.Add(this.btn_new);
this.Controls.Add(this.btn_edit);
@ -185,6 +198,7 @@
this.Text = "HeliosPlus - Setup Game Shortcuts";
this.Load += new System.EventHandler(this.ShortcutLibraryForm_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
@ -198,5 +212,6 @@
private System.Windows.Forms.Button btn_new;
private System.Windows.Forms.Button btn_save;
private System.Windows.Forms.SaveFileDialog dialog_save;
private System.Windows.Forms.Label label1;
}
}

View File

@ -37,6 +37,7 @@ namespace HeliosPlus.UIForms
if (shortcutForm.DialogResult == DialogResult.OK)
{
_selectedShortcut = shortcutForm.Shortcut;
RefreshShortcutLibraryUI();
}
}
@ -71,13 +72,38 @@ namespace HeliosPlus.UIForms
//ilv_saved_profiles.Items.Add(newItem);
ilv_saved_shortcuts.Items.Add(newItem, _shortcutAdaptor);
}
if (_selectedShortcut != null && _selectedShortcut is Shortcut)
RefreshImageListView(_selectedShortcut);
}
// Restart updating the saved_profiles listview
ilv_saved_shortcuts.ResumeLayout();
}
// Refresh the image list view
//RefreshImageListView(profile);
}
private void RefreshImageListView(Shortcut shortcut)
{
ilv_saved_shortcuts.ClearSelection();
IEnumerable<ImageListViewItem> matchingImageListViewItems = (from item in ilv_saved_shortcuts.Items where item.Text == shortcut.Name select item);
if (matchingImageListViewItems.Any())
{
matchingImageListViewItems.First().Selected = true;
matchingImageListViewItems.First().Focused = true;
}
}
private Shortcut GetShortcutFromName(string shortcutName)
{
return (from item in Shortcut.AllSavedShortcuts where item.Name == shortcutName select item).First();
}
private void btn_save_Click(object sender, EventArgs e)
@ -141,6 +167,41 @@ namespace HeliosPlus.UIForms
}
}
private void ilv_saved_shortcuts_ItemClick(object sender, ItemClickEventArgs e)
{
_selectedShortcut = GetShortcutFromName(e.Item.Text);
}
private void ilv_saved_shortcuts_ItemDoubleClick(object sender, ItemClickEventArgs e)
{
_selectedShortcut = GetShortcutFromName(e.Item.Text);
if (_selectedShortcut == null)
return;
var shortcutForm = new ShortcutForm(_selectedShortcut);
shortcutForm.ShowDialog(this);
if (shortcutForm.DialogResult == DialogResult.OK)
{
_selectedShortcut = shortcutForm.Shortcut;
RefreshShortcutLibraryUI();
}
}
private void btn_edit_Click(object sender, EventArgs e)
{
if (_selectedShortcut == null)
return;
var shortcutForm = new ShortcutForm(_selectedShortcut);
shortcutForm.ShowDialog(this);
if (shortcutForm.DialogResult == DialogResult.OK)
{
_selectedShortcut = shortcutForm.Shortcut;
RefreshShortcutLibraryUI();
}
}
}
}

File diff suppressed because it is too large Load Diff