Skip to content

Commit

Permalink
Add project files.
Browse files Browse the repository at this point in the history
  • Loading branch information
ClemeK committed Oct 29, 2022
1 parent 87e34d2 commit 5069c57
Show file tree
Hide file tree
Showing 43 changed files with 3,629 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) [year] [fullname]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
59 changes: 59 additions & 0 deletions MinuteTaker/AgendaReport.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<Window x:Class="MinuteTaker.AgendaReport"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="Agenda Report" Height="650" Width="850" WindowStartupLocation="CenterScreen">
<ScrollViewer VerticalScrollBarVisibility="Auto">
<StackPanel>

<StackPanel Orientation="Horizontal">
<Label Content="From User:" Width="85" FontWeight="Bold" />
<TextBox x:Name="tbUserName" Width="710" VerticalAlignment="Center" DataContextChanged="DataChanged"/>
</StackPanel>

<StackPanel Orientation="Horizontal">
<Label Content="Password:" Width="85" FontWeight="Bold" />
<PasswordBox x:Name="pbPassword" Width="710" PasswordChar="*" VerticalAlignment="Center" DataContextChanged="DataChanged"/>
</StackPanel>

<StackPanel Orientation="Horizontal">
<Label Content="From eMail:" Width="85" FontWeight="Bold" />
<TextBox x:Name="tbUseremail" Width="710" VerticalAlignment="Center" DataContextChanged="DataChanged"/>
</StackPanel>

<StackPanel Orientation="Horizontal">
<Label Content="Subject:" Width="85" FontWeight="Bold" />
<TextBox x:Name="tbSubject" Width="710" VerticalAlignment="Center" />
</StackPanel>

<StackPanel Orientation="Horizontal">
<Label Content="Message:" Width="85" FontWeight="Bold" />
<TextBox x:Name="tbBody" Height="50" Width="710" TextWrapping="Wrap" />
</StackPanel>

<StackPanel Orientation="Horizontal">
<Label Content="Attachment:" Width="85" FontWeight="Bold" />
<TextBox x:Name="tbFilename" Width="710" IsReadOnly="True"
Foreground="Red" FontStyle="Italic"
MouseDoubleClick="lbFilename_MouseDoubleClick" TextDecorations="Underline"/>
</StackPanel>

<RichTextBox x:Name="RTBox" IsReadOnly="True" FontFamily="Calibri" FontSize="12" VerticalScrollBarVisibility="Visible" />

<StackPanel Orientation="Horizontal">
<Label Content="SMTP:" Width="85" FontWeight="Bold" />
<ComboBox x:Name="cbSmtp" Width="150" VerticalAlignment="Center" SelectionChanged="cbSmtp_SelectionChanged" />
<Label Content="Host:" Width="45" FontWeight="Bold" />
<TextBox x:Name="tbHost" Width="150" VerticalAlignment="Center" />
<Label Content="Port:" Width="45" FontWeight="Bold" />
<TextBox x:Name="tbPort" Width="150" VerticalAlignment="Center" />
<Label Content="SSL:" Width="45" FontWeight="Bold" />
<TextBox x:Name="tbSSL" Width="50" VerticalAlignment="Center" />
</StackPanel>

<Button x:Name="btnSend" Content="Send" FontWeight="Bold" Margin="5" Padding="4" VerticalAlignment="Center" Click="btnSend_Click" />
</StackPanel>
</ScrollViewer>
</Window>
288 changes: 288 additions & 0 deletions MinuteTaker/AgendaReport.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,288 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Windows;
using System.Windows.Documents;

