ソースを参照

Add Recgonize Hotkey

+Add Recgonize Hotkey
+Add Functions on the HomePage
- Remove useless classes
ZhuYifan 5 年 前
コミット
9586ab9762

+ 24 - 42
WpfTest1/MainWindow.xaml

@@ -11,7 +11,7 @@
         Title="劳拉" Height="725" Width="1366"
         ShowTitleBar="True"
         ShowIconOnTitleBar="True"
-
+        PreviewKeyDown="processGrid_KeyDown"
         WindowStartupLocation="CenterScreen"
         WindowState = "Normal" Loaded="MetroWindow_Loaded"
         >
@@ -34,25 +34,8 @@
         </Style>
         <Style  TargetType="{x:Type TabItem}" x:Key="darkItem" >
             <Setter Property="Controls:ControlsHelper.HeaderFontSize" Value="20"/>
-            <!--
-            <Setter Property="Foreground" Value="White"></Setter>
-            <Setter Property="Width" Value="114"></Setter>
-            <Setter Property="Height" Value="39"></Setter>
-            <Setter Property="BorderBrush" Value="#CC00FF"></Setter>
-            <Style.Triggers>
-                <Trigger Property="TabItem.IsSelected" Value="True">
-                    <Setter Property="Background" Value="#4D5667"></Setter>
-                </Trigger>
-            </Style.Triggers>
-            BasedOn="{StaticResource MetroTabItem}"-->
         </Style>
         <Style BasedOn="{StaticResource MetroLabel}" TargetType="{x:Type Label}" x:Key="whiteLabel" >
-            <!--<Setter Property="Foreground" Value="White"></Setter>
-            <Setter Property="Width" Value="114"></Setter>
-            <Setter Property="Height" Value="39"></Setter>
-            <Setter Property="FontSize" Value="20"></Setter>
-            <Setter Property="FontWeight" Value="13"></Setter>
-            //change the "Value" to your required size-->
         </Style>
     </Controls:MetroWindow.Resources>
     <Controls:MetroWindow.RightWindowCommands>
@@ -74,12 +57,12 @@
             </Button>
         </Controls:WindowCommands>
     </Controls:MetroWindow.RightWindowCommands>
-    <Grid x:Name="mainWndGrid" Background="#FFFFFF" >
+    <Grid x:Name="mainWndGrid" Background="#FFFFFF">
         <Grid.ColumnDefinitions>
             <ColumnDefinition Width="395*"/>
             <ColumnDefinition Width="959*"/>
         </Grid.ColumnDefinitions>
-        <TabControl x:Name="tabControlGeneral"  HorizontalAlignment="Left" Height="694" VerticalAlignment="Top" Width="1358" SelectionChanged="tabControlGeneral_SelectionChanged" Grid.ColumnSpan="2" Controls:TabControlHelper.Underlined="TabPanel" >
+        <TabControl x:Name="tabControlGeneral"  HorizontalAlignment="Left" Height="694" VerticalAlignment="Top" Width="1358" SelectionChanged="tabControlGeneral_SelectionChanged" Grid.ColumnSpan="2" Controls:TabControlHelper.Underlined="TabPanel">
             <TabItem Header="首页" Style="{StaticResource smallHeader}" x:Uid="1000">
                 <Grid  Margin="-1,-1,-1,-1">
                     <Grid.Background>
@@ -113,44 +96,44 @@
                             </DataTemplate>
                         </Button.ContentTemplate>
                     </Button>
-                    <Button x:Name="buttonHomePageMeasureFunction" Content="Button" HorizontalAlignment="Left" Margin="699,178,0,0" VerticalAlignment="Top" Width="160" Height="150" Background="#008b7b" Click="buttonHomePageMeasureFunction_Click">
+                    <Button x:Name="buttonHomePageFilterFunction" Content="Button" HorizontalAlignment="Left" Margin="699,178,0,0" VerticalAlignment="Top" Width="160" Height="150" Background="#008b7b" Click="buttonHomePageFilterFunction_Click">
                         <Button.ContentTemplate>
                             <DataTemplate>
                                 <StackPanel>
                                     <Rectangle Fill="#ffffff" Width="80" Height="80">
                                         <Rectangle.OpacityMask>
-                                            <VisualBrush Visual="{StaticResource appbar_medical_pulse}" Stretch="Fill" />
+                                            <VisualBrush Visual="{StaticResource appbar_clipboard_paper_check}" Stretch="Fill" />
                                         </Rectangle.OpacityMask>
                                     </Rectangle>
-                                    <TextBlock Text="检测操作"  Margin="5 10 4 4" VerticalAlignment="Center" FontSize="20" Foreground="White" />
+                                    <TextBlock Text="快速筛查"  Margin="5 10 4 4" VerticalAlignment="Center" FontSize="20" Foreground="White" />
                                 </StackPanel>
                             </DataTemplate>
                         </Button.ContentTemplate>
                     </Button>
-                    <Button x:Name="buttonHomePageHistoryRecord" Content="Button" HorizontalAlignment="Left" Margin="886,178,0,0" VerticalAlignment="Top" Width="160" Height="150" Background="#daa520" Click="buttonHomePageHistoryRecord_Click">
+                    <Button x:Name="buttonHomePageEvaluationFunction" Content="Button" HorizontalAlignment="Left" Margin="886,178,0,0" VerticalAlignment="Top" Width="160" Height="150" Background="#daa520" Click="buttonHomePageEvaluationFunction_Click">
                         <Button.ContentTemplate>
                             <DataTemplate>
                                 <StackPanel>
                                     <Rectangle Fill="#ffffff" Width="80" Height="80">
                                         <Rectangle.OpacityMask>
-                                            <VisualBrush Visual="{StaticResource appbar_journal}" Stretch="Fill" />
+                                            <VisualBrush Visual="{StaticResource appbar_magnify_browse}" Stretch="Fill" />
                                         </Rectangle.OpacityMask>
                                     </Rectangle>
-                                    <TextBlock Text="历史记录"  Margin="5 10 4 4" VerticalAlignment="Center" FontSize="20" Foreground="White" />
+                                    <TextBlock Text="详细评估"  Margin="5 10 4 4" VerticalAlignment="Center" FontSize="20" Foreground="White" />
                                 </StackPanel>
                             </DataTemplate>
                         </Button.ContentTemplate>
                     </Button>
-                    <Button x:Name="buttonHomePageReport" Content="Button" HorizontalAlignment="Left" Margin="315,359,0,0" VerticalAlignment="Top" Width="160" Height="150" Background="#9370db" Click="buttonHomePageReport_Click">
+                    <Button x:Name="buttonHomeHistoryRecords" Content="Button" HorizontalAlignment="Left" Margin="315,359,0,0" VerticalAlignment="Top" Width="160" Height="150" Background="#9370db" Click="buttonHomeHistoryRecords_Click">
                         <Button.ContentTemplate>
                             <DataTemplate>
                                 <StackPanel>
                                     <Rectangle Fill="#ffffff" Width="80" Height="80">
                                         <Rectangle.OpacityMask>
-                                            <VisualBrush Visual="{StaticResource appbar_newspaper}" Stretch="Fill" />
+                                            <VisualBrush Visual="{StaticResource appbar_window_restore}" Stretch="Fill" />
                                         </Rectangle.OpacityMask>
                                     </Rectangle>
-                                    <TextBlock Text="检测报告"  Margin="5 10 4 4" VerticalAlignment="Center" FontSize="20" Foreground="White" />
+                                    <TextBlock Text="历史报告"  Margin="5 10 4 4" VerticalAlignment="Center" FontSize="20" Foreground="White" />
                                 </StackPanel>
                             </DataTemplate>
                         </Button.ContentTemplate>
@@ -161,7 +144,7 @@
                                 <StackPanel>
                                     <Rectangle Fill="#ffffff" Width="80" Height="80">
                                         <Rectangle.OpacityMask>
-                                            <VisualBrush Visual="{StaticResource appbar_settings}" Stretch="Fill" />
+                                            <VisualBrush Visual="{StaticResource appbar_cogs}" Stretch="Fill" />
                                         </Rectangle.OpacityMask>
                                     </Rectangle>
                                     <TextBlock Text="系统设置"  Margin="5 10 4 4" VerticalAlignment="Center" FontSize="20" Foreground="White" />
@@ -169,16 +152,16 @@
                             </DataTemplate>
                         </Button.ContentTemplate>
                     </Button>
-                    <Button x:Name="buttonHomePageDataTransfer" Content="Button" HorizontalAlignment="Left" Margin="699,359,0,0" VerticalAlignment="Top" Width="160" Height="150" Background="#008080" >
+                    <Button x:Name="buttonHomePageDataTransfer" Content="Button" HorizontalAlignment="Left" Margin="699,359,0,0" VerticalAlignment="Top" Width="160" Height="150" Background="#008080" Click="buttonHomePageDataTransfer_Click">
                         <Button.ContentTemplate>
                             <DataTemplate>
                                 <StackPanel>
                                     <Rectangle Fill="#ffffff" Width="80" Height="80">
                                         <Rectangle.OpacityMask>
-                                            <VisualBrush Visual="{StaticResource appbar_share}" Stretch="Fill" />
+                                            <VisualBrush Visual="{StaticResource appbar_information_circle}" Stretch="Fill" />
                                         </Rectangle.OpacityMask>
                                     </Rectangle>
-                                    <TextBlock Text="数据传输"  Margin="5 10 4 4" VerticalAlignment="Center" FontSize="20" Foreground="White" />
+                                    <TextBlock Text="关于程序"  Margin="5 10 4 4" VerticalAlignment="Center" FontSize="20" Foreground="White" />
                                 </StackPanel>
                             </DataTemplate>
                         </Button.ContentTemplate>
@@ -197,7 +180,7 @@
                             </DataTemplate>
                         </Button.ContentTemplate>
                     </Button>
-                    <Label x:Name="labelHomepageCversion" Content="编译日期:20190726" HorizontalAlignment="Left" Margin="594,109,0,0" VerticalAlignment="Top" Foreground="White"/>
+                    <Label x:Name="labelHomepageCversion" Content="编译版本:20200301" HorizontalAlignment="Left" Margin="594,109,0,0" VerticalAlignment="Top" Foreground="White"/>
                 </Grid>
             </TabItem>
             <TabItem Header="用户管理" Style="{StaticResource smallHeader}" >
@@ -212,7 +195,6 @@
                     </TabItem>
                 </TabControl>
             </TabItem>
-
             <!--快筛-->
             <TabItem Header="筛查" Style="{StaticResource smallHeader}" >
                 <TabControl x:Name="tabFilter" HorizontalAlignment="Left" Height="645" Width="1338" Margin="10,-5,0,0" VerticalAlignment="Top" >
@@ -222,8 +204,8 @@
                             <Button x:Name="buttonFilterSelectPatient" IsEnabled="True" Content="开始测试" HorizontalAlignment="Left" Margin="41,531,0,0" VerticalAlignment="Top" Width="240" Height="36" FontSize="15" Click="buttonFilterSelectPatient_Click"/>
                         </Grid>
                     </TabItem>
-                    <TabItem  Header="筛查流程" Style="{StaticResource smallerHeader}"  IsEnabled="False" >
-                        <Grid Background="White" Margin="0,0,0,0">
+                    <TabItem  Header="筛查流程" Style="{StaticResource smallerHeader}"  IsEnabled="False">
+                        <Grid x:Name="filterProcessGrid" Background="White" Margin="0,0,0,0">
                             <Label x:Name="labelGong" Content="共" HorizontalAlignment="Left" Margin="90,10,0,0" VerticalAlignment="Top" FontSize="18"/>
                             <Label x:Name="labelFilterNumberofTotalQuestions" Content="XXX" HorizontalAlignment="Left" Margin="110,10,0,0" VerticalAlignment="Top" FontSize="18"/>
                             <Label x:Name="labelTi" Content="题,当前第" HorizontalAlignment="Left" Margin="150,10,0,0" VerticalAlignment="Top" FontSize="18"/>
@@ -280,7 +262,7 @@
                     </TabItem>
                 </TabControl>
             </TabItem>
-
+            <!--历史报告-->
             <TabItem Header="历史报告" Style="{StaticResource smallHeader}" >
                 <TabControl x:Name="tabHistoryRecords" HorizontalAlignment="Left" Height="645" Width="1338" Margin="10,-5,0,0" VerticalAlignment="Top" >
                     <TabItem  Header="选择病例" Style="{StaticResource smallerHeader}"  IsEnabled="False" >
@@ -306,14 +288,14 @@
                     <TabItem  Header="评估报告" Style="{StaticResource smallerHeader}"  IsEnabled="False" >
                         <Grid Background="White" Margin="0,0,0,0">
                             <Label x:Name="labelPDFH" Content="该报告已在第三方软件中打开" HorizontalAlignment="Left" Margin="543,133,0,0" VerticalAlignment="Top" FontSize="18"/>
-                            <Button x:Name="buttonHistoryBackToSelectUser" Content="重新选择病例" HorizontalAlignment="Left" Margin="500,550,0,0" VerticalAlignment="Top" Width="130" Height="50" FontSize="18" Click="buttonHistoryBackToSelectUser_Click" />
-                            <Button x:Name="buttonHistoryBackToHome" Content="回到首页" HorizontalAlignment="Left" Margin="700,550,0,0" VerticalAlignment="Top" Width="130" Height="50" FontSize="18" Click="buttonHistoryBackToHome_Click" />
+                            <Button x:Name="buttonHistoryBackToSelectUser" Content="重新选择病例" HorizontalAlignment="Left" Margin="400,550,0,0" VerticalAlignment="Top" Width="130" Height="50" FontSize="18" Click="buttonHistoryBackToSelectUser_Click" />
+                            <Button x:Name="buttonHistoryBackToSelectRecord" Content="返回上一级" HorizontalAlignment="Left" Margin="600,550,0,0" VerticalAlignment="Top" Width="130" Height="50" FontSize="18" Click="buttonHistoryBackToSelectRecord_Click" />
+                            <Button x:Name="buttonHistoryBackToHome" Content="回到首页" HorizontalAlignment="Left" Margin="800,550,0,0" VerticalAlignment="Top" Width="130" Height="50" FontSize="18" Click="buttonHistoryBackToHome_Click" />
                         </Grid>
                     </TabItem>
                 </TabControl>
             </TabItem>
