Skip to content

Commit ba45503

Browse files
committed
update
1 parent 3b7c69c commit ba45503

7 files changed

Lines changed: 39 additions & 29 deletions

File tree

Crystallography.Controls/CrystalDatabase/CrystalDatabaseControl.cs

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
using Windows.UI.StartScreen;
2222
using ZLinq;
2323
using static Community.CsharpSqlite.Sqlite3;
24+
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
2425
#endregion
2526

2627
namespace Crystallography.Controls;
@@ -436,11 +437,9 @@ private static bool checkMD5(string path, byte[] md5)
436437
/// <summary>
437438
/// CODデータベースのダウンロードや読み込み.
438439
/// </summary>
439-
/// <param name="sender"></param>
440-
/// <param name="e"></param>
441-
public void ReadCOD()
440+
/// <returns>正常に読み込めた場合はtrue, 途中キャンセルされたりした場合はfalse</returns>
441+
public bool ReadCOD()
442442
{
443-
this.Enabled = false;
444443
var (Valid, DataNum, FileNum, FileSizes, CheckSums) = CheckDatabaseFiles(UserAppDataPath + "COD.cdb3", true);
445444
string urlHeader = "https://github.com/seto77/CSManager/raw/master/COD/";
446445
if (Valid)
@@ -450,7 +449,7 @@ public void ReadCOD()
450449
if (new WebClient().DownloadData(new Uri(urlHeader + "COD.cdb3")).SequenceEqual(File.ReadAllBytes(UserAppDataPath + "COD.cdb3")))
451450
{//ローカルのCODが最新版の場合
452451
ReadDatabase(UserAppDataPath + "COD.cdb3");
453-
return;
452+
return true;
454453
}
455454
else
456455
{//更新版が存在する場合
@@ -461,27 +460,26 @@ public void ReadCOD()
461460
ReadDatabase(UserAppDataPath + "COD.cdb3");
462461

463462
if (result == DialogResult.No || result == DialogResult.Cancel)//NoかCancelの場合
464-
return;
463+
return false;
465464
}
466465

467466
}
468467
catch //WEBが落ちている場合は、現状のCODを読み込む
469468
{
470469
ReadDatabase(UserAppDataPath + "COD.cdb3");
471-
return;
470+
return true;
472471
}
473472
}
474473
else//CODデータが存在しないか、適切でない場合
475474
{
476475
if (MessageBox.Show("Local COD database is missing.\r\n Do you download the new database now ?", "Local COD database is missing.",
477476
MessageBoxButtons.YesNo) == DialogResult.No)
478-
return;
477+
return false;
479478
}
480479

481480
//ここまでくる場合は、CODデータが存在しない場合
482481
//CODをダウンロードする
483-
if (DownloadCodWorker.IsBusy) return;
484-
this.Enabled = false;
482+
if (DownloadCodWorker.IsBusy) return false;
485483
DownloadCodWorker.RunWorkerAsync(UserAppDataPath);
486484

487485
while (DownloadCodWorker.IsBusy)//ダウンロードが完了するまで待つ
@@ -491,6 +489,7 @@ public void ReadCOD()
491489
}
492490
//this.Enabled = true;
493491
ReadDatabase(UserAppDataPath + "COD.cdb3");
492+
return true;
494493
}
495494

496495
private void DownloadCodWorker_DoWork(object sender, DoWorkEventArgs e)
@@ -685,24 +684,40 @@ private void CrystalDatabaseControl_Resize(object sender, EventArgs e)
685684

686685
private void checkBoxAMCSD_CheckedChanged(object sender, EventArgs e)
687686
{
688-
if(checkBoxAMCSD.Checked && !AMCSD_Has_Read)
687+
Enabled = false;
688+
if (checkBoxAMCSD.Checked && !AMCSD_Has_Read)
689689
{
690690
ReadDatabase(UserAppDataPath + "AMCSD.cdb3");
691691
AMCSD_Has_Read = true;
692692
}
693693

694694
DataBaseChanged?.Invoke(sender, e);
695+
Enabled = true;
695696
}
696697

697698
private void checkBoxCOD_CheckedChanged(object sender, EventArgs e)
698699
{
699-
if (checkBoxCOD.Checked && !COD_Has_Read)
700+
Enabled = false;
701+
var text = textBox1.Text;
702+
if (checkBoxCOD.Checked)
700703
{
701-
ReadCOD();
702-
COD_Has_Read = true;
703-
do { Thread.Sleep(100);Application.DoEvents(); } while (!Enabled);
704+
textBox1.Text = "Now, loading COD database...";
705+
Application.DoEvents();
706+
if (!COD_Has_Read)
707+
{
708+
if (ReadCOD())
709+
{
710+
COD_Has_Read = true;
711+
do { Thread.Sleep(100); Application.DoEvents(); } while (!Enabled);
712+
}
713+
else
714+
{ checkBoxCOD.Checked = false; Enabled = true; }
715+
}
704716
}
705717
DataBaseChanged?.Invoke(sender, e);
718+
textBox1.Text = text;
719+
Enabled = true;
720+
706721
}
707722
}
708723

