您的位置:首页 > 编程语言 > C#

C#--工作笔记(直方图Page页)

2013-12-25 10:18 309 查看
<Page xmlns:my="clr-namespace:Health365IIProjectView"
x:Class="Health365IIProjectView.HeartbeatStatisticsPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="600" d:DesignWidth="800"
Title="HeartbeatStatisticsPage" Loaded="Page_Loaded" SizeChanged="Page_SizeChanged" Background="DarkGray">

<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="100*"/>
<RowDefinition Height="100*"/>
</Grid.RowDefinitions>
<my:HartHistogramControl Margin="0" Grid.Row="0" x:Name="hartHistogramControl" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
<my:HartListControl Grid.Row="1" HorizontalAlignment="Stretch" x:Name="hartListControl" VerticalAlignment="Stretch" />
</Grid>
</Page>

===============================================================

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

using Health365IIProjectBLL;

namespace Health365IIProjectView
{

/// <summary>
/// HeartbeatStatisticsPage.xaml 的交互逻辑
/// </summary>
public partial class HeartbeatStatisticsPage : Page
{
/// <summary>
/// 当前应用程序
/// </summary>
private App _thisApplication;
/// 当前主逻辑类
private Health365IIMainLogic _mainLogic;
/// 保存数组
private int[] _heartList;
/// <summary>
/// 从直方图中获取心搏模板的数据保存到列表中
/// </summary>
private List<int> _listOneHeartBeat;
/// <summary>
/// 记录被点击的直方图索引
/// </summary>
private int _index;

public HeartbeatStatisticsPage()
{
_thisApplication = (App)Application.Current;
_mainLogic = _thisApplication.MainLogic;
InitializeComponent();
hartHistogramControl.UXEvent += new HartHistogramControl.user_OnClick(RefreshList);

//进入直方图页面时,清空心搏模板列表
_listOneHeartBeat = new List<int>();
hartListControl.HartListControlListIndex(_listOneHeartBeat);
}
private void Page_SizeChanged(object sender, SizeChangedEventArgs e)
{
hartHistogramControl.SetData(_index, _heartList, 25, "毫秒");
}

private void Page_Loaded(object sender, RoutedEventArgs e)
{

_heartList = _mainLogic.GetHeartRateData();

hartHistogramControl.SetData(_index, _heartList, 25, "毫秒");

//初始化分类模板心搏类型变化事件(N、V、S、O)
_mainLogic.HeartTypesChangeEvent += new DlgtHeartChange(_mainLogic_HeartTypesChangeEvent);
//初始化心搏个数变化事件(添加、删除心搏)
_mainLogic.HeartCountChangeEvent += new DlgtHeartChange(_mainLogic_HeartCountChangeEvent);
}

/// <summary>
/// 右键改变心电节点类型时,向逻辑层触发事件,刷新页面显示
/// </summary>
/// <param name="heartIndex">心搏索引列表</param>
private void _mainLogic_HeartTypesChangeEvent(List<int> heartIndex)
{
//同步刷新心搏模板显示
_listOneHeartBeat = _mainLogic.GetRateStatByIndex(_index);
//发送给心搏模板,相应的刷新心搏模板的事件
hartListControl.HartListControlListIndex(_listOneHeartBeat);
}

/// <summary>
/// 心搏个数变化时,刷新页面显示
/// </summary>
/// <param name="heartIndex">心搏索引列表</param>
private void _mainLogic_HeartCountChangeEvent(List<int> heartIndex)
{
//同步刷新心搏模板显示
_listOneHeartBeat = _mainLogic.GetRateStatByIndex(_index);
//发送给心搏模板,相应的刷新心搏模板的事件
hartListControl.HartListControlListIndex(_listOneHeartBeat);
}

public void RefreshList(int index)
{
//接收Control的一个下标,根据下标判断点击的直方图
//传到逻辑层获取心搏模板的List集合,这个集合中应该有当前心率模板的集合
_index = index;
_listOneHeartBeat = _mainLogic.GetRateStatByIndex(index);
//发送给心搏模板,相应的刷新心搏模板的事件
hartListControl._selectCtrIndex = -1;
hartListControl._oldScrValue = 0;
hartListControl.HartListControlListIndex(_listOneHeartBeat);
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: