Skip to content

Commit 3d452c4

Browse files
committed
stupid console
1 parent aa78f8a commit 3d452c4

File tree

6 files changed

+59
-17
lines changed

6 files changed

+59
-17
lines changed

Slic3rPostProcessing/Program.cs

Lines changed: 50 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,18 @@ private static int Main(string[] args)
5050
bool booCounter = true;
5151
bool booResetCounter = false;
5252

53+
////// / / / / / / / / / / / / /
54+
// Log writer START
55+
Trace.AutoFlush = false;
56+
57+
Logger.traceSwitch.Level = (TraceLevel)verbosity;//TraceLevel.Info;
58+
Trace.Listeners.Clear();
59+
60+
TextWriterTraceListener listener = new TextWriterTraceListener(Console.Out);
61+
Trace.Listeners.Add(listener);
62+
63+
ConsoleWidth = Logger.GetConsoleWidth();
64+
5365
var p = new OptionSet() {
5466
{ "i|input=", "The {INPUTFILE} to process. " + Environment.NewLine + "If file extention is omitted, .gcode will be assumed.",
5567
v => strINputFile=v },
@@ -91,17 +103,6 @@ private static int Main(string[] args)
91103
return 1;
92104
}
93105

94-
////// / / / / / / / / / / / / /
95-
// Log writer START
96-
Trace.AutoFlush = true;
97-
ConsoleWidth = Logger.GetConsoleWidth();
98-
99-
Logger.traceSwitch.Level = (TraceLevel)verbosity;//TraceLevel.Info;
100-
Trace.Listeners.Clear();
101-
102-
TextWriterTraceListener listener = new TextWriterTraceListener(Console.Out);
103-
Trace.Listeners.Add(listener);
104-
105106
if (show_help)
106107
{
107108
ShowHelp(p);
@@ -129,9 +130,9 @@ private static int Main(string[] args)
129130
if (!WaitForFile(strINputFile, 30))
130131
{
131132
Console.WriteLine(" ");
132-
Logger.LogInfo("I assume there is no file:");
133+
Logger.LogWarning("I assume there is no file:");
133134
PrintFileSummary(strINputFile);
134-
Logger.LogInfo("Please try again later or check your input.");
135+
Logger.LogWarning("Please try again later or check your input.");
135136
#if DEBUG
136137
{
137138
Console.WriteLine("Press any key to continue . . .");
@@ -567,16 +568,30 @@ private static string TrimComment(string line)
567568

568569
private static void ShowHelp(OptionSet p)
569570
{
571+
ConsoleColor fg = Console.ForegroundColor;
572+
ConsoleColor bg = Console.BackgroundColor;
573+
570574
Console.WriteLine();
571-
Console.WriteLine("This program is for use with Slic3r or standalone.");
575+
Console.BackgroundColor = ConsoleColor.Black;
576+
Console.ForegroundColor = ConsoleColor.Yellow;
577+
578+
string textnote = "This program is for use with Slic3r (or standalone).";
579+
int textlength = textnote.Length;
580+
int paaad = (Program.ConsoleWidth - textlength) / 2;
581+
582+
Console.WriteLine("".PadLeft(paaad) + textnote.PadRight(Program.ConsoleWidth - paaad));
583+
Console.ResetColor();
572584
Console.WriteLine();
573585
Console.WriteLine("Slic3r -> Print Settings -> Output options");
574586
Console.WriteLine(" * Enable Verbose G-Code (!)");
575587
Console.WriteLine(" * Put full filename to " + Path.GetFileName(System.Reflection.Assembly.GetEntryAssembly().Location) + " in Post-Processing Scripts.");
576588
Console.WriteLine(" Current filename: \"" + System.Reflection.Assembly.GetEntryAssembly().Location + "\"");
577589

578590
Console.WriteLine();
579-
Console.WriteLine("Standalone usage: Slic3rPostProcessing [OPTIONS]");
591+
Console.BackgroundColor = ConsoleColor.Black;
592+
Console.ForegroundColor = ConsoleColor.Yellow;
593+
Console.WriteLine("Standalone usage: Slic3rPostProcessing [OPTIONS]".PadRight(Program.ConsoleWidth));
594+
Console.ResetColor();
580595
Console.WriteLine();
581596
Console.WriteLine("Options:");
582597
p.WriteOptionDescriptions(Console.Out);
@@ -651,21 +666,37 @@ internal class Logger
651666
private static int origBWidth { get; set; }
652667
private static int origBHeight { get; set; }
653668

669+
private static ConsoleColor fg = Console.ForegroundColor;
670+
private static ConsoleColor bg = Console.BackgroundColor;
671+
654672
public static int GetConsoleWidth()
655673
{
656-
return Console.WindowWidth;
674+
// IntPtr myHandle = Process.GetCurrentProcess().MainWindowHandle;
675+
// NOW WHAT?! What do I do with myHandle? I Need the console!
676+
677+
//return Console.WindowWidth;
678+
679+
return 80;
657680
}
658681

659682
public static void LogInfo(string message)
660683
{
661684
Trace.WriteLineIf(Logger.traceSwitch.TraceInfo, "Info : " + message);
662685
}
663686

687+
/// <summary>
688+
/// Overwrites current line
689+
/// </summary>
690+
/// <param name="message"></param>
664691
public static void LogInfoOverwrite(string message)
665692
{
666693
Console.Write("\r" + message);
667694
}
668695

696+
/// <summary>
697+
/// Writeline with datetime stamp
698+
/// </summary>
699+
/// <param name="message"></param>
669700
public static void Log(string message)
670701
{
671702
Trace.WriteLine(DateTime.Now + " : " + message);
@@ -678,7 +709,10 @@ public static void LogError(string message)
678709

679710
public static void LogWarning(string message)
680711
{
712+
Console.ForegroundColor = ConsoleColor.Yellow;
713+
Console.BackgroundColor = ConsoleColor.Black;
681714
Trace.WriteLineIf(Logger.traceSwitch.TraceWarning, "WARNING : " + message);
715+
Console.ResetColor();
682716
}
683717

684718
public static void LogError(Exception e)

Slic3rPostProcessing/S3erPP.ico

-9.11 KB
Binary file not shown.

Slic3rPostProcessing/S3erPP.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Pizza Cutter by Musket from the Noun Project
2+
https://thenounproject.com/term/pizza-cutter/106697/
3+
4+
# # # # # # # # # # # # # # # # # # # # # # # # # # #
5+
6+
https://creativecommons.org/licenses/by/3.0/
7+
* changed color

Slic3rPostProcessing/SPPIcon.ico

101 KB
Binary file not shown.

Slic3rPostProcessing/SPPIcon.pdn

12.5 KB
Binary file not shown.

Slic3rPostProcessing/Slic3rPostProcessing.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<StartupObject />
3737
</PropertyGroup>
3838
<PropertyGroup>
39-
<ApplicationIcon>S3erPP.ico</ApplicationIcon>
39+
<ApplicationIcon>SPPIcon.ico</ApplicationIcon>
4040
</PropertyGroup>
4141
<PropertyGroup>
4242
<NoWin32Manifest>true</NoWin32Manifest>
@@ -68,6 +68,7 @@
6868
</ItemGroup>
6969
<ItemGroup>
7070
<Content Include="S3erPP.ico" />
71+
<Content Include="SPPIcon.ico" />
7172
</ItemGroup>
7273
<ItemGroup>
7374
<None Include="app.config" />

0 commit comments

Comments
 (0)