mirror of
https://github.com/claunia/libexeinfo.git
synced 2025-12-16 19:14:24 +00:00
Add list of icons to icon viewer.
This commit is contained in:
@@ -14,6 +14,9 @@
|
||||
</StackLayoutItem>
|
||||
</StackLayout>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem HorizontalAlignment="Stretch" Expand="True">
|
||||
<GridView ID="grdIcons"/>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Expand="True">
|
||||
<ImageView ID="imgIcon"/>
|
||||
</StackLayoutItem>
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Eto.Forms;
|
||||
using Eto.Drawing;
|
||||
using Eto.Forms;
|
||||
using Eto.Serialization.Xaml;
|
||||
using Bitmap = libexeinfo.Os2.Bitmap;
|
||||
|
||||
@@ -12,36 +9,80 @@ namespace iconviewer
|
||||
{
|
||||
public class MainForm : Form
|
||||
{
|
||||
GridView grdIcons;
|
||||
ImageView imgIcon;
|
||||
TextBox txtPath;
|
||||
|
||||
TextBox txtPath;
|
||||
|
||||
public MainForm()
|
||||
{
|
||||
XamlReader.Load(this);
|
||||
|
||||
grdIcons.Columns.Add(new GridColumn
|
||||
{
|
||||
DataCell =
|
||||
new TextBoxCell {Binding = Binding.Property<Bitmap.DecodedBitmap, string>(b => $"{b.Type}")},
|
||||
HeaderText = "Command"
|
||||
});
|
||||
|
||||
grdIcons.Columns.Add(new GridColumn
|
||||
{
|
||||
DataCell = new TextBoxCell
|
||||
{
|
||||
Binding = Binding.Property<Bitmap.DecodedBitmap, string>(b => $"{b.Width}x{b.Height}")
|
||||
},
|
||||
HeaderText = "Size"
|
||||
});
|
||||
|
||||
grdIcons.Columns.Add(new GridColumn
|
||||
{
|
||||
DataCell = new TextBoxCell
|
||||
{
|
||||
Binding = Binding.Property<Bitmap.DecodedBitmap, string>(b => $"{1 << (int)b.BitsPerPixel}")
|
||||
},
|
||||
HeaderText = "Colors"
|
||||
});
|
||||
|
||||
grdIcons.AllowMultipleSelection = false;
|
||||
grdIcons.SelectionChanged += GrdIconsOnSelectionChanged;
|
||||
}
|
||||
|
||||
protected void OnBtnPathClick(object sender, EventArgs e)
|
||||
void GrdIconsOnSelectionChanged(object sender, EventArgs eventArgs)
|
||||
{
|
||||
OpenFileDialog dlgOpenFileDialog = new OpenFileDialog {MultiSelect = false};
|
||||
dlgOpenFileDialog.Filters.Add(new FileFilter {Extensions = new[] {".ico"}});
|
||||
DialogResult result = dlgOpenFileDialog.ShowDialog(this);
|
||||
|
||||
if(result != DialogResult.Ok)
|
||||
if(!(grdIcons.SelectedItem is Bitmap.DecodedBitmap icon))
|
||||
{
|
||||
txtPath.Text = "";
|
||||
imgIcon.Image = null;
|
||||
return;
|
||||
}
|
||||
|
||||
txtPath.Text = dlgOpenFileDialog.FileName;
|
||||
imgIcon.Image =
|
||||
new Eto.Drawing.Bitmap((int)icon.Width, (int)icon.Height, PixelFormat.Format32bppRgba, icon.Pixels);
|
||||
}
|
||||
|
||||
protected void OnBtnPathClick(object sender, EventArgs e)
|
||||
{
|
||||
OpenFileDialog dlgOpenFileDialog = new OpenFileDialog {MultiSelect = false};
|
||||
dlgOpenFileDialog.Filters.Add(new FileFilter {Extensions = new[] {".ico"}});
|
||||
DialogResult result = dlgOpenFileDialog.ShowDialog(this);
|
||||
|
||||
if(result != DialogResult.Ok)
|
||||
{
|
||||
txtPath.Text = "";
|
||||
imgIcon.Image = null;
|
||||
grdIcons.DataStore = null;
|
||||
return;
|
||||
}
|
||||
|
||||
txtPath.Text = dlgOpenFileDialog.FileName;
|
||||
FileStream fstream = new FileStream(dlgOpenFileDialog.FileName, FileMode.Open);
|
||||
byte[] data = new byte[fstream.Length];
|
||||
byte[] data = new byte[fstream.Length];
|
||||
fstream.Read(data, 0, data.Length);
|
||||
fstream.Dispose();
|
||||
|
||||
Bitmap.DecodedBitmap[] icons = libexeinfo.Os2.Bitmap.DecodeBitmap(data);
|
||||
imgIcon.Image = new Eto.Drawing.Bitmap((int)icons[0].Width, (int)icons[0].Height, PixelFormat.Format32bppRgba,
|
||||
icons[0].Pixels);
|
||||
Bitmap.DecodedBitmap[] icons = Bitmap.DecodeBitmap(data);
|
||||
imgIcon.Image = new Eto.Drawing.Bitmap((int)icons[0].Width, (int)icons[0].Height,
|
||||
PixelFormat.Format32bppRgba, icons[0].Pixels);
|
||||
grdIcons.DataStore = icons;
|
||||
grdIcons.Visible = icons.Length != 1;
|
||||
}
|
||||
|
||||
protected void HandleAbout(object sender, EventArgs e)
|
||||
@@ -54,4 +95,4 @@ namespace iconviewer
|
||||
Application.Instance.Quit();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user