Author Topic: Using a Palette for testing Routines.  (Read 2055 times)

0 Members and 1 Guest are viewing this topic.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Using a Palette for testing Routines.
« on: January 11, 2008, 06:29:14 PM »

It's Saturday ..my playday.
I've noticed when testing routines I invariably forget the name of the command I have defined, and after a couple of days forget what each one does.

So .. I thought I'd make a menu for Function testing ; with a description displayed for each command.

This is simply a Dockable Palette as a Front-End for the Methods.
In this case I'm using buttons to run the commands, but I Imagine a ComboBox would work just as well.

I'll post the code and solution later if anyone is interested.

The obligatory Piccy :
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<--

Glenn R

  • Water Moccasin
  • Posts: 1932
  • What idiot child of married cousins wrote this?!
Re: Using a Palette for testing Routines.
« Reply #1 on: January 11, 2008, 06:36:30 PM »
Please do kerry - I for one, am always interested in your experiences with C#, as you wade through it...it is a lot of fun at the end of the day.

Cheers,
Glenn.
Me

Bryco

  • Water Moccasin
  • Posts: 1855
Re: Using a Palette for testing Routines.
« Reply #2 on: January 12, 2008, 01:57:46 PM »
Me too.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Using a Palette for testing Routines.
« Reply #3 on: January 12, 2008, 08:41:02 PM »
Attached Zip is the Solution for the Palette with buttons.
I'll post the Palette with ComboBox solution later.

The code is in the next post.
I've built this for AC2008 in VS2008 with NET3.5.

The Palette is currently loaded automagically during the initialization from this :
public class StartApp : IExtensionApplication
..

Yell if there are problems .. ;-)
« Last Edit: January 12, 2008, 08:59:38 PM by Kerry Brown »
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<--

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Using a Palette for testing Routines.
« Reply #4 on: January 12, 2008, 08:51:28 PM »
Commands.cs
// CodeHimBelongaKwb   Jan 2008

using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.Windows.Forms;

// using System.Runtime.InteropServices;

using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;

using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application;
using AcAp = Autodesk.AutoCAD.ApplicationServices;
using AcDb = Autodesk.AutoCAD.DatabaseServices;
using AcEd = Autodesk.AutoCAD.EditorInput;
using AcGe = Autodesk.AutoCAD.Geometry;
using AcRx = Autodesk.AutoCAD.Runtime;
using AcWin = Autodesk.AutoCAD.Windows;
using WinForms = System.Windows.Forms;

[assembly: AcRx.ExtensionApplication(typeof(kdub.Testing.Commands.StartApp))]
[assembly: AcRx.CommandClass(typeof(kdub.Testing.Commands.TestStuff))]

namespace kdub.Testing.Commands
{
    //===========================================
    public class StartApp : IExtensionApplication
    {
        public void Initialize()
        {
            Editor ed = AcadApp.DocumentManager.MdiActiveDocument.Editor;
            ed.WriteMessage("\n\nTestRig Commands Loading ...");
            ed.WriteMessage("\nType TestRig_B for Button Menu, ");
            ed.WriteMessage("\nType TestRig_C for Combo Menu. ");

            kdub.Testing.FrontEnd.ButtonPaleteTestRig.ShowButtonPaletteTestRig();
        }
        //---------------------------------------
        public void Terminate()
        {
            // Does Nothing Yet, 'cause can't unload NET assembly ...
            //.... so, unloads automagically on close of AutoCad!

        }
    }
    //===========================================
    public static class TestStuff
    {
        [CommandMethod("Command_B1")]
        public static void ButtonCommand1()
        {
            MessageBox.Show("Pretend Button 1 Command is running",
                            "Button 1 Friendly Message");
        }
        //---------------------------------------
        [CommandMethod("Command_B2")]
        public static void ButtonCommand2()
        {
            MessageBox.Show("Pretend Button 2 Command is running",
                            "Button 2 Friendly Message");
        }
        //---------------------------------------
        [CommandMethod("Command_B3")]
        public static void ButtonCommand3()
        {
            MessageBox.Show("Pretend Button 3 Command is running",
                            "Button 3 Friendly Message");
        }
        //---------------------------------------
    }
    //===========================================
}