namespace MinuteTaker
{
/// <summary>
/// Interaction logic for AgendaReport.xaml
/// </summary>
public partial class AgendaReport : Window
{
private static string temp = "";
private static bool minutes = false;
private static int gangId = -1;
private static bool changed = false;
private string fileName = "";

private List<SmtpsModel> SmtpList = new();

public AgendaReport(AgendaModel agenda, bool type)
{
InitializeComponent();

temp = agenda.Title;
minutes = type;
gangId = agenda.GangId;

if (minutes == false)
{
tbSubject.Text = "Meeting Reminder";
tbBody.Text = $"Reminder that the {agenda.Title} meeting is on the {agenda.Day}/{agenda.Month}/{agenda.Year}" +
$" at {agenda.Hour}:{agenda.Minute}, I have attached the agenda for the meeting.";
}
else
{
tbSubject.Text = "Meeting Minutes";
tbBody.Text = $"Please find attached the minutes for the {agenda.Title} meeting that took place" +
$" on the {agenda.Day}/{agenda.Month}/{agenda.Year} at {agenda.Hour}:{agenda.Minute}.";
}

WireUpSmtpList();

tbUserName.Text = MinuteTakerLibary.AppKeyLookup("senderName");
tbUseremail.Text = MinuteTakerLibary.AppKeyLookup("senderEmail");
cbSmtp.SelectedItem = MinuteTakerLibary.AppKeyLookup("Host");
pbPassword.Password = MinuteTakerLibary.AppKeyLookup("senderPassword");

CreateRTF(agenda);

SaveRFT();

tbFilename.Text = fileName;

changed = false;
}

private void WireUpSmtpList()
{
cbSmtp.Items.Clear();

SmtpList = MinuteTakerLibary.LoadSmtps();

foreach (var s in SmtpList)
{
cbSmtp.Items.Add(s.Name);
}

cbSmtp.SelectedValue = "Local Host";
}

private void CreateRTF(AgendaModel agenda)
{
FlowDocument mcFlowDoc = new FlowDocument();

// Add the Title and Date & Time of the meeting
Paragraph head = new Paragraph();
head.FontSize = 48;
head.Inlines.Add(new Bold(new Run(agenda.Title)));
head.TextAlignment = TextAlignment.Center;

// This is done to add a line feed to the RTF out \n\r does appear to work
string newline = "\u2028";

Paragraph para = new Paragraph();
para.FontSize = 14;
para.Inlines.Add(new Bold(new Run("Date: ")));
para.Inlines.Add(new Run(agenda.Day + "/" + agenda.Month + "/" + agenda.Year + newline));
para.Inlines.Add(new Bold(new Run("Time: ")));
para.Inlines.Add(new Run(agenda.Hour + ":" + agenda.Minute.ToString("00") + newline));
para.Inlines.Add(new Bold(new Run("Location: ")));
para.Inlines.Add(new Run(agenda.Location + newline + newline));

if (minutes == true)
{
if (agenda.Attendees.Count > 0)
{
// List the expected attendees
para.Inlines.Add(new Bold(new Run("Attendees: ")));
string attn = "";

foreach (var m in agenda.Attendees)
{
attn += m.FullName() + ", ";
}

attn = attn.Substring(0, attn.Length - 2);
para.Inlines.Add(new Run(attn + newline + newline));
}

if (agenda.NonAttendees.Count > 0)
{
// List the Non-attendees
para.Inlines.Add(new Bold(new Run("Not Present: ")));
string nonattn = "";

foreach (var m in agenda.NonAttendees)
{
nonattn += m.FullName() + ", ";
}

if (agenda.Apologies.Count > 0)
{
foreach (var m in agenda.Apologies)
{
nonattn += m.FullName() + ", ";
}

nonattn = nonattn.Substring(0, nonattn.Length - 2);
para.Inlines.Add(new Run(nonattn + newline + newline));
}
}
}
else
{
GangModel gm = new();
gm = MinuteTakerLibary.GetGang(agenda.GangId);

para.Inlines.Add(new Bold(new Run("Attendees: ")));
string attn = "";

foreach (var m in gm.Members)
{
attn += m.FullName() + ", ";
}

attn = attn.Substring(0, attn.Length - 2);
para.Inlines.Add(new Run(attn + newline + newline));
}

// List the Topic of the meeting
foreach (var t in agenda.Topics)
{
para.Inlines.Add(new Bold(new Run(t.ItemNbr.ToString() + ") " + t.Heading + newline)));

if (minutes == true)
{
para.Inlines.Add(new Run(t.Detail + newline + newline));
}
}

// Display the Document
mcFlowDoc.Blocks.Add(head);
mcFlowDoc.Blocks.Add(para);
RTBox.Document = mcFlowDoc;
}

private void cbSmtp_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
int SIndex = cbSmtp.SelectedIndex;

if (SIndex > -1)
{
if (SmtpList[SIndex].Name != "Other")
{
tbHost.Text = SmtpList[SIndex].Url;
tbHost.IsEnabled = false;
tbPort.Text = SmtpList[SIndex].Port.ToString();
tbPort.IsEnabled = false;
tbSSL.Text = SmtpList[SIndex].Ssl;
tbSSL.IsEnabled = false;
}
else
{
tbHost.Text = "";
tbHost.IsEnabled = true;
tbPort.Text = "";
tbPort.IsEnabled = true;
tbSSL.Text = "";
tbSSL.IsEnabled = true;
}

changed = true;
}
}

private void DataChanged(object sender, DependencyPropertyChangedEventArgs e)
{
changed = true;
}

private void btnSend_Click(object sender, RoutedEventArgs e)
{

if (changed)
{
// Save the User\Password
MinuteTakerLibary.UpdateKeyLookup("senderName", tbUserName.Text.Trim());
MinuteTakerLibary.UpdateKeyLookup("senderEmail", tbUseremail.Text.Trim());
MinuteTakerLibary.UpdateKeyLookup("senderPassword", pbPassword.Password.Trim());
MinuteTakerLibary.UpdateKeyLookup("Host", tbHost.Text.Trim());

changed = false;
}

//SaveRFT();

GangModel g = new GangModel();
g = MinuteTakerLibary.GetGang(gangId);

int SIndex = cbSmtp.SelectedIndex;

if (SIndex > -1)
{
if (SmtpList[SIndex].Name == "Other")
{
SmtpList[SIndex].Url = tbHost.Text.Trim();
SmtpList[SIndex].Port = int.Parse(tbPort.Text);
SmtpList[SIndex].Url = tbHost.Text.Trim();
}

FluentEmailLogic.SendEmailToGroupWithAttachment(SmtpList[SIndex], g.Members, tbSubject.Text, tbBody.Text, fileName);
}
}

private void SaveRFT()
{
string reportType = "agenda";

if (minutes == true)
{
reportType = "minutes";
}

string path = @"Docs\";
fileName = path + temp + $" - {reportType}.rtf";

// Check if the directory exist and if not create it
if (Directory.Exists(path) == false)
{
Directory.CreateDirectory(path);
}

// Save the Document
TextRange range;
FileStream fStream;
range = new TextRange(RTBox.Document.ContentStart, RTBox.Document.ContentEnd);
fStream = new FileStream(fileName, FileMode.Create);
range.Save(fStream, DataFormats.Rtf);
fStream.Close();
}

private void lbFilename_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
if (fileName != "")
{
FileInfo fileInfo = new FileInfo(fileName);
var folderPath = Path.GetDirectoryName(fileName);

if (Directory.Exists(folderPath))
{
ProcessStartInfo startInfo = new ProcessStartInfo
{
Arguments = folderPath,
FileName = "explorer.exe"
};

Process.Start(startInfo);
}
else
{
MessageBox.Show(string.Format("{0} Directory does not exist!", folderPath));
}
}
}
}
}
Loading

0 comments on commit 5069c57

Please sign in to comment.