Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
seto committed Nov 1, 2024
1 parent b3d8fda commit e2845eb
Show file tree
Hide file tree
Showing 8 changed files with 624 additions and 378 deletions.
2 changes: 1 addition & 1 deletion Crystallography/Crystallography.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<PackageReference Include="MemoryPack" Version="1.21.3" />
<PackageReference Include="OpenTK" Version="3.3.3" />
<PackageReference Include="SimdLinq" Version="1.3.2" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.4.7" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.4.8" />
</ItemGroup>

<ItemGroup>
Expand Down
48 changes: 48 additions & 0 deletions Crystallography/Miscellaneous.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Threading;
Expand Down Expand Up @@ -108,6 +109,53 @@ public static bool IsDecimalPointComma

public static (int Division, int Modulus) DivMod(int n, int m) => (n / m, n % m);

/// <summary>
/// ファイルが使用中かどうかをチェック
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
public static bool isFileExistsAndLocked(string path)
{
if (File.Exists(path))
{
FileStream stream = null;

try
{
stream = new FileStream(path, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
}
catch (DirectoryNotFoundException e)
{
return false;
}
catch (FileNotFoundException e)
{
return false;
}
catch (IOException e)
{
if (File.Exists(path))
{
return true;
}
}
catch (Exception e)
{
return false;
}
finally
{
if (stream != null)
{
stream.Close();
}
}

return false;
}

return false;
}
}


Expand Down
2 changes: 0 additions & 2 deletions IPAnalyzer/FormAutoProcedure.Designer.cs

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

12 changes: 11 additions & 1 deletion IPAnalyzer/FormAutoProcedure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Crystallography;
using System.Text;
using System.Collections.Generic;
using System.Threading;
#endregion

namespace IPAnalyzer;
Expand Down Expand Up @@ -112,6 +113,9 @@ private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
{
if (!checkBoxPatternMatching.Checked)
{
while (Miscellaneous.isFileExistsAndLocked(f))
Thread.Sleep(50);

formMain.ReadImage(f);
// break;
}
Expand All @@ -132,6 +136,12 @@ private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
if ((radioButtonEqual.Checked && num % numericBoxDivisor.ValueInteger == numericBoxRemainder.ValueInteger) ||
(radioButtonNotEqual.Checked && num % numericBoxDivisor.ValueInteger != numericBoxRemainder.ValueInteger))
{
long fileSize = 0;
while (fileSize != new FileInfo(f).Length)
{
Thread.Sleep(50);
fileSize = new FileInfo(f).Length;
}
formMain.ReadImage(f);
// break;
}
Expand All @@ -145,7 +155,7 @@ private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
}

catch { System.Threading.Thread.Sleep(1000); }
System.Threading.Thread.Sleep(200);
System.Threading.Thread.Sleep(100);
}
}

Expand Down
20 changes: 10 additions & 10 deletions IPAnalyzer/FormAutoProcedure.ja.resx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Microsoft ResX Schema
Version 2.0
Expand Down Expand Up @@ -48,7 +48,7 @@
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
Expand Down Expand Up @@ -188,14 +188,20 @@
<data name="checkBoxAutoLoad.Text" xml:space="preserve">
<value>新しい画像を自動で読み込む</value>
</data>
<data name="groupBox1.Size" type="System.Drawing.Size, System.Drawing">
<value>249, 118</value>
</data>
<data name="checkBoxPatternMatching.Location" type="System.Drawing.Point, System.Drawing">
<value>10, 70</value>
</data>
<data name="flowLayoutPanel1.Location" type="System.Drawing.Point, System.Drawing">
<value>13, 90</value>
</data>
<data name="groupBox1.Size" type="System.Drawing.Size, System.Drawing">
<value>249, 118</value>
<data name="groupBox2.Location" type="System.Drawing.Point, System.Drawing">
<value>6, 140</value>
</data>
<data name="groupBox2.Size" type="System.Drawing.Size, System.Drawing">
<value>249, 174</value>
</data>
<data name="label2.Font" type="System.Drawing.Font, System.Drawing">
<value>メイリオ, 9pt</value>
Expand All @@ -218,12 +224,6 @@
<data name="comboBoxMacro.Size" type="System.Drawing.Size, System.Drawing">
<value>121, 26</value>
</data>
<data name="groupBox2.Location" type="System.Drawing.Point, System.Drawing">
<value>6, 140</value>
</data>
<data name="groupBox2.Size" type="System.Drawing.Size, System.Drawing">
<value>249, 174</value>
</data>
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
<value>259, 323</value>
</data>
Expand Down
Loading

0 comments on commit e2845eb

Please sign in to comment.