Преглед на файлове

+题目展示功能和报告功能完善

+题目展示功能支持图片和红色字体
+报告功能采用模板拼接
-移除部分没用的代码
ZhuYifan преди 5 години
родител
ревизия
0455bbf3f8
променени са 5 файла, в които са добавени 116 реда и са изтрити 29 реда
  1. 14 4
      WpfTest1/MainWindow.xaml
  2. 68 2
      WpfTest1/MainWindow.xaml.cs
  3. 1 1
      WpfTest1/SQLite/Run.cs
  4. 5 2
      WpfTest1/Toolkits/Constants.cs
  5. 28 20
      WpfTest1/Toolkits/ReportGenerater.cs

+ 14 - 4
WpfTest1/MainWindow.xaml

@@ -210,11 +210,16 @@
                             <Label x:Name="labelGong" Content="共" HorizontalAlignment="Left" Margin="90,10,0,0" VerticalAlignment="Top" FontSize="18"/>
                             <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="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"/>
                             <Label x:Name="labelTi" Content="题,当前第" HorizontalAlignment="Left" Margin="150,10,0,0" VerticalAlignment="Top" FontSize="18"/>
+                            <Label x:Name="labelFilterNameLabel" Content="当前病例:" HorizontalAlignment="Left" Margin="800,10,0,0" VerticalAlignment="Top" FontSize="18"/>
+                            <Label x:Name="labelFilterName" Content="[被试姓名]" HorizontalAlignment="Left" Margin="890,10,0,0" VerticalAlignment="Top" FontSize="18"/>
+                            <Label x:Name="labelFilterRecordidLabel" Content="病案号:" HorizontalAlignment="Left" Margin="1000,10,0,0" VerticalAlignment="Top" FontSize="18"/>
+                            <Label x:Name="labelFilterRecordid" Content="[病案编号233333333]" HorizontalAlignment="Left" Margin="1070,10,0,0" VerticalAlignment="Top" FontSize="18"/>
                             <Label x:Name="labelFilterNumberofCurrentQuestion" Content="XXX" HorizontalAlignment="Left" Margin="240,10,0,0" VerticalAlignment="Top" FontSize="18"/>
                             <Label x:Name="labelFilterNumberofCurrentQuestion" Content="XXX" HorizontalAlignment="Left" Margin="240,10,0,0" VerticalAlignment="Top" FontSize="18"/>
                             <Label x:Name="labelTi2" Content="题" HorizontalAlignment="Left" Margin="280,10,0,0" VerticalAlignment="Top" FontSize="18"/>
                             <Label x:Name="labelTi2" Content="题" HorizontalAlignment="Left" Margin="280,10,0,0" VerticalAlignment="Top" FontSize="18"/>
                             <Label x:Name="labelFilterQuestionTitle" Content="[问题的标题,大约需要30个汉字,所以空间需要够]" HorizontalAlignment="Left" Margin="90,36,0,0" VerticalAlignment="Top" FontSize="30"/>
                             <Label x:Name="labelFilterQuestionTitle" Content="[问题的标题,大约需要30个汉字,所以空间需要够]" HorizontalAlignment="Left" Margin="90,36,0,0" VerticalAlignment="Top" FontSize="30"/>
