Version 1.0, 26 November 2012
View Toolbar Addins
This plugin adds some extra tool bar buttons to CamBam's View tool bar strip.
These provide the following functions:
ISO : View isometric projection.
XY : View the XY plane.
XZ : View the XZ plane.
YZ : View the YZ plane.
The source code is also provided and demonstrates adding to the existing toolbars using a custom plugin,
as well as how to programmatically change the current view projection.
Download
Plugin
download ViewToolbarAddins-1.0.zip (3 KB)
Source
download ViewToolbarAddins-1.0-source.zip (3 KB)
Installation
To install the plugin, unzip ViewToolbarAddins.dll into the CamBam plugins folder.
If the installation is successful, you should see 4 new entries on the CamBam View tool bar, with text labels 'ISO', 'XY', 'XZ' and 'YZ'.
Source
ViewToolbarPlugin.cs
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using CamBam;
using CamBam.Geom;
using CamBam.CAD;
using CamBam.UI;
namespace ViewToolbarAddins
{
    public class ViewToolbarPlugin
    {
        public static void InitPlugin(CamBamUI ui)
        {
            ThisApplication.TopWindow.Load += new EventHandler(TopWindow_Load);
        }
        static void TopWindow_Load(object sender, EventArgs e)
        {
            Form f = ThisApplication.TopWindow;
            foreach (Control c in f.Controls)
            {
                if (c is ToolStripContainer)
                {
                    ToolStripContainer tsc = (ToolStripContainer)c;
                    foreach (Control cc in tsc.TopToolStripPanel.Controls)
                    {
                        if (cc is ViewToolStrip)
                        {
                            ViewToolStrip vts = cc as ViewToolStrip;
                            ToolStripItem ti = vts.Items.Add("ISO");
                            ti.Click += new EventHandler(ViewISO_Click);
                            ti.ToolTipText = "ISO View";
                            ti = vts.Items.Add("XY");
                            ti.Click += new EventHandler(ViewXY_Click);
                            ti.ToolTipText = "XY View";
                            ti = vts.Items.Add("XZ");
                            ti.Click += new EventHandler(ViewXZ_Click);
                            ti.ToolTipText = "XZ View";
                            ti = vts.Items.Add("YZ");
                            ti.Click += new EventHandler(ViewYZ_Click);
                            ti.ToolTipText = "YZ View";
                            // ti.ImageTransparentColor = Color.Magenta;
                            break;
                        }
                    }
                    break;
                }
            }
        }
        static void ViewISO_Click(object sender, EventArgs e)
        {
            if (CamBamUI.MainUI.ActiveView == null) return;
            ViewProjection vp = CamBamUI.MainUI.ActiveView.ViewProjection;
            Matrix4x4F vt = Matrix4x4F.Identity;
            vt.Scale(vp.ViewMatrix4x4F.GetScale());
            vt.RotZ(-Math.PI / 4);
            vt.RotX(-Math.Asin(Math.Tan(Math.PI / 6)));
            vt.Translate(vp.ViewMatrix4x4F.m[12], vp.ViewMatrix4x4F.m[13], vp.ViewMatrix4x4F.m[14]);
            vp.ViewMatrix4x4F = vt;
            CamBamUI.MainUI.ActiveView.RefreshView();
        }
        static void ViewXY_Click(object sender, EventArgs e)
        {
            if (CamBamUI.MainUI.ActiveView == null) return;
            CamBamUI.MainUI.ActiveView.ViewProjection.ViewXYPlane();
            CamBamUI.MainUI.ActiveView.RefreshView();
        }
        static void ViewXZ_Click(object sender, EventArgs e)
        {
            if (CamBamUI.MainUI.ActiveView == null) return;
            CamBamUI.MainUI.ActiveView.ViewProjection.ViewXZPlane();
            CamBamUI.MainUI.ActiveView.RefreshView();
        }
        static void ViewYZ_Click(object sender, EventArgs e)
        {
            if (CamBamUI.MainUI.ActiveView == null) return;
            CamBamUI.MainUI.ActiveView.ViewProjection.ViewYZPlane();
            CamBamUI.MainUI.ActiveView.RefreshView();
        }
    }
}
Version 1.0