Exemplo n.º 1
0
        public MainWindow(MainWindowViewModel viewModel, CommandRunner commandRunner, ConfigurationManager configurationManager,
                          TranslationService translationService, DynamicHttpClientProvider dynamicHttpClientProvider, InputDeviceManager inputDeviceManager)
        {
            this.viewModel            = viewModel;
            this.commandRunner        = commandRunner;
            this.configurationManager = configurationManager;
            DataContext = viewModel;
            InitializeComponent();
            var helper = new WindowInteropHelper(this);

            WindowHandleStore.Handle = helper.EnsureHandle();
            appConfig = configurationManager.Load(() => new AppConfig(translationService.DefaultLanguage));
            if (!translationService.Load(appConfig.Language))
            {
                translationService.Load(translationService.DefaultLanguage);
            }
            ViewModel.Model.MainContent = ApplicationContext.Global.Resolve <GeneralPanel>();
            if (appConfig.ServerUrl != null)
            {
                var uri = new Uri($"http://{appConfig.ServerUrl}/api/");
                dynamicHttpClientProvider.SetBaseAddress(uri);
                if (appConfig.AutoConnect)
                {
                    // TODO autoconnect
                }
            }
            if (!appConfig.Minimized)
            {
                Show();
            }
            IntPtr value;
            var    hinst         = DInput8.GetModuleHandle(null);
            var    guid          = IID.IID_IDirectInput8W;
            var    x             = DInput8.DirectInput8Create(hinst, 0x00000800, guid, out value, IntPtr.Zero);
            var    err           = System.Runtime.InteropServices.Marshal.GetLastWin32Error();
            var    directInput8W = new DirectInput8W(value);

            directInput8W.GetLifetimeService();
            inputDeviceManager.Start();
        }
Exemplo n.º 2
0
        public MainWindow(MainWindowViewModel viewModel, CommandRunner commandRunner, ConfigurationManager configurationManager, TranslationService translationService, DynamicHttpClientProvider dynamicHttpClientProvider)
        {
            this.viewModel            = viewModel;
            this.commandRunner        = commandRunner;
            this.configurationManager = configurationManager;
            DataContext = viewModel;
            InitializeComponent();
            var helper = new WindowInteropHelper(this);

            WindowHandleStore.Handle = helper.EnsureHandle();
            appConfig = configurationManager.Load(() => new AppConfig(translationService.DefaultLanguage));
            if (!translationService.Load(appConfig.Language))
            {
                translationService.Load(translationService.DefaultLanguage);
            }
            ViewModel.Model.MainContent = ApplicationContext.Global.Resolve <GeneralPanel>();
            if (appConfig.ServerUrl != null)
            {
                var uri = new Uri($"http://{appConfig.ServerUrl}/api/");
                dynamicHttpClientProvider.SetBaseAddress(uri);
                if (appConfig.AutoConnect)
                {
                    // TODO autoconnect
                }
            }
            if (!appConfig.Minimized)
            {
                Show();
            }
        }