ButtonPage_Container.cs [Form code]

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
//////////////////////////////////////////////////////////////////////////
using kdub.Testing.Commands;
namespace kdub.Testing.FrontEnd
{
    public partial class ButtonPage_Container : UserControl
    {
        public ButtonPage_Container()
        {
            InitializeComponent();
        }
        private void PsContainer_Load(object sender, EventArgs e)
        {
            DescriptionText.Text = "Select Command Button";
        }
        //----------------------------------------------------
        private void button1_Click(object sender, EventArgs e)
        {
            kdub.Testing.Commands.TestStuff.ButtonCommand1();
        }
        private void button1_MouseEnter(object sender, EventArgs e)
        {
            DescriptionText.Text = "COMMAND_B1 : This is a description of the functionality for the command run from Button 1";
        }
        private void button1_MouseLeave(object sender, EventArgs e)
        {
            DescriptionText.Text = "Select Command Button";
        }
        //----------------------------------------------------

        private void button2_Click(object sender, EventArgs e)
        {
            kdub.Testing.Commands.TestStuff.ButtonCommand1();
        }
        private void button2_MouseEnter(object sender, EventArgs e)
        {
            DescriptionText.Text = "COMMAND_B2 : Button 2 Description goes here";
        }
        private void button2_MouseLeave(object sender, EventArgs e)
        {
            DescriptionText.Text = "Select Command Button";
        }
        //----------------------------------------------------
        private void button3_Click(object sender, EventArgs e)
        {
            kdub.Testing.Commands.TestStuff.ButtonCommand1();
        }
        private void button3_MouseEnter(object sender, EventArgs e)
        {
            DescriptionText.Text = "COMMAND_B3 :Button 3 Description goes here";
        }
        private void button3_MouseLeave(object sender, EventArgs e)
        {
            DescriptionText.Text = "Select Command Button";
        }
        //----------------------------------------------------
    }
}


ButtonPaleteTestRig.cs

// CodeHimBelongaKwb   Jan 2008

using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;

// using System.Runtime.InteropServices;

using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;
using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application;
using AcAp = Autodesk.AutoCAD.ApplicationServices;
using AcDb = Autodesk.AutoCAD.DatabaseServices;
using AcEd = Autodesk.AutoCAD.EditorInput;
using AcGe = Autodesk.AutoCAD.Geometry;
using AcRx = Autodesk.AutoCAD.Runtime;
using AcWin = Autodesk.AutoCAD.Windows;
using WinForms = System.Windows.Forms;

[assembly: AcRx.CommandClass(typeof(kdub.Testing.FrontEnd.ButtonPaleteTestRig))]

namespace kdub.Testing.FrontEnd
{
    public class ButtonPaleteTestRig
    {
        // declare a variable name for our PaletteSet and Pages
        public static AcWin.PaletteSet pSet;
        public static ButtonPage_Container pSetButtonPage;


        [AcRx.CommandMethod("TestRig_B")]
        static public void ShowButtonPaletteTestRig()
        {
            // Has the PaletteSet been created ?
            if (pSet == null)
            {
                // Create a new PaletteSet with a Guid.
                pSet = new AcWin.PaletteSet("Palette Set Name goes Here ... ",
                    new Guid("557448CD-85F8-4d30-9C0B-02DCC94FEC01"));

                pSet.Style =    AcWin.PaletteSetStyles.ShowPropertiesMenu |
                                AcWin.PaletteSetStyles.ShowAutoHideButton |
                                AcWin.PaletteSetStyles.Snappable |
                                AcWin.PaletteSetStyles.ShowCloseButton;
                               
                pSet.MinimumSize = new System.Drawing.Size(400, 90);
                pSet.Dock = AcWin.DockSides.Top;

                // Create the palette pages from the UserControl 'ButtonPage_Container'
                // Add the palette page 'pSetBottonPage'
                // to the PaletteSet pSet.
                pSetButtonPage = new ButtonPage_Container();
                pSet.Add("BottonPage", pSetButtonPage);
            }
            // display the PaletteSet
            pSet.Visible = true;
        }
    }
}




Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<--