Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
seto committed Dec 7, 2024
1 parent f47ac58 commit 012db1f
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 25 deletions.
4 changes: 2 additions & 2 deletions Crystallography.Controls/Crystallography.Controls.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<OutputType>Library</OutputType>
<TargetFramework>net9.0-windows10.0.26100.0</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<AssemblyVersion>2024.12.6.0246</AssemblyVersion>
<FileVersion>2024.12.6.0246</FileVersion>
<AssemblyVersion>2024.12.7.0024</AssemblyVersion>
<FileVersion>2024.12.7.0024</FileVersion>
<ApplicationHighDpiMode>PerMonitorV2</ApplicationHighDpiMode>
<ApplicationUseCompatibleTextRendering>true</ApplicationUseCompatibleTextRendering>
<ApplicationVisualStyles>true</ApplicationVisualStyles>
Expand Down
2 changes: 1 addition & 1 deletion Crystallography/Atom/AtomMinimum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Crystallography;
/// <summary>
/// Atoms2クラス
/// </summary>
[Serializable()]
//[Serializable()]
[MemoryPackable]
public partial class Atoms2
{
Expand Down
40 changes: 39 additions & 1 deletion Crystallography/Crystal/CrystalMinimum.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using MemoryPack;
using MemoryPack.Compression;
using System;
using System.Collections.Frozen;
using System.Collections.Generic;
Expand All @@ -11,7 +12,7 @@ namespace Crystallography;

//必要最小限の情報だけを保存するクラス
//[ProtoContract]
[Serializable()]
//[Serializable()]
[MemoryPackable]
public partial class Crystal2
{
Expand Down Expand Up @@ -217,6 +218,43 @@ [ Compose(a.Dsf.Aniso11, a.Dsf.Aniso11_err),
return c2;
}

/// <summary>
/// MemoryPackでシリアライズしてbyte[]配列を返す
/// </summary>
/// <returns></returns>
public byte[] Serialize()
{
return Serialize(this);
}

/// <summary>
/// 静的メソッド MemoryPackでシリアライズしてbyte[]配列を返す
/// </summary>
/// <param name="c"></param>
/// <returns></returns>
public static byte[] Serialize(Crystal2 c )
{
using var compressor = new BrotliCompressor(System.IO.Compression.CompressionLevel.Optimal);
MemoryPackSerializer.Serialize(compressor, c);
var data = compressor.ToArray();
return data;
}

/// <summary>
/// MemoryPackでシリアライズされたbyte[]配列からCrystal2を返す. 不適切な入力値だった場合はnull返し。
/// </summary>
/// <param name="bytes"></param>
/// <returns></returns>
public static Crystal2 Deserialize(byte[] bytes)
{
try
{
using var decompressor = new BrotliDecompressor();// Decompression(require using)
return MemoryPackSerializer.Deserialize<Crystal2>(decompressor.Decompress(bytes));
}
catch { return null; }
}

[MemoryPackIgnore]
private static readonly CultureInfo culture = CultureInfo.InvariantCulture;
[MemoryPackIgnore]
Expand Down
4 changes: 2 additions & 2 deletions Crystallography/Crystallography.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<OutputType>Library</OutputType>
<TargetFramework>net9.0-windows10.0.26100.0</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<AssemblyVersion>2024.12.6.0246</AssemblyVersion>
<FileVersion>2024.12.6.0246</FileVersion>
<AssemblyVersion>2024.12.7.0024</AssemblyVersion>
<FileVersion>2024.12.7.0024</FileVersion>
<SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>
Expand Down
5 changes: 2 additions & 3 deletions Crystallography/PdiFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ public static bool SavePdi2File(DiffractionProfile2[] dp, string fileName)
}
catch
{
if (fs != null)
fs.Close();
fs?.Close();
return false;
}
}
Expand Down Expand Up @@ -70,7 +69,7 @@ public static DiffractionProfile2[] ReadPdi2File(string fileName, int version =
if (dp.Length > 0)
return dp;
else
return Array.Empty<DiffractionProfile2>();
return [];
}
else //バージョン1
{
Expand Down
1 change: 1 addition & 0 deletions Crystallography/Profile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Drawing;
using System.Linq;
using System.Numerics;
using System.Text.Json.Serialization;
using System.Xml.Serialization;

namespace Crystallography;
Expand Down
4 changes: 2 additions & 2 deletions PDIndexer/FormMain.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 11 additions & 11 deletions PDIndexer/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -354,15 +354,16 @@ protected override void WndProc(ref Message msg)
{
try
{
if (Clipboard.GetDataObject().GetDataPresent(typeof(DiffractionProfile2)))
{
var data = Clipboard.GetDataObject();
var dp = (DiffractionProfile2)data.GetData(typeof(DiffractionProfile2));
//if (Clipboard.GetDataObject().GetDataPresent(typeof(DiffractionProfile2)))
//{
// var data = Clipboard.GetDataObject();
// var dp = (DiffractionProfile2)data.GetData(typeof(DiffractionProfile2));

if (dp != null)
AddProfileToCheckedListBox(dp, true, true);
}
else if (Clipboard.GetDataObject().GetDataPresent(typeof(DiffractionProfile2[])))
// if (dp != null)
// AddProfileToCheckedListBox(dp, true, true);
//}
//else
if (Clipboard.GetDataObject().GetDataPresent(typeof(DiffractionProfile2[])))
{
var dataObject = Clipboard.GetDataObject();
var data = dataObject;
Expand Down Expand Up @@ -398,10 +399,9 @@ protected override void WndProc(ref Message msg)
}
}

else if (Clipboard.GetDataObject().GetDataPresent(typeof(Crystal2)) && formCrystal.Visible)
else if (Clipboard.GetDataObject().GetDataPresent(typeof(byte[])) && formCrystal.Visible)
{
IDataObject data = Clipboard.GetDataObject();
var c2 = (Crystal2)data.GetData(typeof(Crystal2));
var c2 =Crystal2.Deserialize((byte[])Clipboard.GetDataObject().GetData(typeof(byte[])));
formCrystal.crystalControl.Crystal = Crystal2.GetCrystal(c2);
}
else if ((Clipboard.GetDataObject()).GetDataPresent(typeof(MacroTriger)))
Expand Down
2 changes: 1 addition & 1 deletion PDIndexer/FormMain.resx
Original file line number Diff line number Diff line change
Expand Up @@ -2198,7 +2198,7 @@ You can set the limit value in right-click menu.</value>
<value>0</value>
</data>
<data name="tableLayoutPanel2.LayoutSettings" type="System.Windows.Forms.TableLayoutSettings, System.Windows.Forms">
<value>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TableLayoutSettings&gt;&lt;Controls&gt;&lt;Control Name="numericBoxUpperX" Row="0" RowSpan="1" Column="3" ColumnSpan="1" /&gt;&lt;Control Name="numericBoxUpperY" Row="0" RowSpan="1" Column="7" ColumnSpan="1" /&gt;&lt;Control Name="numericBoxLowerX" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="numericBoxLowerY" Row="0" RowSpan="1" Column="5" ColumnSpan="1" /&gt;&lt;Control Name="labelD" Row="0" RowSpan="1" Column="9" ColumnSpan="1" /&gt;&lt;Control Name="labelTwoTheta" Row="0" RowSpan="1" Column="8" ColumnSpan="1" /&gt;&lt;Control Name="label11" Row="0" RowSpan="1" Column="6" ColumnSpan="1" /&gt;&lt;Control Name="label10" Row="0" RowSpan="1" Column="2" ColumnSpan="1" /&gt;&lt;Control Name="labelX" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="label9" Row="0" RowSpan="1" Column="4" ColumnSpan="1" /&gt;&lt;Control Name="labelIntensity" Row="0" RowSpan="1" Column="11" ColumnSpan="1" /&gt;&lt;Control Name="labelQ" Row="0" RowSpan="1" Column="10" ColumnSpan="1" /&gt;&lt;/Controls&gt;&lt;Columns Styles="AutoSize,0,Percent,9,751601,AutoSize,0,Percent,9,751601,AutoSize,0,Percent,9,751601,AutoSize,0,Percent,9,751601,Percent,17,114044,Percent,14,627389,Percent,14,627389,Percent,14,624775" /&gt;&lt;Rows Styles="Percent,100" /&gt;&lt;/TableLayoutSettings&gt;</value>
<value>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TableLayoutSettings&gt;&lt;Controls&gt;&lt;Control Name="numericBoxUpperX" Row="0" RowSpan="1" Column="3" ColumnSpan="1" /&gt;&lt;Control Name="numericBoxUpperY" Row="0" RowSpan="1" Column="7" ColumnSpan="1" /&gt;&lt;Control Name="numericBoxLowerX" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="numericBoxLowerY" Row="0" RowSpan="1" Column="5" ColumnSpan="1" /&gt;&lt;Control Name="labelD" Row="0" RowSpan="1" Column="9" ColumnSpan="1" /&gt;&lt;Control Name="labelTwoTheta" Row="0" RowSpan="1" Column="8" ColumnSpan="1" /&gt;&lt;Control Name="label11" Row="0" RowSpan="1" Column="6" ColumnSpan="1" /&gt;&lt;Control Name="label10" Row="0" RowSpan="1" Column="2" ColumnSpan="1" /&gt;&lt;Control Name="labelX" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="label9" Row="0" RowSpan="1" Column="4" ColumnSpan="1" /&gt;&lt;Control Name="labelIntensity" Row="0" RowSpan="1" Column="11" ColumnSpan="1" /&gt;&lt;Control Name="labelQ" Row="0" RowSpan="1" Column="10" ColumnSpan="1" /&gt;&lt;/Controls&gt;&lt;Columns Styles="AutoSize,0,Percent,9.751601,AutoSize,0,Percent,9.751601,AutoSize,0,Percent,9.751601,AutoSize,0,Percent,9.751601,Percent,17.114044,Percent,14.627389,Percent,14.627389,Percent,14.624775" /&gt;&lt;Rows Styles="Percent,100" /&gt;&lt;/TableLayoutSettings&gt;</value>
</data>
<data name="panel1.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Top</value>
Expand Down
6 changes: 4 additions & 2 deletions PDIndexer/PDIndexer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
<OutputType>WinExe</OutputType>
<TargetFramework>net9.0-windows10.0.26100.0</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<AssemblyVersion>2024.12.6.0246</AssemblyVersion>
<FileVersion>2024.12.6.0246</FileVersion>
<AssemblyVersion>2024.12.7.0021</AssemblyVersion>
<FileVersion>2024.12.7.0021</FileVersion>
<ApplicationIcon>App.ico</ApplicationIcon>
<SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion>
<ApplicationHighDpiMode>PerMonitorV2</ApplicationHighDpiMode>
<ApplicationUseCompatibleTextRendering>true</ApplicationUseCompatibleTextRendering>
<ApplicationVisualStyles>true</ApplicationVisualStyles>
<EnableUnsafeBinaryFormatterSerialization>true</EnableUnsafeBinaryFormatterSerialization>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand All @@ -37,6 +38,7 @@

<ItemGroup>
<PackageReference Include="SimdLinq" Version="1.3.2" />
<PackageReference Include="System.Runtime.Serialization.Formatters" Version="9.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions PDIndexer/Version.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ static class Version
/// </summary>
public const string History =
"History" +
"\r\n ver4.450(2024/12/07) Fixed a minor bug on the clipboard operation." +
"\r\n ver4.449(2024/12/06) Fixed a minor bug when loading/saving the version number. (thx to Loïc Toraille-san)" +
"\r\n ver4.448(2024/12/03) Further bug fixes have been made regarding the decimal separator issue. (thx to Loïc Toraille-san)" +
"\r\n ver4.447(2024/12/02) The framework has been changed to .Net Desktop Runtime 9.0. Fixed bugs on decimal separator symbols (thx to Loïc Toraille-san, see github.com/seto77/PDIndexer/issues/2)." +
Expand Down

0 comments on commit 012db1f

Please sign in to comment.