惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

www.infosecurity-magazine.com
www.infosecurity-magazine.com
D
DataBreaches.Net
T
Tailwind CSS Blog
M
MIT News - Artificial intelligence
Stack Overflow Blog
Stack Overflow Blog
F
Full Disclosure
V2EX - 技术
V2EX - 技术
N
News and Events Feed by Topic
Help Net Security
Help Net Security
L
LangChain Blog
Y
Y Combinator Blog
宝玉的分享
宝玉的分享
Google Online Security Blog
Google Online Security Blog
P
Proofpoint News Feed
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
The Blog of Author Tim Ferriss
Google DeepMind News
Google DeepMind News
The Register - Security
The Register - Security
B
Blog RSS Feed
N
Netflix TechBlog - Medium
N
News | PayPal Newsroom
TaoSecurity Blog
TaoSecurity Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
V
Vulnerabilities – Threatpost
B
Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
I
Intezer
H
Hackread – Cybersecurity News, Data Breaches, AI and More
博客园_首页
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
AI
AI
aimingoo的专栏
aimingoo的专栏
大猫的无限游戏
大猫的无限游戏
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Cyberwarzone
Cyberwarzone
P
Proofpoint News Feed
Google DeepMind News
Google DeepMind News
G
GRAHAM CLULEY
Vercel News
Vercel News
罗磊的独立博客
MyScale Blog
MyScale Blog
Last Week in AI
Last Week in AI
博客园 - 司徒正美
C
CERT Recently Published Vulnerability Notes
GbyAI
GbyAI
Scott Helme
Scott Helme
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
T
Troy Hunt's Blog
A
About on SuperTechFans
P
Privacy International News Feed

博客园 - dataxiu.com

[原创.数据可视化系列之十三]idw反距离权重插值算法的javascript代码实现 [原创.数据可视化系列之十二]使用 nodejs通过async await建立同步数据抓取 [原创.数据可视化系列之八]使用等d3进行灰度图转伪彩色 [原创.数据可视化系列之七]阿里竞赛作品技术展示 [原创.数据可视化系列之六]使用openlyaers进行公网地图剪切 [原创.数据可视化系列之五]韩国"萨德"系统防御图 [原创.数据可视化系列之四]跨平台,多格式的等值线和等值面的生成 [原创.数据可视化系列之三]使用Ol3加载大量点数据 [原创.数据可视化系列之二]使用cesium三维地图展示美国全球军事基地分布 [原创.数据可视化系列之一]使用openlayers 3 显示聚合数据 管理类软件的界面模板。 使用SilverLight开发ARPG游戏(一) 买联想学生机器的遭遇:问联想1(连载) 联想09年春节学生机开卖了。 谈UrlRewriter在XP和2003上IIS设置的差异 使用SilverLight构建插件式应用程序(九) —聊天插件客户端的实现 .NET 访问JAVA的WebService使用SOAP头 使用SilverLight构建插件式应用程序(八) —聊天插件Duplex WCF的实现 使用SilverLight构建插件式应用程序(七)
使用SilverLight构建插件式应用程序(六)
dataxiu.com · 2008-10-12 · via 博客园 - dataxiu.com

使用SilverLight构建插件式应用程序(六)

留言板插件的开发-插件留言的显示:

留言板是整个系统第一个可以和用户交互的插件,插件实现了登录用户留言,系统从数据库获取的功能。

首先看服务器提供的数据功能:

/// <summary>

    /// 获取留言的总条数

    /// </summary>

    /// <returns>留言条数</returns>

    [OperationContract]

    public int GetNotesCount()

    {

        NotesBLL bll = new NotesBLL();

        return bll.GetNotesCount();

    }  

    /// <summary>

    /// 获取指定页码和大小的留言

    /// </summary>

    /// <param name="pageNumber">页码</param>

    /// <param name="pageSize">大小</param>

    /// <returns>留言</returns>

    [OperationContract]

    public List<NotesInfo> GetNotesByPage(int pageNumber,int pageSize)

    {

        NotesBLL bll = new NotesBLL();

        return bll.GetNotesByPage(pageNumber,pageSize);

    }

下面看看客户端的代码:

整个客户单和显示有关的有3个对象;
NotesItem:显示的留言项;

       留言项基本就是一个XAML的界面,每条留言需要显示的内容。

NotesPage:显示的留言页;

       容纳留言项的界面,没有更多的代码。

