From d8b6dccae5aa7d7d441daa1150661c6ed9d62f9e Mon Sep 17 00:00:00 2001 From: phantomix Date: Sun, 21 Feb 2021 16:18:07 +0100 Subject: [PATCH] 210221PX Added gitignore, removed compilation warnings, more work on MV --- .gitignore | 4 +++ model/FormMail.cs | 15 +++++++++++ model/Mv.cs | 1 + model/svg/SvgPath.cs | 12 ++++++--- view/LvMvInvitations.cs | 22 +++++++++++++--- view/frmMain.cs | 12 +++++++-- view/frmMv.cs | 57 +++++++++++++++++++++++++++++++++-------- 7 files changed, 103 insertions(+), 20 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1a4dae4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +obj/ +/*.csproj.user +.vs/ +bin/ diff --git a/model/FormMail.cs b/model/FormMail.cs index 2c1f414..842c912 100644 --- a/model/FormMail.cs +++ b/model/FormMail.cs @@ -69,8 +69,23 @@ namespace dezentrale.model foreach (string f in files) message.Attachments.Add(new Attachment(f)); +#pragma warning disable CS0618 //Suppress deprecation warning + /* Warning CS0618: 'SmtpClient' is obsolete: 'SmtpClient + * and its network of types are poorly designed, we strongly + * recommend you use https://github.com/jstedfast/MailKit + * and https://github.com/jstedfast/MimeKit instead + * (CS0618) (dezentrale-members) + * + * I'm pretty much aware about this fancy new mail client + * project by some $user, which lets me keep track of POP3 and + * IMAP accounts and everything, but at this point I simply + * need a possibility to send mails via SMTP, and this is a + * feature, SmtpClient does very well, without dragging + * dependencies to other code into our project. + */ SmtpClient client = new SmtpClient(Program.config.Smtp.Host, Program.config.Smtp.Port) +#pragma warning restore CS0618 { DeliveryMethod = SmtpDeliveryMethod.Network, EnableSsl = Program.config.Smtp.SSL, diff --git a/model/Mv.cs b/model/Mv.cs index 82ecc32..6132a66 100644 --- a/model/Mv.cs +++ b/model/Mv.cs @@ -13,6 +13,7 @@ namespace dezentrale.model public string AuthCode { get; set; } = ""; public bool AttendedMv { get; set; } = false; + [XmlIgnore] public string NumberString { get { return $"{MemberNumber:D3}"; } } [XmlIgnore] public string InvitedString { get { return Invited ? "Yes" : "No"; } } private Member member = null; diff --git a/model/svg/SvgPath.cs b/model/svg/SvgPath.cs index 506dfc0..ff7d134 100644 --- a/model/svg/SvgPath.cs +++ b/model/svg/SvgPath.cs @@ -293,17 +293,20 @@ namespace dezentrale.model.svg /** Tries to transform all contained path commands to absolute coordinate values */ public void MakeAbsolute() { +#pragma warning disable CS0219 // suppress unused for now, until this method is implemented better double x = 0; double y = 0; - foreach(SvgPathCommand c in CommandList) +#pragma warning restore CS0219 + foreach (SvgPathCommand c in CommandList) { } + throw new NotImplementedException(); } /** Tries to transform all contained path commands to absolute coordinate values */ public void MakeRelative() { - + throw new NotImplementedException(); } public void AddCommand(SvgPathCommand cmd) { CommandList.Add(cmd); } @@ -312,8 +315,10 @@ namespace dezentrale.model.svg /**\short translates all path coordinates by (dx, dy) */ public void Translate(double dx, double dy) { +#pragma warning disable CS0219 // suppress unused for now, until this method is implemented better double x = 0; double y = 0; +#pragma warning restore CS0219 foreach (SvgPathCommand cmd in CommandList) { if(!cmd.Relative) @@ -321,11 +326,12 @@ namespace dezentrale.model.svg //cmd.Translate(dx, dy); } } + throw new NotImplementedException(); } /**\short scales all path coordinates around the center point (cx,cy) by the factors of (fx, fy) */ public void Scale(double cx, double cy, double fx, double fy) { - + throw new NotImplementedException(); } } } diff --git a/view/LvMvInvitations.cs b/view/LvMvInvitations.cs index adc4e6f..0ea136f 100644 --- a/view/LvMvInvitations.cs +++ b/view/LvMvInvitations.cs @@ -15,25 +15,39 @@ namespace dezentrale.view { return new List() { + new ConfigLVDataHandler() + { + Name = "number", + Display = "#", + Width = 40, + CustomToString = x => ((MvInvitedMember)x).NumberString, + }, + new ConfigLVDataHandler() + { + Name = "nickname", + Display = "name / nickname", + Width = 120, + CustomToString = x => ((MvInvitedMember)x).Member?.Nickname, + }, new ConfigLVDataHandler() { Name = "invited", Display = "Invited", - Width = 57, TextAlign = HorizontalAlignment.Right, + Width = 48, TextAlign = HorizontalAlignment.Right, CustomToString = ( x => ((MvInvitedMember)x).InvitedString), }, new ConfigLVDataHandler() { Name = "date", Display = "Date", - Width = 160, - CustomToString = ( x => (((MvInvitedMember)x).InvitationDate.ToString()) ), + Width = 130, + CustomToString = ( x => (((MvInvitedMember)x).InvitationDate.Year > 1 ? ((MvInvitedMember)x).InvitationDate.ToString() : "-") ), }, }; } } - public LvMvInvitations() : base(Program.config.MemberListColumns, LvMvInvitations_ColumnsChanged) { } + public LvMvInvitations() : base(Program.config.MvInvitationsListColumns, LvMvInvitations_ColumnsChanged, false) { } private static void LvMvInvitations_ColumnsChanged(object sender, ColumnsChangedArgs e) { diff --git a/view/frmMain.cs b/view/frmMain.cs index e87cc02..f38495f 100644 --- a/view/frmMain.cs +++ b/view/frmMain.cs @@ -252,8 +252,16 @@ namespace dezentrale.view private void lstMv_New(object sender, EventArgs e) { - frmMv newMv = new frmMv(); - newMv.ShowDialog(); + DialogResult res = MessageBox.Show("This will create a new MV and store it in MV list.\n", "Create new MV?", MessageBoxButtons.YesNo); + if (res == DialogResult.Yes) + { + frmMv newMv = new frmMv(); + Program.mvList.Entries.Add(newMv.mv); + Program.mvList.SaveToFile(); + newMv.ShowDialog(); + + Program.mvList.SaveToFile(); + } //if(newMv.DialogResult == DialogResult.OK) //lstMv.AddEntry(newMv.GetMv()); diff --git a/view/frmMv.cs b/view/frmMv.cs index 8dad851..aa1eb82 100644 --- a/view/frmMv.cs +++ b/view/frmMv.cs @@ -17,7 +17,7 @@ namespace dezentrale.view */ public class frmMv : FormWithActionButtons { - private Mv mv; + public Mv mv { get; set; } private TabControl tabControl; //private TabPage tabInvitationSettings; @@ -32,8 +32,8 @@ namespace dezentrale.view private TextBox tbInviteHeadline; private TextBox tbInviteBody; //private TabPage tabMemberInvitation; - //private ComboBox cbInviteSelection; //List with all members and invited yes|no + private LvMvInvitations lvMvInvitations; //Option to invite selected|all members //private TabPage tabRunningMv; //List with invited members with authenticated status @@ -203,13 +203,19 @@ namespace dezentrale.view //Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom, }; split.Panel1.Controls.Add(grpInvitations); - GroupBox grpPreview = new GroupBox() + + grpInvitations.Controls.Add(lvMvInvitations = new LvMvInvitations() { Dock = DockStyle.Fill, - Text = "Invitation mail preview", - Width = 500, - //Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom, - }; + }); + GroupBox grpPreview = new GroupBox() + { + Dock = DockStyle.Fill, + Text = "Invitation mail preview", + Width = 500, + //Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom, + }; + split.Panel2.Controls.Add(grpPreview); grpInvitations.Controls.Add(null); @@ -290,7 +296,36 @@ namespace dezentrale.view UpdateButtons(); programmaticChange = false; RefreshPreview(); + + + //for new MV, we want to keep the member list up-to-date in order + //to be able to invite new members even if their membership status + //becomes active after MV entry was generated. The other way round, + //entries with no (or inactive) member reference will not be + //removed (documentation purposes) + if (this.mv.Status < Mv.MvStatus.Started) + { + foreach (Member m in Program.members.Entries) + { + if (m.Status == Member.eStatus.Active) + { + //find invitation entry + if(this.mv.Invited.Find((x) => x.MemberNumber == m.Number) == null) + //if there is none, create one + { + this.mv.Invited.Add(new MvInvitedMember() + { + MemberNumber = m.Number, + }); + } + } + } + } + + foreach(MvInvitedMember mvi in this.mv.Invited) + lvMvInvitations.AddEntry(mvi); } + public frmMv(Mv mv) { this.mv = mv; @@ -327,9 +362,9 @@ namespace dezentrale.view */ this.Close(); } - private void btnCancel_Click(object sender, EventArgs e) - { - this.Close(); - } +// private void btnCancel_Click(object sender, EventArgs e) +// { +// this.Close(); + // } } } \ No newline at end of file