Can now select a data storage.

This commit is contained in:
Fey 2026-01-25 22:57:06 +01:00
parent 7094ae45d2
commit c83d69a200
4 changed files with 558 additions and 462 deletions

View File

@ -12,6 +12,7 @@ namespace Voile.Storage.Sqlite
{ {
[VoilePlugin] [VoilePlugin]
[VoilePluginId(3)] [VoilePluginId(3)]
[DisplayName("SQLite")]
public class SqliteDataStorageFactory : IVoileDataStorageFactory public class SqliteDataStorageFactory : IVoileDataStorageFactory
{ {
public IVoileDataStorage CreateDataStorage() public IVoileDataStorage CreateDataStorage()

View File

@ -45,17 +45,21 @@
textBox1 = new TextBox(); textBox1 = new TextBox();
radioButtonHasLicense = new RadioButton(); radioButtonHasLicense = new RadioButton();
label3 = new Label(); label3 = new Label();
tabPagePickDataStorage = new TabPage();
labelDataStorageHint = new Label();
label5 = new Label();
buttonNext = new Button(); buttonNext = new Button();
buttonBack = new Button(); buttonBack = new Button();
openFileDialogCertificate = new OpenFileDialog(); openFileDialogCertificate = new OpenFileDialog();
tabPage1 = new TabPage(); tabPageConfigureDataStorage = new TabPage();
label5 = new Label(); label6 = new Label();
((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit(); ((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit();
tabControl1.SuspendLayout(); tabControl1.SuspendLayout();
tabPageWelcome.SuspendLayout(); tabPageWelcome.SuspendLayout();
tabPageLicense.SuspendLayout(); tabPageLicense.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBox2).BeginInit(); ((System.ComponentModel.ISupportInitialize)pictureBox2).BeginInit();
tabPage1.SuspendLayout(); tabPagePickDataStorage.SuspendLayout();
tabPageConfigureDataStorage.SuspendLayout();
SuspendLayout(); SuspendLayout();
// //
// pictureBox1 // pictureBox1
@ -72,7 +76,8 @@
// //
tabControl1.Controls.Add(tabPageWelcome); tabControl1.Controls.Add(tabPageWelcome);
tabControl1.Controls.Add(tabPageLicense); tabControl1.Controls.Add(tabPageLicense);
tabControl1.Controls.Add(tabPage1); tabControl1.Controls.Add(tabPagePickDataStorage);
tabControl1.Controls.Add(tabPageConfigureDataStorage);
tabControl1.Location = new Point(138, 12); tabControl1.Location = new Point(138, 12);
tabControl1.Name = "tabControl1"; tabControl1.Name = "tabControl1";
tabControl1.SelectedIndex = 0; tabControl1.SelectedIndex = 0;
@ -98,7 +103,7 @@
label2.AutoSize = true; label2.AutoSize = true;
label2.Location = new Point(6, 3); label2.Location = new Point(6, 3);
label2.Name = "label2"; label2.Name = "label2";
label2.Size = new Size(328, 240); label2.Size = new Size(329, 240);
label2.TabIndex = 3; label2.TabIndex = 3;
label2.Text = resources.GetString("label2.Text"); label2.Text = resources.GetString("label2.Text");
// //
@ -116,7 +121,7 @@
radioButtonAmExpert.AutoSize = true; radioButtonAmExpert.AutoSize = true;
radioButtonAmExpert.Location = new Point(6, 271); radioButtonAmExpert.Location = new Point(6, 271);
radioButtonAmExpert.Name = "radioButtonAmExpert"; radioButtonAmExpert.Name = "radioButtonAmExpert";
radioButtonAmExpert.Size = new Size(299, 34); radioButtonAmExpert.Size = new Size(298, 34);
radioButtonAmExpert.TabIndex = 1; radioButtonAmExpert.TabIndex = 1;
radioButtonAmExpert.Text = "Im an expert. Let me choose my own database and \r\nstorage options."; radioButtonAmExpert.Text = "Im an expert. Let me choose my own database and \r\nstorage options.";
radioButtonAmExpert.UseVisualStyleBackColor = true; radioButtonAmExpert.UseVisualStyleBackColor = true;
@ -231,6 +236,35 @@
label3.TabIndex = 0; label3.TabIndex = 0;
label3.Text = resources.GetString("label3.Text"); label3.Text = resources.GetString("label3.Text");
// //
// tabPagePickDataStorage
//
tabPagePickDataStorage.Controls.Add(labelDataStorageHint);
tabPagePickDataStorage.Controls.Add(label5);
tabPagePickDataStorage.Location = new Point(4, 24);
tabPagePickDataStorage.Name = "tabPagePickDataStorage";
tabPagePickDataStorage.Size = new Size(348, 384);
tabPagePickDataStorage.TabIndex = 2;
tabPagePickDataStorage.Text = "Pick Data Storage";
tabPagePickDataStorage.UseVisualStyleBackColor = true;
//
// labelDataStorageHint
//
labelDataStorageHint.AutoSize = true;
labelDataStorageHint.Location = new Point(3, 165);
labelDataStorageHint.Name = "labelDataStorageHint";
labelDataStorageHint.Size = new Size(124, 15);
labelDataStorageHint.TabIndex = 1;
labelDataStorageHint.Text = "DATA_STORAGE_HINT";
//
// label5
//
label5.AutoSize = true;
label5.Location = new Point(3, 0);
label5.Name = "label5";
label5.Size = new Size(347, 165);
label5.TabIndex = 0;
label5.Text = resources.GetString("label5.Text");
//
// buttonNext // buttonNext
// //
buttonNext.Enabled = false; buttonNext.Enabled = false;
@ -259,24 +293,24 @@
openFileDialogCertificate.Filter = "X.509 Certificate (*.cer)|*.cer"; openFileDialogCertificate.Filter = "X.509 Certificate (*.cer)|*.cer";
openFileDialogCertificate.Title = "Open Voile License File"; openFileDialogCertificate.Title = "Open Voile License File";
// //
// tabPage1 // tabPageConfigureDataStorage
// //
tabPage1.Controls.Add(label5); tabPageConfigureDataStorage.Controls.Add(label6);
tabPage1.Location = new Point(4, 24); tabPageConfigureDataStorage.Location = new Point(4, 24);
tabPage1.Name = "tabPage1"; tabPageConfigureDataStorage.Name = "tabPageConfigureDataStorage";
tabPage1.Size = new Size(348, 384); tabPageConfigureDataStorage.Size = new Size(348, 384);
tabPage1.TabIndex = 2; tabPageConfigureDataStorage.TabIndex = 3;
tabPage1.Text = "Pick Data Storage"; tabPageConfigureDataStorage.Text = "Configure Date Storage";
tabPage1.UseVisualStyleBackColor = true; tabPageConfigureDataStorage.UseVisualStyleBackColor = true;
// //
// label5 // label6
// //
label5.AutoSize = true; label6.AutoSize = true;
label5.Location = new Point(3, 0); label6.Location = new Point(3, 0);
label5.Name = "label5"; label6.Name = "label6";
label5.Size = new Size(347, 165); label6.Size = new Size(38, 15);
label5.TabIndex = 0; label6.TabIndex = 0;
label5.Text = resources.GetString("label5.Text"); label6.Text = "label6";
// //
// FirstRunWizard // FirstRunWizard
// //
@ -300,8 +334,10 @@
tabPageLicense.ResumeLayout(false); tabPageLicense.ResumeLayout(false);
tabPageLicense.PerformLayout(); tabPageLicense.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBox2).EndInit(); ((System.ComponentModel.ISupportInitialize)pictureBox2).EndInit();
tabPage1.ResumeLayout(false); tabPagePickDataStorage.ResumeLayout(false);
tabPage1.PerformLayout(); tabPagePickDataStorage.PerformLayout();
tabPageConfigureDataStorage.ResumeLayout(false);
tabPageConfigureDataStorage.PerformLayout();
ResumeLayout(false); ResumeLayout(false);
} }
@ -326,7 +362,10 @@
private Label label4; private Label label4;
private PictureBox pictureBox2; private PictureBox pictureBox2;
private OpenFileDialog openFileDialogCertificate; private OpenFileDialog openFileDialogCertificate;
private TabPage tabPage1; private TabPage tabPagePickDataStorage;
private Label label5; private Label label5;
private Label labelDataStorageHint;
private TabPage tabPageConfigureDataStorage;
private Label label6;
} }
} }

