1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Security.Principal;
- using Microsoft.Win32;
- using System.IO;
- using System.Security.Cryptography;
- using System.Reflection;
- namespace Optimizer
- {
- static class Program
- {
- /* VERSION PROPERTIES */
- /* DO NOT LEAVE THEM EMPTY */
- // Enter current version here
- internal readonly static float Major = 4;
- internal readonly static float Minor = 3;
- internal static string GetCurrentVersionTostring()
- {
- return Major.ToString() + "." + Minor.ToString();
- }
- internal static float GetCurrentVersion()
- {
- return float.Parse(GetCurrentVersionTostring());
- }
- /* END OF VERSION PROPERTIES */
- internal static MainForm MainForm;
- readonly static string _adminMissingMessage = "Optimizer needs to be run as administrator!\nApp will now close...";
- readonly static string _unsupportedMessage = "Optimizer works in Windows 7 or higher!\nApp will now close...";
- [STAThread]
- static void Main()
- {
- Application.EnableVisualStyles();
- Application.SetCompatibleTextRenderingDefault(false);
- if (!Utilities.IsAdmin())
- {
- HelperForm f = new HelperForm(null, MessageType.Error, _adminMissingMessage);
- f.ShowDialog();
- Application.Exit();
- }
- else
- {
- if (Utilities.IsCompatible())
- {
- string resource = "Optimizer.Newtonsoft.Json.dll";
- EmbeddedAssembly.Load(resource, "Newtonsoft.Json.dll");
- AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
- if (!Directory.Exists(Required.CoreFolder))
- {
- Required.Deploy();
- }
- // for backward compatibility
- if (File.Exists(Options.SettingsFile))
- {
- if (File.ReadAllText(Options.SettingsFile).Contains("FirstRun"))
- {
- File.Delete(Options.SettingsFile);
- }
- }
- // load settings, if there is no settings, load defaults
- Options.LoadSettings();
- Application.Run(new MainForm());
- }
- else
- {
- HelperForm f = new HelperForm(null, MessageType.Error, _unsupportedMessage);
- f.ShowDialog();
- Application.Exit();
- }
- }
- }
- static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
- {
- return EmbeddedAssembly.Get(args.Name);
- }
- }
- }
|