2018-03-03 04:57:40 +00:00
|
|
|
|
//
|
|
|
|
|
|
// PanelWin16Version.xeto.cs
|
|
|
|
|
|
//
|
|
|
|
|
|
// Author:
|
|
|
|
|
|
// Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
|
//
|
2018-03-07 20:15:17 +00:00
|
|
|
|
// Copyright (c) 2017-2018 Copyright © Claunia.com
|
2018-03-03 04:57:40 +00:00
|
|
|
|
//
|
|
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
|
|
// of this software and associated documentation files (the "Software"), to deal
|
|
|
|
|
|
// in the Software without restriction, including without limitation the rights
|
|
|
|
|
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
|
|
// copies of the Software, and to permit persons to whom the Software is
|
|
|
|
|
|
// furnished to do so, subject to the following conditions:
|
|
|
|
|
|
//
|
|
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
|
|
//
|
|
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
|
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
|
|
// THE SOFTWARE.
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using Eto.Forms;
|
|
|
|
|
|
using Eto.Serialization.Xaml;
|
2018-03-09 16:36:39 +00:00
|
|
|
|
using libexeinfo.Windows;
|
|
|
|
|
|
using Version = libexeinfo.Windows.Version;
|
2018-03-03 04:57:40 +00:00
|
|
|
|
|
|
|
|
|
|
namespace exeinfogui.Win16
|
|
|
|
|
|
{
|
|
|
|
|
|
public class PanelWin16Version : Panel
|
|
|
|
|
|
{
|
|
|
|
|
|
ObservableCollection<StrByLang> stringsByLanguage;
|
|
|
|
|
|
GridView treeLanguages;
|
|
|
|
|
|
GridView treeStrings;
|
|
|
|
|
|
TextBox txtFileDate;
|
|
|
|
|
|
TextBox txtFileFlags;
|
|
|
|
|
|
TextBox txtFileOs;
|
|
|
|
|
|
TextBox txtFileSubtype;
|
|
|
|
|
|
TextBox txtFileType;
|
|
|
|
|
|
TextBox txtFileVersion;
|
|
|
|
|
|
TextBox txtProductVersion;
|
|
|
|
|
|
|
|
|
|
|
|
public PanelWin16Version()
|
|
|
|
|
|
{
|
|
|
|
|
|
XamlReader.Load(this);
|
|
|
|
|
|
|
|
|
|
|
|
treeLanguages.Columns.Add(new GridColumn
|
|
|
|
|
|
{
|
|
|
|
|
|
DataCell = new TextBoxCell {Binding = Binding.Property<StrByLang, string>(r => r.Name)},
|
|
|
|
|
|
HeaderText = "Language (codepage)"
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
treeStrings.Columns.Add(new GridColumn
|
|
|
|
|
|
{
|
|
|
|
|
|
DataCell = new TextBoxCell {Binding = Binding.Property<Strings, string>(r => r.Key)},
|
|
|
|
|
|
HeaderText = "Key"
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
treeStrings.Columns.Add(new GridColumn
|
|
|
|
|
|
{
|
|
|
|
|
|
DataCell = new TextBoxCell {Binding = Binding.Property<Strings, string>(r => r.Value)},
|
|
|
|
|
|
HeaderText = "Value"
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
stringsByLanguage = new ObservableCollection<StrByLang>();
|
|
|
|
|
|
treeLanguages.SelectionChanged += TreeLanguagesOnSelectionChanged;
|
|
|
|
|
|
treeLanguages.AllowMultipleSelection = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TreeLanguagesOnSelectionChanged(object sender, EventArgs eventArgs)
|
|
|
|
|
|
{
|
|
|
|
|
|
treeStrings.DataStore = null;
|
|
|
|
|
|
if(!(treeLanguages.SelectedItem is StrByLang strs)) return;
|
|
|
|
|
|
|
|
|
|
|
|
List<Strings> strings = new List<Strings>();
|
|
|
|
|
|
foreach(KeyValuePair<string, string> kvp in strs.Strings)
|
|
|
|
|
|
strings.Add(new Strings {Key = kvp.Key, Value = kvp.Value});
|
|
|
|
|
|
|
|
|
|
|
|
treeStrings.DataStore = strings;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Update(byte[] data)
|
|
|
|
|
|
{
|
2018-03-08 16:50:25 +00:00
|
|
|
|
Update(new libexeinfo.NE.Version(data));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Update(libexeinfo.NE.Version version)
|
|
|
|
|
|
{
|
|
|
|
|
|
txtFileDate.Text = version.FileDate != new DateTime(1601, 1, 1) ? $"{version.FileDate}" : "Not set";
|
|
|
|
|
|
txtFileFlags.Text = version.FileFlags == 0 ? "Normal" : $"{version.FileFlags}";
|
2018-03-09 16:36:39 +00:00
|
|
|
|
txtFileOs.Text = Version.OsToString(version.FileOs);
|
2018-03-03 04:57:40 +00:00
|
|
|
|
|
2018-03-09 16:36:39 +00:00
|
|
|
|
if(version.FileType == VersionFileType.VFT_DRV)
|
|
|
|
|
|
txtFileSubtype.Text = $"{Version.DriverToString(version.FileSubtype)} driver";
|
|
|
|
|
|
else if(version.FileType == VersionFileType.VFT_DRV)
|
|
|
|
|
|
txtFileSubtype.Text = $"{Version.FontToString(version.FileSubtype)} font";
|
2018-03-08 16:50:25 +00:00
|
|
|
|
else if(version.FileSubtype > 0) txtFileSubtype.Text = $"{(uint)version.FileSubtype}";
|
|
|
|
|
|
else txtFileSubtype.Text = "None";
|
2018-03-03 04:57:40 +00:00
|
|
|
|
|
2018-03-09 16:36:39 +00:00
|
|
|
|
txtFileType.Text = Version.TypeToString(version.FileType);
|
2018-03-03 04:57:40 +00:00
|
|
|
|
txtFileVersion.Text = $"{version.FileVersion}";
|
|
|
|
|
|
txtProductVersion.Text = $"{version.ProductVersion}";
|
|
|
|
|
|
|
|
|
|
|
|
stringsByLanguage.Clear();
|
|
|
|
|
|
|
|
|
|
|
|
foreach(KeyValuePair<string, Dictionary<string, string>> strByLang in version.StringsByLanguage)
|
|
|
|
|
|
{
|
|
|
|
|
|
string cultureName;
|
|
|
|
|
|
string encodingName;
|
|
|
|
|
|
|
2018-03-08 16:50:25 +00:00
|
|
|
|
try { cultureName = new CultureInfo(Convert.ToInt32(strByLang.Key.Substring(0, 4), 16)).DisplayName; }
|
|
|
|
|
|
catch { cultureName = $"0x{Convert.ToInt32(strByLang.Key.Substring(0, 4), 16):X4}"; }
|
2018-03-03 04:57:40 +00:00
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
encodingName = Encoding.GetEncoding(Convert.ToInt32(strByLang.Key.Substring(4), 16)).EncodingName;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch { encodingName = $"0x{Convert.ToInt32(strByLang.Key.Substring(4), 16):X4}"; }
|
|
|
|
|
|
|
|
|
|
|
|
stringsByLanguage.Add(new StrByLang
|
|
|
|
|
|
{
|
|
|
|
|
|
Name = $"{cultureName} ({encodingName})",
|
|
|
|
|
|
Strings = strByLang.Value
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
treeLanguages.DataStore = stringsByLanguage;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class StrByLang
|
|
|
|
|
|
{
|
|
|
|
|
|
public Dictionary<string, string> Strings;
|
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class Strings
|
|
|
|
|
|
{
|
|
|
|
|
|
public string Key { get; set; }
|
|
|
|
|
|
public string Value { get; set; }
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|