private void IconSet(object sender) { byte[] imageBytes; try { imageBytes = FrmIconSelector.GetImage(this, CurrentShortcutItem.TargetFilePath); } catch (UserCancellationException) { return; } var pictureBoxMetaDataToUse = chkUseSameImg.Checked ? _pannablePictureBoxMetaDatas : new List <PannablePictureBoxMetaData> { GetSenderPictureBoxToMetaData(sender) }; foreach (var pictureBoxMetaData in pictureBoxMetaDataToUse) { pictureBoxMetaData.ShortcutItemImage.SetImage(imageBytes, pictureBoxMetaData.Size); UpdatePictureBoxImage(pictureBoxMetaData.PannablePictureBox, pictureBoxMetaData.ShortcutItemImage); pictureBoxMetaData.PannablePictureBox.ResetImage(); } RunUpdate(); }
private void pctCurrentIcon_Click(object sender, EventArgs e) { try { CurrentCache.SetIconBytes(FrmIconSelector.GetImage(this, CustomShortcutGetters.ExplorerPath)); pctCurrentIcon.Image = CurrentCache.GetIcon(); } catch (UserCancellationException) { } }
private void IconSet(object sender) { IconSelectorResult selectedImage; try { var imagePath = GetSenderPictureBoxToMetaData(sender).ShortcutItemImage.Path; //if we haven't got a valid file from previously, try and get the default icon if (string.IsNullOrEmpty(imagePath) || !File.Exists(imagePath)) { //if it's a custom shortcut, try and get the target path from the VBS file if (CurrentShortcutItem.IsTileIconifierCustomShortcut) { try { var customShortcutExecutionTarget = CustomShortcut.Load(CurrentShortcutItem.TargetFilePath); imagePath = customShortcutExecutionTarget.TargetPath.UnQuoteWrap(); } catch (InvalidCustomShortcutException) { //corrupted custom shortcut? imagePath = CurrentShortcutItem.TargetFilePath; } } else { //otherwise we just use the target file path from the shortcut imagePath = CurrentShortcutItem.TargetFilePath; } } selectedImage = FrmIconSelector.GetImage(this, imagePath); } catch (UserCancellationException) { return; } var pictureBoxMetaDataToUse = chkUseSameImg.Checked ? _pannablePictureBoxMetaDatas : new List <PannablePictureBoxMetaData> { GetSenderPictureBoxToMetaData(sender) }; foreach (var pictureBoxMetaData in pictureBoxMetaDataToUse) { pictureBoxMetaData.ShortcutItemImage.Path = selectedImage.ImagePath; pictureBoxMetaData.ShortcutItemImage.SetImage(selectedImage.ImageBytes, pictureBoxMetaData.Size); UpdatePictureBoxImage(pictureBoxMetaData.PannablePictureBox, pictureBoxMetaData.ShortcutItemImage); pictureBoxMetaData.PannablePictureBox.ResetImage(); } RunUpdate(); }