public BotWindowViewModel(MoonlightAPI api)
        {
            Client = api.CreateLocalClient();

            Bot = new Bot(Client);

            StartCommand = new RelayCommand(Bot.Start);
            StopCommand  = new RelayCommand(Bot.Stop);
        }
示例#2
0
        protected override void OnStartup(StartupEventArgs e)
        {
            try // prevent whole process crash on exception
            {
                AppConfig config = new AppConfig
                {
                    Configuration = (App)App.Current
                };

                MoonlightAPI api = new MoonlightAPI(config)
                {
                    Language = Language.CZ
                };

#if DEBUG
                api.AllocConsole();
#endif

                api.DeferPackets();      // handle packets in separate thread to prevent slowing down NosTale
                                         // this is useful if you don't need to modify or cancel packets...
                                         // and if you don't need 'to send packets at precise time right after particular packet etc.
                                         // to disable this use api.SyncPackets(); that is the default behavior

                api.CreateLocalClient(); // creates local client so it will be middleware for real game packet send/receive

                MoonlightMainWindow nosDamage = new MoonlightMainWindow
                {
                    DataContext = api.Services.GetService <MoonlightMainViewModel>()
                };

                nosDamage.Show();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }