Added a page to configure the database.

This commit is contained in:
feyris-tan 2026-02-01 20:10:36 +01:00
parent 20ee473fda
commit eed28664a6
9 changed files with 849 additions and 701 deletions

1
.gitignore vendored
View File

@ -38,3 +38,4 @@
/Voile.Storage.SqlServer/bin/Debug/net8.0 /Voile.Storage.SqlServer/bin/Debug/net8.0
/Voile.Storage.Sqlite/obj /Voile.Storage.Sqlite/obj
/Voile.Storage.Sqlite/bin/Debug/net8.0 /Voile.Storage.Sqlite/bin/Debug/net8.0
/.vs/Voile/CopilotIndices/17.14.1577.30250

View File

@ -8,6 +8,6 @@ namespace Voile.Patchouli.Data
{ {
public interface IVoileDataStorage public interface IVoileDataStorage
{ {
bool Ping(); Exception Ping();
} }
} }

View File

@ -8,5 +8,6 @@ namespace Voile.Patchouli.Data
{ {
public interface IVoileObjectStorage public interface IVoileObjectStorage
{ {
Exception Ping();
} }
} }

View File

@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Voile.Patchouli.Reflection
{
[System.AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
public sealed class VoilePluginCanSaveFileAttribute : Attribute
{
public VoilePluginCanSaveFileAttribute(bool enable, string filter, CanSaveFileMode mode = CanSaveFileMode.SaveFile, bool fileMustExist = false)
{
Enable = enable;
Filter = filter;
Mode = mode;
FileMustExist = fileMustExist;
}
public bool Enable { get; }
public string Filter { get; }
public CanSaveFileMode Mode { get; }
public bool FileMustExist { get; }
}
public enum CanSaveFileMode
{
OpenFile = 0,
SaveFile = 1,
Directory = 2
}
}

View File

@ -131,5 +131,26 @@ namespace Voile.Patchouli.Reflection
return Description; return Description;
} }
} }
private VoilePluginCanSaveFileAttribute _canSaveFile;
public VoilePluginCanSaveFileAttribute CanSaveFile
{
get
{
if (_canSaveFile == null)
{
VoilePluginCanSaveFileAttribute child = Type.GetCustomAttribute<VoilePluginCanSaveFileAttribute>();
if (child != null)
{
_canSaveFile = child;
}
else
{
_canSaveFile = new VoilePluginCanSaveFileAttribute(false, null);
}
}
return _canSaveFile;
}
}
} }
} }

View File

