Esempio n. 1
0
 public ViewCommands(string[] args)
 {
     configService = new ConfigService(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile);
     viewcommands = configService.Get<CommandActionConfig>("CommandActionTypeConfig").ToList();
     InitializeComponent();
     this.args = args.Length == 0 ? new String[] { "Login", "logon", ".cshtml" } : args;
 }
Esempio n. 2
0
        public Add_Command(ConfigService configService, CommandActionConfig commandConfig)
        {
            this.configService = configService;
            this.CommandActionConfig = commandConfig;
            InitializeComponent();
            List<CommandConfig> commands = GetCommands();

            cboCommand.DataSource = commands;
            cboCommand.DisplayMember = "CommandKey";
            cboCommand.ValueMember = "CommandUri";
        }
        public void AppSettings_Returns_Stored_Value()
        {
            // Arrange
            var values = new NameValueCollection();
            values.Add("test", "penguin");
            var configService = new ConfigService(values);

            // Act
            var result = configService.AppSettings("test");

            // Assert
            Assert.AreEqual("penguin", result);
        }
Esempio n. 4
0
        static async Task Main(string[] args)
        {
            WriteLine("Initializing from config...");

            AppConfig = ConfigService.LoadAppSettings(args);

            GraphService = new GraphService(AppConfig);

            Hubitat = new HubitatService(AppConfig);

            var devices = await Hubitat.GetDevicesAsync();

            TargetDevice = devices.Single(x => string.Equals(x.Name, AppConfig.Hubitat.DeviceName, StringComparison.OrdinalIgnoreCase));

            await Hubitat.SendDeviceInitAsync(TargetDevice);

            WriteLine($"Starting timer after 100 ms.");

            using (var timer = new Timer(PollForPresence, "PresenceUnknown", 100, TimerSleepMilleseconds))
            {
                Console.WriteLine("Press any key to exit...");
                Console.ReadLine();
            }
        }
Esempio n. 5
0
        protected override async Task OnInitializedAsync()
        {
            var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();

            var user = authState.User;

            CurrentUser = await UserManager.GetUserAsync(user);

            UserConfig = await ConfigService.GetUserConfigAsync(CurrentUser.Id);

            People = await PersonService.GetPeopleAndSharedAsync(CurrentUser.Id);

            ExpenseTypes = await ExpenseTypeService.GetExpenseTypesAsync();

            if (People.Count <= 2)
            {
                People.RemoveAll(p => p.IsSharedPerson);
            }

            foreach (Person person in People)
            {
                person.Expenses = await ExpenseService.GetPersonsExpensesByMonth(person.Id, FilterMonth);
            }
        }
