Skip to content

Commit

Permalink
New notification module with images included
Browse files Browse the repository at this point in the history
  • Loading branch information
unholyHub committed Jan 13, 2016
1 parent e548355 commit af15a38
Show file tree
Hide file tree
Showing 16 changed files with 1,136 additions and 100 deletions.
101 changes: 101 additions & 0 deletions Classes/Notifications/ProgramStatus.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
using System;
using System.Collections.Generic;
using TeamViewerPopupBlocker.Forms;
using TeamViewerPopupBlocker.Properties;

namespace TeamViewerPopupBlocker.Classes.Notifications
{
public sealed class ProgramStatus
{
private static ProgramStatus instance = null;

private static readonly object syncRoot = new Object();

public static ProgramStatus Instance
{
get
{
lock (syncRoot)
{
return instance ?? (instance = new ProgramStatus());
}
}
}

private List<Status> statusList = new List<Status>();

private DateTime tTimeStatusReady = DateTime.Now;

public void AddStatus(Status srcStatus)
{
statusList.Add(srcStatus);
}

public void GetStatus(MainForm mainForm)
{
if (statusList.Count <= 0) return;

bool tContnue = DateTime.Now > tTimeStatusReady;

if (!tContnue) return;

Status status = statusList[0].Clone();

if (status == null)
{
return;
}

if (status.TimeOutMinimum > 0)
{
this.tTimeStatusReady = DateTime.Now.AddMilliseconds(status.TimeOutMinimum);
}

switch (status.StatusType)
{
case StatusType.StartBlocking:
{
mainForm.ShowNotificationMessage(status.StatusType,
Resources.ProgramStatus_GetStatus_Blocking_started, status.TimeOut);
break;
}

case StatusType.StopBlocking:
{
mainForm.ShowNotificationMessage(status.StatusType,
Resources.ProgramStatus_GetStatus_Blocking_stopped, status.TimeOut);
break;
}

case StatusType.ErrorException:
{
mainForm.ShowNotificationMessage(status.StatusType,
Resources.ProgramStatus_GetStatus_Exception_was_thrown_, status.TimeOut);
break;
}

case StatusType.InfoUpToDate:
{
mainForm.ShowNotificationMessage(
status.StatusType,
Resources.Your_version_is_up_to_date,
status.TimeOut);
break;
}

case StatusType.InfoUpdate:
{
mainForm.ShowNotificationMessage(
status.StatusType,
status.AdditionalInformation,
status.TimeOut);

break;
}

}

this.statusList.RemoveAt(0);
}
}
}
41 changes: 41 additions & 0 deletions Classes/Notifications/Status.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System;

namespace TeamViewerPopupBlocker.Classes.Notifications
{
public class Status : ICloneable
{
public Status()
{
this.StatusType = StatusType.Unknown;
this.TimeOut = 0;
this.TimeOutMinimum = 0;
this.AdditionalInformation = "";
}

public Status(StatusType status, int timeOut, int timeOutMinimum = 0, string additionalInformation = "")
{
this.StatusType = status;
this.TimeOut = timeOut;
this.TimeOutMinimum = timeOutMinimum;
this.AdditionalInformation = additionalInformation;
}

public StatusType StatusType { get; set; }

public int TimeOut { get; set; }

public int TimeOutMinimum { get; set; }

public string AdditionalInformation { get; set; }

object ICloneable.Clone()
{
return this.Clone();
}

public Status Clone()
{
return (Status)this.MemberwiseClone();
}
}
}
17 changes: 17 additions & 0 deletions Classes/Notifications/StatusType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace TeamViewerPopupBlocker.Classes.Notifications
{
public enum StatusType
{
Unknown = 0,

StartBlocking,

StopBlocking,

ErrorException,

InfoUpdate,

InfoUpToDate
}
}
Loading

0 comments on commit af15a38

Please sign in to comment.