Exemplo n.º 1
0
        /// <summary>
        /// Scan assembly for all classes that derive from class Command.
        /// </summary>
        /// <param name="commandTarget">The target the commands operate on.</param>
        /// <param name="csUnitCtrl">The CsUnitControl the commands operate on.</param>
        private static void FindCommandsFor(ICommandTarget commandTarget,
                                            CsUnitControl csUnitCtrl)
        {
            List <Assembly> assembliesToBeSearched = CreateListOfAssembliesToBeSearched(commandTarget);

            foreach (Assembly a in assembliesToBeSearched)
            {
                foreach (Type t in a.GetTypes())
                {
                    if (t.IsSubclassOf(typeof(Command)) &&
                        !t.IsAbstract)
                    {
                        ConstructorInfo ci = t.GetConstructor(new[] { typeof(ICommandTarget), typeof(CsUnitControl) });
                        try {
                            Commands.Add((Command)ci.Invoke(new object[] { commandTarget, csUnitCtrl }));
                        }
                        catch (Exception ex) {
                            System.Diagnostics.Debug.WriteLine("Invocation exception occured while constructing command: "
                                                               + t);
                            System.Diagnostics.Debug.WriteLine(ex.ToString());
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
 public SaveResultsAsXmlCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl)
     : base(commandTarget, csUnitCtrl, "&File", "Save Result As &XML...", _menuPosition, true)
 {
     _results              = new DefaultXmlWriter(RecipeFactory.Current, string.Empty);
     RecipeFactory.Loaded += RecipeFactory_Loaded;
     Enabled = false;
 }
Exemplo n.º 3
0
        public ViewToolBarCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl)
            : base(commandTarget, csUnitCtrl, "&View", "&Tool Bar", _menuPosition)
        {
            ConfigCurrentUser config = new ConfigCurrentUser();

            CommandTarget.ToolBarVisible = config.ToolBarVisible;
            Checked = config.ToolBarVisible;
        }
Exemplo n.º 4
0
      public TestAbortCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl)
         : base(commandTarget, csUnitCtrl, "&Test", "&Abort", _menuPosition, true) {
         _onRecipeStarted = OnRecipeStarted;
         _onRecipeFinishedOrAborted = OnRecipeFinishedOrAborted;

         RecipeFactory.Loaded += this.OnRecipeLoaded;
         RecipeFactory.Closing += OnRecipeClosing;
         HookupRecipe();
         Enabled = false;
      }
Exemplo n.º 5
0
 public RecentRecipesCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl)
     : base(commandTarget, csUnitCtrl, "&File", "Recent Recipes", RequestedMenuPosition, true)
 {
     _onRecipeLoaded = OnRecipeLoaded;
     _onRecipeSaved  = OnRecipeSaved;
     _recentRecipies = new RecentRecipies(commandTarget);
     _recentRecipies.AddRecipe(RecipeFactory.Current.PathName);
     RecipeFactory.Loaded        += _onRecipeLoaded;
     RecipeFactory.Current.Saved += _onRecipeSaved;
 }
Exemplo n.º 6
0
        public TestAbortCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl)
            : base(commandTarget, csUnitCtrl, "&Test", "&Abort", _menuPosition, true)
        {
            _onRecipeStarted           = OnRecipeStarted;
            _onRecipeFinishedOrAborted = OnRecipeFinishedOrAborted;

            RecipeFactory.Loaded  += this.OnRecipeLoaded;
            RecipeFactory.Closing += OnRecipeClosing;
            HookupRecipe();
            Enabled = false;
        }
Exemplo n.º 7
0
      public TestRunCheckedCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl)
         : base(commandTarget, csUnitCtrl, "&Test", "Run Checked", MenuPosition) {
         Enabled = false;
         _onRecipeLoaded += OnRecipeLoaded;
         _onRecipeClosing += OnRecipeClosing;
         _onRecipeStartedOrFinished += OnRecipeStartedOrFinished;

         CsUnitControl.CheckedItems.CollectionChanged += OnCheckedItemsChanged;
         RecipeFactory.Loaded += _onRecipeLoaded;
         RecipeFactory.Closing += _onRecipeClosing;
         HookupRecipe();
      }
