示例#1
0
		/// <summary>
		/// Scans a TreeView control searching for data
		/// </summary>
		/// <param name="tree">The TreeView control to search</param>
		/// <param name="text">The text to search for</param>
		/// <returns>A SearchResults object containing the results</returns>
		public static SearchResults Find( TreeView tree, string text )
		{
			SearchResults results = new SearchResults();

			foreach ( TreeNode node in tree.Nodes )
			{
				DoNode( node, results, text );
			}			

			return results;
		}
示例#2
0
        /// <summary>
        /// Search for an item
        /// </summary>
        private void lnkFind_LinkClicked(object sender, EventArgs e)
        {
            TheBox.Forms.SearchForm form = new TheBox.Forms.SearchForm(TheBox.Forms.SearchForm.SearchType.Item);

            if (form.ShowDialog() == DialogResult.OK)
            {
                string text = form.SearchString.Replace(" ", "");

                m_Results = TheBox.Data.TreeSearch.Find(tCat, text);

                if (m_Results.Count == 0)
                {
                    MessageBox.Show(Pandora.Localization.TextProvider["Misc.NoResults"]);
                    m_Results = null;
                }
                else
                {
                    NextSearchResult();
                }
            }
        }
示例#3
0
		private static void DoNode( TreeNode node, SearchResults results, string text )
		{
			foreach ( TreeNode subNode in node.Nodes )
			{
				DoNode( subNode, results, text );
			}
			// Issue 10 - Update the code to Net Framework 3.5 - http://code.google.com/p/pandorasbox3/issues/detail?id=10 - Smjert
			if ( node.Tag != null && node.Tag is List<object> )
			{
				List<object> list = node.Tag as List<object>;
				// Issue 10 - End

				for ( int i = 0; i < list.Count; i++ )
				{
					object o = list[ i ];

					if ( o is BoxMobile )
					{
						BoxMobile mob = o as BoxMobile;

						if ( mob.Name.ToLower().IndexOf( text.ToLower() ) > -1 )
						{
							Result res = new Result( node, i );
							results.Add( res );
						}
					}
					else if ( o is BoxItem )
					{
						BoxItem item = o as BoxItem;

						if ( item.Name.ToLower().IndexOf( text.ToLower() ) > -1 )
						{
							Result res = new Result( node, i );
							results.Add( res );
						}
					}
				}
			}
		}
示例#4
0
        /// <summary>
        /// Displays a search result
        /// </summary>
        /// <param name="res"></param>
        private void DisplayResult(Result res)
        {
            try
            {
                tCat.SelectedNode = res.Node;

                foreach (TreeNode node in tItems.Nodes)
                {
                    // Issue 10 - Update the code to Net Framework 3.5 - http://code.google.com/p/pandorasbox3/issues/detail?id=10 - Smjert
                    if ((node.Tag as BoxItem) == (tCat.SelectedNode.Tag as List <object>)[res.Index] as BoxItem)
                    // Issue 10 - End
                    {
                        tItems.SelectedNode = node;
                        break;
                    }
                }
            }
            catch
            {
                MessageBox.Show(Pandora.Localization.TextProvider["Misc.SearchError"]);
                m_Results = null;
            }
        }
示例#5
0
		/// <summary>
		/// Searches for a given item
		/// </summary>
		/// <param name="text">Part of the name of the item</param>
		private void SearchFor( string text )
		{
			text = text.ToLower();

			m_Results = new SearchResults();

			foreach ( TreeNode cat in tCat.Nodes )
			{
				foreach ( TreeNode sub in cat.Nodes )
				{
					// Issue 10 - Update the code to Net Framework 3.5 - http://code.google.com/p/pandorasbox3/issues/detail?id=10 - Smjert
					foreach ( BoxDeco deco in sub.Tag as List<object> )
					{
						if ( deco.Name.ToLower().IndexOf( text ) > -1 )
						{
							// Result
							Result r = new Result( sub, ( sub.Tag as List<object> ).IndexOf( deco ) );
							// Issue 10 - End
							m_Results.Add( r );
						}
					}
				}
			}

			if ( m_Results.Count > 0 )
			{
				ShowNextResult();
			}
			else
			{
				MessageBox.Show( Pandora.Localization.TextProvider[ "Deco.NoResults" ] );
			}
		}
示例#6
0
		/// <summary>
		/// Merges the results provided by a second search results
		/// </summary>
		/// <param name="moreResults"></param>
		public void MergeWith( SearchResults moreResults )
		{
			this.m_Results.AddRange( moreResults.m_Results );
		}
