public async Task <ActionResult> Index(string lastEditedEffectId) { var filter = new EffectFilter(); // Get values from database. var effects = await _effectService.GetAllAsync(filter); var categories = await _categoryService.GetAllAsync(new CategoryFilter()); IList <EffectViewModel> effectViewModels = new List <EffectViewModel>(); // Create list of effects for view. foreach (var effect in effects) { var model = new EffectViewModel(effect, null); effectViewModels.Add(model); } // Create view model for Index view. var effectViewModelIndex = new EffectViewModelIndex(effectViewModels, categories); // Set value to where to scroll to. effectViewModelIndex.LastEditedEffectId = lastEditedEffectId; return(View(effectViewModelIndex)); }
/*public override void checkingConnection(InputStuff effectFilter) * { * // Copy and paste the list of object in the radius of the generator in a local list. * List<ReactableObject> objectList = new List<ReactableObject>(); * effectFilter.ObjectsInRadius.ForEach(objectList.Add); * * //Takes the nearest object of the list of object. * ReactableObject nearestObject = effectFilter.nearestObject(objectList); * bool connectionCheck = false; * * // Condition: the effect or the filter has got an object ,at least one, in its radius. * if (nearestObject != null) * { * // Condition: If the nearest object is an effect filter which is already connected. * if (nearestObject.InputObject != null && nearestObject is EffectFilter * // && !effectFilter.Equals(nearestObject.InputObject[0]) * ) * { * // To leave: a connection has been established or every objects in the effect or filter's radius are not available to be connected. * while (!connectionCheck && nearestObject != null && objectList.Count > 0) * { * // If a connection is available with the filter or if the filter is already connected with the generator * if (nearestObject.InputObject[0] == null || nearestObject.InputObject[0].Equals(effectFilter)) * { * // Creates or updates the connection * connection(effectFilter, nearestObject); * connectionCheck = true; * } * // If the nearest object has already got a connected object, we check if the connected object is more distant of the generator or not * if (nearestObject.distanceCalculation(nearestObject.InputObject[0]) > effectFilter.distanceCalculation(nearestObject)) * { * // If the generator is more close, a new connection is established. * connection(effectFilter, nearestObject); * connectionCheck = true; * } * // If a connection is not available with the given nearest object. * if (!connectionCheck) * { * // Creates a temporary list which stores the current list of object * List<ReactableObject> temp = new List<ReactableObject>(); * objectList.ForEach(temp.Add); * // Clear the old list * objectList.Clear(); * * // Updates the list of object which has got the objects in the generator's radius, * // without the previous nearest object. * foreach (ReactableObject reactableObject in temp) * { * if (!reactableObject.Equals(nearestObject)) * objectList.Add(reactableObject); * } * // Gets the new nearest object * nearestObject = effectFilter.nearestObject(objectList); * } * } * // If the connection has not been established. * if (nearestObject == null && !connectionCheck) * { * // The connection will be done with the output. * connection(effectFilter, SmartBoard.output); * } * } * // Condition: If the nearest object is not connected. * else * { * //The connection can be established with the given object * connection(effectFilter, nearestObject); * } * } * * // Condition: the generator has not got an object near its. * else if (!connectionCheck) * { * // Then the connection is established with the output * connection(effectFilter, SmartBoard.output); * } * * // Saves the previous object which has been connected. * previousConnectedObject = null; * if (nearestObject != null) * { * previousConnectedObject = nearestObject; * } * }*/ public void debug(EffectFilter f1) { Console.WriteLine("hello, Im the filter X={0} Y={1}", f1.getX(), f1.getY()); if (f1.ConnectedObjects != null) { foreach (EffectFilter effectFilter in f1.ConnectedObjects) { Console.WriteLine(effectFilter.getX()); } } }
public async Task <JsonResult> GetEffectNames() { var filter = new EffectFilter(); // Get all effects from database. var effects = await _effectService.GetAllAsync(filter); // Create array of effect names. var effectNames = effects.Select(e => e.Name).ToArray(); Log.Info($"Effect names '{string.Join(", ", effectNames)}' where loaded."); // TODO: check this //return new JsonResult {Data = effectNames, JsonRequestBehavior = JsonRequestBehavior.AllowGet}; return(new JsonResult(effectNames)); }
//Sets the effect and applies it, allows for asynchronous or sychronous execution public void SetSpecialEffect(EffectFilter filter, bool interrupt) { specialEffect = filter; if (interrupt) { if (worker != null) { worker.Abort(); while (worker.IsAlive) { Thread.Sleep(10); } } working = true; ApplyEffect(); ImageChanged(); working = false; } else { if (!working) { working = true; worker = new Thread(new ThreadStart(delegate() { ApplyEffect(); Dispatcher.Invoke(DispatcherPriority.Normal, new DispatcherOperationCallback(delegate(object arg) { ImageChanged(); return(null); } ), null); working = false; })); worker.SetApartmentState(ApartmentState.STA); worker.Start(); } } }