public TeamToSeasonFormViewModel(IRegionManager regionManager, IInteractionService interactionService, ILeagueService leagueService) { this.regionManager = regionManager; this.interactionService = interactionService; this.leagueService = leagueService; this.OKCommand = new DelegateCommand(async() => { if (this.SelectedItem != null) { this.IsEnabled = GlobalCommands.BlockWindowButtons(); var result = this.leagueService.AssignTeamToSeason(SelectedItem.Id, this.seasonId); if (!(await result)) { await this.interactionService.ShowMessageBox("Team already added", "This team was already assigned to this season."); this.IsEnabled = GlobalCommands.UnlockWindowButtons(); return; } } else { await this.interactionService.ShowMessageBox("No seasons available", "To assign team to season, add season first."); } GlobalCommands.GoBackCommand.Execute(null); }); }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); // Create a new instance of the main window. var mainWindow = new MainWindow(); Application.Current.MainWindow = mainWindow; if (e.Args.Any(arg => arg.ToUpper().Equals("/refresh"))) { mainWindow.Refresh(); } //create the notifyicon (it's a resource declared in SystemTray/SystemTrayResources.xaml). _taskBarIcon = (TaskbarIcon)FindResource("SystemTrayIcon"); // Register the hot-key that will show the application HotKeyManager.Register( Key.Space, OperatingSystem.KeyModifier.Alt, () => { var command = GlobalCommands.ShowWindowCommand(); if (command.CanExecute(null)) { command.Execute(null); } }); }
public static IEnumerator Update() { if (!UpdateAvailable) { yield return(CheckForUpdates()); } if (!UpdateAvailable) { IRCConnection.SendMessage("Twitch Plays is up-to-date."); yield break; } IRCConnection.SendMessage("Updating Twitch Plays and restarting."); // Delete the current build DirectoryInfo modFolder = new DirectoryInfo(GetModFolder()); modFolder.Delete(true); // Copy the build that CheckForUpdates() downloaded to where the current one was. // Note: .MoveTo(desDirName) was intentionally not used as it doesn't work across drives. DirectoryInfo buildFolder = new DirectoryInfo(Path.Combine(BuildStorage, "Twitch Plays")); buildFolder.CopyTo(modFolder); buildFolder.Delete(true); GlobalCommands.RestartGame(); }
public async void OnNavigatedTo(NavigationContext navigationContext) { this.IsEnabled = GlobalCommands.BlockWindowButtons(); int?stadiumId = (int?)navigationContext.Parameters["id"]; if (!stadiumId.HasValue) { this.OKCommand = new DelegateCommand(async() => { await this.leagueService.AddStadium(this.Stadium); regionManager.RequestNavigate(UiRegions.MainRegion, nameof(MainMenu)); }); } else { this.OKCommand = new DelegateCommand(async() => { await this.leagueService.SaveChangesAsync(); regionManager.RequestNavigate(UiRegions.MainRegion, nameof(MainMenu)); }); this.Stadium = await this.leagueService.GetStadium(stadiumId.Value); this.Header = "Edit existing stadium"; } this.IsEnabled = GlobalCommands.UnlockWindowButtons(); }
public async void OnNavigatedTo(NavigationContext navigationContext) { this.IsEnabled = GlobalCommands.BlockWindowButtons(); int?coachId = (int?)navigationContext.Parameters["id"]; if (!coachId.HasValue) { this.OKCommand = new DelegateCommand(async() => { this.IsEnabled = GlobalCommands.BlockWindowButtons(); await this.leagueService.AddCoach(this.Coach); regionManager.RequestNavigate(UiRegions.MainRegion, nameof(MainMenu)); }); } else { this.OKCommand = new DelegateCommand(async() => { this.IsEnabled = GlobalCommands.BlockWindowButtons(); await this.leagueService.SaveChangesAsync(); regionManager.RequestNavigate(UiRegions.MainRegion, nameof(MainMenu)); }); this.Coach = await this.leagueService.GetCoach(coachId.Value); this.TeamLabel = (this.Coach.Teams != null && this.Coach.Teams.Any()) ? string.Join(", ", Array.ConvertAll(this.Coach.Teams.ToArray(), x => x.Name)) : "No team"; this.Header = "Edit existing coach"; } this.IsEnabled = GlobalCommands.UnlockWindowButtons(); }
public FixturesFormViewModel(IRegionManager regionManager, IInteractionService interactionService, ILeagueService leagueService) { this.regionManager = regionManager; this.leagueService = leagueService; this.interactionService = interactionService; this.OKCommand = new DelegateCommand(async() => { this.IsEnabled = GlobalCommands.BlockWindowButtons(); var result = await this.leagueService.GenerateFixtures(this.SelectedItem.Id, this.StartingDate, this.IntervalValue); if (!result) { this.IsEnabled = GlobalCommands.UnlockWindowButtons(); await this.interactionService.ShowConfirmationMessage("Fixture already exists", "Fixture can't be generated, because it already exists. Do you want to override?", async() => { this.IsEnabled = GlobalCommands.BlockWindowButtons(); await this.leagueService.GenerateFixtures(this.SelectedItem.Id, this.StartingDate, this.IntervalValue, true); regionManager.RequestNavigate(UiRegions.MainRegion, nameof(MainMenu)); }); } else { regionManager.RequestNavigate(UiRegions.MainRegion, nameof(MainMenu)); } }); }
public static IEnumerator Update() { if (!UpdateAvailable) { yield return(CheckForUpdates()); } if (!UpdateAvailable) { IRCConnection.SendMessage("Twitch Plays is up-to-date."); yield break; } IRCConnection.SendMessage("Updating Twitch Plays and restarting."); // Make the current build the previous build var previousBuild = new DirectoryInfo(Path.Combine(TwitchPlaysService.DataFolder, "Previous Build")); if (previousBuild.Exists) { previousBuild.Delete(true); } DirectoryInfo modFolder = new DirectoryInfo(GetModFolder()); modFolder.MoveToSafe(previousBuild); // Copy the build that CheckForUpdates() downloaded to where the current one was. DirectoryInfo buildFolder = new DirectoryInfo(Path.Combine(BuildStorage, "Twitch Plays")); buildFolder.MoveToSafe(modFolder); GlobalCommands.RestartGame(); }
public async void OnNavigatedTo(NavigationContext navigationContext) { this.IsEnabled = GlobalCommands.BlockWindowButtons(); int?refereeId = (int?)navigationContext.Parameters["id"]; if (!refereeId.HasValue) { this.OKCommand = new DelegateCommand(async() => { this.IsEnabled = GlobalCommands.BlockWindowButtons(); await this.leagueService.AddReferee(this.Referee); regionManager.RequestNavigate(UiRegions.MainRegion, nameof(MainMenu)); }); } else { this.OKCommand = new DelegateCommand(async() => { this.IsEnabled = GlobalCommands.BlockWindowButtons(); await this.leagueService.SaveChangesAsync(); regionManager.RequestNavigate(UiRegions.MainRegion, nameof(MainMenu)); }); this.Referee = await this.leagueService.GetReferee(refereeId.Value); if (this.Referee.Matches != null) { this.Matches.AddRange(this.Referee.Matches); } } this.IsEnabled = GlobalCommands.UnlockWindowButtons(); }
public void OnInitialize(GlobalCommands globalCommands, IEventAggregator eventAggregator, IUnityContainer container) { this.GlobalCommands = globalCommands; var navController = container.Resolve <MainWindowNavigationController>(); navController.RegisterDefaultSubscriptions(eventAggregator); }
public async void OnNavigatedTo(NavigationContext navigationContext) { this.IsEnabled = GlobalCommands.BlockWindowButtons(); this.Match = await this.leagueService.GetMatch((int)navigationContext.Parameters["id"]); this.AwayGoals.AddRange(Match.Goals.Where(g => g.TeamID == this.Match.AwayTeamId)); this.HomeGoals.AddRange(Match.Goals.Where(g => g.TeamID == this.Match.HomeTeamId)); this.IsEnabled = GlobalCommands.UnlockWindowButtons(); }
private void CommandService_CommandsChanged() { GlobalCommands.Clear(); foreach (var delegateCommand in _commandService.GetForRole(AppUserModel.RoleModel)) { GlobalCommands.Add(delegateCommand); } SendPropertyChanged(() => GlobalCommands); }
public static void Navigate(object link) { if (FullscreenApplication.Current.Dialogs.ShowMessage( string.Format(ResourceProvider.GetString("LOCUrlNavigationMessage"), link.ToString()), string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.Yes) { GlobalCommands.NavigateUrl(link); } }
private void OnRestoreCompleted(string message) { if (!string.IsNullOrEmpty(message)) { // restore successfully // initial database again in case the database was restored to a old schema. GlobalCommands.InitializeDatabase(true); } }
public void OnInitialization(IEventAggregator eventAggregator, GlobalCommands globalCommands, IRepository repository) { this.eventAggregator = eventAggregator; this.globalCommands = globalCommands; this.repository = repository; this.globalCommands.Print.RegisterCommand(this.PrintCommand); this.globalCommands.PrintAll.RegisterCommand(this.PrintCommand); this.globalCommands.Close.RegisterCommand(this.CloseCommand); }
public async void OnNavigatedTo(NavigationContext navigationContext) { this.IsEnabled = GlobalCommands.BlockWindowButtons(); this.seasonId = (int)navigationContext.Parameters["id"]; this.Teams.AddRange(await this.leagueService.GetTeamsList()); //if(this.Teams.Any()) //{ // this.SelectedItem = this.Teams.First(); //} this.IsEnabled = GlobalCommands.UnlockWindowButtons(); }
public async void OnNavigatedTo(NavigationContext navigationContext) { this.IsEnabled = GlobalCommands.BlockWindowButtons(); this.Teams.AddRange(await this.leagueService.GetTeamsList()); int?playerId = (int?)navigationContext.Parameters["id"]; if (!playerId.HasValue) { this.OKCommand = new DelegateCommand(async() => { this.IsEnabled = GlobalCommands.BlockWindowButtons(); this.Footballer.TeamId = SelectedTeam?.Id; var result = await this.leagueService.AddFootballer(this.Footballer); if (!result) { await this.interactionService.ShowMessageBox("Cannot add player", "Salary is too high."); this.IsEnabled = GlobalCommands.UnlockWindowButtons(); } else { regionManager.RequestNavigate(UiRegions.MainRegion, nameof(MainMenu)); } }); } else { this.OKCommand = new DelegateCommand(async() => { this.IsEnabled = GlobalCommands.BlockWindowButtons(); if (await this.leagueService.CanAddFootballer(this.Footballer)) { this.Footballer.TeamId = SelectedTeam?.Id; await this.leagueService.SaveChangesAsync(); GlobalCommands.GoBackCommand.Execute(null); } else { await this.interactionService.ShowMessageBox("Cannot edit player", "Salary is too high."); this.IsEnabled = GlobalCommands.UnlockWindowButtons(); } }); this.Footballer = await this.leagueService.GetFootballer(playerId.Value); this.SelectedTeam = Teams.FirstOrDefault(t => t.Id == this.Footballer.TeamId); if (this.Footballer.Goals != null) { this.Goals.AddRange(this.Footballer.Goals); } } this.IsEnabled = GlobalCommands.UnlockWindowButtons(); }
/// <summary> /// Event for text changes in searchtextbox. /// </summary> private void SearchTextbox_OnTextChanged(object sender, TextChangedEventArgs e) { var origin = sender as TextBox; if (!origin.IsFocused) { return; } DisposeTimer(); this.okButton.IsEnabled = false; this.cancelButton.IsEnabled = false; GlobalCommands.BlockWindowButtons(); timer = new Timer(TimerElapsed, null, VALIDATION_DELAY, VALIDATION_DELAY); }
/// <summary> /// Performs search query using filterFunc for text input. /// </summary> /// <param name="text">User input for search query.</param> public async void Search(string text) { this.List.Clear(); if (text.Length == 0) { return; } var result = await this.filterFunc.Invoke(text, this.leagueService); this.List.AddRange(result); if (List.Count > 0) { this.SelectedItem = List.First(); } GlobalCommands.UnlockWindowButtons(); }
public async void OnNavigatedTo(NavigationContext navigationContext) { this.IsEnabled = GlobalCommands.BlockWindowButtons(); int?seasonId = (int?)navigationContext.Parameters["id"]; if (!seasonId.HasValue) { this.OKCommand = new DelegateCommand(async() => { this.IsEnabled = GlobalCommands.BlockWindowButtons(); await this.leagueService.AddSeason(this.Season); regionManager.RequestNavigate(UiRegions.MainRegion, nameof(MainMenu)); }); } else { this.OKCommand = new DelegateCommand(async() => { await this.leagueService.SaveChangesAsync(); //regionManager.RequestNavigate(UiRegions.MainRegion, nameof(MainMenu)); GlobalCommands.GoBackCommand.Execute(null); }); this.AddTeamCommand = new DelegateCommand(() => { var parameter = new NavigationParameters(); parameter.Add("id", this.Season.Id); this.regionManager.RequestNavigate(UiRegions.MainRegion, nameof(TeamToSeasonForm), parameter); }); this.Season = await this.leagueService.GetSeason(seasonId.Value); if (this.Season.Matches != null) { this.Season.Matches = this.Season.Matches.OrderBy(x => x.Date).ToList(); } OnPropertyChanged("Season"); if (this.Season.Table != null) { this.Table.AddRange(this.Season.Table.OrderByDescending(x => x.Points)); } this.AddTeamEnabled = true; } this.IsEnabled = GlobalCommands.UnlockWindowButtons(); }
private void DeployBtn_Click(object sender, RoutedEventArgs e) { var dialog = new FolderBrowserDialog() { ShowNewFolderButton = true, Description = "Select a destination folder" }; if (Properties.Settings.Default.LastDeploymentFolder != string.Empty) { dialog.SelectedPath = Properties.Settings.Default.LastDeploymentFolder; } if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { // path is fine? if (dialog.SelectedPath == Gibbo.Library.SceneManager.GameProject.ProjectPath) { System.Windows.Forms.MessageBox.Show("You cannot select the folder of your project.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Properties.Settings.Default.LastDeploymentFolder = dialog.SelectedPath; Properties.Settings.Default.Save(); bool previousDebugMode = Gibbo.Library.SceneManager.GameProject.Debug; Gibbo.Library.SceneManager.GameProject.Debug = false; Gibbo.Library.SceneManager.GameProject.Save(); if (GlobalCommands.DeployProject(Gibbo.Library.SceneManager.GameProject.ProjectPath, dialog.SelectedPath, selectedOption)) { // deployed with success! if (System.Windows.Forms.MessageBox.Show("Deployed successfully!\n\nOpen output directory?", "Success", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == System.Windows.Forms.DialogResult.Yes) { System.Diagnostics.Process.Start(dialog.SelectedPath); } } Gibbo.Library.SceneManager.GameProject.Debug = previousDebugMode; Gibbo.Library.SceneManager.GameProject.Save(); } }
private static void LoadGlobalCommands(JObject root) { JToken jFoundation = root.GetValue("foundation"); foreach (JProperty command in jFoundation) { ZclGlobalCommand zclCommand = new ZclGlobalCommand(); zclCommand.Id = command.Value["id"].Value <byte>(); zclCommand.Name = command.Name; zclCommand.KnownBufLen = command.Value["knownBufLen"].Value <int>(); var paramCollection = command.Value["params"]; foreach (JObject pObject in paramCollection) { foreach (var p in pObject) { ZclCommandParam param = new ZclCommandParam() { Name = p.Key }; if (p.Value.Type == JTokenType.Integer) { param.DataType = (DataType)p.Value.ToObject <int>(); } else if (p.Value.Type == JTokenType.String) { param.SpecialType = p.Value.ToObject <string>(); } else { throw new NotImplementedException($"Param type {p.Value.Type.ToString()} not implemented"); } zclCommand.Params.Add(param); } } GlobalCommands.Add(zclCommand); } }
public async void OnNavigatedTo(NavigationContext navigationContext) { this.IsEnabled = GlobalCommands.BlockWindowButtons(); this.Coaches.AddRange(await this.leagueService.GetCoachList()); this.Stadiums.AddRange(await this.leagueService.GetStadiumsList()); int?teamId = (int?)navigationContext.Parameters["id"]; if (!teamId.HasValue) { this.OKCommand = new DelegateCommand(async() => { this.IsEnabled = GlobalCommands.BlockWindowButtons(); await this.leagueService.AddTeam(this.Team); regionManager.RequestNavigate(UiRegions.MainRegion, nameof(MainMenu)); }); } else { this.OKCommand = new DelegateCommand(async() => { this.IsEnabled = GlobalCommands.BlockWindowButtons(); this.Team.CoachId = this.SelectedCoach.Id; this.Team.StadiumId = this.SelectedStadium.Id; await this.leagueService.SaveChangesAsync(); //regionManager.RequestNavigate(UiRegions.MainRegion, nameof(MainMenu)); GlobalCommands.GoBackCommand.Execute(null); }); this.Team = await this.leagueService.GetTeam(teamId.Value); this.SelectedCoach = Coaches.FirstOrDefault(c => c.Id == Team.CoachId); this.SelectedStadium = Stadiums.FirstOrDefault(s => s.Id == Team.StadiumId); if (this.Team.Footballers != null) { this.Footballers.AddRange(Team.Footballers); } if (this.Team.Table != null) { this.Tables.AddRange(Team.Table); } } this.IsEnabled = GlobalCommands.UnlockWindowButtons(); }
public static IEnumerator Revert() { var previousBuild = new DirectoryInfo(Path.Combine(TwitchPlaysService.DataFolder, "Previous Build")); if (!previousBuild.Exists) { IRCConnection.SendMessage("There is no previous version of Twitch Plays to revert to."); yield break; } IRCConnection.SendMessage("Reverting to the previous Twitch Plays build and restarting."); DirectoryInfo modFolder = new DirectoryInfo(GetModFolder()); modFolder.Delete(true); previousBuild.MoveToSafe(modFolder); GlobalCommands.RestartGame(); }
protected override void OnStartup(StartupEventArgs e) { log4net.LogManager.GetLogger(typeof(App)).Info("Starting application..."); App.Current.ShutdownMode = System.Windows.ShutdownMode.OnExplicitShutdown; if (!CheckLicese()) { Application.Current.Shutdown(); return; } try { string logPath = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "logs"); Utility.EnsureFloderWritable(logPath); } catch { var interaction = DependencyInjection.Container.Resolve <IInteractionService>(); interaction.ShowError("Please make sure the logs folder is writable, otherwise logging will not work.", null); } GlobalCommands.ApplyTheme("Windows8"); GlobalCommands.RefreshLanguage(new CultureInfo("en")); // set exception handler Application.Current.DispatcherUnhandledException += new DispatcherUnhandledExceptionEventHandler(App_DispatcherUnhandledException); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); // set DataDirectory AppDomain.CurrentDomain.SetData("DataDirectory", AppDomain.CurrentDomain.BaseDirectory); App.Current.ShutdownMode = System.Windows.ShutdownMode.OnMainWindowClose; base.OnStartup(e); Bootstrapper bootstrapper = new Bootstrapper(); bootstrapper.Run(); }
public TeamFormViewModel(IRegionManager regionManager, IViewToDataService viewToDataService, ILeagueService leagueService, IInteractionService interactionService) { this.regionManager = regionManager; this.leagueService = leagueService; this.viewToDataService = viewToDataService; this.interactionService = interactionService; this.Team = new Team() { Address = new Address() }; this.RemovePlayerCommand = new DelegateCommand <Footballer>((Footballer player) => { if (player != null) { this.leagueService.RemovePlayerFromTeam(player); this.Footballers.Remove(player); OnPropertyChanged("Team"); } }); this.RemoveSeasonCommand = new DelegateCommand <Table>(async(Table table) => { if (table != null) { this.IsEnabled = GlobalCommands.BlockWindowButtons(); var result = await this.leagueService.RemoveTeamFromSeason(table.Id); if (result) { this.Tables.Remove(table); } else { await this.interactionService.ShowMessageBox("Cannot remove team from season", "This team is already included in fixtures"); } this.IsEnabled = GlobalCommands.UnlockWindowButtons(); } }); }
public override void Init() { if (containingAtom.type != "SessionPluginManager") { SuperController.LogError("Keybindings plugin can only be installed as a session plugin."); CreateTextField(new JSONStorableString("Error", "Keybindings plugin can only be installed as a session plugin.")); enabledJSON.val = false; return; } _settings = new KeybindingsSettings(); _prefabManager = new PrefabManager(); _keyMapManager = new KeyMapManager(); _analogMapManager = new AnalogMapManager(); _selectionHistoryManager = new SelectionHistoryManager(); _remoteCommandsManager = new RemoteCommandsManager(this, _selectionHistoryManager); _globalCommands = new GlobalCommands(this, containingAtom, _selectionHistoryManager, _remoteCommandsManager); _storage = new KeybindingsStorage(this, _keyMapManager, _analogMapManager, _settings); _overlayReference = new KeybindingsOverlayReference(); _analogHandler = new AnalogHandler(_remoteCommandsManager, _analogMapManager, _settings); _normalModeHandler = new NormalModeHandler(this, _settings, _keyMapManager, _overlayReference, _remoteCommandsManager); _findModeHandler = new FindModeHandler(this, _remoteCommandsManager, _overlayReference); SuperController.singleton.StartCoroutine(_prefabManager.LoadUIAssets()); AcquireBuiltInCommands(); _globalCommands.Init(); AcquireAllAvailableBroadcastingPlugins(); _storage.ImportDefaults(); EnterNormalMode(); // TODO: Map multiple bindings to the same action? _valid = true; }
public static void ForceEndVote(string user) => GlobalCommands.ForceEndVote(user);
public static void CancelVote(string user) => GlobalCommands.CancelVote(user);
public static void ShowVoteTime(string user) => GlobalCommands.ShowVoteTime(user);
public static void RemoveVote(string user) => GlobalCommands.RemoveVote(user);