示例#7
0
		/// <summary>
		/// Displays a search result
		/// </summary>
		/// <param name="res"></param>
		private void DisplayResult( Result res )
		{
			try
			{
				tCat.SelectedNode = res.Node;
				tLoc.SelectedNode = tLoc.Nodes[ res.Index ];
			}
			catch
			{
				MessageBox.Show( Pandora.Localization.TextProvider[ "Misc.SearchError" ] );
				m_Results = null;
			}
		}
示例#8
0
		/// <summary>
		/// Performs a search
		/// </summary>
		/// <param name="text">The text to search for</param>
		private void DoSearch( string text )
		{
			m_Results = Pandora.TravelAgent.SearchFor( text, tCat.Nodes, Pandora.Profile.Travel.SelectedMapLocations );

			if ( m_Results.Count == 0 )
			{
				MessageBox.Show( Pandora.Localization.TextProvider[ "Misc.NoResults" ] );
				m_Results = null;
			}
			else
			{
				NextSearchResult();
			}
		}
示例#9
0
		/// <summary>
		/// Displays a search result
		/// </summary>
		/// <param name="res"></param>
		private void DisplayResult( Result res )
		{
			try
			{
				tCat.SelectedNode = res.Node;
				
				foreach ( TreeNode node in tItems.Nodes )
				{
					// Issue 10 - Update the code to Net Framework 3.5 - http://code.google.com/p/pandorasbox3/issues/detail?id=10 - Smjert
					if ( ( node.Tag as BoxItem ) == ( tCat.SelectedNode.Tag as List<object> )[ res.Index ] as BoxItem )
					// Issue 10 - End
					{
						tItems.SelectedNode = node;
						break;
					}
				}
			}
			catch
			{
				MessageBox.Show( Pandora.Localization.TextProvider[ "Misc.SearchError" ] );
				m_Results = null;
			}
		}
示例#10
0
		/// <summary>
		/// Search for an item
		/// </summary>
		private void lnkFind_LinkClicked(object sender, EventArgs e)
		{
			TheBox.Forms.SearchForm form = new TheBox.Forms.SearchForm( TheBox.Forms.SearchForm.SearchType.Item );

			if ( form.ShowDialog() == DialogResult.OK )
			{
				string text = form.SearchString.Replace( " ", "" );

				m_Results = TheBox.Data.TreeSearch.Find( tCat, text );

				if ( m_Results.Count == 0 )
				{
					MessageBox.Show( Pandora.Localization.TextProvider[ "Misc.NoResults" ] );
					m_Results = null;
				}
				else
				{
					NextSearchResult();
				}
			}
		}
示例#11
0
 /// <summary>
 ///     Merges the results provided by a second search results
 /// </summary>
 /// <param name="moreResults"></param>
 public void MergeWith(SearchResults moreResults)
 {
     m_Results.AddRange(moreResults.m_Results);
 }
示例#12
0
		/// <summary>
		/// Searches the current facet for locations according to an input text
		/// </summary>
		/// <param name="nodes">The TreeNodeCollection representing the category nodes of a facet</param>
		/// <param name="text">The text to search for in the location names</param>
		/// <returns>A SearchResults object</returns>
		public static SearchResults Search( TreeNodeCollection nodes, string text )
		{
			text = text.ToLower();
			SearchResults results = new SearchResults();

			foreach ( TreeNode cat in nodes )
			{
				foreach ( TreeNode sub in cat.Nodes )
				{
					// Issue 10 - Update the code to Net Framework 3.5 - http://code.google.com/p/pandorasbox3/issues/detail?id=10 - Smjert
					foreach ( Location loc in sub.Tag as List<object> )
					// Issue 10 - End
					{
						if ( loc.Name.ToLower().IndexOf( text ) != -1 )
						{
							// Issue 10 - Update the code to Net Framework 3.5 - http://code.google.com/p/pandorasbox3/issues/detail?id=10 - Smjert
							Result res = new Result( sub, ( sub.Tag as List<object> ).IndexOf( loc ) );
							// Issue 10 - End
							results.Add( res );
						}
					}
				}
			}

			return results;
		}
示例#13
0
		/// <summary>
		/// Search for mobile
		/// </summary>
		private void linkLabel1_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
		{
			TheBox.Forms.SearchForm sf = new TheBox.Forms.SearchForm( TheBox.Forms.SearchForm.SearchType.Mobile );

			if ( sf.ShowDialog() == DialogResult.OK )
			{
				string text = sf.SearchString.Replace( " ", "" );

				m_Results = TreeSearch.Find( tCat, sf.SearchString );

				if ( m_Results.Count == 0 )
				{
					MessageBox.Show( Pandora.Localization.TextProvider[ "Misc.NoResults" ] );
					m_Results = null;
				}
				else
				{
					NextSearchResult();
				}
			}		
		}