-                            <TextBlock x:Name="textBlockFilterQuetionContent" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="94,90,0,0" TextWrapping="Wrap" Text="Here is the question content." Height="200" Width="1150" FontSize="20"/>
-                            <Grid x:Name="gridFilterSelection" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="94,300,0,0" Width="1150" Height="200" ></Grid>
+                            <TextBlock x:Name="textBlockFilterQuetionContent" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="94,90,0,0" TextWrapping="Wrap" Text="Here is the question content." Height="240" Width="745" FontSize="18"/>
+                            <Image x:Name="imageFilterQuestion" HorizontalAlignment="Left" Width="348" Height="430" Margin="850,90,0,0" VerticalAlignment="Top" />
+                            <Grid x:Name="gridFilterSelection" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="94,340,0,0" Width="745" Height="200" ></Grid>
                             <Button x:Name="buttonFilterPrevious" Content="上一题" HorizontalAlignment="Left" Margin="424,550,0,0" VerticalAlignment="Top" Width="130" Height="50" FontSize="18" IsEnabled="False" Click="buttonFilterPrevious_Click" />
                             <Button x:Name="buttonFilterPrevious" Content="上一题" HorizontalAlignment="Left" Margin="424,550,0,0" VerticalAlignment="Top" Width="130" Height="50" FontSize="18" IsEnabled="False" Click="buttonFilterPrevious_Click" />
                             <Button x:Name="buttonFilterNext" Content="下一题" HorizontalAlignment="Left" Margin="784,550,0,0" VerticalAlignment="Top" Width="130" Height="50" FontSize="18" IsEnabled="False" Click="buttonFilterNext_Click" />
                             <Button x:Name="buttonFilterNext" Content="下一题" HorizontalAlignment="Left" Margin="784,550,0,0" VerticalAlignment="Top" Width="130" Height="50" FontSize="18" IsEnabled="False" Click="buttonFilterNext_Click" />
                             <Button x:Name="buttonSubmitFilter" Content="提交" HorizontalAlignment="Left" Margin="604,550,0,0" VerticalAlignment="Top" Width="130" Height="50" FontSize="18" Background="#FF317602" Foreground="White" IsEnabled="False" Click="buttonSubmitFilter_Click"/>
                             <Button x:Name="buttonSubmitFilter" Content="提交" HorizontalAlignment="Left" Margin="604,550,0,0" VerticalAlignment="Top" Width="130" Height="50" FontSize="18" Background="#FF317602" Foreground="White" IsEnabled="False" Click="buttonSubmitFilter_Click"/>
@@ -243,11 +248,16 @@
                     <TabItem  Header="评估流程" Style="{StaticResource smallerHeader}"  IsEnabled="False" >
                     <TabItem  Header="评估流程" Style="{StaticResource smallerHeader}"  IsEnabled="False" >
                         <Grid Background="White" Margin="0,0,0,0">
                         <Grid Background="White" Margin="0,0,0,0">
                             <Label x:Name="labelTiE" Content="当前第" HorizontalAlignment="Left" Margin="94,10,0,0" VerticalAlignment="Top" FontSize="18"/>
                             <Label x:Name="labelTiE" Content="当前第" HorizontalAlignment="Left" Margin="94,10,0,0" VerticalAlignment="Top" FontSize="18"/>
+                            <Label x:Name="labelEvaluationNameLabel" Content="当前病例:" HorizontalAlignment="Left" Margin="800,10,0,0" VerticalAlignment="Top" FontSize="18"/>
+                            <Label x:Name="labelEvaluationName" Content="[被试姓名]" HorizontalAlignment="Left" Margin="890,10,0,0" VerticalAlignment="Top" FontSize="18"/>
+                            <Label x:Name="labelEvaluationRecordidLabel" Content="病案号:" HorizontalAlignment="Left" Margin="1000,10,0,0" VerticalAlignment="Top" FontSize="18"/>
+                            <Label x:Name="labelEvaluationRecordid" Content="[病案编号233333333]" HorizontalAlignment="Left" Margin="1070,10,0,0" VerticalAlignment="Top" FontSize="18"/>
                             <Label x:Name="labelQuestionNumberofCurrentQuestion" Content="XXX" HorizontalAlignment="Left" Margin="150,10,0,0" VerticalAlignment="Top" FontSize="18"/>
                             <Label x:Name="labelQuestionNumberofCurrentQuestion" Content="XXX" HorizontalAlignment="Left" Margin="150,10,0,0" VerticalAlignment="Top" FontSize="18"/>
                             <Label x:Name="labelTi2E" Content="题" HorizontalAlignment="Left" Margin="190,10,0,0" VerticalAlignment="Top" FontSize="18"/>
                             <Label x:Name="labelTi2E" Content="题" HorizontalAlignment="Left" Margin="190,10,0,0" VerticalAlignment="Top" FontSize="18"/>
                             <Label x:Name="labelEvaluationQuestionTitle" Content="[问题的标题,大约需要30个汉字,所以空间需要够]" HorizontalAlignment="Left" Margin="90,36,0,0" VerticalAlignment="Top" FontSize="30"/>
                             <Label x:Name="labelEvaluationQuestionTitle" Content="[问题的标题,大约需要30个汉字,所以空间需要够]" HorizontalAlignment="Left" Margin="90,36,0,0" VerticalAlignment="Top" FontSize="30"/>
