MainForm.cs :  » Testing » xUnit.net » Xunit » Installer » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Testing » xUnit.net 
xUnit.net » Xunit » Installer » MainForm.cs
using System;
using System.Drawing;
using System.Reflection;
using System.Windows.Forms;

namespace Xunit.Installer{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }

        void MainForm_Load(object sender, EventArgs e)
        {
            Text = Program.Name + " (build " + Assembly.GetExecutingAssembly().GetName().Version + ")";

            Font boldFont = new Font(labelStatusTdNet.Font, FontStyle.Bold);
            labelStatusMVC.Font = boldFont;
            labelStatusMVC2.Font = boldFont;
            labelStatusMVC2VS2010.Font = boldFont;
            labelStatusTdNet.Font = boldFont;
            labelStatusGuiExplorer.Font = boldFont;

            UpdateUI();
        }

        void UpdateUI()
        {
            UpdateUI(btnEnableMVC,
                     btnDisableMVC,
                     labelStatusMVC,
                     "ASP.NET MVC 1.0",
                     Mvc1Helper.CanBeEnabled,
                     Mvc1Helper.IsEnabled,
                     Mvc1Helper.InstalledXunitVersion);

            UpdateUI(btnEnableMVC2,
                     btnDisableMVC2,
                     labelStatusMVC2,
                     "ASP.NET MVC 2 (VS2008)",
                     Mvc2Helper.CanBeEnabled,
                     Mvc2Helper.IsEnabled,
                     Mvc2Helper.InstalledXunitVersion);

            UpdateUI(btnEnableMVC2VS2010,
                     btnDisableMVC2VS2010,
                     labelStatusMVC2VS2010,
                     "ASP.NET MVC 2 (VS2010)",
                     Mvc2VS2010Helper.CanBeEnabled,
                     Mvc2VS2010Helper.IsEnabled,
                     Mvc2VS2010Helper.InstalledXunitVersion);

            UpdateUI(btnEnableTdNet,
                     btnDisableTdNet,
                     labelStatusTdNet,
                     "TestDriven.NET 2.x",
                     TdNetHelper.CanBeEnabled,
                     TdNetHelper.IsEnabled,
                     () => "(Can run tests against any version of xUnit.net)");

            UpdateUI(btnEnableGuiExplorer,
                     btnDisableGuiExplorer,
                     labelStatusGuiExplorer,
                     "Project File Explorer Integration",
                     true,
                     GuiExplorerHelper.IsEnabled,
                     null);
        }

        static void UpdateUI(Control enable, Control disable, Control status, string toolName, bool isToolInstalled,
                             bool isRunnerInstalled, InstalledStatusDelegate installedStatusDelegate)
        {
            if (!isToolInstalled)
            {
                enable.Enabled = false;
                disable.Enabled = false;
                status.Text = toolName + " is not installed.\r\nYou must install it to enable this feature.";
                status.ForeColor = Color.DarkRed;
                return;
            }

            if (isRunnerInstalled)
            {
                enable.Enabled = false;
                disable.Enabled = true;
                status.Text = "Support for " + toolName + " is enabled.";
                status.ForeColor = Color.Green;

                if (installedStatusDelegate != null)
                    status.Text += Environment.NewLine + "  " + installedStatusDelegate();
            }
            else
            {
                enable.Enabled = true;
                disable.Enabled = false;
                status.Text = "Support for " + toolName + " is disabled.";
                status.ForeColor = Color.DarkGoldenrod;
            }
        }

        // Event handlers

        void btnDisableGuiExplorer_Click(object sender, EventArgs e)
        {
            GuiExplorerHelper.Disable();
            UpdateUI();
        }

        void btnDisableMVC_Click(object sender, EventArgs e)
        {
            if (!Mvc1Helper.Disable(this))
                MessageBox.Show("Uninstallation failed. Make sure Visual Studio is not running and try again.",
                                Program.Name,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);

            UpdateUI();
        }

        void btnDisableMVC2_Click(object sender, EventArgs e)
        {
            if (!Mvc2Helper.Disable(this))
                MessageBox.Show("Uninstallation failed. Make sure Visual Studio is not running and try again.",
                                Program.Name,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);

            UpdateUI();
        }

        void btnDisableMVC2VS2010_Click(object sender, EventArgs e)
        {
            if (!Mvc2VS2010Helper.Disable(this))
                MessageBox.Show("Uninstallation failed. Make sure Visual Studio is not running and try again.",
                                Program.Name,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);

            UpdateUI();
        }

        void btnDisableTdNet_Click(object sender,
                                     EventArgs e)
        {
            if (!TdNetHelper.Disable())
                MessageBox.Show("Uninstallation failed. Make sure Visual Studio is not running and try again.",
                                Program.Name,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);

            UpdateUI();
        }

        void btnEnableGuiExplorer_Click(object sender, EventArgs e)
        {
            GuiExplorerHelper.Enable();
            UpdateUI();
        }

        void btnEnableMVC_Click(object sender, EventArgs e)
        {
            if (!Mvc1Helper.Enable(this))
                MessageBox.Show("Installation failed. Make sure Visual Studio is not running and try again.",
                                Program.Name,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);

            UpdateUI();
        }

        void btnEnableMVC2_Click(object sender, EventArgs e)
        {
            if (!Mvc2Helper.Enable(this))
                MessageBox.Show("Installation failed. Make sure Visual Studio is not running and try again.",
                                Program.Name,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);

            UpdateUI();
        }

        void btnEnableMVC2VS2010_Click(object sender, EventArgs e)
        {
            if (!Mvc2VS2010Helper.Enable(this))
                MessageBox.Show("Installation failed. Make sure Visual Studio is not running and try again.",
                                Program.Name,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);

            UpdateUI();
        }

        void btnEnableTdNet_Click(object sender, EventArgs e)
        {
            if (!TdNetHelper.Enable())
                MessageBox.Show("Installation failed. Make sure Visual Studio is not running and try again.",
                                Program.Name,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);

            UpdateUI();
        }

        void btnExit_Click(object sender, EventArgs e)
        {
            Close();
        }
    }

    public delegate string InstalledStatusDelegate();
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.