From 8cfc4915b1e47968acc1d5cbbc9e0b7c2821c139 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=BB=D0=B0=D0=B4=D0=B8=D1=81=D0=BB=D0=B0=D0=B2=20?= =?UTF-8?q?=D0=9F=D1=80=D0=B5=D0=BA=D0=B5=D0=BB=D1=8C?= Date: Fri, 2 Mar 2018 17:32:21 +0700 Subject: [PATCH 01/52] fixed issue #18 --- MyExpression.Wpf/MainWindow.xaml.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/MyExpression.Wpf/MainWindow.xaml.cs b/MyExpression.Wpf/MainWindow.xaml.cs index 4d9727e..4e4d584 100644 --- a/MyExpression.Wpf/MainWindow.xaml.cs +++ b/MyExpression.Wpf/MainWindow.xaml.cs @@ -74,7 +74,7 @@ private void ResetButton_Click(object sender, RoutedEventArgs e) } catch (Exception ex) { - MessageBox.Show(ex.StackTrace, ex.Message); + MessageBox.Show(ex.Message + '\n' + ex.StackTrace); } } @@ -82,11 +82,15 @@ private void DrawButton_Click(object sender, RoutedEventArgs e) { try { + if (Graph.Children.Count == 0) + { + throw new ApplicationException("Непроинициализировано"); + } Graph.DrawFunctions(); } catch (Exception ex) { - MessageBox.Show(ex.StackTrace, ex.Message); + MessageBox.Show(ex.Message + '\n' + ex.StackTrace); } } @@ -114,7 +118,7 @@ private void AddButton_Click(object sender, RoutedEventArgs e) } catch (Exception ex) { - MessageBox.Show(ex.StackTrace, ex.Message); + MessageBox.Show(ex.Message + '\n' + ex.StackTrace); } } @@ -128,7 +132,7 @@ private void ClearButton_Click(object sender, RoutedEventArgs e) } catch (Exception ex) { - MessageBox.Show(ex.StackTrace, ex.Message); + MessageBox.Show(ex.Message + '\n' + ex.StackTrace); } } @@ -145,7 +149,7 @@ private void SolveButton_Click(object sender, RoutedEventArgs e) } catch (Exception ex) { - MessageBox.Show(ex.StackTrace, ex.Message); + MessageBox.Show(ex.Message + '\n' + ex.StackTrace); } } } From 79368abaa2a98b18b6fd9a3b9ca41e3f75510e8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=BB=D0=B0=D0=B4=D0=B8=D1=81=D0=BB=D0=B0=D0=B2=20?= =?UTF-8?q?=D0=9F=D1=80=D0=B5=D0=BA=D0=B5=D0=BB=D1=8C?= Date: Fri, 2 Mar 2018 18:29:20 +0700 Subject: [PATCH 02/52] =?UTF-8?q?=D1=87=D0=B5=D1=80=D0=B5=D0=B7=20=D0=BF?= =?UTF-8?q?=D0=BE=D1=82=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MyExpression.Wpf/MainWindow.xaml.cs | 38 +++++++++++++++++------------ 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/MyExpression.Wpf/MainWindow.xaml.cs b/MyExpression.Wpf/MainWindow.xaml.cs index 4e4d584..d456944 100644 --- a/MyExpression.Wpf/MainWindow.xaml.cs +++ b/MyExpression.Wpf/MainWindow.xaml.cs @@ -14,6 +14,7 @@ using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; +using System.Threading; using MyExpression.Core; @@ -98,23 +99,30 @@ private void AddButton_Click(object sender, RoutedEventArgs e) { try { - var da = new Interval(Double.Parse(DefinitionAreaLeft.Text), Double.Parse(DefinitionAreaRight.Text)); - IFunctionX fp; - try - { - fp = Core.Polynomial.Parse(Polynomial.Text); - } - catch + var t = new Thread(new ParameterizedThreadStart(par => { - fp = new CodeDomEval(Polynomial.Text); - } + var tp = (Tuple)par; + //var tp = (Tuple)par; + IFunctionX fp; + try + { + fp = Core.Polynomial.Parse(tp.Item1); + } + catch + { + fp = new CodeDomEval(tp.Item1); + } + Func f = fp.Calculate; + Graph.Add(f, tp.Item3, tp.Item2); + var df = Graph.Functions.Last(); + Functions.Add(new GraphableFunction(fp, df)); + + //tp.Item4.Content = tp.Item5; + })); - Func f = fp.Calculate; - Graph.Add(f, da, GraphBrushComboBox.SelectedBrush); - var df = Graph.Functions.Last(); - Functions.Add(new GraphableFunction(fp, df)); - - CountLabel.Content = Graph.Count; + var da = new Interval(Double.Parse(DefinitionAreaLeft.Text), Double.Parse(DefinitionAreaRight.Text)); + t.Start((Polynomial.Text, GraphBrushComboBox.SelectedBrush, da, CountLabel, Graph.Count).ToTuple()); + //t.Start((Polynomial.Text, GraphBrushComboBox.SelectedBrush, da).ToTuple()); } catch (Exception ex) { From c5d2c42a0cce7c080c625c878b44b28b0c0e49a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=BB=D0=B0=D0=B4=D0=B8=D1=81=D0=BB=D0=B0=D0=B2=20?= =?UTF-8?q?=D0=9F=D1=80=D0=B5=D0=BA=D0=B5=D0=BB=D1=8C?= Date: Fri, 2 Mar 2018 18:39:44 +0700 Subject: [PATCH 03/52] =?UTF-8?q?=D0=B2=D1=80=D0=BE=D0=B4=D0=B5=20=D1=80?= =?UTF-8?q?=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=D0=B5=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MyExpression.Wpf/MainWindow.xaml.cs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/MyExpression.Wpf/MainWindow.xaml.cs b/MyExpression.Wpf/MainWindow.xaml.cs index d456944..f5648b9 100644 --- a/MyExpression.Wpf/MainWindow.xaml.cs +++ b/MyExpression.Wpf/MainWindow.xaml.cs @@ -99,9 +99,11 @@ private void AddButton_Click(object sender, RoutedEventArgs e) { try { - var t = new Thread(new ParameterizedThreadStart(par => + var da = new Interval(Double.Parse(DefinitionAreaLeft.Text), Double.Parse(DefinitionAreaRight.Text)); + var tpl = (Polynomial.Text, GraphBrushComboBox.SelectedBrush, da); + var t = new Task(par => { - var tp = (Tuple)par; + var tp = (Tuple)par; //var tp = (Tuple)par; IFunctionX fp; try @@ -117,12 +119,9 @@ private void AddButton_Click(object sender, RoutedEventArgs e) var df = Graph.Functions.Last(); Functions.Add(new GraphableFunction(fp, df)); - //tp.Item4.Content = tp.Item5; - })); - - var da = new Interval(Double.Parse(DefinitionAreaLeft.Text), Double.Parse(DefinitionAreaRight.Text)); - t.Start((Polynomial.Text, GraphBrushComboBox.SelectedBrush, da, CountLabel, Graph.Count).ToTuple()); - //t.Start((Polynomial.Text, GraphBrushComboBox.SelectedBrush, da).ToTuple()); + Dispatcher.Invoke(() => CountLabel.Content = Graph.Count); + }, tpl.ToTuple()); + t.Start(); } catch (Exception ex) { From 39e59452c63f1ac5db36b087204e06d0a3061e3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=BB=D0=B0=D0=B4=D0=B8=D1=81=D0=BB=D0=B0=D0=B2=20?= =?UTF-8?q?=D0=9F=D1=80=D0=B5=D0=BA=D0=B5=D0=BB=D1=8C?= Date: Fri, 2 Mar 2018 19:06:56 +0700 Subject: [PATCH 04/52] =?UTF-8?q?=D0=B2=D0=BE=D1=82=20=D0=BB=D1=83=D1=87?= =?UTF-8?q?=D1=88=D0=B5=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=D0=B5=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MyExpression.Wpf/MainWindow.xaml.cs | 38 +++++++++++++++-------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/MyExpression.Wpf/MainWindow.xaml.cs b/MyExpression.Wpf/MainWindow.xaml.cs index f5648b9..da7905f 100644 --- a/MyExpression.Wpf/MainWindow.xaml.cs +++ b/MyExpression.Wpf/MainWindow.xaml.cs @@ -100,28 +100,30 @@ private void AddButton_Click(object sender, RoutedEventArgs e) try { var da = new Interval(Double.Parse(DefinitionAreaLeft.Text), Double.Parse(DefinitionAreaRight.Text)); - var tpl = (Polynomial.Text, GraphBrushComboBox.SelectedBrush, da); - var t = new Task(par => + try { - var tp = (Tuple)par; - //var tp = (Tuple)par; - IFunctionX fp; - try - { - fp = Core.Polynomial.Parse(tp.Item1); - } - catch - { - fp = new CodeDomEval(tp.Item1); - } + var fp = Core.Polynomial.Parse(Polynomial.Text); Func f = fp.Calculate; - Graph.Add(f, tp.Item3, tp.Item2); + Graph.Add(f, da, GraphBrushComboBox.SelectedBrush); var df = Graph.Functions.Last(); Functions.Add(new GraphableFunction(fp, df)); - - Dispatcher.Invoke(() => CountLabel.Content = Graph.Count); - }, tpl.ToTuple()); - t.Start(); + CountLabel.Content = Graph.Count; + } + catch + { + var tpl = (Polynomial.Text, GraphBrushComboBox.SelectedBrush, da); + var t = new Task((par) => + { + var tp = (Tuple)par; + var fp = new CodeDomEval(tp.Item1); + Func f = fp.Calculate; + Graph.Add(f, tp.Item3, tp.Item2); + var df = Graph.Functions.Last(); + Functions.Add(new GraphableFunction(fp, df)); + Dispatcher.Invoke(() => CountLabel.Content = Graph.Count); + }, tpl.ToTuple()); + t.Start(); + } } catch (Exception ex) { From f4d58f74314864e041f8c0357ceec71647166691 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=BB=D0=B0=D0=B4=D0=B8=D1=81=D0=BB=D0=B0=D0=B2=20?= =?UTF-8?q?=D0=9F=D1=80=D0=B5=D0=BA=D0=B5=D0=BB=D1=8C?= Date: Fri, 2 Mar 2018 19:56:16 +0700 Subject: [PATCH 05/52] trycatch --- MyExpression.Core/CodeDomEval.cs | 4 ++-- MyExpression.Wpf/MainWindow.xaml.cs | 21 ++++++++++++++------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/MyExpression.Core/CodeDomEval.cs b/MyExpression.Core/CodeDomEval.cs index a66aafe..47c300c 100644 --- a/MyExpression.Core/CodeDomEval.cs +++ b/MyExpression.Core/CodeDomEval.cs @@ -62,9 +62,9 @@ public CodeDomEval(string expression) // Сбор ошибок компиляции foreach (CompilerError error in CompilerResults.Errors) { - sb.Append(error.ErrorText + "\n"); + sb.Append(error + "\n"); } - throw new Exception("Ошибка сборки\n" + sb); + throw new ApplicationException("Ошибка сборки\n" + sb); } if (!IsSuccessfulBuild) throw new Exception("Ошибка сборки"); diff --git a/MyExpression.Wpf/MainWindow.xaml.cs b/MyExpression.Wpf/MainWindow.xaml.cs index da7905f..b8ea449 100644 --- a/MyExpression.Wpf/MainWindow.xaml.cs +++ b/MyExpression.Wpf/MainWindow.xaml.cs @@ -114,13 +114,20 @@ private void AddButton_Click(object sender, RoutedEventArgs e) var tpl = (Polynomial.Text, GraphBrushComboBox.SelectedBrush, da); var t = new Task((par) => { - var tp = (Tuple)par; - var fp = new CodeDomEval(tp.Item1); - Func f = fp.Calculate; - Graph.Add(f, tp.Item3, tp.Item2); - var df = Graph.Functions.Last(); - Functions.Add(new GraphableFunction(fp, df)); - Dispatcher.Invoke(() => CountLabel.Content = Graph.Count); + try + { + var tp = (Tuple)par; + var fp = new CodeDomEval(tp.Item1); + Func f = fp.Calculate; + Graph.Add(f, tp.Item3, tp.Item2); + var df = Graph.Functions.Last(); + Functions.Add(new GraphableFunction(fp, df)); + Dispatcher.Invoke(() => CountLabel.Content = Graph.Count); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message + '\n' + ex.StackTrace); + } }, tpl.ToTuple()); t.Start(); } From a6842b88225d26be4d49b4d7a28816c6d59d4059 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=BB=D0=B0=D0=B4=D0=B8=D1=81=D0=BB=D0=B0=D0=B2=20?= =?UTF-8?q?=D0=9F=D1=80=D0=B5=D0=BA=D0=B5=D0=BB=D1=8C?= Date: Fri, 2 Mar 2018 20:06:35 +0700 Subject: [PATCH 06/52] =?UTF-8?q?=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BA=D1=83=D1=80=D1=81=D0=BE=D1=80=D0=B0?= =?UTF-8?q?=20=D0=BF=D1=80=D0=B8=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MyExpression.Wpf/MainWindow.xaml.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/MyExpression.Wpf/MainWindow.xaml.cs b/MyExpression.Wpf/MainWindow.xaml.cs index b8ea449..55e15d0 100644 --- a/MyExpression.Wpf/MainWindow.xaml.cs +++ b/MyExpression.Wpf/MainWindow.xaml.cs @@ -99,6 +99,7 @@ private void AddButton_Click(object sender, RoutedEventArgs e) { try { + Cursor = Cursors.Wait; var da = new Interval(Double.Parse(DefinitionAreaLeft.Text), Double.Parse(DefinitionAreaRight.Text)); try { @@ -108,6 +109,7 @@ private void AddButton_Click(object sender, RoutedEventArgs e) var df = Graph.Functions.Last(); Functions.Add(new GraphableFunction(fp, df)); CountLabel.Content = Graph.Count; + Cursor = null; } catch { @@ -128,6 +130,10 @@ private void AddButton_Click(object sender, RoutedEventArgs e) { MessageBox.Show(ex.Message + '\n' + ex.StackTrace); } + finally + { + Dispatcher.Invoke(() => Cursor = null); + } }, tpl.ToTuple()); t.Start(); } From 31455f6bfa278558ab630d246aa29357e2595d5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=BB=D0=B0=D0=B4=D0=B8=D1=81=D0=BB=D0=B0=D0=B2=20?= =?UTF-8?q?=D0=9F=D1=80=D0=B5=D0=BA=D0=B5=D0=BB=D1=8C?= Date: Fri, 2 Mar 2018 22:13:07 +0700 Subject: [PATCH 07/52] =?UTF-8?q?=D0=B2=D1=80=D0=BE=D0=B4=D0=B5=20=D1=80?= =?UTF-8?q?=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=D0=B5=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MyExpression.Wpf/MainWindow.xaml | 5 ++++ MyExpression.Wpf/MainWindow.xaml.cs | 41 +++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/MyExpression.Wpf/MainWindow.xaml b/MyExpression.Wpf/MainWindow.xaml index 580904f..89376c1 100644 --- a/MyExpression.Wpf/MainWindow.xaml +++ b/MyExpression.Wpf/MainWindow.xaml @@ -52,5 +52,10 @@