[7446] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[12012] | 3 | * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[7446] | 4 | *
|
---|
| 5 | * This file is part of HeuristicLab.
|
---|
| 6 | *
|
---|
| 7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
| 8 | * it under the terms of the GNU General Public License as published by
|
---|
| 9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 10 | * (at your option) any later version.
|
---|
| 11 | *
|
---|
| 12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 15 | * GNU General Public License for more details.
|
---|
| 16 | *
|
---|
| 17 | * You should have received a copy of the GNU General Public License
|
---|
| 18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 19 | */
|
---|
| 20 | #endregion
|
---|
| 21 |
|
---|
| 22 | using System;
|
---|
[8110] | 23 | using System.IO;
|
---|
[7446] | 24 | using System.Windows.Forms;
|
---|
| 25 | using HeuristicLab.MainForm;
|
---|
| 26 | using HeuristicLab.MainForm.WindowsForms;
|
---|
| 27 |
|
---|
| 28 | namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views {
|
---|
| 29 | [View("Mathematical Representation")]
|
---|
[8110] | 30 | [Content(typeof(ISymbolicDataAnalysisModel))]
|
---|
[7446] | 31 | public partial class MathSymbolicDataAnalysisModelView : AsynchronousContentView {
|
---|
| 32 | private SymbolicDataAnalysisExpressionLatexFormatter formatter = new SymbolicDataAnalysisExpressionLatexFormatter();
|
---|
| 33 | public MathSymbolicDataAnalysisModelView()
|
---|
| 34 | : base() {
|
---|
| 35 | InitializeComponent();
|
---|
| 36 | webBrowser.ScrollBarsEnabled = true;
|
---|
| 37 | webBrowser.ScriptErrorsSuppressed = false;
|
---|
| 38 |
|
---|
| 39 | // update for the first time after page has loaded
|
---|
| 40 | webBrowser.DocumentCompleted += (sender, args) => RefreshHtmlPage();
|
---|
| 41 |
|
---|
| 42 | string hlDir = Path.GetFullPath(AppDomain.CurrentDomain.BaseDirectory);
|
---|
[8110] | 43 | webBrowser.Navigate("file://" + Path.Combine(hlDir, "displayModelFrame.html"));
|
---|
[7446] | 44 | }
|
---|
| 45 |
|
---|
| 46 | public new ISymbolicDataAnalysisModel Content {
|
---|
| 47 | get { return (ISymbolicDataAnalysisModel)base.Content; }
|
---|
| 48 | set { base.Content = value; }
|
---|
| 49 | }
|
---|
| 50 |
|
---|
| 51 | protected override void OnContentChanged() {
|
---|
| 52 | base.OnContentChanged();
|
---|
| 53 | RefreshHtmlPage();
|
---|
| 54 | }
|
---|
| 55 |
|
---|
| 56 | private void RefreshHtmlPage() {
|
---|
| 57 | // only update if the page has loaded already
|
---|
| 58 | if (webBrowser.Document == null || webBrowser.Document.Body == null) return;
|
---|
| 59 |
|
---|
| 60 | if (Content != null) {
|
---|
| 61 | HtmlElement newElement = webBrowser.Document.GetElementById("model");
|
---|
| 62 | newElement.InnerText = formatter.Format(Content.SymbolicExpressionTree);
|
---|
[13984] | 63 | webBrowser.Document.InvokeScript("refreshModel");
|
---|
[7446] | 64 | } else {
|
---|
| 65 | HtmlElement newElement = webBrowser.Document.GetElementById("model");
|
---|
| 66 | newElement.InnerText = string.Empty;
|
---|
| 67 | }
|
---|
| 68 | }
|
---|
| 69 | }
|
---|
| 70 | }
|
---|