Exemplo n.º 8
0
        /// <summary>
        /// Constructs a Command object. As Command is abstract only derived
        /// non-abstract classes can be instantiated. They internally should
        /// either call this constructor or the overloaded version which does not
        /// require the <code>insertLeadingSeparator</code> parameter.
        /// <param name="commandTarget">The commandTarget this command acts upon.</param>
        /// <param name="menuName">The name of the menu to which the item is
        /// added.</param>
        /// <param name="menuItemName">The name of the menu item.</param>
        /// <param name="position">The position where to add the menu item.</param>
        /// <param name="insertLeadingSeparator">If 'true' a separator will be added just
        /// before the menu item.</param>
        /// <remarks>The 'position' parameter is only the requested position. If
        /// a different command requests the same position then the implementation
        /// of the reflection functionality determines the actual order of the
        /// commands.</remarks>
        protected Command(ICommandTarget commandTarget, CsUnitControl csUnitCtrl,
                          string menuName, string menuItemName, int position, bool insertLeadingSeparator)
        {
            _commandTarget          = commandTarget;
            _csUnitCtrl             = csUnitCtrl;
            _menuItemName           = menuItemName;
            _menuName               = menuName;
            _desiredMenuPosition    = position;
            _insertLeadingSeparator = insertLeadingSeparator;

            CreateCommandFullName(menuName, menuItemName);
        }
Exemplo n.º 9
0
 public TestRunAllCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl)
    : base(commandTarget, csUnitCtrl, "&Test", "&Run All", MenuPosition, true) {
    _onRecipeLoaded = OnRecipeLoaded;
    _onRecipeClosing = OnRecipeClosing;
    _onOtherRecipeEvent = OnOtherRecipeEvent;
    _onAssemblyEvent = OnAssemblyEvent;
    
    RecipeFactory.Loaded += _onRecipeLoaded;
    RecipeFactory.Closing += _onRecipeClosing;
    HookupRecipe();
    UpdateEnabledStatus();
 }
Exemplo n.º 10
0
        public TestRunAllCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl)
            : base(commandTarget, csUnitCtrl, "&Test", "&Run All", MenuPosition, true)
        {
            _onRecipeLoaded     = OnRecipeLoaded;
            _onRecipeClosing    = OnRecipeClosing;
            _onOtherRecipeEvent = OnOtherRecipeEvent;
            _onAssemblyEvent    = OnAssemblyEvent;

            RecipeFactory.Loaded  += _onRecipeLoaded;
            RecipeFactory.Closing += _onRecipeClosing;
            HookupRecipe();
            UpdateEnabledStatus();
        }
Exemplo n.º 11
0
        private const int DesiredToolBarPosition = NoMenuEntry; // Context menu item only

        public TestRunThisCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl)
            : base(commandTarget, csUnitCtrl, "&Test", "Run This", MenuPosition)
        {
            Enabled            = false;
            _onRecipeFinished += OnRecipeFinished;
            _onRecipeLoaded   += OnRecipeLoaded;
            _onRecipeClosing  += OnRecipeClosing;

            CsUnitControl.SelectedItems.CollectionChanged += SelectedItemsChanged;
            RecipeFactory.Loaded  += _onRecipeLoaded;
            RecipeFactory.Closing += _onRecipeClosing;
            HookupRecipe();
        }
Exemplo n.º 12
0
        public RecentAssembliesCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl)
            : base(commandTarget, csUnitCtrl, "&Assembly", "Recent Assemblies", DesiredMenuPosition)
        {
            _onRecipeLoaded  = OnRecipeLoaded;
            _onRecipeClosing = OnRecipeClosing;
            _onAssemblyAdded = OnAssemblyAdded;

            _recentAssemblies = new RecentAssemblies();

            RecipeFactory.Loaded  += _onRecipeLoaded;
            RecipeFactory.Closing += _onRecipeClosing;
            RecipeFactory.Current.AssemblyAdded += _onAssemblyAdded;
        }
Exemplo n.º 13
0
      public TestRunFailedCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl)
         : base(commandTarget, csUnitCtrl, "&Test", "Run &Failed", _menuPosition, true) {
         Enabled = ! _failedTestCriterion.IsEmpty;
         _onRecipeLoaded = OnRecipeLoaded;
         _onRecipeClosing = OnRecipeClosing;
         _onTestErrorOrFail = OnTestErrorOrFail;
         _onAssemblyAdded = OnAssemblyAdded;
         _onAssemblyRemoving = OnAssemblyRemoving;

         RecipeFactory.Loaded += _onRecipeLoaded;
         RecipeFactory.Closing += _onRecipeClosing;
         HookupRecipe();
      }
Exemplo n.º 14
0
        public TestRunFailedCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl)
            : base(commandTarget, csUnitCtrl, "&Test", "Run &Failed", _menuPosition, true)
        {
            Enabled             = !_failedTestCriterion.IsEmpty;
            _onRecipeLoaded     = OnRecipeLoaded;
            _onRecipeClosing    = OnRecipeClosing;
            _onTestErrorOrFail  = OnTestErrorOrFail;
            _onAssemblyAdded    = OnAssemblyAdded;
            _onAssemblyRemoving = OnAssemblyRemoving;

            RecipeFactory.Loaded  += _onRecipeLoaded;
            RecipeFactory.Closing += _onRecipeClosing;
            HookupRecipe();
        }
