/// <summary> /// Defines the method to be called when the command is invoked. /// </summary> /// <param name="parameter">The parameter.</param> public void Execute(object parameter) { _scalar.Value(); }
private async void button2_ClickAsync(object sender, EventArgs e) { string text = textBox2.Text; if (!new IsBlank(text).Value() && !new IsBlank(_location).Value()) { IText pattern; if (text.Contains('.')) { pattern = new Text(text); } else { pattern = new Text( new LowerText( new TrimmedText(text) ).String() + '*' ); } var items = new ErrorSafeScalar <string[]>(() => Directory.GetFileSystemEntries( _location, pattern.String(), SearchOption.AllDirectories ), () => array <string>() ); label1.Text = "the search is being run..."; var result = items.Value(); label1.Text = string.Empty; if (!items.HasErrors()) { //populate list box if (result.Any()) { string[] source = array(items.Value().Distinct()); _results = source; listView1.Items.Clear(); ImageList il = new ImageList(); foreach (var item in source) { il.Images.Add( new Icon( Icon.ExtractAssociatedIcon(item), new Size(60, 60) ) ); } listView1.LargeImageList = il; for (int i = 0; i < source.Length; i++) { listView1.Items.Add(new ListViewItem() { ImageIndex = i, Text = Path.GetFileName(source[i]) }); } } } else { await Message(items.Errors().FirstOrDefault()?.Message, TimeSpan.FromSeconds(15)).ConfigureAwait(false); } } }