Crystallography.Controls/CrystalDatabase/SearchCrystalControl.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
using MathNet.Numerics.Statistics.Mcmc;
2-
using System;
1+
using System;
32
using System.Collections.Generic;
43
using System.Data;
54
using System.Diagnostics;
65
using System.Linq;
76
using System.Runtime.InteropServices;
8-
using System.Security.Cryptography.Xml;
97
using System.Threading;
108
using System.Threading.Tasks;
119
using System.Windows.Forms;
12-
using static Community.CsharpSqlite.Sqlite3;
1310

1411
namespace Crystallography.Controls;
1512
public partial class SearchCrystalControl : UserControl
@@ -306,7 +303,7 @@ static float[] calcDlist(double a, double b, double c, double alpha, double beta
306303
outer.RemoveRange(0, end + 1);
307304
outer.Sort((e1, e2) => e1.len.CompareTo(e2.len));
308305
}
309-
return gList.Select(g => (float)(1 / g)).ToArray();
306+
return [.. gList.Select(g => (float)(1 / g))];
310307
}
311308

312309

@@ -344,7 +341,6 @@ private void backgroundWorkerSearch_RunWorkerCompleted(object sender, System.Com
344341
//else
345342
CrystalDatabaseControl.Resume();//バインディングを繋げる
346343

347-
348344
this.Enabled = true;
349345

350346
Thread.Sleep(100);

Crystallography.Controls/Crystallography.Controls.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<OutputType>Library</OutputType>
55
<TargetFramework>net9.0-windows10.0.26100.0</TargetFramework>
66
<UseWindowsForms>true</UseWindowsForms>
7-
<AssemblyVersion>2025.9.26.0817</AssemblyVersion>
8-
<FileVersion>2025.9.26.0817</FileVersion>
7+
<AssemblyVersion>2025.9.26.0917</AssemblyVersion>
8+
<FileVersion>2025.9.26.0917</FileVersion>
99
<ApplicationHighDpiMode>PerMonitorV2</ApplicationHighDpiMode>
1010
<ApplicationUseCompatibleTextRendering>true</ApplicationUseCompatibleTextRendering>
1111
<ApplicationVisualStyles>true</ApplicationVisualStyles>

Crystallography/Crystallography.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<OutputType>Library</OutputType>
55
<TargetFramework>net9.0-windows10.0.26100.0</TargetFramework>
66
<UseWindowsForms>true</UseWindowsForms>
7-
<AssemblyVersion>2025.9.26.0817</AssemblyVersion>
8-
<FileVersion>2025.9.26.0817</FileVersion>
7+
<AssemblyVersion>2025.9.26.0917</AssemblyVersion>
8+
<FileVersion>2025.9.26.0917</FileVersion>
99
<SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion>
1010
<Platforms>AnyCPU;x64</Platforms>
1111
<PublishReadyToRun>true</PublishReadyToRun>

ReciPro/FormCrystalDatabase.Designer.cs

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ReciPro/FormCrystalDatabase.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ public FormCrystalDatabase()
1717

1818
private void FormCrystalDatabase_Load(object sender, EventArgs e)
1919
{
20-
//if (File.Exists(FormMain.UserAppDataPath + "AMCSD.cdb3"))
21-
// crystalDatabaseControl.ReadDatabase(FormMain.UserAppDataPath + "AMCSD.cdb3");
2220
crystalDatabaseControl.AMCSD_Checked = true;
2321
}
2422

ReciPro/ReciPro.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<OutputType>WinExe</OutputType>
55
<TargetFramework>net9.0-windows10.0.26100.0</TargetFramework>
66
<UseWindowsForms>true</UseWindowsForms>
7-
<AssemblyVersion>2025.9.26.0815</AssemblyVersion>
8-
<FileVersion>2025.9.26.0815</FileVersion>
7+
<AssemblyVersion>2025.9.26.0822</AssemblyVersion>
8+
<FileVersion>2025.9.26.0822</FileVersion>
99
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
1010
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
1111
<ApplicationIcon>App.ico</ApplicationIcon>

0 commit comments

Comments
 (0)