Click here to Skip to main content
15,892,746 members
Articles / Programming Languages / C#

NUnit Starter

Rate me:
Please Sign up or sign in to vote.
4.92/5 (6 votes)
13 Oct 2009Zlib34 min read 42.5K   470   39  
How to create Visual Studio 2008 Add-in compatible with Visual Studio 2003
/*
 * Filename:    NUnitExecutableUserControl.cs
 * Product:     NUnit Starter
 * Solution:    NUnitStarter.sln
 * Project:     AddIn
 * Description: User control that groups controls required to define 
 *              executable name and command line parameters.
 * Copyright:   Julijan Šribar, 2009
 * 
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the author(s) be held liable for any damages
 * arising from the use of this software.
 *
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
 *
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
 *    appreciated but is not required.
 * 2. Altered source versions must be plainly marked as such, and must not be
 *    misrepresented as being the original software.
 * 3. This notice may not be removed or altered from any source distribution.
 */
using System;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace NUnitStarter
{
    class NUnitExecutableUserControl : UserControl
    {
        #region Controls

        private System.Windows.Forms.GroupBox m_groupBox;
        private FilePathUserControl m_filePathUserControl;

        private System.Windows.Forms.GroupBox m_commandLinegroupBox;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.Label label2;
        private TextBox m_textBoxCommandLineItem;
        private TextBox m_textBoxCommandLineProject;


        /// <summary> 
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        #endregion // Controls

        public NUnitExecutableUserControl()
        {
            InitializeComponent();
        }

        /// <summary> 
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Public properties

        [Browsable(true)]
        [Category("Appearance")]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public string Title
        {
            get { return m_groupBox.Text; }
            set { m_groupBox.Text = value; }
        }

        [Browsable(false)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        public NUnitExecutable NUnitExecutable
        {
            get
            {
                string commandLineFormatProject = m_textBoxCommandLineProject.Text;
                string commandLineFormatItem = m_textBoxCommandLineItem.Text;
                return new NUnitExecutable(m_filePathUserControl.Filename, commandLineFormatProject, commandLineFormatItem);
            }
            set
            {
                m_filePathUserControl.Filename = value.Filename;
                m_textBoxCommandLineProject.Text = value.CommandLineFormat4Project;
                m_textBoxCommandLineItem.Text = value.CommandLineFormat4Item;
            }
        }

        public string DefaultFilename
        {
            get { return m_filePathUserControl.DefaultFilename; }
            set { m_filePathUserControl.DefaultFilename = value; }
        }

        public string Filter
        {
            get { return m_filePathUserControl.Filter; }
            set { m_filePathUserControl.Filter = value; }
        }

        #endregion // Public properties

        #region Component Designer generated code

        /// <summary> 
        /// Required method for Designer support - do not modify 
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.m_groupBox = new System.Windows.Forms.GroupBox();
            this.m_filePathUserControl = new NUnitStarter.FilePathUserControl();
            this.m_commandLinegroupBox = new System.Windows.Forms.GroupBox();
            this.m_textBoxCommandLineItem = new System.Windows.Forms.TextBox();
            this.m_textBoxCommandLineProject = new System.Windows.Forms.TextBox();
            this.label2 = new System.Windows.Forms.Label();
            this.label1 = new System.Windows.Forms.Label();
            this.m_groupBox.SuspendLayout();
            this.m_commandLinegroupBox.SuspendLayout();
            this.SuspendLayout();
            // 
            // m_groupBox
            // 
            this.m_groupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                        | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.m_groupBox.Controls.Add(this.m_filePathUserControl);
            this.m_groupBox.Controls.Add(this.m_commandLinegroupBox);
            this.m_groupBox.Location = new System.Drawing.Point(0, 0);
            this.m_groupBox.Name = "m_groupBox";
            this.m_groupBox.Size = new System.Drawing.Size(414, 133);
            this.m_groupBox.TabIndex = 0;
            this.m_groupBox.TabStop = false;
            // 
            // m_filePathUserControl
            // 
            this.m_filePathUserControl.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.m_filePathUserControl.DefaultFilename = null;
            this.m_filePathUserControl.Filename = "";
            this.m_filePathUserControl.Filter = "Executable files (*.exe)|*.exe|All files (*.*)|*.*";
            this.m_filePathUserControl.LabelText = "E&xecutable:";
            this.m_filePathUserControl.Location = new System.Drawing.Point(9, 19);
            this.m_filePathUserControl.Name = "m_filePathUserControl";
            this.m_filePathUserControl.Size = new System.Drawing.Size(396, 22);
            this.m_filePathUserControl.TabIndex = 0;
            // 
            // m_commandLinegroupBox
            // 
            this.m_commandLinegroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                        | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.m_commandLinegroupBox.Controls.Add(this.m_textBoxCommandLineItem);
            this.m_commandLinegroupBox.Controls.Add(this.m_textBoxCommandLineProject);
            this.m_commandLinegroupBox.Controls.Add(this.label2);
            this.m_commandLinegroupBox.Controls.Add(this.label1);
            this.m_commandLinegroupBox.Location = new System.Drawing.Point(9, 47);
            this.m_commandLinegroupBox.Name = "m_commandLinegroupBox";
            this.m_commandLinegroupBox.Size = new System.Drawing.Size(396, 77);
            this.m_commandLinegroupBox.TabIndex = 1;
            this.m_commandLinegroupBox.TabStop = false;
            this.m_commandLinegroupBox.Text = "Command Line Format";
            // 
            // m_textBoxCommandLineItem
            // 
            this.m_textBoxCommandLineItem.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.m_textBoxCommandLineItem.Location = new System.Drawing.Point(72, 44);
            this.m_textBoxCommandLineItem.Name = "m_textBoxCommandLineItem";
            this.m_textBoxCommandLineItem.Size = new System.Drawing.Size(315, 20);
            this.m_textBoxCommandLineItem.TabIndex = 3;
            // 
            // m_textBoxCommandLineProject
            // 
            this.m_textBoxCommandLineProject.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.m_textBoxCommandLineProject.Location = new System.Drawing.Point(72, 18);
            this.m_textBoxCommandLineProject.Name = "m_textBoxCommandLineProject";
            this.m_textBoxCommandLineProject.Size = new System.Drawing.Size(315, 20);
            this.m_textBoxCommandLineProject.TabIndex = 1;
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.Location = new System.Drawing.Point(9, 47);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(30, 13);
            this.label2.TabIndex = 2;
            this.label2.Text = "&Item:";
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(9, 21);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(43, 13);
            this.label1.TabIndex = 0;
            this.label1.Text = "&Project:";
            // 
            // NUnitExecutableUserControl
            // 
            this.Controls.Add(this.m_groupBox);
            this.Name = "NUnitExecutableUserControl";
            this.Size = new System.Drawing.Size(414, 133);
            this.m_groupBox.ResumeLayout(false);
            this.m_commandLinegroupBox.ResumeLayout(false);
            this.m_commandLinegroupBox.PerformLayout();
            this.ResumeLayout(false);

        }

        #endregion

    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The zlib/libpng License


Written By
Software Developer (Senior)
Croatia Croatia
Graduated at the Faculty of Electrical Engineering and Computing, University of Zagreb (Croatia) and received M.Sc. degree in electronics. For several years he was research and lecturing assistant in the fields of solid state electronics and electronic circuits, published several scientific and professional papers, as well as a book "Physics of Semiconductor Devices - Solved Problems with Theory" (in Croatian).
During that work he gained interest in C++ programming language and have co-written "C++ Demystified" (in Croatian), 1st edition published in 1997, 2nd in 2001, 3rd in 2010, 4th in 2014.
After book publication, completely switched to software development, programming mostly in C++ and in C#.
In 2016 coauthored the book "Python for Curious" (in Croatian).

Comments and Discussions