From 6af2a88a4b14a9258196e5a353cdd4a2dcea3485 Mon Sep 17 00:00:00 2001 From: seto Date: Fri, 6 Dec 2024 18:43:43 +0900 Subject: [PATCH] update --- Crystallography.Controls/.editorconfig | 131 +++- .../Crystal/PoleFigureControl.cs | 3 +- .../CrystalDatabase/CrystalDatabaseControl.cs | 25 +- .../Crystallography.Controls.csproj | 5 +- Crystallography.Controls/DataSet.cs | 3 +- .../FormCrystalSelection.cs | 4 +- .../Numeric/NumericBox.resx | 4 +- Crystallography/Atom/AtomStatic.cs | 13 +- Crystallography/BetheMethod.cs | 8 +- Crystallography/ChemicalStandard.cs | 3 +- Crystallography/Crystal/ConvertCrystalData.cs | 20 +- Crystallography/Crystal/Crystal.cs | 3 +- Crystallography/Crystal/CrystalMinimum.cs | 2 +- Crystallography/Crystallography.csproj | 6 +- Crystallography/Detector/Ring.cs | 3 +- Crystallography/Euler.cs | 4 +- Crystallography/ExtensionMethods.cs | 39 +- Crystallography/FindParameter.cs | 44 +- Crystallography/Images/BitmapConverter.cs | 3 +- Crystallography/Images/DigitalMicrograph.cs | 8 +- Crystallography/Images/ImageIO.cs | 10 +- Crystallography/Images/ImageProcessor.cs | 3 +- Crystallography/Images/Tiff.cs | 25 +- Crystallography/Material.cs | 198 +++--- Crystallography/Mathematics/Geometry.cs | 8 +- Crystallography/Mathematics/Marquardt.cs | 28 +- Crystallography/Mathematics/Statistics.cs | 672 +++++++++--------- Crystallography/Matrix.cs | 26 +- Crystallography/Miscellaneous.cs | 10 +- Crystallography/NativeWrapper.cs | 2 +- Crystallography/NumericalFormula.cs | 4 +- Crystallography/PdiFile.cs | 63 +- Crystallography/Symmetry/SymmetryStatic.cs | 38 +- Crystallography/Symmetry/WyckoffPosition.cs | 2 +- 34 files changed, 796 insertions(+), 624 deletions(-) diff --git a/Crystallography.Controls/.editorconfig b/Crystallography.Controls/.editorconfig index be539c9..53db69e 100644 --- a/Crystallography.Controls/.editorconfig +++ b/Crystallography.Controls/.editorconfig @@ -1,4 +1,133 @@ [*.cs] # WFO1000: A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method -dotnet_diagnostic.WFO1000.severity = silent \ No newline at end of file +dotnet_diagnostic.WFO1000.severity = silent +[*.cs] +#### 命名スタイル #### + +# 名前付けルール + +dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion +dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface +dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i + +dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.types_should_be_pascal_case.symbols = types +dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case + +# 記号の仕様 + +dotnet_naming_symbols.interface.applicable_kinds = interface +dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.interface.required_modifiers = + +dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum +dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.types.required_modifiers = + +# 命名スタイル + +dotnet_naming_style.begins_with_i.required_prefix = I +dotnet_naming_style.begins_with_i.required_suffix = +dotnet_naming_style.begins_with_i.word_separator = +dotnet_naming_style.begins_with_i.capitalization = pascal_case + +dotnet_naming_style.pascal_case.required_prefix = +dotnet_naming_style.pascal_case.required_suffix = +dotnet_naming_style.pascal_case.word_separator = +dotnet_naming_style.pascal_case.capitalization = pascal_case +csharp_indent_labels = one_less_than_current +csharp_space_around_binary_operators = before_and_after +csharp_using_directive_placement = outside_namespace:silent +csharp_style_conditional_delegate_call = true:suggestion +csharp_style_var_for_built_in_types = false:silent +csharp_style_var_when_type_is_apparent = false:silent +csharp_style_var_elsewhere = false:silent +csharp_prefer_simple_using_statement = true:suggestion +csharp_prefer_braces = true:silent +csharp_style_namespace_declarations = block_scoped:silent +csharp_style_prefer_method_group_conversion = true:silent +csharp_style_prefer_top_level_statements = true:silent +csharp_style_prefer_primary_constructors = true:suggestion +csharp_prefer_system_threading_lock = true:suggestion +csharp_style_prefer_switch_expression = true:suggestion +csharp_style_prefer_pattern_matching = true:silent +csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion +csharp_style_pattern_matching_over_as_with_null_check = true:suggestion +csharp_style_prefer_not_pattern = true:suggestion +csharp_style_prefer_extended_property_pattern = true:suggestion +csharp_prefer_static_local_function = true:suggestion +csharp_prefer_static_anonymous_function = true:suggestion +csharp_style_prefer_readonly_struct = true:suggestion +csharp_style_prefer_readonly_struct_member = true:suggestion +csharp_style_expression_bodied_methods = false:silent +csharp_style_expression_bodied_constructors = false:silent +csharp_style_expression_bodied_operators = false:silent +csharp_style_expression_bodied_properties = true:silent +csharp_style_expression_bodied_indexers = true:silent +csharp_style_expression_bodied_accessors = true:silent + +[*.vb] +#### 命名スタイル #### + +# 名前付けルール + +dotnet_naming_rule.interface_should_be_i_で始まる.severity = suggestion +dotnet_naming_rule.interface_should_be_i_で始まる.symbols = interface +dotnet_naming_rule.interface_should_be_i_で始まる.style = i_で始まる + +dotnet_naming_rule.型_should_be_パスカル_ケース.severity = suggestion +dotnet_naming_rule.型_should_be_パスカル_ケース.symbols = 型 +dotnet_naming_rule.型_should_be_パスカル_ケース.style = パスカル_ケース + +dotnet_naming_rule.フィールド以外のメンバー_should_be_パスカル_ケース.severity = suggestion +dotnet_naming_rule.フィールド以外のメンバー_should_be_パスカル_ケース.symbols = フィールド以外のメンバー +dotnet_naming_rule.フィールド以外のメンバー_should_be_パスカル_ケース.style = パスカル_ケース + +# 記号の仕様 + +dotnet_naming_symbols.interface.applicable_kinds = interface +dotnet_naming_symbols.interface.applicable_accessibilities = public, friend, private, protected, protected_friend, private_protected +dotnet_naming_symbols.interface.required_modifiers = + +dotnet_naming_symbols.型.applicable_kinds = class, struct, interface, enum +dotnet_naming_symbols.型.applicable_accessibilities = public, friend, private, protected, protected_friend, private_protected +dotnet_naming_symbols.型.required_modifiers = + +dotnet_naming_symbols.フィールド以外のメンバー.applicable_kinds = property, event, method +dotnet_naming_symbols.フィールド以外のメンバー.applicable_accessibilities = public, friend, private, protected, protected_friend, private_protected +dotnet_naming_symbols.フィールド以外のメンバー.required_modifiers = + +# 命名スタイル + +dotnet_naming_style.i_で始まる.required_prefix = I +dotnet_naming_style.i_で始まる.required_suffix = +dotnet_naming_style.i_で始まる.word_separator = +dotnet_naming_style.i_で始まる.capitalization = pascal_case + +dotnet_naming_style.パスカル_ケース.required_prefix = +dotnet_naming_style.パスカル_ケース.required_suffix = +dotnet_naming_style.パスカル_ケース.word_separator = +dotnet_naming_style.パスカル_ケース.capitalization = pascal_case + +dotnet_naming_style.パスカル_ケース.required_prefix = +dotnet_naming_style.パスカル_ケース.required_suffix = +dotnet_naming_style.パスカル_ケース.word_separator = +dotnet_naming_style.パスカル_ケース.capitalization = pascal_case + +[*.{cs,vb}] +tab_width = 4 +indent_size = 4 +dotnet_style_operator_placement_when_wrapping = beginning_of_line +end_of_line = crlf +dotnet_style_qualification_for_field = false:silent +dotnet_style_qualification_for_property = false:silent +dotnet_style_qualification_for_method = false:silent +dotnet_style_qualification_for_event = false:silent +dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent +dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent +dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent +dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent +dotnet_code_quality_unused_parameters = all:suggestion +dotnet_style_readonly_field = true:suggestion +dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent \ No newline at end of file diff --git a/Crystallography.Controls/Crystal/PoleFigureControl.cs b/Crystallography.Controls/Crystal/PoleFigureControl.cs index 43059b5..8a28287 100644 --- a/Crystallography.Controls/Crystal/PoleFigureControl.cs +++ b/Crystallography.Controls/Crystal/PoleFigureControl.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Drawing; using System.Linq; +using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; @@ -286,7 +287,7 @@ public void DrawOutline(Graphics g) private int justBeforeCrystallineNumber = -1; private IEnumerable<(int Radial, int Sector)>[] Index; - public object lockObject = new object(); + public Lock lockObject = new(); public double[][] generateDensityArrayNormal(double angleResolution) { diff --git a/Crystallography.Controls/CrystalDatabase/CrystalDatabaseControl.cs b/Crystallography.Controls/CrystalDatabase/CrystalDatabaseControl.cs index f1e8720..3a80cdd 100644 --- a/Crystallography.Controls/CrystalDatabase/CrystalDatabaseControl.cs +++ b/Crystallography.Controls/CrystalDatabase/CrystalDatabaseControl.cs @@ -13,6 +13,7 @@ using System.Linq; using System.Reflection; using System.Security.Cryptography; +using System.Threading; using System.Windows.Forms; #endregion @@ -61,13 +62,13 @@ static byte[] serialize(T c) static Crystal2[] deserialize(Stream stream) { var buffer1 = new byte[4]; - stream.Read(buffer1); + stream.ReadExactly(buffer1); var length = BitConverter.ToInt32(buffer1); var buffer2 = ArrayPool.Shared.Rent(length); try { - stream.Read(buffer2, 0, length); + stream.ReadExactly(buffer2, 0, length); using var decompressor = new BrotliDecompressor();// Decompression(require using) return MemoryPackSerializer.Deserialize(decompressor.Decompress(buffer2.AsSpan()[0..length])); } @@ -100,21 +101,21 @@ public CrystalDatabaseControl() #region 繝繝シ繧ソ繝吶シ繧ケ隱ュ縺ソ霎シ縺ソ/譖ク縺崎セシ縺ソ髢「騾」 #region 繝舌う繝域嶌縺崎セシ縺ソ/隱ュ縺ソ霎シ縺ソ - private static int readInt(Stream s) => BitConverter.ToInt32(readBytes(s, 4), 0); - private static int readByte(Stream s) => s.ReadByte(); - private static long readLong(Stream s) => BitConverter.ToInt64(readBytes(s, 8), 0); + private static int readInt(FileStream s) => BitConverter.ToInt32(readBytes(s, 4), 0); + private static int readByte(FileStream s) => s.ReadByte(); + private static long readLong(FileStream s) => BitConverter.ToInt64(readBytes(s, 8), 0); - private static byte[] readBytes(Stream s, int length) + private static byte[] readBytes(FileStream s, int length) { var bytes = new byte[length]; - s.Read(bytes, 0, bytes.Length); + s.ReadExactly(bytes); return bytes; } - private static void writeInt(Stream s, in int v) => s.Write(BitConverter.GetBytes(v), 0, 4); - private static void writeLong(Stream s, in long v) => s.Write(BitConverter.GetBytes(v), 0, 8); - private static void writeByte(Stream s, in byte v) => s.WriteByte(v); - private static void writeBytes(Stream s, in byte[] v) => s.Write(v, 0, v.Length); + private static void writeInt(FileStream s, in int v) => s.Write(BitConverter.GetBytes(v), 0, 4); + private static void writeLong(FileStream s, in long v) => s.Write(BitConverter.GetBytes(v), 0, 8); + private static void writeByte(FileStream s, in byte v) => s.WriteByte(v); + private static void writeBytes(FileStream s, in byte[] v) => s.Write(v, 0, v.Length); #endregion @@ -128,7 +129,7 @@ public void ReadDatabase(string filename) ReadDatabaseWorker.RunWorkerAsync(filename); } - readonly object lockObj = new(); + readonly Lock lockObj = new(); private void ReadDatabaseWorker_DoWork(object sender, DoWorkEventArgs e) { var filename = (string)e.Argument; diff --git a/Crystallography.Controls/Crystallography.Controls.csproj b/Crystallography.Controls/Crystallography.Controls.csproj index a98fc33..ffb00a8 100644 --- a/Crystallography.Controls/Crystallography.Controls.csproj +++ b/Crystallography.Controls/Crystallography.Controls.csproj @@ -4,8 +4,8 @@ Library net9.0-windows10.0.26100.0 true - 2024.11.13.0858 - 2024.11.13.0858 + 2024.12.6.0941 + 2024.12.6.0941 PerMonitorV2 true true @@ -42,6 +42,7 @@ + diff --git a/Crystallography.Controls/DataSet.cs b/Crystallography.Controls/DataSet.cs index 67d9526..7b8c928 100644 --- a/Crystallography.Controls/DataSet.cs +++ b/Crystallography.Controls/DataSet.cs @@ -5,6 +5,7 @@ using System.Drawing; using System.Linq; using System.Numerics; +using System.Threading; namespace Crystallography.Controls; @@ -258,7 +259,7 @@ public void Replace(object srcCrystal, Crystal2 targetcrystal) } } - readonly object lockObj = new(); + readonly Lock lockObj = new(); public DataTableCrystalDatabaseRow CreateRow(Crystal2 c) { DataTableCrystalDatabaseRow dr; diff --git a/Crystallography.Controls/FormCrystalSelection.cs b/Crystallography.Controls/FormCrystalSelection.cs index 0357009..0a6172e 100644 --- a/Crystallography.Controls/FormCrystalSelection.cs +++ b/Crystallography.Controls/FormCrystalSelection.cs @@ -75,10 +75,10 @@ public Crystal[] CheckedCrystalList { get { - List crystalList = new List(); + List crystalList = []; for (int i = 0; i < checkedListBox1.CheckedItems.Count; i++) crystalList.Add((Crystal)checkedListBox1.CheckedItems[i]); - return crystalList.ToArray(); + return [.. crystalList]; } } diff --git a/Crystallography.Controls/Numeric/NumericBox.resx b/Crystallography.Controls/Numeric/NumericBox.resx index 52b4c25..a716d04 100644 --- a/Crystallography.Controls/Numeric/NumericBox.resx +++ b/Crystallography.Controls/Numeric/NumericBox.resx @@ -1,7 +1,7 @@