Files
UVtools/UVtools.GUI/Program.cs
T
Tiago Conceição fa5073e68f v0.6.6.1
* (Add) Elapsed time to the Log list
* (Add) Setting - Issues - Islands: Allow diagonal bonds with default to false (#22)
* (Change) Tool - Repair Layers: Allow set both iterations to 0 to skip closing and opening operations and allow remove islands independently
* (Change) Title - file open time from miliseconds to seconds
* (Improvement) Tool - Repair Layers: Layer image will only read/save if required and if current layer got modified
* (Fix) Setting - Issues - Islands: "Pixels below this value will turn black, otherwise white" (Threshold) was not using the set value and was forcing 1
* (Fix) Remove duplicated log for repair layers and issues
2020-08-17 22:01:06 +01:00

103 lines
3.7 KiB
C#

/*
* GNU AFFERO GENERAL PUBLIC LICENSE
* Version 3, 19 November 2007
* Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
* Everyone is permitted to copy and distribute verbatim copies
* of this license document, but changing it is not allowed.
*/
using System;
using System.Diagnostics;
using System.Drawing;
using System.Globalization;
using System.Threading;
using System.Windows.Forms;
using ApplicationManagement;
using Emgu.CV;
using UVtools.Core;
using UVtools.Core.FileFormats;
using UVtools.GUI.Forms;
namespace UVtools.GUI
{
static class Program
{
/// <summary>
/// Changes fonts of controls contained in font collection recursively. <br/>
/// <b>Usage:</b> <c><br/>
/// SetAllControlsFont(this.Controls, 20); // This makes fonts 20% bigger. <br/>
/// SetAllControlsFont(this.Controls, -4, false); // This makes fonts smaller by 4.</c>
/// </summary>
/// <param name="ctrls">Control collection containing controls</param>
/// <param name="amount">Amount to change: posive value makes it bigger,
/// negative value smaller</param>
/// <param name="amountInPercent">True - grow / shrink in percent,
/// False - grow / shrink absolute</param>
/// <param name="amountType">0 = Absolute | 1 = Partial | 2 = Percent</param>
public static void SetAllControlsFontSize(
Control.ControlCollection ctrls,
int amount = 0, byte amountType = 0)
{
if (amount == 0) return;
foreach (Control ctrl in ctrls)
{
// recursive
SetAllControlsFontSize(ctrl.Controls, amount, amountType);
var oldSize = ctrl.Font.Size;
float newSize;
switch (amountType)
{
case 1:
newSize = oldSize + amount;
break;
case 2:
newSize = oldSize + oldSize * (amount / 100);
break;
default:
newSize = amount;
break;
}
if (newSize < 8) newSize = 8; // don't allow less than 8
var fontFamilyName = ctrl.Font.FontFamily.Name;
var fontStyle = ctrl.Font.Style;
ctrl.Font = new Font(fontFamilyName, newSize, fontStyle);
};
}
public static FileFormat SlicerFile { get; set; }
public static FrmMain FrmMain { get; private set; }
public static FrmAbout FrmAbout { get; private set; }
public static ExceptionHandler ExceptionHandler { get; private set; }
public static string[] Args { get; private set; }
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
Args = args;
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-GB");
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
ExceptionHandler = new ExceptionHandler {MessageBoxButtons = MessageBoxButtons.OK};
ExceptionHandler.StartHandlingExceptions();
FrmMain = new FrmMain();
FrmAbout = new FrmAbout();
Application.Run(FrmMain);
}
public static void NewInstance(string filePath)
{
var info = new ProcessStartInfo(Application.ExecutablePath, $"\"{filePath}\"");
Process.Start(info);
}
}
}