-
-
+            <!--系统设置-->
             <TabItem Header="系统设置" x:Name="tabitemDoctorSetting" Style="{StaticResource smallHeader}">
                 <TabControl x:Name="tabControlSystemSetting" HorizontalAlignment="Left" Height="645" Margin="10,-5,0,0" VerticalAlignment="Top" Width="1338" SelectionChanged="tabControlSystemSetting_SelectionChanged">
                     <TabItem Header="医师账户管理" Style="{StaticResource smallerHeader}" >

+ 175 - 33
WpfTest1/MainWindow.xaml.cs

@@ -44,6 +44,7 @@ namespace WpfTest1
         int currentEvaluationCount = 0;
         List<Record> recordsFromOnePatient;
         BindingList<Record> bindingRecords;
+        Dictionary<string, int> mapKeyToDigit = new Dictionary<string, int>();
 
         #endregion
 
@@ -90,6 +91,7 @@ namespace WpfTest1
             }
             loadQuestionaire(filterQuestionaire, "filter");
             loadQuestionaire(evaluationQuestionaire, "evaluation");
+            labelHomepageCversion.Content = "编译日期:" + Toolkits.Constants.compileDate;
         }
 
         private void loadQuestionaire(List<QuestionAnswerPair> oneQuestionaire, string type = "filter")
@@ -104,6 +106,93 @@ namespace WpfTest1
             }
         }
 
+        /// <summary>
+        /// 筛查或评估流程页面识别快捷键的操作
+        /// </summary>
+        /// <param name="sender">默认</param>
+        /// <param name="e">默认</param>
+        private void processGrid_KeyDown(object sender, KeyEventArgs e)
+        {
+            //System.Console.WriteLine(String.Format("KeyDown detected. {0} is detected.", e.Key.ToString()));
+            if (tabControlGeneral.SelectedIndex == 2 && tabFilter.SelectedIndex == 1)
+            {
+                //筛查流程中
+                if (e.Key == Key.N && buttonFilterNext.IsEnabled)
+                {
+                    buttonFilterNext_Click(sender, (RoutedEventArgs)e);
+                    return;
+                }
+                if (e.Key == Key.P && buttonFilterPrevious.IsEnabled)
+                {
+                    buttonFilterPrevious_Click(sender, (RoutedEventArgs)e);
+                    return;
+                }
+                if (e.Key == Key.E)
+                {
+                    buttonAbortFilter_Click(sender, (RoutedEventArgs)e);
+                    return;
+                }
+                if(e.Key == Key.S && buttonSubmitFilter.IsEnabled)
+                {
+                    buttonSubmitFilter_Click(sender, (RoutedEventArgs)e);
+                    return;
+                }
+                if (Constants.keyboardToDigit.ContainsKey(e.Key.ToString()))
+                {
+                    int numInput = Constants.keyboardToDigit[e.Key.ToString()];
+                    try
+                    {
+                        RadioButton rbTemp = (RadioButton)gridFilterSelection.Children[numInput - 1];
+                        rbTemp.IsChecked = true;
+                        radioButtonFilter_Checked(rbTemp, e);
+                    }
+                    catch (Exception)
+                    {
+                        return;
+                    }
+                    
+                    return;
+                }
+            }
+            else if(tabControlGeneral.SelectedIndex == 3 && tabEvaluation.SelectedIndex == 1)
+            {
+                //评估流程中
+                if (e.Key == Key.N && buttonEvaluationNext.IsEnabled)
+                {
+                    buttonEvaluationNext_Click(sender, (RoutedEventArgs)e);
+                    return;
+                }
+                if (e.Key == Key.E)
+                {
+                    buttonAbortEvaluation_Click(sender, (RoutedEventArgs)e);
+                    return;
+                }
+                if (e.Key == Key.S && buttonSubmitEvaluation.IsEnabled)
+                {
+                    buttonSubmitEvaluation_Click(sender, (RoutedEventArgs)e);
+                    return;
+                }
+                if (Constants.keyboardToDigit.ContainsKey(e.Key.ToString()))
+                {
+                    int numInput = Constants.keyboardToDigit[e.Key.ToString()];
+                    try
+                    {
+                        RadioButton rbTemp = (RadioButton)gridEvaluationSelection.Children[numInput - 1];
+                        rbTemp.IsChecked = true;
+                        radioButtonEvaluation_Checked(rbTemp, e);
+                    }
+                    catch (Exception)
+                    {
+                        return;
+                    }
+                }
+            }
+            else
+            {
+                return;
+            }
+        }
+
         #endregion
 
         #region 首页功能
@@ -126,18 +215,35 @@ namespace WpfTest1
             tabControlGeneral.SelectedIndex = 1;
         }
 
+        private void buttonHomePageFilterFunction_Click(object sender, RoutedEventArgs e)
+        {
+            tabControlGeneral.SelectedIndex = 2;
+        }
+
+        private void buttonHomePageEvaluationFunction_Click(object sender, RoutedEventArgs e)
+        {
+            tabControlGeneral.SelectedIndex = 3;
+        }
+
         //首页--检测报告
-        private void buttonHomePageReport_Click(object sender, RoutedEventArgs e)
+        private void buttonHomeHistoryRecords_Click(object sender, RoutedEventArgs e)
         {
-            //buttonResultOpenDirHistory_Click(this, e);
+            tabControlGeneral.SelectedIndex = 4;
         }
 
         //首页--系统设置
         private void buttonHomePageSystemSettings_Click(object sender, RoutedEventArgs e)
         {
-            tabControlGeneral.SelectedIndex = 2;
+            tabControlGeneral.SelectedIndex = 5;
+        }
+
+        //关于程序
+        private void buttonHomePageDataTransfer_Click(object sender, RoutedEventArgs e)
+        {
+            SmallDialogs.AboutBox ab = new SmallDialogs.AboutBox();
+            ab.Show();
         }