Esempio n. 6
0
        public static async Task RunAsync(string[] args, IServiceProvider servicesProvider)
        {
            var            cliMapSource       = new EmbeddedSource("cli-map.json", Assembly.GetExecutingAssembly());
            var            cliMapSchemaSource = new EmbeddedSource("cli-map.schema.json", Assembly.GetExecutingAssembly());
            var            cliMapService      = new ConfigService <CLIMap>(cliMapSource, cliMapSchemaSource);
            List <Command>?commands           = cliMapService.Config?.Commands;

            if (commands == null)
            {
                throw new ArgsException("CLI map has empty commands array.");
            }

            var commandsToExecute = new List <Command>();

            foreach (string arg in args)
            {
                Command?command = commands.Where(x => x.Name == arg || x.Shortcut == arg).FirstOrDefault();
                if (commandsToExecute.Count == 0 && command == null)
                {
                    throw new ArgsException($"Argument {arg} isn't handled.");
                }
                if (command == null)
                {
                    commandsToExecute[^ 1].Parameters.Add(arg);
Esempio n. 7
0
        public GameInstallViewModel(
            ConfigService configService,
            GamePathService gamePathService,
            VersionService versionService,
            LibraryService libraryService,
            AssetService assetService,
            DownloadService downloadService,

            IWindowManager windowManager,
            DownloadStatusViewModel downloadVM)
        {
            _config          = configService.Entries;
            _gamePathService = gamePathService;
            _versionService  = versionService;
            _libraryService  = libraryService;
            _assetService    = assetService;
            _downloadService = downloadService;

            _versionDownloads       = new BindableCollection <VersionDownload>();
            VersionDownloads        = CollectionViewSource.GetDefaultView(_versionDownloads);
            VersionDownloads.Filter = obj =>
            {
                if (_isReleaseOnly)
                {
                    return((obj as VersionDownload).Type == VersionType.Release);
                }

                return(true);
            };

            _windowManager    = windowManager;
            _downloadStatusVM = downloadVM;

            _isVersionListLoaded = false;
            _isReleaseOnly       = true;
        }
        private void RegisterContainer()
        {
            logger.Debug("Services container register start");

            var cb = new ContainerBuilder();

            cb.Register(r => logger).AsSelf().SingleInstance();

            var configService = new ConfigService(logger);

            cb.Register(r => configService).AsSelf().SingleInstance();

            var drawService = new DrawService(this, configService, logger);

            cb.Register(r => drawService).AsSelf().SingleInstance();

            var throwService = new ThrowService(drawService, logger);

            cb.Register(r => throwService).AsSelf().SingleInstance();

            ServiceContainer = cb.Build();

            logger.Debug("Services container register end");
        }
Esempio n. 9
0
        private async Task Init(HttpAuthenticationService httpAuth)
        {
            Cache = new CacheService();
            _map.AddSingleton(Cache);
            AudioClients = new AudioClientService();
            _map.AddSingleton(AudioClients);
            var gcmService = new GuildConfigManagerService();

            _map.AddSingleton(gcmService);
            _map.AddSingleton(httpAuth);

            Config = new ConfigService(Helper.GetAppDataPath("config.json"));
            Cleanup(Config.FileCachePath);
            token = Config.BotToken;
            _map.AddSingleton(Config);
            Queues = new QueueManagerService(Config, gcmService);
            _map.AddSingleton(Queues);

            _services = _map.BuildServiceProvider();

            await _commands.AddModulesAsync(Assembly.GetEntryAssembly());

            _client.MessageReceived += HandleCommandAsync;
        }
Esempio n. 10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var configJson = ConfigService.GetCompanyConfigJsonById(SessionVariable.Current.Company.Id, Configuration.OFFICE365_CODE);

                if (configJson != null)
                {
                    if (configJson["endPoint"] != null)
                    {
                        EndPointTextBox.Text = (String)configJson["endPoint"];
                    }

                    if (configJson["appID"] != null)
                    {
                        AppIDTextBox.Text = (String)configJson["appID"];
                    }
                }
                else
                {
                    DelBtn.Visible = false;
                }
            }
        }
        public async Task HandleParallelCalls()
        {
            var client      = new DomainWebsocketClient(ConfigService.GetWsUrl());
            var syncService = new SyncService(client);

            syncService.SetSessionId("test-session");
            syncService.PlayerName = "test-player";
            var rnd   = new Random();
            var tasks = Enumerable.Range(1, 5)
                        .Select(i => Task.Run(async() =>
            {
                while (true)
                {
                    var val  = rnd.Next(0, 100);
                    var mode = val switch
                    {
                        < 40 => SyncServiceMode.Poll,
                        < 80 => SyncServiceMode.Push,
                        _ => SyncServiceMode.Idle
                    };
                    Logger.Debug($"  --> {mode:G}");
                    syncService.SetMode(mode);
                    await Task.Delay(i * 30);
                }
Esempio n. 12
0
        public MainWindow()
        {
            _configService     = new ConfigService();
            _jiraApiService    = new JiraApiService();
            _apiRequestService = new ApiRequestService();

            InitializeComponent();

            AppHeartbeatTimer.Start();

            var files             = Directory.GetFiles(".", "appsettings*.json");
            var applicationConfig = _configService.GetConfig <ApplicationConfig>(files.First());
            var windowViewModel   = new WindowViewModel
            {
                Windows = new ObservableCollection <ViewModelBase>(), IsDebugMode = applicationConfig.IsDebugMode
            };

            DataContext = windowViewModel;

            Dispatcher.InvokeAsync(() =>
            {
                return(InitialLoad(windowViewModel, applicationConfig));
            });
        }
Esempio n. 13
0
 public BlogController(AttachService attachService
                       , TokenSerivce tokenSerivce
                       , NoteFileService noteFileService
                       , UserService userService
                       , ConfigFileService configFileService
                       , IHttpContextAccessor accessor
                       , AccessService accessService
                       , ConfigService configService
                       , TagService tagService
                       , NoteService noteService
                       , NotebookService notebookService
                       , BlogService blogService
                       , NoteRepositoryService noteRepository
                       ) :
     base(attachService, tokenSerivce, noteFileService, userService, configFileService, accessor)
 {
     this.accessService   = accessService;
     this.blogService     = blogService;
     this.configService   = configService;
     this.tagService      = tagService;
     this.notebookService = notebookService;
     this.noteService     = noteService;
     this.noteRepository  = noteRepository;
 }
Esempio n. 14
0
		public static void RegisterConfig(HttpApplication httpApplication)
		{
			// Connection string (we need to have this first, to start logging)
			Config.Database.ConnectionString = AppInfo.WebConfig.ConnectionString;

			// Paths
			Config.Paths.Application = httpApplication.Server.MapPath("~");
			Config.Paths.Temp = httpApplication.Server.MapPath("~/Temp");
			Config.Paths.EmailTemplates = httpApplication.Server.MapPath("~/Content/Emails");

			// Load all other configs from database
			ConfigService.LoadConfig();

			// Initialize temp folder
			FileService.InitializeTempFolder();

			// Set Config refresh task (Disabled for now, it was clogging the event log)
			// ConfigService.SetupRefreshConfigTask();

			// Path for the email templates
			EmailingService.EmailTemplatePath = Config.Paths.EmailTemplates;
			EmailingService.EmailingEnabled = true;
			EmailingService.StartQueueManager();
		}
Esempio n. 15
0
        public EnabledCommandState(ConfigService configService, ILogger logger)
        {
            this.configService = configService;

            configService.GetRange("Command").ContinueWith(task =>
            {
                if (task.Exception != null)
                {
                    logger.LogError(task.Exception, task.Exception.Message);
                    return;
                }

                var channelMatch = new Regex($@"^.*{Regex.Escape("/Command/")}(?<channel>[\d]+)$");

                foreach (var(Key, Value) in task.Result)
                {
                    ulong channel;

                    var match = channelMatch.Match(Key);

                    if (!match.Success)
                    {
                        continue;
                    }

                    if (!ulong.TryParse(match.Groups["channel"].Value, out channel))
                    {
                        continue;
                    }

                    logger.LogInformation($"Loading configuration from {Key}");

                    AddOrUpdate(channel, Value, (k, o) => Value);
                }
            });
        }
Esempio n. 16
0
        /// <summary>
        /// 获取单例对象
        /// </summary>
        /// <returns></returns>
        public static TimeDataManager GetTimeDataManager()
        {
            if (uniqueTimeDataManager != null)
            {
                return(uniqueTimeDataManager);
            }

            lock (locker)
            {
                uniqueTimeDataManager = new TimeDataManager();
                uniqueTimeDataManager.EnsureDbCreated();                                                 // 只检查一次是否建库建表
                uniqueTimeDataManager.LoadDataFromDb();                                                  // 读入数据

                int SaveToDbTimeSlice     = ConfigService.GetConfigService().TSConfig.SaveToDbTimeSlice; // 定时写入数据库时间
                System.Timers.Timer timer = new System.Timers.Timer
                {
                    Interval = ConfigService.GetConfigService().TSConfig.SaveToDbTimeSlice,
                    Enabled  = true
                };
                timer.Elapsed += TimeWriteToDb;
                timer.Start();
            }
            return(uniqueTimeDataManager);
        }
Esempio n. 17
0
        public TipViewModel(ResetService reset,
                            SoundService sound,
                            ConfigService config,
                            StatisticService statistic,
                            MainService main)
        {
            this.reset                 = reset;
            this.reset.TimeChanged    += new ResetEventHandler(timeChanged);
            this.reset.ResetCompleted += new ResetEventHandler(resetCompleted);

            this.sound           = sound;
            this.config          = config;
            this.config.Changed += config_Changed;


            resetCommand = new Command(new Action <object>(resetCommand_action));
            busyCommand  = new Command(new Action <object>(busyCommand_action));

            this.statistic = statistic;

            this.main = main;

            LoadConfig();
        }
Esempio n. 18
0
        public FormData GetFormData()
        {
            OAuthWXConfigInfo config = ConfigService <OAuthWXConfigInfo> .GetConfig(string.Concat(WXLoginPlugin.WXWorkDirectory, "\\Config\\OAuthWXConfig.config"));

            FormData formDatum = new FormData();

            FormData.FormItem[] formItemArray = new FormData.FormItem[2];
            FormData.FormItem   formItem      = new FormData.FormItem();
            formItem.DisplayName = "AppId";
            formItem.Name        = "AppId";
            formItem.IsRequired  = true;
            formItem.Type        = FormData.FormItemType.text;
            formItem.Value       = config.AppId;
            formItemArray[0]     = formItem;
            FormData.FormItem formItem1 = new FormData.FormItem();
            formItem1.DisplayName = "AppSecret";
            formItem1.Name        = "AppSecret";
            formItem1.IsRequired  = true;
            formItem1.Type        = FormData.FormItemType.text;
            formItem1.Value       = config.AppSecret;
            formItemArray[1]      = formItem1;
            formDatum.Items       = formItemArray;
            return(formDatum);
        }
Esempio n. 19
0
        public MainViewModel(
            ConfigService configService,
            VersionService versionService,
            ThemeService themeService,

            LaunchViewModel launchVM,
            SettingsRootViewModel settingsVM,
            VersionsRootViewModel versionsVM,
            AuxiliariesRootViewModel auxVM,
            AboutViewModel aboutVM,

            IWindowManager windowManager)
        {
            _windowManager  = windowManager;
            _config         = configService.Entries;
            _versionService = versionService;

            _pages = new Screen[]
            {
                launchVM, settingsVM, versionsVM, auxVM, aboutVM,
            };

            // Start up with LaunchView
            ActivePageIndex = 0;

            // Bind background image service
            ThemeService = themeService;

            //Set Title
            this.DisplayName = "GBCL v" + AssemblyUtil.Version;

            // You don't want to switch to other pages while launching the game
            CanChangePage = true;
            launchVM.LaunchProcessStarted += () => CanChangePage = false;
            launchVM.LaunchProcessEnded   += () => CanChangePage = true;
        }
Esempio n. 20
0
        protected override async Task OnInitializedAsync()
        {
            var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();

            var user = authState.User;

            CurrentUser = await UserManager.GetUserAsync(user);

            UserConfig = await ConfigService.GetUserConfigAsync(CurrentUser.Id);

            Expenses = await ExpenseService.GetAllExpensesAsync(CurrentUser.Id);

            People = await PersonService.GetPeopleAndSharedAsync(CurrentUser.Id);

            MonthlyIncome      = FinanceService.GetTotalMonthlyIncome(People);
            MonthlyExpenditure = FinanceService.GetTotalMonthlyExpenditure(Expenses);
            MonthlyNet         = MonthlyIncome - MonthlyExpenditure;


            if (MonthlyIncome <= MonthlyExpenditure)
            {
                SpendingWarning = true;
            }
        }
Esempio n. 21
0
        public IActionResult Register(string iu, string from)
        {
            if (iu == null)
            {
                iu = "";
            }
            if (from == null)
            {
                from = "";
            }


            //return Content("An API listing authors of docs.asp.net.");
            ViewBag.title = "leanote";
            Dictionary <string, string> msg = LanguageResource.GetMsg();

            ViewBag.msg = msg;

            ViewBag.iu           = iu;
            ViewBag.from         = from;
            ViewBag.openRegister = ConfigService.IsOpenRegister();

            return(View());
        }
Esempio n. 22
0
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel()
        {
            if (IsInDesignMode)
            {
                // Code runs in Blend --> create design time data.
            }
            else
            {
                // Code runs "for real"
                ConfigService config = new ConfigService();
                this.myModel                       = config.LoadJSON();
                this.SearchRelayCommand            = new RelayCommand <string>(Search);
                this.SelectByRectangleRelayCommand = new RelayCommand(SelectByRectangle);
                this.AddPointRelayCommand          = new RelayCommand(AddPoint);

                Messenger.Default.Register <Esri.ArcGISRuntime.Controls.MapView>(this, (mapView) =>
                {
                    this.mapView          = mapView;
                    this.mapView.MaxScale = 500;

                    ArcGISLocalTiledLayer localTiledLayer = new ArcGISLocalTiledLayer(this.TilePackage);
                    localTiledLayer.ID = "SF Basemap";
                    localTiledLayer.InitializeAsync();

                    this.mapView.Map.Layers.Add(localTiledLayer);

                    this.CreateLocalServiceAndDynamicLayer();
                    this.CreateFeatureLayers();

                    this.graphicsLayer    = new Esri.ArcGISRuntime.Layers.GraphicsLayer();
                    this.graphicsLayer.ID = "Results";
                    this.graphicsLayer.InitializeAsync();
                    this.mapView.Map.Layers.Add(this.graphicsLayer);
                });
            }
        }
Esempio n. 23
0
        public ActionResult Index(string searchTerm, int?minimumPrice, int?maximumPrice, int?categoryID, int?sortBy, int?pageNo)
        {
            CategoryService categoryService = new CategoryService();
            ConfigService   configService   = new ConfigService();
            var             pageSize        = configService.ShopPageSize();

            ShopViewModel model = new ShopViewModel();

            model.SearchTerm         = searchTerm;
            model.FeaturedCategories = categoryService.GetFeaturedCategories();
            model.MaximumPrice       = ProductService.Instance.GetMaximumPrice();

            pageNo           = pageNo.HasValue ? pageNo.Value > 0 ? pageNo.Value : 1 : 1;
            model.SortBy     = sortBy;
            model.CategoryID = categoryID;

            int totalCount = ProductService.Instance.SearchProductsCount(searchTerm, minimumPrice, maximumPrice, categoryID, sortBy);

            model.Products = ProductService.Instance.SearchProducts(searchTerm, minimumPrice, maximumPrice, categoryID, sortBy, pageNo.Value, 10);

            model.Pager = new Pager(totalCount, pageNo, pageSize);

            return(View(model));
        }
Esempio n. 24
0
 public static void SaveServerConfig()
 {
     ConfigService.SaveConfig(ServerConfig);
 }
Esempio n. 25
0
 public Startup(IWebHostEnvironment env)
 {
     Configuration = ConfigService.GetConfiguration(env);
 }
Esempio n. 26
0
        private void ButtonLoadDefaults_Click(object sender, EventArgs e)
        {
            tabControl1.SuspendLayout();

            var wasTabbedMain  = tabControl1.SelectedTab.Name;
            var tb1            = GetTabControl(NormalControlsTab.Controls);
            var tb2            = GetTabControl(AutofireControlsTab.Controls);
            var tb3            = GetTabControl(AnalogControlsTab.Controls);
            var tb4            = GetTabControl(FeedbacksTab.Controls);
            int?wasTabbedPage1 = null;
            int?wasTabbedPage2 = null;
            int?wasTabbedPage3 = null;
            int?wasTabbedPage4 = null;

            if (tb1?.SelectedTab != null)
            {
                wasTabbedPage1 = tb1.SelectedIndex;
            }
            if (tb2?.SelectedTab != null)
            {
                wasTabbedPage2 = tb2.SelectedIndex;
            }
            if (tb3?.SelectedTab != null)
            {
                wasTabbedPage3 = tb3.SelectedIndex;
            }
            if (tb4?.SelectedTab != null)
            {
                wasTabbedPage4 = tb4.SelectedIndex;
            }

            NormalControlsTab.Controls.Clear();
            AutofireControlsTab.Controls.Clear();
            AnalogControlsTab.Controls.Clear();
            FeedbacksTab.Controls.Clear();

            // load panels directly from the default config.
            // this means that the changes are NOT committed.  so "Cancel" works right and you
            // still have to hit OK at the end.
            var cd = ConfigService.Load <DefaultControls>(Config.ControlDefaultPath);

            LoadPanels(cd);

            tabControl1.SelectTab(wasTabbedMain);

            if (wasTabbedPage1.HasValue)
            {
                var newTb1 = GetTabControl(NormalControlsTab.Controls);
                newTb1?.SelectTab(wasTabbedPage1.Value);
            }

            if (wasTabbedPage2.HasValue)
            {
                var newTb2 = GetTabControl(AutofireControlsTab.Controls);
                newTb2?.SelectTab(wasTabbedPage2.Value);
            }

            if (wasTabbedPage3.HasValue)
            {
                var newTb3 = GetTabControl(AnalogControlsTab.Controls);
                newTb3?.SelectTab(wasTabbedPage3.Value);
            }

            if (wasTabbedPage4.HasValue)
            {
                var newTb4 = GetTabControl(FeedbacksTab.Controls);
                newTb4?.SelectTab(wasTabbedPage4.Value);
            }

            tabControl1.ResumeLayout();
        }
 public RpcService(Program program, LoggerService loggerService, ConfigService configService)
 {
     Program       = program;
     LoggerService = loggerService;
     ConfigService = configService;
 }
Esempio n. 28
0
 public ConfigEmailService(ConfigService configService, FileService fileService)
 {
     _configService = configService;
     _fileService = fileService;
 }
Esempio n. 29
0
 public ConfigController(ConfigService configService) => _configService = configService;
 public SpawnPingpongEnemySystem(Contexts contexts, Services services)
 {
     this.contexts             = contexts;
     this.entityFactoryService = services.entityFactoryService as EntityFactoryService;
     this.configService        = services.configService;
 }
        // TODO: This doesn't really belong here, but not sure where to put it
        public static void PopulateWithDefaultHeaderValues(this IMovie movie, string author = null)
        {
            movie.Author          = author ?? Global.Config.DefaultAuthor;
            movie.EmulatorVersion = VersionInfo.GetEmuVersion();
            movie.SystemID        = Global.Emulator.SystemId;

            var settable = new SettingsAdapter(Global.Emulator);

            if (settable.HasSyncSettings)
            {
                movie.SyncSettingsJson = ConfigService.SaveWithType(settable.GetSyncSettings());
            }

            if (Global.Game != null)
            {
                movie.GameName = PathManager.FilesystemSafeName(Global.Game);
                movie.Hash     = Global.Game.Hash;
                if (Global.Game.FirmwareHash != null)
                {
                    movie.FirmwareHash = Global.Game.FirmwareHash;
                }
            }
            else
            {
                movie.GameName = "NULL";
            }

            if (Global.Emulator.BoardName != null)
            {
                movie.BoardName = Global.Emulator.BoardName;
            }

            if (Global.Emulator.HasRegions())
            {
                var region = Global.Emulator.AsRegionable().Region;
                if (region == Emulation.Common.DisplayType.PAL)
                {
                    movie.HeaderEntries.Add(HeaderKeys.PAL, "1");
                }
            }

            if (Global.FirmwareManager.RecentlyServed.Any())
            {
                foreach (var firmware in Global.FirmwareManager.RecentlyServed)
                {
                    var key = firmware.SystemId + "_Firmware_" + firmware.FirmwareId;

                    if (!movie.HeaderEntries.ContainsKey(key))
                    {
                        movie.HeaderEntries.Add(key, firmware.Hash);
                    }
                }
            }

            if (Global.Emulator is Gameboy && (Global.Emulator as Gameboy).IsCGBMode())
            {
                movie.HeaderEntries.Add("IsCGBMode", "1");
            }

            if (Global.Emulator is SMS && (Global.Emulator as SMS).IsSG1000)
            {
                movie.HeaderEntries.Add("IsSGMode", "1");
            }

            if (Global.Emulator is GPGX && (Global.Emulator as GPGX).IsSegaCD)
            {
                movie.HeaderEntries.Add("IsSegaCDMode", "1");
            }

            movie.Core = ((CoreAttributes)Attribute
                          .GetCustomAttribute(Global.Emulator.GetType(), typeof(CoreAttributes)))
                         .CoreName;
        }
Esempio n. 32
0
 public HomeController(ConfigService configService)
 {
     _configService = configService;
 }
 public HelpModule(Program program, LoggerService loggerService, ConfigService configService, SqliteDatabaseService sqliteDatabaseService, RpcService rpcService) : base(loggerService, configService, sqliteDatabaseService, rpcService)
 {
     ServiceProvider = program.ServiceProvider;
     CommandService  = program.CommandService;
 }
Esempio n. 34
0
        static void SubMain(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            string iniPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "config.ini");

            Global.Config = ConfigService.Load <Config>(iniPath);
            Global.Config.ResolveDefaults();
            HawkFile.ArchiveHandlerFactory = new SevenZipSharpArchiveHandler();

            //super hacky! this needs to be done first. still not worth the trouble to make this system fully proper
            for (int i = 0; i < args.Length; i++)
            {
                var arg = args[i].ToLower();
                if (arg.StartsWith("--gdi"))
                {
                    Global.Config.DispMethod = Config.EDispMethod.GdiPlus;
                }
            }


            //WHY do we have to do this? some intel graphics drivers (ig7icd64.dll 10.18.10.3304 on an unknown chip on win8.1) are calling SetDllDirectory() for the process, which ruins stuff.
            //The relevant initialization happened just before in "create IGL context".
            //It isn't clear whether we need the earlier SetDllDirectory(), but I think we do.
            //note: this is pasted instead of being put in a static method due to this initialization code being sensitive to things like that, and not wanting to cause it to break
            //pasting should be safe (not affecting the jit order of things)
            string dllDir = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "dll");

            SetDllDirectory(dllDir);

            try
            {
                using (var mf = new Mainform(args))
                {
                    var title = mf.Text;
                    mf.Show();
                    mf.Text = title;
                    try
                    {
                        mf.ProgramRunLoop();
                    }
                    catch (Exception e)
                    {
#if WINDOWS
                        if (Global.MovieSession.Movie.IsActive)
                        {
                            var result = MessageBox.Show(
                                "EmuHawk has thrown a fatal exception and is about to close.\nA movie has been detected. Would you like to try to save?\n(Note: Depending on what caused this error, this may or may not succeed)",
                                "Fatal error: " + e.GetType().Name,
                                MessageBoxButtons.YesNo,
                                MessageBoxIcon.Exclamation
                                );
                            if (result == DialogResult.Yes)
                            {
                                Global.MovieSession.Movie.Save();
                            }
                        }
#endif
                        throw;
                    }
                }
            }
            catch (Exception e)
            {
                string message = e.ToString();
                if (e.InnerException != null)
                {
                    message += "\n\nInner Exception:\n\n" + e.InnerException;
                }

                message += "\n\nStackTrace:\n" + e.StackTrace;
                MessageBox.Show(message);
            }
#if WINDOWS
            finally
            {
                GamePad.CloseAll();
            }
#endif
        }