@ -14,6 +14,7 @@ namespace Voile.Storage.Sqlite
[VoilePlugin] [VoilePlugin]
[VoilePluginId(3)] [VoilePluginId(3)]
[Voile.Patchouli.Reflection.DisplayName("SQLite")] [Voile.Patchouli.Reflection.DisplayName("SQLite")]
[VoilePluginCanSaveFile(true,"SQLite3 Database (*.db)|*.db",CanSaveFileMode.SaveFile,false)]
public class SqliteDataStorageFactory : IVoileDataStorageFactory public class SqliteDataStorageFactory : IVoileDataStorageFactory
{ {
public IVoileDataStorage CreateDataStorage() public IVoileDataStorage CreateDataStorage()

View File

@ -20,375 +20,389 @@
base.Dispose(disposing); base.Dispose(disposing);
} }
#region Windows Form Designer generated code #region Windows Form Designer generated code
/// <summary> /// <summary>
/// Required method for Designer support - do not modify /// Required method for Designer support - do not modify
/// the contents of this method with the code editor. /// the contents of this method with the code editor.
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FirstRunWizard)); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FirstRunWizard));
pictureBox1 = new PictureBox(); pictureBox1 = new PictureBox();
tabControl1 = new TabControl(); tabControl1 = new TabControl();
tabPageWelcome = new TabPage(); tabPageWelcome = new TabPage();
label2 = new Label(); label2 = new Label();
label1 = new Label(); label1 = new Label();
radioButtonAmExpert = new RadioButton(); radioButtonAmExpert = new RadioButton();
radioButtonAmBegginer = new RadioButton(); radioButtonAmBegginer = new RadioButton();
tabPageLicense = new TabPage(); tabPageLicense = new TabPage();
pictureBox2 = new PictureBox(); pictureBox2 = new PictureBox();
label4 = new Label(); label4 = new Label();
radioButtonNoLicense = new RadioButton(); radioButtonNoLicense = new RadioButton();
buttonLoadLicenseFile = new Button(); buttonLoadLicenseFile = new Button();
buttonValidateLicense = new Button(); buttonValidateLicense = new Button();
textBox1 = new TextBox(); textBox1 = new TextBox();
radioButtonHasLicense = new RadioButton(); radioButtonHasLicense = new RadioButton();
label3 = new Label(); label3 = new Label();
tabPagePickDataStorage = new TabPage(); tabPagePickDataStorage = new TabPage();
labelDataStorageHint = new Label(); labelDataStorageHint = new Label();
label5 = new Label(); label5 = new Label();
tabPageConfigureDataStorage = new TabPage(); tabPageConfigureDataStorage = new TabPage();
dbSettingsErrorLabel = new Label(); dbSettingsErrorLabel = new Label();
dbTestTrafficLight = new PictureBox(); dbTestTrafficLight = new PictureBox();
dbTestButton = new Button(); dbTestButton = new Button();
dbSettingsPropertyGrid = new PropertyGrid(); dbSettingsPropertyGrid = new PropertyGrid();
label6 = new Label(); label6 = new Label();
buttonNext = new Button(); buttonNext = new Button();
buttonBack = new Button(); buttonBack = new Button();
openFileDialogCertificate = new OpenFileDialog(); openFileDialogCertificate = new OpenFileDialog();
((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit(); loadFileButton = new Button();
tabControl1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit();
tabPageWelcome.SuspendLayout(); tabControl1.SuspendLayout();
tabPageLicense.SuspendLayout(); tabPageWelcome.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBox2).BeginInit(); tabPageLicense.SuspendLayout();
tabPagePickDataStorage.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)pictureBox2).BeginInit();
tabPageConfigureDataStorage.SuspendLayout(); tabPagePickDataStorage.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dbTestTrafficLight).BeginInit(); tabPageConfigureDataStorage.SuspendLayout();
SuspendLayout(); ((System.ComponentModel.ISupportInitialize)dbTestTrafficLight).BeginInit();
// SuspendLayout();
// pictureBox1 //
// // pictureBox1
pictureBox1.Image = Properties.Resources.technlgy; //
pictureBox1.Location = new Point(12, 12); pictureBox1.Image = Properties.Resources.technlgy;
pictureBox1.Name = "pictureBox1"; pictureBox1.Location = new Point(12, 12);
pictureBox1.Size = new Size(120, 90); pictureBox1.Name = "pictureBox1";
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom; pictureBox1.Size = new Size(120, 90);
pictureBox1.TabIndex = 0; pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
pictureBox1.TabStop = false; pictureBox1.TabIndex = 0;
// pictureBox1.TabStop = false;
// tabControl1 //
// // tabControl1
tabControl1.Controls.Add(tabPageWelcome); //
tabControl1.Controls.Add(tabPageLicense); tabControl1.Controls.Add(tabPageWelcome);
tabControl1.Controls.Add(tabPagePickDataStorage); tabControl1.Controls.Add(tabPageLicense);
tabControl1.Controls.Add(tabPageConfigureDataStorage); tabControl1.Controls.Add(tabPagePickDataStorage);
tabControl1.Location = new Point(138, 12); tabControl1.Controls.Add(tabPageConfigureDataStorage);
tabControl1.Name = "tabControl1"; tabControl1.Location = new Point(138, 12);
tabControl1.SelectedIndex = 0; tabControl1.Name = "tabControl1";
tabControl1.Size = new Size(356, 412); tabControl1.SelectedIndex = 0;
tabControl1.TabIndex = 1; tabControl1.Size = new Size(356, 412);
// tabControl1.TabIndex = 1;
// tabPageWelcome //
// // tabPageWelcome
tabPageWelcome.Controls.Add(label2); //
tabPageWelcome.Controls.Add(label1); tabPageWelcome.Controls.Add(label2);
tabPageWelcome.Controls.Add(radioButtonAmExpert); tabPageWelcome.Controls.Add(label1);
tabPageWelcome.Controls.Add(radioButtonAmBegginer); tabPageWelcome.Controls.Add(radioButtonAmExpert);
tabPageWelcome.Location = new Point(4, 24); tabPageWelcome.Controls.Add(radioButtonAmBegginer);
tabPageWelcome.Name = "tabPageWelcome"; tabPageWelcome.Location = new Point(4, 24);
tabPageWelcome.Padding = new Padding(3); tabPageWelcome.Name = "tabPageWelcome";
tabPageWelcome.Size = new Size(348, 384); tabPageWelcome.Padding = new Padding(3);
tabPageWelcome.TabIndex = 0; tabPageWelcome.Size = new Size(348, 384);
tabPageWelcome.Text = "Welcome!"; tabPageWelcome.TabIndex = 0;
tabPageWelcome.UseVisualStyleBackColor = true; tabPageWelcome.Text = "Welcome!";
// tabPageWelcome.UseVisualStyleBackColor = true;
// label2 //
// // label2
label2.AutoSize = true; //
label2.Location = new Point(6, 3); label2.AutoSize = true;
label2.Name = "label2"; label2.Location = new Point(6, 3);
label2.Size = new Size(329, 240); label2.Name = "label2";
label2.TabIndex = 3; label2.Size = new Size(328, 240);
label2.Text = resources.GetString("label2.Text"); label2.TabIndex = 3;
// label2.Text = resources.GetString("label2.Text");
// label1 //
// // label1
label1.AutoSize = true; //
label1.Location = new Point(6, 308); label1.AutoSize = true;
label1.Name = "label1"; label1.Location = new Point(6, 308);
label1.Size = new Size(202, 15); label1.Name = "label1";
label1.TabIndex = 2; label1.Size = new Size(202, 15);
label1.Text = "(You can change these options later!)"; label1.TabIndex = 2;
// label1.Text = "(You can change these options later!)";
// radioButtonAmExpert //
// // radioButtonAmExpert
radioButtonAmExpert.AutoSize = true; //
radioButtonAmExpert.Location = new Point(6, 271); radioButtonAmExpert.AutoSize = true;
radioButtonAmExpert.Name = "radioButtonAmExpert"; radioButtonAmExpert.Location = new Point(6, 271);
radioButtonAmExpert.Size = new Size(298, 34); radioButtonAmExpert.Name = "radioButtonAmExpert";
radioButtonAmExpert.TabIndex = 1; radioButtonAmExpert.Size = new Size(299, 34);
radioButtonAmExpert.Text = "Im an expert. Let me choose my own database and \r\nstorage options."; radioButtonAmExpert.TabIndex = 1;
radioButtonAmExpert.UseVisualStyleBackColor = true; radioButtonAmExpert.Text = "Im an expert. Let me choose my own database and \r\nstorage options.";
radioButtonAmExpert.CheckedChanged += radioButtonAmExpert_CheckedChanged; radioButtonAmExpert.UseVisualStyleBackColor = true;
// radioButtonAmExpert.CheckedChanged += radioButtonAmExpert_CheckedChanged;
// radioButtonAmBegginer //
// // radioButtonAmBegginer
radioButtonAmBegginer.AutoSize = true; //
radioButtonAmBegginer.Location = new Point(6, 246); radioButtonAmBegginer.AutoSize = true;
radioButtonAmBegginer.Name = "radioButtonAmBegginer"; radioButtonAmBegginer.Location = new Point(6, 246);
radioButtonAmBegginer.Size = new Size(298, 19); radioButtonAmBegginer.Name = "radioButtonAmBegginer";
radioButtonAmBegginer.TabIndex = 0; radioButtonAmBegginer.Size = new Size(298, 19);
radioButtonAmBegginer.Text = "Im a beginner. Set things up for me automatically. "; radioButtonAmBegginer.TabIndex = 0;
radioButtonAmBegginer.UseVisualStyleBackColor = true; radioButtonAmBegginer.Text = "Im a beginner. Set things up for me automatically. ";
radioButtonAmBegginer.CheckedChanged += radioButtonAmBegginer_CheckedChanged; radioButtonAmBegginer.UseVisualStyleBackColor = true;
// radioButtonAmBegginer.CheckedChanged += radioButtonAmBegginer_CheckedChanged;
// tabPageLicense //
// // tabPageLicense
tabPageLicense.Controls.Add(pictureBox2); //
tabPageLicense.Controls.Add(label4); tabPageLicense.Controls.Add(pictureBox2);
tabPageLicense.Controls.Add(radioButtonNoLicense); tabPageLicense.Controls.Add(label4);
tabPageLicense.Controls.Add(buttonLoadLicenseFile); tabPageLicense.Controls.Add(radioButtonNoLicense);
tabPageLicense.Controls.Add(buttonValidateLicense); tabPageLicense.Controls.Add(buttonLoadLicenseFile);
tabPageLicense.Controls.Add(textBox1); tabPageLicense.Controls.Add(buttonValidateLicense);
tabPageLicense.Controls.Add(radioButtonHasLicense); tabPageLicense.Controls.Add(textBox1);
tabPageLicense.Controls.Add(label3); tabPageLicense.Controls.Add(radioButtonHasLicense);
tabPageLicense.Location = new Point(4, 24); tabPageLicense.Controls.Add(label3);
tabPageLicense.Name = "tabPageLicense"; tabPageLicense.Location = new Point(4, 24);
tabPageLicense.Padding = new Padding(3); tabPageLicense.Name = "tabPageLicense";
tabPageLicense.Size = new Size(348, 384); tabPageLicense.Padding = new Padding(3);
tabPageLicense.TabIndex = 1; tabPageLicense.Size = new Size(348, 384);
tabPageLicense.Text = "License"; tabPageLicense.TabIndex = 1;
tabPageLicense.UseVisualStyleBackColor = true; tabPageLicense.Text = "License";
// tabPageLicense.UseVisualStyleBackColor = true;
// pictureBox2 //
// // pictureBox2
pictureBox2.Image = Properties.Resources.SETUPAPI_18_1_32x32x4; //
pictureBox2.Location = new Point(127, 262); pictureBox2.Image = Properties.Resources.SETUPAPI_18_1_32x32x4;
pictureBox2.Name = "pictureBox2"; pictureBox2.Location = new Point(127, 262);
pictureBox2.Size = new Size(32, 32); pictureBox2.Name = "pictureBox2";
pictureBox2.TabIndex = 7; pictureBox2.Size = new Size(32, 32);
pictureBox2.TabStop = false; pictureBox2.TabIndex = 7;
pictureBox2.Click += pictureBox2_Click; pictureBox2.TabStop = false;
// pictureBox2.Click += pictureBox2_Click;
// label4 //
// // label4
label4.AutoSize = true; //
label4.Location = new Point(22, 344); label4.AutoSize = true;
label4.Name = "label4"; label4.Location = new Point(22, 344);
label4.Size = new Size(299, 30); label4.Name = "label4";
label4.TabIndex = 6; label4.Size = new Size(299, 30);
label4.Text = "(You can also change between Licensed and Shareware \r\nmode later!)"; label4.TabIndex = 6;
// label4.Text = "(You can also change between Licensed and Shareware \r\nmode later!)";
// radioButtonNoLicense //
// // radioButtonNoLicense
radioButtonNoLicense.AutoSize = true; //
radioButtonNoLicense.Location = new Point(6, 307); radioButtonNoLicense.AutoSize = true;
radioButtonNoLicense.Name = "radioButtonNoLicense"; radioButtonNoLicense.Location = new Point(6, 307);
radioButtonNoLicense.Size = new Size(309, 34); radioButtonNoLicense.Name = "radioButtonNoLicense";
radioButtonNoLicense.TabIndex = 5; radioButtonNoLicense.Size = new Size(309, 34);
radioButtonNoLicense.Text = "No license yet — Id like to use the shareware version, \r\nor request a license later."; radioButtonNoLicense.TabIndex = 5;
radioButtonNoLicense.UseVisualStyleBackColor = true; radioButtonNoLicense.Text = "No license yet — Id like to use the shareware version, \r\nor request a license later.";
radioButtonNoLicense.CheckedChanged += radioButtonNoLicense_CheckedChanged; radioButtonNoLicense.UseVisualStyleBackColor = true;
// radioButtonNoLicense.CheckedChanged += radioButtonNoLicense_CheckedChanged;
// buttonLoadLicenseFile //
// // buttonLoadLicenseFile
buttonLoadLicenseFile.Enabled = false; //
buttonLoadLicenseFile.Location = new Point(246, 262); buttonLoadLicenseFile.Enabled = false;
buttonLoadLicenseFile.Name = "buttonLoadLicenseFile"; buttonLoadLicenseFile.Location = new Point(246, 262);
buttonLoadLicenseFile.Size = new Size(75, 39); buttonLoadLicenseFile.Name = "buttonLoadLicenseFile";
buttonLoadLicenseFile.TabIndex = 4; buttonLoadLicenseFile.Size = new Size(75, 39);
buttonLoadLicenseFile.Text = "Load License File"; buttonLoadLicenseFile.TabIndex = 4;
buttonLoadLicenseFile.UseVisualStyleBackColor = true; buttonLoadLicenseFile.Text = "Load License File";
buttonLoadLicenseFile.Click += buttonLoadLicenseFile_Click; buttonLoadLicenseFile.UseVisualStyleBackColor = true;
// buttonLoadLicenseFile.Click += buttonLoadLicenseFile_Click;
// buttonValidateLicense //
// // buttonValidateLicense
buttonValidateLicense.Enabled = false; //
buttonValidateLicense.Location = new Point(165, 262); buttonValidateLicense.Enabled = false;
buttonValidateLicense.Name = "buttonValidateLicense"; buttonValidateLicense.Location = new Point(165, 262);
buttonValidateLicense.Size = new Size(75, 39); buttonValidateLicense.Name = "buttonValidateLicense";
buttonValidateLicense.TabIndex = 3; buttonValidateLicense.Size = new Size(75, 39);
buttonValidateLicense.Text = "Validate License"; buttonValidateLicense.TabIndex = 3;
buttonValidateLicense.UseVisualStyleBackColor = true; buttonValidateLicense.Text = "Validate License";
buttonValidateLicense.Click += buttonValidateLicense_Click; buttonValidateLicense.UseVisualStyleBackColor = true;
// buttonValidateLicense.Click += buttonValidateLicense_Click;
// textBox1 //
// // textBox1
textBox1.Enabled = false; //
textBox1.Location = new Point(17, 233); textBox1.Enabled = false;
textBox1.Name = "textBox1"; textBox1.Location = new Point(17, 233);
textBox1.Size = new Size(304, 23); textBox1.Name = "textBox1";
textBox1.TabIndex = 2; textBox1.Size = new Size(304, 23);
// textBox1.TabIndex = 2;
// radioButtonHasLicense //
// // radioButtonHasLicense
radioButtonHasLicense.AutoSize = true; //
radioButtonHasLicense.Location = new Point(3, 208); radioButtonHasLicense.AutoSize = true;
radioButtonHasLicense.Name = "radioButtonHasLicense"; radioButtonHasLicense.Location = new Point(3, 208);
radioButtonHasLicense.Size = new Size(189, 19); radioButtonHasLicense.Name = "radioButtonHasLicense";
radioButtonHasLicense.TabIndex = 1; radioButtonHasLicense.Size = new Size(189, 19);
radioButtonHasLicense.Text = "Yes, I have a license file to load."; radioButtonHasLicense.TabIndex = 1;
radioButtonHasLicense.UseVisualStyleBackColor = true; radioButtonHasLicense.Text = "Yes, I have a license file to load.";
radioButtonHasLicense.CheckedChanged += radioButton3_CheckedChanged; radioButtonHasLicense.UseVisualStyleBackColor = true;
// radioButtonHasLicense.CheckedChanged += radioButton3_CheckedChanged;
// label3 //
// // label3
label3.AutoSize = true; //
label3.Location = new Point(6, 3); label3.AutoSize = true;
label3.Name = "label3"; label3.Location = new Point(6, 3);
label3.Size = new Size(337, 120); label3.Name = "label3";
label3.TabIndex = 0; label3.Size = new Size(337, 120);
label3.Text = resources.GetString("label3.Text"); label3.TabIndex = 0;
// label3.Text = resources.GetString("label3.Text");
// tabPagePickDataStorage //
// // tabPagePickDataStorage
tabPagePickDataStorage.Controls.Add(labelDataStorageHint); //
tabPagePickDataStorage.Controls.Add(label5); tabPagePickDataStorage.Controls.Add(labelDataStorageHint);
tabPagePickDataStorage.Location = new Point(4, 24); tabPagePickDataStorage.Controls.Add(label5);
tabPagePickDataStorage.Name = "tabPagePickDataStorage"; tabPagePickDataStorage.Location = new Point(4, 24);
tabPagePickDataStorage.Size = new Size(348, 384); tabPagePickDataStorage.Name = "tabPagePickDataStorage";
tabPagePickDataStorage.TabIndex = 2; tabPagePickDataStorage.Size = new Size(348, 384);
tabPagePickDataStorage.Text = "Pick Data Storage"; tabPagePickDataStorage.TabIndex = 2;
tabPagePickDataStorage.UseVisualStyleBackColor = true; tabPagePickDataStorage.Text = "Pick Data Storage";
// tabPagePickDataStorage.UseVisualStyleBackColor = true;
// labelDataStorageHint //
// // labelDataStorageHint
labelDataStorageHint.AutoSize = true; //
labelDataStorageHint.Location = new Point(3, 165); labelDataStorageHint.AutoSize = true;
labelDataStorageHint.Name = "labelDataStorageHint"; labelDataStorageHint.Location = new Point(3, 165);
labelDataStorageHint.Size = new Size(124, 15); labelDataStorageHint.Name = "labelDataStorageHint";
labelDataStorageHint.TabIndex = 1; labelDataStorageHint.Size = new Size(121, 15);
labelDataStorageHint.Text = "DATA_STORAGE_HINT"; labelDataStorageHint.TabIndex = 1;
// labelDataStorageHint.Text = "DATA_STORAGE_HINT";
// label5 //
// // label5
label5.AutoSize = true; //
label5.Location = new Point(3, 0); label5.AutoSize = true;
label5.Name = "label5"; label5.Location = new Point(3, 0);
label5.Size = new Size(347, 165); label5.Name = "label5";
label5.TabIndex = 0; label5.Size = new Size(347, 165);
label5.Text = resources.GetString("label5.Text"); label5.TabIndex = 0;
// label5.Text = resources.GetString("label5.Text");
// tabPageConfigureDataStorage //
// // tabPageConfigureDataStorage
tabPageConfigureDataStorage.Controls.Add(dbSettingsErrorLabel); //
tabPageConfigureDataStorage.Controls.Add(dbTestTrafficLight); tabPageConfigureDataStorage.Controls.Add(dbSettingsErrorLabel);
tabPageConfigureDataStorage.Controls.Add(dbTestButton); tabPageConfigureDataStorage.Controls.Add(dbTestTrafficLight);
tabPageConfigureDataStorage.Controls.Add(dbSettingsPropertyGrid); tabPageConfigureDataStorage.Controls.Add(dbTestButton);
tabPageConfigureDataStorage.Controls.Add(label6); tabPageConfigureDataStorage.Controls.Add(dbSettingsPropertyGrid);
tabPageConfigureDataStorage.Location = new Point(4, 24); tabPageConfigureDataStorage.Controls.Add(label6);
tabPageConfigureDataStorage.Name = "tabPageConfigureDataStorage"; tabPageConfigureDataStorage.Location = new Point(4, 24);
tabPageConfigureDataStorage.Size = new Size(348, 384); tabPageConfigureDataStorage.Name = "tabPageConfigureDataStorage";
tabPageConfigureDataStorage.TabIndex = 3; tabPageConfigureDataStorage.Size = new Size(348, 384);
tabPageConfigureDataStorage.Text = "Configure Date Storage"; tabPageConfigureDataStorage.TabIndex = 3;
tabPageConfigureDataStorage.UseVisualStyleBackColor = true; tabPageConfigureDataStorage.Text = "Configure Date Storage";
// tabPageConfigureDataStorage.UseVisualStyleBackColor = true;
// dbSettingsErrorLabel //
// // dbSettingsErrorLabel
dbSettingsErrorLabel.AutoSize = true; //
dbSettingsErrorLabel.Location = new Point(3, 70); dbSettingsErrorLabel.AutoSize = true;
dbSettingsErrorLabel.Name = "dbSettingsErrorLabel"; dbSettingsErrorLabel.Location = new Point(3, 87);
dbSettingsErrorLabel.Size = new Size(77, 15); dbSettingsErrorLabel.Name = "dbSettingsErrorLabel";
dbSettingsErrorLabel.TabIndex = 9; dbSettingsErrorLabel.Size = new Size(74, 15);
dbSettingsErrorLabel.Text = "TEST_RESULT"; dbSettingsErrorLabel.TabIndex = 9;
// dbSettingsErrorLabel.Text = "TEST_RESULT";
// dbTestTrafficLight //
// // dbTestTrafficLight
dbTestTrafficLight.Image = Properties.Resources.SETUPAPI_18_1_32x32x4; //
dbTestTrafficLight.Location = new Point(214, 70); dbTestTrafficLight.Image = Properties.Resources.SETUPAPI_18_1_32x32x4;
dbTestTrafficLight.Name = "dbTestTrafficLight"; dbTestTrafficLight.Location = new Point(313, 34);
dbTestTrafficLight.Size = new Size(32, 32); dbTestTrafficLight.Name = "dbTestTrafficLight";
dbTestTrafficLight.TabIndex = 8; dbTestTrafficLight.Size = new Size(32, 32);
dbTestTrafficLight.TabStop = false; dbTestTrafficLight.TabIndex = 8;
// dbTestTrafficLight.TabStop = false;
// dbTestButton dbTestTrafficLight.Click += dbTestTrafficLight_Click;
// //
dbTestButton.Location = new Point(252, 70); // dbTestButton
dbTestButton.Name = "dbTestButton"; //
dbTestButton.Size = new Size(93, 32); dbTestButton.Location = new Point(252, 70);
dbTestButton.TabIndex = 2; dbTestButton.Name = "dbTestButton";
dbTestButton.Text = "Test Settings"; dbTestButton.Size = new Size(93, 32);
dbTestButton.UseVisualStyleBackColor = true; dbTestButton.TabIndex = 2;
dbTestButton.Click += dbTestButton_Click; dbTestButton.Text = "Test Settings";
// dbTestButton.UseVisualStyleBackColor = true;
// dbSettingsPropertyGrid dbTestButton.Click += dbTestButton_Click;
// //
dbSettingsPropertyGrid.Location = new Point(3, 108); // dbSettingsPropertyGrid
dbSettingsPropertyGrid.Name = "dbSettingsPropertyGrid"; //
dbSettingsPropertyGrid.Size = new Size(342, 273); dbSettingsPropertyGrid.Location = new Point(3, 108);
dbSettingsPropertyGrid.TabIndex = 1; dbSettingsPropertyGrid.Name = "dbSettingsPropertyGrid";
// dbSettingsPropertyGrid.Size = new Size(342, 273);
// label6 dbSettingsPropertyGrid.TabIndex = 1;
// //
label6.AutoSize = true; // label6
label6.Location = new Point(3, 0); //
label6.Name = "label6"; label6.AutoSize = true;
label6.Size = new Size(38, 15); label6.Location = new Point(3, 0);
label6.TabIndex = 0; label6.Name = "label6";
label6.Text = "label6"; label6.Size = new Size(394, 75);
// label6.TabIndex = 0;
// buttonNext label6.Text = "Here are the configuration options for the database engine you selected. \r\n\r\nAdjust the settings as needed, and when you're ready, \r\nclick \"Test Settings\" to verify the connection before \r\nmoving on.";
// //
buttonNext.Enabled = false; // buttonNext
buttonNext.Location = new Point(419, 430); //
buttonNext.Name = "buttonNext"; buttonNext.Enabled = false;
buttonNext.Size = new Size(75, 23); buttonNext.Location = new Point(419, 430);
buttonNext.TabIndex = 2; buttonNext.Name = "buttonNext";
buttonNext.Text = "Next >"; buttonNext.Size = new Size(75, 23);
buttonNext.UseVisualStyleBackColor = true; buttonNext.TabIndex = 2;
buttonNext.Click += buttonNext_Click; buttonNext.Text = "Next >";
// buttonNext.UseVisualStyleBackColor = true;
// buttonBack buttonNext.Click += buttonNext_Click;
// //
buttonBack.Enabled = false; // buttonBack
buttonBack.Location = new Point(338, 430); //
buttonBack.Name = "buttonBack"; buttonBack.Enabled = false;
buttonBack.Size = new Size(75, 23); buttonBack.Location = new Point(338, 430);
buttonBack.TabIndex = 3; buttonBack.Name = "buttonBack";
buttonBack.Text = "< Back"; buttonBack.Size = new Size(75, 23);
buttonBack.UseVisualStyleBackColor = true; buttonBack.TabIndex = 3;
// buttonBack.Text = "< Back";
// openFileDialogCertificate buttonBack.UseVisualStyleBackColor = true;
// buttonBack.Click += buttonBack_Click;
openFileDialogCertificate.DefaultExt = "cer"; //
openFileDialogCertificate.FileName = "openFileDialog1"; // openFileDialogCertificate
openFileDialogCertificate.Filter = "X.509 Certificate (*.cer)|*.cer"; //
openFileDialogCertificate.Title = "Open Voile License File"; openFileDialogCertificate.DefaultExt = "cer";
// openFileDialogCertificate.FileName = "openFileDialog1";
// FirstRunWizard openFileDialogCertificate.Filter = "X.509 Certificate (*.cer)|*.cer";
// openFileDialogCertificate.Title = "Open Voile License File";
AutoScaleDimensions = new SizeF(7F, 15F); //
AutoScaleMode = AutoScaleMode.Font; // loadFileButton
ClientSize = new Size(502, 465); //
Controls.Add(buttonBack); loadFileButton.Location = new Point(257, 430);
Controls.Add(buttonNext); loadFileButton.Name = "loadFileButton";
Controls.Add(tabControl1); loadFileButton.Size = new Size(75, 23);
Controls.Add(pictureBox1); loadFileButton.TabIndex = 4;
FormBorderStyle = FormBorderStyle.FixedSingle; loadFileButton.Text = "Load File";
MaximizeBox = false; loadFileButton.UseVisualStyleBackColor = true;
MinimizeBox = false; loadFileButton.Click += loadFileButton_Click;
Name = "FirstRunWizard"; //
ShowIcon = false; // FirstRunWizard
Text = "Voile - First Run Wizard"; //
((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit(); AutoScaleDimensions = new SizeF(7F, 15F);
tabControl1.ResumeLayout(false); AutoScaleMode = AutoScaleMode.Font;
tabPageWelcome.ResumeLayout(false); ClientSize = new Size(502, 465);
tabPageWelcome.PerformLayout(); Controls.Add(loadFileButton);
tabPageLicense.ResumeLayout(false); Controls.Add(buttonBack);
tabPageLicense.PerformLayout(); Controls.Add(buttonNext);
((System.ComponentModel.ISupportInitialize)pictureBox2).EndInit(); Controls.Add(tabControl1);
tabPagePickDataStorage.ResumeLayout(false); Controls.Add(pictureBox1);
tabPagePickDataStorage.PerformLayout(); FormBorderStyle = FormBorderStyle.FixedSingle;
tabPageConfigureDataStorage.ResumeLayout(false); MaximizeBox = false;
tabPageConfigureDataStorage.PerformLayout(); MinimizeBox = false;
((System.ComponentModel.ISupportInitialize)dbTestTrafficLight).EndInit(); Name = "FirstRunWizard";
ResumeLayout(false); ShowIcon = false;
} Text = "Voile - First Run Wizard";
((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit();
tabControl1.ResumeLayout(false);
tabPageWelcome.ResumeLayout(false);
tabPageWelcome.PerformLayout();
tabPageLicense.ResumeLayout(false);
tabPageLicense.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBox2).EndInit();
tabPagePickDataStorage.ResumeLayout(false);
tabPagePickDataStorage.PerformLayout();
tabPageConfigureDataStorage.ResumeLayout(false);
tabPageConfigureDataStorage.PerformLayout();
((System.ComponentModel.ISupportInitialize)dbTestTrafficLight).EndInit();
ResumeLayout(false);
}
#endregion #endregion
private PictureBox pictureBox1; private PictureBox pictureBox1;
private TabControl tabControl1; private TabControl tabControl1;
private TabPage tabPageWelcome; private TabPage tabPageWelcome;
private TabPage tabPageLicense; private TabPage tabPageLicense;
@ -416,5 +430,6 @@
private Button dbTestButton; private Button dbTestButton;
private PictureBox dbTestTrafficLight; private PictureBox dbTestTrafficLight;
private Label dbSettingsErrorLabel; private Label dbSettingsErrorLabel;
} private Button loadFileButton;
}
} }

