public virtual ResourceCollection <Subscription> Search(SearchDelegate searchDelegate) { var query = new SubscriptionSearchRequest(); searchDelegate(query); return(Search(query)); }
public Uri SearchFor(IRequest criteria) { IEnumerable <IPeer> peers = Peer.Self.PeerContainer.GetAvailablePeers(); foreach (var peer in peers) { SearchDelegate del = peer.SearchEngine.StartSearching; IAsyncResult result = del.BeginInvoke(criteria, null, null); if (result.IsCompleted) { try { del.EndInvoke(result); } catch (WebException) { Peer.Self.PeerContainer.RemovePeer(peer); } catch (RemotingException) { Peer.Self.PeerContainer.RemovePeer(peer); } } } return(null); }
private void btnSearchZanr_Click(object sender, EventArgs e) { SearchDelegate search = new SearchDelegate(SearchList); search(listZanr, txtSrchZanr); txtSrchNaslov.Focus(); }
public void ButtonWonder_Click(object sender, RoutedEventArgs e) { globalFuncs.scoutTimer.start(); if (searching) { stopSearching = true; searching = false; return; } this.windowMain.CurrentGameDate.Text = context.fm.MetaData.IngameDate.ToLongDateString(); this.windowMain.vm.tabteams.TextBlockText = globalFuncs.localization.WindowMainLabels[2]; this.vm.wonder.TextBlockText = globalFuncs.localization.SearchingResults[ScoutLocalization.SR_STOP]; //this.ButtonWonder.IsEnabled = false; this.vm.results.Text = globalFuncs.localization.SearchingResults[ScoutLocalization.SR_SEARCHING] + "..."; setControlAvailability(false); this.ButtonSearch.IsEnabled = false; SearchDelegate d = new SearchDelegate(this.retrieveFieldsWonder); d.BeginInvoke(null, null); ProgressBarDelegate p = new ProgressBarDelegate(this.updateProgressBar); p.BeginInvoke(null, null); }
protected override void Start() { // Subscribe to robot sensors so we are able to receive data from the robot SubscribeToTouchSensor(); SubscribeToLightSensor(); SubscribeToButtonSensor(); SubscribeToDriveSensor(); SubscribeToColorSensor(); // Turn on spotlight _nxtLightSensorPort.Spotlight(true); // Define initial search pattern (Default) // Search right first then left FirstSearch = SearchRight; SecondSearch = SearchLeft; // Set initial direction to straight currentDirection = Direction.STRAIGHT; // Start main program timer mainTimer.Elapsed += new ElapsedEventHandler(MainLoop); mainTimer.Interval = 50; // Decide what to do every 50ms mainTimer.Start(); queueTimer.Elapsed += new ElapsedEventHandler(queueHandler); queueTimer.Interval = 100; base.Start(); }
public static ReturnType SearchBreadthFirst <T, ReturnType>(T origin, ReturnType startValue, SearchDelegate <T, ReturnType> .SearchMethod strategy) where T : GraphElement <T> { var value = startValue; var nodes = new List <T> { origin }; var startIndex = 0; int count = nodes.Count; while (startIndex < count) { for (var index = startIndex; index < count; index++) { if (!strategy(nodes[index], ref value)) { return(value); } foreach (T neighbor in nodes[index].Neighbors) { if (!nodes.Contains(neighbor)) { nodes.Add(neighbor); } } } startIndex = count; count = nodes.Count; } return(value); }
public _ResultCard( int integer, string title, SearchDelegate <int> searchDelegate ) { this.integer = integer; this.title = title; this.searchDelegate = searchDelegate; }
public MainForm() { InitializeComponent(); m_LogWindow.Location = new Point(this.ClientSize.Width + this.Location.X, this.Location.Y); SearchEvent += new SearchDelegate(MainForm_SearchEvent); // m_SearchForm.listViewclickEvent += new Form_VariableSearch.listViewClickDelegate(m_SearchForm_listViewclickEvent); m_ProgramPath = System.IO.Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName); }
public static void Search(GeoCoordinate location, string[] categories, SearchDelegate callback) { string url = String.Format( FS_VENUE_SEARCH, location.Latitude, location.Longitude, string.Join(",", categories)); GetRequest(url, (JObject response) => { callback((JArray)response["response"]["venues"]); }); }
private void DoSearch() { if (this.InvokeRequired) { SearchDelegate idl = new SearchDelegate(Search); this.Invoke(idl); } else { Search(); } }
public void ButtonSearch_Click(object sender, RoutedEventArgs e) { globalFuncs.scoutTimer.start(); if (searching) { stopSearching = true; searching = false; return; } this.windowMain.CurrentGameDate.Text = context.fm.MetaData.IngameDate.ToLongDateString(); this.windowMain.vm.tabteams.TextBlockText = globalFuncs.localization.WindowMainLabels[2]; this.vm.search.TextBlockText = globalFuncs.localization.SearchingResults[ScoutLocalization.SR_STOP]; //this.ButtonSearch.IsEnabled = false; setControlAvailability(false); this.ButtonWonder.IsEnabled = false; this.vm.results.Text = globalFuncs.localization.SearchingResults[ScoutLocalization.SR_SEARCHING] + "..."; searchUI.name = this.name.TextBox.Text.ToLower(); searchUI.nation = this.nation.TextBox.Text.ToLower(); searchUI.stadium = this.stadium.TextBox.Text.ToLower(); globalFuncs.specialCharactersReplacement(ref searchUI.name); globalFuncs.specialCharactersReplacement(ref searchUI.nation); globalFuncs.specialCharactersReplacement(ref searchUI.stadium); searchUI.teamtypeIndex = this.teamtype.ComboBox.SelectedIndex; if (this.teamtype.ComboBox.SelectedItem != null) { searchUI.teamtypeItem = (String)this.teamtype.ComboBox.SelectedItem; } searchUI.regionIndex = this.region.ComboBox.SelectedIndex; if (this.region.ComboBox.SelectedItem != null) { searchUI.regionItem = globalFuncs.localization.regionsNative[searchUI.regionIndex]; } searchUI.reputationIndex = this.reputation.ComboBox.SelectedIndex; if (this.reputation.ComboBox.SelectedItem != null) { searchUI.reputationItem = (String)this.reputation.ComboBox.SelectedItem; } searchUI.transferBudgetMin = (int)this.transferBudget.NumericUpDownMin.Value; searchUI.transferBudgetMax = (int)this.transferBudget.NumericUpDownMax.Value; searchUI.wageBudgetMin = (int)this.wageBudget.NumericUpDownMin.Value; searchUI.wageBudgetMax = (int)this.wageBudget.NumericUpDownMax.Value; SearchDelegate d = new SearchDelegate(this.retrieveFields); d.BeginInvoke(null, null); ProgressBarDelegate p = new ProgressBarDelegate(this.updateProgressBar); p.BeginInvoke(null, null); }
public Form1() { InitializeComponent(); h = 6; a = 9; b = -8; c = 5; n = 5; v0 = 2f; textBoxA.Text = a.ToString("F1"); textBoxB.Text = b.ToString("F1"); textBoxC.Text = c.ToString("F1"); textBoxH.Text = h.ToString("F1"); textBoxV0.Text = v0.ToString("F1"); textBoxN.Text = n.ToString(); g3d = new Graphic3D(gorka, 0f, 20f, -20f, 20f, 5e-1f); vpr.phiH = 150f; vpr.phiV = 105f; vpr.zoom = 20; vpr.ox = pictureBox1.Width / 2f; vpr.oy = pictureBox1.Height / 2f; syncList = new List <Graphic3D>(); syncList.Add(g3d); SetupCheckpionts(); MakeGorkaShape(); lOpen = new List <Point3dNode>(); lClosed = new List <Point3dNode>(); path = new List <Point3dNode>(); penPath = new Pen(Color.OrangeRed, 1f / vpr.zoom); penBestPath = new Pen(Color.LimeGreen, 3f / vpr.zoom); penBestPath.LineJoin = LineJoin.Round; penGorka = new Pen(Color.Black, 1.5f / vpr.zoom); penGorka.LineJoin = LineJoin.Round; pictureBox1.Refresh(); measuringMethod = this.MeasureDist; searchMethod = this.BreadthFirstSearch; }
/// <summary> /// Efetua a pesquisa pelo delegate e registra seus logs /// </summary> /// <param name="type">Tipo de Pesquisa</param> /// <param name="idRoom">Id Room pesquisado</param> /// <param name="searchDelegate">Função de pesquisa</param> private static void Search(string type, int idRoom, SearchDelegate searchDelegate) { Console.Clear(); Console.Write("Pesquisando..."); // Salva o horario de início DateTime start = DateTime.Now; // Inicia o cronômetro Stopwatch watch = Stopwatch.StartNew(); // Invoca o delegate Airbnb airbnb = searchDelegate.Invoke(idRoom, out int comparisons); // Pausa o cronômetro watch.Stop(); // Salva o horario de término DateTime end = DateTime.Now; // Converte o tempo do cronômetro para segundos long time = watch.ElapsedTicks; Console.Clear(); Console.WriteLine("Pesquisa finalizada"); Console.WriteLine("-------------------"); Console.WriteLine($"Tipo: {type}"); Console.WriteLine($"ID Room pesquisado: {idRoom}"); Console.WriteLine($"Comparações: {comparisons}"); Console.WriteLine($"Tempo: {time} ticks ({start.ToLongTimeString()} - {end.ToLongTimeString()})"); Console.WriteLine("-------------------"); // Mostra o objeto pesquisado Console.WriteLine("Objeto: "); if (airbnb == null) { Console.WriteLine("Não encontrado."); } else { Console.WriteLine(airbnb.ToString()); } Console.WriteLine("-------------------"); }
private void rbDFS_CheckedChanged(object sender, EventArgs e) { searchMethod = this.DepthFirstSearch; }
public OutContent ProcessRequest <T>(ArraySegment <byte> content, SearchDelegate <T> searchHandler, T param) { try { List <DirectorySearchItem> foundItems = null; bool moreAvailable = false; var request = DirectorySearchRequest.Parse(CreateXmlReader(content)); int maxResults = Math.Min(MaxResults, request.MaxResults); foreach (var searchTerm in request.SearchTerms) { const string testPrefix = @"TESTJDOE"; if (searchTerm.Key == @"givenName" && string.Compare(searchTerm.Value, 0, testPrefix, 0, testPrefix.Length) == 0) { int requestedResults; if (int.TryParse(searchTerm.Value.Substring(testPrefix.Length), out requestedResults)) { foundItems = new List <DirectorySearchItem>(); for (int i = 0; i < maxResults && i < requestedResults; i++) { foundItems.Add(new DirectorySearchItem() { Uri = string.Format(@"jdoe{0}@officesip.local", i), DisplayName = string.Format(@"Joe Doe {0}", i), Title = string.Format(@"Title {0}", i), Office = string.Format(@"#{0}", i), Phone = string.Format(@"+1 111 111 1111 ext.{0}", i), Company = string.Format(@"Company #{0}", i), City = string.Format(@"City{0}", i), State = string.Format(@"State{0}", i), Country = string.Format(@"Country{0}", i), Email = string.Format(@"jdoe{0}@officesip.com", i), }); } moreAvailable = (maxResults < requestedResults); } break; } } DirectorySearchResponse response = null; if (foundItems == null && searchHandler != null) { response = searchHandler(this, request, param); } else { response = new DirectorySearchResponse() { Items = foundItems, MoreAvailable = moreAvailable, }; } return(new OutContent(response, new object())); } catch (Exception) { return(new OutContent( new DirectorySearchResponse() { Items = new List <DirectorySearchItem>(), }, new object())); } }
static public ISyncWSResult GetResult(ISyncWSParameter dataParameter, SearchDelegate searchDelegate, TestDelegate testDelegate) { string PartnerName = ""; // unknown = default /* * if ((PartnerName == "") || (PartnerName == null)) * { * try * { * return testDelegate(dataParameter); * } * catch * { * return null; * } * }*/ ISyncWSResult res = null; using (DBHelper dbHelper = new DBHelper(PartnerName)) { try { dbHelper.GetDataBase().StartTransaction(); res = searchDelegate(dbHelper.GetDataBase(), dataParameter); dbHelper.GetDataBase().Commit(); } catch (Exception e) { try { dbHelper.GetDataBase().Rollback(); } catch (Exception) { // ignore exceptions at rollback in exception handler } string almId = ""; // sample: //ORA-20100: ART001 - The Product does not exist. if (e.Message.StartsWith("ORA-20100")) { string[] delimiters = { ": ", " - " }; string[] messageParts = e.Message.Split(delimiters, System.StringSplitOptions.None); if (messageParts.GetLength(0) > 1) { almId = messageParts[1]; } } Exception exception; if (string.IsNullOrEmpty(almId)) { exception = new WarehouseException("XXX001", e.Message); } else { try { exception = new WarehouseException(almId, dbHelper.GetDataBase(), "en"); } catch { exception = new Exception("DataError: Error processing data", e); } } throw (exception); } } return(res); }
private void MainLoop(object source, ElapsedEventArgs e) { if (currentState == State.FORCING && motorSpinning == false) { currentState = State.ONLINE; } if (buttonOn && currentState != State.FORCING) // Robot is on (and we are not forcing a turn) { // See what color it is on and decide what to do with the drive motor if (currentColor == Color.BLACK) { // If state was previously seaching then stop robot before going straight if (currentState != State.ONLINE) { stopRobot(); Console.WriteLine("Stoped before straight"); } currentState = State.ONLINE; if (FirstSearch == SearchRight) { dirToCheckFor = Direction.RIGHT; } onNode = false; // Back on line, no longer on node currentDirection = Direction.STRAIGHT; driveStraight(); } else if (currentColor == Color.WHITE) //(currentShade == Shade.WHITE) // Robot went off course { // Initiate Main search pattern currentState = State.SEARCHING; // Change state to searching if ((currentDirection == Direction.STRAIGHT || currentDirection == Direction.CHECKINGLEFT || currentDirection == Direction.CHECKINGRIGHT) && motorSpinning == true) { stopRobot(); } // Search right first if ((currentDirection == Direction.STRAIGHT || currentDirection == Direction.CHECKINGLEFT || currentDirection == Direction.CHECKINGRIGHT) && motorSpinning == false) { Console.WriteLine("White detected, first search {0}", FirstSearch.ToString()); FirstSearch(80); // Reset delegate back to default FirstSearch = SearchRight; SecondSearch = SearchLeft; //SearchRight(60); motorSpinning = true; } // Search left next else if (currentDirection == dirToCheckFor && motorSpinning == false) { Console.WriteLine("White detected, second search {0}", SecondSearch.ToString()); SecondSearch(200); // Reset delegate back to default SecondSearch = SearchLeft; dirToCheckFor = Direction.RIGHT; } } else if (currentColor == Color.RED) //(currentShade == Shade.LIGHTGREY || currentShade == Shade.DARKESTGREY) { // Test if end is reached or just edge reading of the line turnRightOnSpot(345); currentState = State.FORCING; Console.WriteLine("180 degree red"); } else if (nodeReached(prevReadings) && !onNode) //currentShade == Shade.GREY) { onNode = true; numberOfNodes++; Console.WriteLine("Case {0}, Color: {1}", numberOfNodes, currentColor); switch (numberOfNodes) { case 1: stopRobot(); Console.WriteLine("Stoped before straight node"); currentState = State.ONLINE; driveStraight(); break; case 2: stopRobot(); Console.WriteLine("Stoped before straight node"); currentState = State.ONLINE; driveStraight(); break; case 3: stopRobot(); Console.WriteLine("Stoped before straight node"); // Switch search order - turn left first FirstSearch = SearchLeft; SecondSearch = SearchRight; dirToCheckFor = Direction.LEFT; currentState = State.ONLINE; driveStraight(); break; case 4: stopRobot(); Console.WriteLine("Stoped before straight node"); currentState = State.ONLINE; driveStraight(); break; case 5: turnRightOnSpot(160); currentState = State.FORCING; break; case 6: stopRobot(); Console.WriteLine("Stoped before straight node"); // Switch search order - turn left first FirstSearch = SearchLeft; SecondSearch = SearchRight; dirToCheckFor = Direction.LEFT; currentState = State.ONLINE; driveStraight(); break; case 7: turnLeftOnSpot(300); currentState = State.FORCING; break; case 8: turnLeftOnSpot(90); currentState = State.FORCING; break; case 9: turnRightOnSpot(200); currentState = State.FORCING; break; case 10: turnRightOnSpot(230); currentState = State.FORCING; break; case 11: stopRobot(); Console.WriteLine("Stoped before straight node"); currentState = State.ONLINE; driveStraight(); break; case 12: stopRobot(); Console.WriteLine("Stoped before straight node"); currentState = State.ONLINE; driveStraight(); break; case 13: stopRobot(); Console.WriteLine("Stoped before straight node"); currentState = State.ONLINE; driveStraight(); break; case 14: turnLeftOnSpot(230); currentState = State.FORCING; break; case 15: stopRobot(); Console.WriteLine("Stoped before straight node"); // Switch search order - turn left first FirstSearch = SearchLeft; SecondSearch = SearchRight; dirToCheckFor = Direction.LEFT; currentState = State.ONLINE; driveStraight(); break; default: break; } } else if (currentColor == Color.DARKGREEN) // End condition, found color specified { //stopRobot(); buttonOn = false; // Stop robot from tracking line Console.WriteLine("Found End!!"); } } }
public Find(SearchDelegate delSearch) { m_delSearch = delSearch; InitializeComponent(); }
public DigiClient() { SearchMethod = SearchForPerson; }
private void btnSearchNaslov_Click(object sender, EventArgs e) { SearchDelegate search = new SearchDelegate(SearchList); search(listArtikal, txtSrchNaslov); }
private void rbHS_CheckedChanged(object sender, EventArgs e) { searchMethod = this.HeuristicsSearch; }
public virtual ResourceCollection<Subscription> Search(SearchDelegate searchDelegate) { var query = new SubscriptionSearchRequest(); searchDelegate(query); return Search(query); }
public void SetSearchPointer(SearchDelegate pointer) { searchDelegate = pointer; }