protected void SubscribeToUndo(EventHandler handler) { ProgramEventHandler ph = s => realizer.Undo -= handler; ph += s => this.ProgramStateChanged -= ph; handler += (s, e) => { realizer.Undo -= handler; this.ProgramStateChanged -= ph; }; realizer.Undo += handler; this.ProgramStateChanged += ph; }
void customMapsControl_OpenCustomMap(string mapFileName) { var oldProfileMenu = Program.Instance.ProfileMenuDefault; Program.Instance.ProfileMenuDefault = ProfileMenuType.MainMenu; Program.Instance.Profile = Profile.NewDeveloper(); var game = new Game.Game(mapFileName); Program.Instance.ProgramState = game; ProgramEventHandler p = null; p = (e) => { if (e.Type == ProgramEventType.ProgramStateChanged) { Program.Instance.ProfileMenuDefault = oldProfileMenu; Program.Instance.ProgramEvent -= p; } }; Program.Instance.ProgramEvent += p; }
public void Remove(ProgramEventHandler handler) { _removeAction(handler); }
public void Add(ProgramEventHandler handler) { _addAction(handler); }