-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make it easier/document ability to combine multiple sized files into single ico file #25
Comments
Wait, I thought this worked, but I think it's regenerating scaled images vs. using the bunch of files I dragged in... I was having a bit of trouble trying to find the code that handled this amongst the single page, but finally found the function here that deals with multiple files being dropped: Simple-Icon-File-Maker/Simple Icon File Maker/Simple Icon File Maker/MainPage.xaml.cs Lines 339 to 348 in 2d6ccf4
Looks like it bails out after a single image is found. |
Well, I started to try and implement this, and got preview images kind-of replaced, but didn't realize you just regenerate all the images on save: Simple-Icon-File-Maker/Simple Icon File Maker/Simple Icon File Maker/MainPage.xaml.cs Lines 561 to 566 in 2d6ccf4
Was even trying to start small with a 1-by-1 approach with an additional button here: It worked at updating the preview kind of (images below the imported one wouldn't display for some reason): private async void ImportSizedImageButton_Click(object sender, RoutedEventArgs e)
{
SourceImageSize = null;
FileOpenPicker picker = new()
{
ViewMode = PickerViewMode.Thumbnail,
SuggestedStartLocation = PickerLocationId.PicturesLibrary
};
foreach (string extension in SupportedImageFormats)
picker.FileTypeFilter.Add(extension);
Window window = new();
IntPtr windowHandle = WindowNative.GetWindowHandle(window);
InitializeWithWindow.Initialize(picker, windowHandle);
StorageFile file = await picker.PickSingleFileAsync();
if (file is null)
return;
StorageFile imageFile = await StorageFile.GetFileFromPathAsync(file.Path);
using IRandomAccessStream fileStream = await imageFile.OpenAsync(FileAccessMode.Read);
var properties = await imageFile.Properties.GetImagePropertiesAsync();
var existing = PreviewStackPanel.Children.Cast<PreviewImage>().FirstOrDefault(child => child.SideLength == properties.Width);
var index = 0;
if (existing != null)
{
index = PreviewStackPanel.Children.IndexOf(existing);
PreviewStackPanel.Children.RemoveAt(index);
}
// TODO: Probably want to handle if we're trying to import a size we haven't seen yet...
PreviewImage image = new(imageFile, (int)properties.Width, Path.GetFileNameWithoutExtension(file.Path));
PreviewStackPanel.Children.Insert(index, image);
SetPreviewsZoom();
} This work seems to conflict a bit with your latest branch anyway, but maybe this is a good starting point. Thanks! |
@hawkerm as you noticed I am moving around the code currently. Hopefully the new structure will make this change easier to implement. The new "PreviewsStack" will also enable generating multiple icons at once. To your point of regenerating the images on save, I don't think that needs to happen if the latest options match what was last generated. Again hopefully the PreviewsStack will make it easy to handle this. I do appreciate the idea and the work you've done already! |
I didn't realize that I could drag multiple files in of varying sizes in order to add them as the individual pieces of a single ico file.
This is handy for hand-crafting certain scaling artifacts from a single image after exporting the individual images (didn't know I could drag them out either at first to save off individual sizes).
Could be handy to have another explicit button for this or another little help screen that describes some of these types of extra 'hidden' features.
Another option is to allow dragging in the images but if they're one-by-one giving the option of importing to the current ico vs. assuming it's a new icon to convert, maybe that's a toggle somewhere?
The text was updated successfully, but these errors were encountered: