Skip to content

Commit

Permalink
Add rebranding support
Browse files Browse the repository at this point in the history
  • Loading branch information
Jbob committed Dec 3, 2016
1 parent 700cec6 commit 8e1d8e1
Show file tree
Hide file tree
Showing 12 changed files with 81 additions and 64 deletions.
4 changes: 2 additions & 2 deletions MSI/Product.wxs
Expand Up @@ -20,14 +20,14 @@
-->

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:iis="http://schemas.microsoft.com/wix/IIsExtension">
<Product Id="*" Name="FOG Service" Language="1033" Version="0.11.5" UpgradeCode="1CCFDEAF-53E9-43AC-AE18-F9F86CEFA4EA"
<Product Id="*" Name="FOG Service" Language="1033" Version="0.11.6" UpgradeCode="1CCFDEAF-53E9-43AC-AE18-F9F86CEFA4EA"
Manufacturer="FOG">
<Package Description="FOG Service" Comments="A client for the FOG project" InstallerVersion="300" Compressed="yes"
InstallScope="perMachine" />
<!-- Remove old versions -->
<Upgrade Id="1CCFDEAF-53E9-43AC-AE18-F9F86CEFA4EA">
<UpgradeVersion OnlyDetect="yes" Minimum="0.0.0" Property="NEWERVERSIONDETECTED" IncludeMinimum="no" />
<UpgradeVersion OnlyDetect="no" Minimum="0.0.0" Maximum="0.11.4" Property="OLDERVERSIONBEINGUPGRADED"
<UpgradeVersion OnlyDetect="no" Minimum="0.0.0" Maximum="0.11.5" Property="OLDERVERSIONBEINGUPGRADED"
IncludeMinimum="no" IncludeMaximum="yes" MigrateFeatures="yes" />
</Upgrade>
<InstallExecuteSequence>
Expand Down
1 change: 0 additions & 1 deletion Service/FOGSystemService.cs
Expand Up @@ -22,7 +22,6 @@
using System.Diagnostics;
using System.IO;
using FOG.Modules.HostnameChanger;
using FOG.Modules.PowerManagement;
using FOG.Modules.PrinterManager;
using FOG.Modules.SnapinClient;
using FOG.Modules.TaskReboot;
Expand Down
30 changes: 10 additions & 20 deletions SetupHelper/GenericSetup.cs
Expand Up @@ -82,27 +82,17 @@ private static bool PinServerCertPreset(string location)
var filePath = Path.Combine(location, "settings.json");
try
{

if (File.Exists(filePath))
{
var settings = JObject.Parse(File.ReadAllText(filePath));
settings["Version"] = version;
File.WriteAllText(filePath, settings.ToString());
}
else
var settings = new JObject
{
var settings = new JObject
{
{"HTTPS", https},
{"Tray", usetray},
{"Server", webaddress},
{"WebRoot", webroot},
{"Version", version},
{"Company", company},
{"RootLog", rootLog}
};
File.WriteAllText(filePath, settings.ToString());
}
{ "HTTPS", https},
{ "Tray", usetray},
{ "Server", webaddress},
{ "WebRoot", webroot},
{ "Version", version},
{ "Company", company},
{ "RootLog", rootLog}
};
File.WriteAllText(filePath, settings.ToString());
return true;
}
catch (Exception ex)
Expand Down
25 changes: 12 additions & 13 deletions ShutdownGUI/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 44 additions & 9 deletions ShutdownGUI/MainForm.cs
Expand Up @@ -20,7 +20,9 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using MetroFramework.Components;
using Newtonsoft.Json.Linq;
using Zazzles;
using Zazzles.Data;
Expand All @@ -31,26 +33,28 @@ public partial class MainForm : Form
{
private const string LogName = "Shutdown GUI";
private const int OSXTitleBarHeight = 22;
private const string ProgressColor = "#00567a";

// Provide 5 different delay options, starting at 15 minutes
private const int NumberOfDelays = 5;
private const int StartingDelay = 15;

private readonly int _gracePeriod = 600;
private readonly dynamic _transport;
private Power.ShutdownOptions _options;
private int _aggregatedDelayTime;
private readonly Power.ShutdownOptions _options;
private readonly int _aggregatedDelayTime;

public MainForm(string[] args)
{
if (args.Length == 0) Environment.Exit(1);
//if (args.Length == 0) Environment.Exit(1);
Log.Output = Log.Mode.Quiet;

//_transport = new JObject();
//_transport.options = 1;
//_transport.aggregatedDelayTime = 0;
//_transport.period = 600;
_transport = JObject.Parse(Transform.DecodeBase64(args[0]));
_transport = new JObject();
_transport.options = Power.ShutdownOptions.Abort.ToString();
_transport.aggregatedDelayTime = 0;
_transport.period = 30;

//_transport = JObject.Parse(Transform.DecodeBase64(args[0]));
InitializeComponent();

// Retrieve what configuration the prompt should use
Expand All @@ -67,21 +71,52 @@ public MainForm(string[] args)

Log.Entry(LogName, _gracePeriod.ToString());
if (_gracePeriod == 0)
throw new Exception("Invaid gracePeriod");
return;

textBox1.Text = GenerateMessage();
textBox1.Select(0, 0);

progressBar1.Maximum = _gracePeriod - 1;
label1.Text = Time.FormatSeconds(_gracePeriod);

SetColors();
SwapBanner();
GenerateDelays();
PositionForm();

Bus.SetMode(Bus.Mode.Client);
Bus.Subscribe(Bus.Channel.Power, onPower);
}

private void SetColors()
{
var customColor = ColorTranslator.FromHtml(ProgressColor);
try
{
if (!string.IsNullOrEmpty(Settings.Get("Color")))
customColor = ColorTranslator.FromHtml(Settings.Get("Color"));
}
catch (Exception)
{

}

MetroStyleManager.Styles.AddStyle("Custom", customColor);
progressBar1.Style = "Custom";
}

private void SwapBanner()
{
var bannerPath = Path.Combine(Settings.Location, "banner.png");
if (!File.Exists(bannerPath))
return;
var bannerHash = Hash.SHA512(bannerPath);
if (bannerHash != Settings.Get("BannerHash"))
return;

bannerBox.Image = Image.FromFile(bannerPath);
}

private void GenerateDelays()
{
var delays = new SortedDictionary<int, string>();
Expand Down
2 changes: 1 addition & 1 deletion ShutdownGUI/MainForm.resx
Expand Up @@ -118,7 +118,7 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="pictureBox1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<data name="bannerBox.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAooAAAB4CAYAAAB1sdO3AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAN
1wAADdcBQiibeAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAADjvSURBVHhe7Z0H
Expand Down
13 changes: 5 additions & 8 deletions Tray/Tray.cs
Expand Up @@ -28,27 +28,24 @@ namespace FOG
{
public sealed class NotificationIcon
{
//Define variables
private readonly NotifyIcon _notifyIcon;
private const int DURATION = 10 * 1000;
/// <summary>Program entry point.</summary>
/// <param name="args">Command Line Arguments</param>
private const int Duration = 10 * 1000;

[STAThread]
public static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);

bool isFirstInstance;
// Please use a unique name for the mutex to prevent conflicts with other programs
using (new Mutex(true, "FOG-TRAY", out isFirstInstance))
{
if (!isFirstInstance) return;
var notificationIcon = new NotificationIcon();
notificationIcon._notifyIcon.Visible = true;
Application.Run();
notificationIcon._notifyIcon.Dispose();
} // releases the Mutex
}
}

private void IconDoubleClick(object sender, EventArgs e)
Expand All @@ -57,6 +54,7 @@ private void IconDoubleClick(object sender, EventArgs e)

public NotificationIcon()
{
Log.Output = Log.Mode.Quiet;
Eager.Initalize();
Bus.SetMode(Bus.Mode.Client);
Bus.Subscribe(Bus.Channel.Notification, OnNotification);
Expand Down Expand Up @@ -88,7 +86,7 @@ private void OnNotification(dynamic data)
{
_notifyIcon.BalloonTipTitle = data.title;
_notifyIcon.BalloonTipText = data.message;
_notifyIcon.ShowBalloonTip(DURATION);
_notifyIcon.ShowBalloonTip(Duration);
}
catch (Exception)
{
Expand All @@ -108,6 +106,5 @@ private static MenuItem[] InitializeMenu()
var menu = new MenuItem[] { };
return menu;
}

}
}
2 changes: 1 addition & 1 deletion UniversalInstaller/Helper.cs
Expand Up @@ -28,7 +28,7 @@ namespace FOG
public static class Helper
{
private const string LogName = "Installer";
public const string ClientVersion = "0.11.5";
public const string ClientVersion = "0.11.6";

public static IInstall Instance { get; }

Expand Down
5 changes: 1 addition & 4 deletions UniversalInstaller/UniversalInstaller.cs
Expand Up @@ -100,13 +100,10 @@ private static void PerformUpgrade()
{
Log.Output = Log.Mode.File;
var settingsFile = Path.Combine(Settings.Location, "settings.json");

Settings.SetPath(settingsFile);
Settings.Set("Version", Helper.ClientVersion, false);

Install(Settings.Get("HTTPS"), Settings.Get("Tray"), Settings.Get("Server"),
Settings.Get("WebRoot"), Settings.Get("Company"), Settings.Get("RootLog"),
true);
Settings.Get("WebRoot"), Settings.Get("Company"), Settings.Get("RootLog"));

File.Copy(settingsFile,
Path.Combine(Helper.Instance.GetLocation(), "settings.json"), true);
Expand Down
10 changes: 5 additions & 5 deletions UserService/FOGUserService.cs
Expand Up @@ -86,11 +86,11 @@ protected override Response GetLoopData()
{
Settings.Reload();

var alo = -1;
var displayX = -1;
var displayY = -1;
var displayR = -1;
var printer = "";
int alo;
int displayX;
int displayY;
int displayR;
string printer;

int.TryParse(Settings.Get("ALOTime"), out alo);
printer = Settings.Get("DefaultPrinter");
Expand Down
Binary file modified libs/MetroFramework.dll
Binary file not shown.
Binary file modified libs/Zazzles.dll
Binary file not shown.

0 comments on commit 8e1d8e1

Please sign in to comment.