private static List <Result> SetInitial(List <Result> results) { results.Clear(); results.Add(new Result() { Title = "All Devices", IcoPath = "Images\\rotate.png", SubTitle = "Rotate to initial orientation", Action = (c) => { MyDisplay.ResetAllRotations(); return(true); } }); return(results); }
public List <Result> Query(Query query) { var results = new List <Result>(); Device device = null; int deviceIndex = 0; if (query.Search == String.Empty) { return(HelloWorld(results)); } else { try { deviceIndex = Convert.ToInt32(query.FirstSearch); } catch { deviceIndex = 0; } if (deviceIndex != 0) { device = MyDisplay.GetDisplay(Convert.ToUInt32(deviceIndex)); if (device == null) { Result rotateResult = new Result() { Title = "No device?!", }; results.Add(rotateResult); } else { results.Clear(); if (query.SecondSearch == string.Empty) { foreach (var direction in RotationDict.Keys) { Result rotateResult = new Result() { Title = device.ToString(), IcoPath = "Images\\rotate.png", SubTitle = String.Format("Rotated direction: ClockWise {0}", direction), Action = (c) => MyDisplay.Rotate(Convert.ToUInt32(deviceIndex), RotationDict[direction]) }; results.Add(rotateResult); } } else { var selectedDirection = RotationDict.Keys .Where(e => e.Contains(query.SecondSearch.ToUpper())).ToList(); if (selectedDirection.Count() != 0) { foreach (var direction in selectedDirection) { Result rotateResult = new Result() { Title = device.ToString(), IcoPath = "Images\\rotate.png", SubTitle = String.Format("Rotated direction: ClockWise {0}", direction), Action = (c) => MyDisplay.Rotate(Convert.ToUInt32(deviceIndex), RotationDict[direction]) }; results.Add(rotateResult); } } } } } else { return(SetInitial(results)); } } return(results); }