Esempio n. 1
0
        public GeneralPanelViewModel(GeneralPanelModel model, ConfigurationManager configurationManager, TranslationService translationService, DynamicHttpClientProvider dynamicHttpClientProvider) : base(model)
        {
            this.configurationManager      = configurationManager;
            this.translationService        = translationService;
            this.dynamicHttpClientProvider = dynamicHttpClientProvider;
            foreach (var language in translationService.GetAvailableLanguages())
            {
                Model.Languages.Add(language);
            }
            Model.SelectedLanguage = TranslationModel.Instance.Language;
            var appConfig = GetAppConfig();

            Model.AutoConnect      = appConfig.AutoConnect;
            Model.ServerUrl        = appConfig.ServerUrl;
            Model.PropertyChanged += Model_PropertyChanged;
        }
Esempio n. 2
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();
        }
Esempio n. 3
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();
            }
        }