博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
LazyListBoxHelper 动态分页
阅读量:5296 次
发布时间:2019-06-14

本文共 5500 字,大约阅读时间需要 18 分钟。

最近整理电脑东西,虽然WP7已成过去式,记录下吧,代码是该别人的,增加委托传值,如得到获取数据的百分比等

正则抓取下厨房数据

下厨房正则
(?
.+?)</span>
<>]*?\bsrc[\s\t\r\n]*=[\s\t\r\n]*[""']?[\s\t\r\n]*(?
[^\s\t\r\n""'<>]*)[^<>]*?/?[\s\t\r\n]*> 图片
(?
.+?)</div> 介绍
(?
.+?)</em> 配料
.+?
    .+?
  1. (?.+?)
    第一步
  2. (?.+?)
    .+?
  3. 做法
    (?
    .+?)</pre> 小贴士豆果
    .+?)">(?
    .+?)</a></span> 菜系类型
    .+?)"\s+target="_blank">
    .+?)"\s+alt="(?
    .+?)">.+?

    (?

    .+?)

    菜系详细

    特色菜:

    .+?([
    .+?].+?) 特色菜
    电话:
    .+?
    (?
    .+?)
    做法
    (?
    .+?)
    .+?
    (?.+?)</span>.+?
    .+?)"
    (?
    .+?)
    (?
    .+?)
    No Image主料itemprop="name"\s+title=.+?的做法">(?
    .+?)
    (?
    .+?)</a>

分页

public delegate void LazyListBoxHelperDelegateHandler(object obj);    public class LazyListBoxHelper    {        static public int _pageIndex=0;        static public bool _isBusy=true;        //用于保存ListBox的ScrollViewer对象的引用        static private ScrollViewer _scrollViewer = null;        //用于判断是否已经捕捉ScrollViewer        static private bool _isHookedScrollEvents = false;        static public event LazyListBoxHelperDelegateHandler EventLazyListBoxHelperDelegateHandler;        public static void InitLazyBox(Control LazyBox)        {            List
scrollBarList = GetVisualChildCollection
(LazyBox); foreach (ScrollBar scrollBar in scrollBarList) { if (scrollBar.Orientation == System.Windows.Controls.Orientation.Horizontal) { } else { scrollBar.ValueChanged += verticalScrollBar_ValueChanged; } } } #region 分页调用方法 ///
/// 分页 /// ///
///
private static void verticalScrollBar_ValueChanged(object sender, RoutedEventArgs e) { ScrollBar scrollBar = (ScrollBar)sender; object valueObj = scrollBar.GetValue(ScrollBar.ValueProperty); object maxObj = scrollBar.GetValue(ScrollBar.MaximumProperty); if (valueObj != null && maxObj != null) { double value = (double)valueObj; double max = (double)maxObj - 1.0; if (value >= max) { if (EventLazyListBoxHelperDelegateHandler != null) { EventLazyListBoxHelperDelegateHandler(max); } } } } public static List
GetVisualChildCollection
(object parent) where T : UIElement { List
visualCollection = new List
(); GetVisualChildCollection(parent as DependencyObject, visualCollection); return visualCollection; } public static void GetVisualChildCollection
(DependencyObject parent, List
visualCollection) where T : UIElement { int count = VisualTreeHelper.GetChildrenCount(parent); for (int i = 0; i < count; i++) { DependencyObject child = VisualTreeHelper.GetChild(parent, i); if (child is T) { visualCollection.Add(child as T); } else if (child != null) { GetVisualChildCollection(child, visualCollection); } } } #endregion ///
///获取控件的子控件 /// ///
子控件类
///
父控件 ///
public static T FindChildOfType
(DependencyObject root) where T : class { var queue = new Queue
(); queue.Enqueue(root); while (queue.Count > 0) { DependencyObject current = queue.Dequeue(); for (int i = VisualTreeHelper.GetChildrenCount(current) - 1; 0 <= i; i--) { var child = VisualTreeHelper.GetChild(current, i); var typedChild = child as T; if (typedChild != null) { return typedChild; } queue.Enqueue(child); } } return null; } ///
/// 高敏感翻页 /// public static bool HightDragSensitivity { get { return false; } } }

调用如果需要返回当前状态值,订阅Event事件即可

LazyListBoxHelper.EventLazyListBoxHelperDelegateHandler += (args) =>            {                WebClient client = new WebClient();                if (!client.IsBusy && LazyListBoxHelper._isBusy)                {                    LazyListBoxHelper._isBusy = false;                    LazyListBoxHelper._pageIndex += 20;                    this.progressBar.IsIndeterminate = true;                    this.progressBar.Visibility = Visibility.Visible;                    client.DownloadStringCompleted += (s, e) =>                    {                        if (e.Error == null)                        {                            List
list = GetFoodDetail(e.Result); for (int i = 0; i < list.Count; i++) { this.ListFindData.Items.Add(list[i]); } LazyListBoxHelper._isBusy = true; } this.progressBar.IsIndeterminate = false; this.progressBar.Visibility = Visibility.Collapsed; }; client.DownloadStringAsync(new Uri(String.Format(@"http://www.douguo.com/store/lists/c1t/{0}{1}", (this.listFindTitle.SelectedItem as FindLinkInfo).Url, LazyListBoxHelper._pageIndex), UriKind.Absolute)); } }; LazyListBoxHelper.InitLazyBox(ListFindData); } private void IninHot() { //检查网路 if (NetworkInterface.GetIsNetworkAvailable()) {

 

 

转载于:https://www.cnblogs.com/Irving/archive/2012/11/05/2756077.html

你可能感兴趣的文章
Sprint阶段测试评分总结
查看>>
sqlite3经常使用命令&amp;语法
查看>>
linux下编译openjdk8
查看>>
【python】--迭代器生成器装饰器
查看>>
Pow(x, n)
查看>>
安卓当中的线程和每秒刷一次
查看>>
每日一库:Modernizr.js,es5-shim.js,es5-safe.js
查看>>
ajax连接服务器框架
查看>>
wpf样式绑定 行为绑定 事件关联 路由事件实例
查看>>
利用maven管理项目之POM文件配置
查看>>
FUSE-用户空间文件系统
查看>>
 VS2012 C#调用C++ dll
查看>>
TCL:表格(xls)中写入数据
查看>>
Oracle事务
查看>>
String类中的equals方法总结(转载)
查看>>
bash使用规则
查看>>
AVL数
查看>>
C语言程序设计II—第九周教学
查看>>
全栈12期的崛起之捡点儿有用的说说
查看>>
基础类型
查看>>