Free cookie consent management tool by TermsFeed Policy Generator

source: stable/HeuristicLab.PluginInfrastructure/3.3/ErrorHandling/FrameworkVersionErrorDialog.cs @ 11178

Last change on this file since 11178 was 11170, checked in by ascheibe, 10 years ago

#2115 updated copyright year in stable branch

File size: 3.5 KB
RevLine 
[5984]1#region License Information
2/* HeuristicLab
[11170]3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
[5984]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
[8632]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   */
[5984]20#endregion
[5997]21
[5984]22using System;
[8632]23using System.Reflection;
[5984]24using System.Windows.Forms;
25
26namespace HeuristicLab.PluginInfrastructure {
[5997]27  public partial class FrameworkVersionErrorDialog : Form {
28    public static bool NET4FullProfileInstalled {
[8632]29      get {
30        try {
31          return Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\NET Framework Setup\\NDP\\v4\\Full") != null;
32        }
33        catch (System.Security.SecurityException) {
34          return false;
35        }
36      }
[5997]37    }
38
[8632]39    public static bool MonoInstalled {
40      get { return Type.GetType("Mono.Runtime") != null; }
41    }
42
43    public static bool MonoCorrectVersionInstalled {
44      get {
[8816]45        var monoVersion = MonoVersion;
46        var minRequiredVersion = new Version(2, 11, 4);
47                                                                     
[8632]48        //we need at least mono version 2.11.4
[8816]49        if (monoVersion != null && monoVersion >= minRequiredVersion) {
[8632]50          return true;
51        } else {
52          return false;
53        }
54      }
55    }
56
57    public static Version MonoVersion {
58      get {
59        Type type = Type.GetType("Mono.Runtime");
60        if (type != null) {
61          MethodInfo dispalayName = type.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static);
62          if (dispalayName != null) {
63            string versionString = dispalayName.Invoke(null, null) as string;
64            if (versionString != null) {
65              // the version string looks something like: 2.11.4 (master/99d5e54 Thu Sep  6 15:55:44 CEST 2012)
66              var subVerStrings = versionString.Split(' ');
67              if (subVerStrings.Length > 0) {
68                try {
69                  return Version.Parse(subVerStrings[0]);
70                }
71                catch { }
72              }
73            }
74          }
75        }
76        return null;
77      }
78    }
79
[5997]80    public FrameworkVersionErrorDialog() {
[5984]81      InitializeComponent();
82    }
83
84    private void linkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) {
85      try {
86        System.Diagnostics.Process.Start("http://www.microsoft.com/downloads/en/details.aspx?displaylang=en&FamilyID=0a391abd-25c1-4fc0-919f-b21f31ab88b7");
87        linkLabel.LinkVisited = true;
88      }
89      catch (Exception) { }
90    }
91
92    private void cancelButton_Click(object sender, EventArgs e) {
93      Application.Exit();
94    }
[8632]95
96    private void linkLabelMono_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) {
97      try {
98        System.Diagnostics.Process.Start("http://www.mono-project.org");
99        linkLabelMono.LinkVisited = true;
100      }
101      catch (Exception) { }
102    }
[5984]103  }
104}
Note: See TracBrowser for help on using the repository browser.