Exemplo n.º 15
0
 public AboutCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl)
     : base(commandTarget, csUnitCtrl, "&Help", "&About...", _menuPosition, true)
 {
 }
Exemplo n.º 16
0
 public RecipeOpenCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl)
     : base(commandTarget, csUnitCtrl, "&File", "&Open Recipe...", RequestedMenuPosition)
 {
 }
Exemplo n.º 17
0
 /// <summary>
 /// Constructs a Command object. As Command is abstract only derived
 /// non-abstract classes can be instantiated. They internally should
 /// either call this constructor or the overloaded version which also
 /// supports the <code>insertLeadingSeparator</code> parameter.
 /// </summary>
 /// <param name="commandTarget">The commandTarget this command operates on.</param>
 /// <param name="csUnitCtrl">The CsUnitControl to operate on.</param>
 /// <param name="menuName">The name of the menu to which the item is
 /// added.</param>
 /// <param name="menuItemName">The name of the menu item.</param>
 /// <param name="position">The position where to add the menu item.</param>
 protected Command(ICommandTarget commandTarget, CsUnitControl csUnitCtrl,
                   string menuName, string menuItemName, int position)
     : this(commandTarget, csUnitCtrl, menuName, menuItemName, position, false)
 {
 }
Exemplo n.º 18
0
 /// <summary>
 /// Using reflection this static method creates all commands which can be
 /// found in the assembly in which class csUnit.Runner.Commands.Command is
 /// defined.
 /// </summary>
 /// <remarks>First this method scans the assembly in which class Command is
 /// defined. In step two, when all commands have been found, the commands
 /// are then used to fill the menus.</remarks>
 /// <param name="commandTarget">The commandTarget the command operates 
 /// on.</param>
 /// <param name="csUnitCtrl">The CsUnitControl the command operates on.
 /// </param>
 public static void CreateCommands(ICommandTarget commandTarget,
    CsUnitControl csUnitCtrl) {
    FindCommandsFor(commandTarget, csUnitCtrl);
    FillMainMenuStrip(commandTarget.MainMenuStrip);
 }
Exemplo n.º 19
0
 public ShowFindPanelCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl)
    : base(commandTarget, csUnitCtrl, "&View", "&Find Panel", _menuPosition, true) {
    CsUnitControl.FindPanel.Visible = false;
 }
Exemplo n.º 20
0
 /// <summary>
 /// Constructs a Command object. As Command is abstract only derived 
 /// non-abstract classes can be instantiated. They internally should 
 /// either call this constructor or the overloaded version which also
 /// supports the <code>insertLeadingSeparator</code> parameter.
 /// </summary>
 /// <param name="commandTarget">The commandTarget this command operates on.</param>
 /// <param name="csUnitCtrl">The CsUnitControl to operate on.</param>
 /// <param name="menuName">The name of the menu to which the item is 
 /// added.</param>
 /// <param name="menuItemName">The name of the menu item.</param>
 /// <param name="position">The position where to add the menu item.</param>
 protected Command(ICommandTarget commandTarget, CsUnitControl csUnitCtrl,
    string menuName, string menuItemName, int position)
    : this(commandTarget, csUnitCtrl, menuName, menuItemName, position, false) {
 }
Exemplo n.º 21
0
 /// <summary>
 /// Instantiates the command.
 /// </summary>
 /// <param name="commandTarget">The form to act upon.</param>
 /// <param name="csUnitCtrl">The control on which to operate</param>
 public RecipeSaveAsCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl)
     : base(commandTarget, csUnitCtrl, "&File", "Save Recipe &As...", DesiredMenuPosition)
 {
 }
Exemplo n.º 22
0
 public FileExitCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl)
     : base(commandTarget, csUnitCtrl, "&File", "E&xit", _menuPosition, true)
 {
 }
Exemplo n.º 23
0
 public ShowFindPanelCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl)
     : base(commandTarget, csUnitCtrl, "&View", "&Find Panel", _menuPosition, true)
 {
     CsUnitControl.FindPanel.Visible = false;
 }
 public GotoOnlineDocumentationCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl)
     : base(commandTarget, csUnitCtrl, "&Help", "Online &Documentation", _menuPosition)
 {
 }
