void StarChangedHandler(object sender, StarChangedEventArgs e) { StarControl starControl = null; if (_stars.ContainsKey(e.StarThatChanged)) { starControl = _stars[e.StarThatChanged]; } if (e.Removed && starControl != null) { _fadedStars.Add(starControl); _stars.Remove(e.StarThatChanged); starControl.FadeOut(); return; } else if (starControl == null) { starControl = new StarControl(); if (_stars.ContainsKey(e.StarThatChanged)) { _stars[e.StarThatChanged] = starControl; } else { _stars.Add(e.StarThatChanged, starControl); } _sprites.Add(starControl); starControl.FadeIn(); BeeStarHelper.SendToBack(starControl); } BeeStarHelper.SetCanvasLocation(starControl, e.StarThatChanged.Location.X, e.StarThatChanged.Location.Y); }
void StarChangedHandler(object sender, StarChangedEventArgs e) { if (e.Removed) { StarControl starControl = _stars[e.StarThatChanged]; _stars.Remove(e.StarThatChanged); _fadedStars.Add(starControl); starControl.FadeOut(); } else { StarControl newStar; if (_stars.ContainsKey(e.StarThatChanged)) newStar = _stars[e.StarThatChanged]; else { newStar = new StarControl(); _stars[e.StarThatChanged] = newStar; newStar.FadeIn(); BeeStarHelper.SendToBack(newStar); _sprites.Add(newStar); } BeeStarHelper.SetCanvasLocation( newStar, e.StarThatChanged.Location.X, e.StarThatChanged.Location.Y); } }
void ModelStarChangedEventHandler(object sender, StarChangedEventArgs e) { if (e.Disappeared && _stars.ContainsKey(e.Point)) { FrameworkElement control = _stars[e.Point]; _sprites.Remove(control); } else { if (!_stars.ContainsKey(e.Point)) { FrameworkElement control = InvadersHelper.StarControlFactory(e.Point, Scale); _stars.Add(e.Point, control); _sprites.Add(control); } else { //Stars typically won't change locations, so this else clause probably won't //get hit—but you can use it to add shooting stars if you //want.Look up the star's control in _stars and use a //helper method to move it to the new location. //Random random = new Random(); } } }
void StarChangedHandler(object sender, StarChangedEventArgs e) { if (e.Removed)//if removed than move to faded stars collection { StarControl starControl = _stars[e.StarThatChanged]; _stars.Remove(e.StarThatChanged); _fadedStars.Add(starControl); starControl.FadeOut(); } else {//if exsits then take reference StarControl newStar; if (_stars.ContainsKey(e.StarThatChanged)) { newStar = _stars[e.StarThatChanged]; } else//else create one and add to sprites collection { newStar = new StarControl(); _stars[e.StarThatChanged] = newStar; newStar.Fadein(); Helper.SendToBack(newStar); _sprites.Add(newStar); } Helper.SetCanvasLocation(newStar, e.StarThatChanged.Location.X, e.StarThatChanged.Location.Y); } }
void StarChangedHandler(object sender, StarChangedEventArgs e) { if (e.Removed) { StarControl starControl = _stars[e.StarThatChanged]; _stars.Remove(e.StarThatChanged); _fadedStars.Add(starControl); starControl.FadeOut(); } else { StarControl newStar; if (_stars.ContainsKey(e.StarThatChanged)) { newStar = _stars[e.StarThatChanged]; } else { newStar = new StarControl(); _stars[e.StarThatChanged] = newStar; newStar.FadeIn(); BeeStarHelper.SendToBack(newStar); _sprites.Add(newStar); } BeeStarHelper.SetCanvasLocation( newStar, e.StarThatChanged.Location.X, e.StarThatChanged.Location.Y); } }
private void _model_StarChanged(object sender, StarChangedEventArgs e) { if (e.Removed && _stars.ContainsKey(e.StarThatChanged)) { StarControl starRemoved = _stars[e.StarThatChanged]; _fadedStars.Add(starRemoved); _stars.Remove(e.StarThatChanged); starRemoved.FadeOut(); } else { StarControl starToBeShown; if (_stars.ContainsKey(e.StarThatChanged)) { starToBeShown = _stars[e.StarThatChanged]; } else { starToBeShown = new StarControl(); starToBeShown.FadeIn(); _sprites.Add(starToBeShown); BeeStarHelper.SentToBack(starToBeShown); } BeeStarHelper.SetCanvasLocation(starToBeShown, e.StarThatChanged.Location.X, e.StarThatChanged.Location.Y); } }
private void StarChangedHandler(object sender, StarChangedEventArgs e) { if (_stars.ContainsKey(e.StarThatChanged)) { if (e.Removed) { _fadedStars.Add(_stars[e.StarThatChanged]); _stars[e.StarThatChanged].FadeOut(); _stars.Remove(e.StarThatChanged); } else { BeeStarHelper.SetCanvasLocation(_stars[e.StarThatChanged], e.StarThatChanged.Location.X, e.StarThatChanged.Location.Y); } } else { StarControl newStarControl = new StarControl(); newStarControl.FadeIn(); _stars.Add(e.StarThatChanged, newStarControl); _sprites.Add(newStarControl); BeeStarHelper.SendToBack(newStarControl); BeeStarHelper.SetCanvasLocation(newStarControl, e.StarThatChanged.Location.X, e.StarThatChanged.Location.Y); } }
private void ModelStarChangedEventHandler(object sender, StarChangedEventArgs e) { if (e.Disappeared && _stars.ContainsKey(e.Point)) { FrameworkElement control = _stars[e.Point]; _sprites.Remove(control); } else { if (!_stars.ContainsKey(e.Point)) { FrameworkElement starControl = InvadersHelper.StarControlFactory(Scale); InvadersHelper.SendToBack(starControl); _stars.Add(e.Point, starControl); _sprites.Add(starControl); InvadersHelper.SetCanvasLocation(starControl, e.Point.X, e.Point.Y, Scale); } else { // Create a shooting star FrameworkElement starControl = _stars[e.Point]; InvadersHelper.MoveElementOnCanvas(starControl, InvadersModel.PlayAreaSize.Width, InvadersModel.PlayAreaSize.Height, Scale); } } }
void StarChangedHandler(object sender, StarChangedEventArgs e) { // The _stars dictionary works just like the _bees one, except that it maps Star objects // to their corresponding StarControl controls. The EventArgs contains references to // the Star object (which has a Location property) and a Boolean to tell you if the star // was removed. If it is then we want it to fade out, so remove it from _stars, add it // to _fadedStars, and call its FadeOut() method (it'll be removed from _sprites the next // time the Update() method is called, which is why we set the timer’s tick interval to // be greater than the StarControl's fade out animation). if (e.Removed) { StarControl starControl = _stars[e.StarThatChanged]; _stars.Remove(e.StarThatChanged); _fadedStars.Add(starControl); starControl.FadeOut(); } // // If the star is not being removed, then check to see if _stars contains it - if so, get // the StarControl reference; if not, you'll need to create a new StarControl, fade it in, // add it to _sprites, and send it to back so the bees can fly in front of it. Then set // the canvas location for the StarControl. else { StarControl starControl; if (!_stars.ContainsKey(e.StarThatChanged)) { starControl = new StarControl(); _stars.Add(e.StarThatChanged, starControl); starControl.FadeIn(); starControl.Rotate(e.StarThatChanged.Rotating); _sprites.Add(starControl); BeeStarHelper.SendToBack(starControl); } else { starControl = _stars[e.StarThatChanged]; } BeeStarHelper.SetCanvasLocation(starControl, e.StarThatChanged.Location.X, e.StarThatChanged.Location.Y); } }
private void ModelStarChangedEventHandler(object sender, StarChangedEventArgs e) { if (e.isDisappeared && _stars.ContainsKey(e.Point)) { FrameworkElement starControl = _stars[e.Point]; _sprites.Remove(starControl); } else { if (!_stars.ContainsKey(e.Point)) { FrameworkElement starControl = InvadersHelper.StarControlFactory(e.Point, Scale); _stars[e.Point] = starControl; _sprites.Add(starControl); } else { FrameworkElement starControl = _stars[e.Point]; InvadersHelper.SetCanvasLocation(starControl, e.Point.X * Scale, e.Point.Y * Scale); } } }
private void StarChangedHandler(object sender, StarChangedEventArgs e) { Point star = e.StarThatChanged; if (e.Removed) { if (_starDictionary.ContainsKey(e.StarThatChanged)) { StarControl starControl = _starDictionary[e.StarThatChanged]; _starDictionary.Remove(e.StarThatChanged); _fadedStars.Add(starControl, DateTime.Now); starControl.FadeOut(); //// not sure where to put this resize element method //InvadersHelper.ResizeElement(starControl, e.StarThatChanged.X * Scale, e.StarThatChanged.Y * Scale, // e.StarThatChanged.X * Scale, e.StarThatChanged.Y * Scale, Scale); } } else { StarControl newStar; if (_starDictionary.ContainsKey(e.StarThatChanged)) { newStar = _starDictionary[e.StarThatChanged]; } else { newStar = InvadersHelper.StarControlFactory(star, Scale) as StarControl; _starDictionary[e.StarThatChanged] = newStar; newStar.FadeIn(); _sprites.Add(newStar); } //InvadersHelper.SetCanvasLocation(newStar, e.StarThatChanged.X, e.StarThatChanged.Y, Scale); //// not sure where to put this resize element method //InvadersHelper.ResizeElement(newStar, e.StarThatChanged.X * Scale, e.StarThatChanged.Y * Scale, // e.StarThatChanged.X * Scale, e.StarThatChanged.Y * Scale, Scale); } }
private void ModelStarChangedEventHandler(object sender, StarChangedEventArgs e) { if (e.Disappeared && _stars.ContainsKey(e.Point)) { _sprites.Remove(_stars[e.Point]); _stars.Remove(e.Point); } else { if (!_stars.ContainsKey(e.Point)) { var starControl = InvadersHelper.StarControlFactory(e.Point, Scale); _stars.Add(e.Point, starControl); _sprites.Add(starControl); } else { var starControl = _stars[e.Point]; InvadersHelper.MoveElementOnCanvas(starControl, e.Point.X * Scale, e.Point.Y * Scale); } } }
private void ModelStarChangedEventHandler(object sender, StarChangedEventArgs e) { if (e.Disappeared && _stars.ContainsKey(e.Point)) { FrameworkElement starToRemove = _stars[e.Point]; _sprites.Remove(starToRemove); } else { if (!_stars.ContainsKey(e.Point)) { FrameworkElement newStar = InvadersHelper.StarControlFactory(e.Point, Scale); _stars[e.Point] = newStar; _sprites.Add(newStar); } } }
private void OnStarChanged(StarChangedEventArgs e) { var starChangedEventHandler = StarChanged; if (starChangedEventHandler != null) starChangedEventHandler(this, e); }
private void _model_StarChanged(object sender, StarChangedEventArgs e) { Star starThatChanged = e.StarThatChanged; if (e.Removed) { StarControl starControl = _stars[starThatChanged]; _fadedStars.Add(starControl); _stars.Remove(starThatChanged); starControl.FadeOut(); } else { if(_stars.ContainsKey(starThatChanged)) { StarControl starControl; _stars.TryGetValue(starThatChanged,out starControl); if(starControl == null) { starControl = new StarControl(); BeeStarHelper.SendToBack(starControl); starControl.FadeIn(); _sprites.Add(starControl); _stars[starThatChanged] = starControl; BeeStarHelper.SetCanvasLocation(starControl, starThatChanged.Location.X, starThatChanged.Location.Y); } } } }
private void _model_StarChanged(object sender, StarChangedEventArgs e) { throw new NotImplementedException(); }