private void LoadPictureIfPreviouslySelected(PlayerUserControl control) { if (_repository.PictureExists(control.Name)) { control.Image = Image.FromFile(_repository.GetPictureLocation(control.Name)); } }
private void tabControl_Selected(object sender, TabControlEventArgs e) { _goals.OrderByDescending(kvp => kvp.Value).ToList().ForEach(kvp => { var playerUserControl = new PlayerUserControl { PlayerName = kvp.Key, PlayerNumber = kvp.Value.ToString(), PositionVisible = false, CaptainVisible = false, CustomText = Resources.Resources.goals, Name = $@"{kvp.Key}" }; flpRankedByGoals.Controls.Add(playerUserControl); LoadPictureIfPreviouslySelected(playerUserControl); }); _yellowCards.OrderByDescending(kvp => kvp.Value).ToList().ForEach(kvp => { var playerUserControl = new PlayerUserControl { PlayerName = kvp.Key, PlayerNumber = kvp.Value.ToString(), PositionVisible = false, CaptainVisible = false, CustomText = Resources.Resources.cards, Name = $@"{kvp.Key}" }; flpRankByYellowCards.Controls.Add(playerUserControl); LoadPictureIfPreviouslySelected(playerUserControl); }); }
private void FlpAllPlayersContextMenu(PlayerUserControl puc) { contextMenuStrip.Items.Clear(); var loadImageItem = new ToolStripMenuItem { Text = Resources.Resources.loadPicture, Name = "loadImageItem" }; loadImageItem.Click += (s, e) => LoadPicture(puc); contextMenuStrip.Items.Add(loadImageItem); var favoritePlayerItem = new ToolStripMenuItem { Text = Resources.Resources.favoritePlayerItem, Name = "favoritePlayerItem" }; favoritePlayerItem.Click += (s, e) => { if (flpFavoritePlayers.Controls.Count >= 3) { return; } puc.StarVisible = true; puc.IsSelected = false; flpFavoritePlayers.Controls.Add(puc); var controlNames = flpFavoritePlayers.Controls.Cast <PlayerUserControl>() .Select(c => c.Name); _repository.SaveFavoritePlayers(controlNames); }; contextMenuStrip.Items.Add(favoritePlayerItem); }
private void ShowImageInForm(PlayerUserControl sender, string fileName) { //sender.pbPlayerPicture.ImageLocation = fileName; imagePaths[sender.PlayerName] = fileName; //imagePaths.Add(sender.PlayerName, fileName); //lvRangList.SmallImageList.Images.Add(sender.PlayerName, Image.FromFile(fileName)); LoadRangList(); }
private void Image_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e) { if (tcMain.Items.Count == 0 || (tcMain.Items[0] as BaseUserControl).filePath.Equals(String.Empty)) { if ((userControls[3] as BaseUserControl).filePath.Equals(String.Empty)) { return; } mLightList = (userControls[3] as BaseMakerLightUserControl).GetData(); } else { if (userControls[userControls.IndexOf((BaseUserControl)tcMain.Items[0])].IsMakerLightUserControl()) { BaseMakerLightUserControl baseMakerLightUserControl = tcMain.Items[0] as BaseMakerLightUserControl; mLightList = baseMakerLightUserControl.GetData(); } } mLightList = Business.LightBusiness.Copy(mLightList); UserControl userControl = null; if (sender == iPlayer) { //DeviceModel deviceModel = FileBusiness.CreateInstance().LoadDeviceModel(AppDomain.CurrentDomain.BaseDirectory + @"Device\" + playerDefault); //bToolChild.Width = deviceModel.DeviceSize; //bToolChild.Height = deviceModel.DeviceSize + 31; //bToolChild.Visibility = Visibility.Visible; //加入播放器页面 userControl = new PlayerUserControl(mw, mLightList); } else if (sender == iPaved) { //加入平铺页面 userControl = new ShowPavedUserControl(mw, mLightList); } else if (sender == iExport) { userControl = new ExportUserControl(mw, mLightList); } else if (sender == iPianoRoll) { userControl = new ShowPianoRollUserControl(mw, mLightList); } else if (sender == iData) { userControl = new DataGridUserControl(mw, mLightList); } else if (sender == iMy3D) { userControl = new My3DUserControl(mw, mLightList); } gTool.Children.Clear(); gTool.Children.Add(userControl); gToolBackGround.Visibility = Visibility.Visible; DoubleAnimation daV = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromSeconds(0.5))); userControl.BeginAnimation(OpacityProperty, daV); }
private void LoadPicture(PlayerUserControl playerUserControl) { if (_openFileDialog.ShowDialog() == DialogResult.OK) { var filePath = _openFileDialog.FileName; _repository.SaveLoadedPicturePath(playerUserControl.Name.Trim(), filePath.Trim()); playerUserControl.Image = Image.FromFile(filePath); } }
private void GetPlayerUserControls() { CleanupPlayerUserControls(); PlayerUserControl.NumberOfFavourites = 0; if (PlayersForSelectedTeam == null) { return; } // create new player user controls for (int i = 0; i < PlayersForSelectedTeam.Count; i++) { var player = PlayersForSelectedTeam[i]; var puc = new PlayerUserControl(ref player); if (PlayersForSelectedTeam[i].Favourite) { PlayerUserControl.NumberOfFavourites++; flpFavouritePlayers.Controls.Add(puc); } else { flpOtherPlayers.Controls.Add(puc); } // add event handlers puc.MouseDown += Puc_MouseDown; puc.MouseUp += Puc_MouseUp; puc.tsmiAddToFavourites.Click += TsmiAddToFavourites_Click; puc.tsmiSelect.Click += TsmiSelect_Click; puc.tsmiAddPicture.Click += TsmiAddPicture_Click; puc.imgFavourite.MouseClick += ImgFavourite_MouseClick; puc.pbPlayerPicture.MouseClick += PbPlayerPicture_MouseClick; foreach (Control control in puc.Controls) { control.MouseDown += Puc_MouseDown; control.MouseUp += Puc_MouseUp; } puc.imgFavourite.MouseDown -= Puc_MouseDown; puc.imgFavourite.MouseUp -= Puc_MouseUp; puc.pbPlayerPicture.MouseDown -= Puc_MouseDown; puc.pbPlayerPicture.MouseUp -= Puc_MouseUp; PUCs.Add(puc); } }
public AIControlDisabler() { GameObject[] bears = GameObject.FindGameObjectsWithTag("Bear"); GameObject player = GameObject.FindGameObjectWithTag("Player"); playerControl = player.GetComponent <PlayerUserControl>(); playerCharacter = player.GetComponent <PlayerCharacter>(); bearAgents = new NavMeshAgent[bears.Length]; for (int i = 0; i < bears.Length; i++) { bearAgents[i] = bears[i].GetComponent <NavMeshAgent>(); } }
private void AddPlayerUserControlToCorrespondingPanel(PlayerUserControl puc) { if (puc.Favourite) { if (!flpFavouritePlayers.Controls.Contains(puc)) { flpFavouritePlayers.Controls.Add(puc); } } else { if (!flpOtherPlayers.Controls.Contains(puc)) { flpOtherPlayers.Controls.Add(puc); } } //flpFavouritePlayers.Controls.AddRange(selectedOtherPUCs.Where(x => x.Favourite).ToArray()); }
private void FlpFavoritePlayersContextMenu(PlayerUserControl puc) { contextMenuStrip.Items.Clear(); var favoritePlayerItem = new ToolStripMenuItem { Text = Resources.Resources.removeFavoritePlayer, Name = "removeFavoritePlayer" }; favoritePlayerItem.Click += (s, e) => { puc.StarVisible = false; flpAllPlayers.Controls.Add(puc); var controlNames = flpFavoritePlayers.Controls.Cast <PlayerUserControl>() .Select(c => c.Name); _repository.SaveFavoritePlayers(controlNames); }; contextMenuStrip.Items.Add(favoritePlayerItem); }
public void OnNext(IGame value) { this.game = value; try { if (levelUC == null) { Player player = game.GetPlayer(); playerUC = new PlayerUserControl(player); playerUCGrid.Children.Add(playerUC); levelUC = new LevelUserControl(game); levelUCGrid.Children.Add(levelUC); levelUC.Focus(); } Update(); } catch (Exception ex) { Debug.WriteLine("Eroare in mainwindow : " + ex.Message); } }
private void ShowData() { if (showModel == -1) { return; } List <Light> mLightList = mw.GetData(); UserControl userControl = null; if (showModel == 0) { //DeviceModel deviceModel = FileBusiness.CreateInstance().LoadDeviceModel(AppDomain.CurrentDomain.BaseDirectory + @"Device\" + playerDefault); //bToolChild.Width = deviceModel.DeviceSize; //bToolChild.Height = deviceModel.DeviceSize + 31; //bToolChild.Visibility = Visibility.Visible; //加入播放器页面 if (!(mw.editUserControl.userControls[3] as BaseUserControl).filePath.Equals(String.Empty)) { String strAudioResources = (mw.editUserControl.userControls[3] as ScriptUserControl).AudioResources; if (!strAudioResources.Contains(@"\")) { //说明是不完整路径 strAudioResources = mw.LastProjectPath + @"Audio\" + strAudioResources; } if (File.Exists(strAudioResources)) { userControl = new PlayerUserControl(mw, mLightList, strAudioResources, (mw.editUserControl.userControls[3] as ScriptUserControl).nowTimeP, (mw.editUserControl.userControls[3] as ScriptUserControl).nowTimeI); } else { userControl = new PlayerUserControl(mw, mLightList); } } else { userControl = new PlayerUserControl(mw, mLightList); } } else if (showModel == 1) { //加入平铺页面 userControl = new ShowPavedUserControl(mw, mLightList); } else if (showModel == 2) { userControl = new ExportUserControl(mw, mLightList); } else if (showModel == 3) { userControl = new ShowPianoRollUserControl(mw, mLightList); } else if (showModel == 4) { userControl = new DataGridUserControl(mw, mLightList); } else if (showModel == 5) { userControl = new My3DUserControl(mw, mLightList); } spBottomTool.Children.Clear(); spBottomTool.Children.Add(userControl); //spPlay.Children.Clear(); //Point point = iPlay.TranslatePoint(new Point(0, 0), this); //spPlay.Margin = new Thickness(0, point.Y + SystemParameters.CaptionHeight, 0, 0); //spPlay.Children.Add(userControl); //gToolBackGround.Visibility = Visibility.Visible; }
private async void LoadPanelWithPlayersAsync(dynamic team) { try { _goals.Clear(); _yellowCards.Clear(); flpRankByAttendances.Controls.Clear(); var country = team is Team t ? t.Country : team as string; // show loading animation var busyIndicator = new BusyIndicator(); busyIndicator.Show(flpAllPlayers); // get API data var teamGender = _repository.GetTeamGender(); var endpoint = EndpointBuilder.GetMatchesEndpoint(teamGender); var matches = await _api.GetDataAsync <IList <Match> >(endpoint); // find all players for selected team var match = matches?.FirstOrDefault(m => m.HomeTeamCountry == country); var players = match?.HomeTeamStatistics.StartingEleven.Union(match.HomeTeamStatistics.Substitutes).ToList(); // load all players to FlowLayoutPanel players?.ForEach(p => { var playerUserControl = new PlayerUserControl { PlayerName = p.Name, PlayerNumber = p.ShirtNumber.ToString(), PlayerPosition = p.Position.ToString(), Captain = p.Captain ? Resources.Resources.yes : Resources.Resources.no, Name = $"{p.Name}" }; LoadPictureIfPreviouslySelected(playerUserControl); flpAllPlayers.Controls.Add(playerUserControl); playerUserControl.MouseDown += PlayerUserControl_MouseDown; _goals.Add(p.Name, 0); _yellowCards.Add(p.Name, 0); }); // Get goals and yellow cards per each player matches? .Where(m => m.HomeTeamCountry == match?.HomeTeamCountry) .ToList() .ForEach(m => { m.HomeTeamEvents.ToList().ForEach(te => { switch (te.TypeOfEvent) { case TypeOfEvent.Goal: _goals[te.Player] += 1; break; case TypeOfEvent.YellowCard: _yellowCards[te.Player] += 1; break; case TypeOfEvent.YellowCardSecond: _yellowCards[te.Player] += 1; break; } }); }); // Get all matches for selected country ordered by attendance matches? .Where(m => m.HomeTeamCountry == match?.HomeTeamCountry || m.AwayTeamCountry == match?.HomeTeamCountry) .OrderByDescending(m => m.Attendance) .ToList() .ForEach(m => { flpRankByAttendances.Controls.Add(new MatchUserControl { Location = m.Location, Attendances = m.Attendance.ToString(), HomeTeam = m.HomeTeamCountry, AwayTeam = m.AwayTeamCountry }); }); LoadFavoritePlayers(); busyIndicator.Hide(); } catch (Exception ex) when(ex is IOException || ex is ArgumentNullException || ex is JsonReaderException) { MessageBox.Show(Resources.Resources.dataNotLoaded, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private async void LoadPanelWithPlayersAsync(dynamic team, bool awayTeam) { try { LoadingSpinner.Visibility = Visibility.Visible; LoadingSpinner.Spin = true; Panel panel; var country = awayTeam ? (team as MatchTeam)?.Country : team is Team t ? t.Country : team as string; // get API data var teamGender = _repository.GetTeamGender(); var endpoint = EndpointBuilder.GetMatchesEndpoint(teamGender); var matches = await _api.GetDataAsync <IList <Match> >(endpoint); // find all players for selected team var match = matches?.FirstOrDefault(m => m.HomeTeamCountry == country); var players = match?.HomeTeamStatistics.StartingEleven.ToList(); // load all players to FlowLayoutPanel players?.ForEach(p => { var playerUserControl = new PlayerUserControl(p.Name, (int)p.ShirtNumber) { MaxHeight = 140, MaxWidth = 120, BtnUserControl = { ClickMode = ClickMode.Press } }; playerUserControl.BtnUserControl.Click += OnUserControlClick; switch (p.Position) { case Position.Defender: panel = awayTeam ? PnlAwayTeamDefender : PnlHomeTeamDefender; panel.Children.Add(playerUserControl); break; case Position.Forward: panel = awayTeam ? PnlAwayTeamForward : PnlHomeTeamForward; panel.Children.Add(playerUserControl); break; case Position.Goalie: panel = awayTeam ? PnlAwayTeamGoalie : PnlHomeTeamGoalie; panel.Children.Add(playerUserControl); break; case Position.Midfield: panel = awayTeam ? PnlAwayTeamMidfield : PnlHomeTeamMidfield; panel.Children.Add(playerUserControl); break; default: return; } LoadingSpinner.Visibility = Visibility.Hidden; LoadingSpinner.Spin = false; }); } catch (Exception ex) when(ex is IOException || ex is JsonReaderException || ex is ArgumentNullException) { MessageBox.Show("Could not retrieve data", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void DragCompleted(object sender, System.Windows.Controls.Primitives.DragCompletedEventArgs e) { Thumb thumb = sender as Thumb; int position = -1; if (thumb == thumb_player) { position = 0; } else if (thumb == thumb_paved) { position = 1; } if (position == -1) { return; } double left = Canvas.GetLeft(thumb); if (left > gd.ActualWidth / 3 * 2 || (gMain.Children[0] as BaseUserControl).filePath.Equals(String.Empty)) { thumb.RenderTransformOrigin = new Point(0.5, 0.5); if (position == 0) { thumb.RenderTransform = MatrixTransform_01; } else if (position == 1) { thumb.RenderTransform = MatrixTransform_02; } double top = Canvas.GetTop(thumb); QuadraticBezierSegment quadraticBezierSegment = new QuadraticBezierSegment(); quadraticBezierSegment.Point1 = new Point((startPoints[position].X - left) / 2, (top - startPoints[position].Y) / 2); quadraticBezierSegment.Point2 = new Point(startPoints[position].X - left, startPoints[position].Y - top); PathSegmentCollection pathSegmentCollection = new PathSegmentCollection(); pathSegmentCollection.Add(quadraticBezierSegment); PathFigure pathFigure = new PathFigure(); pathFigure.StartPoint = new Point(0, 0); pathFigure.Segments = pathSegmentCollection; PathFigureCollection pathFigureCollection = new PathFigureCollection(); pathFigureCollection.Add(pathFigure); PathGeometry pathGeometry = new PathGeometry(); pathGeometry.Figures = pathFigureCollection; MatrixAnimationUsingPath matrixAnimation = new MatrixAnimationUsingPath(); matrixAnimation.PathGeometry = pathGeometry; //动画的路径 matrixAnimation.Duration = TimeSpan.FromSeconds(0.5); matrixAnimation.Completed += MatrixAnimation_Completed; //matrixAnimation.FillBehavior = FillBehavior.Stop; //matrixAnimation.RepeatBehavior = RepeatBehavior.Forever; //matrixAnimation.DoesRotateWithTangent = true; //Storyboard.SetTarget(matrixAnimation, thumb); if (position == 0) { Storyboard.SetTargetName(matrixAnimation, "MatrixTransform_01");//动画的对象 } else if (position == 1) { Storyboard.SetTargetName(matrixAnimation, "MatrixTransform_02");//动画的对象 } Storyboard.SetTargetProperty(matrixAnimation, new PropertyPath(MatrixTransform.MatrixProperty)); Storyboard pathAnimationStoryboard = new Storyboard(); pathAnimationStoryboard.Children.Add(matrixAnimation); pathAnimationStoryboard.Begin(this); } else { BaseMakerLightUserControl baseMakerLightUserControl = gMain.Children[0] as BaseMakerLightUserControl; UserControl userControl = null; if (position == 0) { //加入播放器页面 PlayerUserControl playerUserControl = new PlayerUserControl(mw); playerUserControl.SetData(baseMakerLightUserControl.GetData()); userControl = playerUserControl; } else if (position == 1) { //加入平铺页面 //PavedUserControl pavedUserControl = new PavedUserControl(this,baseMakerLightUserControl.GetData()); //userControl = pavedUserControl; } gMost.Children.Add(userControl); DoubleAnimation daV = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromSeconds(0.5))); userControl.BeginAnimation(OpacityProperty, daV); //回原位 ToolBackToOld(thumb, position); } }