View File

@ -1,381 +1,452 @@
using Org.BouncyCastle.Utilities; using Org.BouncyCastle.Utilities;
using Org.BouncyCastle.X509; using Org.BouncyCastle.X509;
using Sophia.Net.DRM; using Sophia.Net.DRM;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Data; using System.Data;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using Voile.Patchouli.Data; using Voile.Patchouli.Data;
using Voile.Patchouli.Reflection; using Voile.Patchouli.Reflection;
using Voile.Properties; using Voile.Properties;
namespace Voile namespace Voile
{ {
public partial class FirstRunWizard : Form public partial class FirstRunWizard : Form
{ {
public FirstRunWizard() public FirstRunWizard()
{ {
InitializeComponent(); InitializeComponent();
DisplayTabPage(0); DisplayTabPage(0);
} }
private TabPage[] allPages; private TabPage[] allPages;
private int currentTabPage; private int currentTabPage;
private Stack<int> pastPages; private Stack<int> pastPages;
private bool beginnerMode; private bool beginnerMode;
private FileInfo licenceCertificateFileInfo; private FileInfo licenceCertificateFileInfo;
private byte[] licenseBuffer; private byte[] licenseBuffer;
private int licenseState; private int licenseState;
private X509Certificate licenseCertificate; private X509Certificate licenseCertificate;
private bool sharewareMode; private bool sharewareMode;
private VoilePluginInfo selectedDataStorage; private VoilePluginInfo selectedDataStorage;
private IVoileDataStorageFactory voileDataStorageFactory; private IVoileDataStorageFactory voileDataStorageFactory;
private bool dataStorageConnectionSucessful; private bool dataStorageConnectionSucessful;
public void DisplayTabPage(int target, bool isGoingBack = false) public void DisplayTabPage(int target)
{ {
if (pastPages == null) if (pastPages == null)
pastPages = new Stack<int>(); pastPages = new Stack<int>();
else else
pastPages.Push(target); pastPages.Push(currentTabPage);
if (allPages == null) if (allPages == null)
{ {
allPages = new TabPage[tabControl1.TabPages.Count]; allPages = new TabPage[tabControl1.TabPages.Count];
for (int i = 0; i < tabControl1.TabPages.Count; i++) for (int i = 0; i < tabControl1.TabPages.Count; i++)
{ {
allPages[i] = tabControl1.TabPages[i]; allPages[i] = tabControl1.TabPages[i];
} }
} }
tabControl1.TabPages.Clear(); tabControl1.TabPages.Clear();
tabControl1.TabPages.Add(allPages[target]); tabControl1.TabPages.Add(allPages[target]);
currentTabPage = target; currentTabPage = target;
RefreshView(); RefreshView();
} }
void RefreshView() void RefreshView()
{ {
buttonBack.Enabled = false; loadFileButton.Visible = false;
buttonNext.Enabled = false; buttonBack.Enabled = false;
buttonNext.Enabled = false;
if (pastPages != null) if (pastPages != null)
{ {
if (pastPages.Count > 0) if (pastPages.Count > 0)
{ {
buttonBack.Enabled = true; buttonBack.Enabled = true;
} }
} }
switch (currentTabPage) switch (currentTabPage)
{ {
case 0: case 0:
beginnerMode = radioButtonAmBegginer.Checked; beginnerMode = radioButtonAmBegginer.Checked;
buttonNext.Enabled = radioButtonAmBegginer.Checked || radioButtonAmExpert.Checked; buttonNext.Enabled = radioButtonAmBegginer.Checked || radioButtonAmExpert.Checked;
break; break;
case 1: case 1:
//Lizenzstatus validieren. //Lizenzstatus validieren.
buttonValidateLicense.Enabled = ((licenceCertificateFileInfo != null) & radioButtonHasLicense.Checked); buttonValidateLicense.Enabled = ((licenceCertificateFileInfo != null) & radioButtonHasLicense.Checked);
buttonLoadLicenseFile.Enabled = radioButtonHasLicense.Checked; buttonLoadLicenseFile.Enabled = radioButtonHasLicense.Checked;
pictureBox2.Visible = radioButtonHasLicense.Checked; pictureBox2.Visible = radioButtonHasLicense.Checked;
if (pictureBox2.Visible) if (pictureBox2.Visible)
{ {
switch (licenseState) switch (licenseState)
{ {
case 0: //Noch nichts geladen. case 0: //Noch nichts geladen.
pictureBox2.Image = Resources.SETUPAPI_18_1_32x32x4; //Fragezeichen pictureBox2.Image = Resources.SETUPAPI_18_1_32x32x4; //Fragezeichen
break; break;
case 1: //Root cert konnte nicht geladen werden. case 1: //Root cert konnte nicht geladen werden.
case 2: //Lizenz file konnte nicht geladen werden. case 2: //Lizenz file konnte nicht geladen werden.
case 3: //Lizenzzertifikat wurde nicht von sophia.net ausgestellt. case 3: //Lizenzzertifikat wurde nicht von sophia.net ausgestellt.
case 4: //Lizennzertifikat enthält keine sophia.net extensions case 4: //Lizennzertifikat enthält keine sophia.net extensions
case 5: //sophia.net extension ist leer case 5: //sophia.net extension ist leer
case 7: //sophia.net extension hat ungültige länge case 7: //sophia.net extension hat ungültige länge
pictureBox2.Image = Resources.TRFFC10C_1_32x32x4; //rote Ampel pictureBox2.Image = Resources.TRFFC10C_1_32x32x4; //rote Ampel
break; break;
case 6: //gültige lizenz case 6: //gültige lizenz
pictureBox2.Image = Resources.TRFFC10A_1_32x32x4; //grüne Ampel pictureBox2.Image = Resources.TRFFC10A_1_32x32x4; //grüne Ampel
break; break;
case 8: case 8:
default: default:
pictureBox2.Image = Resources.iblicense_133_1_32x32x4; //Ausrufezeichen pictureBox2.Image = Resources.iblicense_133_1_32x32x4; //Ausrufezeichen
licenseState = 8; licenseState = 8;
break; break;
} }
} }
//Können wir weiter machen? //Können wir weiter machen?
sharewareMode = radioButtonNoLicense.Checked; sharewareMode = radioButtonNoLicense.Checked;
buttonNext.Enabled = (sharewareMode) | (licenseState == 6); buttonNext.Enabled = (sharewareMode) | (licenseState == 6);
break; break;
case 2: case 2:
labelDataStorageHint.Text = " "; labelDataStorageHint.Text = " ";
if (!dataStorageRadioButtonsGenerated) if (!dataStorageRadioButtonsGenerated)
GenerateDataStorageRadioButtons(); GenerateDataStorageRadioButtons();
//TODO: Hier zusätzlich Lizenzvalidierung einfügen. //TODO: Hier zusätzlich Lizenzvalidierung einfügen.
buttonNext.Enabled = selectedDataStorage != null; buttonNext.Enabled = selectedDataStorage != null;
break; break;
case 3: case 3:
dbSettingsErrorLabel.Text = ""; loadFileButton.Visible = selectedDataStorage.CanSaveFile.Enable;
if (voileDataStorageFactory == null) dbSettingsErrorLabel.Text = "";
{ if (voileDataStorageFactory == null)
dbSettingsPropertyGrid.SelectedObject = selectedDataStorage.GetPluginInstance(); {
} dbSettingsPropertyGrid.SelectedObject = selectedDataStorage.GetPluginInstance();
break; }
default: break;
MessageBox.Show("Could not find handler for the current tab page."); default:
return; MessageBox.Show("Could not find handler for the current tab page.");
} return;
} }
}
private bool dataStorageRadioButtonsGenerated; private bool dataStorageRadioButtonsGenerated;
private RadioButton[] dataStorageRadioButtons; 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();
dataStorageRadioButtons = new RadioButton[dataStoragePlugins.Count]; dataStorageRadioButtons = new RadioButton[dataStoragePlugins.Count];
int top = labelDataStorageHint.Top; int top = labelDataStorageHint.Top;
top += labelDataStorageHint.Height; top += labelDataStorageHint.Height;
int left = labelDataStorageHint.Left; int left = labelDataStorageHint.Left;
for (int i = 0; i < dataStorageRadioButtons.Length; i++) for (int i = 0; i < dataStorageRadioButtons.Length; i++)
{ {
RadioButton childRadioButton = new RadioButton(); RadioButton childRadioButton = new RadioButton();
childRadioButton.Parent = tabPagePickDataStorage; childRadioButton.Parent = tabPagePickDataStorage;
if (dataStoragePlugins[i].Incomplete) if (dataStoragePlugins[i].Incomplete)
childRadioButton.Enabled = false; childRadioButton.Enabled = false;
string radioButtonLabel = dataStoragePlugins[i].DisplayName; string radioButtonLabel = dataStoragePlugins[i].DisplayName;
if (dataStoragePlugins[i].NeededEntitlement.HasValue) if (dataStoragePlugins[i].NeededEntitlement.HasValue)
radioButtonLabel += " (needs license)"; radioButtonLabel += " (needs license)";
childRadioButton.AutoSize = true; childRadioButton.AutoSize = true;
childRadioButton.Text = radioButtonLabel; childRadioButton.Text = radioButtonLabel;
if (selectedDataStorage != null) if (selectedDataStorage != null)
childRadioButton.Checked = (selectedDataStorage.Id == dataStoragePlugins[i].Id); childRadioButton.Checked = (selectedDataStorage.Id == dataStoragePlugins[i].Id);
childRadioButton.Top = top; childRadioButton.Top = top;
childRadioButton.Left = left; childRadioButton.Left = left;
childRadioButton.Tag = dataStoragePlugins[i]; childRadioButton.Tag = dataStoragePlugins[i];
top += childRadioButton.Height; top += childRadioButton.Height;
dataStorageRadioButtons[i] = childRadioButton; dataStorageRadioButtons[i] = childRadioButton;
dataStorageRadioButtons[i].CheckedChanged += OnDataStrorageSelected; dataStorageRadioButtons[i].CheckedChanged += OnDataStrorageSelected;
} }
dataStorageRadioButtonsGenerated = true; dataStorageRadioButtonsGenerated = true;
} }
private void OnDataStrorageSelected(object? sender, EventArgs e) private void OnDataStrorageSelected(object? sender, EventArgs e)
{ {
RadioButton senderUnboxed = sender as RadioButton; RadioButton senderUnboxed = sender as RadioButton;
if (senderUnboxed == null) if (senderUnboxed == null)
throw new Voile.Common.VoileException("Could not unbox sender."); throw new Voile.Common.VoileException("Could not unbox sender.");
VoilePluginInfo pluginInfo = senderUnboxed.Tag as VoilePluginInfo; VoilePluginInfo pluginInfo = senderUnboxed.Tag as VoilePluginInfo;
if (pluginInfo == null) if (pluginInfo == null)
throw new Common.VoileException("Could not unbox plugin info"); throw new Common.VoileException("Could not unbox plugin info");
selectedDataStorage = pluginInfo; selectedDataStorage = pluginInfo;
RefreshView(); RefreshView();
} }
private void radioButton3_CheckedChanged(object sender, EventArgs e) private void radioButton3_CheckedChanged(object sender, EventArgs e)
{ {
RefreshView(); RefreshView();
} }
private void radioButtonAmBegginer_CheckedChanged(object sender, EventArgs e) private void radioButtonAmBegginer_CheckedChanged(object sender, EventArgs e)
{ {
RefreshView(); RefreshView();
} }
private void radioButtonAmExpert_CheckedChanged(object sender, EventArgs e) private void radioButtonAmExpert_CheckedChanged(object sender, EventArgs e)
{ {
RefreshView(); RefreshView();
} }
private void radioButtonNoLicense_CheckedChanged(object sender, EventArgs e) private void radioButtonNoLicense_CheckedChanged(object sender, EventArgs e)
{ {
RefreshView(); RefreshView();
} }
private void pictureBox2_Click(object sender, EventArgs e) private void pictureBox2_Click(object sender, EventArgs e)
{ {
} }
private void buttonNext_Click(object sender, EventArgs e) private void buttonNext_Click(object sender, EventArgs e)
{ {
if (currentTabPage == 0) if (currentTabPage == 0)
{ {
//Wir sind auf der Willkommensseite, hier wird ausgewählt ob Anfänger oder Experte. //Wir sind auf der Willkommensseite, hier wird ausgewählt ob Anfänger oder Experte.
//Es wird nach der Lizenz gefragt //Es wird nach der Lizenz gefragt
DisplayTabPage(1); DisplayTabPage(1);
} }
else if (currentTabPage == 1) else if (currentTabPage == 1)
{ {
//Hier soll der Nutzer auswählen ob einfach oder schwierig. //Hier soll der Nutzer auswählen ob einfach oder schwierig.
if (beginnerMode) if (beginnerMode)
{ {
//TODO: Automatisch SQLite und Directory Storage auswählen //TODO: Automatisch SQLite und Directory Storage auswählen
} }
else else
{ {
DisplayTabPage(2); DisplayTabPage(2);
} }
} }
else if (currentTabPage == 2) else if (currentTabPage == 2)
{ {
//Hier soll der Nutzer auswählen, welche DB verwendet werden soll. //Hier soll der Nutzer auswählen, welche DB verwendet werden soll.
DisplayTabPage(3); DisplayTabPage(3);
} }
} }
private void buttonLoadLicenseFile_Click(object sender, EventArgs e) private void buttonLoadLicenseFile_Click(object sender, EventArgs e)
{ {
if (openFileDialogCertificate.ShowDialog() == DialogResult.OK) if (openFileDialogCertificate.ShowDialog() == DialogResult.OK)
{ {
licenceCertificateFileInfo = new FileInfo(openFileDialogCertificate.FileName); licenceCertificateFileInfo = new FileInfo(openFileDialogCertificate.FileName);
licenseBuffer = File.ReadAllBytes(licenceCertificateFileInfo.FullName); licenseBuffer = File.ReadAllBytes(licenceCertificateFileInfo.FullName);
textBox1.Text = licenceCertificateFileInfo.FullName; textBox1.Text = licenceCertificateFileInfo.FullName;
licenseState = 0; licenseState = 0;
pictureBox2.Image = Resources.SETUPAPI_18_1_32x32x4; pictureBox2.Image = Resources.SETUPAPI_18_1_32x32x4;
} }
RefreshView(); RefreshView();
} }
private void buttonValidateLicense_Click(object sender, EventArgs e) private void buttonValidateLicense_Click(object sender, EventArgs e)
{ {
VoileContext voileContext = VoileContext.GetContext(); VoileContext voileContext = VoileContext.GetContext();
if (voileContext.SophiaNetRootCertificate == null) if (voileContext.SophiaNetRootCertificate == null)
{ {
try try
{ {
byte[] sophianetCertBuffer = Resources.sophianet_cert; byte[] sophianetCertBuffer = Resources.sophianet_cert;
voileContext.SophiaNetRootCertificate = SophiaNetDrmApi.ImportCertificate(sophianetCertBuffer); voileContext.SophiaNetRootCertificate = SophiaNetDrmApi.ImportCertificate(sophianetCertBuffer);
} }
catch (Exception ex) catch (Exception ex)
{ {
licenseState = 1; licenseState = 1;
RefreshView(); RefreshView();
return; return;
} }
} }
try try
{ {
licenseCertificate = SophiaNetDrmApi.ImportCertificate(licenseBuffer); licenseCertificate = SophiaNetDrmApi.ImportCertificate(licenseBuffer);
} }
catch (Exception f) catch (Exception f)
{ {
licenseState = 2; licenseState = 2;
RefreshView(); RefreshView();
return; return;
} }
bool certificateChainValid = SophiaNetDrmApi.ValidateCertificateChain(licenseCertificate, voileContext.SophiaNetRootCertificate); bool certificateChainValid = SophiaNetDrmApi.ValidateCertificateChain(licenseCertificate, voileContext.SophiaNetRootCertificate);
if (!certificateChainValid) if (!certificateChainValid)
{ {
licenseState = 3; licenseState = 3;
RefreshView(); RefreshView();
return; return;
} }
byte[] sophiaNetExtensionBuffer; byte[] sophiaNetExtensionBuffer;
try try
{ {
sophiaNetExtensionBuffer = SophiaNetDrmApi.GetSophiaNetExtensionFromCertificate(licenseCertificate); sophiaNetExtensionBuffer = SophiaNetDrmApi.GetSophiaNetExtensionFromCertificate(licenseCertificate);
} }
catch (Exception g) catch (Exception g)
{ {
licenseState = 4; licenseState = 4;
RefreshView(); RefreshView();
return; return;
} }
if (sophiaNetExtensionBuffer.Length == 0) if (sophiaNetExtensionBuffer.Length == 0)
{ {
licenseState = 5; licenseState = 5;
RefreshView(); RefreshView();
return; return;
} }
if (sophiaNetExtensionBuffer.Length % 16 != 0) if (sophiaNetExtensionBuffer.Length % 16 != 0)
{ {
licenseState = 7; licenseState = 7;
RefreshView(); RefreshView();
return; return;
} }
licenseState = 6; licenseState = 6;
RefreshView(); RefreshView();
return; return;
} }
private void dbTestButton_Click(object sender, EventArgs e) private void dbTestButton_Click(object sender, EventArgs e)
{ {
dataStorageConnectionSucessful = false; dataStorageConnectionSucessful = false;
if (voileDataStorageFactory == null) if (voileDataStorageFactory == null)
{ {
IVoileDataStorageFactory newDs = selectedDataStorage.GetPluginInstance() as IVoileDataStorageFactory; IVoileDataStorageFactory newDs = selectedDataStorage.GetPluginInstance() as IVoileDataStorageFactory;
if (newDs == null) if (newDs == null)
{ {
dbSettingsErrorLabel.Text = "The selected plugin is not a Data Storage plugin. This is a bug in voile, please report it."; dbSettingsErrorLabel.Text = "The selected plugin is not a Data Storage plugin. This is a bug in voile, please report it.";
dbTestTrafficLight.Image = Resources.TRFFC10C_1_32x32x4; dbTestTrafficLight.Image = Resources.TRFFC10C_1_32x32x4;
return; return;
} }
voileDataStorageFactory = newDs; voileDataStorageFactory = newDs;
} }
IVoileDataStorage dataStorage = null; IVoileDataStorage dataStorage = null;
try try
{ {
dataStorage = voileDataStorageFactory.CreateDataStorage(); dataStorage = voileDataStorageFactory.CreateDataStorage();
} }
catch (Exception ex) catch (Exception ex)
{ {
dbSettingsErrorLabel.Text = ex.Message; dbSettingsErrorLabel.Text = ex.Message;
dbTestTrafficLight.Image = Resources.TRFFC10C_1_32x32x4; dbTestTrafficLight.Image = Resources.TRFFC10C_1_32x32x4;
return; return;
} }
try try
{ {
Exception pingResult = dataStorage.Ping(); Exception pingResult = dataStorage.Ping();
if (pingResult != null) if (pingResult != null)
{ {
dbSettingsErrorLabel.Text = pingResult.Message; dbSettingsErrorLabel.Text = pingResult.Message;
dbTestTrafficLight.Image = Resources.TRFFC10C_1_32x32x4; dbTestTrafficLight.Image = Resources.TRFFC10C_1_32x32x4;
return; return;
} }
} }
catch (Exception ex2) catch (Exception ex2)
{ {
dbSettingsErrorLabel.Text = ex2.Message; dbSettingsErrorLabel.Text = ex2.Message;
dbTestTrafficLight.Image = Resources.TRFFC10C_1_32x32x4; dbTestTrafficLight.Image = Resources.TRFFC10C_1_32x32x4;
return; return;
} }
dbSettingsErrorLabel.Text = "Database connection sucessful!"; dbSettingsErrorLabel.Text = "Database connection sucessful!";
pictureBox2.Image = Resources.TRFFC10A_1_32x32x4; //grüne Ampel pictureBox2.Image = Resources.TRFFC10A_1_32x32x4; //grüne Ampel
dataStorageConnectionSucessful = true; dataStorageConnectionSucessful = true;
} }
}
} private void buttonBack_Click(object sender, EventArgs e)
{
int previousTabPageId = pastPages.Pop();
tabControl1.TabPages.Clear();
tabControl1.TabPages.Add(allPages[previousTabPageId]);
currentTabPage = previousTabPageId;
RefreshView();
}
private void loadFileButton_Click(object sender, EventArgs e)
{
switch (currentTabPage)
{
case 3:
VoilePluginCanSaveFileAttribute canSaveFile = selectedDataStorage.CanSaveFile;
switch (canSaveFile.Mode)
{
case CanSaveFileMode.SaveFile:
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = canSaveFile.Filter;
sfd.OverwritePrompt = canSaveFile.FileMustExist;
DialogResult dialogResult = sfd.ShowDialog(this);
if (dialogResult == DialogResult.OK)
{
if (voileDataStorageFactory == null)
{
voileDataStorageFactory = selectedDataStorage.GetPluginInstance() as IVoileDataStorageFactory;
}
SetFileNameProperty(voileDataStorageFactory, sfd.FileName);
dbSettingsPropertyGrid.Refresh();
}
break;
default:
MessageBox.Show(this, String.Format("Don't know what to do with a {1} dialog on page {0}.", currentTabPage, canSaveFile.Mode), allPages[currentTabPage].Text, MessageBoxButtons.OK, MessageBoxIcon.Hand);
break;
}
break;
default:
MessageBox.Show(this, String.Format("Don't know what to do on page {0}", currentTabPage), allPages[currentTabPage].Text, MessageBoxButtons.OK, MessageBoxIcon.Hand);
return;
}
}
private void SetFileNameProperty(object voilePlugin, string targetFileName)
{
Type type = voilePlugin.GetType();
System.Reflection.PropertyInfo[] propertyInfos = type.GetProperties();
foreach (System.Reflection.PropertyInfo propertyInfo in propertyInfos)
{
if (!propertyInfo.CanWrite)
continue;
string name = propertyInfo.Name.ToLower();
switch (name)
{
case "filepath":
propertyInfo.SetValue(voilePlugin, targetFileName, null);
return;
}
}
}
private void dbTestTrafficLight_Click(object sender, EventArgs e)
{
MessageBox.Show("Adjust the settings as needed, and when you're ready, click \"Test Settings\" to verify the connection before moving on.", string.Format("Configuring {0}", selectedDataStorage.DisplayName),MessageBoxButtons.OK,MessageBoxIcon.Information);
}
}
}

View File

@ -15,5 +15,10 @@ namespace Voile.Persistence
} }
public DirectoryInfo Directory { get; } public DirectoryInfo Directory { get; }
public Exception Ping()
{
throw new NotImplementedException();
}
} }
} }