public Listener Attach <A>(int priority, Action <A> func) where A : T { if (!actions.ContainsKey(typeof(A))) { actions[typeof(A)] = new ActionListContainer <A>(); } Listener final = new Listener(typeof(A), func, priority); actions[typeof(A)].Add(final, priority); return(final); }
public IEnumerator Post <A>(A _args) where A : T { if (actions != null && actions.ContainsKey(typeof(A))) { ActionListContainer <A> action_list = actions[typeof(A)] as ActionListContainer <A>; List <Listener> temp = new List <Listener>(action_list); for (int i = 0; i < temp.Count; i++) { Listener it = temp[i]; if (it == null) { continue; } (it._delegate as System.Action <A>)(_args); } } if (routines != null && routines.ContainsKey(typeof(A))) { RoutineListContainer <A> routine_list = routines[typeof(A)] as RoutineListContainer <A>; //Extensions.RunInfo inf = null; List <RoutineListener <A> > temp = new List <RoutineListener <A> >(routine_list); for (int i = 0; i < temp.Count; i++) { RoutineListener <A> it = temp[i]; if (it == null) { continue; } /* * if (routine_list.parallel) * { * inf = it._delegate(_args).ParallelCoroutine(typeof(A).ToString()); * } * else */ yield return(it._delegate(_args)); } /* if (routine_list.parallel) * { * while (inf.count > 0) yield return null; * } */ } }
private void load() { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; Child = new Container { RelativeSizeAxes = Axes.X, Height = 50, Children = new Drawable[] { new Box { RelativeSizeAxes = Axes.Both, Colour = Color4.Beige, }, new Container { Anchor = Anchor.BottomRight, Origin = Anchor.BottomRight, RelativeSizeAxes = Axes.Y, Width = 100, Child = new AutoSizeButton { RelativeSizeAxes = Axes.Both, Text = @"Añadir acción", Action = toggleAvailableEvents, }, }, possibleEventsList = new ActionListContainer(), }, }; currentEditing.BindTo(editor.CurrentEditingElement); currentEditing.BindValueChanged(_ => possibleEventsList.Hide(), true); // ReSharper disable once ForeachCanBePartlyConvertedToQueryUsingAnotherGetEnumerator foreach (var type in WorkingProject.AvailableActions.Values) { var defaultAction = Activator.CreateInstance(type) as EventAction; possibleEventsList.AddPossibility(defaultAction); } }
private async void ImportButton_Click(object sender, RoutedEventArgs e) { await this.window.RunAsyncOperation(async() => { string fileName = ChannelSession.Services.FileService.ShowOpenFileDialog("Mix It Up Command (*.mixitupc)|*.mixitupc|All files (*.*)|*.*"); if (!string.IsNullOrEmpty(fileName)) { try { ActionListContainer actionContainer = await FileSerializerHelper.DeserializeFromFile <ActionListContainer>(fileName); if (actionContainer != null && actionContainer.Actions != null) { foreach (ActionBase action in actionContainer.Actions) { ActionContainerControl actionControl = new ActionContainerControl(this.window, this, action); actionControl.Minimize(); this.actionControls.Add(actionControl); } } } catch (Exception ex) { Logger.Log(ex); } } }); }