예제 #1
0
        private void Search()
        {
            ResultsListBox.Items.Clear();

            if (GetMovies()?.Length > 0)
            {
                foreach (Movie movie in GetMovies())
                {
                    ResultsListBox.Items.Add(movie.Title);
                }
            }

            ReloadGrammars();

            if (!ResultsListBox.Items.IsEmpty)
            {
                ResultsListBox.Focus();
            }
        }
예제 #2
0
        // ReSharper restore UnusedAutoPropertyAccessor.Local


        private void FindButton_Click(object sender, EventArgs e)
        {
#if NO_ACTIVE_DIRECTORY
            MessageBox.Show("Active Directory Search Disabled.", "Sorry", MessageBoxButtons.OK,
                            MessageBoxIcon.Information);
#else
            var    context   = new PrincipalContext(ContextType.Domain, "nps", "OU=AKR,DC=nps,DC=doi,DC=net");
            string search    = EditorTextBox.Text + "*";
            var    principal = new UserPrincipal(context)
            {
                Surname = search, Enabled = true
            };
            var searcher = new PrincipalSearcher {
                QueryFilter = principal
            };
            var query = from Principal p in searcher.FindAll()
                        orderby p.DisplayName
                        select new EditorListItem
            {
                DisplayName = p.Name + " (" + p.Description + ") - NPS\\" + p.SamAccountName,
                DomainName  = "NPS\\" + p.SamAccountName,
            };
            ResultsListBox.DisplayMember = "DisplayName";
            var data = query.ToList();
            ResultsListBox.DataSource = data;
            EnableControls(); //If the Datasource is empty, then SelectedIndexChanged is not called.
            if (data.Count > 0)
            {
                ResultsListBox.Focus();
            }
            else
            {
                MessageBox.Show("Nobody found with that name.", "Try again", MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
                EditorTextBox.Focus();
            }
#endif
        }