774 lines
36 KiB
C#
774 lines
36 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
using dezentrale.model;
|
|
|
|
namespace dezentrale.view
|
|
{
|
|
public class frmConfiguration : FormWithActionButtons
|
|
{
|
|
//Generic settings
|
|
private TextBox tbDbDirectory;
|
|
private TextBox tbRegularPayment;
|
|
private ComboBox cbRegularCurrency;
|
|
private TextBox tbLocalUser;
|
|
private TextBox tbKeylockCombination;
|
|
public bool KeylockCombiChanged { get; private set; } = false;
|
|
|
|
//SMTP settings
|
|
private CheckBox cbSmtpEnabled;
|
|
private TextBox tbSmtpHost;
|
|
private TextBox tbSmtpPort;
|
|
private CheckBox cbSmtpSSL;
|
|
private TextBox tbSmtpFrom;
|
|
private TextBox tbSmtpUserName;
|
|
private TextBox tbSmtpPassword;
|
|
private TextBox tbSmtpCcTo;
|
|
|
|
//Mail template settings
|
|
private LvMailTemplates lvMailTemplates;
|
|
private LvFormmailTemplateFields lvMailTemplateFields;
|
|
private TextBox tbMailTemplateSubject;
|
|
private TextBox tbMailTemplateBody;
|
|
|
|
//Vorstand settings
|
|
private TextBox tbVSName;
|
|
private TextBox tbVSEmail;
|
|
private TextBox tbSMName;
|
|
private TextBox tbSMEmail;
|
|
private TextBox tbSFName;
|
|
private TextBox tbSFEmail;
|
|
|
|
//Import / Export settings
|
|
private CheckBox cbIeEnabled;
|
|
private TextBox tbIeZipFile;
|
|
private TextBox tbIeZipPassword;
|
|
private CheckBox cbIeGpgEnabled;
|
|
private TextBox tbIeGpgFile;
|
|
private TextBox tbIeGpgPassword;
|
|
|
|
private CheckBox cbIeHgEnabled;
|
|
private TextBox tbIeHgUserName;
|
|
private TextBox tbIeHgPassword;
|
|
private TextBox tbIeHgURL;
|
|
|
|
public TabPage BuildGenericGui()
|
|
{
|
|
TabPage gui = new TabPage("Generic");
|
|
gui.Controls.Add(new Label()
|
|
{
|
|
Text = "DbDirectory:",
|
|
Location = new Point(lm, 0 * line + tm + labelOffs),
|
|
Size = new Size(110, labelHeight),
|
|
TextAlign = ContentAlignment.BottomRight,
|
|
});
|
|
gui.Controls.Add(tbDbDirectory = new TextBox()
|
|
{
|
|
Location = new Point(lm + 113, 0 * line + tm),
|
|
Width = 400,
|
|
});
|
|
Button btnBrowseDataDir;
|
|
gui.Controls.Add(btnBrowseDataDir = new Button()
|
|
{
|
|
Text = "...",
|
|
Location = new Point(lm + 523, 0 * line + tm),
|
|
Width = 30,
|
|
});
|
|
btnBrowseDataDir.Click += btnBrowseDataDir_Click;
|
|
gui.Controls.Add(new Label()
|
|
{
|
|
Text = "RegularPayment:",
|
|
Location = new Point(lm, 1 * line + tm + labelOffs),
|
|
Size = new Size(110, labelHeight),
|
|
TextAlign = ContentAlignment.BottomRight,
|
|
});
|
|
gui.Controls.Add(tbRegularPayment = new TextBox()
|
|
{
|
|
Text = "0,00",
|
|
Location = new Point(lm + 113, 1 * line + tm),
|
|
Width = 100,
|
|
Anchor = AnchorStyles.Top | AnchorStyles.Left,
|
|
TextAlign = HorizontalAlignment.Right,
|
|
});
|
|
gui.Controls.Add(cbRegularCurrency = new ComboBox()
|
|
{
|
|
Location = new Point(lm + 223, 1 * line + tm),
|
|
Width = 70,
|
|
Anchor = AnchorStyles.Top | AnchorStyles.Left,
|
|
DropDownStyle = ComboBoxStyle.DropDownList,
|
|
ForeColor = Color.Black,
|
|
});
|
|
cbRegularCurrency.Items.Add("EUR");
|
|
cbRegularCurrency.SelectedIndex = 0;
|
|
|
|
gui.Controls.Add(new Label()
|
|
{
|
|
Text = "LocalUser:",
|
|
Location = new Point(lm, 2 * line + tm + labelOffs),
|
|
Size = new Size(110, labelHeight),
|
|
TextAlign = ContentAlignment.BottomRight,
|
|
});
|
|
gui.Controls.Add(tbLocalUser = new TextBox()
|
|
{
|
|
Location = new Point(lm + 113, 2 * line + tm),
|
|
Width = 100,
|
|
});
|
|
gui.Controls.Add(new Label()
|
|
{
|
|
Text = "Doorlock code:",
|
|
Location = new Point(lm, 3 * line + tm + labelOffs),
|
|
Size = new Size(110, labelHeight),
|
|
TextAlign = ContentAlignment.BottomRight,
|
|
});
|
|
gui.Controls.Add(tbKeylockCombination = new TextBox()
|
|
{
|
|
Location = new Point(lm + 113, 3 * line + tm),
|
|
Width = 100,
|
|
});
|
|
|
|
tbDbDirectory.Text = Program.config.DbDirectory;
|
|
tbRegularPayment.Text = core.Utils.Int64FPToString(Program.config.RegularPaymentAmount);
|
|
if (Program.config.RegularPaymentCurrency != "EUR")
|
|
{
|
|
cbRegularCurrency.Items.Add(Program.config.RegularPaymentCurrency);
|
|
cbRegularCurrency.SelectedIndex = 1;
|
|
}
|
|
tbLocalUser.Text = Program.config.LocalUser;
|
|
tbKeylockCombination.Text = Program.config.KeylockCombination;
|
|
return gui;
|
|
}
|
|
|
|
public TabPage BuildSmtpGui()
|
|
{
|
|
TabPage gui = new TabPage("Mail Settings");
|
|
gui.Controls.Add(cbSmtpEnabled = new CheckBox()
|
|
{
|
|
Text = "Enable SMTP transmission",
|
|
Location = new Point(lm + 113, 0 * line + tm),
|
|
Width = 400,
|
|
});
|
|
|
|
gui.Controls.Add(new Label()
|
|
{
|
|
Text = "SMTP Server:",
|
|
Location = new Point(lm, 1 * line + tm + labelOffs),
|
|
Size = new Size(110, labelHeight),
|
|
TextAlign = ContentAlignment.BottomRight,
|
|
});
|
|
gui.Controls.Add(tbSmtpHost = new TextBox()
|
|
{
|
|
Text = "localhost",
|
|
Location = new Point(lm + 113, 1 * line + tm),
|
|
Width = 200,
|
|
Anchor = AnchorStyles.Top | AnchorStyles.Left,
|
|
});
|
|
gui.Controls.Add(tbSmtpPort = new TextBox()
|
|
{
|
|
Text = "587",
|
|
Location = new Point(lm + 318, 1 * line + tm),
|
|
Width = 40,
|
|
Anchor = AnchorStyles.Top | AnchorStyles.Left,
|
|
});
|
|
|
|
gui.Controls.Add(cbSmtpSSL = new CheckBox()
|
|
{
|
|
Text = "Enable encrypted connection (SSL)",
|
|
Location = new Point(lm + 113, 2 * line + tm),
|
|
Width = 400,
|
|
});
|
|
gui.Controls.Add(new Label()
|
|
{
|
|
Text = "Mail from:",
|
|
Location = new Point(lm, 3 * line + tm + labelOffs),
|
|
Size = new Size(110, labelHeight),
|
|
TextAlign = ContentAlignment.BottomRight,
|
|
});
|
|
gui.Controls.Add(tbSmtpFrom = new TextBox()
|
|
{
|
|
Location = new Point(lm + 113, 3 * line + tm),
|
|
Width = 400,
|
|
Anchor = AnchorStyles.Top | AnchorStyles.Left,
|
|
});
|
|
|
|
gui.Controls.Add(new Label()
|
|
{
|
|
Text = "SMTP login:",
|
|
Location = new Point(lm, 4 * line + tm + labelOffs),
|
|
Size = new Size(110, labelHeight),
|
|
TextAlign = ContentAlignment.BottomRight,
|
|
});
|
|
gui.Controls.Add(tbSmtpUserName = new TextBox()
|
|
{
|
|
Location = new Point(lm + 113, 4 * line + tm),
|
|
Width = 200,
|
|
Anchor = AnchorStyles.Top | AnchorStyles.Left,});
|
|
|
|
gui.Controls.Add(new Label()
|
|
{
|
|
Text = "SMTP password:",
|
|
Location = new Point(lm, 5 * line + tm + labelOffs),
|
|
Size = new Size(110, labelHeight),
|
|
TextAlign = ContentAlignment.BottomRight,
|
|
});
|
|
gui.Controls.Add(tbSmtpPassword = new TextBox()
|
|
{
|
|
PasswordChar = '*',
|
|
Location = new Point(lm + 113, 5 * line + tm),
|
|
Width = 200,
|
|
Anchor = AnchorStyles.Top | AnchorStyles.Left,
|
|
});
|
|
|
|
gui.Controls.Add(new Label()
|
|
{
|
|
Text = "Cc sent mails:",
|
|
Location = new Point(lm, 6 * line + tm + labelOffs),
|
|
Size = new Size(110, labelHeight),
|
|
TextAlign = ContentAlignment.BottomRight,
|
|
});
|
|
gui.Controls.Add(tbSmtpCcTo = new TextBox()
|
|
{
|
|
Location = new Point(lm + 113, 6 * line + tm),
|
|
Width = 400,
|
|
Anchor = AnchorStyles.Top | AnchorStyles.Left,
|
|
});
|
|
|
|
//VS settings
|
|
gui.Controls.Add(new Label()
|
|
{
|
|
Text = "Contact info for the Vorstand",
|
|
Location = new Point(lm, 8 * line + tm + labelOffs),
|
|
Size = new Size(210, labelHeight),
|
|
TextAlign = ContentAlignment.BottomRight,
|
|
});
|
|
|
|
gui.Controls.Add(new Label()
|
|
{
|
|
Text = "Vorstand:",
|
|
Location = new Point(lm, 9 * line + tm + labelOffs),
|
|
Size = new Size(110, labelHeight),
|
|
TextAlign = ContentAlignment.BottomRight,
|
|
});
|
|
gui.Controls.Add(tbVSName = new TextBox()
|
|
{
|
|
Location = new Point(lm + 113, 9 * line + tm),
|
|
Width = 200,
|
|
Anchor = AnchorStyles.Top | AnchorStyles.Left,
|
|
});
|
|
gui.Controls.Add(new Label()
|
|
{
|
|
Text = "VS-Mail:",
|
|
Location = new Point(lm, 10 * line + tm + labelOffs),
|
|
Size = new Size(110, labelHeight),
|
|
TextAlign = ContentAlignment.BottomRight,
|
|
});
|
|
gui.Controls.Add(tbVSEmail = new TextBox()
|
|
{
|
|
Location = new Point(lm + 113, 10 * line + tm),
|
|
Width = 200,
|
|
Anchor = AnchorStyles.Top | AnchorStyles.Left,
|
|
});
|
|
|
|
gui.Controls.Add(new Label()
|
|
{
|
|
Text = "Schatzmeister:",
|
|
Location = new Point(lm, 11 * line + tm + labelOffs),
|
|
Size = new Size(110, labelHeight),
|
|
TextAlign = ContentAlignment.BottomRight,
|
|
});
|
|
gui.Controls.Add(tbSMName = new TextBox()
|
|
{
|
|
Location = new Point(lm + 113, 11 * line + tm),
|
|
Width = 200,
|
|
Anchor = AnchorStyles.Top | AnchorStyles.Left,
|
|
});
|
|
gui.Controls.Add(new Label()
|
|
{
|
|
Text = "SM-Mail:",
|
|
Location = new Point(lm, 12 * line + tm + labelOffs),
|
|
Size = new Size(110, labelHeight),
|
|
TextAlign = ContentAlignment.BottomRight,
|
|
});
|
|
gui.Controls.Add(tbSMEmail = new TextBox()
|
|
{
|
|
Location = new Point(lm + 113, 12 * line + tm),
|
|
Width = 200,
|
|
Anchor = AnchorStyles.Top | AnchorStyles.Left,
|
|
});
|
|
|
|
gui.Controls.Add(new Label()
|
|
{
|
|
Text = "Schriftfuehrer:",
|
|
Location = new Point(lm, 13 * line + tm + labelOffs),
|
|
Size = new Size(110, labelHeight),
|
|
TextAlign = ContentAlignment.BottomRight,
|
|
});
|
|
gui.Controls.Add(tbSFName = new TextBox()
|
|
{
|
|
Location = new Point(lm + 113, 13 * line + tm),
|
|
Width = 200,
|
|
Anchor = AnchorStyles.Top | AnchorStyles.Left,
|
|
});
|
|
gui.Controls.Add(new Label()
|
|
{
|
|
Text = "SF-Mail:",
|
|
Location = new Point(lm, 14 * line + tm + labelOffs),
|
|
Size = new Size(110, labelHeight),
|
|
TextAlign = ContentAlignment.BottomRight,
|
|
});
|
|
gui.Controls.Add(tbSFEmail = new TextBox()
|
|
{
|
|
Location = new Point(lm + 113, 14 * line + tm),
|
|
Width = 200,
|
|
Anchor = AnchorStyles.Top | AnchorStyles.Left,
|
|
});
|
|
|
|
cbSmtpEnabled.Checked = Program.config.Smtp.Enabled;
|
|
tbSmtpHost.Text = Program.config.Smtp.Host;
|
|
tbSmtpPort.Text = $"{Program.config.Smtp.Port}";
|
|
cbSmtpSSL.Checked = Program.config.Smtp.SSL;
|
|
tbSmtpFrom.Text = Program.config.Smtp.From;
|
|
tbSmtpUserName.Text = Program.config.Smtp.UserName;
|
|
tbSmtpPassword.Text = Program.config.Smtp.Password;
|
|
tbSmtpCcTo.Text = Program.config.Smtp.CcTo;
|
|
|
|
tbVSName.Text = Program.config.VS.EMailName;
|
|
tbVSEmail.Text = Program.config.VS.EMail;
|
|
tbSMName.Text = Program.config.Schatzmeister.EMailName;
|
|
tbSMEmail.Text = Program.config.Schatzmeister.EMail;
|
|
tbSFName.Text = Program.config.Schriftfuehrer.EMailName;
|
|
tbSFEmail.Text = Program.config.Schriftfuehrer.EMail;
|
|
return gui;
|
|
}
|
|
public TabPage BuildMailTemplateGui()
|
|
{
|
|
TabPage gui = new TabPage("Mail templates");
|
|
|
|
gui.BackColor = Color.LightBlue;
|
|
SplitContainer split1 = new SplitContainer()
|
|
{
|
|
Dock = DockStyle.Fill,
|
|
Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom,
|
|
//BackColor = Color.LightBlue,
|
|
};
|
|
gui.Controls.Add(split1);
|
|
GroupBox gbTemplates = new GroupBox()
|
|
{
|
|
Width = 45, Height = 95,
|
|
Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom,
|
|
Text = "Templates",
|
|
};
|
|
try
|
|
{
|
|
split1.Panel1MinSize = 250;
|
|
} catch(Exception ex) { MessageBox.Show(ex.Message); }
|
|
split1.Panel1.Controls.Add(gbTemplates);
|
|
|
|
gbTemplates.Controls.Add(lvMailTemplates = new LvMailTemplates()
|
|
{
|
|
Location = new Point(lm + 6, 15 + 0 * line + tm),
|
|
Width = 25,
|
|
Height = 70,
|
|
Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom,
|
|
});
|
|
lvMailTemplates.SelectedIndexChanged += (sender, e) => {
|
|
FormMail m = lvMailTemplates.GetFirstSelectedItem();
|
|
try
|
|
{
|
|
if (m != null)
|
|
{
|
|
tbMailTemplateSubject.Enabled = true;
|
|
tbMailTemplateBody.Enabled = true;
|
|
lvMailTemplateFields.Enabled = true;
|
|
tbMailTemplateSubject.Text = m.Subject;
|
|
tbMailTemplateBody.Text = m.Body;
|
|
lvMailTemplateFields.LoadFromList(m.AllowedObjectFields);
|
|
}
|
|
else
|
|
{
|
|
tbMailTemplateSubject.Enabled = false;
|
|
tbMailTemplateBody.Enabled = false;
|
|
lvMailTemplateFields.Enabled = false;
|
|
tbMailTemplateSubject.Text = "";
|
|
tbMailTemplateBody.Text = "";
|
|
lvMailTemplateFields.LoadFromList(new List<string>());
|
|
}
|
|
} catch(Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message);
|
|
}
|
|
};
|
|
|
|
GroupBox gbContents = new GroupBox()
|
|
{
|
|
Dock = DockStyle.Fill,
|
|
Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom,
|
|
Text = "Contents",
|
|
};
|
|
|
|
|
|
split1.Panel2.Controls.Add(gbContents);
|
|
SplitContainer split2 = new SplitContainer()
|
|
{
|
|
Dock = DockStyle.Fill,
|
|
Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom,
|
|
//BackColor = Color.Orange,
|
|
};
|
|
gbContents.Controls.Add(split2);
|
|
split2.Panel1.Controls.Add(lvMailTemplateFields = new LvFormmailTemplateFields()
|
|
{
|
|
Enabled = false,
|
|
Location = new Point(lm, 0 * line + tm),
|
|
Width = 43,
|
|
Height = 90,
|
|
Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom,
|
|
});
|
|
split2.Panel2.Controls.Add(tbMailTemplateSubject = new TextBox()
|
|
{
|
|
Enabled = false,
|
|
Location = new Point(lm, 0 * line + tm),
|
|
Width = 35,
|
|
Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right,
|
|
});
|
|
split2.Panel2.Controls.Add(tbMailTemplateBody = new TextBox()
|
|
{
|
|
Enabled = false,
|
|
Location = new Point(lm, 1 * line + tm),
|
|
Multiline = true,
|
|
ScrollBars = ScrollBars.Both,
|
|
Width = 35,
|
|
Height = 446,
|
|
Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom,
|
|
});
|
|
/*
|
|
gui.Controls.Add(new Label()
|
|
{
|
|
Text = "Template",
|
|
Location = new Point(lm + 113, 0 * line + tm),
|
|
Width = 300,
|
|
});*/
|
|
LoadMailTemplates();
|
|
return gui;
|
|
}
|
|
private MailTemplates mailTemplates = new MailTemplates();
|
|
private bool mailTemplatesChanged = false;
|
|
private void LoadMailTemplates()
|
|
{
|
|
PropertyInfo[] properties = typeof(MailTemplates).GetProperties();
|
|
foreach (PropertyInfo p in properties)
|
|
{
|
|
if (p.PropertyType != typeof(FormMail)) continue;
|
|
if (!p.CanRead) continue;
|
|
if (!p.CanWrite) continue;
|
|
//m.AllowedObjectFields.Add($"{p.Name}");
|
|
FormMail fm = (FormMail)p.GetValue(Program.mailTemplates);
|
|
//lvMailTemplates.AddEntry();
|
|
}
|
|
lvMailTemplates.AddEntry(mailTemplates.NewMemberWelcome = new FormMail(Program.mailTemplates.NewMemberWelcome));
|
|
lvMailTemplates.AddEntry(mailTemplates.MemberAccountActivated = new FormMail(Program.mailTemplates.MemberAccountActivated));
|
|
lvMailTemplates.AddEntry(mailTemplates.NewMemberVorstand = new FormMail(Program.mailTemplates.NewMemberVorstand));
|
|
lvMailTemplates.AddEntry(mailTemplates.MemberActiveVorstand = new FormMail(Program.mailTemplates.MemberActiveVorstand));
|
|
//lvMailTemplates.AddEntry(mailTemplates.AutoTypeFoerdermitglied = new FormMail(Program.mailTemplates.AutoTypeFoerdermitglied));
|
|
lvMailTemplates.AddEntry(mailTemplates.MembershipTypeChanged = new FormMail(Program.mailTemplates.MembershipTypeChanged));
|
|
lvMailTemplates.AddEntry(mailTemplates.BalanceNegativeMemberNotify1 = new FormMail(Program.mailTemplates.BalanceNegativeMemberNotify1));
|
|
lvMailTemplates.AddEntry(mailTemplates.BalanceNegativeMemberNotify2 = new FormMail(Program.mailTemplates.BalanceNegativeMemberNotify2));
|
|
lvMailTemplates.AddEntry(mailTemplates.BalanceNegativeMemberDeactivation = new FormMail(Program.mailTemplates.BalanceNegativeMemberDeactivation));
|
|
lvMailTemplates.AddEntry(mailTemplates.BalanceNegativeMemberDeactivationVS = new FormMail(Program.mailTemplates.BalanceNegativeMemberDeactivationVS));
|
|
lvMailTemplates.AddEntry(mailTemplates.BalanceNegativeNotify2SM = new FormMail(Program.mailTemplates.BalanceNegativeNotify2SM));
|
|
lvMailTemplates.AddEntry(mailTemplates.DisabledMemberGettingPayments2SM = new FormMail(Program.mailTemplates.DisabledMemberGettingPayments2SM));
|
|
lvMailTemplates.AddEntry(mailTemplates.BalanceAbove200NotifySM = new FormMail(Program.mailTemplates.BalanceAbove200NotifySM));
|
|
//lvMailTemplates.AddEntry(mailTemplates.MemberPaymentNotify = new FormMail(Program.mailTemplates.MemberPaymentNotify));
|
|
lvMailTemplates.AddEntry(mailTemplates.KeylockChanged = new FormMail(Program.mailTemplates.KeylockChanged));
|
|
lvMailTemplates.AddEntry(mailTemplates.Testmail = new FormMail(Program.mailTemplates.Testmail));
|
|
lvMailTemplates.AddEntry(mailTemplates.SingleMemberStatusReport = new FormMail(Program.mailTemplates.SingleMemberStatusReport));
|
|
lvMailTemplates.AddEntry(mailTemplates.ReducedFeeReminder = new FormMail(Program.mailTemplates.ReducedFeeReminder));
|
|
lvMailTemplates.AddEntry(mailTemplates.MemberPaymentReceipts = new FormMail(Program.mailTemplates.MemberPaymentReceipts));
|
|
lvMailTemplates.AddEntry(mailTemplates.MvCancelNotification = new FormMail(Program.mailTemplates.MvCancelNotification));
|
|
lvMailTemplates.AddEntry(mailTemplates.MvFinishedNotification = new FormMail(Program.mailTemplates.MvFinishedNotification));
|
|
mailTemplatesChanged = false;
|
|
}
|
|
private void StoreMailTemplates()
|
|
{
|
|
if (mailTemplatesChanged)
|
|
{
|
|
Program.mailTemplates.NewMemberWelcome = mailTemplates.NewMemberWelcome;
|
|
Program.mailTemplates.MemberAccountActivated = mailTemplates.MemberAccountActivated;
|
|
Program.mailTemplates.NewMemberVorstand = mailTemplates.NewMemberVorstand;
|
|
Program.mailTemplates.MemberActiveVorstand = mailTemplates.MemberActiveVorstand;
|
|
//Program.mailTemplates.AutoTypeFoerdermitglied = mailTemplates.AutoTypeFoerdermitglied;
|
|
Program.mailTemplates.MembershipTypeChanged = mailTemplates.MembershipTypeChanged;
|
|
Program.mailTemplates.BalanceNegativeMemberNotify1 = mailTemplates.BalanceNegativeMemberNotify1;
|
|
Program.mailTemplates.BalanceNegativeMemberNotify2 = mailTemplates.BalanceNegativeMemberNotify2;
|
|
Program.mailTemplates.BalanceNegativeMemberDeactivation = mailTemplates.BalanceNegativeMemberDeactivation;
|
|
Program.mailTemplates.BalanceNegativeMemberDeactivationVS = mailTemplates.BalanceNegativeMemberDeactivationVS;
|
|
Program.mailTemplates.BalanceNegativeNotify2SM = mailTemplates.BalanceNegativeNotify2SM;
|
|
Program.mailTemplates.DisabledMemberGettingPayments2SM = mailTemplates.DisabledMemberGettingPayments2SM;
|
|
Program.mailTemplates.BalanceAbove200NotifySM = mailTemplates.BalanceAbove200NotifySM;
|
|
//Program.mailTemplates.MemberPaymentNotify = mailTemplates.MemberPaymentNotify;
|
|
Program.mailTemplates.KeylockChanged = mailTemplates.KeylockChanged;
|
|
Program.mailTemplates.Testmail = mailTemplates.Testmail;
|
|
Program.mailTemplates.SingleMemberStatusReport = mailTemplates.SingleMemberStatusReport;
|
|
Program.mailTemplates.ReducedFeeReminder = mailTemplates.ReducedFeeReminder;
|
|
Program.mailTemplates.MemberPaymentReceipts = mailTemplates.MemberPaymentReceipts;
|
|
Program.mailTemplates.MvCancelNotification = mailTemplates.MvCancelNotification;
|
|
Program.mailTemplates.MvFinishedNotification = mailTemplates.MvFinishedNotification;
|
|
}
|
|
}
|
|
|
|
public TabPage BuildMoneyTransfersGui()
|
|
{
|
|
TabPage gui = new TabPage("MoneyTransfers");
|
|
//use MoneyTransferList for that, not Program.config
|
|
//[XmlElement] public List<KeyValue> MoneyTransferRegEx { get; set; } = new List<KeyValue>();
|
|
return gui;
|
|
}
|
|
public TabPage BuildImportExportGui()
|
|
{
|
|
TabPage gui = new TabPage("Import / Export");
|
|
|
|
|
|
gui.Controls.Add(cbIeEnabled = new CheckBox()
|
|
{
|
|
Text = "Enable Import/Export with the settings below",
|
|
Location = new Point(lm + 113, 0 * line + tm),
|
|
Width = 400,
|
|
});
|
|
|
|
gui.Controls.Add(new Label()
|
|
{
|
|
Text = "Zip filename:",
|
|
Location = new Point(lm, 1 * line + tm + labelOffs),
|
|
Size = new Size(110, labelHeight),
|
|
TextAlign = ContentAlignment.BottomRight,
|
|
});
|
|
gui.Controls.Add(tbIeZipFile = new TextBox()
|
|
{
|
|
Location = new Point(lm + 113, 1 * line + tm),
|
|
Width = 200,
|
|
Anchor = AnchorStyles.Top | AnchorStyles.Left,
|
|
});
|
|
|
|
gui.Controls.Add(new Label()
|
|
{
|
|
Text = "Zip password:",
|
|
Location = new Point(lm, 2 * line + tm + labelOffs),
|
|
Size = new Size(110, labelHeight),
|
|
TextAlign = ContentAlignment.BottomRight,
|
|
});
|
|
gui.Controls.Add(tbIeZipPassword = new TextBox()
|
|
{
|
|
PasswordChar = '*',
|
|
Location = new Point(lm + 113, 2 * line + tm),
|
|
Width = 200,
|
|
Anchor = AnchorStyles.Top | AnchorStyles.Left,
|
|
});
|
|
|
|
gui.Controls.Add(cbIeGpgEnabled = new CheckBox()
|
|
{
|
|
Text = "Enable file encryption with GPG (AES + password)",
|
|
Location = new Point(lm + 113, 3 * line + tm),
|
|
Width = 400,
|
|
});
|
|
|
|
gui.Controls.Add(new Label()
|
|
{
|
|
Text = "Gpg filename:",
|
|
Location = new Point(lm, 4 * line + tm + labelOffs),
|
|
Size = new Size(110, labelHeight),
|
|
TextAlign = ContentAlignment.BottomRight,
|
|
});
|
|
gui.Controls.Add(tbIeGpgFile = new TextBox()
|
|
{
|
|
Location = new Point(lm + 113, 4 * line + tm),
|
|
Width = 200,
|
|
Anchor = AnchorStyles.Top | AnchorStyles.Left,
|
|
});
|
|
|
|
gui.Controls.Add(new Label()
|
|
{
|
|
Text = "Gpg password:",
|
|
Location = new Point(lm, 5 * line + tm + labelOffs),
|
|
Size = new Size(110, labelHeight),
|
|
TextAlign = ContentAlignment.BottomRight,
|
|
});
|
|
gui.Controls.Add(tbIeGpgPassword = new TextBox()
|
|
{
|
|
PasswordChar = '*',
|
|
Location = new Point(lm + 113, 5 * line + tm),
|
|
Width = 200,
|
|
Anchor = AnchorStyles.Top | AnchorStyles.Left,
|
|
});
|
|
gui.Controls.Add(cbIeHgEnabled = new CheckBox()
|
|
{
|
|
Text = "Enable data synchronisation over mercurial",
|
|
Location = new Point(lm + 113, 6 * line + tm),
|
|
Width = 400,
|
|
});
|
|
|
|
gui.Controls.Add(new Label()
|
|
{
|
|
Text = "HG UserName:",
|
|
Location = new Point(lm, 7 * line + tm + labelOffs),
|
|
Size = new Size(110, labelHeight),
|
|
TextAlign = ContentAlignment.BottomRight,
|
|
});
|
|
gui.Controls.Add(tbIeHgUserName = new TextBox()
|
|
{
|
|
Location = new Point(lm + 113, 7 * line + tm),
|
|
Width = 200,
|
|
Anchor = AnchorStyles.Top | AnchorStyles.Left,
|
|
});
|
|
|
|
gui.Controls.Add(new Label()
|
|
{
|
|
Text = "HG password:",
|
|
Location = new Point(lm, 8 * line + tm + labelOffs),
|
|
Size = new Size(110, labelHeight),
|
|
TextAlign = ContentAlignment.BottomRight,
|
|
});
|
|
gui.Controls.Add(tbIeHgPassword = new TextBox()
|
|
{
|
|
PasswordChar = '*',
|
|
Location = new Point(lm + 113, 8 * line + tm),
|
|
Width = 200,
|
|
Anchor = AnchorStyles.Top | AnchorStyles.Left,
|
|
});
|
|
|
|
gui.Controls.Add(new Label()
|
|
{
|
|
Text = "HG URL:",
|
|
Location = new Point(lm, 9 * line + tm + labelOffs),
|
|
Size = new Size(110, labelHeight),
|
|
TextAlign = ContentAlignment.BottomRight,
|
|
});
|
|
gui.Controls.Add(tbIeHgURL = new TextBox()
|
|
{
|
|
Location = new Point(lm + 113, 9 * line + tm),
|
|
Width = 400,
|
|
Anchor = AnchorStyles.Top | AnchorStyles.Left,
|
|
});
|
|
|
|
cbIeEnabled.Checked = Program.config.ImportExport.Enabled;
|
|
tbIeZipFile.Text = Program.config.ImportExport.ZipFile;
|
|
tbIeZipPassword.Text = Program.config.ImportExport.ZipPassword;
|
|
cbIeGpgEnabled.Checked = Program.config.ImportExport.GpgEnabled;
|
|
tbIeGpgFile.Text = Program.config.ImportExport.GpgFile;
|
|
tbIeGpgPassword.Text = Program.config.ImportExport.GpgPassword;
|
|
cbIeHgEnabled.Checked = Program.config.ImportExport.HgEnabled;
|
|
tbIeHgUserName.Text = Program.config.ImportExport.HgUserName;
|
|
tbIeHgPassword.Text = Program.config.ImportExport.HgPassword;
|
|
tbIeHgURL.Text = Program.config.ImportExport.HgURL;
|
|
/*
|
|
[XmlElement] public bool GitEnabled { get; set; } = false;
|
|
[XmlElement] public string GitUserName { get; set; } = "";
|
|
[XmlElement] public string GitPassword { get; set; } = "";*/
|
|
return gui;
|
|
}
|
|
public frmConfiguration()
|
|
{
|
|
DialogResult = DialogResult.Cancel;
|
|
this.StartPosition = FormStartPosition.CenterParent;
|
|
this.Size = new System.Drawing.Size(800, 600);
|
|
this.Text = "dezentrale-members :: Configuration";
|
|
this.Controls.Add(new TabControl()
|
|
{
|
|
Size = new System.Drawing.Size(this.Width - 16, this.Height - 95),
|
|
Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom,
|
|
TabPages =
|
|
{
|
|
BuildGenericGui(),
|
|
BuildSmtpGui(),
|
|
BuildMailTemplateGui(),
|
|
BuildMoneyTransfersGui(),
|
|
BuildImportExportGui(),
|
|
}
|
|
});
|
|
AddButton("OK", btnOK_Click);
|
|
AddButton("Cancel", btnCancel_Click);
|
|
}
|
|
private void btnOK_Click(object sender, EventArgs e)
|
|
{
|
|
DialogResult = DialogResult.OK;
|
|
this.Close();
|
|
}
|
|
private void btnCancel_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
private void btnBrowseDataDir_Click(object sender, EventArgs e)
|
|
{
|
|
FolderBrowserDialog fbd = new FolderBrowserDialog();
|
|
DialogResult dr = fbd.ShowDialog();
|
|
if(dr == DialogResult.OK)
|
|
{
|
|
tbDbDirectory.Text = fbd.SelectedPath;
|
|
}
|
|
}
|
|
public void FillAndSaveConfig()
|
|
{
|
|
Program.config.DbDirectory = tbDbDirectory.Text;
|
|
Program.config.RegularPaymentAmount = (uint) core.Utils.StringToInt64FP(tbRegularPayment.Text);
|
|
Program.config.RegularPaymentCurrency = cbRegularCurrency.Text;
|
|
Program.config.LocalUser = tbLocalUser.Text;
|
|
if (Program.config.KeylockCombination != tbKeylockCombination.Text)
|
|
KeylockCombiChanged = true;
|
|
Program.config.KeylockCombination = tbKeylockCombination.Text;
|
|
|
|
Program.config.Smtp.Enabled = cbSmtpEnabled.Checked;
|
|
Program.config.Smtp.Host = tbSmtpHost.Text;
|
|
Program.config.Smtp.Port = Convert.ToUInt16(tbSmtpPort.Text);
|
|
Program.config.Smtp.SSL = cbSmtpSSL.Checked;
|
|
Program.config.Smtp.From = tbSmtpFrom.Text;
|
|
Program.config.Smtp.UserName = tbSmtpUserName.Text;
|
|
Program.config.Smtp.Password = tbSmtpPassword.Text;
|
|
Program.config.Smtp.CcTo = tbSmtpCcTo.Text;
|
|
|
|
Program.config.VS.EMailName = tbVSName.Text;
|
|
Program.config.VS.EMail = tbVSEmail.Text;
|
|
Program.config.Schatzmeister.EMailName = tbSMName.Text;
|
|
Program.config.Schatzmeister.EMail = tbSMEmail.Text;
|
|
Program.config.Schriftfuehrer.EMailName = tbSFName.Text;
|
|
Program.config.Schriftfuehrer.EMail = tbSFEmail.Text;
|
|
|
|
|
|
StoreMailTemplates();
|
|
|
|
//use MoneyTransferList for that, not Program.config
|
|
//[XmlElement] public List<KeyValue> MoneyTransferRegEx { get; set; } = new List<KeyValue>();
|
|
|
|
Program.config.ImportExport.Enabled = cbIeEnabled.Checked;
|
|
Program.config.ImportExport.ZipFile = tbIeZipFile.Text;
|
|
Program.config.ImportExport.ZipPassword = tbIeZipPassword.Text;
|
|
Program.config.ImportExport.GpgEnabled = cbIeGpgEnabled.Checked;
|
|
Program.config.ImportExport.GpgFile = tbIeGpgFile.Text;
|
|
Program.config.ImportExport.GpgPassword = tbIeGpgPassword.Text;
|
|
Program.config.ImportExport.HgEnabled = cbIeHgEnabled.Checked;
|
|
Program.config.ImportExport.HgUserName = tbIeHgUserName.Text;
|
|
Program.config.ImportExport.HgPassword = tbIeHgPassword.Text;
|
|
Program.config.ImportExport.HgURL = tbIeHgURL.Text;
|
|
/*
|
|
[XmlElement] public bool GitEnabled { get; set; } = false;
|
|
[XmlElement] public string GitUserName { get; set; } = "";
|
|
[XmlElement] public string GitPassword { get; set; } = "";*/
|
|
|
|
|
|
try
|
|
{
|
|
XmlData.SaveToFile(Program.ConfigFile, Program.config);
|
|
Program.MoneyTransfers.SaveToFile();
|
|
Console.WriteLine("Stored new configuration.");
|
|
XmlData.SaveToFile(System.IO.Path.Combine(Program.config.DbDirectory, "MailTemplates.xml"), Program.mailTemplates);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show($"Error while storing configuration: {ex.Message}");
|
|
}
|
|
}
|
|
}
|
|
}
|