-       
+
         //首页--操作帮助
         private void buttonHomePageHelp_Click(object sender, RoutedEventArgs e)
         {
@@ -368,7 +474,7 @@ namespace WpfTest1
                     oneOption.IsChecked = true;
                 else
                     oneOption.IsChecked = false;
-                oneOption.Content = filterQuestionaire[currentIndex - 1].answers[i].a_content;
+                oneOption.Content = String.Format("[选项{0}]:{1}", i+1, filterQuestionaire[currentIndex - 1].answers[i].a_content) ;
                 oneOption.Checked += radioButtonFilter_Checked;
                 oneOption.GroupName = "filterOption";
                 oneOption.FontSize = 18;
@@ -410,9 +516,17 @@ namespace WpfTest1
             MessageBoxResult dr = MessageBox.Show("保存筛查结果成功,是否生成报告?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Question);
             if (dr == MessageBoxResult.OK)
             {
-                Record targetRecord = SQLiteModel.getRecordByID(inserted_r_id);
-                ReportGenerater.generateReport(1, filterPatient, loginDoctor, targetRecord, cfg.organization_name);
-                SQLiteModel.plusOneCountOnRecordByRid(inserted_r_id);
+                try
+                {
+                    Record targetRecord = SQLiteModel.getRecordByID(inserted_r_id);
+                    ReportGenerater.generateReport(1, filterPatient, loginDoctor, targetRecord, cfg.organization_name);
+                    SQLiteModel.plusOneCountOnRecordByRid(inserted_r_id);
+                }
+                catch (Exception err)
+                {
+                    MessageBox.Show("报告生成异常,可能是这份报告当前已被打开无法写入,请尝试关闭该报告后重试。\r\n调试信息:" + err.Message + "\r\n" + err.StackTrace, "错误");
+                    return;
+                }
                 tabFilter.SelectedIndex = 2;
             }
             else
@@ -543,7 +657,7 @@ namespace WpfTest1
                     oneOption.IsChecked = true;
                 else
                     oneOption.IsChecked = false;
-                oneOption.Content = evaluationQuestionaire[currentIndex - 1].answers[i].a_content;
+                oneOption.Content = String.Format("[选项{0}]:{1}", i + 1, evaluationQuestionaire[currentIndex - 1].answers[i].a_content);
                oneOption.Checked += radioButtonEvaluation_Checked;
                oneOption.GroupName = "evaluationOption";
                oneOption.FontSize = 18;
@@ -633,7 +747,7 @@ namespace WpfTest1
             //首先,记录该选择
             RadioButton oneSelection = (RadioButton)sender;
             evaluationUserSelection[currentEvaluationCount - 1].a_id = Convert.ToInt32(oneSelection.Name.Substring(3));
-            if (flagEvaluationWithoutFilter)
+            if (flagEvaluationWithoutFilter && evaluationQuestionaire[currentEvaluationCount-1].question.q_type ==1)
             {
                 filterUserSelection[currentFilterCount - 1].a_id = Convert.ToInt32(oneSelection.Name.Substring(3));
             }
@@ -729,13 +843,18 @@ namespace WpfTest1
             resultsEvaluation = JsonMapper.ToJson(evaluationUserSelection);
             try
             {
+                int tempRId;
                 if (flagEvaluationWithoutFilter)
                 {
-                    int tempRId = SQLiteModel.insertRecord(1, evaluationPatient.p_id, loginDoctor.id, 0, DateTime.Now, 0, resultsFilter);
+                    tempRId = SQLiteModel.insertRecord(1, evaluationPatient.p_id, loginDoctor.id, 0, DateTime.Now, 0, resultsFilter);
                     SQLiteModel.UpdatePatientDataWithLastDate(evaluationPatient.p_id, "p_last_filter_time", DateTime.Now);
-                    filterReportForEvaluation.r_id = tempRId;
                 }
-                inserted_r_id = SQLiteModel.insertRecord(2, evaluationPatient.p_id, loginDoctor.id, filterReportForEvaluation.r_id, DateTime.Now, 0, resultsEvaluation);
+                else
+                {
+                    tempRId = filterReportForEvaluation.r_id;
+                }
+                inserted_r_id = SQLiteModel.insertRecord(2, evaluationPatient.p_id, loginDoctor.id, tempRId, DateTime.Now, 0, resultsEvaluation);
+                SQLiteModel.UpdatePatientDataWithLastDate(evaluationPatient.p_id, "p_last_evaluation_time", DateTime.Now);
             }
             catch (Exception err)
             {
@@ -745,9 +864,18 @@ namespace WpfTest1
             MessageBoxResult dr = MessageBox.Show("保存成功,是否生成报告?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Question);
             if (dr == MessageBoxResult.OK)
             {
-                Record targetRecord = SQLiteModel.getRecordByID(inserted_r_id);
-                SQLiteModel.plusOneCountOnRecordByRid(inserted_r_id);
-                ReportGenerater.generateReport(2, evaluationPatient, loginDoctor, targetRecord, cfg.organization_name);
+                try
+                {
+                    Record targetRecord = SQLiteModel.getRecordByID(inserted_r_id);
+                    SQLiteModel.plusOneCountOnRecordByRid(inserted_r_id);
+                    ReportGenerater.generateReport(2, evaluationPatient, loginDoctor, targetRecord, cfg.organization_name);
+                }
+                catch (Exception err)
+                {
+                    MessageBox.Show("报告生成异常,可能是这份报告当前已被打开无法写入,请尝试关闭该报告后重试。\r\n调试信息:" + err.Message + "\r\n" + err.StackTrace, "错误");
+                    return;
+                }
+
                 tabEvaluation.SelectedIndex = 2;
             }
             else
@@ -846,12 +974,22 @@ namespace WpfTest1
             tabHistoryRecords.SelectedIndex = 1;
         }
 
+        /// <summary>
+        /// 在选择记录页面,点击返回上一级触发的事件
+        /// </summary>
+        /// <param name="sender">默认</param>
+        /// <param name="e">默认</param>
         private void buttonHistoryBackToSelectUser_Click(object sender, RoutedEventArgs e)
         {
             recordsFromOnePatient.Clear();
             tabHistoryRecords.SelectedIndex = 0;
         }
 
+        /// <summary>
+        /// 由历史记录相关页面返回至首页的事件
+        /// </summary>
+        /// <param name="sender">默认</param>
+        /// <param name="e">默认</param>
         private void buttonHistoryBackToHome_Click(object sender, RoutedEventArgs e)
         {
             recordsFromOnePatient.Clear();
@@ -859,6 +997,11 @@ namespace WpfTest1
             tabControlGeneral.SelectedIndex = 0;
         }
 
+        /// <summary>
+        /// 点击生成报告的页面
+        /// </summary>
+        /// <param name="sender">默认</param>
+        /// <param name="e">默认</param>
         private void buttonRegenerateReport_Click(object sender, RoutedEventArgs e)
         {
             Record targetRecord;
@@ -884,12 +1027,27 @@ namespace WpfTest1
             }
             catch(Exception err)
             {
-                MessageBox.Show("报告生成异常\r\n调试信息:\r\n" + err.StackTrace, "错误");
+                MessageBox.Show("报告生成异常,可能是这份报告当前已被打开无法写入,请尝试关闭该报告后重试。\r\n调试信息:\r\n" + err.StackTrace, "错误");
                 return;
             }
             tabHistoryRecords.SelectedIndex = 2;
         }
 
+        /// <summary>
+        /// 从报告生成页点击返回上一页的事件
+        /// </summary>
+        /// <param name="sender">默认</param>
+        /// <param name="e">默认</param>
+        private void buttonHistoryBackToSelectRecord_Click(object sender, RoutedEventArgs e)
+        {
+            tabHistoryRecords.SelectedIndex = 1;
+        }
+
+        /// <summary>
+        /// 双击报告也要生成报告的功能
+        /// </summary>
+        /// <param name="sender">默认</param>
+        /// <param name="e">默认</param>
         private void dataGridRecords_MouseDoubleClick(object sender, MouseButtonEventArgs e)
         {
             buttonRegenerateReport_Click(sender, e);
@@ -1263,9 +1421,6 @@ namespace WpfTest1
             if (((Button)sender).Equals(buttonDeleteAllPdfReport))
             {
                 target_path = Constants.reportPath;
-            }else if (((Button)sender).Equals(buttonDeleteAllCSVWave))
-            {
-                target_path = Constants.exportWavePath;
             }
             try
             {
@@ -1304,19 +1459,6 @@ namespace WpfTest1
 
         #endregion
 
-        private void buttonHomePageMeasureFunction_Click(object sender, RoutedEventArgs e)
-        {
-            Patient onePatient = SQLiteModel.getPatientById("1");
-            Record oneRecord = SQLiteModel.getRecordByID(7);
-            ReportGenerater.generateReport(2, onePatient, loginDoctor, oneRecord, cfg.organization_name);
-        }
-
-        private void buttonHomePageHistoryRecord_Click(object sender, RoutedEventArgs e)
-        {
-            string filename = Constants.reportPath + "\\" + "8" + ".pdf";
-            System.Diagnostics.Process.Start(filename);
-        }
-
         
     }
 

BIN
WpfTest1/Resources/homepage - 副本.jpg


+ 22 - 0
WpfTest1/SmallDialogs/AboutBox.xaml

@@ -0,0 +1,22 @@
+<Window x:Class="WpfTest1.SmallDialogs.AboutBox"
+        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+        xmlns:local="clr-namespace:WpfTest1.SmallDialogs"
+        mc:Ignorable="d"
+        Title="关于" Height="300" Width="400">
+    <Grid>
+        <Label x:Name="label" Content="关于系统" FontSize="18" HorizontalAlignment="Left" Margin="156,5,0,0" VerticalAlignment="Top"/>
+        
+        <Label x:Name="label1" Content="北京君德医疗有限公司  版权所有© 2006-2020" HorizontalAlignment="Left" Margin="69,33,0,0" VerticalAlignment="Top"/>
+        <TextBlock x:Name="textBlock" HorizontalAlignment="Left" Margin="29,63,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="344">
+             &#x0020;&#x0020;&#x0020;&#x0020;君德集团是集医疗器械研发生产、医疗器械销售、康复中心整体解决方案、妇幼关爱解决方案为一体的综合医疗服务商。君德医疗秉承"让科技温暖生命"的理念,提供更具人文关怀的产品及专业的服务。君德医疗联合新加坡南洋理工大学、韩国延世大学、清华大学、北航等知名科研院校分别于新加坡、首尔、北京及深圳成立技术研发平台。目前公司与中国人民解放军总医院、青岛大学附属医院等多家医疗机构打造产学研一体的转化医学平台,为客户提供人性化的专业康复体验。详情请访问:
+            https://jdhealthcare.cn
+        </TextBlock>
+        <Label x:Name="label1_Copy" Content="版本号:" HorizontalAlignment="Left" Margin="243,227,0,0" VerticalAlignment="Top"/>
+        <Label x:Name="labelVersion" Content="XXXXXX" HorizontalAlignment="Left" Margin="301,227,0,0" VerticalAlignment="Top"/>
+        <Button x:Name="buttonClose" Content="关闭窗口" HorizontalAlignment="Left" Margin="156,216,0,0" VerticalAlignment="Top" Width="75" Click="buttonClose_Click"/>
+
+    </Grid>
+</Window>

+ 33 - 0
WpfTest1/SmallDialogs/AboutBox.xaml.cs

@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+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.Shapes;
+
+namespace WpfTest1.SmallDialogs
+{
+    /// <summary>
+    /// AboutBox.xaml 的交互逻辑
+    /// </summary>
+    public partial class AboutBox : Window
+    {
+        public AboutBox()
+        {
+            InitializeComponent();
+            labelVersion.Content = Toolkits.Constants.version;
+        }
+
+        private void buttonClose_Click(object sender, RoutedEventArgs e)
+        {
+            this.Close();
+        }
+    }
+}

+ 17 - 29
WpfTest1/Toolkits/Constants.cs

@@ -9,12 +9,14 @@ namespace WpfTest1.Toolkits
     //各种系统需要使用的常值
     public class Constants
     {
+        //编译版本
+        public static string version = "0.1.0.0";
+        //编译日期
+        public static string compileDate = "20200301";
         //数据库物理地址
         public static string dbPath = System.Environment.CurrentDirectory + "\\Junde.db3";
         //数据库连接直接实用的连接字符串
         public static string Connstr = @"Data Source=" + System.Environment.CurrentDirectory + "\\Junde.db3";
-        //采样间隔(秒)
-        public static double sampleInterval = 0.002;
         //默认的公钥位置
         public static string pubkeyPath = System.Environment.CurrentDirectory + "\\pubkey.xml";
         //报告存放目录
@@ -25,35 +27,21 @@ namespace WpfTest1.Toolkits
         public static string imgPath = System.Environment.CurrentDirectory + "\\image";
         //报告页眉的医院图标
         public static string reportHeadPicPath = Constants.imgPath + "\\reportHeadPic.png";
-        //报告页RP图文件名
-        public static string tmpRPWave = tmpPath + "\\raodongmai.png";
-        //报告页PPG文件名
-        public static string tmpPPGLeftRedWave = tmpPath + "\\ppgLeftRed.png";
-        public static string tmpPPGLeftInfraredWave = tmpPath + "\\ppgLeftInf.png";
-        public static string tmpPPGRightRedWave = tmpPath + "\\ppgRightRed.png";
-        public static string tmpPPGRightInfraredWave = tmpPath + "\\ppgLeftInf.png";
-        //上位机的IP地址
-        public static string UptterIp = "192.168.10.31";
-        //上位机端口
-        public static int UpperPort = 9000;
+        public static readonly Dictionary<string, int> keyboardToDigit = new Dictionary<string, int>
+        {
+            { "D1", 1 },
+            { "D2", 2 },
+            { "D3", 3 },
+            { "D4", 4 },
+            { "D5", 5 },
+            { "D6", 6 },
+            { "D7", 7 },
+            { "D8", 8 },
+            { "D9", 9 },
+        };
         //厂家管理员的ID
         public static string adminUsername = "superman";
-        //波形存储放大话或者缩小的倍数
-        public static int zoomTimes = 1000000;
-        //滤波器一阶低通
-        public static string filter_1_PathLow = System.Environment.CurrentDirectory + "\\filter1l.dat";
-        //滤波器一阶高通
-        public static string filter_1_PathHigh = System.Environment.CurrentDirectory + "\\filter1h.dat";
-        //滤波器二阶低通
-        public static string filter_2_PathLow = System.Environment.CurrentDirectory + "\\filter2l.dat";
-        //滤波器二阶高通
-        public static string filter_2_PathHigh = System.Environment.CurrentDirectory + "\\filter2h.dat";
-        //导出文件存放目录
-        public static string exportWavePath = System.Environment.CurrentDirectory + "\\exportWave";
-        //判断波谷范围的阈值
-        //public static int searchPoints = 2000;
-        //public static double redTroughThreShold = 6600;
-        //public static double infraredTroughThreshold = 22000;
+
 
     }
 }

+ 0 - 51
WpfTest1/Toolkits/FilterFile.cs

@@ -1,51 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace WpfTest1.Toolkits
-{
-    class FilterFile
-    {
-        public static int ReadFilterFiles(List<double>[] filter)
-        {
-            //滤波器加载
-            string[] files = { Toolkits.Constants.filter_1_PathLow, Toolkits.Constants.filter_1_PathHigh, Toolkits.Constants.filter_2_PathLow, Toolkits.Constants.filter_1_PathHigh };
-            for(int i = 0;i< files.Length; ++i)
-            {
-                try
-                {
-                    StreamReader filterReader = new StreamReader(files[i]);
-                    string sLine = "";
-                    while (sLine != null)
-                    {
-                        try
-                        {
-                            sLine = filterReader.ReadLine();
-                            //Console.WriteLine(sLine);
-                            if (sLine != null && !sLine.Equals(""))
-                                filter[i].Add(Convert.ToDouble(sLine));
-                        }
-                        catch (Exception err)
-                        {
-                            Console.WriteLine("滤波器文件内容已损坏,错误文件编号:" + i);
-                            Console.WriteLine(err.StackTrace);
-                            return -1;
-                        }
-
-                    }
-                    filterReader.Close();
-                }
-                catch (Exception)
-                {
-                    Console.WriteLine("滤波器文件不存在或文件内容已损坏,错误文件编号:" + i);
-                    return -2;
-                }
-            }
-            return 0;
-            
-        }
-    }
-}

+ 0 - 50
WpfTest1/Toolkits/MeasureHandle.cs

@@ -1,50 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace WpfTest1.Toolkits
-{
-    class MeasureHandle
-    {
-        public static double Code2Vol(byte hex1,byte hex2, byte hex3)
-        {
-            int data;
-            if(hex1>>7 == 0x01)
-            {
-                //是负数,补0xff
-                data = (0xff << 24) | (hex1 << 16) | (hex2 << 8) | hex3;
-            }
-            else
-            {
-                //是正数,补0x00
-                data = (0x00 << 24) | (hex1 << 16) | (hex2 << 8) | hex3;
-            }
-            double result = (1.25 + 1.21 * data / 8388607.0);
-            return 2.47 - result;//波形需要拿最大值翻转一下
-            //return (int)((result_temp - (int)result_temp) * 1000000);
-        }
-
-        //4404组件使用的22位数字信号转数值方法
-        public static double Code2Vol_22(byte hex1, byte hex2, byte hex3)
-        {
-            int data;
-            byte masked_hex1 = (byte)(hex1 & 0x3f);
-            if ((masked_hex1) >> 5 > 0x01)
-            {
-                //是负数,补0xff
-                data = (0xff << 24) | ((masked_hex1 | 0xc0 ) << 16) | (hex2 << 8) | hex3;
-            }
-            else
-            {
-                //是正数,补0x00
-                data = (0x00 << 24) | (masked_hex1 << 16) | (hex2 << 8) | hex3;
-            }
-            double result = (1.2 * data / 2097151.0);
-            return -result;//波形需要拿最大值翻转一下
-            //return (int)((result_temp - (int)result_temp) * 1000000);
-        }
-    }
-}

+ 0 - 220
WpfTest1/Toolkits/RPCalculate.cs

@@ -1,220 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Runtime.InteropServices;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace WpfTest1.Toolkits
-{
-    public class RPCalculate
-    {
-        ///*
-        //[DllImport("rgz.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
-        [DllImport("rgz.dll")]
-        public static extern int rgz_fx(ref int val_sg, ref int val_yc, ref int val_cc, ref int val_nl, ref int val_jzs, ref int val_ssy,
-           ref int val_szy, ref int val_pjy, ref int val_xl, ref int val_yz, ref int val_yt, ref int val_bxlx, ref int val_tz, ref double val_bxxs,
-            ref double val_wzzl, ref double val_xscl, ref double val_mbl, ref double val_xzzs, ref double val_xbzs, ref double val_tbmj,
-           ref double val_zxrl, ref double val_syx, ref double val_yac, ref double val_tzzs, ref double val_bltz, ref double val_zxxll,
-            ref double val_xyzs, ref double val_xynd, ref double val_pjzlsj, ref double val_pl, ref double zl,
-             ref string val_ckjg, ref double val_ckzs, ref int val_len, ref string[] val_mbbx);
-
-        //输入源
-        public int shengao;
-        public int yunci;
-        public int chanci;
-        public int nianling;
-        public int jiazushi;
-        public int shousuoya;
-        public int shuzhangya;
-        public int pingjundongmaiya;
-        public int mailv;
-        public int yunzhou;
-        public int yuntian;
-        public int tizhong;
-        public string[] maixinbo = new string[500]; //具体多少需要进一步调整
-        public int boxinleixin;
-        public int mbbxlen;
-        //输出源
-        public double boxinxishu = 0;
-        public double waizhouzuli = 0;
-        public double xinshuchuliang = 0;
-        public double meiboliang = 0;
-        public double xinzangzhishu = 0;
-        public double xinbozhishu = 0;
-        public double tibiaomianji = 0;
-        public double zongxuerongliang = 0;
-        public double shunyinxing = 0;
-        public double maiya = 0;
-        public double tizhongzhishu = 0;
-        public double bianliangtizhong = 0;
-        public double zhongxinxueliuliang = 0;
-        public double xueyazhishu = 0;
-        public double xueyeniandu = 0;
-        public double pingjunzhiliushijian = 0;
-        public string cankaojieguo = "            ";
-        public double cankaozhishu = 0;
-        public double xpl = 0;  //排量
-        public double wzzl = 0; //阻力
-
-        public RPCalculate(int sg, int yc, int cc, int nl, int jzs, int ssy, int szy, int pjdmy, int ml, int yz, int yt, int tz, string[] mxb, int bxlx)
-        {
-            shengao = sg;
-            yunci = yc;
-            chanci = cc;
-            nianling = nl;
-            jiazushi = jzs;
-            shousuoya = ssy;
-            shuzhangya = szy;
-            pingjundongmaiya = pjdmy;
-            mailv = ml;
-            yunzhou = yz;
-            yuntian = yt;
-            tizhong = tz;
-            maixinbo = mxb;
-            boxinleixin = bxlx;
-            mbbxlen = mxb.Count();
-        }
-
-        public void calculateRP()
-        {
-            //测试用例
-            maixinbo[0] = "1";
-            maixinbo[1] = "2";
-            maixinbo[2] = "3";
-            mbbxlen = 3;
-            int status = rgz_fx(
-                     ref shengao, ref yunci, ref chanci, ref nianling, ref jiazushi, ref shousuoya, ref shuzhangya, ref pingjundongmaiya,
-                     ref mailv, ref yunzhou, ref yuntian, ref boxinleixin, ref tizhong, ref boxinxishu, ref waizhouzuli, ref xinshuchuliang,
-                     ref meiboliang, ref xinzangzhishu, ref xinbozhishu, ref tibiaomianji, ref zongxuerongliang, ref shunyinxing,
-                     ref maiya, ref tizhongzhishu, ref bianliangtizhong, ref zhongxinxueliuliang, ref xueyazhishu, ref xueyeniandu,
-                     ref pingjunzhiliushijian, ref xpl, ref wzzl, ref cankaojieguo, ref cankaozhishu, ref mbbxlen, ref maixinbo);
-
-            if (status == 1)
-            {
-                Console.WriteLine("rp calculate done.");
-            }
-            else
-            {
-                Console.WriteLine("rp calculate failed.");
-            }
-        }
-        //*/
-            /*
-            [DllImport("rgz.dll", CallingConvention = CallingConvention.StdCall)]
-            public static extern IntPtr rgz_fx(IntPtr val_sg, IntPtr val_yc, IntPtr val_cc, IntPtr val_nl, IntPtr val_jzs, IntPtr val_ssy, IntPtr val_szy
-                , IntPtr val_pjy, IntPtr val_xl, IntPtr val_yz, IntPtr val_yt, IntPtr val_bxlx, IntPtr val_tz , IntPtr val_bxxs, IntPtr val_wzzl,
-                IntPtr val_xscl, IntPtr val_mbl, IntPtr val_xzzs, IntPtr val_xbzs, IntPtr val_tbmj, IntPtr val_zxrl, IntPtr val_syx,
-                IntPtr val_yac, IntPtr val_tzzs, IntPtr val_bltz, IntPtr val_zxxll, IntPtr val_xyzs, IntPtr val_xynd, IntPtr val_pjzlsj,
-                IntPtr val_mbbx, IntPtr val_ckjg, IntPtr val_ckzs);
-            //输入源
-            public int shengao;
-            public int yunci;
-            public int chanci;
-            public int nianling;
-            public int jiazushi;
-            public int shousuoya;
-            public int shuzhangya;
-            public int pingjundongmaiya;
-            public int mailv;
-            public int yunzhou;
-            public int yuntian;
-            public int tizhong;
-            public int[] maixinbo;
-            public int boxinleixin;
-            //输出源
-            float boxinxishu = 0;
-            float waizhouzuli = 0;
-            float xinshuchuliang = 0;
-            float meiboliang = 0;
-            float xinzangzhishu = 0;
-            float xinbozhishu = 0;
-            float tibiaomianji = 0;
-            float zongxuerongliang = 0;
-            float shunyinxing = 0;
-            float maiya = 0;
-            float tizhongzhishu = 0;
-            float bianliangtizhong = 0;
-            float zhongxinxueliuliang = 0;
-            float xueyazhishu = 0;
-            float xueyeniandu = 0;
-            float pingjunzhiliushijian = 0;
-            char[] cankaojieguo = new char[1000];
-            float cankaozhishu = 0;
-
-            public RPCalculate(int sg,int yc, int cc,int nl, int jzs, int ssy, int szy, int pjdmy, int ml, int yz, int yt, int tz, int[] mxb,int bxlx)
-            {
-                shengao = sg;
-                yunci = yc;
-                chanci = cc;
-                nianling = nl;
-                jiazushi = jzs;
-                shousuoya = ssy;
-                shuzhangya = szy;
-                pingjundongmaiya = pjdmy;
-                mailv = ml;
-                yunzhou = yz;
-                yuntian = yt;
-                tizhong = tz;
-                maixinbo = mxb;
-                boxinleixin = bxlx;
-            }
-
-            public void calculateRP()
-            {
-                IntPtr shengaoPTR = Marshal.AllocHGlobal(Marshal.SizeOf(shengao));
-                IntPtr yunciPTR = Marshal.AllocHGlobal(Marshal.SizeOf(yunci));
-                IntPtr chanciPTR = Marshal.AllocHGlobal(Marshal.SizeOf(chanci));
-                IntPtr nianlingPTR = Marshal.AllocHGlobal(Marshal.SizeOf(nianling));
-                IntPtr jiazushiPTR = Marshal.AllocHGlobal(Marshal.SizeOf(jiazushi));
-                IntPtr shousuoyaPTR = Marshal.AllocHGlobal(Marshal.SizeOf(shousuoya));
-                IntPtr shuzhangyaPTR = Marshal.AllocHGlobal(Marshal.SizeOf(shuzhangya));
-                IntPtr pingjundongmaiyaPTR = Marshal.AllocHGlobal(Marshal.SizeOf(pingjundongmaiya));
-                IntPtr mailvPTR = Marshal.AllocHGlobal(Marshal.SizeOf(mailv));
-                IntPtr yunzhouPTR = Marshal.AllocHGlobal(Marshal.SizeOf(yunzhou));
-                IntPtr yuntianPTR = Marshal.AllocHGlobal(Marshal.SizeOf(yuntian));
-                IntPtr boxinleixinPTR = Marshal.AllocHGlobal(Marshal.SizeOf(boxinleixin));
-                IntPtr tizhongPTR = Marshal.AllocHGlobal(Marshal.SizeOf(tizhong));
-                IntPtr boxinxishuPTR = Marshal.AllocHGlobal(Marshal.SizeOf(boxinxishu));
-                IntPtr waizhouzuliPTR = Marshal.AllocHGlobal(Marshal.SizeOf(waizhouzuli));
-                IntPtr xinshuchuliangPTR = Marshal.AllocHGlobal(Marshal.SizeOf(xinshuchuliang));
-                IntPtr meiboliangPTR = Marshal.AllocHGlobal(Marshal.SizeOf(meiboliang));
-                IntPtr xinzangzhishuPTR = Marshal.AllocHGlobal(Marshal.SizeOf(xinzangzhishu));
-                IntPtr xinbozhishuPTR = Marshal.AllocHGlobal(Marshal.SizeOf(xinbozhishu));
-                IntPtr tibiaomianjiPTR = Marshal.AllocHGlobal(Marshal.SizeOf(tibiaomianji));
-                IntPtr zongxuerongliangPTR = Marshal.AllocHGlobal(Marshal.SizeOf(zongxuerongliang));
-                IntPtr shunyinxingPTR = Marshal.AllocHGlobal(Marshal.SizeOf(shunyinxing));
-                IntPtr maiyaPTR = Marshal.AllocHGlobal(Marshal.SizeOf(maiya));
-                IntPtr tizhongzhishuPTR = Marshal.AllocHGlobal(Marshal.SizeOf(tizhongzhishu));
-                IntPtr bianliangtizhongPTR = Marshal.AllocHGlobal(Marshal.SizeOf(bianliangtizhong));
-                IntPtr zhongxinxueliuliangPTR = Marshal.AllocHGlobal(Marshal.SizeOf(zhongxinxueliuliang));
-                IntPtr xueyazhishuPTR = Marshal.AllocHGlobal(Marshal.SizeOf(xueyazhishu));
-                IntPtr xueyenianduPTR = Marshal.AllocHGlobal(Marshal.SizeOf(xueyeniandu));
-                IntPtr pingjunzhiliushijianPTR = Marshal.AllocHGlobal(Marshal.SizeOf(pingjunzhiliushijian));
-                IntPtr maixinboPTR = Marshal.AllocHGlobal(sizeof(int)*2000);
-                Marshal.Copy(maixinbo, 0, maixinboPTR, 2000);
-                IntPtr cankaojieguoPTR = Marshal.AllocHGlobal(sizeof(char) * 1000);
-                Marshal.Copy(cankaojieguo, 0, cankaojieguoPTR, 1000);
-                IntPtr cankaozhishuPTR = Marshal.AllocHGlobal(Marshal.SizeOf(cankaozhishu));
-                IntPtr statusPTR = Marshal.AllocHGlobal(Marshal.SizeOf(1));
-                statusPTR = rgz_fx(
-                    shengaoPTR, yunciPTR, chanciPTR, nianlingPTR, jiazushiPTR, shousuoyaPTR, shuzhangyaPTR, pingjundongmaiyaPTR
-                    , mailvPTR, yunzhouPTR, yuntianPTR, boxinleixinPTR, tizhongPTR, boxinxishuPTR, waizhouzuliPTR, xinshuchuliangPTR,
-                    meiboliangPTR, xinzangzhishuPTR, xinbozhishuPTR, tibiaomianjiPTR, zongxuerongliangPTR, shunyinxingPTR,
-                    maiyaPTR, tizhongzhishuPTR, bianliangtizhongPTR, zhongxinxueliuliangPTR, xueyazhishuPTR, xueyenianduPTR,
-                    pingjunzhiliushijianPTR, maixinboPTR,
-                    cankaojieguoPTR, cankaozhishuPTR);
-                int status = Marshal.ReadInt32(statusPTR);
-                if (status == 1)
-                {
-                    Console.WriteLine("done.");
-                }
-                else
-                {
-                    Console.WriteLine("failed.");
-                }
-            }
-            //*/
-
-        }
-}

+ 0 - 1013
WpfTest1/Toolkits/ReportGenerator_old.cs

@@ -1,1013 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using MSWord = Microsoft.Office.Interop.Word;
-using System.IO;
-using System.Reflection;
-
-namespace WpfTest1.Toolkits
-{
-    class ReportGenerator_old
-    {
-        /*
-         * generateReport:生成报告的方法
-         * 参数:
-         * patiment:病人对象
-         * rcd: 报告对象
-         * cfg 系统Config类
-         * handFlag:0均没有,1左手,2右手,3双手
-         * mw: 主界面引用
-         * expressions:各参数值结果
-         * rpRecord: RP环节的结果
-         * generalExpressionResult: 用于自动评价风险的总表达式结果,double
-         * */
-        //
-        public void generateReport(SQLite.Patient patient, SQLite.Record rcd, Config cfg, int handFlag,MainWindow mw, Dictionary<string,double> expressions, SQLite.doctor doct,RPCalculate rpRecord, string generalExpressionResult)
-        {
-            String path = Constants.reportPath;
-            //String now = System.DateTime.Now.ToString("yyyyMMddHHmmss");
-            /* String picName0 = path + "\\" + "0.jpg";
-             String picName1 = path + "\\" + "1.jpg";
-             String picName2 = path + "\\" + "2.jpg";
-             String picName3 = path + "\\" + "3.jpg";
-             String picName4 = path + "\\" + "4.jpg";
-             */
-            String fileName = path + "\\" + patient.p_record_id + "_" + patient.p_name + "_" + rcd.r_time.ToString("yyyyMMddHHmmss") + ".doc";
-            String pdfFileName = path + "\\" + patient.p_record_id + "_" + patient.p_name + "_" + rcd.r_time.ToString("yyyyMMddHHmmss") + ".pdf";
-            if (File.Exists(fileName))
-            {
-                try
-                {
-                    File.Delete(fileName);
-                }
-                catch (Exception)
-                {
-                    ;
-                }
-                
-            }
-            FileStream fs = new FileStream(fileName, FileMode.CreateNew);
-            fs.Close();
-            int space = 12;
-
-            Object oMissing = System.Reflection.Missing.Value;
-            Microsoft.Office.Interop.Word._Application WordApp = new Microsoft.Office.Interop.Word.Application();
-            object filename = fileName;
-            Microsoft.Office.Interop.Word._Document WordDoc = null;
-
-            try
-            {
-                
-                WordDoc = WordApp.Documents.Open(ref filename, ref oMissing,
-                        ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
-                        ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
-                WordApp.Visible = false;
-
-                //页面设置
-                WordDoc.PageSetup.PaperSize = MSWord.WdPaperSize.wdPaperA4;//设置纸张样式为A4纸
-                WordDoc.PageSetup.Orientation = MSWord.WdOrientation.wdOrientPortrait;//排列方式为垂直方向
-                WordDoc.PageSetup.TopMargin = 57.0f;
-                WordDoc.PageSetup.BottomMargin = 10.0f;
-                WordDoc.PageSetup.LeftMargin = 57.0f;
-                WordDoc.PageSetup.RightMargin = 57.0f;
-                WordDoc.PageSetup.HeaderDistance = 30.0f;//页眉位置
-                WordDoc.PageSetup.FooterDistance = 15.0f;
-
-                //设置页眉
-                WordApp.ActiveWindow.View.Type = Microsoft.Office.Interop.Word.WdViewType.wdOutlineView;//视图样式
-                WordApp.ActiveWindow.View.SeekView = Microsoft.Office.Interop.Word.WdSeekView.wdSeekPrimaryHeader;//进入页眉设置,其中页眉边距在页面设置中已完成
-                WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphRight;
-
-                //插入页眉图片(测试结果图片未插入成功)
-                WordApp.Selection.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;
-                string headerfile = Constants.reportHeadPicPath;
-                Console.WriteLine(headerfile);
-                Microsoft.Office.Interop.Word.InlineShape shape1 = WordApp.ActiveWindow.ActivePane.Selection.InlineShapes.AddPicture(headerfile, ref oMissing, ref oMissing, ref oMissing);
-                shape1.Height = 25;
-                shape1.Width = 25;
-
-                //页眉修改Test
-                object unite = Microsoft.Office.Interop.Word.WdUnits.wdStory;
-                object count = WordDoc.Paragraphs.Count;
-                object WdLine = Microsoft.Office.Interop.Word.WdUnits.wdParagraph;
-                string eyeContent = cfg.organization_name;
-                //第一行
-                WordApp.Selection.Font.Name = "黑体";
-                WordApp.Selection.Font.Bold = 1;
-                WordApp.Selection.Font.Color = MSWord.WdColor.wdColorRed;
-                WordApp.Selection.Font.Size = 30;
-                WordApp.Selection.Font.Spacing = 10;
-
-
-                WordApp.ActiveWindow.ActivePane.Selection.InsertAfter(" " + eyeContent + "\n");
-                WordApp.Selection.MoveDown(ref WdLine, ref count, ref oMissing);
-                //第二行
-                WordApp.Selection.Font.Name = "黑体";
-                WordApp.Selection.Font.Bold = 1;
-                WordApp.Selection.Font.Color = MSWord.WdColor.wdColorGray30;
-                WordApp.Selection.Font.Size = 20;
-                WordApp.Selection.Font.Spacing = 0;
-                WordApp.ActiveWindow.ActivePane.Selection.InsertAfter("PIH检测报告单" + "\n");
-                //第一行
-                WordApp.Selection.MoveDown(ref WdLine, ref count, ref oMissing);
-                WordApp.Selection.Font.Name = "黑体";
-                WordApp.Selection.Font.Bold = 1;
-                WordApp.Selection.Font.Color = MSWord.WdColor.wdColorGray30;
-                WordApp.Selection.Font.Size = 10;
-                string currentData = DateTime.Now.ToString("yy/MM/dd");
-                WordApp.ActiveWindow.ActivePane.Selection.InsertAfter("病案编号:" + rcd.r_id + "      " + "检查日期:" + currentData);
-
-                //去掉页眉的横线
-                //WordApp.ActiveWindow.ActivePane.Selection.ParagraphFormat.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].LineStyle = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleNone;
-                //WordApp.ActiveWindow.ActivePane.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].Visible = false;
-                WordApp.ActiveWindow.ActivePane.View.SeekView = Microsoft.Office.Interop.Word.WdSeekView.wdSeekMainDocument;//退出页眉设置
-
-                //页脚
-                WordApp.ActiveWindow.View.Type = Microsoft.Office.Interop.Word.WdViewType.wdOutlineView;
-                WordApp.ActiveWindow.View.SeekView = Microsoft.Office.Interop.Word.WdSeekView.wdSeekPrimaryFooter;
-                //移动光标文档末尾
-                //  object count = WordDoc.Paragraphs.Count;
-                // object WdLine = Microsoft.Office.Interop.Word.WdUnits.wdParagraph;
-                WordApp.Selection.MoveDown(ref WdLine, ref count, ref oMissing);//移动焦点
-                // 去掉页脚的横线
-                WordApp.ActiveWindow.ActivePane.Selection.ParagraphFormat.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderTop].LineStyle = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleSingle;
-                WordApp.ActiveWindow.ActivePane.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].Visible = true;
-
-                //为当前页添加页码
-                Microsoft.Office.Interop.Word.PageNumbers pns = WordApp.Selection.Sections[1].Headers[Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterEvenPages].PageNumbers;//获取当前页的号码
-                pns.NumberStyle = Microsoft.Office.Interop.Word.WdPageNumberStyle.wdPageNumberStyleNumberInDash;
-                pns.HeadingLevelForChapter = 0;
-                pns.IncludeChapterNumber = false;
-                pns.RestartNumberingAtSection = false;
-                pns.StartingNumber = 0;
-                object pagenmbetal = Microsoft.Office.Interop.Word.WdPageNumberAlignment.wdAlignPageNumberCenter;//将号码设置在中间
-                object first = true;
-                WordApp.Selection.Sections[1].Footers[Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterEvenPages].PageNumbers.Add(ref pagenmbetal, ref first);
-
-
-                WordApp.ActiveWindow.ActivePane.View.SeekView = Microsoft.Office.Interop.Word.WdSeekView.wdSeekMainDocument;//退出页眉设置
-                //插入表格
-                // WordApp.Selection.EndKey(ref WdLine, ref oMissing);
-                //WordApp.Selection.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;
-                int tableRow = 6;
-                int tableColumn = 6;
-                //定义一个word中的表格对象
-                MSWord.Table table = WordDoc.Tables.Add(WordApp.Selection.Range, tableRow, tableColumn, ref oMissing, ref oMissing);
-                table.Range.Font.Size = 10;
-                table.Range.Font.Bold = 0;
-                table.Range.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;
-                //内线
-                //table.Borders.InsideLineStyle = MSWord.WdLineStyle.wdLineStyleSingle;
-                table.Columns[1].Width = 70;
-                table.Columns[2].Width = 120;
-                table.Columns[3].Width = 60;
-                table.Columns[4].Width = 70;
-                table.Columns[5].Width = 80;
-                //table.Columns[6].Width = 40;
-                for (int i = 1; i <= 6; i = i + 2)
-                {
-                    for (int j = 1; j <= 6; j++)
-                    {
-                        table.Cell(j, i).Range.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphLeft;
-                    }
-                }
-
-                table.Cell(1, 1).Range.Text = "身份证号:";
-                table.Cell(1, 2).Range.Text = patient.p_record_id;
-                table.Cell(1, 3).Range.Text = "性别:";
-                table.Cell(1, 4).Range.Text = "女";
-                table.Cell(1, 5).Range.Text = "病例号:";
-                table.Cell(1, 6).Range.Text = patient.p_record_id.ToString();
-                table.Cell(2, 1).Range.Text = "姓名:";
-                table.Cell(2, 2).Range.Text = patient.p_name;
-                table.Cell(2, 3).Range.Text = "年龄:";
-                if (patient.p_record_id.Length == 18)
-                {
-                    //假设身份证号合法
-                    string birthday = patient.p_record_id.Substring(6, 8);
-                    //MessageBox.Show(birthday);
-                    if (birthday.Substring(0, 2) == "19" || birthday.Substring(0, 2) == "20")
-                    {
-                        DateTime birthdayDate = new DateTime(Convert.ToInt32(birthday.Substring(0, 4)), Convert.ToInt32(birthday.Substring(4, 2)), Convert.ToInt32(birthday.Substring(6, 2)));
-                        int age = Toolkits.OtherSmallFunction.getAgeByBirthDay(birthdayDate);
-                        table.Cell(2, 4).Range.Text = age.ToString();
-                    }
-                    else
-                    {
-                        table.Cell(2, 4).Range.Text = "--";
-                    }
-                }
-                else
-                {
-                    table.Cell(2, 4).Range.Text = "--";
-                }
-                table.Cell(2, 5).Range.Text = "床号:";
-                table.Cell(2, 6).Range.Text = "--";
-                table.Cell(3, 1).Range.Text = "身高:";
-                table.Cell(3, 2).Range.Text = patient.p_height.ToString();
-                table.Cell(3, 3).Range.Text = "科别:";
-                table.Cell(3, 4).Range.Text = "产科";
-                table.Cell(3, 5).Range.Text = "检查部位:";
-                switch (handFlag)
-                {
-                    case 0:
-                        table.Cell(3, 6).Range.Text = "□左手 □右手";
-                        break;
-                    case 1:
-                        table.Cell(3, 6).Range.Text = "√左手 □右手";
-                        break;
-                    case 2:
-                        table.Cell(3, 6).Range.Text = "□左手 √右手";
-                        break;
-                    default:
-                        table.Cell(3, 6).Range.Text = "√左手 √右手";
-                        break;
-                }
-                table.Cell(4, 1).Range.Text = "体重:";
-                table.Cell(4, 2).Range.Text = patient.p_weight.ToString();
-                table.Cell(4, 3).Range.Text = "孕周:";
-                //table.Cell(4, 4).Range.Text = ((DateTime.Now - patient.pregnancy_date).Days / 7 + 1).ToString(); ;
-                table.Cell(4, 5).Range.Text = "孕次:";
-                //table.Cell(4, 6).Range.Text = patient.pregnancy_times.ToString();
-                table.Cell(5, 1).Range.Text = "科室:";
-                table.Cell(5, 2).Range.Text = "--";
-                table.Cell(5, 3).Range.Text = "病床号:";
-                table.Cell(5, 4).Range.Text = "----";
-                table.Cell(5, 5).Range.Text = "单胎/多胎:";
-                table.Cell(5, 6).Range.Text = "--";
-                table.Cell(6, 1).Range.Text = "病区:";
-                table.Cell(6, 2).Range.Text = "--";
-                table.Cell(6, 3).Range.Text = "住院号:";
-                table.Cell(6, 4).Range.Text = "--";
-                table.Cell(6, 5).Range.Text = "设备型号:";
-                table.Cell(6, 6).Range.Text = "HC2180-D";
-
-                Microsoft.Office.Interop.Word.Paragraph oPara1 = WordDoc.Content.Paragraphs.Add(ref oMissing);
-                oPara1.Range.Text = "____________________________________________________________________________________________";
-                oPara1.Range.Font.Bold = 0;
-                oPara1.Range.InsertParagraphAfter();
-
-                //分栏测试
-
-
-                //参数检测部分
-                /*
-                oPara1.Range.Text = "血液动力学参数检测";
-                oPara1.Range.Font.Bold = 0;
-                oPara1.Format.SpaceAfter = space;
-                oPara1.Range.InsertParagraphAfter();
-                */
-                //插入表格
-                //WordDoc.Content.InsertAfter("\n");
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                //WordApp.Selection.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;
-                //WordApp.Selection.MoveDown(ref WdLine, ref count, ref oMissing);
-                int tableRow2 = 43;
-                int tableColumn2 = 5;
-                //定义一个word中的表格对象
-                MSWord.Table table2 = WordDoc.Tables.Add(WordApp.Selection.Range, tableRow2, tableColumn2, ref oMissing, ref oMissing);
-                table2.Range.Font.Size = 8;
-                table2.Range.Font.Bold = 0;
-                table2.Range.Rows.Height = 13;
-                table2.Rows.HeightRule = MSWord.WdRowHeightRule.wdRowHeightExactly;
-                table2.Range.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphLeft;
-                //内线
-                //table2.Borders.InsideLineStyle = MSWord.WdLineStyle.wdLineStyleSingle;
-                table2.Columns[1].Width = 95;
-                table2.Columns[2].Width = 40;
-                table2.Columns[3].Width = 15;
-                table2.Columns[4].Width = 95;
-                table2.Columns[5].Width = 250;
-                //table2.Columns[6].Width = 40;
-                //table2.Columns[7].Width = 15;
-                //table2.Columns[8].Width = 95;
-                /*for(int i=1;i<=22;i++)
-                {
-                    table2.Rows[i].Height = 60;
-                }*/
-                //合并表格
-                table2.Cell(1, 1).Merge(table2.Cell(1, 4));
-                table2.Cell(2, 5).Merge(table2.Cell(43, 5));
-
-                //表格文字
-                table2.Cell(1, 1).Range.Text = "血液动力学参数检测结果";
-                table2.Cell(2, 1).Range.Text = "收缩压SPB:";
-                table2.Cell(2, 2).Range.Text = rpRecord.shousuoya.ToString();
-                try
-                {
-                    double hbp = rpRecord.shousuoya;
-                    if (hbp > 130)
-                    {
-                        table2.Cell(2, 3).Range.Text = "↑";
-                    }
-                    else if (hbp < 90)
-                    {
-                        table2.Cell(2, 3).Range.Text = "↓";
-                    }
-                    else
-                    {
-                    }
-                }
-                catch (Exception)
-                {
-
-                }
-                table2.Cell(2, 4).Range.Text = "90-130mmHg";
-
-                table2.Cell(3, 1).Range.Text = "舒张压DPB:";
-                table2.Cell(3, 2).Range.Text = rpRecord.shuzhangya.ToString();
-                try
-                {
-                    double hbp = rpRecord.shuzhangya;
-                    if (hbp > 100)
-                    {
-                        table2.Cell(3, 3).Range.Text = "↑";
-                    }
-                    else if (hbp < 60)
-                    {
-                        table2.Cell(3, 3).Range.Text = "↓";
-                    }
-                    else
-                    {
-                    }
-                }
-                catch (Exception)
-                {
-
-                }
-                table2.Cell(3, 4).Range.Text = "60-100mmHg";
-
-                table2.Cell(4, 1).Range.Text = "脉压PP:";
-                table2.Cell(4, 2).Range.Text = rpRecord.maiya.ToString();
-                if(rpRecord.maiya > 50)
-                {
-                    table2.Cell(4, 3).Range.Text = "↑";
-                }
-                else if(rpRecord.maiya < 35)
-                {
-                    table2.Cell(4, 3).Range.Text = "↓";
-                }
-                table2.Cell(4, 4).Range.Text = "35-50mmHg";
-
-                table2.Cell(5, 1).Range.Text = "平均动脉压MAP:";
-                table2.Cell(5, 2).Range.Text = rpRecord.pingjundongmaiya.ToString();
-                try
-                {
-                    double hbp = rpRecord.pingjundongmaiya;
-                    if (hbp > 95)
-                    {
-                        table2.Cell(5, 3).Range.Text = "↑";
-                    }
-                    else if (hbp < 85)
-                    {
-                        table2.Cell(5, 3).Range.Text = "↓";
-                    }
-                    else
-                    {
-                    }
-                }
-                catch (Exception)
-                {
-
-                }
-                table2.Cell(5, 4).Range.Text = "85-95mmHg";
-
-                table2.Cell(6, 1).Range.Text = "血压指数BPI:";
-                table2.Cell(6, 2).Range.Text = rpRecord.xueyazhishu.ToString();
-                try
-                {
-                    double hbp = rpRecord.xueyazhishu;
-                    if (hbp > 150)
-                    {
-                        table2.Cell(6, 3).Range.Text = "↓";
-                    }
-                    else
-                    {
-                    }
-                }
-                catch (Exception)
-                {
-                }
-                table2.Cell(6, 4).Range.Text = "<150";
-
-                table2.Cell(7, 1).Range.Text = "体表面积TBA:";
-                table2.Cell(7, 2).Range.Text = rpRecord.tibiaomianji.ToString();
-                table2.Cell(7, 4).Range.Text = "m*m";
-
-                table2.Cell(8, 1).Range.Text = "血总容量BV:"; //textBoxRPzongxuerongliangHistory
-                table2.Cell(8, 2).Range.Text = rpRecord.zongxuerongliang.ToString();
-                table2.Cell(8, 4).Range.Text = "(参考范围)";
-
-                table2.Cell(9, 1).Range.Text = "波形系数K:";
-                table2.Cell(9, 2).Range.Text = rpRecord.boxinxishu.ToString();
-                try
-                {
-                    double hbp = rpRecord.boxinxishu;
-                    if (hbp > 0.4)
-                    {
-                        table2.Cell(9, 3).Range.Text = "↑";
-                    }
-                    else if (hbp < 0.33)
-                    {
-                        table2.Cell(9, 3).Range.Text = "↓";
-                    }
-                    else
-                    {
-                    }
-                }
-                catch (Exception)
-                {
-
-                }
-                table2.Cell(9, 4).Range.Text = "0.33-0.4";
-
-                table2.Cell(10, 1).Range.Text = "体重指数WI:";
-                table2.Cell(10, 2).Range.Text = rpRecord.tizhongzhishu.ToString();
-                try
-                {
-                    double hbp = rpRecord.tizhongzhishu;
-                    if (hbp > 0.24)
-                    {
-                        table2.Cell(10, 3).Range.Text = "↑";
-                    }
-                    else
-                    {
-                    }
-                }
-                catch (Exception)
-                {
-                }
-                table2.Cell(10, 4).Range.Text = "<0.24";
-
-                table2.Cell(11, 1).Range.Text = "心输出量CO:";
-                table2.Cell(11, 2).Range.Text = rpRecord.xinshuchuliang.ToString();
-                try
-                {
-                    double hbp = rpRecord.xinshuchuliang;
-                    if (hbp > 7)
-                    {
-                        table2.Cell(11, 3).Range.Text = "↑";
-                    }
-                    else if (hbp < 3)
-                    {
-                        table2.Cell(11, 3).Range.Text = "↓";
-                    }
-                    else
-                    {
-                    }
-                }
-                catch (Exception)
-                {
-                }
-                table2.Cell(11, 4).Range.Text = "3-7L/min";
-
-                table2.Cell(12, 1).Range.Text = "外周阻力TPR:";
-                table2.Cell(12, 2).Range.Text = rpRecord.waizhouzuli.ToString();
-                try
-                {
-                    double hbp = rpRecord.waizhouzuli;
-                    if (hbp > 1.4)
-                    {
-                        table2.Cell(12, 3).Range.Text = "↑";
-                    }
-                    else if (hbp < 0.9)
-                    {
-                        table2.Cell(12, 3).Range.Text = "↓";
-                    }
-                    else
-                    {
-                    }
-                }
-                catch (Exception)
-                {
-                }
-                table2.Cell(12, 4).Range.Text = "0.9-1.4PRU";
-
-                table2.Cell(13, 1).Range.Text = "每搏量SV:";
-                table2.Cell(13, 2).Range.Text = rpRecord.meiboliang.ToString();
-                try
-                {
-                    double hbp = rpRecord.meiboliang;
-                    if (hbp > 100)
-                    {
-                        table2.Cell(13, 3).Range.Text = "↑";
-                    }
-                    else if (hbp < 60)
-                    {
-                        table2.Cell(13, 3).Range.Text = "↓";
-                    }
-                    else
-                    {
-                    }
-                }
-                catch (Exception)
-                {
-                }
-                table2.Cell(13, 4).Range.Text = "60-100ml";
-
-                table2.Cell(14, 1).Range.Text = "心脏指数CI:";
-                table2.Cell(14, 2).Range.Text = rpRecord.xinzangzhishu.ToString();
-                try
-                {
-                    double hbp = rpRecord.xinzangzhishu;
-                    if (hbp > 4)
-                    {
-                        table2.Cell(14, 3).Range.Text = "↑";
-                    }
-                    else if (hbp < 2.5)
-                    {
-                        table2.Cell(14, 3).Range.Text = "↓";
-                    }
-                    else
-                    {
-                    }
-                }
-                catch (Exception)
-                {
-                }
-                table2.Cell(14, 4).Range.Text = "2.5-4";
-
-                table2.Cell(15, 1).Range.Text = "心搏指数SI:";
-                table2.Cell(15, 2).Range.Text = rpRecord.xinbozhishu.ToString();
-                try
-                {
-                    double hbp = rpRecord.xinbozhishu;
-                    if (hbp > 60)
-                    {
-                        table2.Cell(15, 3).Range.Text = "↑";
-                    }
-                    else if (hbp < 40)
-                    {
-                        table2.Cell(15, 3).Range.Text = "↓";
-                    }
-                    else
-                    {
-                    }
-                }
-                catch (Exception)
-                {
-                }
-                table2.Cell(15, 4).Range.Text = "40-60ml/m*m";
-
-                table2.Cell(16, 1).Range.Text = "顺应性AC:";
-                table2.Cell(16, 2).Range.Text = rpRecord.shunyinxing.ToString();
-                try
-                {
-                    double hbp = rpRecord.shunyinxing;
-                    if (hbp > 2)
-                    {
-                        table2.Cell(16, 3).Range.Text = "↑";
-                    }
-                    else if (hbp < 1.2)
-                    {
-                        table2.Cell(16, 3).Range.Text = "↓";
-                    }
-                    else
-                    {
-                    }
-                }
-                catch (Exception)
-                {
-                }
-                table2.Cell(16, 4).Range.Text = "1.2-2ml/mmHg";
-
-                table2.Cell(17, 1).Range.Text = "心率HR:";
-                table2.Cell(17, 2).Range.Text = "";
-                table2.Cell(17, 4).Range.Text = "bpm";
-
-                table2.Cell(18, 1).Range.Text = "中心血流量CBF:";
-                table2.Cell(18, 2).Range.Text = rpRecord.zhongxinxueliuliang.ToString();
-
-                table2.Cell(19, 1).Range.Text = "血液黏度V:";
-                table2.Cell(19, 2).Range.Text = rpRecord.xueyeniandu.ToString();
-                try
-                {
-                    double hbp = rpRecord.xueyeniandu;
-                    if (hbp > 4.5)
-                    {
-                        table2.Cell(19, 3).Range.Text = "↑";
-                    }
-                    else if (hbp < 3.8)
-                    {
-                        table2.Cell(16, 3).Range.Text = "↓";
-                    }
-                    else
-                    {
-                    }
-                }
-                catch (Exception)
-                {
-                }
-                table2.Cell(19, 4).Range.Text = "3.8-4.5CP";
-
-                table2.Cell(20, 1).Range.Text = "平均滞留时间T:";
-                table2.Cell(20, 2).Range.Text = rpRecord.pingjunzhiliushijian.ToString();
-                try
-                {
-                    double hbp = rpRecord.pingjunzhiliushijian;
-                    if (hbp > 33)
-                    {
-                        table2.Cell(20, 3).Range.Text = "↑";
-                    }
-                    else if (hbp < 20)
-                    {
-                        table2.Cell(20, 3).Range.Text = "↓";
-                    }
-                    else
-                    {
-                    }
-                }
-                catch (Exception)
-                {
-                }
-                table2.Cell(20, 4).Range.Text = "20-33s";
-                //21项开始自动生成
-                int startIdx = 21;
-                /*
-                for (int i = 0; i < expressions.Count && i + startIdx < 41; ++i)
-                {
-                    SQLite.Expression oneExpression = SQLite.SQLiteModel.getExpressionByContent(expressions.ElementAt(i).Key);
-                    table2.Cell(i + startIdx, 1).Range.Text = oneExpression.expression_description;
-                    if (expressions.ElementAt(i).Value == Double.MinValue)
-                    {
-                        table2.Cell(i + startIdx, 2).Range.Text = "--";
-                        continue;
-                    }
-                    table2.Cell(i + startIdx, 2).Range.Text = expressions.ElementAt(i).Value.ToString();
-
-                    if (expressions.ElementAt(i).Value > oneExpression.upBound)
-                    {
-                        table2.Cell(i + startIdx, 3).Range.Text = "↑";
-                    }
-                    else if (expressions.ElementAt(i).Value < (oneExpression.upBound))
-                    {
-                        table2.Cell(i + startIdx, 3).Range.Text = "↓";
-                    }
-                    table2.Cell(i + startIdx, 4).Range.Text = oneExpression.downBound.ToString() + "-" + oneExpression.upBound.ToString();
-                }*/
-
-                //诊断部分
-                string pailiangRemark = "";
-                string zuliRemark = "";
-                if (rpRecord.xpl < 4)
-                {
-                    pailiangRemark = "低排";
-                }
-                else if(rpRecord.xpl > 5)
-                {
-                    pailiangRemark = "高排";
-                }
-                else
-                {
-                    pailiangRemark = "中排";
-                }
-                if (rpRecord.wzzl < 4)
-                {
-                    zuliRemark = "低阻";
-                }
-                else if (rpRecord.wzzl > 5)
-                {
-                    zuliRemark = "高阻";
-                }
-                else
-                {
-                    zuliRemark = "中阻";
-                }
-                table2.Cell(2, 5).Range.Text = "自动分析结果:\n"
-                    + "一、参考结果\n"
-                    + rpRecord.cankaojieguo + "\n"
-                    + "二、参考指数\n"
-                    + "排量:" + rpRecord.xpl.ToString() + "(" + pailiangRemark + ")\n阻力:" + rpRecord.wzzl.ToString() + "(" + zuliRemark + ")\n"
-                    + "三、脉搏波形\n" + rcd.r_type + "\n"
-                    + "四、医师建议" + "\n风险等级:" + generalExpressionResult + "\n";// + mw.textBoxDiagnosis.Text;
-                table2.Cell(2, 5).Range.Font.Size = 15;
-
-                //自动分析结果
-                /*
-                oPara1.Range.Text = "______________________________________________________________________________________________________________";
-                oPara1.Range.Font.Bold = fontBold;
-                oPara1.Range.InsertParagraphAfter();
-                */
-
-                //插入分页符
-                object oPageBreak = Microsoft.Office.Interop.Word.WdBreakType.wdPageBreak;
-
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                WordDoc.ActiveWindow.Selection.InsertBreak(ref oPageBreak);
-
-                //图片页
-                //图片1
-                WordApp.Selection.ParagraphFormat.FirstLineIndent = 80;
-                oPara1.Range.Text = "\n桡动脉波形图:";
-                oPara1.Range.Font.Bold = 0;
-                oPara1.Range.Font.Size = 15;
-                oPara1.Format.SpaceAfter = space;
-                oPara1.Range.InsertParagraphAfter();
-
-
-                //插图
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                WordApp.Selection.ParagraphFormat.FirstLineIndent = 0;
-                string picture1 = Constants.tmpRPWave;
-                //定义要向文档中插入图片的位置
-                object range = WordDoc.Paragraphs.Last.Range;
-                //定义该图片是否为外部链接
-                object linkToFile = false;//默认
-                //定义插入的图片是否随word一起保存
-                object saveWithDocument = true;
-                //向word中写入图片
-                try
-                {
-                    WordDoc.InlineShapes.AddPicture(picture1, ref oMissing, ref oMissing, ref oMissing);
-                }
-                catch (Exception)
-                {
-                    Console.WriteLine("fail to load raodongmai.");
-                }
-
-                WordApp.Selection.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;//居中显示图片
-                WordDoc.InlineShapes[1].Height = 130;
-                WordDoc.InlineShapes[1].Width = 490;
-                //WordDoc.Content.InsertAfter("\n");
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
-                WordApp.Selection.Font.Size = 10;//字体大小
-                WordApp.Selection.TypeText("右侧桡动脉\n");
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                oPara1.Range.Text = "____________________________________________________________________________________________";
-                oPara1.Range.Font.Bold = 0;
-                oPara1.Range.Font.Size = 10;
-                oPara1.Range.InsertParagraphAfter();
-
-
-                //图片2.3
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;
-                WordApp.Selection.ParagraphFormat.FirstLineIndent = 80;
-                oPara1.Range.Text = cfg.report_figure_name + ":";
-                oPara1.Range.Font.Bold = 0;
-                oPara1.Range.Font.Size = 15;
-                oPara1.Format.SpaceAfter = space;
-                oPara1.Format.SpaceBefore = 0;
-                oPara1.Range.InsertParagraphAfter();
-
-
-                //插图
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                WordApp.Selection.ParagraphFormat.FirstLineIndent = 0;
-                string picture2 = Constants.tmpPPGLeftInfraredWave;
-                string picture3 = Constants.tmpPPGLeftRedWave;
-                string picture4 = Constants.tmpPPGRightRedWave;
-                string picture5 = Constants.tmpPPGRightInfraredWave;
-                //向word中写入图片
-                try
-                {
-                    WordDoc.InlineShapes.AddPicture(picture2, ref oMissing, ref oMissing, ref oMissing);
-                    WordDoc.InlineShapes.AddPicture(picture3, ref oMissing, ref oMissing, ref oMissing);
-                    WordDoc.InlineShapes.AddPicture(picture4, ref oMissing, ref oMissing, ref oMissing);
-                    WordDoc.InlineShapes.AddPicture(picture5, ref oMissing, ref oMissing, ref oMissing);
-
-                }
-                catch (Exception)
-                {
-                    Console.WriteLine("fail to load a image.");
-                }
-
-                WordApp.Selection.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;//居中显示图片
-                for(int i = 2; i < 6; ++i)
-                {
-                    WordDoc.InlineShapes[i].Height = 80;
-                    WordDoc.InlineShapes[i].Width = 200;
-                }
-                
-                //WordDoc.Content.InsertAfter("\n");
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
-                WordApp.Selection.Font.Size = 10;//字体大小
-                WordApp.Selection.TypeText("左手手指 红外光\n");
-                //左手红光
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                WordApp.Selection.ParagraphFormat.FirstLineIndent = 0;
-                /*
-                try
-                {
-                    WordDoc.InlineShapes.AddPicture(picture3, ref oMissing, ref oMissing, ref oMissing);
-
-                }
-                catch (Exception)
-                {
-                    Console.WriteLine("fail to load ppg Left2.");
-                }
-                WordApp.Selection.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;//居中显示图片
-                WordDoc.InlineShapes[3].Height = 100;
-                WordDoc.InlineShapes[3].Width = 245;
-                //WordDoc.Content.InsertAfter("\n");
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
-                WordApp.Selection.Font.Size = 10;//字体大小
-                WordApp.Selection.TypeText("左手手指 红光\n");
-                //右手红外光
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                WordApp.Selection.ParagraphFormat.FirstLineIndent = 0;
-               
-                //向word中写入图片
-                try
-                {
-                    WordDoc.InlineShapes.AddPicture(picture4, ref oMissing, ref oMissing, ref oMissing);
-
-                }
-                catch (Exception)
-                {
-                    Console.WriteLine("fail to load ppg right1.");
-                }
-
-                WordApp.Selection.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;//居中显示图片
-                WordDoc.InlineShapes[4].Height = 130;
-                WordDoc.InlineShapes[4].Width = 490;
-                //WordDoc.Content.InsertAfter("\n");
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
-                WordApp.Selection.Font.Size = 10;//字体大小
-                WordApp.Selection.TypeText("右手手指 红外光\n");
-                //右手红外光
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                WordApp.Selection.ParagraphFormat.FirstLineIndent = 0;
-                
-                //向word中写入图片
-                try
-                {
-                    WordDoc.InlineShapes.AddPicture(picture5, ref oMissing, ref oMissing, ref oMissing);
-
-                }
-                catch (Exception)
-                {
-                    Console.WriteLine("fail to load ppg right1.");
-                }
-
-                WordApp.Selection.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;//居中显示图片
-                WordDoc.InlineShapes[5].Height = 130;
-                WordDoc.InlineShapes[5].Width = 490;
-                //WordDoc.Content.InsertAfter("\n");
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
-                WordApp.Selection.Font.Size = 10;//字体大小
-                WordApp.Selection.TypeText("右手手指 红光\n");
-                */
-                //插入分页符
-                //object oPageBreak = Microsoft.Office.Interop.Word.WdBreakType.wdPageBreak;
-                //WordApp.Selection.EndKey(ref unite, ref oMissing);
-                // WordDoc.ActiveWindow.Selection.InsertBreak(ref oPageBreak);
-
-
-                //第三页
-                /*
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;
-                WordApp.Selection.ParagraphFormat.FirstLineIndent = 80;
-                oPara1.Range.Text = "趋势图:";
-                oPara1.Range.Font.Bold = 0;
-                oPara1.Range.Font.Size = 15;
-                oPara1.Format.SpaceBefore = space;
-                oPara1.Format.SpaceAfter = space;
-                oPara1.Range.InsertParagraphAfter();
-
-
-                //插图
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                WordApp.Selection.ParagraphFormat.FirstLineIndent = 0;
-                string picture4 = "c:\\picture\\raodongmai.png";
-                //定义要向文档中插入图片的位置
-                //向word中写入图片
-                WordDoc.InlineShapes.AddPicture(picture4, ref oMissing, ref oMissing, ref oMissing);
-
-                WordApp.Selection.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;//居中显示图片
-                WordDoc.InlineShapes[4].Height = 130;
-                WordDoc.InlineShapes[4].Width = 490;
-                //WordDoc.Content.InsertAfter("\n");
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
-                WordApp.Selection.Font.Size = 10;//字体大小
-                WordApp.Selection.TypeText("IPR 右侧桡动脉\n");
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                oPara1.Range.Text = "________________________________________________________________________________________________________________";
-                oPara1.Range.Font.Bold = 0;
-                oPara1.Range.Font.Size = 10;
-                oPara1.Format.SpaceAfter = 0;
-                oPara1.Range.InsertParagraphAfter();
-
-
-                //图片2.3
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;
-                WordApp.Selection.ParagraphFormat.FirstLineIndent = 80;
-                oPara1.Range.Text = "趋势图:";
-                oPara1.Range.Font.Bold = 0;
-                oPara1.Range.Font.Size = 15;
-                oPara1.Format.SpaceAfter = space;
-                oPara1.Range.InsertParagraphAfter();
-
-
-                //插图
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                WordApp.Selection.ParagraphFormat.FirstLineIndent = 0;
-                string picture5 = "c:\\picture\\2.png";
-                //向word中写入图片
-                WordDoc.InlineShapes.AddPicture(picture5, ref oMissing, ref oMissing, ref oMissing);
-
-                WordApp.Selection.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;//居中显示图片
-                WordDoc.InlineShapes[5].Height = 130;
-                WordDoc.InlineShapes[5].Width = 490;
-                //WordDoc.Content.InsertAfter("\n");
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
-                WordApp.Selection.Font.Size = 10;//字体大小
-                WordApp.Selection.TypeText("RI 左手手指 红外光\n");
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                WordApp.Selection.ParagraphFormat.FirstLineIndent = 0;
-                string picture6 = "c:\\picture\\3.png";
-                //向word中写入图片
-                WordDoc.InlineShapes.AddPicture(picture6, ref oMissing, ref oMissing, ref oMissing);
-
-                WordApp.Selection.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;//居中显示图片
-                WordDoc.InlineShapes[6].Height = 130;
-                WordDoc.InlineShapes[6].Width = 490;
-                //WordDoc.Content.InsertAfter("\n");
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
-                WordApp.Selection.Font.Size = 10;//字体大小
-                WordApp.Selection.TypeText("RI 右手手指 红外光\n");
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                //*/
-                oPara1.Range.Text = "____________________________________________________________________________________________";
-                oPara1.Range.Font.Bold = 0;
-                oPara1.Range.Font.Size = 10;
-                oPara1.Format.SpaceBefore = 0;
-                oPara1.Format.SpaceAfter = 0;
-                oPara1.Range.InsertParagraphAfter();
-                //医师签名
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;
-                WordApp.Selection.ParagraphFormat.FirstLineIndent = 150;
-                oPara1.Range.Text = "检查医师:" + doct.name + "   医师签名:";
-                oPara1.Range.Font.Bold = 0;
-                oPara1.Range.Font.Size = 15;
-                oPara1.Format.SpaceAfter = 0;
-                oPara1.Format.SpaceBefore = 0;
-                oPara1.Range.InsertParagraphAfter();
-
-
-                //   object LinkToFile = false;
-                object SaveWithDocument = true;
-                //   object Anchor = WordDoc.Application.Selection.Range;
-                /*
-                WordApp.Selection.MoveDown(ref WdLine, ref count, ref oMissing);//移动焦点
-                WordDoc.Application.ActiveDocument.InlineShapes.AddPicture(picName4, ref LinkToFile, ref SaveWithDocument, ref Anchor);
-                WordApp.Selection.MoveDown(ref WdLine, ref count, ref oMissing);//移动焦点
-                WordDoc.Application.ActiveDocument.InlineShapes.AddPicture(picName3, ref LinkToFile, ref SaveWithDocument, ref Anchor);
-                WordApp.Selection.MoveDown(ref WdLine, ref count, ref oMissing);//移动焦点
-                WordDoc.Application.ActiveDocument.InlineShapes.AddPicture(picName2, ref LinkToFile, ref SaveWithDocument, ref Anchor);
-                WordApp.Selection.MoveDown(ref WdLine, ref count, ref oMissing);//移动焦点
-                WordDoc.Application.ActiveDocument.InlineShapes.AddPicture(picName1, ref LinkToFile, ref SaveWithDocument, ref Anchor);
-                WordApp.Selection.MoveDown(ref WdLine, ref count, ref oMissing);//移动焦点
-                WordDoc.Application.ActiveDocument.InlineShapes.AddPicture(picName0, ref LinkToFile, ref SaveWithDocument, ref Anchor);
-                */
-                //保存
-                WordDoc.Save();
-                WordDoc.ExportAsFixedFormat(pdfFileName, Microsoft.Office.Interop.Word.WdExportFormat.wdExportFormatPDF, true);
-                
-
-            }
-            catch (Exception e)
-            {
-                Console.WriteLine(e.Message);
-                Console.WriteLine(e.StackTrace);
-                
-            }
-            finally
-            {
-                //try
-                //{
-                    WordDoc.Close(ref oMissing, ref oMissing, ref oMissing);
-                    WordApp.Quit(ref oMissing, ref oMissing, ref oMissing);
-                //}
-                //catch (Exception)
-                //{
-
-                //}
-               
-                try
-                {
-                    File.Delete(fileName);
-                }
-                catch (Exception)
-                {
-                    ;
-                }
-            }
-
-
-        }
-    }
-}

+ 0 - 247
WpfTest1/Toolkits/SocketListener.cs

@@ -1,247 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Net;
-using System.Net.Sockets;
-
-
-namespace WpfTest1.Toolkits
-{
-    class SocketListener
-    {
-        private static string ip = Constants.UptterIp;
-        private static int myPort = Constants.UpperPort;
-
-        static void test()
-        {
-            List<int> leftList1 = new List<int>();
-            List<int> leftList2 = new List<int>();
-            List<int> rightList1 = new List<int>();
-            List<int> rightList2 = new List<int>();
-            Console.WriteLine(getTcpData(leftList1, leftList2, rightList1, rightList2, 0.01));
-            Console.Write("1\n");
-            foreach (int i in leftList1)
-            {
-                Console.Write(i);
-                Console.Write(" ");
-            }
-            Console.Write("2\n");
-            foreach (int i in leftList2)
-            {
-                Console.Write(i);
-                Console.Write(" ");
-            }
-            Console.Write("3\n");
-            foreach (int i in rightList1)
-            {
-                Console.Write(i);
-                Console.Write(" ");
-            }
-            Console.Write("4\n");
-            foreach (int i in rightList2)
-            {
-                Console.Write(i);
-                Console.Write(" ");
-            }
-            Console.Write("5\n");
-        }
-
-        /// <summary>
-        /// 服务器端获取下位机数据包的方法
-        /// </summary>
-        /// 
-        static bool getTcpData(List<int> leftList1, List<int> leftList2, List<int> rightList1, List<int> rightList2, double minutes)
-        {
-            try
-            {
-                //1.监听端口
-                TcpListener server = new TcpListener(IPAddress.Parse(ip), myPort);
-                server.Start();
-                Console.WriteLine("{0:HH:mm:ss}->监听端口{1}...", DateTime.Now, myPort);
-
-                //2.等待请求
-                try
-                {
-                    Console.WriteLine("开始数据的传输!");
-                    //2.1 收到请求
-                    TcpClient client = server.AcceptTcpClient(); //停在这等待连接请求
-                    IPEndPoint ipendpoint = client.Client.RemoteEndPoint as IPEndPoint;
-                    NetworkStream stream = client.GetStream();
-
-                    int iterNo = 0;
-                    DateTime startTime = new DateTime();
-                    DateTime nowTime = new DateTime();
-                    bool checkedFlag = false;
-
-                    while (true)
-                    {
-                        if (iterNo == 0)
-                        {
-                            startTime = DateTime.Now;
-                        }
-                        nowTime = DateTime.Now;
-                        //Console.Write((nowTime - startTime).TotalMinutes);
-                        //Console.Write("\n");
-                        if ((nowTime - startTime).TotalMinutes > minutes)
-                        {
-                            break;
-                        }
-
-                        //2.2 解析数据,长度<1024字节
-                        string data = string.Empty;
-                        byte[] bytes = new byte[1024];
-                        int length = 0;
-                        int exceptionCount = 0;
-                        bool trueFlag = false;
-                        while (true)
-                        {
-                            if (trueFlag)
-                            {
-                                break;
-                            }
-                            if (exceptionCount == 3)
-                            {
-                                return false;
-                            }
-                            try
-                            {
-                                length = stream.Read(bytes, 0, bytes.Length);
-                                trueFlag = true;
-                            }
-                            catch (Exception ex)
-                            {
-                                Console.WriteLine("{0:HH:mm:ss}->{1}", DateTime.Now, ex.Message);
-                                exceptionCount += 1;
-                            }
-                        }
-                        //int length = stream.Read(bytes, 0, bytes.Length);
-                        //Console.Write(length);
-                        //Console.Write("\n");
-                        //Console.Write(bytes.Length);
-                        //Console.Write("\n");
-                        for (int i = 0; i < bytes.Length; i++)
-                        {
-                            Console.Write(bytes[i]);
-                            Console.Write(" ");
-                        }
-                        // 签到报文、如果刚开始没有签到报文,则返回false
-                        if (bytes[0] == 2 && bytes[1] == 0 && bytes[2] == 0 && bytes[3] == 0 && bytes[4] == 0 && bytes[5] == 200 && checkedFlag)
-                        {
-                            continue;
-                        }
-                        if (checkedFlag == false)
-                        {
-                            if (bytes[0] == 2 && bytes[1] == 0 && bytes[2] == 0 && bytes[3] == 0 && bytes[4] == 0 && bytes[5] == 200)
-                            {
-                                checkedFlag = true;
-                            }
-                            else
-                            {
-                                break;
-                                //return false;
-                            }
-                        }
-
-                        // 数据报文
-                        if (bytes[0] == 2 && bytes[1] == 0 && bytes[2] == 0 && bytes[3] == 0 && bytes[4] == 0 && bytes[5] == 23)
-                        {
-                            // 校检
-                            int sum = 0;
-                            for (int i = 0; i < length - 2; i++)
-                            {
-                                sum += bytes[i];
-                            }
-                            String sum_ = Convert.ToString(sum, 16);
-                            int sumLength = sum_.Length;
-                            //Console.Write(sumLength);
-                            sum_ = sum_.Substring(sumLength - 2, 2);
-                            String checkString = Convert.ToString(bytes[length - 1], 16);
-                            if (checkString.Length == 1)
-                            {
-                                checkString = "0" + checkString;
-                            }
-                            if (sum_ != checkString)
-                            {
-                                Console.Write("校检失败!");
-                                continue;
-                            }
-                            String c1 = Convert.ToString(bytes[10], 16);
-                            String c2 = Convert.ToString(bytes[11], 16);
-                            int dataLength = Convert.ToInt32(c1 + c2, 16);
-                            byte[] data_ = bytes.Skip(12).Take(dataLength).ToArray();
-                            if (bytes[9] == 1)
-                            {
-                                //表示右手
-                                for (int i = 0; i < data_.Length / 16; i++)
-                                {
-                                    String d1 = ""; //红光
-                                    foreach (byte b in data_.Skip(i * 16 + 2).Take(3).ToArray())
-                                    {
-                                        d1 += Convert.ToString(b, 16);
-                                    }
-                                    String d2 = "";//红外光
-                                    foreach (byte b in data_.Skip(i * 16 + 9).Take(3).ToArray())
-                                    {
-                                        d2 += Convert.ToString(b, 16);
-                                    }
-                                    rightList1.Add(Convert.ToInt32(d1, 16));
-                                    rightList2.Add(Convert.ToInt32(d2, 16));
-                                }
-                            }
-                            if (bytes[9] == 0)
-                            {
-                                //表示左手
-                                for (int i = 0; i < data_.Length / 16; i++)
-                                {
-                                    String d1 = ""; //红光
-                                    foreach (byte b in data_.Skip(i * 16 + 2).Take(3).ToArray())
-                                    {
-                                        d1 += Convert.ToString(b, 16);
-                                    }
-                                    String d2 = "";//红外光
-                                    foreach (byte b in data_.Skip(i * 16 + 9).Take(3).ToArray())
-                                    {
-                                        d2 += Convert.ToString(b, 16);
-                                    }
-                                    leftList1.Add(Convert.ToInt32(d1, 16));
-                                    leftList2.Add(Convert.ToInt32(d2, 16));
-                                }
-                            }
-                        }
-
-                        Console.WriteLine();
-                        Console.WriteLine(length);
-                        iterNo += 1;
-                    }
-
-                    stream.Close();
-                    client.Close();
-                }
-                catch (Exception ex)
-                {
-                    Console.WriteLine(ex);
-                    Console.WriteLine("传输出现问题1!");
-                    Console.WriteLine("{0:HH:mm:ss}->{1}", DateTime.Now, ex.Message);
-                }
-
-            }
-            catch (SocketException socketEx)
-            {
-                Console.WriteLine("传输出现问题2!");
-                //10013 The requested address is a broadcast address, but flag is not set.
-                if (socketEx.ErrorCode == 10013)
-                    Console.WriteLine("{0:HH:mm:ss}->启动失败,请检查{1}端口有无其他程序占用.", DateTime.Now, myPort);
-                else
-                    Console.WriteLine("{0:HH:mm:ss}->{1}", DateTime.Now, socketEx.Message);
-            }
-            catch (Exception ex)
-            {
-                Console.WriteLine("传输出现问题3!");
-                Console.WriteLine("{0:HH:mm:ss}->{1}", DateTime.Now, ex.Message);
-            }
-            return true;
-        }
-    }
-}

+ 0 - 238
WpfTest1/Toolkits/WaveHandle.cs

@@ -1,238 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using ZedGraph;
-
-namespace WpfTest1.Toolkits
-{
-    //本类是处理波的相关工具方法集
-    public class WaveHandle
-    {
-        //由原始字节流转换为数字数组的方法
-        public static int generateWaveData(byte[] orginalData,List<double> red , List<double> infrared)
-        {
-            red.Clear();
-            infrared.Clear();
-            if (orginalData == null)
-            {
-                return 0;
-            }
-            ///*
-            for (int i = 0; i < orginalData.Length; i += 6)
-            {
-                int v1 = (orginalData[i] << 16) | orginalData[i + 1] << 8 | orginalData[i + 2];
-                int v2 = (orginalData[i + 3] << 16) | orginalData[i + 4] << 8 | orginalData[i + 5];
-                red.Add((double)v1);
-                infrared.Add((double)v2);
-            }
-            //*/
-            /*
-            for (int i = 0; i < orginalData.Length; i += 4)
-            {
-                int v1 = (orginalData[i] << 8) | orginalData[i + 1];
-                int v2 = (orginalData[i + 2] << 8) | orginalData[i + 3];
-                red.Add((double)v1);
-                infrared.Add((double)v2);
-            }
-            */
-            return orginalData.Length;
-        }
-        //由数字数组转换为原始字节流的方法
-        public static int zipToWaveByte(byte[] orginalData, List<double> red, List<double> infrared, int measureStartIndex)
-        {
-            int count = red.Count <= infrared.Count ? red.Count : infrared.Count;
-            int j = 0;
-            for (int i = measureStartIndex; i < count; ++i)
-            {
-                Int32 tempIntRed = Convert.ToInt32(red[i] * Toolkits.Constants.zoomTimes);
-                byte[] tempBytesRed = BitConverter.GetBytes(tempIntRed);
-                Int32 tempIntInfrared = Convert.ToInt32(infrared[i] * Toolkits.Constants.zoomTimes);
-                byte[] tempBytesInfrared = BitConverter.GetBytes(tempIntInfrared);
-                orginalData[j * 6] = tempBytesRed[2];
-                orginalData[j * 6 + 1] = tempBytesRed[1];
-                orginalData[j * 6 + 2] = tempBytesRed[0];
-                orginalData[j * 6 + 3] = tempBytesInfrared[2];
-                orginalData[j * 6 + 4] = tempBytesInfrared[1];
-                orginalData[j * 6 + 5] = tempBytesInfrared[0];
-                ++j;
-            }
-            return orginalData.Length;
-        }
-
-        //由原始字节流转换为RP数字数组的方法
-        public static int generateRPWaveData(byte[] orginalData, List<int> target)
-        {
-            target.Clear();
-            if (orginalData == null)
-            {
-                return 0;
-            }
-            for (int i = 0; i < orginalData.Length; i += 4)
-            {
-                double v1 = (orginalData[i] << 8) | orginalData[i + 1];
-                target.Add(Convert.ToInt32(v1));
-            }
-            return orginalData.Length;
-        }
-
-        //平滑数据方法,平滑点数smoothpoints从配置中选取,smoothTimes是平滑次数
-        public static void smoothList(List<double> points,int smoothpoints,int smoothTimes = 1)
-        {
-            if(smoothpoints > points.Count)
-            {
-                return;
-            }
-            
-            ///*
-            for (int i = 0; i < smoothTimes; ++i)
-            {
-                //此处算法应为,取前n/2的点和后n/2的点进行平滑
-                int smooth_radius = smoothpoints / 2;
-                for (int j = smooth_radius; j < points.Count - smooth_radius; ++j)
-                {
-                    double temp = 0;
-                    for (int k = -smooth_radius; k <= smooth_radius; ++k)
-                    {
-                        temp += points[j + k];
-                    }
-                    points[j] = temp / smoothpoints;
-                }
-                //之后平滑最初和最后的几个点(如果不平滑那么显示会很丑)
-                double tempFinal = 0;
-                for (int j = 0; j< smooth_radius;++j)
-                {
-                    tempFinal += points[j];
-                }
-                for (int j = 0; j < smooth_radius; ++j)
-                {
-                    points[j] = points[smooth_radius];
-                }
-                tempFinal = 0;
-                for (int j = points.Count - smooth_radius; j < points.Count; ++j)
-                {
-                    tempFinal += points[j];
-                }
-                for (int j = points.Count - smooth_radius; j < points.Count; ++j)
-                {
-                    points[j] = points[points.Count - smooth_radius - 1];
-                }
-            }
-            //*/
-        }
-
-        //计算滤波的方法
-        public static void filterList(List<double> source)
-        {
-            if (source.Count <= 0)
-            {
-                return;
-            }
-            //先读滤波数
-            List<double>[] filter = new List<double>[4];
-            for(int i = 0; i < filter.Length; ++i)
-            {
-                filter[i] = new List<double>();
-            }
-            int status = Toolkits.FilterFile.ReadFilterFiles(filter);
-            if (status < 0)
-            {
-                System.Console.WriteLine("滤波器文件文件内容已损坏");
-                return;
-            }
-            //然后开始滤波
-            for(int p=0;p< filter.Length; ++p)
-            {
-                for (int i = 0; i <= source.Count - filter[p].Count; ++i)
-                {
-                    double temp = 0;
-                    for (int j = 0; j < filter[p].Count; ++j)
-                    {
-                        temp += (filter[p][j] * source[i + j]);
-                    }
-                    source[i] = temp;
-                }
-                source.RemoveRange(source.Count - filter[p].Count + 1, filter[p].Count - 1);    //记得删除之后不要的点
-            }
-        }
-
-        //计算List导数方法,即后项减前项计算梯度
-        public static void deriveList(List<double> points,List<double> target)
-        {
-            target.Clear();
-            for(int i = 0; i < points.Count - 1; ++i)
-            {
-                //target.Add(points[i + 1] - points[i]);
-                target.Add((points[i + 1] - points[i])/Toolkits.Constants.sampleInterval);
-                //为保证数组长度一致最后补一个点
-                if(i == points.Count - 2)
-                {
-                    target.Add((points[i + 1] - points[i]) / Toolkits.Constants.sampleInterval);
-                    //target.Add(points[i + 1] - points[i]);
-                }
-            }
-        }
-
-        //给一个波,计算某一点之前或者之后的波谷的x坐标,如不存在则返回-1
-        //注意,rightFlag为true时向右找,否则向左找
-        public static int FindTrough(List<double> data, List<double> driveData, int x, bool rightFlag)
-        {
-            double waveMean = data.Average();
-            for (int i = x; i > 1 && i < driveData.Count - 1;)
-            {
-                if (driveData[i] * driveData[i + 1] <= 0 && driveData[i + 1] >= 0 && data[i] < 1 * waveMean)
-                {
-                    return i;
-                }
-                else
-                {
-                    if (rightFlag)//向右走
-                    {
-                        ++i;
-                    }
-                    else
-                    {
-                        --i;
-                    }
-
-                }
-            }
-            return -1;
-        }
-
-        //将一个波形规范化
-        public static PointPairList NormalizeWave(PointPairList target)
-        {
-            PointPairList result = new PointPairList();
-            int count = target.Count;
-            double max = double.MinValue;
-            for (int i = 0; i < count; i++)
-            {
-                if (target[i].Y > max)
-                {
-                    max = target[i].Y;
-                }
-                //target[i].Y -= target[0].Y;
-            }
-            for (int i = 0; i < count; i++)
-            {
-                double x = (double)i / ((double)count - 1);
-                double y = (target[i].Y - target[0].Y - ((target[count - 1].Y - target[0].Y) / (count - 1)) * i) / (max - target[0].Y);
-                //Console.WriteLine(x+";;;"+y);
-                //double y = target[0].Y + ((target[count - 1].Y - target[0].Y) / (count - 1)) * i;
-                //double result = (y);
-                result.Add(x, y);
-                //target[i].X = x;
-                //target[i].Y = y;
-            }
-            for (int i = 0; i < count; ++i)
-            {
-                target[i].X = result[i].X;
-                target[i].Y = result[i].Y;
-            }
-            return target;
-        }
-    }
-}

+ 0 - 81
WpfTest1/Toolkits/WaveSimulator.cs

@@ -1,81 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace WpfTest1.Toolkits
-{
-    class WaveSimulator
-    {
-        //产生模拟波形的方法
-        //generate a signal combining from 0-5 hz
-        //take amplitude and phase shift into account
-        public static List<double> getSimulatedWave()
-        {
-            double Fs = 100;           //Sampling frequency
-            double T = 1.0 / Fs;      //Sample time
-            int L = 1500;            //Length of signal
-            List<double> t = new List<double>();    //Time vector
-            for (int i = 0; i < L; ++i)
-            {
-                t.Add(i * T);
-                //System.Console.WriteLine("t[i]:" + t[i].ToString());
-            }
-            List<double> f = new List<double>();    //frequency
-            for (int i = 1; i < 6; ++i)
-            {
-                f.Add(i);
-            }
-
-            //phase
-            //int pstep = 0;
-            int count = f.Count();
-            //phase = 0:pstep:count * pstep;
-            List<double> phase = new List<double>();
-            for(int i = 0; i < count; ++i)
-            {
-                phase.Add(0);
-            }
-            //phase(2) = 0 / 180;
-            //phase(3) = 00 / 180;
-            //phase(4) = 0 / 180;
-            //phase(5) = 0 / 180;
-
-            //amplitude
-            List<double> amplitude = new List<double>();
-            for (int i = 0; i < count; ++i)
-            {
-                amplitude.Add(1);
-            }
-            for(int i = 2 - 1; i <= count - 1; ++i)
-            {
-                amplitude[i] = 0.9 * amplitude[i - 1];
-            }
-            amplitude[2-1] = 0.8;
-            amplitude[3-1] = 0.1;
-            amplitude[4-1] = 0.1;
-            amplitude[5-1] = 0.2;
-
-            List<double> y = new List<double>();
-            for (int i = 0; i < t.Count; ++i)
-            {
-                y.Add(0);
-            }
-
-            for(int j = 1 - 1; j <= t.Count - 1; ++j)
-            {
-                for(int i = 1 - 1; i <= count - 1; ++i)
-                {
-                    y[j] = y[j] + amplitude[i] * Math.Sin(2 * Math.PI * f[i] * t[j] + phase[i]);
-                    //System.Console.WriteLine("y[i]:"+ y[i].ToString());
-                }
-            }
-            for(int i = 0; i < y.Count; ++i)
-            {
-                y[i] = 1000 * y[i] + 2000;
-            }
-            return y;
-        }
-    }
-}

+ 7 - 7
WpfTest1/WpTest.csproj

@@ -189,6 +189,9 @@
     <Compile Include="PatientInfoShort.xaml.cs">
       <DependentUpon>PatientInfoShort.xaml</DependentUpon>
     </Compile>
+    <Compile Include="SmallDialogs\AboutBox.xaml.cs">
+      <DependentUpon>AboutBox.xaml</DependentUpon>
+    </Compile>
     <Compile Include="SmallDialogs\LoginWindow.xaml.cs">
       <DependentUpon>LoginWindow.xaml</DependentUpon>
     </Compile>
@@ -205,14 +208,7 @@
     <Compile Include="Exceptions\ExpressionCalculateExpression.cs" />
     <Compile Include="Exceptions\ExpressionFindFailedException.cs" />
     <Compile Include="Exceptions\ExpressionUnformattedException.cs" />
-    <Compile Include="Toolkits\FilterFile.cs" />
-    <Compile Include="Toolkits\MeasureHandle.cs" />
     <Compile Include="Toolkits\ReportGenerater.cs" />
-    <Compile Include="Toolkits\ReportGenerator_old.cs" />
-    <Compile Include="Toolkits\RPCalculate.cs" />
-    <Compile Include="Toolkits\SocketListener.cs" />
-    <Compile Include="Toolkits\WaveHandle.cs" />
-    <Compile Include="Toolkits\WaveSimulator.cs" />
     <Compile Include="SmallDialogs\AddDoctor.xaml.cs">
       <DependentUpon>AddDoctor.xaml</DependentUpon>
     </Compile>
@@ -251,6 +247,10 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="SmallDialogs\AboutBox.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="SmallDialogs\LoginWindow.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>