コード例 #1
0
        public void ToParse(string url)
        {
            try
            {
                ParserResult.ClearAll();
                TextDocument           = new FlowDocument();
                Searcher.FlagIsRuleRow = false;
                using (StreamReader document = new StreamReader(url, Encoding.Default))
                {
                    while (!document.EndOfStream)
                    {
                        string TextLine = document.ReadLine();
                        AnalysisOfTheRow(TextLine);

                        Paragraph paragraph = new Paragraph();
                        paragraph.Inlines.Add(new Bold(new Run(TextLine)));
                        TextDocument.Blocks.Add(paragraph);
                    }
                }

                GetDataEvent?.Invoke();
            }
            catch (Exception e)
            {
                if (e.Message == "No_Reles")
                {
                    MessageEvent?.Invoke("В тексте нет ни одного правила!");
                }
                else
                {
                    MessageEvent?.Invoke("Синтаксическая ошибка");
                }
            }
        }
コード例 #2
0
 /// <summary>
 ///     实时的加载数据函数
 /// </summary>
 /// <returns></returns>
 public void GetData()
 {
     try
     {
         IsUpdatingData = true;
         var data = GetDataEvent.Invoke(SearchFilter, PageSize, PageNum) as List <Student>;
         if (data != null)
         {
             DataList.AddRange(data);
         }
         if (_currentWorker == null)                 //防止数据导出时,界面字段有排序,频繁绘制grid时数据源变化引起空异常
         {
             _grid.RefreshDataSource();
         }
     }
     catch (Exception ex)
     {
         MsgBox.ShowError(ex);
     }
     finally
     {
         IsUpdatingData = false;
     }
 }
コード例 #3
0
 public void ToParseFromTextRedactor(string text)
 {
     try
     {
         ParserResult.ClearAll();
         TextDocument = null;
         string CurrentText = text;
         int    NumberN;
         while (CurrentText.Length > 0)
         {
             if (CurrentText.Contains('\n'))
             {
                 NumberN = CurrentText.IndexOf('\n');
                 AnalysisOfTheRow(CurrentText.Substring(0, NumberN));
                 CurrentText = CurrentText.Substring(NumberN + 1);
             }
             else
             {
                 AnalysisOfTheRow(CurrentText);
                 CurrentText = "";
             }
         }
         GetDataEvent?.Invoke();
     }
     catch (Exception e)
     {
         if (e.Message == "No_Reles")
         {
             MessageEvent?.Invoke("В тексте нет ни одного правила!");
         }
         else
         {
             MessageEvent?.Invoke("Синтаксическая ошибка");
         }
     }
 }