From 153923c5992a845740f30176fc509ef2b7ef62f4 Mon Sep 17 00:00:00 2001 From: Sander van Vliet Date: Wed, 1 Dec 2021 14:22:35 +0100 Subject: [PATCH] Show bytes suffix when data is less than 1kb --- Sources/WPFHexaEditor/HexEditor.xaml.cs | 27 ++- .../Properties/Resources.Designer.cs | 210 +++++++++--------- .../WPFHexaEditor/Properties/Resources.resx | 3 + Sources/WPFHexaEditor/WpfHexEditorCore.csproj | 14 ++ 4 files changed, 141 insertions(+), 113 deletions(-) diff --git a/Sources/WPFHexaEditor/HexEditor.xaml.cs b/Sources/WPFHexaEditor/HexEditor.xaml.cs index 1193404f..199f1a45 100644 --- a/Sources/WPFHexaEditor/HexEditor.xaml.cs +++ b/Sources/WPFHexaEditor/HexEditor.xaml.cs @@ -3837,21 +3837,26 @@ private void UpdateStatusBar(bool updateFilelength = true) #region Show length if (updateFilelength) { - var isMegabByte = false; + double length; + string unit; - //is mega bytes ? - double length = _provider.LengthAjusted / 1024; - - if (length > 1024) + if (_provider.LengthAjusted < 1024) + { + length = _provider.LengthAjusted; + unit = Properties.Resources.BytesTagString; + } + else if (_provider.LengthAjusted < 1048576) // 1048576 bytes = 1 MiB + { + length = _provider.LengthAjusted / 1024; + unit = Properties.Resources.KBTagString; + } + else { - length /= 1024; - isMegabByte = true; + length = _provider.LengthAjusted / 1048576; + unit = Properties.Resources.MBTagString; } - FileLengthKbLabel.Content = Math.Round(length, 2) + - (isMegabByte - ? $" {Properties.Resources.MBTagString}" - : $" {Properties.Resources.KBTagString}"); + FileLengthKbLabel.Content = Math.Round(length, 2) + " " + unit; } #endregion diff --git a/Sources/WPFHexaEditor/Properties/Resources.Designer.cs b/Sources/WPFHexaEditor/Properties/Resources.Designer.cs index 43bbe4ae..e9f59081 100644 --- a/Sources/WPFHexaEditor/Properties/Resources.Designer.cs +++ b/Sources/WPFHexaEditor/Properties/Resources.Designer.cs @@ -1,10 +1,10 @@ //------------------------------------------------------------------------------ // -// Ce code a été généré par un outil. -// Version du runtime :4.0.30319.42000 +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 // -// Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si -// le code est régénéré. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. // //------------------------------------------------------------------------------ @@ -13,12 +13,12 @@ namespace WpfHexaEditor.Properties { /// - /// Une classe de ressource fortement typée destinée, entre autres, à la consultation des chaînes localisées. + /// A strongly-typed resource class, for looking up localized strings, etc. /// - // Cette classe a été générée automatiquement par la classe StronglyTypedResourceBuilder - // à l'aide d'un outil, tel que ResGen ou Visual Studio. - // Pour ajouter ou supprimer un membre, modifiez votre fichier .ResX, puis réexécutez ResGen - // avec l'option /str ou régénérez votre projet VS. + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] @@ -33,7 +33,7 @@ internal Resources() { } /// - /// Retourne l'instance ResourceManager mise en cache utilisée par cette classe. + /// Returns the cached ResourceManager instance used by this class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] public static global::System.Resources.ResourceManager ResourceManager { @@ -47,8 +47,8 @@ internal Resources() { } /// - /// Remplace la propriété CurrentUICulture du thread actuel pour toutes - /// les recherches de ressources à l'aide de cette classe de ressource fortement typée. + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] public static global::System.Globalization.CultureInfo Culture { @@ -61,7 +61,7 @@ internal Resources() { } /// - /// Recherche une chaîne localisée semblable à You have reached the end of file. Do you want append one byte ? This operation cannot be canceled if you continue.. + /// Looks up a localized string similar to You have reached the end of file. Do you want append one byte ? This operation cannot be canceled if you continue.. /// public static string AppendByteConfirmationString { get { @@ -70,7 +70,7 @@ public static string AppendByteConfirmationString { } /// - /// Recherche une chaîne localisée semblable à Bookmarks. + /// Looks up a localized string similar to Bookmarks. /// public static string BookmarksString { get { @@ -79,7 +79,7 @@ public static string BookmarksString { } /// - /// Recherche une chaîne localisée semblable à Byte action. + /// Looks up a localized string similar to Byte action. /// public static string ByteActionString { get { @@ -88,7 +88,16 @@ public static string ByteActionString { } /// - /// Recherche une chaîne localisée semblable à Byte. + /// Looks up a localized string similar to Bytes. + /// + public static string BytesTagString { + get { + return ResourceManager.GetString("BytesTagString", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Byte. /// public static string ByteString { get { @@ -97,7 +106,7 @@ public static string ByteString { } /// - /// Recherche une chaîne localisée semblable à Cancel long process. + /// Looks up a localized string similar to Cancel long process. /// public static string CancelLongProcessString { get { @@ -106,26 +115,16 @@ public static string CancelLongProcessString { } /// - /// Recherche une chaîne localisée semblable à Click to cancel long process.. + /// Looks up a localized string similar to Click to cancel long process.. /// public static string CancelLongProcessToolTipString { get { return ResourceManager.GetString("CancelLongProcessToolTipString", resourceCulture); } } - - /// - /// Recherche une chaîne localisée semblable à Can't convert this string to long.. - /// - public static string ConvertStringToLongErrorString - { - get { - return ResourceManager.GetString("ConvertStringToLongErrorString", resourceCulture); - } - } /// - /// Recherche une chaîne localisée semblable à Cancel. + /// Looks up a localized string similar to Cancel. /// public static string CancelString { get { @@ -134,7 +133,7 @@ public static string CancelString { } /// - /// Recherche une chaîne localisée semblable à Clear bookmark. + /// Looks up a localized string similar to Clear bookmark. /// public static string ClearBookMarkString { get { @@ -143,7 +142,7 @@ public static string ClearBookMarkString { } /// - /// Recherche une chaîne localisée semblable à Clear. + /// Looks up a localized string similar to Clear. /// public static string ClearString { get { @@ -152,7 +151,7 @@ public static string ClearString { } /// - /// Recherche une chaîne localisée semblable à Click to go to at position.. + /// Looks up a localized string similar to Click to go to at position.. /// public static string ClickToGoAtPositionString { get { @@ -161,7 +160,7 @@ public static string ClickToGoAtPositionString { } /// - /// Recherche une chaîne localisée semblable à Close. + /// Looks up a localized string similar to Close. /// public static string CloseString { get { @@ -170,7 +169,16 @@ public static string CloseString { } /// - /// Recherche une chaîne localisée semblable à Copy as ASCII. + /// Looks up a localized string similar to Can't convert this string to long. + /// + public static string ConvertStringToLongErrorString { + get { + return ResourceManager.GetString("ConvertStringToLongErrorString", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Copy as ASCII. /// public static string CopyAsASCIIString { get { @@ -179,7 +187,7 @@ public static string CopyAsASCIIString { } /// - /// Recherche une chaîne localisée semblable à Copy as decimal. + /// Looks up a localized string similar to Copy as decimal. /// public static string CopyAsDecimalString { get { @@ -188,7 +196,7 @@ public static string CopyAsDecimalString { } /// - /// Recherche une chaîne localisée semblable à Copy as hexadecimal. + /// Looks up a localized string similar to Copy as hexadecimal. /// public static string CopyAsHexadecimalString { get { @@ -197,7 +205,7 @@ public static string CopyAsHexadecimalString { } /// - /// Recherche une chaîne localisée semblable à TBL string (character file loaded). + /// Looks up a localized string similar to TBL string (character file loaded). /// public static string CopyAsTBLString { get { @@ -206,7 +214,7 @@ public static string CopyAsTBLString { } /// - /// Recherche une chaîne localisée semblable à Copy selection as .... + /// Looks up a localized string similar to Copy selection as .... /// public static string CopySelectionAsString { get { @@ -215,7 +223,7 @@ public static string CopySelectionAsString { } /// - /// Recherche une chaîne localisée semblable à Count of. + /// Looks up a localized string similar to Count of. /// public static string CountOfString { get { @@ -224,7 +232,7 @@ public static string CountOfString { } /// - /// Recherche une chaîne localisée semblable à Default TBL. + /// Looks up a localized string similar to Default TBL. /// public static string DefaultTBLString { get { @@ -233,7 +241,7 @@ public static string DefaultTBLString { } /// - /// Recherche une chaîne localisée semblable à Delete. + /// Looks up a localized string similar to Delete. /// public static string DeleteString { get { @@ -242,7 +250,7 @@ public static string DeleteString { } /// - /// Recherche une chaîne localisée semblable à Description. + /// Looks up a localized string similar to Description. /// public static string DescriptionString { get { @@ -251,7 +259,7 @@ public static string DescriptionString { } /// - /// Recherche une chaîne localisée semblable à 00=<NUL> + /// Looks up a localized string similar to 00=<NUL> ///01=<SOH> ///02=<STX> ///03=<ETX> @@ -307,7 +315,7 @@ public static string DescriptionString { ///35=<RS> ///36=<UC> ///37=<EOT> - ///38 [le reste de la chaîne a été tronqué]";. + ///38 [rest of string was truncated]";. /// public static string EBCDIC { get { @@ -316,7 +324,7 @@ public static string EBCDIC { } /// - /// Recherche une chaîne localisée semblable à 00=. + /// Looks up a localized string similar to 00=. ///01=. ///02=. ///03=. @@ -401,7 +409,7 @@ public static string EBCDIC { ///52=. ///53=. ///54=. - ///55 [le reste de la chaîne a été tronqué]";. + ///55 [rest of string was truncated]";. /// public static string EBCDICNoSpecialChar { get { @@ -410,7 +418,7 @@ public static string EBCDICNoSpecialChar { } /// - /// Recherche une chaîne localisée semblable à <end>. + /// Looks up a localized string similar to <end>. /// public static string EndTagString { get { @@ -419,7 +427,7 @@ public static string EndTagString { } /// - /// Recherche une chaîne localisée semblable à Enter hexadecimal value .... + /// Looks up a localized string similar to Enter hexadecimal value .... /// public static string EnterHexValueMsgString { get { @@ -428,7 +436,7 @@ public static string EnterHexValueMsgString { } /// - /// Recherche une chaîne localisée semblable à Do you want close the current file and open : . + /// Looks up a localized string similar to Do you want close the current file and open : . /// public static string FileDroppingConfirmationString { get { @@ -437,7 +445,7 @@ public static string FileDroppingConfirmationString { } /// - /// Recherche une chaîne localisée semblable à Fill selection with byte. + /// Looks up a localized string similar to Fill selection with byte. /// public static string FillSelectionAloneString { get { @@ -446,7 +454,7 @@ public static string FillSelectionAloneString { } /// - /// Recherche une chaîne localisée semblable à Fill selection with byte.... + /// Looks up a localized string similar to Fill selection with byte.... /// public static string FillSelectionString { get { @@ -455,7 +463,7 @@ public static string FillSelectionString { } /// - /// Recherche une chaîne localisée semblable à Find All. + /// Looks up a localized string similar to Find All. /// public static string FindAllString { get { @@ -464,7 +472,7 @@ public static string FindAllString { } /// - /// Recherche une chaîne localisée semblable à Find and Replace. + /// Looks up a localized string similar to Find and Replace. /// public static string FindAndReplaceString { get { @@ -473,7 +481,7 @@ public static string FindAndReplaceString { } /// - /// Recherche une chaîne localisée semblable à Byte to search. + /// Looks up a localized string similar to Byte to search. /// public static string FindByteString { get { @@ -482,7 +490,7 @@ public static string FindByteString { } /// - /// Recherche une chaîne localisée semblable à Find First. + /// Looks up a localized string similar to Find First. /// public static string FindFirstString { get { @@ -491,7 +499,7 @@ public static string FindFirstString { } /// - /// Recherche une chaîne localisée semblable à Find Last. + /// Looks up a localized string similar to Find Last. /// public static string FindLastString { get { @@ -500,7 +508,7 @@ public static string FindLastString { } /// - /// Recherche une chaîne localisée semblable à Find Next. + /// Looks up a localized string similar to Find Next. /// public static string FindNextString { get { @@ -509,7 +517,7 @@ public static string FindNextString { } /// - /// Recherche une chaîne localisée semblable à Find all occurence of selection. + /// Looks up a localized string similar to Find all occurence of selection. /// public static string FindSelectionString { get { @@ -518,7 +526,7 @@ public static string FindSelectionString { } /// - /// Recherche une chaîne localisée semblable à Find. + /// Looks up a localized string similar to Find. /// public static string FindString { get { @@ -527,7 +535,7 @@ public static string FindString { } /// - /// Recherche une chaîne localisée semblable à Find what:. + /// Looks up a localized string similar to Find what:. /// public static string FindWhatString { get { @@ -536,7 +544,7 @@ public static string FindWhatString { } /// - /// Recherche une chaîne localisée semblable à First byte. + /// Looks up a localized string similar to First byte. /// public static string FirstByteString { get { @@ -545,7 +553,7 @@ public static string FirstByteString { } /// - /// Recherche une chaîne localisée semblable à Hex. + /// Looks up a localized string similar to Hex. /// public static string HexString { get { @@ -554,7 +562,7 @@ public static string HexString { } /// - /// Recherche une chaîne localisée semblable à Highlight all data find. + /// Looks up a localized string similar to Highlight all data find. /// public static string HighLightSettingString { get { @@ -563,7 +571,7 @@ public static string HighLightSettingString { } /// - /// Recherche une chaîne localisée semblable à Kb. + /// Looks up a localized string similar to Kb. /// public static string KBTagString { get { @@ -572,7 +580,7 @@ public static string KBTagString { } /// - /// Recherche une chaîne localisée semblable à Length. + /// Looks up a localized string similar to Length. /// public static string LengthString { get { @@ -581,7 +589,7 @@ public static string LengthString { } /// - /// Recherche une chaîne localisée semblable à Ln. + /// Looks up a localized string similar to Ln. /// public static string LineStatusBarTagString { get { @@ -590,7 +598,7 @@ public static string LineStatusBarTagString { } /// - /// Recherche une chaîne localisée semblable à <ln>. + /// Looks up a localized string similar to <ln>. /// public static string LineTagString { get { @@ -599,7 +607,7 @@ public static string LineTagString { } /// - /// Recherche une chaîne localisée semblable à Long. + /// Looks up a localized string similar to Long. /// public static string LongString { get { @@ -608,7 +616,7 @@ public static string LongString { } /// - /// Recherche une chaîne localisée semblable à Mb. + /// Looks up a localized string similar to Mb. /// public static string MBTagString { get { @@ -617,7 +625,7 @@ public static string MBTagString { } /// - /// Recherche une chaîne localisée semblable à Ok. + /// Looks up a localized string similar to Ok. /// public static string OkString { get { @@ -626,7 +634,16 @@ public static string OkString { } /// - /// Recherche une chaîne localisée semblable à Paste operation reached the end of file. Do you want extend the file for complete operation ? This operation cannot be canceled if you continue.. + /// Looks up a localized string similar to The file is locked. Do you want to open it in read-only mode?. + /// + public static string OpenAsReadOnlyString { + get { + return ResourceManager.GetString("OpenAsReadOnlyString", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Paste operation reached the end of file. Do you want extend the file for complete operation ? This operation cannot be canceled if you continue.. /// public static string PasteExtendByteConfirmationString { get { @@ -635,7 +652,7 @@ public static string PasteExtendByteConfirmationString { } /// - /// Recherche une chaîne localisée semblable à Paste from clipboard. + /// Looks up a localized string similar to Paste from clipboard. /// public static string PasteFromClipboardString { get { @@ -644,7 +661,7 @@ public static string PasteFromClipboardString { } /// - /// Recherche une chaîne localisée semblable à Paste without inserting. + /// Looks up a localized string similar to Paste without inserting. /// public static string PasteNotInsertString { get { @@ -653,7 +670,7 @@ public static string PasteNotInsertString { } /// - /// Recherche une chaîne localisée semblable à Position. + /// Looks up a localized string similar to Position. /// public static string PositionString { get { @@ -662,7 +679,7 @@ public static string PositionString { } /// - /// Recherche une chaîne localisée semblable à Replace All. + /// Looks up a localized string similar to Replace All. /// public static string ReplaceAllString { get { @@ -671,7 +688,7 @@ public static string ReplaceAllString { } /// - /// Recherche une chaîne localisée semblable à Replace by byte. + /// Looks up a localized string similar to Replace by byte. /// public static string ReplaceByByteString { get { @@ -680,7 +697,7 @@ public static string ReplaceByByteString { } /// - /// Recherche une chaîne localisée semblable à Replace Next. + /// Looks up a localized string similar to Replace Next. /// public static string ReplaceNextString { get { @@ -689,7 +706,7 @@ public static string ReplaceNextString { } /// - /// Recherche une chaîne localisée semblable à Replace byte in selection.... + /// Looks up a localized string similar to Replace byte in selection.... /// public static string ReplaceSelectionString { get { @@ -698,7 +715,7 @@ public static string ReplaceSelectionString { } /// - /// Recherche une chaîne localisée semblable à Replace. + /// Looks up a localized string similar to Replace. /// public static string ReplaceString { get { @@ -707,7 +724,7 @@ public static string ReplaceString { } /// - /// Recherche une chaîne localisée semblable à Trim the data on the find length when replace. + /// Looks up a localized string similar to Trim the data on the find length when replace. /// public static string ReplaceTrimSettingString { get { @@ -716,7 +733,7 @@ public static string ReplaceTrimSettingString { } /// - /// Recherche une chaîne localisée semblable à Replace with byte. + /// Looks up a localized string similar to Replace with byte. /// public static string ReplaceWithByteString { get { @@ -725,7 +742,7 @@ public static string ReplaceWithByteString { } /// - /// Recherche une chaîne localisée semblable à Replace with:. + /// Looks up a localized string similar to Replace with:. /// public static string ReplaceWithString { get { @@ -734,7 +751,7 @@ public static string ReplaceWithString { } /// - /// Recherche une chaîne localisée semblable à Select all. + /// Looks up a localized string similar to Select all. /// public static string SelectAllString { get { @@ -743,7 +760,7 @@ public static string SelectAllString { } /// - /// Recherche une chaîne localisée semblable à Set bookmark. + /// Looks up a localized string similar to Set bookmark. /// public static string SetBookMarkString { get { @@ -752,7 +769,7 @@ public static string SetBookMarkString { } /// - /// Recherche une chaîne localisée semblable à TBL. + /// Looks up a localized string similar to TBL. /// public static string TBLString { get { @@ -761,7 +778,7 @@ public static string TBLString { } /// - /// Recherche une chaîne localisée semblable à This string are not hex. + /// Looks up a localized string similar to This string are not hex. /// public static string ThisStringAreNotHexString { get { @@ -770,7 +787,7 @@ public static string ThisStringAreNotHexString { } /// - /// Recherche une chaîne localisée semblable à Undo. + /// Looks up a localized string similar to Undo. /// public static string UndoString { get { @@ -779,7 +796,7 @@ public static string UndoString { } /// - /// Recherche une chaîne localisée semblable à Value. + /// Looks up a localized string similar to Value. /// public static string ValueString { get { @@ -788,7 +805,7 @@ public static string ValueString { } /// - /// Recherche une chaîne localisée semblable à An error is occurs when writing.. + /// Looks up a localized string similar to An error is occurs when writing.. /// public static string WritingErrorExeptionString { get { @@ -797,7 +814,7 @@ public static string WritingErrorExeptionString { } /// - /// Recherche une chaîne localisée semblable à Reset zoom to 100%. + /// Looks up a localized string similar to Reset zoom to 100%. /// public static string ZoomResetString { get { @@ -806,23 +823,12 @@ public static string ZoomResetString { } /// - /// Recherche une chaîne localisée semblable à Zoom. + /// Looks up a localized string similar to Zoom. /// public static string ZoomString { get { return ResourceManager.GetString("ZoomString", resourceCulture); } } - - /// - /// Recherche une chaîne localisée semblable à The file is locked. Do you want to open it in read-only mode?. - /// - public static string OpenAsReadOnlyString - { - get - { - return ResourceManager.GetString("OpenAsReadOnlyString", resourceCulture); - } - } } } diff --git a/Sources/WPFHexaEditor/Properties/Resources.resx b/Sources/WPFHexaEditor/Properties/Resources.resx index 02d18f91..dc0742e7 100644 --- a/Sources/WPFHexaEditor/Properties/Resources.resx +++ b/Sources/WPFHexaEditor/Properties/Resources.resx @@ -325,4 +325,7 @@ The file is locked. Do you want to open it in read-only mode? + + Bytes + \ No newline at end of file diff --git a/Sources/WPFHexaEditor/WpfHexEditorCore.csproj b/Sources/WPFHexaEditor/WpfHexEditorCore.csproj index 6011d957..1c874166 100644 --- a/Sources/WPFHexaEditor/WpfHexEditorCore.csproj +++ b/Sources/WPFHexaEditor/WpfHexEditorCore.csproj @@ -120,4 +120,18 @@ Settings.Designer.cs + + + + True + True + Resources.resx + True + + + Designer + Resources.Designer.cs + PublicResXFileCodeGenerator + +