View File

@ -33,8 +33,10 @@ namespace Voile
private int licenseState; private int licenseState;
private X509Certificate licenseCertificate; private X509Certificate licenseCertificate;
private bool sharewareMode; private bool sharewareMode;
private VoilePluginInfo selectedDataStorage;
private bool dataStorageRadioButtonsGenerated;
public void DisplayTabPage(int target, bool isGoingBack = false) public void DisplayTabPage(int target, bool isGoingBack = false)
{ {
@ -113,8 +115,12 @@ namespace Voile
buttonNext.Enabled = (sharewareMode) | (licenseState == 6); buttonNext.Enabled = (sharewareMode) | (licenseState == 6);
break; break;
case 2: case 2:
labelDataStorageHint.Text = " ";
if (!dataStorageRadioButtonsGenerated) if (!dataStorageRadioButtonsGenerated)
GenerateDataStorageRadioButtons(); GenerateDataStorageRadioButtons();
//TODO: Hier zusätzlich Lizenzvalidierung einfügen.
buttonNext.Enabled = selectedDataStorage != null;
break; break;
default: default:
MessageBox.Show("Could not find handler for the current tab page."); MessageBox.Show("Could not find handler for the current tab page.");
@ -122,11 +128,61 @@ namespace Voile
} }
} }
private bool dataStorageRadioButtonsGenerated;
private RadioButton[] dataStorageRadioButtons;
private void GenerateDataStorageRadioButtons() private void GenerateDataStorageRadioButtons()
{ {
VoilePluginManager pluginManager = VoilePluginManager.GetInstance(); VoilePluginManager pluginManager = VoilePluginManager.GetInstance();
IReadOnlyList<VoilePluginInfo> dataStoragePlugins = pluginManager.GetDataStorages(); IReadOnlyList<VoilePluginInfo> dataStoragePlugins = pluginManager.GetDataStorages();
//TODO: Finish generating the radio buttons for the data storage. dataStorageRadioButtons = new RadioButton[dataStoragePlugins.Count];
int top = labelDataStorageHint.Top;
top += labelDataStorageHint.Height;
int left = labelDataStorageHint.Left;
for (int i = 0; i < dataStorageRadioButtons.Length; i++)
{
RadioButton childRadioButton = new RadioButton();
childRadioButton.Parent = tabPagePickDataStorage;
if (dataStoragePlugins[i].Incomplete)
childRadioButton.Enabled = false;
string radioButtonLabel = dataStoragePlugins[i].DisplayName;
if (dataStoragePlugins[i].NeededEntitlement.HasValue)
radioButtonLabel += " (needs license)";
childRadioButton.AutoSize = true;
childRadioButton.Text = radioButtonLabel;
if (selectedDataStorage != null)
childRadioButton.Checked = (selectedDataStorage.Id == dataStoragePlugins[i].Id);
childRadioButton.Top = top;
childRadioButton.Left = left;
childRadioButton.Tag = dataStoragePlugins[i];
top += childRadioButton.Height;
dataStorageRadioButtons[i] = childRadioButton;
dataStorageRadioButtons[i].CheckedChanged += OnDataStrorageSelected;
}
dataStorageRadioButtonsGenerated = true;
}
private void OnDataStrorageSelected(object? sender, EventArgs e)
{
RadioButton senderUnboxed = sender as RadioButton;
if (senderUnboxed == null)
throw new Voile.Common.VoileException("Could not unbox sender.");
VoilePluginInfo pluginInfo = senderUnboxed.Tag as VoilePluginInfo;
if (pluginInfo == null)
throw new Common.VoileException("Could not unbox plugin info");
selectedDataStorage = pluginInfo;
RefreshView();
} }
private void radioButton3_CheckedChanged(object sender, EventArgs e) private void radioButton3_CheckedChanged(object sender, EventArgs e)

