当前位置: 首页 > news >正文

网站cms系统 开源水果网络营销策划方案

网站cms系统 开源,水果网络营销策划方案,网站收录目录源码,哪些网站可以做ppi一)Model - View - Presenter (MVP) 模式在 TouchGFX 中的应用 1)Model(模型): 模型代表应用程序的数据和业务逻辑。例如,在一个简单的计数器应用中,模型可以是一个包含计数器当前值的类。 class CounterModel { pri…

一)Model - View - Presenter (MVP) 模式在 TouchGFX 中的应用
1)Model(模型):
模型代表应用程序的数据和业务逻辑。例如,在一个简单的计数器应用中,模型可以是一个包含计数器当前值的类。

class CounterModel 
{
private:int count;
public:CounterModel() : count(0) {}int getCount() const {return count;}void increment() {count++;}
};

2)View(视图):
在 TouchGFX 中,视图是通过界面设计工具创建的图形用户界面(GUI)元素。例如,有一个文本框用于显示计数器的值,一个按钮用于增加计数器的值。这些 GUI 元素在 TouchGFX Designer 中设计,然后在代码中通过相关的类来引用。
视图类需要能够更新界面显示,以反映模型的状态变化。以下是一个简单的视图类示例,用于显示计数器的值:

class CounterView : public touchgfx::View{
private:touchgfx::TextAreaWithOneWildcard& countText;
public:CounterView(touchgfx::TextAreaWithOneWildcard& textArea) : countText(textArea) {}void updateCounterDisplay(int count){Unicode::snprintf(countText.getBuffer(), countText.getBufferSize(), "%d", count);countText.invalidate();}
};

3)Presenter(展示器):
展示器作为模型和视图之间的桥梁,它包含对模型和视图的引用,并处理用户交互。当用户点击增加计数器的按钮时,展示器会调用模型的increment方法来更新数据,然后调用视图的updateCounterDisplay方法来更新界面。

class CounterPresenter 
{
private:CounterModel& model;CounterView& view;
public:CounterPresenter(CounterModel& m, CounterView& v) : model(m), view(v) {}void handleIncrementButtonClicked() {model.increment();view.updateCounterDisplay(model.getCount());}
};

使用示例:
在main函数或者应用程序初始化的地方,可以这样使用 MVP 模式构建计数器应用。
// 创建模型、视图和展示器

CounterModel counterModel;
touchgfx::TextAreaWithOneWildcard countTextArea;
CounterView counterView(countTextArea);
CounterPresenter counterPresenter(counterModel, counterView);

// 假设这里有一个按钮点击事件处理器,将其与展示器的方法关联
Button incrementButton;
incrementButton.setClickAction(counterPresenter, &CounterPresenter::handleIncrementButtonClicked);
二)Model - View - Controller (MVC) 模式在 TouchGFX 中的应用示例(与 MVP 类似但有区别)
1)Model(模型):
同样以计数器应用为例,模型类和 MVP 模式中的类似。

class CounterModel{
private:int count;
public:CounterModel() : count(0) {}int getCount() const{return count;}void increment() {count++;}
};

2)View(视图):
在 MVC 模式中,视图主要负责显示。它会从模型获取数据来更新自己的显示,但不像 MVP 中的视图那样直接被展示器调用更新方法。

class CounterView : public touchgfx::View 
{
private:touchgfx::TextAreaWithOneWildcard& countText;
public:CounterView(touchgfx::TextAreaWithOneWildcard& textArea) : countText(textArea) {}void updateCounterDisplay(int count){Unicode::snprintf(countText.getBuffer(), countText.getBufferSize(), "%d", count);countText.invalidate();}
};

3)Controller(控制器):
控制器处理用户输入和模型更新,同时也会通知视图更新显示。与 MVP 不同的是,它的职责划分更侧重于控制整个流程。

class CounterController{
private:CounterModel& model;CounterView& view;
public:CounterController(CounterModel& m, CounterView& v) : model(m), view(v) {}void handleIncrementButtonClicked() {model.increment();view.updateCounterDisplay(model.getCount());}
};

使用示例:
与 MVP 模式类似,在应用程序初始化阶段使用 MVC 模式构建计数器应用。
// 创建模型、视图和控制器
CounterModel counterModel;
touchgfx::TextAreaWithOneWildcard countTextArea;
CounterView counterView(countTextArea);
CounterController counterController(counterModel, counterView);

// 假设这里有一个按钮点击事件处理器,将其与控制器的方法关联
Button incrementButton;
incrementButton.setClickAction(counterController, &CounterController::handleIncrementButtonClicked);
这些设计模式有助于将 TouchGFX 应用程序的不同职责分离,使得代码更加模块化、易于维护和扩展。在实际应用中,可以根据具体的项目需求选择合适的设计模式。

http://www.ds6.com.cn/news/101673.html

相关文章:

  • 北京建筑公司网站软件定制
  • 天津企业建站系统百度一下百度一下你就知道
  • ip138查询网站网址域名ip青岛网站建设方案优化
  • 用公司的信息做网站违法吗免费关键词排名优化
  • 淄博网站价格廊坊seo建站
  • 自适应网站 响应式网站网站内部优化有哪些内容
  • 网站建设与运营最新seo新手教程
  • 网站制作排序重庆搜索排名提升
  • asp.net 网站管理系统百度百科推广联系方式
  • 基于html5的旅游网站开发自动收录网
  • 校园互动网站建设推广引流的10个渠道
  • 郑州做网站网站建设费用如何去推广一个app
  • 牛什么的网站建设正规的微信推广平台
  • 虹口房产网站建设网络营销管理系统
  • 外贸网站如何做推广怎么让网站快速收录
  • 健康湖州网站网站收录提交入口
  • 加速百度对网站文章的收录社会新闻热点事件
  • 网站权重优化方式开鲁视频
  • 企业做网站分一般为哪几种类型好看的html网页
  • 北京公司网站建设费用seo前景
  • 专业做营销网站杭州优化排名哪家好
  • 微网站 尺寸产品推广渠道有哪些
  • 太原做网站页面的北京首页关键词优化
  • 深圳网站建设信科便宜品牌整合营销
  • 一般的政府网站空间多少钱一年seo单页快速排名
  • 江苏省建设工程备案网站合肥关键词排名技巧
  • h5响应式网站做动画营销广告语
  • 电商网站建设策划书公众号推广渠道
  • 工厂做网站如何做网页链接
  • 建浏览器网站制作搜索关键词排名推广