-                            <TextBlock x:Name="textBlockEvaluationQuetionContent" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="94,90,0,0" TextWrapping="Wrap" Text="Here is the question content." Height="200" Width="1150" FontSize="20"/>
-                            <Grid x:Name="gridEvaluationSelection" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="94,300,0,0" Width="1150" Height="200" ></Grid>
+                            <TextBlock x:Name="textBlockEvaluationQuetionContent" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="94,90,0,0" TextWrapping="Wrap" Text="Here is the question content." Height="240" Width="745" FontSize="18"/>
+                            <Image x:Name="imageEvaluationQuestion" HorizontalAlignment="Left" Width="348" Height="430" Margin="850,90,0,0" VerticalAlignment="Top" />
+                            <Grid x:Name="gridEvaluationSelection" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="94,340,0,0" Width="745" Height="200" ></Grid>
                             <Button x:Name="buttonEvaluationPrevious" Content="上一题" HorizontalAlignment="Left" Margin="424,550,0,0" VerticalAlignment="Top" Width="130" Height="50" FontSize="18" IsEnabled="False" Click="buttonEvaluationPrevious_Click" />
                             <Button x:Name="buttonEvaluationPrevious" Content="上一题" HorizontalAlignment="Left" Margin="424,550,0,0" VerticalAlignment="Top" Width="130" Height="50" FontSize="18" IsEnabled="False" Click="buttonEvaluationPrevious_Click" />
                             <Button x:Name="buttonEvaluationNext" Content="下一题" HorizontalAlignment="Left" Margin="784,550,0,0" VerticalAlignment="Top" Width="130" Height="50" FontSize="18" IsEnabled="False" Click="buttonEvaluationNext_Click" />
                             <Button x:Name="buttonEvaluationNext" Content="下一题" HorizontalAlignment="Left" Margin="784,550,0,0" VerticalAlignment="Top" Width="130" Height="50" FontSize="18" IsEnabled="False" Click="buttonEvaluationNext_Click" />
                             <Button x:Name="buttonSubmitEvaluation" Content="提交" HorizontalAlignment="Left" Margin="604,550,0,0" VerticalAlignment="Top" Width="130" Height="50" FontSize="18" Background="#FF317602" Foreground="White" IsEnabled="False" Click="buttonSubmitEvaluation_Click"/>
                             <Button x:Name="buttonSubmitEvaluation" Content="提交" HorizontalAlignment="Left" Margin="604,550,0,0" VerticalAlignment="Top" Width="130" Height="50" FontSize="18" Background="#FF317602" Foreground="White" IsEnabled="False" Click="buttonSubmitEvaluation_Click"/>

+ 68 - 2
WpfTest1/MainWindow.xaml.cs

@@ -11,6 +11,9 @@ using WpfTest1.SQLite;
 using WpfTest1.Toolkits;
 using WpfTest1.Toolkits;
 using LitJson;
 using LitJson;
 using System.ComponentModel;
 using System.ComponentModel;
+using System.Windows.Media.Imaging;
+using System.Windows.Documents;
+using System.Windows.Media;
 
 
 namespace WpfTest1
 namespace WpfTest1
 {
 {
@@ -374,6 +377,8 @@ namespace WpfTest1
                 MessageBox.Show("筛查题目加载失败\r\n数据库中无有效问卷", "错误");
                 MessageBox.Show("筛查题目加载失败\r\n数据库中无有效问卷", "错误");
                 return;
                 return;
             }
             }