View File

@ -117,19 +117,6 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="label5.Text" xml:space="preserve">
<value>Great — lets choose where Voile should store its
structured data.
Blindscan results, DVB table contents, and historical
scan information will all be kept in the storage option you select
below. Since youre using Expert Mode, you have full control
over the database backend. (In Beginner Mode, Voile would
simply use SQLite automatically.)
Feel free to pick the option that best fits your workflow or
existing infrastructure.</value>
</data>
<data name="label2.Text" xml:space="preserve"> <data name="label2.Text" xml:space="preserve">
<value>Welcome to Voile! <value>Welcome to Voile!
@ -157,6 +144,19 @@ Voile in a professional setting — or if youd simply like
to support the ongoing development — you can activate to support the ongoing development — you can activate
a license. Some advanced features also become available a license. Some advanced features also become available
once a license is installed.</value> once a license is installed.</value>
</data>
<data name="label5.Text" xml:space="preserve">
<value>Great — lets choose where Voile should store its
structured data.
Blindscan results, DVB table contents, and historical
scan information will all be kept in the storage option you select
below. Since youre using Expert Mode, you have full control
over the database backend. (In Beginner Mode, Voile would
simply use SQLite automatically.)
Feel free to pick the option that best fits your workflow or
existing infrastructure.</value>
</data> </data>
<metadata name="openFileDialogCertificate.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="openFileDialogCertificate.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value> <value>17, 17</value>