Marked as 'AdvertsingProfitControl No Print' by its folder name. Updated the 'Mordify Record' form. I believe the 'No Print' was related to creating a PDF version of the Advertising Profit Control sheet. The next version after this was most likely to have the code for that.
This commit is contained in:
@@ -7,7 +7,8 @@ namespace AdvertsingProfitControl
|
||||
public sealed partial class FrmLogConsole : Form
|
||||
{
|
||||
//Source code: https://hashfactor.wordpress.com/2009/03/31/c-winforms-create-a-single-instance-form/
|
||||
private static bool _gIsShown;
|
||||
private static readonly FrmLogConsole gLogConsoleInstance = new FrmLogConsole();
|
||||
private static bool gIsShown = false;
|
||||
|
||||
public FrmLogConsole()
|
||||
{
|
||||
@@ -17,18 +18,16 @@ namespace AdvertsingProfitControl
|
||||
logListView.View = View.Details;
|
||||
//Information for drawing header columns and sub-items in ListView:
|
||||
//http://stackoverflow.com/questions/561798/how-do-i-align-text-for-a-single-subitem-in-a-listview-using-c
|
||||
var header = new ColumnHeader
|
||||
{
|
||||
Text = @"Advertising Profit Control " + Application.ProductVersion + @" Debug Console",
|
||||
Name = "LogConsoleHeader",
|
||||
Width = logListView.Width
|
||||
};
|
||||
ColumnHeader header = new ColumnHeader();
|
||||
header.Text = "Advertising Profit Control " + Application.ProductVersion + " Debug Console";
|
||||
header.Name = "LogConsoleHeader";
|
||||
header.Width = logListView.Width;
|
||||
logListView.Columns.Add(header);
|
||||
}
|
||||
|
||||
static FrmLogConsole()
|
||||
{
|
||||
GetStaticInstance.FormClosing += LogConsole_FormClosing;
|
||||
GetStaticInstance.FormClosing += new FormClosingEventHandler(LogConsole_FormClosing);
|
||||
//Set the maximum and minimum size of the form.
|
||||
GetStaticInstance.MaximumSize = new Size(900, 900);
|
||||
GetStaticInstance.MinimumSize = new Size(400, 400);
|
||||
@@ -36,25 +35,27 @@ namespace AdvertsingProfitControl
|
||||
|
||||
public new void Show()
|
||||
{
|
||||
if (_gIsShown)
|
||||
if (gIsShown)
|
||||
{
|
||||
base.Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
base.Show();
|
||||
_gIsShown = true;
|
||||
gIsShown = true;
|
||||
}
|
||||
}
|
||||
|
||||
public new void Hide()
|
||||
{
|
||||
if (!_gIsShown) return;
|
||||
base.Hide();
|
||||
_gIsShown = false;
|
||||
if (gIsShown)
|
||||
{
|
||||
base.Hide();
|
||||
gIsShown = false;
|
||||
}
|
||||
}
|
||||
|
||||
public enum Level
|
||||
public enum Level : int
|
||||
{
|
||||
Critical = 0,
|
||||
Error = 1,
|
||||
@@ -67,6 +68,7 @@ namespace AdvertsingProfitControl
|
||||
public void WriteToLog(Level level, string message)
|
||||
{
|
||||
Color color;
|
||||
int index;
|
||||
|
||||
switch (level)
|
||||
{
|
||||
@@ -85,17 +87,14 @@ namespace AdvertsingProfitControl
|
||||
case Level.Verbose:
|
||||
color = Color.Blue;
|
||||
break;
|
||||
case Level.Debug:
|
||||
color = Color.Black;
|
||||
break;
|
||||
default:
|
||||
color = Color.Black;
|
||||
break;
|
||||
}
|
||||
var index = logListView.Items.Count;
|
||||
index = logListView.Items.Count;
|
||||
try
|
||||
{
|
||||
message = $"{level}: {message}";
|
||||
message = String.Format("{0}: {1}", level, message);
|
||||
if (level != Level.Info)
|
||||
{
|
||||
GlobalClasses.WriteToLog(DateTime.Now + ": " + message + Environment.NewLine);
|
||||
@@ -108,17 +107,13 @@ namespace AdvertsingProfitControl
|
||||
MessageBox.Show(e.Message);
|
||||
}
|
||||
|
||||
switch (level)
|
||||
if (level == Level.Critical)
|
||||
{
|
||||
case Level.Critical:
|
||||
logListView.Items[index].BackColor = Color.Red;
|
||||
break;
|
||||
case Level.Error:
|
||||
logListView.Items[index].ForeColor = Color.Maroon;
|
||||
break;
|
||||
default:
|
||||
logListView.Items[index].BackColor = Color.WhiteSmoke;
|
||||
break;
|
||||
logListView.Items[index].BackColor = Color.Red;
|
||||
}
|
||||
else
|
||||
{
|
||||
logListView.Items[index].BackColor = Color.WhiteSmoke;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,11 +121,17 @@ namespace AdvertsingProfitControl
|
||||
{
|
||||
e.Cancel = true;
|
||||
GetStaticInstance.Hide();
|
||||
_gIsShown = false;
|
||||
gIsShown = false;
|
||||
}
|
||||
|
||||
public static FrmLogConsole GetStaticInstance { get; } = new FrmLogConsole();
|
||||
public static FrmLogConsole GetStaticInstance
|
||||
{
|
||||
get { return gLogConsoleInstance; }
|
||||
}
|
||||
|
||||
public bool IsVisable => _gIsShown;
|
||||
public bool IsVisable
|
||||
{
|
||||
get { return gIsShown; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user