Free cookie consent management tool by TermsFeed Policy Generator

source: stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/MathSymbolicDataAnalysisModelView.cs @ 13689

Last change on this file since 13689 was 12009, checked in by ascheibe, 10 years ago

#2212 updated copyright year

File size: 2.7 KB
RevLine 
[7446]1#region License Information
2/* HeuristicLab
[12009]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
22using System;
[8110]23using System.IO;
[7446]24using System.Windows.Forms;
25using HeuristicLab.MainForm;
26using HeuristicLab.MainForm.WindowsForms;
27
28namespace 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);
63      } else {
64        HtmlElement newElement = webBrowser.Document.GetElementById("model");
65        newElement.InnerText = string.Empty;
66      }
67      webBrowser.Document.InvokeScript("refreshModel");
68    }
69  }
70}
Note: See TracBrowser for help on using the repository browser.