Skip to content

Commit

Permalink
update to 0.5.0.19
Browse files Browse the repository at this point in the history
  • Loading branch information
mjohne authored Oct 5, 2019
1 parent e117996 commit 26c5985
Show file tree
Hide file tree
Showing 18 changed files with 7,958 additions and 793 deletions.
60 changes: 47 additions & 13 deletions CatalogChooserForm.Designer.cs

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

150 changes: 143 additions & 7 deletions CatalogChooserForm.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Hipparcos_DB.Properties;
using System;
using System.Diagnostics;
using System.IO;
using System.Windows.Forms;

Expand Down Expand Up @@ -31,11 +32,47 @@ public partial class CatalogChooserForm : Form
"solar_t.dat.gz"
};

private readonly string[] filesTychoCatalog =
{
"h_dm_com.dat.gz",
"h_dm_cor.dat.gz",
"hd_notes.doc.gz",
"hg_notes.doc.gz",
"h_dm_cor.dat.gz",
"hip_dm_g.dat.gz",
"hip_dm_o.dat.gz",
"hip_dm_v.dat.gz",
"hip_dm_x.dat.gz",
"hip_main.dat.gz",
"hip_va_1.dat.gz",
"hip_va_2.dat.gz",
"hp_auth.doc.gz",
"hp_notes.doc.gz",
"hp_refs.doc.gz",
"solar_ha.dat.gz",
"solar_hp.dat.gz",
"solar_t.dat.gz",
"tyc_main.dat"
};

private string RemoveFileExtension(string filename)
{
return filename.Substring(startIndex: 0, length: filename.LastIndexOf(value: "."));
}

private bool HasFileExtension(string filename, string extension)
{
return Path.GetExtension(path: filename).ToLower() == extension.ToLower();
}

private static void OpenExplorer(string path)
{
if (Directory.Exists(path: path))
{
Process.Start(fileName: @path);
}
}

public CatalogChooserForm()
{
InitializeComponent();
Expand All @@ -46,7 +83,6 @@ public CatalogChooserForm()
default: StartPosition = FormStartPosition.CenterParent; break;
}
*/
buttonDownloadTychoCatalog.Enabled = buttonOpenTychoCatalog.Enabled = false;
}

private void SetStatusbar(string text)
Expand Down Expand Up @@ -152,12 +188,6 @@ private void CatalogChooserForm_Load(object sender, EventArgs e)

#region Click event handlers

private void ButtonOpenTychoCatalog_Click(object sender, EventArgs e)
{
settings.Reload();
throw new NotImplementedException();
}

private void ButtonInfo_Click(object sender, EventArgs e)
{
settings.Reload();
Expand Down Expand Up @@ -198,6 +228,9 @@ private void ButtonDownloadTychoCatalog_Click(object sender, EventArgs e)
settings.Reload();
using (DownloaderForm downloaderForm = new DownloaderForm())
{
downloaderForm.SetHost(host: settings.UserHostName);
downloaderForm.SetHostUrls(files: filesTychoCatalog);
downloaderForm.SetCatalogDirectory(directory: settings.UserTychoCatalogDirectory);
downloaderForm.ShowDialog();
}
}
Expand Down Expand Up @@ -238,6 +271,66 @@ private void ButtonOpenHipparcosCatalog_Click(object sender, EventArgs e)
}
}

private void ButtonOpenTychoCatalog_Click(object sender, EventArgs e)
{
settings.Reload();
bool allFilesFound = true;
foreach (string file in filesTychoCatalog)
{
if (allFilesFound)
{
if (HasFileExtension(filename: file, extension: ".gz"))
{
if (File.Exists(path: settings.UserTychoCatalogDirectory + RemoveFileExtension(filename: file)))
{
allFilesFound = true;
}
else
{
allFilesFound = false;
}
}
else
{
if (File.Exists(path: settings.UserTychoCatalogDirectory + file))
{
allFilesFound = true;
}
else
{
allFilesFound = false;
}
}
}
}
if (allFilesFound)
{
using (TychoCatalogViewerForm formTychoCatalogViewer = new TychoCatalogViewerForm())
{
formTychoCatalogViewer.ShowDialog();
}
}
else
{
MessageBox.Show(
owner: this,
text: "Some files are missing. Please use the download button to download all files.",
caption: "Missing files",
buttons: MessageBoxButtons.OK,
icon: MessageBoxIcon.Error);
}
}

private void ButtonOpenHipparcosDirectory_Click(object sender, EventArgs e)
{
OpenExplorer(path: Environment.CurrentDirectory + Path.DirectorySeparatorChar + settings.UserHipparcosCatalogDirectory);
}

private void ButtonOpenTychoDirectory_Click(object sender, EventArgs e)
{
OpenExplorer(path: Environment.CurrentDirectory + Path.DirectorySeparatorChar + settings.UserTychoCatalogDirectory);
}

#endregion

#region Enter event handlers
Expand Down Expand Up @@ -267,6 +360,16 @@ private void ButtonExit_Enter(object sender, EventArgs e)
SetStatusbar(sender: sender, e: e);
}

private void ButtonOpenHipparcosDirectory_Enter(object sender, EventArgs e)
{
SetStatusbar(sender: sender, e: e);
}

private void ButtonOpenTychoDirectory_Enter(object sender, EventArgs e)
{
SetStatusbar(sender: sender, e: e);
}

#endregion

#region MouseEnter event handlers
Expand All @@ -280,6 +383,7 @@ private void ButtonOpenTychoCatalog_MouseEnter(object sender, EventArgs e)
{
SetStatusbar(sender: sender, e: e);
}

private void ButtonInfo_MouseEnter(object sender, EventArgs e)
{
SetStatusbar(sender: sender, e: e);
Expand All @@ -295,6 +399,16 @@ private void ButtonExit_MouseEnter(object sender, EventArgs e)
SetStatusbar(sender: sender, e: e);
}

private void ButtonOpenHipparcosDirectory_MouseEnter(object sender, EventArgs e)
{
SetStatusbar(sender: sender, e: e);
}

private void ButtonOpenTychoDirectory_MouseEnter(object sender, EventArgs e)
{
SetStatusbar(sender: sender, e: e);
}

#endregion

#region Leave event handlers
Expand Down Expand Up @@ -323,6 +437,16 @@ private void ButtonExit_Leave(object sender, EventArgs e)
ClearStatusbar();
}

private void ButtonOpenHipparcosDirectory_Leave(object sender, EventArgs e)
{
ClearStatusbar();
}

private void ButtonOpenTychoDirectory_Leave(object sender, EventArgs e)
{
ClearStatusbar();
}

#endregion

#region MouseLeave event handlers
Expand Down Expand Up @@ -352,6 +476,18 @@ private void ButtonExit_MouseLeave(object sender, EventArgs e)
ClearStatusbar();
}

private void ButtonOpenHipparcosDirectory_MouseLeave(object sender, EventArgs e)
{
ClearStatusbar();
}

private void ButtonOpenTychoDirectory_MouseLeave(object sender, EventArgs e)
{
ClearStatusbar();
}


#endregion

}
}
Loading

0 comments on commit 26c5985

Please sign in to comment.