Пример #1
0
        static void Main(string[] args)
        {
            var settingsFileName = Path.Combine(AssemblyUtils.AssemblyDirectory, "SmartSystemMenu.xml");
            var languageFileName = Path.Combine(AssemblyUtils.AssemblyDirectory, "Language.xml");

#if WIN32
            var windowFileName = Path.Combine(AssemblyUtils.AssemblyDirectory, "Window.xml");
#else
            var windowFileName = Path.Combine(AssemblyUtils.AssemblyDirectory, "Window64.xml");
#endif

            var settings       = File.Exists(settingsFileName) && File.Exists(languageFileName) ? SmartSystemMenuSettings.Read(settingsFileName, languageFileName) : new SmartSystemMenuSettings();
            var windowSettings = File.Exists(windowFileName) ? WindowSettings.Read(windowFileName) : new WindowSettings();

            // Enable High DPI Support
            if (settings.EnableHighDPI)
            {
                SystemUtils.EnableHighDPISupport();
            }

            // Command Line Interface
            var toggleParser = new ToggleParser(args);
            if (toggleParser.HasToggle("help"))
            {
                var dialog = new MessageBoxForm();
                dialog.Message = BuildHelpString();
                dialog.Text    = "Help";
                dialog.ShowDialog();
                return;
            }

            ProcessCommandLine(toggleParser, settings);

            if (toggleParser.HasToggle("n") || toggleParser.HasToggle("nogui"))
            {
                return;
            }

#if WIN32
            var mutexName = "SmartSystemMenuMutex";
#else
            var mutexName = "SmartSystemMenuMutex64";
#endif
            _mutex = new Mutex(false, mutexName, out var createNew);
            if (!createNew)
            {
                return;
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm(settings, windowSettings));
        }