NotesMain.xaml:显示的留言主界面;

       这是整个插件的核心部分,实现了读取数据,生成数据项,显示,翻页等等功能。

       1:实现IPlugIn接口,这个是每个插件都要实现的功能;

       2:获取整个留言的页数,为分页显示最准备,下面是代码:

 private void DataCount()

        {

            Uri uri = System.Windows.Browser.HtmlPage.Document.DocumentUri;

            string host = uri.AbsoluteUri;

            host = host.Substring(0, host.Length - uri.LocalPath.Length);

            string servicePath = "/Services/WSNotes.svc";

            string serviceUri = host + servicePath;

            //

            WSNotesClient ws = new WSNotesClient(new System.ServiceModel.BasicHttpBinding(), new System.ServiceModel.EndpointAddress(serviceUri));

            ws.GetNotesCountCompleted += (o, ev) =>

            {

                if (ev.Error == null)

                {

                    int tmpCount = ev.Result / PageSize;

                    if (tmpCount * PageSize == ev.Result)

                    {

                        PageCount = tmpCount;

                    }

                    else

                    {

                        PageCount = tmpCount + 1;

                    }

                    this.txtPageCount.Text = "/" + PageCount;

                    //

                    DataLoad(1);

                }

            };

            ws.GetNotesCountAsync();

        }

3:显示指定页码的内容:

//

            Uri uri = System.Windows.Browser.HtmlPage.Document.DocumentUri;

            string host = uri.AbsoluteUri;

            host = host.Substring(0, host.Length - uri.LocalPath.Length);

            string servicePath = "/Services/WSNotes.svc";

            string serviceUri = host + servicePath;

            //

            WSNotesClient ws = new WSNotesClient(new System.ServiceModel.BasicHttpBinding(), new System.ServiceModel.EndpointAddress(serviceUri));

            ws.GetNotesByPageCompleted += (o, e) =>

                {

                    if (e.Error == null)

                    {

                        ObservableCollection<NotesInfo> notesInfo = e.Result;

                        int itemCount = notesInfo.Count;

                        NotesPage page = new NotesPage();

                        for (int iItem = 0; iItem < itemCount; iItem++)

                        {

                            NotesItem item = new NotesItem();

                            Thickness thicknessi = new Thickness();

                            thicknessi.Top = 5;

                            thicknessi.Bottom = 5;

                            item.Margin = thicknessi;

                            item.notesTitle.Text = notesInfo[iItem].Title;

                            item.notesText.Text = notesInfo[iItem].Content;

                            item.AuthorName.Text = notesInfo[iItem].UserName;

                            item.AuthorImage.Source = ResourceHelper.GetBitmap("Resources/Images/self.png", this.GetType().Namespace);

                            page.panelPageItem.Children.Add(item);

                        }

                        Thickness thickness = new Thickness();

                        thickness.Top = 10;

                        thickness.Bottom = 10;

                        page.Margin = thickness;

                        page.PageFooter.Text = pageNumber.ToString();

                        this.txtPageNumber.Text = pageNumber.ToString();

                        this.panelPages.Children.Clear();

                        this.panelPages.Children.Add(page);

                    }

                    //如果在xaml界面直接使用这两个属性,程序运行就会报错

                    //在这个地方设定没有错误

                    ScrollPages.SetValue(Grid.RowProperty, 1);

                    ScrollPages.SetValue(Grid.ColumnProperty, 1);

                };

            ws.GetNotesByPageAsync(pageNumber,PageSize);

4:控制翻页的状态

string tag = ((Button)sender).Tag.ToString();

            if (tag == "First")

            {

                PageNumber = 1;

            }

            else if (tag == "Prview")

            {

                PageNumber = PageNumber - 1; ;

            }

            else if (tag == "Next")

            {

                PageNumber = PageNumber + 1; ;

            }

            else if (tag == "Last")

            {

                PageNumber = PageCount;

            }

            else if (tag == "Goto")

            {

                int tmp=PageNumber;

                if (int.TryParse(this.txtPageNumber.Text, out tmp))

                {

                    PageNumber = tmp;

                }

                else

                {

                    MessageBox.Show("你输入的页码不是整数,请重新输入","提示",MessageBoxButton.OK);

                }

            }

            DataLoad(PageNumber);

至此,整个留言显示完成,如果用户需要留言,请先注册登陆。下一个Blog写如何填写留言。

演示地址:www.cuface.cn

代码正在整理。