Exemplo n.º 25
0
 /// <summary>
 /// Using reflection this static method creates all commands which can be
 /// found in the assembly in which class csUnit.Runner.Commands.Command is
 /// defined.
 /// </summary>
 /// <remarks>First this method scans the assembly in which class Command is
 /// defined. In step two, when all commands have been found, the commands
 /// are then used to fill the menus.</remarks>
 /// <param name="commandTarget">The commandTarget the command operates
 /// on.</param>
 /// <param name="csUnitCtrl">The CsUnitControl the command operates on.
 /// </param>
 public static void CreateCommands(ICommandTarget commandTarget,
                                   CsUnitControl csUnitCtrl)
 {
     FindCommandsFor(commandTarget, csUnitCtrl);
     FillMainMenuStrip(commandTarget.MainMenuStrip);
 }
Exemplo n.º 26
0
 public ReportBugCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl)
     : base(commandTarget, csUnitCtrl, "&Help", "Report a Bug", _menuPosition)
 {
 }
Exemplo n.º 27
0
 public ViewOptionsCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl)
     : base(commandTarget, csUnitCtrl, "&View", "&Options...", _menuPosition, true)
 {
 }
Exemplo n.º 28
0
      /// <summary>
      /// Constructs a Command object. As Command is abstract only derived 
      /// non-abstract classes can be instantiated. They internally should 
      /// either call this constructor or the overloaded version which does not
      /// require the <code>insertLeadingSeparator</code> parameter.
      /// <param name="commandTarget">The commandTarget this command acts upon.</param>
      /// <param name="menuName">The name of the menu to which the item is 
      /// added.</param>
      /// <param name="menuItemName">The name of the menu item.</param>
      /// <param name="position">The position where to add the menu item.</param>
      /// <param name="insertLeadingSeparator">If 'true' a separator will be added just 
      /// before the menu item.</param>
      /// <remarks>The 'position' parameter is only the requested position. If
      /// a different command requests the same position then the implementation
      /// of the reflection functionality determines the actual order of the
      /// commands.</remarks>
      protected Command(ICommandTarget commandTarget, CsUnitControl csUnitCtrl, 
         string menuName, string menuItemName, int position, bool insertLeadingSeparator) {
         _commandTarget = commandTarget;
         _csUnitCtrl = csUnitCtrl;
         _menuItemName = menuItemName;
         _menuName = menuName;
         _desiredMenuPosition = position;
         _insertLeadingSeparator = insertLeadingSeparator;

         CreateCommandFullName(menuName, menuItemName);
      }
Exemplo n.º 29
0
      /// <summary>
      /// Scan assembly for all classes that derive from class Command.
      /// </summary>
      /// <param name="commandTarget">The target the commands operate on.</param>
      /// <param name="csUnitCtrl">The CsUnitControl the commands operate on.</param>
      private static void FindCommandsFor(ICommandTarget commandTarget,
         CsUnitControl csUnitCtrl) {
         List<Assembly> assembliesToBeSearched = CreateListOfAssembliesToBeSearched(commandTarget);

         foreach( Assembly a in assembliesToBeSearched ) {
            foreach( Type t in a.GetTypes() ) {
               if( t.IsSubclassOf(typeof(Command))
                  && !t.IsAbstract ) {
                  ConstructorInfo ci = t.GetConstructor(new[] { typeof(ICommandTarget), typeof(CsUnitControl) });
                  try {
                     Commands.Add((Command) ci.Invoke(new object[] { commandTarget, csUnitCtrl }));
                  }
                  catch( Exception ex ) {
                     System.Diagnostics.Debug.WriteLine("Invocation exception occured while constructing command: "
                        + t);
                     System.Diagnostics.Debug.WriteLine(ex.ToString());
                  }
               }
            }
         }
      }
Exemplo n.º 30
0
 public AssemblyRemoveCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl)
     : base(commandTarget, csUnitCtrl, "&Assembly", "&Remove", MenuPosition, true)
 {
     Enabled = false;
     CsUnitControl.SelectedItems.CollectionChanged += SelectedItemsCollectionChanged;
 }
Exemplo n.º 31
0
 public CheckForUpdatesCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl)
     : base(commandTarget, csUnitCtrl, "&Help", "Chec&k for Updates", _menuPosition, true)
 {
 }
Exemplo n.º 32
0
 public AssemblyReloadCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl)
     : base(commandTarget, csUnitCtrl, "&Assembly", "R&eload", MenuPosition)
 {
     Enabled = false;
     CsUnitControl.SelectedItems.CollectionChanged += OnSelectedItemsChanged;
 }
Exemplo n.º 33
0
 public RecipeSaveCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl)
     : base(commandTarget, csUnitCtrl, "&File", "&Save Recipe", _menuPosition)
 {
 }
Exemplo n.º 34
0
 public AssemblyAddCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl)
     : base(commandTarget, csUnitCtrl, "&Assembly", "&Add...", DesiredMenuPosition, true)
 {
 }