private void search_button_Click(object sender, RoutedEventArgs e) { var search_text = search_textbox.Text; if (search_text == "") { return; } var search_result = new netFileCollection(); search_result.Add(new netFile( Name: "<Return>", Url: "", Isdir: true )); foreach (var nf in this.cur_flb.filelist) { if (nf.Name.IndexOf(search_text, StringComparison.OrdinalIgnoreCase) > -1) { search_result.Add(nf); } } grid.Children.Remove(this.cur_flb); this.cur_flb = new FileListBox(search_result); this.cur_flb.MouseDoubleClick += new MouseButtonEventHandler(listBox_MouseDoubleClick); flb_stack.Push(this.cur_flb); this.cur_flb.SetValue(Grid.RowProperty, 1); grid.Children.Add(this.cur_flb); search_textbox.Text = ""; }
public void Connect(object sender, EventArgs e) { if (connect.connected) { if (connect.ptype == protocolType.HTTP) { try { this.networkclient = new HC(connect.url); } catch (Exception ex) { var _m = new Msg(ex.Message, this); this.Close(); return; } } else if (connect.ptype == protocolType.SFTP) { try { this.networkclient = new SC(connect.url); } catch (Exception ex) { var _m = new Msg(ex.Message, this); this.Close(); return; } } else if (connect.ptype == protocolType.FILE_SYSTEM) { try { this.networkclient = new LF(connect.url); } catch (Exception ex) { var _m = new Msg(ex.Message, this); this.Close(); return; } } this.cur_flb = new FileListBox(networkclient.filelist); this.cur_flb.MouseDoubleClick += new MouseButtonEventHandler(listBox_MouseDoubleClick); flb_stack.Push(this.cur_flb); this.cur_flb.SetValue(Grid.RowProperty, 1); grid.Children.Add(this.cur_flb); } else { this.Close(); } }
private void listBox_MouseDoubleClick(object sender, EventArgs e) { var _i = this.cur_flb.listBox.SelectedIndex; if (_i != -1) { if (_i == 0) { if (flb_stack.Count > 1) { grid.Children.Remove(flb_stack.Pop()); this.cur_flb = flb_stack.Peek(); grid.Children.Add(this.cur_flb); //this.cur_flb.SetValue(Grid.RowProperty, 1); var listboxitem = (ListBoxItem)this.cur_flb.listBox.ItemContainerGenerator.ContainerFromItem(this.cur_flb.listBox.SelectedItem); listboxitem.Focus(); } } else { var selectd_file = this.cur_flb.filelist[_i]; if (selectd_file.Isdir) { try { networkclient.cdurl(this.cur_flb.filelist[_i].Url); } catch (Exception ex) { var _m = new Msg(ex.Message, this); return; } grid.Children.Remove(this.cur_flb); this.cur_flb = new FileListBox(networkclient.filelist); this.cur_flb.MouseDoubleClick += new MouseButtonEventHandler(listBox_MouseDoubleClick); flb_stack.Push(this.cur_flb); this.cur_flb.SetValue(Grid.RowProperty, 1); grid.Children.Add(this.cur_flb); } else { if (selectd_file.playable()) { string command_param = string.Format("\"{0}\"", selectd_file.Url); if (selectd_file.Type == fileType.Video) { var ss = new SelectSub(this.cur_flb.filelist, selectd_file.Name, this); if (ss.havesub) { foreach (var su in ss.suburl) { command_param += string.Format(" --sub-file=\"{0}\"", su); } } } else if (selectd_file.Type == fileType.Pciture) { command_param += " --keep-open=yes"; } var vidoprocess = new Process(); ProcessStartInfo startInfo = new ProcessStartInfo(".\\mpv.exe", command_param); vidoprocess.StartInfo = startInfo; vidoprocess.StartInfo.UseShellExecute = true; vidoprocess.Start(); } else { var _m = new Msg("Can not play.", this); } } } } }