+            labelFilterName.Content = filterPatient.p_name;
+            labelFilterRecordid.Content = filterPatient.p_record_id;
             currentFilterCount = 1;
             currentFilterCount = 1;
             loadQuestionViewFilter(currentFilterCount);
             loadQuestionViewFilter(currentFilterCount);
             tabFilter.SelectedIndex += 1;
             tabFilter.SelectedIndex += 1;
@@ -463,7 +468,37 @@ namespace WpfTest1
             labelFilterNumberofTotalQuestions.Content = filterQuestionaire.Count.ToString();
             labelFilterNumberofTotalQuestions.Content = filterQuestionaire.Count.ToString();
             labelFilterNumberofCurrentQuestion.Content = currentIndex.ToString();
             labelFilterNumberofCurrentQuestion.Content = currentIndex.ToString();
             labelFilterQuestionTitle.Content = filterQuestionaire[currentIndex - 1].question.q_title;
             labelFilterQuestionTitle.Content = filterQuestionaire[currentIndex - 1].question.q_title;
-            textBlockFilterQuetionContent.Text = filterQuestionaire[currentIndex - 1].question.q_content;
+            textBlockFilterQuetionContent.Text = "";
+            string[] splitedContentTemp = filterQuestionaire[currentIndex - 1].question.q_content.Split('$');
+            for(int i = 0;i< splitedContentTemp.Length; ++i)
+            {
+                Run aRunTemp = new Run();
+                aRunTemp.Text = splitedContentTemp[i];
+                
+                if (i % 2 == 0)
+                {
+                    textBlockFilterQuetionContent.Inlines.Add(aRunTemp);
+                }
+                else
+                {
+                    aRunTemp.Foreground = Brushes.Red;
+                    textBlockFilterQuetionContent.Inlines.Add(aRunTemp);
+                }
+            }
+            string quetionPic = Constants.imgPath + "\\" + filterQuestionaire[currentIndex - 1].question.q_id.ToString() + ".jpg";
+            if (File.Exists(quetionPic))
+            {
+                BitmapImage bi = new BitmapImage();
+                bi.BeginInit();
+                bi.UriSource = new Uri(quetionPic, UriKind.RelativeOrAbsolute);
+                bi.EndInit();
+                imageFilterQuestion.Source = bi;
+            }
+            else
+            {
+                imageFilterQuestion.Source = null; 
+            }
+            
             int countOptions = filterQuestionaire[currentIndex - 1].answers.Count;
             int countOptions = filterQuestionaire[currentIndex - 1].answers.Count;
             gridFilterSelection.Children.Clear();
             gridFilterSelection.Children.Clear();
             for (int i = 0; i< countOptions; ++i)
             for (int i = 0; i< countOptions; ++i)
@@ -638,6 +673,8 @@ namespace WpfTest1
             {
             {
                 MessageBox.Show("发现该病例于"+ filterReportForEvaluation.r_time.ToString("yyyy-MM-dd HH:mm:ss") +"进行过初筛,评估过程中将使用此初筛结果。", "提示");
                 MessageBox.Show("发现该病例于"+ filterReportForEvaluation.r_time.ToString("yyyy-MM-dd HH:mm:ss") +"进行过初筛,评估过程中将使用此初筛结果。", "提示");
             }
             }
+            labelEvaluationName.Content = evaluationPatient.p_name;
+            labelEvaluationRecordid.Content = evaluationPatient.p_record_id;
             currentFilterCount = 1;
             currentFilterCount = 1;
             currentEvaluationCount = 1;
             currentEvaluationCount = 1;
             evaluationQuestionaire.Add(filterQuestionaire[currentFilterCount - 1]);
             evaluationQuestionaire.Add(filterQuestionaire[currentFilterCount - 1]);
