Skip to content

Commit a9b02ac

Browse files
committed
adds sort by date and include only notifications that pass checks
1 parent 9c6c13f commit a9b02ac

File tree

5 files changed

+182
-193
lines changed

5 files changed

+182
-193
lines changed
1.56 KB
Binary file not shown.

Source/Menu/MainForm.cs

Lines changed: 22 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ void MainForm_Shown(object sender, EventArgs e)
136136
{
137137
var options = Environment.GetCommandLineArgs().Where(a => (a.StartsWith("-") || a.StartsWith("/"))).Select(a => a.Substring(1));
138138
Settings = new UserSettings(options);
139-
NotificationManager = new NotificationManager(this, UpdateManager, Settings);
140139

141140
LoadOptions();
142141
LoadLanguage();
@@ -245,6 +244,13 @@ orderby tool.Text
245244
}
246245
else
247246
buttonDocuments.Enabled = false;
247+
248+
NotificationManager = new NotificationManager(this, UpdateManager, Settings, panelDetails
249+
, (Image)Resources.GetObject("Notification_previous")
250+
, (Image)Resources.GetObject("Notification_next")
251+
, (Image)Resources.GetObject("Notification_first")
252+
, (Image)Resources.GetObject("Notification_last")
253+
);
248254
}
249255

250256
ShowEnvironment();
@@ -1443,13 +1449,6 @@ void comboBoxTimetable_EnabledChanged(object sender, EventArgs e)
14431449
}
14441450

14451451
#region NotificationPages
1446-
public int CurrentNotificationNo = 0;
1447-
private bool firstVisible = true;
1448-
private bool previousVisible = false;
1449-
private bool lastVisible = false;
1450-
private bool nextVisible = true;
1451-
1452-
14531452
private void pbNotificationsNone_Click(object sender, EventArgs e)
14541453
{
14551454
ToggleNotificationPages();
@@ -1480,111 +1479,51 @@ private void ToggleNotificationPages()
14801479

14811480
private void FiddleNewNotificationPageCount()
14821481
{
1483-
//NotificationManager.LastPageViewed = 1;
1482+
//NotificationManager.LastPageViewed = 1; //TODO
14841483
UpdateNotificationPageAlert();
14851484
}
14861485

1487-
public void UpdateNotificationPageAlert()
1488-
{
1489-
if (NotificationManager.LastPageViewed >= NotificationManager.NewPageCount)
1490-
{
1491-
pbNotificationsSome.Visible = false;
1492-
lblNotificationCount.Visible = false;
1493-
}
1494-
}
1495-
1496-
void ShowNotificationPages()
1486+
public void ShowNotificationPages()
14971487
{
14981488
Win32.LockWindowUpdate(Handle);
14991489
ClearPanel();
15001490
NotificationManager.PopulatePage();
1501-
var notificationPage = GetCurrentNotificationPage();
1502-
notificationPage.FlowNDetails();
1491+
UpdateNotificationPageAlert();
1492+
NotificationManager.Page.FlowNDetails();
15031493
Win32.LockWindowUpdate(IntPtr.Zero);
15041494
}
15051495

1506-
/// <summary>
1507-
/// INCOMPLETE
1508-
/// </summary>
1509-
/// <returns></returns>
1510-
NotificationPage GetCurrentNotificationPage()
1511-
{
1512-
return NotificationManager.Page;
1513-
}
1514-
1515-
/// <summary>
1516-
/// Returns a new notificationPage with default images and label
1517-
/// </summary>
1518-
/// <returns></returns>
1519-
public NotificationPage CreateNotificationPage()
1520-
// Located in MainForm to get access to MainForm.Resources
1496+
public void UpdateNotificationPageAlert()
15211497
{
1522-
var previousImage = (Image)Resources.GetObject("Notification_previous");
1523-
var nextImage = (Image)Resources.GetObject("Notification_next");
1524-
var firstImage = (Image)Resources.GetObject("Notification_first");
1525-
var lastImage = (Image)Resources.GetObject("Notification_last");
1526-
var pageCount = $"{CurrentNotificationNo + 1}/{NotificationManager.Notifications.NotificationList.Count}";
1527-
return new NotificationPage(this, panelDetails, nextImage, previousImage, firstImage, lastImage, pageCount,
1528-
previousVisible, firstVisible, nextVisible, lastVisible);
1498+
if (NotificationManager.LastPageViewed >= NotificationManager.NewPageCount)
1499+
{
1500+
pbNotificationsSome.Visible = false;
1501+
lblNotificationCount.Visible = false;
1502+
}
15291503
}
15301504

15311505
// 3 should be enough, but is there a way to get unlimited buttons?
15321506
public void Button0_Click(object sender, EventArgs e)
15331507
{
1534-
GetCurrentNotificationPage().DoButton(UpdateManager, 0);
1508+
NotificationManager.Page.DoButton(UpdateManager, 0);
15351509
}
15361510
public void Button1_Click(object sender, EventArgs e)
15371511
{
1538-
GetCurrentNotificationPage().DoButton(UpdateManager, 1);
1512+
NotificationManager.Page.DoButton(UpdateManager, 1);
15391513
}
15401514
public void Button2_Click(object sender, EventArgs e)
15411515
{
1542-
GetCurrentNotificationPage().DoButton(UpdateManager, 2);
1516+
NotificationManager.Page.DoButton(UpdateManager, 2);
15431517
}
15441518

15451519
public void Next_Click(object sender, EventArgs e)
15461520
{
1547-
ChangePage(1);
1548-
// GetCurrentNotificationPage().DoNext(1);
1521+
NotificationManager.ChangePage(1);
15491522
}
15501523

15511524
public void Previous_Click(object sender, EventArgs e)
15521525
{
1553-
ChangePage(-1);
1554-
//GetCurrentNotificationPage().DoNext(-1);
1555-
}
1556-
1557-
private void ChangePage(int step)
1558-
{
1559-
SetVisibility(step);
1560-
CurrentNotificationNo += step;
1561-
ShowNotificationPages();
1562-
}
1563-
1564-
private void SetVisibility(int step)
1565-
{
1566-
if (step < 0)
1567-
{
1568-
if (CurrentNotificationNo + step <= 0)
1569-
{
1570-
previousVisible = false;
1571-
firstVisible = true;
1572-
return;
1573-
}
1574-
}
1575-
else
1576-
{
1577-
if (CurrentNotificationNo + step >= NotificationManager.Notifications.NotificationList.Count - 1)
1578-
{
1579-
nextVisible = false;
1580-
lastVisible = true;
1581-
return;
1582-
}
1583-
}
1584-
nextVisible = true;
1585-
lastVisible = false;
1586-
previousVisible = true;
1587-
firstVisible = false;
1526+
NotificationManager.ChangePage(-1);
15881527
}
15891528

15901529
#endregion NotificationPages

0 commit comments

Comments
 (0)