WindowsPhone8开发:掌握常用控件与基础应用

需积分: 0 0 下载量 7 浏览量 更新于2024-09-12 收藏 433KB PPTX 举报
本资源是一份关于Windows Phone 8开发的PPT教程,由讲师钟勇讲解。课程第4讲着重介绍了Windows Phone 8中常用的控件,旨在帮助开发者掌握基础控件的使用,以便更好地构建应用程序界面。主要内容分为两部分: 1. **控件基类理解**: - UIElement:这是Silverlight中所有具有可视外观并且能处理基本输入的对象的基础类,包括键盘、鼠标和触屏输入事件,以及焦点处理。它定义了大部分用户界面元素的基本交互行为。 - FrameworkElement:它是Silverlight布局中的核心框架,提供了数据绑定和样式管理的公共接口。这个类对于应用程序的布局设计至关重要,通过ControlTemplate定义控件外观,并且引入了关键的布局策略。 2. **具体控件应用**: - 按钮控件(Button):System.Windows.Controls.Button是表示用户可以点击触发事件的控件,常见于操作交互中。它的XAML语法包括属性元素和内容区域,如: ``` <Button .../> <Button ...>属性元素</Button> <Button ...>内容</Button> ``` - 文本块控件(TextBlock):这是一种轻量级控件,用于显示少量的静态文本,常用于显示提示或标签信息。TextBlock同样有XAML语法: ``` <TextBlock .../> <TextBlock ...>属性元素</TextBlock> <TextBlock ...>内容</TextBlock> ``` 3. **实践环节**: - 作业任务:学员被要求设置Button按钮,并尝试自定义其样式和事件处理,以及创建一个简单的TextBlock实例,展示文本块控件的使用。 通过这节课的学习,开发者能够熟悉Windows Phone 8中常用控件的工作原理,提升界面设计和交互能力。通过实际操作,他们将能够将理论知识应用到项目开发中,从而提高开发效率和用户体验。

帮我把下面一段C++代码改写成python代码:#include "Trade.h" #include "WPrice.h" #include <algorithm> double normalCDF(double x) // Phi(-∞, x) aka N(x) { return std::erfc(-x / std::sqrt(2)) / 2; //erfc()是互补误差函数,该返回值表示标准正态分布下var小于x的概率,即N(x) } CTrade::CTrade(double tick) : wp_bid(0.01), wp_ask(0.01), m_tick(tick), m_TimeRound(50) { newday(NULL); } CTrade::~CTrade() { } void CTrade::OnBook(const BTRec& btRec) { wp.setGamma(0.1); wp_bid = wp.getWP(&btRec.Bids); wp_ask = wp.getWP(&btRec.Asks); if (wp_mid > 0){ //wp_mid初始化为-1,仅遇到第一条BTRec记录时条件为false double wp_now = (wp_bid + wp_ask) / 2; //updated wp_mid int volume = btRec.volume; //volume between two orderbook records double ratio = normalCDF((wp_now - wp_mid) / (2 * m_tick)); //m_tick = tick = 0.2 double buyvolume = ratio*volume, sellvolume = (1 - ratio)*volume; m_TimeRound.update(buyvolume, sellvolume, btRec.rec_time.timestamp); //volume moving average if (mv_volume < 0) { mv_volume = volume; mv_buyvolume = buyvolume; } else{ mv_volume += 0.002*(volume - mv_volume); mv_buyvolume += 0.002*(buyvolume - mv_buyvolume); } // round trip volatility if (time_ini < 0 || btRec.rec_time.timestamp - time_ini >= time_scale){ if (time_ini>0){ double dp = wp_now - wp_ini; volatility += 0.05*(dp*dp - volatility); } time_scale = m_TimeRound.getTime() * 1000; //in milliseconds time_ini = btRec.rec_time.timestamp; wp_ini = wp_now; } } wp_mid = (wp_bid + wp_ask) / 2; } void CTrade::newday(const char* p) { wp_mid = -1; m_TimeRound.newday(p); volatility = 16 * m_tick*m_tick; time_slapse = -1, time_scale = -1, wp_ini = -1, time_ini = -1; mv_buyvolume = mv_volume = -1; }

2023-05-15 上传

优化这段代码:function [Rp,As] = freqzn(num,den,wp,ws,Rp,As,ftype) switch ftype case 1 % 低通 [H, w] = freqz(num, den); H = abs(H); wp_index = find(w >= wp, 1); ws_index = find(w >= ws, 1); Rp = -20*log10(H(wp_index)); As = -20*log10(max(H(ws_index:end))); case 2 % 高通 [H, w] = freqz(num, den); H = abs(H); wp_index = find(w >= wp, 1); ws_index = find(w >= ws, 1); Rp = -20*log10(H(ws_index)); As = -20*log10(max(H(1:wp_index))); case 3 % 带通 [H, w] = freqz(num, den); H = abs(H); wp_index1 = find(w >= wp(1), 1); wp_index2 = find(w >= wp(2), 1); ws_index1 = find(w >= ws(1), 1); ws_index2 = find(w >= ws(2), 1); Rp = -20*log10(min(H(wp_index1:wp_index2))); As = -20*log10(max([max(H(1:ws_index1)), max(H(ws_index2:end))])); case 4 % 带阻 [H, w] = freqz(num, den); H = abs(H); wp_index1 = find(w >= wp(1), 1); wp_index2 = find(w >= wp(2), 1); ws_index1 = find(w >= ws(1), 1); ws_index2 = find(w >= ws(2), 1); Rp = -20*log10(max(H(wp_index1:wp_index2))); As = -20*log10(max([max(H(1:ws_index1)), max(H(ws_index2:end))])); otherwise error('Unsupported filter type!'); end %绘制滤波器的幅频特性 [H, w] = freqz(num, den); H = abs(H); figure; plot(w/pi, H, 'b', 'linewidth', 1.5); hold on; plot([0, wp]/pi, [1, 1], 'r--', 'linewidth', 1.5); plot([ws, 1]/pi, [0, 0], 'r--', 'linewidth', 1.5); if ftype == 3 || ftype == 4 plot([wp(1), wp(1)]/pi, [0, 1], 'r--', 'linewidth', 1.5); plot([wp(2), wp(2)]/pi, [0, 1], 'r--', 'linewidth', 1.5); end hold off; grid on; xlabel('归一化频率/\pi'); ylabel('幅值'); title('数字滤波器幅频特性'); end

2023-06-09 上传