@@ -654,7 +691,36 @@ namespace WpfTest1
         {
         {
             labelQuestionNumberofCurrentQuestion.Content = currentIndex.ToString();
             labelQuestionNumberofCurrentQuestion.Content = currentIndex.ToString();
             labelEvaluationQuestionTitle.Content = evaluationQuestionaire[currentIndex - 1].question.q_title;
             labelEvaluationQuestionTitle.Content = evaluationQuestionaire[currentIndex - 1].question.q_title;
-            textBlockEvaluationQuetionContent.Text = evaluationQuestionaire[currentIndex - 1].question.q_content;
+            textBlockEvaluationQuetionContent.Text = "";
+            string[] splitedContentTemp = evaluationQuestionaire[currentIndex - 1].question.q_content.Split('$');
+            for (int i = 0; i < splitedContentTemp.Length; ++i)
+            {
+                Run aRunTemp = new Run();
+                aRunTemp.Text = splitedContentTemp[i];
+
+                if (i % 2 == 0)
+                {
+                    textBlockEvaluationQuetionContent.Inlines.Add(aRunTemp);
+                }
+                else
+                {
+                    aRunTemp.Foreground = Brushes.Red;
+                    textBlockEvaluationQuetionContent.Inlines.Add(aRunTemp);
+                }
+            }
+            string quetionPic = Constants.imgPath + "\\" + evaluationQuestionaire[currentIndex - 1].question.q_id.ToString() + ".jpg";
+            if (File.Exists(quetionPic))
+            {
+                BitmapImage bi = new BitmapImage();
+                bi.BeginInit();
+                bi.UriSource = new Uri(quetionPic, UriKind.RelativeOrAbsolute);
+                bi.EndInit();
+                imageEvaluationQuestion.Source = bi;
+            }
+            else
+            {
+                imageEvaluationQuestion.Source = null;
+            }
             int countOptions = evaluationQuestionaire[currentIndex - 1].answers.Count;
             int countOptions = evaluationQuestionaire[currentIndex - 1].answers.Count;
             gridEvaluationSelection.Children.Clear();
             gridEvaluationSelection.Children.Clear();
             for (int i = 0; i < countOptions; ++i)
             for (int i = 0; i < countOptions; ++i)

+ 1 - 1
WpfTest1/SQLite/Run.cs

@@ -7,7 +7,7 @@ using System.Threading.Tasks;
 
 
 namespace WpfTest1.SQLite
 namespace WpfTest1.SQLite
 {
 {
-    class Run
+    class RunOld
     {
     {
         public void RunProgress(int range, SetProgressValueEventHandler setProgressBar)
         public void RunProgress(int range, SetProgressValueEventHandler setProgressBar)
         {
         {

+ 5 - 2
WpfTest1/Toolkits/Constants.cs

@@ -12,9 +12,9 @@ namespace WpfTest1.Toolkits
         //软件名称
         //软件名称
         public static string softwareName = "劳拉系统";
         public static string softwareName = "劳拉系统";
         //编译版本
         //编译版本
-        public static string version = "0.1.0.0";
+        public static string version = "0.1.0.1";
         //编译日期
         //编译日期
-        public static string compileDate = "20200301";
+        public static string compileDate = "20200311";
         //加密狗验证所使用的pid
         //加密狗验证所使用的pid
         public static string registerPid = "3DE6BA91";
         public static string registerPid = "3DE6BA91";
         //加密狗验证所使用的uid
         //加密狗验证所使用的uid
@@ -29,6 +29,8 @@ namespace WpfTest1.Toolkits
         public static string reportPath = System.Environment.CurrentDirectory + "\\reports";
         public static string reportPath = System.Environment.CurrentDirectory + "\\reports";
         //各种静态素材
         //各种静态素材
         public static string imgPath = System.Environment.CurrentDirectory + "\\image";
         public static string imgPath = System.Environment.CurrentDirectory + "\\image";
+        //各种模板材料
+        public static string template = System.Environment.CurrentDirectory + "\\template";
         //报告页眉的医院图标
         //报告页眉的医院图标
         public static string reportHeadPicPath = Constants.imgPath + "\\reportHeadPic.png";
         public static string reportHeadPicPath = Constants.imgPath + "\\reportHeadPic.png";
         public static readonly Dictionary<string, int> keyboardToDigit = new Dictionary<string, int>
         public static readonly Dictionary<string, int> keyboardToDigit = new Dictionary<string, int>
@@ -42,6 +44,7 @@ namespace WpfTest1.Toolkits
             { "D7", 7 },
             { "D7", 7 },
             { "D8", 8 },
             { "D8", 8 },
             { "D9", 9 },
             { "D9", 9 },
+            { "D0", 10 },
         };
         };
         //厂家管理员的ID
         //厂家管理员的ID
         public static string adminUsername = "superman";
         public static string adminUsername = "superman";

+ 28 - 20
WpfTest1/Toolkits/ReportGenerater.cs

@@ -102,30 +102,38 @@ namespace WpfTest1.Toolkits
                 }
                 }
                 else
                 else
                 {
                 {
-                    var questionTitle = new Paragraph(String.Format("{0}:{1}", qTemp.q_title, aTemp.a_content), new Font(baseFont, 13, Font.NORMAL, BaseColor.BLACK));
-                    document.Add(questionTitle);
-                    if (aTemp.a_description_img != "")
+                    //判断PDF模板(0,1,2分)是否存在,如存在则直接调用模板
+                    string templateName = Constants.template + "\\" + aTemp.a_id.ToString() + ".pdf";
+                    if (File.Exists(templateName))
                     {
                     {
-                        Image image = Image.GetInstance(Constants.imgPath + "\\" + aTemp.a_description_img);
-                        image.ScaleAbsoluteWidth(500);
-                        document.Add(image);
+                        PdfReader readerTemp = new PdfReader(templateName);
+                        PdfImportedPage newPage;
+                        PdfContentByte cb = writer.DirectContent;
+                        int iPageNum = readerTemp.NumberOfPages;
+                        for (int j = 1; j <= iPageNum; j++)
+                        {
+                            //document.NewPage();
+                            newPage = writer.GetImportedPage(readerTemp, j);
+                            cb.AddTemplate(newPage, 0, 0);
+                        }
                     }
                     }
-                    if (aTemp.a_description_text != "")
+                    else
                     {
                     {
-                        var description = new Paragraph(String.Format("问题说明:\n    {0}", aTemp.a_description_text), new Font(baseFont, 13, Font.NORMAL, BaseColor.BLACK));
-                        document.Add(description);
-                    }
-                    if (aTemp.a_suggestion_img != "")
-                    {
-                        Image image = Image.GetInstance(Constants.imgPath + "\\" + aTemp.a_suggestion_img);
-                        image.ScaleAbsoluteWidth(500);
-                        document.Add(image);
-                    }
-                    if (aTemp.a_suggestion_text != "")
-                    {
-                        var suggestion = new Paragraph(String.Format("建议:\n    {0}", aTemp.a_suggestion_text), new Font(baseFont, 13, Font.NORMAL, BaseColor.BLACK));
-                        document.Add(suggestion);
+                        //document.NewPage();
+                        var questionTitle = new Paragraph(String.Format("{0}:{1}", qTemp.q_title, aTemp.a_content), new Font(baseFont, 13, Font.NORMAL, BaseColor.BLACK));
+                        document.Add(questionTitle);
+                        if (aTemp.a_description_text != "")
+                        {
+                            var description = new Paragraph(String.Format("问题说明:\n    {0}", aTemp.a_description_text), new Font(baseFont, 13, Font.NORMAL, BaseColor.BLACK));
+                            document.Add(description);
+                        }
+                        if (aTemp.a_suggestion_text != "")
+                        {
+                            var suggestion = new Paragraph(String.Format("建议:\n    {0}", aTemp.a_suggestion_text), new Font(baseFont, 13, Font.NORMAL, BaseColor.BLACK));
+                            document.Add(suggestion);
+                        }
                     }
                     }
+                    
                 }
                 }
             }
             }
             document.Close();
             document.Close();